Skip to content

Commit

Permalink
Merge branch 'dev' of research/pomoxis into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
cjw85 committed Jan 24, 2020
2 parents 3a01981 + 337caac commit c493771
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
2 changes: 1 addition & 1 deletion pomoxis/__init__.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
__version__ = '0.3.0'
__version__ = '0.3.1'

import argparse
import os
Expand Down
7 changes: 6 additions & 1 deletion pomoxis/subsample_bam.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,8 @@ def main():
help='Filter reads by accuracy.')
parser.add_argument('-c', '--coverage', type=float,
help='Filter reads by coverage (what fraction of the read aligns).')
parser.add_argument('-l', '--length', type=int, default=None,
help='Filter reads by read length.')

eparser = parser.add_mutually_exclusive_group()
eparser.add_argument('--any_fail', action='store_true',
Expand Down Expand Up @@ -157,14 +159,17 @@ def filter_read(r, bam, args, logger):
return True

# filter accuracy or alignment coverage
if args.accuracy is not None or args.coverage is not None:
if args.accuracy is not None or args.coverage is not None or args.length is not None:
stats = stats_from_aligned_read(r, bam.references, bam.lengths)
if args.accuracy is not None and stats['acc'] < args.accuracy:
logger.info("Filtering {} by accuracy ({:.2f}).".format(r.query_name, stats['acc']))
return True
if args.coverage is not None and stats['coverage'] < args.coverage:
logger.info("Filtering {} by coverage ({:.2f}).".format(r.query_name, stats['coverage']))
return True
if args.length is not None and stats['read_length'] < args.length:
logger.info("Filtering {} by length ({:.2f}).".format(r.query_name, stats['length']))
return True
# don't filter
return False

Expand Down

0 comments on commit c493771

Please sign in to comment.