[Tutor] question...

Danny Yoo dyoo at hkn.eecs.berkeley.edu
Tue Feb 21 01:13:49 CET 2006



On Mon, 20 Feb 2006, Samantha Warbey wrote:

> I have blocks of text (in notebook files currently) that I need to read
> 3 and analyse 3 characters at a time. [This is because I'm studying
> genes and codons are three characters in length]. How do I do this using
> python? I've currently only been able to find ways of analysing text
> line by line, but as I read, this text is all in one long string.

Hi Samantha,

Let's try to break the problem down to smaller easier pieces, and see
where you're getting stuck.

Consider the smaller problem of taking a single string, say:

    "ATGATC"

Would you know how to write a function called firstCodon() that grabs the
first three residues from an given input string?  So, for example, if we
had firstCodon, we might expect:

    firstCodon("ATGATC")   ==>  "ATG"

Is writing something like firstCodon() something you'd be able to do?
We're just trying to get a better sense at where you're getting stuck.



You may be interested in:

    http://wiki.python.org/moin/BeginnersGuide/NonProgrammers

which is a list of beginner tutorials for Python.


If you have more questions, please feel free to ask.  Good luck to you!



More information about the Tutor mailing list