Skip to content

Instantly share code, notes, and snippets.

@ychaouche
Created October 14, 2012 15:47
Show Gist options
  • Select an option

  • Save ychaouche/3888973 to your computer and use it in GitHub Desktop.

Select an option

Save ychaouche/3888973 to your computer and use it in GitHub Desktop.
better version of the lazy ADN parse
is_valid_sequence = lambda x:all(character in "ACTG" for character in x)
>>> is_valid_sequence("ACTG")
True
>>> is_valid_sequence("ACTGAAA")
True
>>> is_valid_sequence("ACTGa")
False
>>>
@anshumanv2
Copy link

sir will u give me code for these diff fuctionss I'm nt geting the desired result
1.
Header insert_sequence:
Type Contract (str, str, int) -> str

The first two parameters are DNA sequences and the third parameter is an index. Return the DNA sequence obtained by inserting the second DNA sequence into the first DNA sequence at the given index. (You can assume that the index is valid.)
For example, If you call this function with arguments 'CCGG', 'AT', and 2, then it should return 'CCATGG'.
When coming up with more examples, think about where the second DNA sequence might be inserted: what are the extremes?
.......................................................................................................................................................................................................................................
2.
Header get_complement:
Type Contract (str) -> str
Description:
The first parameter is a nucleotide ('A', 'T', 'C' or 'G'). Return the nucleotide's complement.
..........................................................................................................................................................................................................................
3.
Header get_complementary_sequence:
Type Contract( str) -> str

Description:
The parameter is a DNA sequence. Return the DNA sequence that is complementary to the given DNA sequence.
For exmaple, if you call this function with 'AT' as the argument, it should return 'TA'.
plzzzz sirr

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment