PYCHOPPER(1)

πŸ“¦
version 2.7.10 Β· 5 versions
, in ubuntu stonking

NAME

okay bestie, deep breath, we're doing this πŸ’– this is PYCHOPPER(1), and the official name line is literally just:

  • pychopper β€” package documentation

that's it. that's the name section. package documentation, periodt πŸŽ€ and like… there's a LOT of package documentation, so hydrate and let's go.


COMMAND LINE TOOLS

Command line tools

so there's a section here called "Command line tools" and, bestie, it is empty. no sub-items, no body text, nothing. iconic of the docs team honestly πŸ’… nothing to report, moving on.


FULL API REFERENCE

okay this is the whole toctree, the full API reference ✨ and I am not skipping a single entry, because that would be a crime. here's everything, in order, exactly as it goes down πŸ‘‘.

pychopper

just pychopper. the package, bestie. that's the entry 🫢

pychopper package

and it's listed again as pychopper package. yes, twice. the docs said it twice and we are respecting the docs πŸ™ˆ

Subpackages

here's where the subpackages start πŸ‘‡

pychopper.phmm_data package

a subpackage: pychopper.phmm_data. main character data package energy πŸ’œ

Module contents

and then β€” "Module contents". no extra content listed under it, just the heading. noted ✨

pychopper.primer_data package

next up: pychopper.primer_data, another subpackage 🌸

Module contents

again, "Module contents" with nothing extra under it. consistency, I guess πŸ’…

pychopper.scripts package

now we're in pychopper.scripts β€” the scripts package πŸŽ€

Submodules

and inside it, submodules:

pychopper.scripts.pychopper module

here's the actual module, pychopper.scripts.pychopper, and it's got one thing in it:

  • pychopper.scripts.pychopper.main() β€” Parse command line arguments.

that's the whole thing. it parses command line arguments, no cap 🫑

Module contents

and another "Module contents". this one's for the scripts package. nothing more listed πŸ¦‹

pychopper.tests package

okay next package: pychopper.tests. tests, we love her πŸ”₯

Submodules

submodules incoming:

pychopper.tests.test_detector module

the pychopper.tests.test_detector module:

  • class pychopper.tests.test_detector.TestDetector(methodName='runTest') β€” Bases: TestCase. Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
    • testPairAlign()
    • testScoreCutoff()

two test methods, that's it πŸ’– (and yes, the "raises a ValueError if the instance does not have a method with the specified name" thing is literally a disclaimer, live with it.)

pychopper.tests.test_regression_simple module

and the regression one: pychopper.tests.test_regression_simple:

  • class pychopper.tests.test_regression_simple.TestIntegration(methodName='runTest') β€” Bases: TestCase. Create an instance of the class that will use the named test method when executed. Raises a ValueError if the instance does not have a method with the specified name.
    • testIntegration() β€” Integration test.
    • testIntegration_umi() β€” Integration test.

two tests, both literally described as "Integration test." πŸ™ˆ copy-paste core but we support it.

Module contents

and yep β€” another "Module contents" heading. we've seen enough of these to recognise the vibe ✨

Submodules

alright, the big list of submodules. strap in, bestie, this is where the actual functions live 😭

pychopper.alignment_hits module

  • pychopper.alignment_hits.process_hits(hits, max_score) β€” Process alignment hits by removing overlaps

one function, one job. love a specialist πŸ’…

pychopper.chopper module

the chopper module, the main event πŸ‘‘:

  • pychopper.chopper.analyse_hits(hits, config) β€” Segment reads based on alignment hits using dynamic programming. The algorithm is based on the rule that each primer alignment hit can be used only once. Hence if a segment is included, the next one has to be excluded.
heads up: read that rule twice. each primer alignment hit can be used only once β€” so if a segment is in, the next one has to be out. no double dipping πŸ’€
  • pychopper.chopper.chopper_edlib(reads, primers, config, max_ed, cutoff, pool, min_batch) β€” Segment using the edlib/parasail backend
  • pychopper.chopper.chopper_phmm(reads, phmm_file, config, cutoff, threads, pool, min_batch) β€” Segment using the profile HMM backend
  • pychopper.chopper.segments_to_reads(read, segments, keep_primers, bam_tags, detect_umis) β€” Convert segments to output reads with annotation

two backends, one segmentation mission 🧚

pychopper.common_structures module

here come the data structures 🌈 β€” all three are tuple bases, and all three say "Create new instance of …" because that's how namedtuples talk.

  • class pychopper.common_structures.Hit(Ref, RefStart, RefEnd, Query, QueryStart, QueryEnd, Score) β€” Bases: tuple. Create new instance of Hit(Ref, RefStart, RefEnd, Query, QueryStart, QueryEnd, Score).
    • Query β€” Alias for field number 3
    • QueryEnd β€” Alias for field number 5
    • QueryStart β€” Alias for field number 4
    • Ref β€” Alias for field number 0
    • RefEnd β€” Alias for field number 2
    • RefStart β€” Alias for field number 1
    • Score β€” Alias for field number 6
  • class pychopper.common_structures.Segment(Left, Start, End, Right, Strand, Len) β€” Bases: tuple. Create new instance of Segment(Left, Start, End, Right, Strand, Len).
    • End β€” Alias for field number 2
    • Left β€” Alias for field number 0
    • Len β€” Alias for field number 5
    • Right β€” Alias for field number 3
    • Start β€” Alias for field number 1
    • Strand β€” Alias for field number 4
  • class pychopper.common_structures.Seq(Id, Name, Seq, Qual, Umi) β€” Bases: tuple. Create new instance of Seq(Id, Name, Seq, Qual, Umi).
    • Id β€” Alias for field number 0
    • Name β€” Alias for field number 1
    • Qual β€” Alias for field number 3
    • Seq β€” Alias for field number 2
    • Umi β€” Alias for field number 4

the field numbers are not in order, and I am not "fixing" them, because nothing here is broken, it's just alphabetical by field name πŸ’–

pychopper.edlib_backend module

edlib/parasail backend, two functions ✨:

  • pychopper.edlib_backend.find_locations(reads, all_primers, max_ed, pool, min_batch) β€” Find alignment hits of all primers in all reads using the edlib/parasail backend
  • pychopper.edlib_backend.find_umi_single(params) β€” Find UMI in a single reads using the edlib/parasail backend

(yes, "in a single reads". we're keeping the grammar exactly as it lives 😌)

pychopper.hmmer_backend module

HMM backend, one function:

  • pychopper.hmmer_backend.find_locations(reads, phmm_file, E, pool, min_batch) β€” Find alignment hits of all primers in all reads using the pHMM/nhmmscan backend

pychopper.parasail_backend module

the parasail backend, four functions, all lowkey doing very precise little things πŸŽ€:

  • pychopper.parasail_backend.first_cigar(cigar) β€” Extract details of the first operation in a cigar string.
  • pychopper.parasail_backend.pair_align(reference, query, query_name, subs_mat, params) β€” Perform pairwise local alignment using parsail-python
  • pychopper.parasail_backend.process_alignment(aln, query, query_name, aln_params) β€” Process an alignment, extracting score, start and end.
  • pychopper.parasail_backend.refine_locations(read, all_primers, locations, aln_params={'gap_extend': 1, 'gap_open': 1, 'match': 1, 'mismatch': -2}, subs_mat=<parasail.bindings_v2.Matrix object>) β€” Refine alignment edges based on local alignment
that default arg is {'gap_extend': 1, 'gap_open': 1, 'match': 1, 'mismatch': -2} and the matrix default is a <parasail.bindings_v2.Matrix object> β€” verbatim, bestie, don't touch it πŸ™

pychopper.report module

plotting time πŸŽ€ this one's a class with a whole personality:

  • class pychopper.report.Report(pdf) β€” Bases: object. Class for plotting utilities on the top of matplotlib. Plots are saved in the specified file through the PDF backend.
    • Parameters
      • self β€” object.
      • pdf β€” Output pdf.
    • Returns β€” The report object.
    • Return type β€” Report <#pychopper.report.Report>

and here's everything she can do:

  • close() β€” Close PDF backend. Do not forget to call this at the end of your script or your output will be damaged!
literally do not forget this. the docs are screaming it in bold-adjacent energy: your output WILL be damaged 😭
  • Parameters
    • self β€” object
  • Returns β€” None
  • Return type β€” object
  • plot_arrays(data_map, title='', xlab='', ylab='', marker='.', legend_loc='best', legend=True, vlines=None, vlcolor='green', vlwitdh=0.5) β€” Plot multiple pairs of data arrays.
    • Parameters
      • self β€” object.
      • data_map β€” A dictionary with labels as keys and tupples of data arrays (x,y) as values.
      • title β€” Figure title.
      • xlab β€” X axis label.
      • ylab β€” Y axis label.
      • marker β€” Marker passed to the plot function.
      • legend_loc β€” Location of legend.
      • legend β€” Plot legend if True
      • vlines β€” Dictionary with labels and positions of vertical lines to draw.
      • vlcolor β€” Color of vertical lines drawn.
      • vlwidth β€” Width of vertical lines drawn.
    • Returns β€” None
    • Return type β€” object
ok so the keyword argument is spelled vlwitdh in the signature and vlwidth in the parameter list, and we are preserving BOTH spellings because that is what the docs say 🫢
  • plot_bars_simple(data_map, title='', xlab='', ylab='', alpha=0.6, xticks_rotation=0, auto_limit=False) β€” Plot simple bar chart from input dictionary.
    • Parameters
      • self β€” object.
      • data_map β€” A dictionary with labels as keys and data as values.
      • title β€” Figure title.
      • xlab β€” X axis label.
      • ylab β€” Y axis label.
      • alpha β€” Alpha value.
      • xticks_rotation β€” Rotation value for x tick labels.
      • auto_limit β€” Set y axis limits automatically.
    • Returns β€” None
    • Return type β€” object
  • plot_histograms(data_map, title='', xlab='', ylab='', bins=50, alpha=0.7, legend_loc='best', legend=True, vlines=None) β€” Plot histograms of multiple data arrays.
    • Parameters
      • self β€” object.
      • data_map β€” A dictionary with labels as keys and data arrays as values.
      • title β€” Figure title.
      • xlab β€” X axis label.
      • ylab β€” Y axis label.
      • bins β€” Number of bins.
      • alpha β€” Transparency value for histograms.
      • legend_loc β€” Location of legend.
      • legend β€” Plot legend if True.
      • vlines β€” Dictionary with labels and positions of vertical lines to draw.
    • Returns β€” None
    • Return type β€” object
  • save_close() β€” Utility method to save and close figure.

pychopper.seq_utils module

final module of this chunk, and it's the cute little sequence-helper one 🌸

Utilities manipulating biological sequences and formats. Extensions to biopython functionality.

  • pychopper.seq_utils.base_complement(k) β€” Return complement of base. Performs the subsitutions: A<=>T, C<=>G, X=>X for both upper and lower case. The return value is identical to the argument for all other values.
    • Parameters
      • k β€” A base.
    • Returns β€” Complement of base.
    • Return type β€” str
note the complements, bestie: A<=>T, C<=>G, and X=>X, upper AND lower case. everything else comes back unchanged πŸ’œ
  • pychopper.seq_utils.errs_tab(n) β€” Generate list of error rates for qualities less than equal than n.
  • pychopper.seq_utils.get_primers(primers) β€” Load primers from fasta file
  • pychopper.seq_utils.get_runid(desc) β€” Parse out runid from sequence description.

…and that's where this part lands, right there on get_runid. πŸ¦‹

✨ pychopper.seq_utils.mean_qual(quals, qround=False, tab=[...])

bestie. BABES. this one is the quality-score calculator and it is so ready for its close-up πŸŽ€ like it literally takes the ascii quality scores of a read and hands you back the average quality for that read. the whole pipeline is giving: first convert Phred scores to probabilities ➑️ calculate the average error probability ➑️ convert that average back to the Phred scale. iconic behaviour, no notes.

and because the default lookup table is 128 whole values long and we do not abbreviate our truths here, here is the entire signature, verbatim, every single digit πŸ’–:

pychopper.seq_utils.mean_qual(quals, qround=False, tab=[1.0,
0.7943282347242815, 0.6309573444801932, 0.5011872336272722,
0.3981071705534972, 0.31622776601683794, 0.251188643150958,
0.19952623149688797, 0.15848931924611134, 0.12589254117941673, 0.1,
0.07943282347242814, 0.06309573444801933, 0.05011872336272722,
0.039810717055349734, 0.03162277660168379, 0.025118864315095794,
0.0199526231496888, 0.015848931924611134, 0.012589254117941675, 0.01,
0.007943282347242814, 0.00630957344480193, 0.005011872336272725,
0.003981071705534973, 0.0031622776601683794, 0.0025118864315095794,
0.001995262314968879, 0.001584893192461114, 0.0012589254117941675,
0.001, 0.0007943282347242813, 0.000630957344480193,
0.0005011872336272725, 0.00039810717055349735, 0.00031622776601683794,
0.00025118864315095795, 0.00019952623149688788, 0.00015848931924611142,
0.00012589254117941674, 0.0001, 7.943282347242822e-05,
6.309573444801929e-05, 5.011872336272725e-05, 3.9810717055349695e-05,
3.1622776601683795e-05, 2.5118864315095822e-05, 1.9952623149688786e-05,
1.584893192461114e-05, 1.2589254117941661e-05, 1e-05,
7.943282347242822e-06, 6.30957344480193e-06, 5.011872336272725e-06,
3.981071705534969e-06, 3.162277660168379e-06, 2.5118864315095823e-06,
1.9952623149688787e-06, 1.584893192461114e-06, 1.2589254117941661e-06,
1e-06, 7.943282347242822e-07, 6.30957344480193e-07,
5.011872336272725e-07, 3.981071705534969e-07, 3.162277660168379e-07,
2.5118864315095823e-07, 1.9952623149688787e-07, 1.584893192461114e-07,
1.2589254117941662e-07, 1e-07, 7.943282347242822e-08,
6.30957344480193e-08, 5.011872336272725e-08, 3.981071705534969e-08,
3.162277660168379e-08, 2.511886431509582e-08, 1.9952623149688786e-08,
1.5848931924611143e-08, 1.2589254117941661e-08, 1e-08,
7.943282347242822e-09, 6.309573444801943e-09, 5.011872336272715e-09,
3.981071705534969e-09, 3.1622776601683795e-09, 2.511886431509582e-09,
1.9952623149688828e-09, 1.584893192461111e-09, 1.2589254117941663e-09,
1e-09, 7.943282347242822e-10, 6.309573444801942e-10,
5.011872336272714e-10, 3.9810717055349694e-10, 3.1622776601683795e-10,
2.511886431509582e-10, 1.9952623149688828e-10, 1.584893192461111e-10,
1.2589254117941662e-10, 1e-10, 7.943282347242822e-11,
6.309573444801942e-11, 5.011872336272715e-11, 3.9810717055349695e-11,
3.1622776601683794e-11, 2.5118864315095823e-11, 1.9952623149688828e-11,
1.5848931924611107e-11, 1.2589254117941662e-11, 1e-11,
7.943282347242821e-12, 6.309573444801943e-12, 5.011872336272715e-12,
3.9810717055349695e-12, 3.1622776601683794e-12, 2.5118864315095823e-12,
1.9952623149688827e-12, 1.584893192461111e-12, 1.258925411794166e-12,
1e-12, 7.943282347242822e-13, 6.309573444801942e-13,
5.011872336272715e-13, 3.981071705534969e-13, 3.162277660168379e-13,
2.511886431509582e-13, 1.9952623149688827e-13, 1.584893192461111e-13])

like... she is not shrinking herself for anyone πŸ’… and yes, qround defaults to False, and yes, that tab is the whole default. periodt.


πŸ¦‹ pychopper.seq_utils.readfq(fastq, sample=None, min_qual=0, rfq_sup={})

Reads fastx files, bestie πŸ“– this one is a generator function, which means it doesn't dump everything on you at once β€” it politely yields sequtils.Seq objects as you go. bougie and efficient.

the ✨options✨ (well, the lowercase ones):

  • fastq β€” the file you're reading from.
  • sample β€” optionally subsample the fastx file, as a number between 0.0 and 1.0 🎲.
  • min_qual β€” optional minimum mean quality filter, defaulting to 0 🌸.
  • rfq_sup β€” defaults to {}.

πŸŽ€ pychopper.seq_utils.record_size(read, in_format='fastq')

Calculates the record size, bb. that's it, that's the whole job. cute little number-cruncher, in_format defaults to 'fastq' ⭐


πŸ’œ pychopper.seq_utils.revcomp_seq(seq)

Reverse complement. a sequence. record. slay, moving on πŸ’…


🌈 pychopper.seq_utils.reverse_complement(seq)

Reverse complement sequence 😌

  • param β€” input sequence string ✨
  • returns β€” the reverse-complemented string 🫢

πŸ“ pychopper.seq_utils.writefq(r, fh)

Writes read r to the fastq file handle fh πŸ’– file goes in, read comes out, no cap.


πŸ’… pychopper.utils module

okay so this module is lowkey the little utility drawer of the whole operation β€” the scissors, the tape, the random pen that works. here's everything in it, no gatekeeping πŸ™ˆ:

  • pychopper.utils.batch(iterable, size) ✨
  • pychopper.utils.check_command(cmd) ✨
  • pychopper.utils.check_min_hmmer_version(major, minor) ✨
  • pychopper.utils.count_fastq_records(fname, size=128000000, opener=<built-in function open>) β€” note that size default of 128000000 and that opener default of <built-in function open> 🫢 keep them exactly as they are.
  • pychopper.utils.hit2bed(hit, read) ✨
  • pychopper.utils.parse_config_string(s) ✨

no descriptions attached in the source, so no invented lore from me β€” we simply do not make things up in this group chat 🧚


πŸ“š Module contents

  • Index <>
  • Module Index <>
  • Search Page <>

πŸ‘‘ Author

ONT Applications Group πŸ’– (the actual main characters)


2016, Oxford Nanopore Technologies Ltd.


and that's the whole page, bestie πŸŽ€ this was the PYCHOPPER(1) manual, version 2.7.10, dated Aug 05, 2026 β€” go forth and chop some reads, you absolute icon πŸ’…βœ¨πŸ¦‹

πŸ“¦ where this page comes from