Skip to content

Commit

Permalink
fix n_alignments not initalized (resolves #19)
Browse files Browse the repository at this point in the history
The number of alignments (em.n_alignments) is filled in by
do_initial_mapping. We skip that step if a bam file is
provided on the command line, so we must count the
number of alignments in the file before going on.
  • Loading branch information
epruesse committed Feb 26, 2016
1 parent dc32058 commit aa905f8
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions emirge_amplicon.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@
import pysam
import numpy
from scipy import sparse
from subprocess import Popen, PIPE, check_call, CalledProcessError
from subprocess import Popen, PIPE, check_call, CalledProcessError, check_output
from time import ctime, time
from datetime import timedelta
import gzip
Expand Down Expand Up @@ -723,7 +723,7 @@ def write_consensus_with_mask(self, reference_fastafilename, output_fastafilenam
i2base_get = self.i2base.get # for speed
of = file(output_fastafilename, 'w')
reference_fastafile = pysam.Fastafile(reference_fastafilename)

for seq_i in range(len(self.probN)):
if self.probN[seq_i] is None:
continue
Expand Down Expand Up @@ -1547,7 +1547,11 @@ def main(argv = sys.argv[1:]):
# DO INITIAL MAPPING if not provided with --mapping
if options.mapping is None:
options.mapping = do_initial_mapping(em, working_dir, options)

else:
# otherwise, count number of alignments in bamfile
em.n_alignments = int(check_output(["samtools", "view", "-c", "-F",
"0x100", options.mapping],
close_fds=True))

# if >= this percentage of bases are minor alleles, split candidate sequence
em.snp_percentage_thresh = options.snp_fraction_thresh
Expand Down

0 comments on commit aa905f8

Please sign in to comment.