Hello,

Try this:

import sys

fasta_file = sys.argv[1]  # should be *.fa
print 'loading dna from', fasta_file
chroms = {}
dna = []
for l in open(fasta_file):
    if l.startswith('>'):  # new chromosome
        if len(dna) > 0:
            chroms[chrom] = ''.join(dna)
        chrom = l.strip().replace('>', '')
        dna = []
    else:
        dna.append(l.rstrip())
if len(dna) > 0:
    chroms[chrom] = ''.join(dna)

-- 
Vincent Legoll
_______________________________________________
pypy-dev mailing list
[email protected]
http://mail.python.org/mailman/listinfo/pypy-dev

Reply via email to