Skip to content

Commit 7702a22

Browse files
Dom LaetschDom Laetsch
Dom Laetsch
authored and
Dom Laetsch
committed
v0.9.16
- added version number - added license - added prefix option for bam2cov - added old function names again as aliases ("plot", "comparecov")
1 parent a29f9d6 commit 7702a22

File tree

3 files changed

+17
-5
lines changed

3 files changed

+17
-5
lines changed

bam2cov.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
#!/usr/bin/env python
22
# -*- coding: utf-8 -*-
33

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]
55
[-h|--help]
66
77
Options:
88
-h --help show this
99
-i, --infile FASTA FASTA file of assembly. Headers are split at whitespaces.
1010
-b, --bam <BAM> BAM file (requires samtools in $PATH)
11+
-o, --output <PREFIX> Output prefix
1112
--mq <MQ> minimum Mapping Quality (MQ) [default: 1]
1213
--no_base_cov only parse read coverage (faster, but ...
1314
can only be used for "blobtools blobplot --noblobs")
@@ -65,6 +66,7 @@ def readFasta(infile):
6566

6667
def parseFasta(infile):
6768
fasta_dict = {}
69+
print BtLog.status_d['1'] % ("FASTA", fasta_f)
6870
for name, seq in readFasta(infile):
6971
fasta = Fasta(name, seq)
7072
fasta_dict[fasta.name] = fasta
@@ -124,6 +126,7 @@ def parseBam(bam_f, fasta_dict):
124126
return fasta_dict, reads_total, reads_mapped
125127

126128
def writeCov(fasta_dict, reads_total, reads_mapped, out_f):
129+
print BtLog.status_d['13'] % out_f
127130
with open(out_f, 'w') as fh:
128131
fh.write("# Total Reads = %s\n" % (reads_total))
129132
fh.write("# Mapped Reads = %s\n" % (reads_mapped))
@@ -135,10 +138,15 @@ def writeCov(fasta_dict, reads_total, reads_mapped, out_f):
135138

136139
if __name__ == '__main__':
137140
args = docopt(__doc__)
138-
139141
fasta_f = args['--infile']
140142
bam_f = args['--bam']
141143
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
142150
mq = int(args['--mq'])
143151
no_base_cov_flag = args['--no_base_cov']
144152

blobtools

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@
55
usage: blobtools <command> [<args>...] [--help]
66
77
commands:
8+
version print version number
9+
810
create create a BlobDB
911
view print BlobDB as a table
1012
blobplot plot BlobDB as a blobplot
@@ -26,20 +28,21 @@ from docopt import docopt
2628
if __name__ == '__main__':
2729
main_dir = join(dirname(__file__), '')
2830
args = docopt(__doc__,
29-
version='version 0.9.13',
31+
version='blobtools v0.9.16',
3032
options_first=True)
31-
#print(args)
3233

3334
argv = [args['<command>']] + args['<args>']
3435
if args['<command>'] == 'create':
3536
exit(call(['python', main_dir + 'create.py'] + argv))
3637
elif args['<command>'] == 'view':
3738
exit(call(['python', main_dir + 'view.py'] + argv))
3839
elif args['<command>'] == 'blobplot' or args['<command>'] == 'plot':
40+
argv[0] = "blobplot"
3941
exit(call(['python', main_dir + 'blobplot.py'] + argv))
4042
elif args['<command>'] == 'bam2cov':
4143
exit(call(['python', main_dir + 'bam2cov.py'] + argv))
4244
elif args['<command>'] == 'covplot' or args['<command>'] == 'comparecov':
45+
argv[0] = "blobplot"
4346
exit(call(['python', main_dir + 'covplot.py'] + argv))
4447
elif args['<command>'] == 'sumcov':
4548
exit(call(['python', main_dir + 'sumcov.py'] + argv))

lib/BtLog.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,8 @@ def progress(iteration, steps, max_value):
8080
'9' : '[STATUS]\t: Reading BlobDb %s',
8181
'10': '[STATUS]\t: \tChecking with \'samtools flagstat\'',
8282
'11': '[STATUS]\t: \tMapping reads = %s, total reads = %s (mapping rate = %s)',
83-
'12': '[STATUS]\t: \tChecking with \'clc_mapping_info\''
83+
'12': '[STATUS]\t: \tChecking with \'clc_mapping_info\'',
84+
'13': '[STATUS]\t: \tWriting %s'
8485
}
8586

8687
info_d = {

0 commit comments

Comments
 (0)