Module Expr Str Import alias Import alias Import alias ImportFrom alias alias ImportFrom alias Import alias Assign NameStore Call AttributeLoad NameLoad attr Call AttributeLoad NameLoad attr Num Num FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam NameParam NameParam defaults Num Num NameLoad NameLoad NameLoad body Expr Str Assign NameStore Dict If NameLoad body AugAssignAdd NameStore Str Assign SubscriptStore NameLoad Index Str Call AttributeLoad NameLoad attr BinOpMod NameLoad Str Str orelse Assign SubscriptStore NameLoad Index Str Call NameLoad BinOpMod NameLoad Str Str Assign NameStore Dict For NameStore NameLoad body If NameLoad body Assign SubscriptStore NameLoad Index NameLoad Call AttributeLoad NameLoad attr BinOpMod NameLoad NameLoad Str orelse Assign SubscriptStore NameLoad Index NameLoad Call NameLoad BinOpMod NameLoad NameLoad Str Assign SubscriptStore NameLoad Index NameLoad Num Assign NameStore Num Assign NameStore Num Assign NameStore Num Assign NameStore Num Assign NameStore Num For NameStore Call AttributeLoad NameLoad attr body Assign TupleStore NameStore TupleStore NameStore NameStore NameStore NameStore Call NameLoad NameLoad AttributeLoad NameLoad attr NameLoad NameLoad NameLoad If UnaryOpNot NameLoad body AugAssignAdd NameStore Num Assign NameStore BinOpMod Str TupleLoad NameLoad SubscriptLoad SubscriptLoad NameLoad Index NameLoad Index Num IfExp NameLoad Str Str AttributeLoad NameLoad attr AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad Expr Call AttributeLoad Call AttributeLoad NameLoad attr NameLoad NameLoad NameLoad attr SubscriptLoad NameLoad Index Str orelse AugAssignAdd NameStore Num If CompareEq AttributeLoad NameLoad attr Num body If BoolOpOr CompareEq AttributeLoad NameLoad attr Num CompareEq AttributeLoad NameLoad attr Call NameLoad AttributeLoad NameLoad attr body AugAssignAdd NameStore Num orelse AugAssignAdd NameStore Num orelse AugAssignAdd NameStore Num Assign NameStore BinOpMod Str TupleLoad NameLoad IfExp NameLoad Str Str AttributeLoad NameLoad attr AttributeLoad NameLoad attr If UnaryOpNot SubscriptLoad SubscriptLoad NameLoad Index NameLoad Index Num body Expr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index NameLoad orelse If NameLoad body If CompareEq SubscriptLoad SubscriptLoad NameLoad Index NameLoad Index Num Str body Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad NameLoad orelse Assign NameStore BinOpAdd BinOpAdd Call NameLoad SubscriptLoad SubscriptLoad NameLoad Index NameLoad Index Num NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad BinOpMult Num BinOpSub NameLoad AttributeLoad NameLoad attr NameLoad orelse If CompareEq SubscriptLoad SubscriptLoad NameLoad Index NameLoad Index Num Str body Assign NameStore BinOpAdd BinOpAdd Call NameLoad SubscriptLoad SubscriptLoad NameLoad Index NameLoad Index Num NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad BinOpMult Num BinOpSub NameLoad AttributeLoad NameLoad attr NameLoad orelse Assign NameStore Call AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad NameLoad Expr Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index NameLoad AugAssignAdd SubscriptStore NameLoad Index NameLoad Num For NameStore NameLoad body Expr Call AttributeLoad SubscriptLoad NameLoad Index NameLoad attr If NameLoad body With Call NameLoad NameLoad Str NameStore body Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad Expr Call AttributeLoad NameLoad attr BinOpMod Str NameLoad Expr Call AttributeLoad NameLoad attr Str For NameStore NameLoad body Expr Call AttributeLoad NameLoad attr BinOpMod Str TupleLoad NameLoad SubscriptLoad NameLoad Index NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults Num Num body Assign NameStore BinOpSub AttributeLoad NameLoad attr AttributeLoad NameLoad attr Assign NameStore BinOpAdd BinOpSub NameLoad NameLoad AttributeLoad NameLoad attr If CompareLtE NameLoad NameLoad body If BoolOpAnd CompareEq NameLoad Str CompareLtE AttributeLoad NameLoad attr NameLoad body Return TupleLoad NameLoad Str orelse If BoolOpAnd CompareEq NameLoad Str CompareGtE AttributeLoad NameLoad attr BinOpSub NameLoad NameLoad body Return TupleLoad NameLoad Str orelse Return TupleLoad NameLoad Str orelse Return TupleLoad NameLoad Str Return TupleLoad NameLoad Str decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam NameParam NameParam defaults NameLoad NameLoad body Expr Str Assign NameStore NameLoad For NameStore NameLoad body Assign TupleStore NameStore NameStore NameStore SubscriptLoad NameLoad Index NameLoad If CompareEq NameLoad Str body Assign NameStore SubscriptLoad NameLoad Slice BinOpAdd BinOpAdd Call NameLoad NameLoad NameLoad NameLoad orelse Assign NameStore SubscriptLoad NameLoad Slice BinOpMult Num BinOpAdd BinOpAdd Call NameLoad NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad NameLoad Assign TupleStore NameStore NameStore Call NameLoad NameLoad Call NameLoad NameLoad Call NameLoad NameLoad NameLoad NameLoad NameLoad If NameLoad body Print BinOpMod Str TupleLoad Call NameLoad SubscriptLoad NameLoad Index NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Print NameLoad NameLoad If NameLoad body Return TupleLoad NameLoad TupleLoad NameLoad NameLoad NameLoad Str If BoolOpOr UnaryOpNot NameLoad CompareGt AttributeLoad NameLoad attr AttributeLoad SubscriptLoad NameLoad Index Num attr body Assign NameStore TupleLoad NameLoad NameLoad NameLoad NameLoad If NameLoad body If CompareEq NameLoad Str body Assign NameStore SubscriptLoad NameLoad Slice BinOpMult Num BinOpAdd BinOpAdd Call NameLoad NameLoad NameLoad NameLoad orelse Assign NameStore SubscriptLoad NameLoad Slice BinOpAdd BinOpAdd Call NameLoad NameLoad NameLoad NameLoad Assign NameStore Call AttributeLoad NameLoad attr Call NameLoad NameLoad NameLoad Assign TupleStore NameStore NameStore Call NameLoad NameLoad Call NameLoad NameLoad Call NameLoad NameLoad IfExp CompareEq NameLoad Str Str Str NameLoad NameLoad If NameLoad body Print BinOpMod Str TupleLoad Call NameLoad SubscriptLoad NameLoad Index NameLoad NameLoad Expr Call AttributeLoad NameLoad attr Print NameLoad NameLoad If NameLoad body Return TupleLoad NameLoad TupleLoad NameLoad NameLoad NameLoad Str If BoolOpOr UnaryOpNot NameLoad CompareGt AttributeLoad NameLoad attr AttributeLoad SubscriptLoad NameLoad Index Num attr body Assign NameStore TupleLoad NameLoad NameLoad NameLoad NameLoad If NameLoad body Print Str NameLoad Expr Call AttributeLoad SubscriptLoad NameLoad Index Num attr Return TupleLoad NameLoad NameLoad decorator_list FunctionDef arguments args defaults body Expr Call AttributeLoad AttributeLoad NameLoad attr attr BinOpMod Str NameLoad Expr Call AttributeLoad AttributeLoad NameLoad attr attr BinOpMod Str Call AttributeLoad AttributeLoad NameLoad attr attr SubscriptLoad AttributeLoad NameLoad attr Index Num Expr Call AttributeLoad NameLoad attr Num decorator_list FunctionDef arguments args NameParam defaults body Expr Str If CompareEq SubscriptLoad NameLoad Slice Num Str body Assign NameStore Call AttributeLoad NameLoad attr NameLoad orelse Assign NameStore Call NameLoad NameLoad TryExcept body While NameLoad body Assign NameStore Call AttributeLoad NameLoad attr If CompareEq SubscriptLoad NameLoad Index Num Str body Expr Call AttributeLoad NameLoad attr Return NameLoad orelse If CompareEq SubscriptLoad NameLoad Index Num Str body Expr Call AttributeLoad NameLoad attr Return NameLoad handlers ExceptHandler body Expr Call AttributeLoad NameLoad attr Raise Call NameLoad Str decorator_list If CompareEq NameLoad Str body Assign NameStore NameLoad Assign NameStore NameLoad Assign NameStore NameLoad Assign NameStore Num Assign NameStore Num Assign NameStore NameLoad Assign NameStore NameLoad Assign NameStore NameLoad Assign NameStore NameLoad For NameStore SubscriptLoad AttributeLoad NameLoad attr Slice Num body If CompareEq NameLoad Str body Assign NameStore Call NameLoad NameLoad Assign NameStore NameLoad orelse If CompareEq NameLoad Str body Assign NameStore Call NameLoad NameLoad Assign NameStore NameLoad orelse If CompareIn NameLoad ListLoad Str Str body Assign NameStore NameLoad orelse If CompareEq NameLoad Str body Assign NameStore NameLoad orelse If CompareEq NameLoad Str body Assign NameStore NameLoad orelse If CompareEq NameLoad Str body Assign NameStore NameLoad orelse If BoolOpAnd UnaryOpNot NameLoad Call AttributeLoad AttributeLoad NameLoad attr attr NameLoad body Assign NameStore Dict With Call NameLoad NameLoad NameStore body Assign NameStore NameLoad For NameStore NameLoad body If NameLoad body Assign NameStore NameLoad Continue Assign NameStore Call AttributeLoad Call AttributeLoad NameLoad attr attr Str If CompareLt Call NameLoad NameLoad Num body Expr Call AttributeLoad NameLoad attr Str Assign SubscriptStore NameLoad Index SubscriptLoad NameLoad Index Num TupleLoad SubscriptLoad NameLoad Index Num SubscriptLoad NameLoad Index Num IfExp CompareIn SubscriptLoad NameLoad Index Num Str NameLoad 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 If BoolOpOr UnaryOpNot NameLoad UnaryOpNot NameLoad UnaryOpNot NameLoad body Expr Call NameLoad If Call NameLoad NameLoad body Assign NameStore BinOpMod Str NameLoad Assign NameStore Call NameLoad NameLoad orelse Assign NameStore BinOpMod Str NameLoad Assign NameStore Call NameLoad NameLoad If NameLoad body Assign NameStore BinOpMod Str NameLoad orelse Assign NameStore NameLoad Expr Call NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad NameLoad
N/A N/A 
Given a FASTA/FASTQ file and a list of barcodes (name and seq),
the FASTA/FASTQ file is split into N number of new files representing
the reads for each barcode. The format of the input file is determined
automatically. The barcode will be removed from read sequence (and quality
score if FASTQ).

barcode input format:
tagname	sequence	orientation (5 or 3)	strip tag? (y/n, optional - default y)

The output files will be named: out_template_tagname.fast[qa]

Reads missing a barcode (or if the tag is too degenerate) will be written to:
out_template_missing.fast[qa]

Note: This is a slow method using a Smith-Waterman alignment algorithm. It is
      primarily useful with data that is inherently noisy, such as PacBio
      sequencing reads. For less-noisy sequences, a faster, non-alignment
      approach will be better.

Note 2: This isn't appropriate for color-space FASTQ files with a prefix base
        included in the read sequence, since it trims an equal number of bases
        from the sequence and quality FASTQ lines.
 N/A sys N/A os N/A gzip ngsutils.support revcomp FASTA ngsutils.fastq FASTQ N/A swalign N/A sw N/A N/A swalign LocalAlignment N/A N/A swalign NucleotideScoringMatrix 2 -1 fastx_barcode_split N/A N/A reader outtempl barcodes edits pos allow_revcomp gzip_output stats_fname N/A 0 0 False False None N/A N/A 
    Split FAST[QA] reads from {fname} using {barcodes} (hash) to write them to
    output files named like {templ}.
     N/A outs N/A N/A gzip_output N/A N/A outtempl .gz N/A N/A outs N/A N/A N/A gzip open N/A outtempl missing w N/A N/A N/A outs N/A N/A open N/A outtempl missing w N/A tag_count N/A N/A tag barcodes N/A N/A gzip_output N/A N/A N/A outs N/A tag N/A N/A gzip open N/A outtempl tag w N/A N/A N/A outs N/A tag N/A open N/A outtempl tag w N/A N/A tag_count N/A tag 0 N/A matched 0 N/A perfect 0 N/A mismatched 0 N/A mispositioned 0 N/A missing 0 N/A record N/A N/A reader fetch N/A N/A N/A ismatch N/A tag aln is_forward reason N/A check_tags barcodes N/A record seq edits pos allow_revcomp N/A N/A ismatch N/A N/A missing 1 N/A comment N/A #guess: %s, %s%s (%s, %s, %smm) %s N/A tag N/A N/A barcodes N/A tag N/A 0 N/A is_forward [rc] N/A aln q_pos N/A aln extended_cigar_str N/A aln mismatches reason N/A N/A N/A N/A N/A record subseq None None comment write N/A outs N/A N/A N/A matched 1 N/A N/A N/A aln mismatches 0 N/A N/A N/A N/A N/A aln q_pos 0 N/A N/A aln q_end N/A len N/A record seq N/A N/A perfect 1 N/A N/A mispositioned 1 N/A N/A mismatched 1 N/A comment N/A #%s%s (%s, %s) N/A tag N/A is_forward [rc] N/A aln q_pos N/A aln mismatches N/A N/A N/A N/A barcodes N/A tag N/A 2 N/A N/A N/A N/A record write N/A outs N/A tag N/A N/A is_forward N/A N/A N/A N/A N/A barcodes N/A tag N/A 1 5 N/A N/A newrec N/A N/A record subseq N/A aln q_end None comment N/A N/A subseqlen N/A N/A N/A len N/A N/A barcodes N/A tag N/A 0 edits pos N/A newrec N/A N/A record subseq None N/A -1 N/A subseqlen N/A aln q_pos comment N/A N/A N/A N/A N/A barcodes N/A tag N/A 1 5 N/A N/A subseqlen N/A N/A N/A len N/A N/A barcodes N/A tag N/A 0 edits pos N/A newrec N/A N/A record subseq None N/A -1 N/A subseqlen N/A aln q_pos comment N/A N/A newrec N/A N/A record subseq N/A aln q_end None comment N/A N/A N/A newrec write N/A outs N/A tag N/A N/A tag_count N/A tag 1 N/A tag outs N/A N/A N/A N/A N/A outs N/A tag close N/A stats_fname N/A N/A N/A open stats_fname w f N/A N/A N/A N/A f write N/A Unmatched	%s
 missing N/A N/A N/A f write N/A Matched	%s
 matched N/A N/A N/A f write N/A  Perfect	%s
 perfect N/A N/A N/A f write N/A  Mismatched	%s
 mismatched N/A N/A N/A f write N/A  Mispositioned	%s
 mispositioned N/A N/A N/A f write N/A tag tag_count N/A N/A N/A N/A f write N/A Tag	%s	%s
 N/A tag N/A tag_count N/A tag N/A _tag_aln_check N/A N/A aln seqlen barcodelen orientation edit pos N/A 0 0 N/A N/A r_len N/A N/A aln r_end N/A aln r_pos N/A mismatches N/A N/A barcodelen r_len N/A aln mismatches N/A N/A mismatches edit N/A N/A N/A N/A orientation 5 N/A N/A aln q_pos pos N/A N/A N/A True N/A N/A N/A N/A orientation 3 N/A N/A aln q_end N/A seqlen pos N/A N/A N/A True N/A N/A N/A False Not at right location N/A N/A N/A False too many mismatches N/A N/A False ? N/A check_tags N/A N/A barcodes seq edit pos allow_revcomp verbose N/A False False N/A N/A 
    For each barcode, pull out the appropriate 5' or 3' sub sequence from {seq}. Then
    run a local alignment of the barcode to the subseq. If a good match is found, return
    it; otherwise, find the best match and return that.

    returns a multi-tuple:
        valid, (tag, valid_seq, edits, reason_if_fail)

    For the alignments, the reference is the barcode, the query is the subset of the read
    that is possibly the barcode (5'/3' subseq)
     N/A best None N/A tag barcodes N/A N/A N/A barcodeseq orientation strip N/A barcodes N/A tag N/A N/A orientation 5 N/A N/A testseq N/A seq N/A N/A N/A N/A len barcodeseq edit pos N/A N/A testseq N/A seq N/A N/A -1 N/A N/A N/A len barcodeseq edit pos N/A aln N/A N/A sw align barcodeseq testseq N/A N/A valid reason N/A _tag_aln_check aln N/A len testseq N/A len barcodeseq orientation edit pos N/A verbose N/A N/A N/A Testing tag: %s vs %s N/A N/A str N/A barcodes N/A tag testseq N/A N/A N/A aln dump N/A valid reason N/A valid N/A N/A N/A True N/A tag aln True N/A N/A N/A best N/A N/A aln score N/A N/A best N/A 1 score N/A N/A best N/A tag aln True reason N/A allow_revcomp N/A N/A N/A orientation 5 N/A N/A testseq N/A seq N/A N/A -1 N/A N/A N/A len barcodeseq edit pos N/A N/A testseq N/A seq N/A N/A N/A N/A len barcodeseq edit pos N/A aln N/A N/A sw align N/A revcomp barcodeseq testseq N/A N/A valid reason N/A _tag_aln_check aln N/A len testseq N/A len barcodeseq N/A N/A orientation 3 5 3 edit pos N/A verbose N/A N/A N/A Testing tag: %s [rc] vs %s N/A N/A str N/A barcodes N/A tag testseq N/A N/A N/A aln dump N/A valid reason N/A valid N/A N/A N/A True N/A tag aln False N/A N/A N/A best N/A N/A aln score N/A N/A best N/A 1 score N/A N/A best N/A tag aln False reason N/A verbose N/A N/A BEST:  best N/A N/A N/A N/A best N/A 1 dump N/A N/A False best N/A usage N/A N/A N/A N/A N/A N/A N/A N/A sys stdout write N/A %s
 __doc__ N/A N/A N/A N/A sys stdout write N/A 
Usage: %s {options} barcodes.txt input.fastx{.gz} output_template

Options:
  -edit num         Number of mismatches/indels to allow in barcode discovery.
                    (default: 0)

  -pos num          Allow barcode to be within [num] bases from the start.
                    (or end for 3' barcodes) (default: 0)

  -allow-revcomp    Allow barcodes to match the reverse-compliment of a read.
                    (non-strand specific sequencing) The read's orientation
                    will *not* be changed in the output file.

  -gz               GZip compress the output files

  -stats            Output stats file (output_template.stats.txt)

 N/A N/A N/A os path basename N/A N/A sys argv N/A 0 N/A N/A N/A sys exit 1 N/A is_fasta_file N/A N/A fname N/A N/A N/A 
    Open a fileobj and read the first line
        If it starts with '>', it's FASTA
        If it starts with '@', it's FASTQ
    Return the actual FASTX object
     N/A N/A N/A fname N/A -3 .gz N/A N/A f N/A N/A gzip open fname N/A N/A f N/A open fname N/A N/A N/A True N/A N/A line N/A N/A f next N/A N/A N/A line N/A 0 > N/A N/A N/A N/A f close N/A True N/A N/A N/A N/A line N/A 0 @ N/A N/A N/A N/A f close N/A False N/A N/A N/A N/A N/A N/A f close N/A N/A ValueError Unknown type of file! N/A N/A N/A __name__ __main__ N/A N/A barcodes None N/A fname None N/A templ None N/A edit 0 N/A pos 0 N/A allow_revcomp False N/A gz False N/A stats False N/A last None N/A arg N/A N/A sys argv N/A 1 N/A N/A N/A last -edit N/A N/A edit N/A int arg N/A last None N/A N/A N/A last -pos N/A N/A pos N/A int arg N/A last None N/A N/A N/A arg N/A -edit -pos N/A N/A last arg N/A N/A N/A arg -allow-revcomp N/A N/A allow_revcomp True N/A N/A N/A arg -gz N/A N/A gz True N/A N/A N/A arg -stats N/A N/A stats True N/A N/A N/A N/A barcodes N/A N/A N/A os path exists arg N/A N/A barcodes N/A N/A N/A open arg f N/A N/A first True N/A line f N/A N/A first N/A N/A first False N/A N/A cols N/A N/A N/A N/A line strip split N/A N/A N/A len cols 4 N/A N/A N/A N/A cols append y N/A N/A barcodes N/A N/A cols N/A 0 N/A N/A cols N/A 1 N/A cols N/A 2 N/A N/A N/A cols N/A 3 TtyY True False N/A N/A N/A N/A fname N/A N/A N/A os path exists arg N/A N/A fname arg N/A N/A N/A templ N/A N/A templ arg N/A N/A N/A barcodes N/A fname N/A templ N/A N/A N/A usage N/A N/A is_fasta_file fname N/A N/A outtempl N/A %s_%%s.fasta templ N/A reader N/A FASTA fname N/A N/A outtempl N/A %s_%%s.fastq templ N/A reader N/A FASTQ fname N/A stats N/A N/A stats_fname N/A %s.stats.txt templ N/A N/A stats_fname None N/A N/A fastx_barcode_split reader outtempl barcodes edit pos allow_revcomp gz stats_fname