[Tutor] next element in list

rahmad akbar matbioinfo at gmail.com
Wed Feb 26 10:35:31 CET 2014


hey guys

i have this file i wish to parse, the file looks something like bellow.
there are only four entry here (AaaI, AacLI, AaeI, AagI). the complete file
contains thousands of entries

    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=
    REBASE, The Restriction Enzyme Database   http://rebase.neb.com
    Copyright (c)  Dr. Richard J. Roberts, 2014.   All rights reserved.
    =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=

Rich Roberts                                                    Jan 30 2014

AaaI (XmaIII)                     C^GGCCG
AacLI (BamHI)                     GGATCC
AaeI (BamHI)                      GGATCC
AagI (ClaI)                       AT^CGAT


the strategy was to mark the string 'Rich Roberts' as the start. i wrote
the following function. but then i realized i couldn't do something like
.next() to the var in_file which is a list. so i added a flag start = False
in which will be turned to True upon 'Rich Roberts' found. is the any
simpler way to move to the next element in the list. like built in method
or something like that.

def read_bionet(bionetfile):
  res_enzime_dict = {}
  in_file = open(bionetfile, 'r').readlines()
  start = False
  for line in in_file:
    if line.startswith('Rich Roberts'):
      start = True
    if start and len(line) >= 10:
        line = line.split()
        res_enzime_dict[line[0]] = line[-1]
  return res_enzime_dict


-- 
many thanks
mat
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140226/277dd45d/attachment.html>


More information about the Tutor mailing list