-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsequenceLength.py
More file actions
executable file
·45 lines (29 loc) · 1.02 KB
/
sequenceLength.py
File metadata and controls
executable file
·45 lines (29 loc) · 1.02 KB
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
37
38
39
40
41
42
43
44
45
#!/home/GLBRCORG/mplace/anaconda3/bin/python
"""
program: sequenceLength.py
purpose: print out seqence name and length of sequence
for a fasta file.
usage: sequenceLength.py -f input.fasta
input: a fasta file
output: text to stdout,
seqName,Length
seq1,129383
By Mike Place
"""
from Bio import SeqIO
import argparse
def main():
"""
Process command line arguments
"""
cmdparser = argparse.ArgumentParser( description="Count sequence lengths in a fasta file",
prog='sequenceLength.py')
cmdparser.add_argument('-f', '--file', action='store', required='true',
dest='FILE', help='Required: fasta input file (.fasta, .fsa, .fa )')
cmdResults = vars( cmdparser.parse_args() )
if cmdResults['FILE'] is not None:
inFile = cmdResults['FILE']
for seqRec in SeqIO.parse(str(inFile), "fasta"):
print( "%s,%i" %(seqRec.id, len(seqRec)))
if __name__ == "__main__":
main()