# Name of the input file
fh = open('out22.fas')
# Name of the output file
newfh = open('out3.fas','w')
for line in fh:
    if line.startswith('>'):
        line = line.replace('\n','')+' [Rattus norvegicus]\n'
    newfh.write(line)
newfh.close(); fh.close()

This code is part of the book "Python for Bioinformatics", by Sebastian Bassi (sbassi@genesdigitales.com). Return to home page.