view splitFasta.py @ 4:ae4d5733272f draft

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/splitfasta commit 03f3cc2000e6ce876a3cb44c55c3fe878a2e7ce3-dirty
author rnateam
date Fri, 16 Oct 2015 16:13:34 -0400
parents bc25ba9d9fcf
children
line wrap: on
line source

#!/usr/bin/env python
import os
import sys
from Bio import SeqIO

if __name__ == "__main__":
    inpath = sys.argv[1]
    os.mkdir('splits')
    with open(inpath, 'r') as handle:
        for record in SeqIO.parse(handle, 'fasta'):
            header = os.path.join('splits', record.id + '.fasta')
            with open(header, 'w') as handle2:
                SeqIO.write([record], handle2, 'fasta')