-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathseq_stat.py
More file actions
23 lines (19 loc) · 734 Bytes
/
seq_stat.py
File metadata and controls
23 lines (19 loc) · 734 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
from collections import Counter
from Bio import SeqIO
from optparse import OptionParser
#inputFile,outputFile = "",""
parser = OptionParser()
parser.add_option("-i","--input",dest="inputFile",help="input fasta/multi-fasta file (protein/nucleotide).")
parser.add_option("-o","--output",dest="outputFile",help="output file name (tab-separated).")
(options,args) = parser.parse_args()
inputFile = options.inputFile
outputFile = options.outputFile
out = open(outputFile,"w")
for record in SeqIO.parse(inputFile,"fasta"):
header = record.id
seq = str(record.seq)
temp = Counter(seq)
out.write(header+"\t")
for i,j in temp.items():
out.write(i+"="+str(j)+"\t")
out.write("SeqLength="+str(len(seq))+"\n")