[Tutor] Biology and introductory programming?

Danny Yoo dyoo@hkn.eecs.berkeley.edu
Mon, 26 Nov 2001 17:02:22 -0800 (PST)


Hi everyone,

Just out of curiosity, how many of us here have an interest in
"bioinformatics"?  I've just bought the book "Beginning Perl for
Bioinformatics", and it appears to be an introductory test for biologists
who are trying to smash their brains against Perl.  *grin*


In all seriousness though, it looks like a great book for people who
haven't programmed before.  Kirby has mentioned using Python to play
around with mathematical ideas; the same synergy would probably work with
molecular biology too.  Using molecular biology as a motivater for
learning a programming language looks really exciting!


For example, we can start talking about a DNA fragment:

###
dna = "ATTAAGCATTAAA"
###


and show how we can "mutate" such an example by zapping it:

###
def mutate(dna):
    """Introduce a single point mutation into a sequence of dna."""
    bases = ['A', 'T', 'G', 'C']
    position_of_mutation = random.randrange(len(dna))
    original_nucleotide = dna[position_of_mutation]
    bases.remove(original_nucleotide)
    return (dna[:position_of_mutation]
            + random.choice(bases)
            + dna[position_of_mutation + 1:])
###


Here's an test of the DNA mutation:

###
>>> mutate('AAAAA')                             ## Zap!
'AAACA'
>>> mutate(mutate('AAAAA'))
'AATCA'
>>> mutate(mutate(mutate('AAAAA')))
'ATAGG'
###


Molecular biology is very much about structure and sequences, so this sort
of stuff seems easy to approach from a programming standpoint.