Mercurial > repos > rnateam > splitfasta
annotate splitFasta.py @ 0:f6d6b62540f8 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:08 -0400 |
parents | |
children |
rev | line source |
---|---|
0
f6d6b62540f8
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/splitfasta commit 03f3cc2000e6ce876a3cb44c55c3fe878a2e7ce3-dirty
rnateam
parents:
diff
changeset
|
1 #!/usr/bin/env python |
f6d6b62540f8
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/splitfasta commit 03f3cc2000e6ce876a3cb44c55c3fe878a2e7ce3-dirty
rnateam
parents:
diff
changeset
|
2 import os |
f6d6b62540f8
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/splitfasta commit 03f3cc2000e6ce876a3cb44c55c3fe878a2e7ce3-dirty
rnateam
parents:
diff
changeset
|
3 import sys |
f6d6b62540f8
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/splitfasta commit 03f3cc2000e6ce876a3cb44c55c3fe878a2e7ce3-dirty
rnateam
parents:
diff
changeset
|
4 from Bio import SeqIO |
f6d6b62540f8
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/splitfasta commit 03f3cc2000e6ce876a3cb44c55c3fe878a2e7ce3-dirty
rnateam
parents:
diff
changeset
|
5 |
f6d6b62540f8
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/splitfasta commit 03f3cc2000e6ce876a3cb44c55c3fe878a2e7ce3-dirty
rnateam
parents:
diff
changeset
|
6 if __name__ == "__main__": |
f6d6b62540f8
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/splitfasta commit 03f3cc2000e6ce876a3cb44c55c3fe878a2e7ce3-dirty
rnateam
parents:
diff
changeset
|
7 inpath = sys.argv[1] |
f6d6b62540f8
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/splitfasta commit 03f3cc2000e6ce876a3cb44c55c3fe878a2e7ce3-dirty
rnateam
parents:
diff
changeset
|
8 os.mkdir('splits') |
f6d6b62540f8
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/splitfasta commit 03f3cc2000e6ce876a3cb44c55c3fe878a2e7ce3-dirty
rnateam
parents:
diff
changeset
|
9 with open(inpath, 'r') as handle: |
f6d6b62540f8
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/splitfasta commit 03f3cc2000e6ce876a3cb44c55c3fe878a2e7ce3-dirty
rnateam
parents:
diff
changeset
|
10 for record in SeqIO.parse(handle, 'fasta'): |
f6d6b62540f8
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/splitfasta commit 03f3cc2000e6ce876a3cb44c55c3fe878a2e7ce3-dirty
rnateam
parents:
diff
changeset
|
11 header = os.path.join('splits', record.id + '.fasta') |
f6d6b62540f8
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/splitfasta commit 03f3cc2000e6ce876a3cb44c55c3fe878a2e7ce3-dirty
rnateam
parents:
diff
changeset
|
12 with open(header, 'w') as handle2: |
f6d6b62540f8
planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/splitfasta commit 03f3cc2000e6ce876a3cb44c55c3fe878a2e7ce3-dirty
rnateam
parents:
diff
changeset
|
13 SeqIO.write([record], handle2, 'fasta') |