Module Expr Str Import alias Import alias Import alias Import alias FunctionDef arguments args NameParam defaults NameLoad body If NameLoad body Print NameLoad Print NameLoad Print Str Expr Call AttributeLoad NameLoad attr Num decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam defaults NameLoad ListLoad Str Str NameLoad body Assign NameStore Call AttributeLoad NameLoad attr NameLoad Str Assign NameStore Call AttributeLoad NameLoad attr BinOpMod Str NameLoad Str keyword NameLoad If NameLoad body Assign NameStore Call AttributeLoad NameLoad attr BinOpMod Str NameLoad Str keyword NameLoad For NameStore Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad keyword NameLoad body Assign NameStore NameLoad Assign NameStore ListLoad Assign NameStore ListLoad For NameStore NameLoad body If UnaryOpNot AttributeLoad NameLoad attr body Assign NameStore ListLoad For NameStore NameLoad body Assign NameStore Call NameLoad Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Slice Num If CompareEq SubscriptLoad NameLoad Index Num Str body Assign NameStore UnaryOpUSub NameLoad Expr Call AttributeLoad NameLoad attr NameLoad If BoolOpOr UnaryOpNot NameLoad CompareGt NameLoad NameLoad body If BoolOpAnd NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore NameLoad Assign NameStore ListLoad NameLoad orelse If CompareEq NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad orelse If NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad If NameLoad body For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad NameLoad If NameLoad body Expr Call AttributeLoad NameLoad attr Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad NameLoad decorator_list If CompareEq NameLoad Str body Assign NameStore NameLoad Assign NameStore NameLoad Assign NameStore NameLoad Assign NameStore NameLoad Assign NameStore ListLoad For NameStore SubscriptLoad AttributeLoad NameLoad attr Slice Num body If CompareEq NameLoad Str body Expr Call NameLoad orelse If CompareEq NameLoad Str body Expr Call AttributeLoad NameLoad attr NameLoad Assign NameStore NameLoad orelse If CompareEq NameLoad Str body Assign NameStore NameLoad Assign NameStore NameLoad orelse If CompareIn NameLoad ListLoad Str Str body Assign NameStore NameLoad orelse If BoolOpAnd UnaryOpNot NameLoad Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad body Assign NameStore NameLoad orelse If UnaryOpNot NameLoad body Assign NameStore NameLoad orelse Expr Call NameLoad BinOpMod Str NameLoad If UnaryOpNot NameLoad body Assign NameStore ListLoad Str Str If BoolOpOr UnaryOpNot NameLoad UnaryOpNot NameLoad body Expr Call NameLoad orelse Expr Call NameLoad NameLoad NameLoad NameLoad NameLoad
N/A N/A 
Given a BAM file sorted by read name with potentially multiple mappings, this
will remove all but the best mapping.

The value of the attribute/tag given will be used to determine which reads
should be kept and which should be discarded. The tag should be a numeric
(int/float) type. Multiple tags may be used. This defaults to 'AS+, NM-'.
 N/A os N/A sys N/A pysam N/A ngsutils.bam usage N/A N/A msg N/A None N/A N/A msg N/A N/A msg N/A __doc__ N/A 
Usage: bamutils best {opts} input.bam output.bam

Options
  -tag VAL    Tag to use to determine from which file reads will be taken.
              (must be type :i or :f) You may have more than one of these,
              in which case they will be sorted in order. You can add a +/-
              at the end of the name to signify sort order (asc/desc). 
              [default: AS+, NM-]

  -fail filename.bam    Write all failed mappings to this file.

 N/A N/A N/A sys exit 1 N/A bam_best N/A N/A infile outfile failfile tags quiet N/A None N/A AS+ NM- False N/A N/A inbam N/A N/A pysam Samfile infile rb N/A outbam N/A N/A pysam Samfile N/A %s.tmp outfile wb template inbam N/A failfile N/A N/A failbam N/A N/A pysam Samfile N/A %s.tmp failfile wb template inbam N/A reads N/A N/A N/A ngsutils bam bam_batch_reads inbam quiet quiet N/A N/A best_val None N/A best_reads N/A N/A failed N/A N/A read reads N/A N/A N/A N/A read is_unmapped N/A N/A tag_val N/A N/A tag tags N/A N/A val N/A float N/A N/A read opt N/A tag N/A 2 N/A N/A N/A tag N/A -1 - N/A N/A val N/A val N/A N/A N/A tag_val append val N/A N/A N/A best_val N/A tag_val best_val N/A N/A N/A best_reads failfile N/A N/A N/A N/A failed extend best_reads N/A best_val tag_val N/A best_reads N/A read N/A N/A N/A tag_val best_val N/A N/A N/A N/A best_reads append read N/A N/A failfile N/A N/A N/A N/A failed append read N/A read best_reads N/A N/A N/A N/A outbam write read N/A failfile N/A N/A read failed N/A N/A N/A N/A failbam write read N/A N/A N/A outbam close N/A N/A N/A os rename N/A %s.tmp outfile outfile N/A failfile N/A N/A N/A N/A failbam close N/A N/A N/A os rename N/A %s.tmp failfile failfile N/A N/A N/A __name__ __main__ N/A N/A infile None N/A outfile None N/A failfile None N/A last None N/A tags N/A N/A arg N/A N/A sys argv N/A 1 N/A N/A N/A arg -h N/A N/A N/A usage N/A N/A N/A last -tag N/A N/A N/A N/A tags append arg N/A last None N/A N/A N/A last -fail N/A N/A failfile arg N/A last None N/A N/A N/A arg N/A -tag -fail N/A N/A last arg N/A N/A N/A N/A infile N/A N/A N/A os path exists arg N/A N/A infile arg N/A N/A N/A outfile N/A N/A outfile arg N/A N/A N/A usage N/A Unknown option: %s arg N/A N/A tags N/A N/A tags N/A AS+ NM- N/A N/A N/A infile N/A outfile N/A N/A N/A usage N/A N/A N/A bam_best infile outfile failfile tags