Skip to content

Instantly share code, notes, and snippets.

@fhucho
Created October 21, 2012 10:59
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save fhucho/3926681 to your computer and use it in GitHub Desktop.
Save fhucho/3926681 to your computer and use it in GitHub Desktop.
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