[Tutor] Deleting strings from a line

Spyros Charonis s.charonis at gmail.com
Tue Apr 26 13:54:54 CEST 2011


Hello,

I've written a script that scans a biological database and extracts some
information. A sample of output from my script is as follows:

LYLGILLSHAN                      AA3R_SHEEP    263    31

 LYMGILLSHAN                      AA3R_HUMAN    264    31

 MCLGILLSHAN                        AA3R_RAT    266    31

 LLVGILLSHAN                      AA3R_RABIT    265    31

The leftmost strings are the ones I want to keep, while I would like to get
rid of the ones to the right (AA3R_SHEEP, 263 61) which are just indicators
of where the sequence came from and genomic coordinates. Is there any way to
do this with a string processing command? The loop which builds my list goes
like this:

 for line in query_lines:
            if line.startswith('fd;'):  # find motif sequences
                #print "Found an FD for your query!",
line.rstrip().lstrip('fd;')
                print line.lstrip('fd;')
                motif.append(line.rstrip().lstrip('fd;'))

Is there a del command I can use to preserve only the actual sequences
themselves. Many thanks in advance!
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110426/a5c6924f/attachment.html>


More information about the Tutor mailing list