On Thu, Aug 6, 2009 at 6:28 PM, Iain King <iaink...@gmail.com> wrote:
> > print >>nucleotides, seq[-76] > > > last_part = line.rstrip()[-76 : ] > > You all mean: seq[:-76] , right? (assuming you've already stripped > any junk off the end of the string) > I think so, probably both of them typo'd. (What are the probabilities of that?) It looks to me like you have two lines per DNA sequence. What you could do instead, is to alternate the line reading with a with statement, as suggested by Jan. Although I don't know why he's nesting two of them. (explanation would be neat.) Here's my version of approach, given the sample data the OP posted: with open('NodeList.txt', 'r') as file: for line in file.readlines(): line = line.rstrip() if line[0] == '>': # Do for New DNA Sequence # ... else: line = line[:-76] # ... Should do what you need. Best regards, Ching-Yun "Xavier" Ho, Technical Artist Contact Information Mobile: (+61) 04 3335 4748 Skype ID: SpaXe85 Email: cont...@xavierho.com Website: http://xavierho.com/
-- http://mail.python.org/mailman/listinfo/python-list