1
1
#!/usr/bin/env python
2
2
# -*- coding: utf-8 -*-
3
3
4
- """usage: blobtools bam2cov -i FASTA -b BAM [--mq MQ] [--no_base_cov]
4
+ """usage: blobtools bam2cov -i FASTA -b BAM [-o PREFIX] [- -mq MQ] [--no_base_cov]
5
5
[-h|--help]
6
6
7
7
Options:
8
8
-h --help show this
9
9
-i, --infile FASTA FASTA file of assembly. Headers are split at whitespaces.
10
10
-b, --bam <BAM> BAM file (requires samtools in $PATH)
11
+ -o, --output <PREFIX> Output prefix
11
12
--mq <MQ> minimum Mapping Quality (MQ) [default: 1]
12
13
--no_base_cov only parse read coverage (faster, but ...
13
14
can only be used for "blobtools blobplot --noblobs")
@@ -65,6 +66,7 @@ def readFasta(infile):
65
66
66
67
def parseFasta (infile ):
67
68
fasta_dict = {}
69
+ print BtLog .status_d ['1' ] % ("FASTA" , fasta_f )
68
70
for name , seq in readFasta (infile ):
69
71
fasta = Fasta (name , seq )
70
72
fasta_dict [fasta .name ] = fasta
@@ -124,6 +126,7 @@ def parseBam(bam_f, fasta_dict):
124
126
return fasta_dict , reads_total , reads_mapped
125
127
126
128
def writeCov (fasta_dict , reads_total , reads_mapped , out_f ):
129
+ print BtLog .status_d ['13' ] % out_f
127
130
with open (out_f , 'w' ) as fh :
128
131
fh .write ("# Total Reads = %s\n " % (reads_total ))
129
132
fh .write ("# Mapped Reads = %s\n " % (reads_mapped ))
@@ -135,10 +138,15 @@ def writeCov(fasta_dict, reads_total, reads_mapped, out_f):
135
138
136
139
if __name__ == '__main__' :
137
140
args = docopt (__doc__ )
138
-
139
141
fasta_f = args ['--infile' ]
140
142
bam_f = args ['--bam' ]
141
143
out_f = os .path .basename (bam_f ) + ".cov"
144
+ prefix = args ['--output' ]
145
+ if (prefix ):
146
+ if prefix .endswith ("/" ):
147
+ out_f = prefix + out_f
148
+ else :
149
+ out_f = prefix + "." + out_f
142
150
mq = int (args ['--mq' ])
143
151
no_base_cov_flag = args ['--no_base_cov' ]
144
152
0 commit comments