Hey I am a newbie at python and I need some help. I've written down the following code:
try:
it = iter(cmLines)
line=it.next()
while (line):
if ("INFERNAL1/a" in line) or ("HMMER3/f" in line) :
title = line
line = it.next()
if word2(line) in namesList: //if second word in line is in list
output.write(title)
output.write(line)
line = it.next()
while ("//" not in line):
output.write(line)
line = it.next()
output.write(line)
line = it.next()
except Exception as e:
print "Loop exited becuase:"
print type(e)
print "at " + line
finally:
output.close()
When the loop ends it always throws an Exception that notifies that the loop stopped. Even though it didn't terminate prematurely. How do I stop that?
Is there a better way to write my code? Something more stylish. I have a big file that has lots of information and I am trying to catch only the information I need. Every slice of information is of the format:
Infernal1/a ... Name someSpecificName ... ... ... ... //
Thank you