-
Notifications
You must be signed in to change notification settings - Fork 0
/
concatenatefasta.py
36 lines (28 loc) · 1.09 KB
/
concatenatefasta.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import optparse
from Bio import SeqIO
import os
import pandas as pd
import sys
parser = optparse.OptionParser(usage='python %prog -f [ "input file 1" ] -f [ "input file 2"] -o [ "Output Id" ] -o [ "Output Pathway" ] ',version='1.0',)
parser.add_option('-f', action="append", dest='input', default=[])
parser.add_option('-o', action="store", dest="output",help='Output Id')
parser.add_option('-p', action="store", dest="pathout",help='Output Pathway')
options, args = parser.parse_args()
class concatenatefasta(object):
def __init__(self,input,output,pathout):
self.input = input
self.output = output
self.pathout = pathout
if pathout.endswith('/') == True:
self.path_out = pathout
else:
self.path_out = pathout+'/'
def confasta(self):
with open(self.pathout+self.output+'.fasta', 'w') as outfile:
for fname in self.input:
with open(fname) as infile:
for line in infile:
outfile.write(line)
if __name__ == '__main__':
print('Concatenate FastA file : %s' % (options.input))
a = concatenatefasta(options.input,options.output,options.pathout).confasta()