Last active
August 29, 2015 14:12
-
-
Save kescobo/ee69d7fd087c3e3192ca to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
#open file to read | |
with open('test.fasta', 'r') as seqs: | |
seqFile = (open('throwaway.txt', 'a+')) | |
for line in seqs: | |
if re.search('^>[a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z]', line): | |
seqFile.close() | |
seqFile = open('%s.fasta' % line, 'a+') | |
seqs.next() | |
else: | |
seqFile.write('%s' % line) | |
seqFile.close() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import re | |
#open file to read | |
with open('test.fasta', 'r') as seqs: | |
#seqFile = (open('throwaway.txt', 'a+')) | |
mydict = {} | |
for line in seqs: | |
if re.search('^>[a-zA-Z][a-zA-Z][a-zA-Z][a-zA-Z]', line): | |
fileName = line + '.fasta' | |
if fileName not in mydict: | |
mydict[fileName] = open(fileName, 'a+') | |
seqs.next() | |
else: | |
#seqFile.write('%s' % line) | |
mydict[fileName].write('%s' % line) | |
seqFile.close() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment