Python Help!!!

Nathan Harmston ratchetgrid at
Wed Jun 13 19:19:00 CEST 2007

Hi, you could try this:

    def parse(self, ifile):
        for line in open(ifile, 'r'):
            if '>'==line[0]:
                if id!="" and len(seq)>0:
                    yield id,seq
                    seq = ""
            elif id!="":
                for word in line.split():
                    seq += word
        if id!="" and len(seq)>0:
            yield id,seq

    for id, seq in parse("some.fa"):
        print "%s \n %s" %(id, seq)

Its adapted from the fasta parser in PyGr.

>From what I understand biopython isnt very active and I think theres a
re-factor of it going on at the moment in the form of corebio.

Hope this helps;



More information about the Python-list mailing list