Skip to content

Commit

Permalink
move unambig_count function into viral-core
Browse files Browse the repository at this point in the history
  • Loading branch information
dpark01 committed Nov 5, 2019
1 parent d606698 commit 6393c51
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 8 deletions.
2 changes: 1 addition & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM quay.io/broadinstitute/viral-core:2.0.7
FROM quay.io/broadinstitute/viral-core:2.0.8

LABEL maintainer "[email protected]"

Expand Down
9 changes: 2 additions & 7 deletions assembly.py
Original file line number Diff line number Diff line change
Expand Up @@ -736,7 +736,7 @@ def impute_from_reference(

# error if PoorAssembly
minLength = len(refSeqObj) * minLengthFraction
non_n_count = unambig_count(asmSeqObj.seq)
non_n_count = util.misc.unambig_count(asmSeqObj.seq)
seq_len = len(asmSeqObj)
log.info(
"Assembly Quality - segment {idx} - name {segname} - contig len {len_actual} / {len_desired} ({min_frac}) - unambiguous bases {unamb_actual} / {unamb_desired} ({min_unamb})".format(
Expand Down Expand Up @@ -1053,11 +1053,6 @@ def parser_refine_assembly(parser=argparse.ArgumentParser()):
__commands__.append(('refine_assembly', parser_refine_assembly))


def unambig_count(seq):
unambig = set(('A', 'T', 'C', 'G'))
return sum(1 for s in seq if s.upper() in unambig)


def parser_filter_short_seqs(parser=argparse.ArgumentParser()):
parser.add_argument("inFile", help="input sequence file")
parser.add_argument("minLength", help="minimum length for contig", type=int)
Expand All @@ -1083,7 +1078,7 @@ def main_filter_short_seqs(args):
Bio.SeqIO.write(
[
s for s in Bio.SeqIO.parse(inf, args.format)
if len(s) >= args.minLength and unambig_count(s.seq) >= len(s) * args.minUnambig
if len(s) >= args.minLength and util.misc.unambig_count(s.seq) >= len(s) * args.minUnambig
], outf, args.output_format
)
return 0
Expand Down

0 comments on commit 6393c51

Please sign in to comment.