Created
February 15, 2012 23:37
-
-
Save SavinaRoja/1840071 to your computer and use it in GitHub Desktop.
Another .seq to .fa converter, except this one dumps all the data into a single .fa file with multiple entries.
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 os | |
import os.path | |
def main(): | |
outdir = 'FASTA' | |
if not os.path.isdir(outdir): | |
os.mkdir(outdir) | |
with open(os.path.join(outdir, 'bundled_seqs.fa'), 'w') as output: | |
for s in os.listdir(os.getcwd()): | |
r, e = os.path.splitext(s) | |
if e.lower() == '.seq': | |
newfile = '{0}.fa'.format(r) | |
with open(s, 'r') as inp: | |
output.write('>{0}\n'.format(r)) | |
output.write(inp.read()) | |
output.write('\n') | |
if __name__ == '__main__': | |
main() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment