Skip to content

Instantly share code, notes, and snippets.

@SavinaRoja
Created February 15, 2012 23:37
Show Gist options
  • Save SavinaRoja/1840071 to your computer and use it in GitHub Desktop.
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.
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