Created
October 21, 2012 10:59
-
-
Save fhucho/3926681 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def get_length(dna): | |
return len(dna) | |
def is_longer(dna1, dna2): | |
return len(dna1) > len(dna2) | |
def count_nucleotides(dna, nucleotide): | |
return dna.count(nucleotide) | |
def contains_sequence(dna1, dna2): | |
return dna1.find(dna2) >= 0 | |
def is_valid_sequence(dna): | |
for c in seq: | |
if not c in ['A', 'C', 'G', 'T']: return False | |
return True | |
def insert_sequence(dna1, dna2, index): | |
return dna1[:index] + dna2 + dna1[index:] | |
def get_complement(c): | |
if c == 'A': return 'T' | |
elif c == 'T': return 'A' | |
elif c == 'C': return 'G' | |
elif c == 'G': return 'C' | |
def get_complementary_sequence(dna1): | |
dna2 = '' | |
for c in dna1: | |
dna2 += get_complement(c) | |
return dna2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment