[Tutor] Logical Structure of Snippet
Alan Gauld
alan.gauld at btinternet.com
Tue May 24 01:54:57 CEST 2011
"Spyros Charonis" <s.charonis at gmail.com> wrote
>>P1; ICA1_HUMAN
> AAEVDTG..... (A very long sequence of letters)
>
> I must extract one of the data fields from the database (done this)
> and place it in the sequence file (structure shown above). The
> relevant
> database fields go like:
>
> tt; ICA1_HUMAN Description
> tt; ICA1_BOVIN Description
> tt; ICA2_HUMAN Description
>
> What I would like is to extract the tt; fields (I already have code
> for
> that) and then to read through the sequence file and insert the
> TT field corresponding to the >P1 header right underneath
> the >P1 header. Basically, I need a newline everytime >P1
> occurs in the sequence file and I need to paste
> its corresponding TT field in that newline
> the pseudocode would go like this:
modified to:
for line sequence file:
insert line
if line.startswith('>P1; ICA ....)
go to list with extracted tt; fields*
find the one with the same query (tt; ICA1 ...)*
insert this field as a newline
> The steps marked * are the ones I am not sure how to implement. What
> logical structure would I need to make Python match a tt; field
What about a dictionary keyed by field type?
HTH,
--
Alan Gauld
Author of the Learn to Program web site
http://www.alan-g.me.uk/
More information about the Tutor
mailing list