[med-svn] [python-cutadapt] 01/03: Imported Upstream version 1.8.3

Olivier Sallou osallou at debian.org
Mon Aug 17 08:29:14 UTC 2015


This is an automated email from the git hooks/post-receive script.

osallou pushed a commit to branch feature_packaging
in repository python-cutadapt.

commit c2e8d99bcf38891683abdc1482cb42de4fc95018
Author: Olivier Sallou <olivier.sallou at debian.org>
Date:   Mon Aug 17 09:10:46 2015 +0200

    Imported Upstream version 1.8.3
---
 CHANGES.rst                                 |  296 +
 CITATION                                    |   16 +
 LICENSE                                     |   19 +
 PKG-INFO                                    |   20 +
 README.rst                                  |   41 +
 bin/_preamble.py                            |   21 +
 bin/cutadapt                                |   10 +
 cutadapt/__init__.py                        |   23 +
 cutadapt/__main__.py                        |   12 +
 cutadapt/_align.c                           | 6607 +++++++++++++++++++++
 cutadapt/_align.pyx                         |  456 ++
 cutadapt/_align.so                          |  Bin 0 -> 385272 bytes
 cutadapt/_qualtrim.c                        | 2336 ++++++++
 cutadapt/_qualtrim.pyx                      |   48 +
 cutadapt/_qualtrim.so                       |  Bin 0 -> 118544 bytes
 cutadapt/_seqio.c                           | 8436 +++++++++++++++++++++++++++
 cutadapt/_seqio.pyx                         |  184 +
 cutadapt/_seqio.so                          |  Bin 0 -> 427936 bytes
 cutadapt/adapters.py                        |  399 ++
 cutadapt/align.py                           |   39 +
 cutadapt/colorspace.py                      |   83 +
 cutadapt/compat.py                          |   45 +
 cutadapt/filters.py                         |  190 +
 cutadapt/modifiers.py                       |  127 +
 cutadapt/qualtrim.py                        |   41 +
 cutadapt/report.py                          |  291 +
 cutadapt/scripts/__init__.py                |    0
 cutadapt/scripts/cutadapt.py                |  855 +++
 cutadapt/seqio.py                           |  498 ++
 cutadapt/xopen.py                           |  178 +
 doc/Makefile                                |  179 +
 doc/changes.rst                             |    1 +
 doc/colorspace.rst                          |  107 +
 doc/conf.py                                 |  270 +
 doc/guide.rst                               | 1181 ++++
 doc/ideas.rst                               |   70 +
 doc/index.rst                               |   25 +
 doc/installation.rst                        |   87 +
 doc/recipes.rst                             |   83 +
 setup.py                                    |  123 +
 tests/cut/454.fa                            |  118 +
 tests/cut/anchored-back.fasta               |    8 +
 tests/cut/anchored.fasta                    |    8 +
 tests/cut/anchored_no_indels.fasta          |   12 +
 tests/cut/anchored_no_indels_wildcard.fasta |   12 +
 tests/cut/anywhere_repeat.fastq             |   28 +
 tests/cut/discard-untrimmed.fastq           |    4 +
 tests/cut/discard.fastq                     |    4 +
 tests/cut/dos.fastq                         |   12 +
 tests/cut/empty.fastq                       |    0
 tests/cut/example.fa                        |   18 +
 tests/cut/examplefront.fa                   |   18 +
 tests/cut/illumina.fastq                    |  400 ++
 tests/cut/illumina.info.txt                 |  100 +
 tests/cut/illumina5.fastq                   |   20 +
 tests/cut/illumina5.info.txt                |    8 +
 tests/cut/illumina64.fastq                  |   80 +
 tests/cut/issue46.fasta                     |    2 +
 tests/cut/lowercase.fastq                   |   12 +
 tests/cut/lowqual.fastq                     |    8 +
 tests/cut/maxlen.fa                         |   14 +
 tests/cut/maxn0.2.fasta                     |    6 +
 tests/cut/maxn0.4.fasta                     |    8 +
 tests/cut/maxn0.fasta                       |    4 +
 tests/cut/maxn1.fasta                       |    8 +
 tests/cut/maxn2.fasta                       |   10 +
 tests/cut/minlen.fa                         |   16 +
 tests/cut/minlen.noprimer.fa                |   14 +
 tests/cut/no-trim.fastq                     |    4 +
 tests/cut/overlapa.fa                       |   40 +
 tests/cut/overlapb.fa                       |   38 +
 tests/cut/paired-m27.1.fastq                |   16 +
 tests/cut/paired-m27.2.fastq                |   16 +
 tests/cut/paired-onlyA.1.fastq              |   16 +
 tests/cut/paired-onlyA.2.fastq              |   16 +
 tests/cut/paired-separate.1.fastq           |   16 +
 tests/cut/paired-separate.2.fastq           |   16 +
 tests/cut/paired-trimmed.1.fastq            |   12 +
 tests/cut/paired-trimmed.2.fastq            |   12 +
 tests/cut/paired-untrimmed.1.fastq          |    4 +
 tests/cut/paired-untrimmed.2.fastq          |    4 +
 tests/cut/paired.1.fastq                    |   12 +
 tests/cut/paired.2.fastq                    |   12 +
 tests/cut/paired.m14.1.fastq                |   12 +
 tests/cut/paired.m14.2.fastq                |   12 +
 tests/cut/pairedq.1.fastq                   |    8 +
 tests/cut/pairedq.2.fastq                   |    8 +
 tests/cut/pairedu.1.fastq                   |   16 +
 tests/cut/pairedu.2.fastq                   |   16 +
 tests/cut/plus.fastq                        |    8 +
 tests/cut/polya.fasta                       |    2 +
 tests/cut/rest.fa                           |   18 +
 tests/cut/restfront.fa                      |   18 +
 tests/cut/s_1_sequence.txt                  |    8 +
 tests/cut/small.fastq                       |   12 +
 tests/cut/small.trimmed.fastq               |    8 +
 tests/cut/small.untrimmed.fastq             |    4 +
 tests/cut/solid-no-zerocap.fastq            |  120 +
 tests/cut/solid.fasta                       |    4 +
 tests/cut/solid.fastq                       |  120 +
 tests/cut/solid5p-anchored.fasta            |   32 +
 tests/cut/solid5p-anchored.fastq            |   64 +
 tests/cut/solid5p-anchored.notrim.fasta     |   32 +
 tests/cut/solid5p-anchored.notrim.fastq     |   64 +
 tests/cut/solid5p.fasta                     |   32 +
 tests/cut/solid5p.fastq                     |   64 +
 tests/cut/solidbfast.fastq                  |  120 +
 tests/cut/solidmaq.fastq                    |  120 +
 tests/cut/solidqual.fastq                   |  120 +
 tests/cut/sra.fastq                         |   24 +
 tests/cut/stripped.fasta                    |    4 +
 tests/cut/suffix.fastq                      |  120 +
 tests/cut/trimN3.fasta                      |    2 +
 tests/cut/trimN5.fasta                      |    2 +
 tests/cut/twoadapters.fasta                 |    6 +
 tests/cut/twoadapters.first.fasta           |    2 +
 tests/cut/twoadapters.second.fasta          |    2 +
 tests/cut/twoadapters.unknown.fasta         |    2 +
 tests/cut/unconditional-back.fastq          |   12 +
 tests/cut/unconditional-both.fastq          |   12 +
 tests/cut/unconditional-front.fastq         |   12 +
 tests/cut/wildcard.fa                       |    4 +
 tests/cut/wildcardN.fa                      |    6 +
 tests/cut/wildcard_adapter.fa               |    8 +
 tests/cut/wildcard_adapter_anywhere.fa      |    8 +
 tests/data/454.fa                           |  118 +
 tests/data/E3M.fasta                        |   59 +
 tests/data/E3M.qual                         |   59 +
 tests/data/adapter.fasta                    |    4 +
 tests/data/anchored-back.fasta              |    8 +
 tests/data/anchored.fasta                   |    8 +
 tests/data/anchored_no_indels.fasta         |   12 +
 tests/data/anywhere_repeat.fastq            |   28 +
 tests/data/dos.fastq                        |   12 +
 tests/data/empty.fastq                      |    0
 tests/data/example.fa                       |   18 +
 tests/data/illumina.fastq.gz                |  Bin 0 -> 7161 bytes
 tests/data/illumina5.fastq                  |   20 +
 tests/data/illumina64.fastq                 |   80 +
 tests/data/issue46.fasta                    |    2 +
 tests/data/lengths.fa                       |   28 +
 tests/data/lowqual.fastq                    |    8 +
 tests/data/maxn.fasta                       |   12 +
 tests/data/multiblock.fastq.gz              |  Bin 0 -> 262 bytes
 tests/data/overlapa.fa                      |   40 +
 tests/data/overlapb.fa                      |   38 +
 tests/data/paired.1.fastq                   |   16 +
 tests/data/paired.2.fastq                   |   16 +
 tests/data/plus.fastq                       |    8 +
 tests/data/polya.fasta                      |    6 +
 tests/data/prefix-adapter.fasta             |    2 +
 tests/data/rest.fa                          |   18 +
 tests/data/rest.txt                         |    5 +
 tests/data/restfront.txt                    |    6 +
 tests/data/s_1_sequence.txt.gz              |  Bin 0 -> 97 bytes
 tests/data/simple.fasta                     |    7 +
 tests/data/simple.fasta~                    |    6 +
 tests/data/simple.fastq                     |    8 +
 tests/data/small.fastq                      |   12 +
 tests/data/small.fastq.bz2                  |  Bin 0 -> 222 bytes
 tests/data/small.fastq.gz                   |  Bin 0 -> 218 bytes
 tests/data/small.fastq.xz                   |  Bin 0 -> 260 bytes
 tests/data/small.myownextension             |   12 +
 tests/data/solid.csfasta                    |   63 +
 tests/data/solid.fasta                      |    4 +
 tests/data/solid.fastq                      |  120 +
 tests/data/solid.qual                       |   63 +
 tests/data/solid5p.fasta                    |   34 +
 tests/data/solid5p.fastq                    |   64 +
 tests/data/sra.fastq                        |   24 +
 tests/data/suffix-adapter.fasta             |    2 +
 tests/data/toolong.fa                       |   14 +
 tests/data/tooshort.fa                      |   12 +
 tests/data/tooshort.noprimer.fa             |   14 +
 tests/data/trimN3.fasta                     |    2 +
 tests/data/trimN5.fasta                     |    2 +
 tests/data/twoadapters.fasta                |    6 +
 tests/data/wildcard.fa                      |    4 +
 tests/data/wildcardN.fa                     |    6 +
 tests/data/wildcard_adapter.fa              |    8 +
 tests/data/withplus.fastq                   |    8 +
 tests/testadapters.py                       |   92 +
 tests/testalign.py                          |  109 +
 tests/testcolorspace.py                     |  140 +
 tests/testfilters.py                        |   41 +
 tests/testmodifiers.py                      |   36 +
 tests/testpaired.py                         |  169 +
 tests/tests.py                              |  342 ++
 tests/testseqio.py                          |  175 +
 tests/testtrim.py                           |   27 +
 tests/testxopen.py                          |  101 +
 tests/utils.py                              |   50 +
 192 files changed, 28259 insertions(+)

diff --git a/CHANGES.rst b/CHANGES.rst
new file mode 100644
index 0000000..abfcef0
--- /dev/null
+++ b/CHANGES.rst
@@ -0,0 +1,296 @@
+=======
+Changes
+=======
+
+v1.8.1
+----
+
+* Fix #110: Counts for 'too short' and 'too long' reads were swapped in statistics.
+* Fix #115: Make ``--trim-n`` work also on second read for paired-end data.
+
+v1.8
+----
+
+* Support single-pass paired-end trimming with the new ``-A``/``-G``/``-B``/``-U``
+  parameters. These work just like their -a/-g/-b/-u counterparts, but they
+  specify sequences that are removed from the *second read* in a pair.
+
+  Also, if you start using one of those options, the read modification options
+  such as ``-q`` (quality trimming) are applied to *both* reads. For backwards
+  compatibility, read modifications are applied to the first read only if
+  neither of ``-A``/``-G``/``-B``/``-U`` is used. See `the
+  documentation <http://cutadapt.readthedocs.org/en/latest/guide.html#paired-end>`_
+  for details.
+
+  This feature has not been extensively tested, so please give feedback if
+  something does not work.
+* The report output has been re-worked in order to accomodate the new paired-end
+  trimming mode. This also changes the way the report looks like in single-end
+  mode. It is hopefully now more accessible.
+* Chris Mitchell contributed a patch adding two new options: ``--trim-n``
+  removes any ``N`` bases from the read ends, and the ``--max-n`` option can be
+  used to filter out reads with too many ``N``.
+* Support notation for repeated bases in the adapter sequence: Write ``A{10}``
+  instead of ``AAAAAAAAAA``. Useful for poly-A trimming: Use ``-a A{100}`` to
+  get the longest possible tail.
+* Quality trimming at the 5' end of reads is now supported. Use ``-q 15,10`` to
+  trim the 5' end with a cutoff of 15 and the 3' end with a cutoff of 10.
+* Fix incorrectly reported statistics (> 100% trimmed bases) when ``--times``
+  set to a value greater than one.
+* Support .xz-compressed files (if running in Python 3.3 or later).
+* Started to use the GitHub issue tracker instead of Google Code. All old issues
+  have been moved.
+
+v1.7
+----
+* IUPAC characters are now supported. For example, use ``-a YACGT`` for an
+  adapter that matches both ``CACGT`` and ``TACGT`` with zero errors. Disable
+  with ``-N``. By default, IUPAC characters in the read are not interpreted in
+  order to avoid matches in reads that consist of many (low-quality) ``N``
+  bases. Use ``--match-read-wildcards`` to enable them also in the read.
+* Support for demultiplexing was added. This means that reads can be written to
+  different files depending on which adapter was found. See `the section in the
+  documentation <http://cutadapt.readthedocs.org/en/latest/guide.html#demultiplexing>`_
+  for how to use it. This is currently only supported for single-end reads.
+* Add support for anchored 3' adapters. Append ``$`` to the adapter sequence to
+  force the adapter to appear in the end of the read (as a suffix). Closes
+  issue #81.
+* Option ``--cut`` (``-u``) can now be specified twice, once for each end of the
+  read. Thanks to Rasmus Borup Hansen for the patch!
+* Options ``--minimum-length``/``--maximum-length`` (``-m``/``-M``) can be used
+  standalone. That is, cutadapt can be used to filter reads by length without
+  trimming adapters.
+* Fix bug: Adapters read from a FASTA file can now be anchored.
+
+v1.6
+----
+* Fix bug: Ensure ``--format=...`` can be used even with paired-end input.
+* Fix bug: Sometimes output files would be incomplete because they were not
+  closed correctly.
+* Alignment algorithm is a tiny bit faster.
+* Extensive work on the documentation. It's now available at
+  https://cutadapt.readthedocs.org/ .
+* For 3' adapters, statistics about the bases preceding the trimmed adapter
+  are collected and printed. If one of the bases is overrepresented, a warning
+  is shown since this points to an incomplete adapter sequence. This happens,
+  for example, when a TruSeq adapter is used but the A overhang is not taken
+  into account when running cutadapt.
+* Due to code cleanup, there is a change in behavior: If you use
+  ``--discard-trimmed`` or ``--discard-untrimmed`` in combination with
+  ``--too-short-output`` or ``--too-long-output``, then cutadapt now writes also
+  the discarded reads to the output files given by the ``--too-short`` or
+  ``--too-long`` options. If anyone complains, I will consider reverting this.
+* Galaxy support files are now in `a separate
+  repository <https://bitbucket.org/lance_parsons/cutadapt_galaxy_wrapper>`_.
+
+v1.5
+----
+* Adapter sequences can now be read from a FASTA file. For example, write
+  ``-a file:adapters.fasta`` to read 3' adapters from ``adapters.fasta``. This works
+  also for ``-b`` and ``-g``.
+* Add the option ``--mask-adapter``, which can be used to not remove adapters,
+  but to instead mask them with ``N`` characters. Thanks to Vittorio Zamboni
+  for contributing this feature!
+* U characters in the adapter sequence are automatically converted to T.
+* Do not run Cython at installation time unless the --cython option is provided.
+* Add the option -u/--cut, which can be used to unconditionally remove a number
+  of bases from the beginning or end of each read.
+* Make ``--zero-cap`` the default for colorspace reads.
+* When the new option ``--quiet`` is used, no report is printed after all reads
+  have been processed.
+* When processing paired-end reads, cutadapt now checks whether the reads are
+  properly paired.
+* To properly handle paired-end reads, an option --untrimmed-paired-output was
+  added.
+
+v1.4
+----
+* This release of cutadapt reduces the overhead of reading and writing files.
+  On my test data set, a typical run of cutadapt (with a single adapter) takes
+  40% less time due to the following two changes.
+* Reading and writing of FASTQ files is faster (thanks to Cython).
+* Reading and writing of gzipped files is faster (up to 2x) on systems
+  where the ``gzip`` program is available.
+* The quality trimming function is four times faster (also due to Cython).
+* Fix the statistics output for 3' colorspace adapters: The reported lengths were one
+  too short. Thanks to Frank Wessely for reporting this.
+* Support the ``--no-indels`` option. This disallows insertions and deletions while
+  aligning the adapter. Currently, the option is only available for anchored 5' adapters.
+  This fixes issue 69.
+* As a sideeffect of implementing the --no-indels option: For colorspace, the
+  length of a read (for ``--minimum-length`` and ``--maximum-length``) is now computed after
+  primer base removal (when ``--trim-primer`` is specified).
+* Added one column to the info file that contains the name of the found adapter.
+* Add an explanation about colorspace ambiguity to the README
+
+v1.3
+----
+* Preliminary paired-end support with the ``--paired-output`` option (contributed by
+  James Casbon). See the README section on how to use it.
+* Improved statistics.
+* Fix incorrectly reported amount of quality-trimmed Mbp (issue 57, fix by Chris Penkett)
+* Add the ``--too-long-output`` option.
+* Add the ``--no-trim`` option, contributed by Dave Lawrence.
+* Port handwritten C alignment module to Cython.
+* Fix the ``--rest-file`` option (issue 56)
+* Slightly speed up alignment of 5' adapters.
+* Support bzip2-compressed files.
+
+v1.2
+----
+* At least 25% faster processing of .csfasta/.qual files due to faster parser.
+* Between 10% and 30% faster writing of gzip-compressed output files.
+* Support 5' adapters in colorspace, even when no primer trimming is requested.
+* Add the ``--info-file`` option, which has a line for each found adapter.
+* Named adapters are possible. Usage: ``-a My_Adapter=ACCGTA`` assigns the name "My_adapter".
+* Improve alignment algorithm for better poly-A trimming when there are sequencing errors.
+  Previously, not the longest possible poly-A tail would be trimmed.
+* James Casbon contributed the ``--discard-untrimmed`` option.
+
+v1.1
+----
+* Allow to "anchor" 5' adapters (``-g``), forcing them to be a prefix of the read.
+  To use this, add the special character ``^`` to the beginning of the adapter sequence.
+* Add the "-N" option, which allows 'N' characters within adapters to match literally.
+* Speedup of approx. 25% when reading from .gz files and using Python 2.7.
+* Allow to only trim qualities when no adapter is given on the command-line.
+* Add a patch by James Casbon: include read names (ids) in rest file
+* Use nosetest for testing. To run, install nose and run "nosetests".
+* When using cutadapt without installing it, you now need to run ``bin/cutadapt`` due to
+  a new directory layout.
+* Allow to give a colorspace adapter in basespace (gets automatically converted).
+* Allow to search for 5' adapters (those specified with ``-g``) in colorspace.
+* Speed up the alignment by a factor of at least 3 by using Ukkonen's algorithm.
+  The total runtime decreases by about 30% in the tested cases.
+* allow to deal with colorspace FASTQ files from the SRA that contain a fake
+  additional quality in the beginning (use ``--format sra-fastq``)
+
+v1.0
+----
+* ASCII-encoded quality values were assumed to be encoded as ascii(quality+33).
+  With the new parameter ``--quality-base``, this can be changed to ascii(quality+64),
+  as used in some versions of the Illumina pipeline. (Fixes issue 7.)
+* Allow to specify that adapters were ligated to the 5' end of reads. This change
+  is based on a patch contributed by James Casbon.
+* Due to cutadapt being published in EMBnet.journal, I found it appropriate
+  to call this release version 1.0. Please see
+  http://journal.embnet.org/index.php/embnetjournal/article/view/200 for the
+  article and I would be glad if you cite it.
+* Add Galaxy support, contributed by Lance Parsons.
+* Patch by James Casbon: Allow N wildcards in read or adapter or both.
+  Wildcard matching of 'N's in the adapter is always done. If 'N's within reads
+  should also match without counting as error, this needs to be explicitly
+  requested via ``--match-read-wildcards``.
+
+v0.9.5
+------
+* Fix issue 20: Make the report go to standard output when ``-o``/``--output`` is
+  specified.
+* Recognize `.fq` as an extension for FASTQ files
+* many more unit tests
+* The alignment algorithm has changed. It will now find some adapters that
+  previously were missed. Note that this will produce different output than
+  older cutadapt versions!
+
+  Before this change, finding an adapter would work as follows:
+
+  - Find an alignment between adapter and read -- longer alignments are
+    better.
+  - If the number of errors in the alignment (divided by length) is above the
+    maximum error rate, report the adapter as not being found.
+
+  Sometimes, the long alignment that is found had too many errors, but a
+  shorter alignment would not. The adapter was then incorrectly seen as "not
+  found". The new alignment algorithm checks the error rate while aligning and only
+  reports alignments that do not have too many errors.
+
+v0.9.4
+------
+* now compatible with Python 3
+* Add the ``--zero-cap`` option, which changes negative quality values to zero.
+  This is a workaround to avoid segmentation faults in BWA. The option is now
+  enabled by default when ``--bwa``/``--maq`` is used.
+* Lots of unit tests added. Run them with ``cd tests && ./tests.sh``.
+* Fix issue 16: ``--discard-trimmed`` did not work.
+* Allow to override auto-detection of input file format with the new ``-f``/``--format``
+  parameter. This mostly fixes issue 12.
+* Don't break when input file is empty.
+
+v0.9.2
+------
+* Install a single ``cutadapt`` Python package instead of multiple Python
+  modules. This avoids cluttering the global namespace and should lead to less
+  problems with other Python modules. Thanks to Steve Lianoglou for
+  pointing this out to me!
+* ignore case (ACGT vs acgt) when comparing the adapter with the read sequence
+* .FASTA/.QUAL files (not necessarily colorspace) can now be read (some
+  454 software uses this format)
+* Move some functions into their own modules
+* lots of refactoring: replace the fasta module with a much nicer seqio module.
+* allow to input FASTA/FASTQ on standard input (also FASTA/FASTQ is
+  autodetected)
+
+v0.9
+----
+* add ``--too-short-output`` and ``--untrimmed-output``, based on patch by Paul Ryvkin (thanks!)
+* add ``--maximum-length`` parameter: discard reads longer than a specified length
+* group options by category in ``--help`` output
+* add ``--length-tag`` option. allows to fix read length in FASTA/Q comment lines
+  (e.g., ``length=123`` becomes ``length=58`` after trimming) (requested by Paul Ryvkin)
+* add ``-q``/``--quality-cutoff`` option for trimming low-quality ends (uses the same algorithm
+  as BWA)
+* some refactoring
+* the filename ``-`` is now interpreted as standard in or standard output
+
+v0.8
+----
+* Change default behavior of searching for an adapter: The adapter is now assumed to
+  be an adapter that has been ligated to the 3' end. This should be the correct behavior
+  for at least the SOLiD small RNA protocol (SREK) and also for the Illumina protocol.
+  To get the old behavior, which uses a heuristic to determine whether the adapter was
+  ligated to the 5' or 3' end and then trimmed the read accordingly, use the new
+  ``-b`` (``--anywhere``) option.
+* Clear up how the statistics after processing all reads are printed.
+* Fix incorrect statistics. Adapters starting at pos. 0 were correctly trimmed,
+  but not counted.
+* Modify scoring scheme: Improves trimming (some reads that should have been
+  trimmed were not). Increases no. of trimmed reads in one of our SOLiD data sets
+  from 36.5 to 37.6%.
+* Speed improvements (20% less runtime on my test data set).
+
+v0.7
+----
+* Useful exit codes
+* Better error reporting when malformed files are encountered
+* Add ``--minimum-length`` parameter for discarding reads that are shorter than
+  a specified length after trimming.
+* Generalize the alignment function a bit. This is preparation for
+  supporting adapters that are specific to either the 5' or 3' end.
+* pure Python fallback for alignment function for when the C module cannot
+  be used.
+
+v0.6
+----
+* Support gzipped input and output.
+* Print timing information in statistics.
+
+v0.5
+----
+* add ``--discard`` option which makes cutadapt discard reads in which an adapter occurs
+
+v0.4
+----
+* (more) correctly deal with multiple adapters: If a long adapter matches with lots of
+  errors, then this could lead to a a shorter adapter matching with few errors getting ignored.
+
+v0.3
+----
+* fix huge memory usage (entire input file was unintentionally read into memory)
+
+v0.2
+----
+* allow FASTQ input
+
+v0.1
+----
+* initial release
diff --git a/CITATION b/CITATION
new file mode 100644
index 0000000..a1e62e2
--- /dev/null
+++ b/CITATION
@@ -0,0 +1,16 @@
+Marcel Martin. Cutadapt removes adapter sequences from high-throughput sequencing reads.
+EMBnet.journal, 17(1):10-12, May 2011.
+DOI: http://dx.doi.org/10.14806/ej.17.1.200
+
+ at ARTICLE{Martin2011Cutadapt,
+  author = {Marcel Martin},
+  title = {Cutadapt removes adapter sequences from high-throughput sequencing reads},
+  journal = {EMBnet.journal},
+  year = 2011,
+  month = may,
+  volume = 17,
+  pages = {10--12},
+  number = 1,
+  doi = {http://dx.doi.org/10.14806/ej.17.1.200},
+  url = {http://journal.embnet.org/index.php/embnetjournal/article/view/200}
+}
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..e3ebf36
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,19 @@
+Copyright (c) 2010-2015 Marcel Martin <marcel.martin at scilifelab.se>
+
+Permission is hereby granted, free of charge, to any person obtaining a copy
+of this software and associated documentation files (the "Software"), to deal
+in the Software without restriction, including without limitation the rights
+to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+copies of the Software, and to permit persons to whom the Software is
+furnished to do so, subject to the following conditions:
+
+The above copyright notice and this permission notice shall be included in
+all copies or substantial portions of the Software.
+
+THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+THE SOFTWARE.
diff --git a/PKG-INFO b/PKG-INFO
new file mode 100644
index 0000000..4f304ba
--- /dev/null
+++ b/PKG-INFO
@@ -0,0 +1,20 @@
+Metadata-Version: 1.1
+Name: cutadapt
+Version: 1.8.3
+Summary: trim adapters from high-throughput sequencing reads
+Home-page: https://cutadapt.readthedocs.org/
+Author: Marcel Martin
+Author-email: marcel.martin at scilifelab.se
+License: MIT
+Description: UNKNOWN
+Platform: UNKNOWN
+Classifier: Development Status :: 5 - Production/Stable
+Classifier: Environment :: Console
+Classifier: Intended Audience :: Science/Research
+Classifier: License :: OSI Approved :: MIT License
+Classifier: Natural Language :: English
+Classifier: Programming Language :: Cython
+Classifier: Programming Language :: Python :: 2.6
+Classifier: Programming Language :: Python :: 2.7
+Classifier: Programming Language :: Python :: 3
+Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
diff --git a/README.rst b/README.rst
new file mode 100644
index 0000000..fcae283
--- /dev/null
+++ b/README.rst
@@ -0,0 +1,41 @@
+.. image:: https://travis-ci.org/marcelm/cutadapt.svg?branch=master
+    :target: https://travis-ci.org/marcelm/cutadapt
+
+.. image:: https://img.shields.io/pypi/v/cutadapt.svg?branch=master
+    :target: https://pypi.python.org/pypi/cutadapt
+
+========
+cutadapt
+========
+
+Cutadapt finds and removes adapter sequences, primers, poly-A tails and other
+types of unwanted sequence from your high-throughput sequencing reads.
+
+Cleaning your data in this way is often required: Reads from small-RNA
+sequencing contain the 3’ sequencing adapter because the read is longer than
+the molecule that is sequenced. Amplicon reads start with a primer sequence.
+Poly-A tails are useful for pulling out RNA from your sample, but often you
+don’t want them to be in your reads.
+
+Cutadapt helps with these trimming tasks by finding the adapter or primer
+sequences in an error-tolerant way. It can also modify and filter reads in
+various ways. Adapter sequences can contain IUPAC wildcard characters. Also,
+paired-end reads and even colorspace data is supported. If you want, you can
+also just demultiplex your input data, without removing adapter sequences at all.
+
+Cutadapt comes with an extensive suite of automated tests and is available under
+the terms of the MIT license.
+
+If you use cutadapt, please cite
+`DOI:10.14806/ej.17.1.200 <http://dx.doi.org/10.14806/ej.17.1.200>`_ .
+
+
+Links
+-----
+
+* `Documentation <https://cutadapt.readthedocs.org/>`_
+* `Source code <https://github.com/marcelm/cutadapt/>`_
+* `Report an issue <https://github.com/marcelm/cutadapt/issues>`_
+* `Project page on PyPI (Python package index) <https://pypi.python.org/pypi/cutadapt/>`_
+* `Follow @marcelm_ on Twitter <https://twitter.com/marcelm_>`_
+* `Wrapper for the Galaxy platform <https://bitbucket.org/lance_parsons/cutadapt_galaxy_wrapper>`_
diff --git a/bin/_preamble.py b/bin/_preamble.py
new file mode 100644
index 0000000..55f392a
--- /dev/null
+++ b/bin/_preamble.py
@@ -0,0 +1,21 @@
+# Copyright (c) Twisted Matrix Laboratories.
+#
+# Copied from Twisted (http://twistedmatrix.com/), see
+# http://twistedmatrix.com/trac/browser/trunk/LICENSE for the license.
+#
+# This makes sure that users don't have to set up their environment
+# specially in order to run these programs from bin/.
+
+# This helper is shared by many different actual scripts.  It is not intended to
+# be packaged or installed, it is only a developer convenience.  By the time
+# the package is actually installed somewhere, the environment should already be set
+# up properly without the help of this tool.
+
+import sys, os
+
+path = os.path.abspath(sys.argv[0])
+while os.path.dirname(path) != path:
+    if os.path.exists(os.path.join(path, 'cutadapt', '__init__.py')):
+        sys.path.insert(0, path)
+        break
+    path = os.path.dirname(path)
diff --git a/bin/cutadapt b/bin/cutadapt
new file mode 100755
index 0000000..02c4c8d
--- /dev/null
+++ b/bin/cutadapt
@@ -0,0 +1,10 @@
+#!/usr/bin/env python
+import sys
+
+try:
+	import _preamble
+except ImportError:
+	pass
+
+from cutadapt.scripts import cutadapt
+cutadapt.main()
diff --git a/cutadapt/__init__.py b/cutadapt/__init__.py
new file mode 100644
index 0000000..7d8fa4f
--- /dev/null
+++ b/cutadapt/__init__.py
@@ -0,0 +1,23 @@
+# coding: utf-8
+from __future__ import print_function, division, absolute_import
+import sys
+
+__version__ = '1.8.3'
+
+def check_importability():  # pragma: no cover
+	try:
+		import cutadapt._align
+	except ImportError as e:
+		if 'undefined symbol' in str(e):
+			print("""
+ERROR: A required extension module could not be imported because it is
+incompatible with your system. A quick fix is to recompile the extension
+modules with the following command:
+
+    {0} setup.py build_ext -i
+
+See the documentation for alternative ways of installing the program.
+
+The original error message follows.
+""".format(sys.executable))
+		raise
diff --git a/cutadapt/__main__.py b/cutadapt/__main__.py
new file mode 100755
index 0000000..5f29857
--- /dev/null
+++ b/cutadapt/__main__.py
@@ -0,0 +1,12 @@
+#!/usr/bin/env python
+# coding: utf-8
+from __future__ import print_function, division, absolute_import
+import sys
+
+try:
+	import _preamble
+except ImportError:
+	pass
+
+from cutadapt.scripts import cutadapt
+cutadapt.main()
diff --git a/cutadapt/_align.c b/cutadapt/_align.c
new file mode 100644
index 0000000..9a4fbb5
--- /dev/null
+++ b/cutadapt/_align.c
@@ -0,0 +1,6607 @@
+/* Generated by Cython 0.22.1 */
+
+/* BEGIN: Cython Metadata
+{
+    "distutils": {
+        "depends": []
+    }
+}
+END: Cython Metadata */
+
+#define PY_SSIZE_T_CLEAN
+#ifndef CYTHON_USE_PYLONG_INTERNALS
+#ifdef PYLONG_BITS_IN_DIGIT
+#define CYTHON_USE_PYLONG_INTERNALS 0
+#else
+#include "pyconfig.h"
+#ifdef PYLONG_BITS_IN_DIGIT
+#define CYTHON_USE_PYLONG_INTERNALS 1
+#else
+#define CYTHON_USE_PYLONG_INTERNALS 0
+#endif
+#endif
+#endif
+#include "Python.h"
+#ifndef Py_PYTHON_H
+    #error Python headers needed to compile C extensions, please install development version of Python.
+#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)
+    #error Cython requires Python 2.6+ or Python 3.2+.
+#else
+#define CYTHON_ABI "0_22_1"
+#include <stddef.h>
+#ifndef offsetof
+#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
+#endif
+#if !defined(WIN32) && !defined(MS_WINDOWS)
+  #ifndef __stdcall
+    #define __stdcall
+  #endif
+  #ifndef __cdecl
+    #define __cdecl
+  #endif
+  #ifndef __fastcall
+    #define __fastcall
+  #endif
+#endif
+#ifndef DL_IMPORT
+  #define DL_IMPORT(t) t
+#endif
+#ifndef DL_EXPORT
+  #define DL_EXPORT(t) t
+#endif
+#ifndef PY_LONG_LONG
+  #define PY_LONG_LONG LONG_LONG
+#endif
+#ifndef Py_HUGE_VAL
+  #define Py_HUGE_VAL HUGE_VAL
+#endif
+#ifdef PYPY_VERSION
+#define CYTHON_COMPILING_IN_PYPY 1
+#define CYTHON_COMPILING_IN_CPYTHON 0
+#else
+#define CYTHON_COMPILING_IN_PYPY 0
+#define CYTHON_COMPILING_IN_CPYTHON 1
+#endif
+#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
+#define Py_OptimizeFlag 0
+#endif
+#define __PYX_BUILD_PY_SSIZE_T "n"
+#define CYTHON_FORMAT_SSIZE_T "z"
+#if PY_MAJOR_VERSION < 3
+  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
+  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
+          PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
+  #define __Pyx_DefaultClassType PyClass_Type
+#else
+  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
+  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
+          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
+  #define __Pyx_DefaultClassType PyType_Type
+#endif
+#ifndef Py_TPFLAGS_CHECKTYPES
+  #define Py_TPFLAGS_CHECKTYPES 0
+#endif
+#ifndef Py_TPFLAGS_HAVE_INDEX
+  #define Py_TPFLAGS_HAVE_INDEX 0
+#endif
+#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
+  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
+#endif
+#ifndef Py_TPFLAGS_HAVE_FINALIZE
+  #define Py_TPFLAGS_HAVE_FINALIZE 0
+#endif
+#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
+  #define CYTHON_PEP393_ENABLED 1
+  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ? \
+                                              0 : _PyUnicode_Ready((PyObject *)(op)))
+  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
+  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
+  #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
+  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
+  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
+#else
+  #define CYTHON_PEP393_ENABLED 0
+  #define __Pyx_PyUnicode_READY(op)       (0)
+  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
+  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
+  #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
+  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
+  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
+#endif
+#if CYTHON_COMPILING_IN_PYPY
+  #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
+  #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
+  #define __Pyx_PyFrozenSet_Size(s)         PyObject_Size(s)
+#else
+  #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
+  #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ? \
+      PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
+  #define __Pyx_PyFrozenSet_Size(s)         PySet_Size(s)
+#endif
+#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
+  #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
+#endif
+#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
+#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
+#if PY_MAJOR_VERSION >= 3
+  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
+#else
+  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define PyBaseString_Type            PyUnicode_Type
+  #define PyStringObject               PyUnicodeObject
+  #define PyString_Type                PyUnicode_Type
+  #define PyString_Check               PyUnicode_Check
+  #define PyString_CheckExact          PyUnicode_CheckExact
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
+  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
+#else
+  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
+  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
+#endif
+#ifndef PySet_CheckExact
+  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
+#endif
+#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
+#if PY_MAJOR_VERSION >= 3
+  #define PyIntObject                  PyLongObject
+  #define PyInt_Type                   PyLong_Type
+  #define PyInt_Check(op)              PyLong_Check(op)
+  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
+  #define PyInt_FromString             PyLong_FromString
+  #define PyInt_FromUnicode            PyLong_FromUnicode
+  #define PyInt_FromLong               PyLong_FromLong
+  #define PyInt_FromSize_t             PyLong_FromSize_t
+  #define PyInt_FromSsize_t            PyLong_FromSsize_t
+  #define PyInt_AsLong                 PyLong_AsLong
+  #define PyInt_AS_LONG                PyLong_AS_LONG
+  #define PyInt_AsSsize_t              PyLong_AsSsize_t
+  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
+  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
+  #define PyNumber_Int                 PyNumber_Long
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define PyBoolObject                 PyLongObject
+#endif
+#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
+  #ifndef PyUnicode_InternFromString
+    #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
+  #endif
+#endif
+#if PY_VERSION_HEX < 0x030200A4
+  typedef long Py_hash_t;
+  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
+  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
+#else
+  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
+  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
+#else
+  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
+#endif
+#ifndef CYTHON_INLINE
+  #if defined(__GNUC__)
+    #define CYTHON_INLINE __inline__
+  #elif defined(_MSC_VER)
+    #define CYTHON_INLINE __inline
+  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+    #define CYTHON_INLINE inline
+  #else
+    #define CYTHON_INLINE
+  #endif
+#endif
+#ifndef CYTHON_RESTRICT
+  #if defined(__GNUC__)
+    #define CYTHON_RESTRICT __restrict__
+  #elif defined(_MSC_VER) && _MSC_VER >= 1400
+    #define CYTHON_RESTRICT __restrict
+  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+    #define CYTHON_RESTRICT restrict
+  #else
+    #define CYTHON_RESTRICT
+  #endif
+#endif
+#ifdef NAN
+#define __PYX_NAN() ((float) NAN)
+#else
+static CYTHON_INLINE float __PYX_NAN() {
+  /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and
+   a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is
+   a quiet NaN. */
+  float value;
+  memset(&value, 0xFF, sizeof(value));
+  return value;
+}
+#endif
+#define __Pyx_void_to_None(void_result) (void_result, Py_INCREF(Py_None), Py_None)
+#ifdef __cplusplus
+template<typename T>
+void __Pyx_call_destructor(T* x) {
+    x->~T();
+}
+template<typename T>
+class __Pyx_FakeReference {
+  public:
+    __Pyx_FakeReference() : ptr(NULL) { }
+    __Pyx_FakeReference(T& ref) : ptr(&ref) { }
+    T *operator->() { return ptr; }
+    operator T&() { return *ptr; }
+  private:
+    T *ptr;
+};
+#endif
+
+
+#if PY_MAJOR_VERSION >= 3
+  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
+  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
+#else
+  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
+  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
+#endif
+
+#ifndef __PYX_EXTERN_C
+  #ifdef __cplusplus
+    #define __PYX_EXTERN_C extern "C"
+  #else
+    #define __PYX_EXTERN_C extern
+  #endif
+#endif
+
+#if defined(WIN32) || defined(MS_WINDOWS)
+#define _USE_MATH_DEFINES
+#endif
+#include <math.h>
+#define __PYX_HAVE__cutadapt___align
+#define __PYX_HAVE_API__cutadapt___align
+#ifdef _OPENMP
+#include <omp.h>
+#endif /* _OPENMP */
+
+#ifdef PYREX_WITHOUT_ASSERTIONS
+#define CYTHON_WITHOUT_ASSERTIONS
+#endif
+
+#ifndef CYTHON_UNUSED
+# if defined(__GNUC__)
+#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
+#     define CYTHON_UNUSED __attribute__ ((__unused__))
+#   else
+#     define CYTHON_UNUSED
+#   endif
+# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
+#   define CYTHON_UNUSED __attribute__ ((__unused__))
+# else
+#   define CYTHON_UNUSED
+# endif
+#endif
+#ifndef CYTHON_NCP_UNUSED
+# if CYTHON_COMPILING_IN_CPYTHON
+#  define CYTHON_NCP_UNUSED
+# else
+#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
+# endif
+#endif
+typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding;
+                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
+
+#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
+#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
+#define __PYX_DEFAULT_STRING_ENCODING ""
+#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
+#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
+#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (    \
+    (sizeof(type) < sizeof(Py_ssize_t))  ||             \
+    (sizeof(type) > sizeof(Py_ssize_t) &&               \
+          likely(v < (type)PY_SSIZE_T_MAX ||            \
+                 v == (type)PY_SSIZE_T_MAX)  &&         \
+          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||       \
+                                v == (type)PY_SSIZE_T_MIN)))  ||  \
+    (sizeof(type) == sizeof(Py_ssize_t) &&              \
+          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||        \
+                               v == (type)PY_SSIZE_T_MAX)))  )
+static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
+static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
+#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
+#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
+#define __Pyx_PyBytes_FromString        PyBytes_FromString
+#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
+static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
+#if PY_MAJOR_VERSION < 3
+    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
+    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
+#else
+    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
+    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
+#endif
+#define __Pyx_PyObject_AsSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
+#define __Pyx_PyObject_AsUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
+#define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
+#define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
+#define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
+#define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
+#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
+#if PY_MAJOR_VERSION < 3
+static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
+{
+    const Py_UNICODE *u_end = u;
+    while (*u_end++) ;
+    return (size_t)(u_end - u - 1);
+}
+#else
+#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
+#endif
+#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
+#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
+#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
+#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
+#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
+static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
+static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
+static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
+static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
+#if CYTHON_COMPILING_IN_CPYTHON
+#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
+#else
+#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
+#endif
+#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
+#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
+static int __Pyx_sys_getdefaultencoding_not_ascii;
+static int __Pyx_init_sys_getdefaultencoding_params(void) {
+    PyObject* sys;
+    PyObject* default_encoding = NULL;
+    PyObject* ascii_chars_u = NULL;
+    PyObject* ascii_chars_b = NULL;
+    const char* default_encoding_c;
+    sys = PyImport_ImportModule("sys");
+    if (!sys) goto bad;
+    default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
+    Py_DECREF(sys);
+    if (!default_encoding) goto bad;
+    default_encoding_c = PyBytes_AsString(default_encoding);
+    if (!default_encoding_c) goto bad;
+    if (strcmp(default_encoding_c, "ascii") == 0) {
+        __Pyx_sys_getdefaultencoding_not_ascii = 0;
+    } else {
+        char ascii_chars[128];
+        int c;
+        for (c = 0; c < 128; c++) {
+            ascii_chars[c] = c;
+        }
+        __Pyx_sys_getdefaultencoding_not_ascii = 1;
+        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
+        if (!ascii_chars_u) goto bad;
+        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
+        if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
+            PyErr_Format(
+                PyExc_ValueError,
+                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
+                default_encoding_c);
+            goto bad;
+        }
+        Py_DECREF(ascii_chars_u);
+        Py_DECREF(ascii_chars_b);
+    }
+    Py_DECREF(default_encoding);
+    return 0;
+bad:
+    Py_XDECREF(default_encoding);
+    Py_XDECREF(ascii_chars_u);
+    Py_XDECREF(ascii_chars_b);
+    return -1;
+}
+#endif
+#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
+#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
+#else
+#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
+#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
+static char* __PYX_DEFAULT_STRING_ENCODING;
+static int __Pyx_init_sys_getdefaultencoding_params(void) {
+    PyObject* sys;
+    PyObject* default_encoding = NULL;
+    char* default_encoding_c;
+    sys = PyImport_ImportModule("sys");
+    if (!sys) goto bad;
+    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
+    Py_DECREF(sys);
+    if (!default_encoding) goto bad;
+    default_encoding_c = PyBytes_AsString(default_encoding);
+    if (!default_encoding_c) goto bad;
+    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
+    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
+    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
+    Py_DECREF(default_encoding);
+    return 0;
+bad:
+    Py_XDECREF(default_encoding);
+    return -1;
+}
+#endif
+#endif
+
+
+/* Test for GCC > 2.95 */
+#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
+  #define likely(x)   __builtin_expect(!!(x), 1)
+  #define unlikely(x) __builtin_expect(!!(x), 0)
+#else /* !__GNUC__ or GCC < 2.95 */
+  #define likely(x)   (x)
+  #define unlikely(x) (x)
+#endif /* __GNUC__ */
+
+static PyObject *__pyx_m;
+static PyObject *__pyx_d;
+static PyObject *__pyx_b;
+static PyObject *__pyx_empty_tuple;
+static PyObject *__pyx_empty_bytes;
+static int __pyx_lineno;
+static int __pyx_clineno = 0;
+static const char * __pyx_cfilenm= __FILE__;
+static const char *__pyx_filename;
+
+
+static const char *__pyx_f[] = {
+  "cutadapt/_align.pyx",
+};
+
+/*--- Type declarations ---*/
+struct __pyx_obj_8cutadapt_6_align_Aligner;
+struct __pyx_t_8cutadapt_6_align__Entry;
+typedef struct __pyx_t_8cutadapt_6_align__Entry __pyx_t_8cutadapt_6_align__Entry;
+struct __pyx_t_8cutadapt_6_align__Match;
+typedef struct __pyx_t_8cutadapt_6_align__Match __pyx_t_8cutadapt_6_align__Match;
+
+/* "cutadapt/_align.pyx":18
+ * 
+ * # structure for a DP matrix entry
+ * ctypedef struct _Entry:             # <<<<<<<<<<<<<<
+ * 	int cost
+ * 	int matches  # no. of matches in this alignment
+ */
+struct __pyx_t_8cutadapt_6_align__Entry {
+  int cost;
+  int matches;
+  int origin;
+};
+
+/* "cutadapt/_align.pyx":24
+ * 
+ * 
+ * ctypedef struct _Match:             # <<<<<<<<<<<<<<
+ * 	int origin
+ * 	int cost
+ */
+struct __pyx_t_8cutadapt_6_align__Match {
+  int origin;
+  int cost;
+  int matches;
+  int ref_stop;
+  int query_stop;
+};
+
+/* "cutadapt/_align.pyx":92
+ * 
+ * 
+ * cdef class Aligner:             # <<<<<<<<<<<<<<
+ * 	"""
+ * 	TODO documentation still uses s1 (reference) and s2 (query).
+ */
+struct __pyx_obj_8cutadapt_6_align_Aligner {
+  PyObject_HEAD
+  int m;
+  __pyx_t_8cutadapt_6_align__Entry *column;
+  double max_error_rate;
+  int flags;
+  int min_overlap;
+  int wildcard_ref;
+  int wildcard_query;
+  PyObject *_reference;
+};
+
+
+/* --- Runtime support code (head) --- */
+#ifndef CYTHON_REFNANNY
+  #define CYTHON_REFNANNY 0
+#endif
+#if CYTHON_REFNANNY
+  typedef struct {
+    void (*INCREF)(void*, PyObject*, int);
+    void (*DECREF)(void*, PyObject*, int);
+    void (*GOTREF)(void*, PyObject*, int);
+    void (*GIVEREF)(void*, PyObject*, int);
+    void* (*SetupContext)(const char*, int, const char*);
+    void (*FinishContext)(void**);
+  } __Pyx_RefNannyAPIStruct;
+  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
+  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
+  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
+#ifdef WITH_THREAD
+  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
+          if (acquire_gil) { \
+              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
+              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
+              PyGILState_Release(__pyx_gilstate_save); \
+          } else { \
+              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
+          }
+#else
+  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
+          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
+#endif
+  #define __Pyx_RefNannyFinishContext() \
+          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
+  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
+  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
+  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
+  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
+#else
+  #define __Pyx_RefNannyDeclarations
+  #define __Pyx_RefNannySetupContext(name, acquire_gil)
+  #define __Pyx_RefNannyFinishContext()
+  #define __Pyx_INCREF(r) Py_INCREF(r)
+  #define __Pyx_DECREF(r) Py_DECREF(r)
+  #define __Pyx_GOTREF(r)
+  #define __Pyx_GIVEREF(r)
+  #define __Pyx_XINCREF(r) Py_XINCREF(r)
+  #define __Pyx_XDECREF(r) Py_XDECREF(r)
+  #define __Pyx_XGOTREF(r)
+  #define __Pyx_XGIVEREF(r)
+#endif
+#define __Pyx_XDECREF_SET(r, v) do {                            \
+        PyObject *tmp = (PyObject *) r;                         \
+        r = v; __Pyx_XDECREF(tmp);                              \
+    } while (0)
+#define __Pyx_DECREF_SET(r, v) do {                             \
+        PyObject *tmp = (PyObject *) r;                         \
+        r = v; __Pyx_DECREF(tmp);                               \
+    } while (0)
+#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
+#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
+
+#if CYTHON_COMPILING_IN_CPYTHON
+static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
+    PyTypeObject* tp = Py_TYPE(obj);
+    if (likely(tp->tp_getattro))
+        return tp->tp_getattro(obj, attr_name);
+#if PY_MAJOR_VERSION < 3
+    if (likely(tp->tp_getattr))
+        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
+#endif
+    return PyObject_GetAttr(obj, attr_name);
+}
+#else
+#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
+#endif
+
+static PyObject *__Pyx_GetBuiltinName(PyObject *name);
+
+#if CYTHON_COMPILING_IN_CPYTHON
+static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
+#else
+#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
+#endif
+
+#if CYTHON_COMPILING_IN_CPYTHON
+static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
+#endif
+
+static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
+
+static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);
+
+static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d);
+
+static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected);
+
+static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index);
+
+static CYTHON_INLINE int __Pyx_IterFinish(void);
+
+static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected);
+
+#if CYTHON_COMPILING_IN_CPYTHON
+static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
+#else
+#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
+#endif
+
+static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
+    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
+
+static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
+
+static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \
+    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \
+    const char* function_name);
+
+static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
+    const char *name, int exact);
+
+#if CYTHON_COMPILING_IN_CPYTHON
+#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o,n,NULL)
+static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
+    PyTypeObject* tp = Py_TYPE(obj);
+    if (likely(tp->tp_setattro))
+        return tp->tp_setattro(obj, attr_name, value);
+#if PY_MAJOR_VERSION < 3
+    if (likely(tp->tp_setattr))
+        return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
+#endif
+    return PyObject_SetAttr(obj, attr_name, value);
+}
+#else
+#define __Pyx_PyObject_DelAttrStr(o,n)   PyObject_DelAttr(o,n)
+#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
+#endif
+
+static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb);
+static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb);
+
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
+
+#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
+    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
+    __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) : \
+    (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) : \
+               __Pyx_GetItemInt_Generic(o, to_py_func(i))))
+#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
+    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
+    __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
+    (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
+                                                              int wraparound, int boundscheck);
+#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
+    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
+    __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
+    (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
+                                                              int wraparound, int boundscheck);
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
+                                                     int is_list, int wraparound, int boundscheck);
+
+static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
+
+typedef struct {
+    int code_line;
+    PyCodeObject* code_object;
+} __Pyx_CodeObjectCacheEntry;
+struct __Pyx_CodeObjectCache {
+    int count;
+    int max_count;
+    __Pyx_CodeObjectCacheEntry* entries;
+};
+static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
+static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
+static PyCodeObject *__pyx_find_code_object(int code_line);
+static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
+
+static void __Pyx_AddTraceback(const char *funcname, int c_line,
+                               int py_line, const char *filename);
+
+static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
+
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
+
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
+
+static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
+
+static int __Pyx_check_binary_version(void);
+
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
+
+
+/* Module declarations from 'cpython.mem' */
+
+/* Module declarations from 'cutadapt._align' */
+static PyTypeObject *__pyx_ptype_8cutadapt_6_align_Aligner = 0;
+static PyObject *__pyx_v_8cutadapt_6_align_ACGT_TABLE = 0;
+static PyObject *__pyx_v_8cutadapt_6_align_IUPAC_TABLE = 0;
+#define __Pyx_MODULE_NAME "cutadapt._align"
+int __pyx_module_is_main_cutadapt___align = 0;
+
+/* Implementation of 'cutadapt._align' */
+static PyObject *__pyx_builtin_ord;
+static PyObject *__pyx_builtin_ValueError;
+static PyObject *__pyx_builtin_MemoryError;
+static PyObject *__pyx_builtin_range;
+static PyObject *__pyx_pf_8cutadapt_6_align__acgt_table(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
+static PyObject *__pyx_pf_8cutadapt_6_align_2_iupac_table(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
+static int __pyx_pf_8cutadapt_6_align_7Aligner___cinit__(struct __pyx_obj_8cutadapt_6_align_Aligner *__pyx_v_self, PyObject *__pyx_v_reference, double __pyx_v_max_error_rate, int __pyx_v_flags, int __pyx_v_degenerate, int __pyx_v_min_overlap); /* proto */
+static PyObject *__pyx_pf_8cutadapt_6_align_7Aligner_9reference___get__(struct __pyx_obj_8cutadapt_6_align_Aligner *__pyx_v_self); /* proto */
+static int __pyx_pf_8cutadapt_6_align_7Aligner_9reference_2__set__(struct __pyx_obj_8cutadapt_6_align_Aligner *__pyx_v_self, PyObject *__pyx_v_reference); /* proto */
+static PyObject *__pyx_pf_8cutadapt_6_align_7Aligner_2locate(struct __pyx_obj_8cutadapt_6_align_Aligner *__pyx_v_self, PyObject *__pyx_v_query); /* proto */
+static void __pyx_pf_8cutadapt_6_align_7Aligner_4__dealloc__(struct __pyx_obj_8cutadapt_6_align_Aligner *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_8cutadapt_6_align_4locate(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_reference, PyObject *__pyx_v_query, double __pyx_v_max_error_rate, int __pyx_v_flags, int __pyx_v_degenerate, int __pyx_v_min_overlap); /* proto */
+static PyObject *__pyx_pf_8cutadapt_6_align_6compare_prefixes(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_query, int __pyx_v_degenerate); /* proto */
+static PyObject *__pyx_tp_new_8cutadapt_6_align_Aligner(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
+static char __pyx_k_[] = "\000";
+static char __pyx_k_A[] = "A";
+static char __pyx_k_B[] = "B";
+static char __pyx_k_C[] = "C";
+static char __pyx_k_D[] = "D";
+static char __pyx_k_G[] = "G";
+static char __pyx_k_H[] = "H";
+static char __pyx_k_K[] = "K";
+static char __pyx_k_M[] = "M";
+static char __pyx_k_N[] = "N";
+static char __pyx_k_R[] = "R";
+static char __pyx_k_S[] = "S";
+static char __pyx_k_T[] = "T";
+static char __pyx_k_U[] = "U";
+static char __pyx_k_V[] = "V";
+static char __pyx_k_W[] = "W";
+static char __pyx_k_X[] = "X";
+static char __pyx_k_Y[] = "Y";
+static char __pyx_k_c[] = "c";
+static char __pyx_k_d[] = "d";
+static char __pyx_k_i[] = "i";
+static char __pyx_k_m[] = "m";
+static char __pyx_k_n[] = "n";
+static char __pyx_k_t[] = "t";
+static char __pyx_k_v[] = "v";
+static char __pyx_k_ord[] = "ord";
+static char __pyx_k_ref[] = "ref";
+static char __pyx_k_main[] = "__main__";
+static char __pyx_k_test[] = "__test__";
+static char __pyx_k_ascii[] = "ascii";
+static char __pyx_k_flags[] = "flags";
+static char __pyx_k_items[] = "items";
+static char __pyx_k_lower[] = "lower";
+static char __pyx_k_q_ptr[] = "q_ptr";
+static char __pyx_k_query[] = "query";
+static char __pyx_k_r_ptr[] = "r_ptr";
+static char __pyx_k_range[] = "range";
+static char __pyx_k_encode[] = "encode";
+static char __pyx_k_length[] = "length";
+static char __pyx_k_locate[] = "locate";
+static char __pyx_k_aligner[] = "aligner";
+static char __pyx_k_matches[] = "matches";
+static char __pyx_k_ref_bytes[] = "ref_bytes";
+static char __pyx_k_reference[] = "reference";
+static char __pyx_k_translate[] = "translate";
+static char __pyx_k_ValueError[] = "ValueError";
+static char __pyx_k_acgt_table[] = "_acgt_table";
+static char __pyx_k_degenerate[] = "degenerate";
+static char __pyx_k_MemoryError[] = "MemoryError";
+static char __pyx_k_iupac_table[] = "_iupac_table";
+static char __pyx_k_min_overlap[] = "min_overlap";
+static char __pyx_k_query_bytes[] = "query_bytes";
+static char __pyx_k_wildcard_ref[] = "wildcard_ref";
+static char __pyx_k_compare_ascii[] = "compare_ascii";
+static char __pyx_k_max_error_rate[] = "max_error_rate";
+static char __pyx_k_wildcard_query[] = "wildcard_query";
+static char __pyx_k_cutadapt__align[] = "cutadapt._align";
+static char __pyx_k_compare_prefixes[] = "compare_prefixes";
+static char __pyx_k_home_marcel_scm_cutadapt_cutada[] = "/home/marcel/scm/cutadapt/cutadapt/_align.pyx";
+static char __pyx_k_minimum_overlap_must_be_at_least[] = "minimum overlap must be at least 1";
+static PyObject *__pyx_kp_b_;
+static PyObject *__pyx_n_s_A;
+static PyObject *__pyx_n_s_B;
+static PyObject *__pyx_n_s_C;
+static PyObject *__pyx_n_s_D;
+static PyObject *__pyx_n_s_G;
+static PyObject *__pyx_n_s_H;
+static PyObject *__pyx_n_s_K;
+static PyObject *__pyx_n_s_M;
+static PyObject *__pyx_n_s_MemoryError;
+static PyObject *__pyx_n_s_N;
+static PyObject *__pyx_n_s_R;
+static PyObject *__pyx_n_s_S;
+static PyObject *__pyx_n_s_T;
+static PyObject *__pyx_n_s_U;
+static PyObject *__pyx_n_s_V;
+static PyObject *__pyx_n_s_ValueError;
+static PyObject *__pyx_n_s_W;
+static PyObject *__pyx_n_s_X;
+static PyObject *__pyx_n_s_Y;
+static PyObject *__pyx_n_s_acgt_table;
+static PyObject *__pyx_n_s_aligner;
+static PyObject *__pyx_n_s_ascii;
+static PyObject *__pyx_n_s_c;
+static PyObject *__pyx_n_s_compare_ascii;
+static PyObject *__pyx_n_s_compare_prefixes;
+static PyObject *__pyx_n_s_cutadapt__align;
+static PyObject *__pyx_n_s_d;
+static PyObject *__pyx_n_s_degenerate;
+static PyObject *__pyx_n_s_encode;
+static PyObject *__pyx_n_s_flags;
+static PyObject *__pyx_kp_s_home_marcel_scm_cutadapt_cutada;
+static PyObject *__pyx_n_s_i;
+static PyObject *__pyx_n_s_items;
+static PyObject *__pyx_n_s_iupac_table;
+static PyObject *__pyx_n_s_length;
+static PyObject *__pyx_n_s_locate;
+static PyObject *__pyx_n_s_lower;
+static PyObject *__pyx_n_s_m;
+static PyObject *__pyx_n_s_main;
+static PyObject *__pyx_n_s_matches;
+static PyObject *__pyx_n_s_max_error_rate;
+static PyObject *__pyx_n_s_min_overlap;
+static PyObject *__pyx_kp_s_minimum_overlap_must_be_at_least;
+static PyObject *__pyx_n_s_n;
+static PyObject *__pyx_n_s_ord;
+static PyObject *__pyx_n_s_q_ptr;
+static PyObject *__pyx_n_s_query;
+static PyObject *__pyx_n_s_query_bytes;
+static PyObject *__pyx_n_s_r_ptr;
+static PyObject *__pyx_n_s_range;
+static PyObject *__pyx_n_s_ref;
+static PyObject *__pyx_n_s_ref_bytes;
+static PyObject *__pyx_n_s_reference;
+static PyObject *__pyx_n_s_t;
+static PyObject *__pyx_n_s_test;
+static PyObject *__pyx_n_s_translate;
+static PyObject *__pyx_n_s_v;
+static PyObject *__pyx_n_s_wildcard_query;
+static PyObject *__pyx_n_s_wildcard_ref;
+static PyObject *__pyx_int_0;
+static PyObject *__pyx_int_1;
+static PyObject *__pyx_int_2;
+static PyObject *__pyx_int_4;
+static PyObject *__pyx_int_8;
+static PyObject *__pyx_int_256;
+static PyObject *__pyx_tuple__2;
+static PyObject *__pyx_tuple__3;
+static PyObject *__pyx_tuple__4;
+static PyObject *__pyx_tuple__5;
+static PyObject *__pyx_tuple__6;
+static PyObject *__pyx_tuple__7;
+static PyObject *__pyx_tuple__8;
+static PyObject *__pyx_tuple__9;
+static PyObject *__pyx_tuple__11;
+static PyObject *__pyx_tuple__13;
+static PyObject *__pyx_tuple__15;
+static PyObject *__pyx_codeobj__10;
+static PyObject *__pyx_codeobj__12;
+static PyObject *__pyx_codeobj__14;
+static PyObject *__pyx_codeobj__16;
+
+/* "cutadapt/_align.pyx":32
+ * 
+ * 
+ * def _acgt_table():             # <<<<<<<<<<<<<<
+ * 	"""
+ * 	Return a translation table that maps A, C, G, T characters to the lower
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_8cutadapt_6_align_1_acgt_table(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static char __pyx_doc_8cutadapt_6_align__acgt_table[] = "\n\tReturn a translation table that maps A, C, G, T characters to the lower\n\tfour bits of a byte. Other characters (including possibly IUPAC characters)\n\tare mapped to zero.\n\n\tLowercase versions are also translated, and U is treated the same as T.\n\t";
+static PyMethodDef __pyx_mdef_8cutadapt_6_align_1_acgt_table = {"_acgt_table", (PyCFunction)__pyx_pw_8cutadapt_6_align_1_acgt_table, METH_NOARGS, __pyx_doc_8cutadapt_6_align__acgt_table};
+static PyObject *__pyx_pw_8cutadapt_6_align_1_acgt_table(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("_acgt_table (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_align__acgt_table(__pyx_self);
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_8cutadapt_6_align__acgt_table(CYTHON_UNUSED PyObject *__pyx_self) {
+  PyObject *__pyx_v_d = NULL;
+  PyObject *__pyx_v_t = NULL;
+  PyObject *__pyx_v_c = NULL;
+  PyObject *__pyx_v_v = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  Py_ssize_t __pyx_t_3;
+  PyObject *(*__pyx_t_4)(PyObject *);
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *(*__pyx_t_8)(PyObject *);
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("_acgt_table", 0);
+
+  /* "cutadapt/_align.pyx":40
+ * 	Lowercase versions are also translated, and U is treated the same as T.
+ * 	"""
+ * 	d = dict(A=1, C=2, G=4, T=8, U=8)             # <<<<<<<<<<<<<<
+ * 	t = bytearray(b'\0') * 256
+ * 	for c, v in d.items():
+ */
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_A, __pyx_int_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_C, __pyx_int_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_G, __pyx_int_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_T, __pyx_int_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_U, __pyx_int_8) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_d = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "cutadapt/_align.pyx":41
+ * 	"""
+ * 	d = dict(A=1, C=2, G=4, T=8, U=8)
+ * 	t = bytearray(b'\0') * 256             # <<<<<<<<<<<<<<
+ * 	for c, v in d.items():
+ * 		t[ord(c)] = v
+ */
+  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyByteArray_Type))), __pyx_tuple__2, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyNumber_Multiply(__pyx_t_1, __pyx_int_256); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (!(likely(PyByteArray_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_t = ((PyObject*)__pyx_t_2);
+  __pyx_t_2 = 0;
+
+  /* "cutadapt/_align.pyx":42
+ * 	d = dict(A=1, C=2, G=4, T=8, U=8)
+ * 	t = bytearray(b'\0') * 256
+ * 	for c, v in d.items():             # <<<<<<<<<<<<<<
+ * 		t[ord(c)] = v
+ * 		t[ord(c.lower())] = v
+ */
+  __pyx_t_2 = __Pyx_PyDict_Items(__pyx_v_d); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
+    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
+    __pyx_t_4 = NULL;
+  } else {
+    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  for (;;) {
+    if (likely(!__pyx_t_4)) {
+      if (likely(PyList_CheckExact(__pyx_t_1))) {
+        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
+        #if CYTHON_COMPILING_IN_CPYTHON
+        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        #else
+        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        #endif
+      } else {
+        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+        #if CYTHON_COMPILING_IN_CPYTHON
+        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        #else
+        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        #endif
+      }
+    } else {
+      __pyx_t_2 = __pyx_t_4(__pyx_t_1);
+      if (unlikely(!__pyx_t_2)) {
+        PyObject* exc_type = PyErr_Occurred();
+        if (exc_type) {
+          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        }
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_2);
+    }
+    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
+      PyObject* sequence = __pyx_t_2;
+      #if CYTHON_COMPILING_IN_CPYTHON
+      Py_ssize_t size = Py_SIZE(sequence);
+      #else
+      Py_ssize_t size = PySequence_Size(sequence);
+      #endif
+      if (unlikely(size != 2)) {
+        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
+        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      }
+      #if CYTHON_COMPILING_IN_CPYTHON
+      if (likely(PyTuple_CheckExact(sequence))) {
+        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
+        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
+      } else {
+        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
+        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
+      }
+      __Pyx_INCREF(__pyx_t_5);
+      __Pyx_INCREF(__pyx_t_6);
+      #else
+      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      #endif
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    } else {
+      Py_ssize_t index = -1;
+      __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
+      index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
+      __Pyx_GOTREF(__pyx_t_5);
+      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
+      __Pyx_GOTREF(__pyx_t_6);
+      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = NULL;
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      goto __pyx_L6_unpacking_done;
+      __pyx_L5_unpacking_failed:;
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __pyx_t_8 = NULL;
+      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_L6_unpacking_done:;
+    }
+    __Pyx_XDECREF_SET(__pyx_v_c, __pyx_t_5);
+    __pyx_t_5 = 0;
+    __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_6);
+    __pyx_t_6 = 0;
+
+    /* "cutadapt/_align.pyx":43
+ * 	t = bytearray(b'\0') * 256
+ * 	for c, v in d.items():
+ * 		t[ord(c)] = v             # <<<<<<<<<<<<<<
+ * 		t[ord(c.lower())] = v
+ * 	return bytes(t)
+ */
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(__pyx_v_c);
+    __Pyx_GIVEREF(__pyx_v_c);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_c);
+    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ord, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    if (unlikely(PyObject_SetItem(__pyx_v_t, __pyx_t_6, __pyx_v_v) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+    /* "cutadapt/_align.pyx":44
+ * 	for c, v in d.items():
+ * 		t[ord(c)] = v
+ * 		t[ord(c.lower())] = v             # <<<<<<<<<<<<<<
+ * 	return bytes(t)
+ * 
+ */
+    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_c, __pyx_n_s_lower); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_5 = NULL;
+    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
+      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
+      if (likely(__pyx_t_5)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+        __Pyx_INCREF(__pyx_t_5);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_2, function);
+      }
+    }
+    if (__pyx_t_5) {
+      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    } else {
+      __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    }
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_GIVEREF(__pyx_t_6);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6);
+    __pyx_t_6 = 0;
+    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ord, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    if (unlikely(PyObject_SetItem(__pyx_v_t, __pyx_t_6, __pyx_v_v) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 44; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+    /* "cutadapt/_align.pyx":42
+ * 	d = dict(A=1, C=2, G=4, T=8, U=8)
+ * 	t = bytearray(b'\0') * 256
+ * 	for c, v in d.items():             # <<<<<<<<<<<<<<
+ * 		t[ord(c)] = v
+ * 		t[ord(c.lower())] = v
+ */
+  }
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "cutadapt/_align.pyx":45
+ * 		t[ord(c)] = v
+ * 		t[ord(c.lower())] = v
+ * 	return bytes(t)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(__pyx_v_t);
+  __Pyx_GIVEREF(__pyx_v_t);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_t);
+  __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyBytes_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 45; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_6);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_r = __pyx_t_6;
+  __pyx_t_6 = 0;
+  goto __pyx_L0;
+
+  /* "cutadapt/_align.pyx":32
+ * 
+ * 
+ * def _acgt_table():             # <<<<<<<<<<<<<<
+ * 	"""
+ * 	Return a translation table that maps A, C, G, T characters to the lower
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("cutadapt._align._acgt_table", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_d);
+  __Pyx_XDECREF(__pyx_v_t);
+  __Pyx_XDECREF(__pyx_v_c);
+  __Pyx_XDECREF(__pyx_v_v);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "cutadapt/_align.pyx":48
+ * 
+ * 
+ * def _iupac_table():             # <<<<<<<<<<<<<<
+ * 	"""
+ * 	Return a translation table for IUPAC characters.
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_8cutadapt_6_align_3_iupac_table(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static char __pyx_doc_8cutadapt_6_align_2_iupac_table[] = "\n\tReturn a translation table for IUPAC characters.\n\n\tThe table maps ASCII-encoded IUPAC nucleotide characters to bytes in which\n\tthe four least significant bits are used to represent one nucleotide each.\n\n\tWhether two characters x and y match can then be checked with the\n\texpression \"x & y != 0\".\n\t";
+static PyMethodDef __pyx_mdef_8cutadapt_6_align_3_iupac_table = {"_iupac_table", (PyCFunction)__pyx_pw_8cutadapt_6_align_3_iupac_table, METH_NOARGS, __pyx_doc_8cutadapt_6_align_2_iupac_table};
+static PyObject *__pyx_pw_8cutadapt_6_align_3_iupac_table(PyObject *__pyx_self, CYTHON_UNUSED PyObject *unused) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("_iupac_table (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_align_2_iupac_table(__pyx_self);
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_8cutadapt_6_align_2_iupac_table(CYTHON_UNUSED PyObject *__pyx_self) {
+  long __pyx_v_A;
+  long __pyx_v_C;
+  long __pyx_v_G;
+  long __pyx_v_T;
+  PyObject *__pyx_v_d = NULL;
+  PyObject *__pyx_v_t = NULL;
+  PyObject *__pyx_v_c = NULL;
+  PyObject *__pyx_v_v = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  Py_ssize_t __pyx_t_3;
+  PyObject *(*__pyx_t_4)(PyObject *);
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *(*__pyx_t_8)(PyObject *);
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("_iupac_table", 0);
+
+  /* "cutadapt/_align.pyx":58
+ * 	expression "x & y != 0".
+ * 	"""
+ * 	A = 1             # <<<<<<<<<<<<<<
+ * 	C = 2
+ * 	G = 4
+ */
+  __pyx_v_A = 1;
+
+  /* "cutadapt/_align.pyx":59
+ * 	"""
+ * 	A = 1
+ * 	C = 2             # <<<<<<<<<<<<<<
+ * 	G = 4
+ * 	T = 8
+ */
+  __pyx_v_C = 2;
+
+  /* "cutadapt/_align.pyx":60
+ * 	A = 1
+ * 	C = 2
+ * 	G = 4             # <<<<<<<<<<<<<<
+ * 	T = 8
+ * 	d = dict(
+ */
+  __pyx_v_G = 4;
+
+  /* "cutadapt/_align.pyx":61
+ * 	C = 2
+ * 	G = 4
+ * 	T = 8             # <<<<<<<<<<<<<<
+ * 	d = dict(
+ * 		X=0,
+ */
+  __pyx_v_T = 8;
+
+  /* "cutadapt/_align.pyx":62
+ * 	G = 4
+ * 	T = 8
+ * 	d = dict(             # <<<<<<<<<<<<<<
+ * 		X=0,
+ * 		A=A,
+ */
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_X, __pyx_int_0) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "cutadapt/_align.pyx":64
+ * 	d = dict(
+ * 		X=0,
+ * 		A=A,             # <<<<<<<<<<<<<<
+ * 		C=C,
+ * 		G=G,
+ */
+  __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_A); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 64; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_A, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "cutadapt/_align.pyx":65
+ * 		X=0,
+ * 		A=A,
+ * 		C=C,             # <<<<<<<<<<<<<<
+ * 		G=G,
+ * 		T=T,
+ */
+  __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_C); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 65; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_C, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "cutadapt/_align.pyx":66
+ * 		A=A,
+ * 		C=C,
+ * 		G=G,             # <<<<<<<<<<<<<<
+ * 		T=T,
+ * 		U=T,
+ */
+  __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_G); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_G, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "cutadapt/_align.pyx":67
+ * 		C=C,
+ * 		G=G,
+ * 		T=T,             # <<<<<<<<<<<<<<
+ * 		U=T,
+ * 		R=A|G,
+ */
+  __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_T); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_T, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "cutadapt/_align.pyx":68
+ * 		G=G,
+ * 		T=T,
+ * 		U=T,             # <<<<<<<<<<<<<<
+ * 		R=A|G,
+ * 		Y=C|T,
+ */
+  __pyx_t_2 = __Pyx_PyInt_From_long(__pyx_v_T); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 68; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_U, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "cutadapt/_align.pyx":69
+ * 		T=T,
+ * 		U=T,
+ * 		R=A|G,             # <<<<<<<<<<<<<<
+ * 		Y=C|T,
+ * 		S=G|C,
+ */
+  __pyx_t_2 = __Pyx_PyInt_From_long((__pyx_v_A | __pyx_v_G)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 69; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_R, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "cutadapt/_align.pyx":70
+ * 		U=T,
+ * 		R=A|G,
+ * 		Y=C|T,             # <<<<<<<<<<<<<<
+ * 		S=G|C,
+ * 		W=A|T,
+ */
+  __pyx_t_2 = __Pyx_PyInt_From_long((__pyx_v_C | __pyx_v_T)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_Y, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "cutadapt/_align.pyx":71
+ * 		R=A|G,
+ * 		Y=C|T,
+ * 		S=G|C,             # <<<<<<<<<<<<<<
+ * 		W=A|T,
+ * 		K=G|T,
+ */
+  __pyx_t_2 = __Pyx_PyInt_From_long((__pyx_v_G | __pyx_v_C)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 71; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_S, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "cutadapt/_align.pyx":72
+ * 		Y=C|T,
+ * 		S=G|C,
+ * 		W=A|T,             # <<<<<<<<<<<<<<
+ * 		K=G|T,
+ * 		M=A|C,
+ */
+  __pyx_t_2 = __Pyx_PyInt_From_long((__pyx_v_A | __pyx_v_T)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 72; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_W, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "cutadapt/_align.pyx":73
+ * 		S=G|C,
+ * 		W=A|T,
+ * 		K=G|T,             # <<<<<<<<<<<<<<
+ * 		M=A|C,
+ * 		B=C|G|T,
+ */
+  __pyx_t_2 = __Pyx_PyInt_From_long((__pyx_v_G | __pyx_v_T)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 73; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_K, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "cutadapt/_align.pyx":74
+ * 		W=A|T,
+ * 		K=G|T,
+ * 		M=A|C,             # <<<<<<<<<<<<<<
+ * 		B=C|G|T,
+ * 		D=A|G|T,
+ */
+  __pyx_t_2 = __Pyx_PyInt_From_long((__pyx_v_A | __pyx_v_C)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_M, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "cutadapt/_align.pyx":75
+ * 		K=G|T,
+ * 		M=A|C,
+ * 		B=C|G|T,             # <<<<<<<<<<<<<<
+ * 		D=A|G|T,
+ * 		H=A|C|T,
+ */
+  __pyx_t_2 = __Pyx_PyInt_From_long(((__pyx_v_C | __pyx_v_G) | __pyx_v_T)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_B, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "cutadapt/_align.pyx":76
+ * 		M=A|C,
+ * 		B=C|G|T,
+ * 		D=A|G|T,             # <<<<<<<<<<<<<<
+ * 		H=A|C|T,
+ * 		V=A|C|G,
+ */
+  __pyx_t_2 = __Pyx_PyInt_From_long(((__pyx_v_A | __pyx_v_G) | __pyx_v_T)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_D, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "cutadapt/_align.pyx":77
+ * 		B=C|G|T,
+ * 		D=A|G|T,
+ * 		H=A|C|T,             # <<<<<<<<<<<<<<
+ * 		V=A|C|G,
+ * 		N=A|C|G|T
+ */
+  __pyx_t_2 = __Pyx_PyInt_From_long(((__pyx_v_A | __pyx_v_C) | __pyx_v_T)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 77; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_H, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "cutadapt/_align.pyx":78
+ * 		D=A|G|T,
+ * 		H=A|C|T,
+ * 		V=A|C|G,             # <<<<<<<<<<<<<<
+ * 		N=A|C|G|T
+ * 	)
+ */
+  __pyx_t_2 = __Pyx_PyInt_From_long(((__pyx_v_A | __pyx_v_C) | __pyx_v_G)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 78; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_V, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "cutadapt/_align.pyx":79
+ * 		H=A|C|T,
+ * 		V=A|C|G,
+ * 		N=A|C|G|T             # <<<<<<<<<<<<<<
+ * 	)
+ * 	t = bytearray(b'\0') * 256
+ */
+  __pyx_t_2 = __Pyx_PyInt_From_long((((__pyx_v_A | __pyx_v_C) | __pyx_v_G) | __pyx_v_T)); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 79; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_N, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 62; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_v_d = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "cutadapt/_align.pyx":81
+ * 		N=A|C|G|T
+ * 	)
+ * 	t = bytearray(b'\0') * 256             # <<<<<<<<<<<<<<
+ * 	for c, v in d.items():
+ * 		t[ord(c)] = v
+ */
+  __pyx_t_1 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyByteArray_Type))), __pyx_tuple__3, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyNumber_Multiply(__pyx_t_1, __pyx_int_256); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  if (!(likely(PyByteArray_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytearray", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_t = ((PyObject*)__pyx_t_2);
+  __pyx_t_2 = 0;
+
+  /* "cutadapt/_align.pyx":82
+ * 	)
+ * 	t = bytearray(b'\0') * 256
+ * 	for c, v in d.items():             # <<<<<<<<<<<<<<
+ * 		t[ord(c)] = v
+ * 		t[ord(c.lower())] = v
+ */
+  __pyx_t_2 = __Pyx_PyDict_Items(__pyx_v_d); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  if (likely(PyList_CheckExact(__pyx_t_2)) || PyTuple_CheckExact(__pyx_t_2)) {
+    __pyx_t_1 = __pyx_t_2; __Pyx_INCREF(__pyx_t_1); __pyx_t_3 = 0;
+    __pyx_t_4 = NULL;
+  } else {
+    __pyx_t_3 = -1; __pyx_t_1 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_4 = Py_TYPE(__pyx_t_1)->tp_iternext; if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  for (;;) {
+    if (likely(!__pyx_t_4)) {
+      if (likely(PyList_CheckExact(__pyx_t_1))) {
+        if (__pyx_t_3 >= PyList_GET_SIZE(__pyx_t_1)) break;
+        #if CYTHON_COMPILING_IN_CPYTHON
+        __pyx_t_2 = PyList_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        #else
+        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        #endif
+      } else {
+        if (__pyx_t_3 >= PyTuple_GET_SIZE(__pyx_t_1)) break;
+        #if CYTHON_COMPILING_IN_CPYTHON
+        __pyx_t_2 = PyTuple_GET_ITEM(__pyx_t_1, __pyx_t_3); __Pyx_INCREF(__pyx_t_2); __pyx_t_3++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        #else
+        __pyx_t_2 = PySequence_ITEM(__pyx_t_1, __pyx_t_3); __pyx_t_3++; if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_2);
+        #endif
+      }
+    } else {
+      __pyx_t_2 = __pyx_t_4(__pyx_t_1);
+      if (unlikely(!__pyx_t_2)) {
+        PyObject* exc_type = PyErr_Occurred();
+        if (exc_type) {
+          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        }
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_2);
+    }
+    if ((likely(PyTuple_CheckExact(__pyx_t_2))) || (PyList_CheckExact(__pyx_t_2))) {
+      PyObject* sequence = __pyx_t_2;
+      #if CYTHON_COMPILING_IN_CPYTHON
+      Py_ssize_t size = Py_SIZE(sequence);
+      #else
+      Py_ssize_t size = PySequence_Size(sequence);
+      #endif
+      if (unlikely(size != 2)) {
+        if (size > 2) __Pyx_RaiseTooManyValuesError(2);
+        else if (size >= 0) __Pyx_RaiseNeedMoreValuesError(size);
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      }
+      #if CYTHON_COMPILING_IN_CPYTHON
+      if (likely(PyTuple_CheckExact(sequence))) {
+        __pyx_t_5 = PyTuple_GET_ITEM(sequence, 0); 
+        __pyx_t_6 = PyTuple_GET_ITEM(sequence, 1); 
+      } else {
+        __pyx_t_5 = PyList_GET_ITEM(sequence, 0); 
+        __pyx_t_6 = PyList_GET_ITEM(sequence, 1); 
+      }
+      __Pyx_INCREF(__pyx_t_5);
+      __Pyx_INCREF(__pyx_t_6);
+      #else
+      __pyx_t_5 = PySequence_ITEM(sequence, 0); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __pyx_t_6 = PySequence_ITEM(sequence, 1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      #endif
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    } else {
+      Py_ssize_t index = -1;
+      __pyx_t_7 = PyObject_GetIter(__pyx_t_2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_7);
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __pyx_t_8 = Py_TYPE(__pyx_t_7)->tp_iternext;
+      index = 0; __pyx_t_5 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_5)) goto __pyx_L5_unpacking_failed;
+      __Pyx_GOTREF(__pyx_t_5);
+      index = 1; __pyx_t_6 = __pyx_t_8(__pyx_t_7); if (unlikely(!__pyx_t_6)) goto __pyx_L5_unpacking_failed;
+      __Pyx_GOTREF(__pyx_t_6);
+      if (__Pyx_IternextUnpackEndCheck(__pyx_t_8(__pyx_t_7), 2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_8 = NULL;
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      goto __pyx_L6_unpacking_done;
+      __pyx_L5_unpacking_failed:;
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __pyx_t_8 = NULL;
+      if (__Pyx_IterFinish() == 0) __Pyx_RaiseNeedMoreValuesError(index);
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_L6_unpacking_done:;
+    }
+    __Pyx_XDECREF_SET(__pyx_v_c, __pyx_t_5);
+    __pyx_t_5 = 0;
+    __Pyx_XDECREF_SET(__pyx_v_v, __pyx_t_6);
+    __pyx_t_6 = 0;
+
+    /* "cutadapt/_align.pyx":83
+ * 	t = bytearray(b'\0') * 256
+ * 	for c, v in d.items():
+ * 		t[ord(c)] = v             # <<<<<<<<<<<<<<
+ * 		t[ord(c.lower())] = v
+ * 	return bytes(t)
+ */
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_INCREF(__pyx_v_c);
+    __Pyx_GIVEREF(__pyx_v_c);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_c);
+    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ord, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    if (unlikely(PyObject_SetItem(__pyx_v_t, __pyx_t_6, __pyx_v_v) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 83; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+    /* "cutadapt/_align.pyx":84
+ * 	for c, v in d.items():
+ * 		t[ord(c)] = v
+ * 		t[ord(c.lower())] = v             # <<<<<<<<<<<<<<
+ * 	return bytes(t)
+ * 
+ */
+    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_c, __pyx_n_s_lower); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_5 = NULL;
+    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
+      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_2);
+      if (likely(__pyx_t_5)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+        __Pyx_INCREF(__pyx_t_5);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_2, function);
+      }
+    }
+    if (__pyx_t_5) {
+      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_5); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    } else {
+      __pyx_t_6 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    }
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_GIVEREF(__pyx_t_6);
+    PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_6);
+    __pyx_t_6 = 0;
+    __pyx_t_6 = __Pyx_PyObject_Call(__pyx_builtin_ord, __pyx_t_2, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    if (unlikely(PyObject_SetItem(__pyx_v_t, __pyx_t_6, __pyx_v_v) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 84; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+
+    /* "cutadapt/_align.pyx":82
+ * 	)
+ * 	t = bytearray(b'\0') * 256
+ * 	for c, v in d.items():             # <<<<<<<<<<<<<<
+ * 		t[ord(c)] = v
+ * 		t[ord(c.lower())] = v
+ */
+  }
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "cutadapt/_align.pyx":85
+ * 		t[ord(c)] = v
+ * 		t[ord(c.lower())] = v
+ * 	return bytes(t)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(__pyx_v_t);
+  __Pyx_GIVEREF(__pyx_v_t);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __pyx_v_t);
+  __pyx_t_6 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)(&PyBytes_Type))), __pyx_t_1, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_6);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_r = __pyx_t_6;
+  __pyx_t_6 = 0;
+  goto __pyx_L0;
+
+  /* "cutadapt/_align.pyx":48
+ * 
+ * 
+ * def _iupac_table():             # <<<<<<<<<<<<<<
+ * 	"""
+ * 	Return a translation table for IUPAC characters.
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("cutadapt._align._iupac_table", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_d);
+  __Pyx_XDECREF(__pyx_v_t);
+  __Pyx_XDECREF(__pyx_v_c);
+  __Pyx_XDECREF(__pyx_v_v);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "cutadapt/_align.pyx":163
+ * 	cdef bytes _reference
+ * 
+ * 	def __cinit__(self, str reference, double max_error_rate, int flags=SEMIGLOBAL, int degenerate=0, int min_overlap=1):             # <<<<<<<<<<<<<<
+ * 		self.max_error_rate = max_error_rate
+ * 		self.flags = flags
+ */
+
+/* Python wrapper */
+static int __pyx_pw_8cutadapt_6_align_7Aligner_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static int __pyx_pw_8cutadapt_6_align_7Aligner_1__cinit__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_reference = 0;
+  double __pyx_v_max_error_rate;
+  int __pyx_v_flags;
+  int __pyx_v_degenerate;
+  int __pyx_v_min_overlap;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__cinit__ (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_reference,&__pyx_n_s_max_error_rate,&__pyx_n_s_flags,&__pyx_n_s_degenerate,&__pyx_n_s_min_overlap,0};
+    PyObject* values[5] = {0,0,0,0,0};
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_reference)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+        case  1:
+        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_max_error_rate)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        }
+        case  2:
+        if (kw_args > 0) {
+          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_flags);
+          if (value) { values[2] = value; kw_args--; }
+        }
+        case  3:
+        if (kw_args > 0) {
+          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_degenerate);
+          if (value) { values[3] = value; kw_args--; }
+        }
+        case  4:
+        if (kw_args > 0) {
+          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_min_overlap);
+          if (value) { values[4] = value; kw_args--; }
+        }
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__cinit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    } else {
+      switch (PyTuple_GET_SIZE(__pyx_args)) {
+        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+    }
+    __pyx_v_reference = ((PyObject*)values[0]);
+    __pyx_v_max_error_rate = __pyx_PyFloat_AsDouble(values[1]); if (unlikely((__pyx_v_max_error_rate == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    if (values[2]) {
+      __pyx_v_flags = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    } else {
+      __pyx_v_flags = ((int)15);
+    }
+    if (values[3]) {
+      __pyx_v_degenerate = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_degenerate == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    } else {
+      __pyx_v_degenerate = ((int)0);
+    }
+    if (values[4]) {
+      __pyx_v_min_overlap = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_min_overlap == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    } else {
+      __pyx_v_min_overlap = ((int)1);
+    }
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("__cinit__", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cutadapt._align.Aligner.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return -1;
+  __pyx_L4_argument_unpacking_done:;
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_reference), (&PyString_Type), 1, "reference", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 163; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_r = __pyx_pf_8cutadapt_6_align_7Aligner___cinit__(((struct __pyx_obj_8cutadapt_6_align_Aligner *)__pyx_v_self), __pyx_v_reference, __pyx_v_max_error_rate, __pyx_v_flags, __pyx_v_degenerate, __pyx_v_min_overlap);
+
+  /* function exit code */
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static int __pyx_pf_8cutadapt_6_align_7Aligner___cinit__(struct __pyx_obj_8cutadapt_6_align_Aligner *__pyx_v_self, PyObject *__pyx_v_reference, double __pyx_v_max_error_rate, int __pyx_v_flags, int __pyx_v_degenerate, int __pyx_v_min_overlap) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("__cinit__", 0);
+
+  /* "cutadapt/_align.pyx":164
+ * 
+ * 	def __cinit__(self, str reference, double max_error_rate, int flags=SEMIGLOBAL, int degenerate=0, int min_overlap=1):
+ * 		self.max_error_rate = max_error_rate             # <<<<<<<<<<<<<<
+ * 		self.flags = flags
+ * 		self.wildcard_ref = degenerate & ALLOW_WILDCARD_SEQ1
+ */
+  __pyx_v_self->max_error_rate = __pyx_v_max_error_rate;
+
+  /* "cutadapt/_align.pyx":165
+ * 	def __cinit__(self, str reference, double max_error_rate, int flags=SEMIGLOBAL, int degenerate=0, int min_overlap=1):
+ * 		self.max_error_rate = max_error_rate
+ * 		self.flags = flags             # <<<<<<<<<<<<<<
+ * 		self.wildcard_ref = degenerate & ALLOW_WILDCARD_SEQ1
+ * 		self.wildcard_query = degenerate & ALLOW_WILDCARD_SEQ2
+ */
+  __pyx_v_self->flags = __pyx_v_flags;
+
+  /* "cutadapt/_align.pyx":166
+ * 		self.max_error_rate = max_error_rate
+ * 		self.flags = flags
+ * 		self.wildcard_ref = degenerate & ALLOW_WILDCARD_SEQ1             # <<<<<<<<<<<<<<
+ * 		self.wildcard_query = degenerate & ALLOW_WILDCARD_SEQ2
+ * 		self.reference = reference
+ */
+  __pyx_v_self->wildcard_ref = (__pyx_v_degenerate & 1);
+
+  /* "cutadapt/_align.pyx":167
+ * 		self.flags = flags
+ * 		self.wildcard_ref = degenerate & ALLOW_WILDCARD_SEQ1
+ * 		self.wildcard_query = degenerate & ALLOW_WILDCARD_SEQ2             # <<<<<<<<<<<<<<
+ * 		self.reference = reference
+ * 		if min_overlap < 1:
+ */
+  __pyx_v_self->wildcard_query = (__pyx_v_degenerate & 2);
+
+  /* "cutadapt/_align.pyx":168
+ * 		self.wildcard_ref = degenerate & ALLOW_WILDCARD_SEQ1
+ * 		self.wildcard_query = degenerate & ALLOW_WILDCARD_SEQ2
+ * 		self.reference = reference             # <<<<<<<<<<<<<<
+ * 		if min_overlap < 1:
+ * 			raise ValueError("minimum overlap must be at least 1")
+ */
+  if (__Pyx_PyObject_SetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_reference, __pyx_v_reference) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "cutadapt/_align.pyx":169
+ * 		self.wildcard_query = degenerate & ALLOW_WILDCARD_SEQ2
+ * 		self.reference = reference
+ * 		if min_overlap < 1:             # <<<<<<<<<<<<<<
+ * 			raise ValueError("minimum overlap must be at least 1")
+ * 		self.min_overlap = min_overlap
+ */
+  __pyx_t_1 = ((__pyx_v_min_overlap < 1) != 0);
+  if (__pyx_t_1) {
+
+    /* "cutadapt/_align.pyx":170
+ * 		self.reference = reference
+ * 		if min_overlap < 1:
+ * 			raise ValueError("minimum overlap must be at least 1")             # <<<<<<<<<<<<<<
+ * 		self.min_overlap = min_overlap
+ * 
+ */
+    __pyx_t_2 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__4, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+
+  /* "cutadapt/_align.pyx":171
+ * 		if min_overlap < 1:
+ * 			raise ValueError("minimum overlap must be at least 1")
+ * 		self.min_overlap = min_overlap             # <<<<<<<<<<<<<<
+ * 
+ * 	property reference:
+ */
+  __pyx_v_self->min_overlap = __pyx_v_min_overlap;
+
+  /* "cutadapt/_align.pyx":163
+ * 	cdef bytes _reference
+ * 
+ * 	def __cinit__(self, str reference, double max_error_rate, int flags=SEMIGLOBAL, int degenerate=0, int min_overlap=1):             # <<<<<<<<<<<<<<
+ * 		self.max_error_rate = max_error_rate
+ * 		self.flags = flags
+ */
+
+  /* function exit code */
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("cutadapt._align.Aligner.__cinit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "cutadapt/_align.pyx":174
+ * 
+ * 	property reference:
+ * 		def __get__(self):             # <<<<<<<<<<<<<<
+ * 			return self._reference
+ * 
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_8cutadapt_6_align_7Aligner_9reference_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_8cutadapt_6_align_7Aligner_9reference_1__get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_align_7Aligner_9reference___get__(((struct __pyx_obj_8cutadapt_6_align_Aligner *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_8cutadapt_6_align_7Aligner_9reference___get__(struct __pyx_obj_8cutadapt_6_align_Aligner *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__", 0);
+
+  /* "cutadapt/_align.pyx":175
+ * 	property reference:
+ * 		def __get__(self):
+ * 			return self._reference             # <<<<<<<<<<<<<<
+ * 
+ * 		def __set__(self, str reference):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_self->_reference);
+  __pyx_r = __pyx_v_self->_reference;
+  goto __pyx_L0;
+
+  /* "cutadapt/_align.pyx":174
+ * 
+ * 	property reference:
+ * 		def __get__(self):             # <<<<<<<<<<<<<<
+ * 			return self._reference
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "cutadapt/_align.pyx":177
+ * 			return self._reference
+ * 
+ * 		def __set__(self, str reference):             # <<<<<<<<<<<<<<
+ * 			mem = <_Entry*> PyMem_Realloc(self.column, (len(reference) + 1) * sizeof(_Entry))
+ * 			if not mem:
+ */
+
+/* Python wrapper */
+static int __pyx_pw_8cutadapt_6_align_7Aligner_9reference_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_reference); /*proto*/
+static int __pyx_pw_8cutadapt_6_align_7Aligner_9reference_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_reference) {
+  CYTHON_UNUSED int __pyx_lineno = 0;
+  CYTHON_UNUSED const char *__pyx_filename = NULL;
+  CYTHON_UNUSED int __pyx_clineno = 0;
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_reference), (&PyString_Type), 1, "reference", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 177; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_r = __pyx_pf_8cutadapt_6_align_7Aligner_9reference_2__set__(((struct __pyx_obj_8cutadapt_6_align_Aligner *)__pyx_v_self), ((PyObject*)__pyx_v_reference));
+
+  /* function exit code */
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static int __pyx_pf_8cutadapt_6_align_7Aligner_9reference_2__set__(struct __pyx_obj_8cutadapt_6_align_Aligner *__pyx_v_self, PyObject *__pyx_v_reference) {
+  __pyx_t_8cutadapt_6_align__Entry *__pyx_v_mem;
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  Py_ssize_t __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("__set__", 0);
+
+  /* "cutadapt/_align.pyx":178
+ * 
+ * 		def __set__(self, str reference):
+ * 			mem = <_Entry*> PyMem_Realloc(self.column, (len(reference) + 1) * sizeof(_Entry))             # <<<<<<<<<<<<<<
+ * 			if not mem:
+ * 				raise MemoryError()
+ */
+  __pyx_t_1 = PyObject_Length(__pyx_v_reference); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_mem = ((__pyx_t_8cutadapt_6_align__Entry *)PyMem_Realloc(__pyx_v_self->column, ((__pyx_t_1 + 1) * (sizeof(__pyx_t_8cutadapt_6_align__Entry)))));
+
+  /* "cutadapt/_align.pyx":179
+ * 		def __set__(self, str reference):
+ * 			mem = <_Entry*> PyMem_Realloc(self.column, (len(reference) + 1) * sizeof(_Entry))
+ * 			if not mem:             # <<<<<<<<<<<<<<
+ * 				raise MemoryError()
+ * 			self.column = mem
+ */
+  __pyx_t_2 = ((!(__pyx_v_mem != 0)) != 0);
+  if (__pyx_t_2) {
+
+    /* "cutadapt/_align.pyx":180
+ * 			mem = <_Entry*> PyMem_Realloc(self.column, (len(reference) + 1) * sizeof(_Entry))
+ * 			if not mem:
+ * 				raise MemoryError()             # <<<<<<<<<<<<<<
+ * 			self.column = mem
+ * 			self._reference = reference.encode('ascii')
+ */
+    PyErr_NoMemory(); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+
+  /* "cutadapt/_align.pyx":181
+ * 			if not mem:
+ * 				raise MemoryError()
+ * 			self.column = mem             # <<<<<<<<<<<<<<
+ * 			self._reference = reference.encode('ascii')
+ * 			self.m = len(reference)
+ */
+  __pyx_v_self->column = __pyx_v_mem;
+
+  /* "cutadapt/_align.pyx":182
+ * 				raise MemoryError()
+ * 			self.column = mem
+ * 			self._reference = reference.encode('ascii')             # <<<<<<<<<<<<<<
+ * 			self.m = len(reference)
+ * 			if self.wildcard_ref:
+ */
+  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_reference, __pyx_n_s_encode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GIVEREF(__pyx_t_4);
+  __Pyx_GOTREF(__pyx_v_self->_reference);
+  __Pyx_DECREF(__pyx_v_self->_reference);
+  __pyx_v_self->_reference = ((PyObject*)__pyx_t_4);
+  __pyx_t_4 = 0;
+
+  /* "cutadapt/_align.pyx":183
+ * 			self.column = mem
+ * 			self._reference = reference.encode('ascii')
+ * 			self.m = len(reference)             # <<<<<<<<<<<<<<
+ * 			if self.wildcard_ref:
+ * 				self._reference = self._reference.translate(IUPAC_TABLE)
+ */
+  __pyx_t_1 = PyObject_Length(__pyx_v_reference); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_self->m = __pyx_t_1;
+
+  /* "cutadapt/_align.pyx":184
+ * 			self._reference = reference.encode('ascii')
+ * 			self.m = len(reference)
+ * 			if self.wildcard_ref:             # <<<<<<<<<<<<<<
+ * 				self._reference = self._reference.translate(IUPAC_TABLE)
+ * 			elif self.wildcard_query:
+ */
+  __pyx_t_2 = (__pyx_v_self->wildcard_ref != 0);
+  if (__pyx_t_2) {
+
+    /* "cutadapt/_align.pyx":185
+ * 			self.m = len(reference)
+ * 			if self.wildcard_ref:
+ * 				self._reference = self._reference.translate(IUPAC_TABLE)             # <<<<<<<<<<<<<<
+ * 			elif self.wildcard_query:
+ * 				self._reference = self._reference.translate(ACGT_TABLE)
+ */
+    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_reference, __pyx_n_s_translate); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_5 = NULL;
+    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
+      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_3);
+      if (likely(__pyx_t_5)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+        __Pyx_INCREF(__pyx_t_5);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_3, function);
+      }
+    }
+    if (!__pyx_t_5) {
+      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_8cutadapt_6_align_IUPAC_TABLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+    } else {
+      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
+      __Pyx_INCREF(__pyx_v_8cutadapt_6_align_IUPAC_TABLE);
+      __Pyx_GIVEREF(__pyx_v_8cutadapt_6_align_IUPAC_TABLE);
+      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_8cutadapt_6_align_IUPAC_TABLE);
+      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_6, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 185; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GIVEREF(__pyx_t_4);
+    __Pyx_GOTREF(__pyx_v_self->_reference);
+    __Pyx_DECREF(__pyx_v_self->_reference);
+    __pyx_v_self->_reference = ((PyObject*)__pyx_t_4);
+    __pyx_t_4 = 0;
+    goto __pyx_L4;
+  }
+
+  /* "cutadapt/_align.pyx":186
+ * 			if self.wildcard_ref:
+ * 				self._reference = self._reference.translate(IUPAC_TABLE)
+ * 			elif self.wildcard_query:             # <<<<<<<<<<<<<<
+ * 				self._reference = self._reference.translate(ACGT_TABLE)
+ * 
+ */
+  __pyx_t_2 = (__pyx_v_self->wildcard_query != 0);
+  if (__pyx_t_2) {
+
+    /* "cutadapt/_align.pyx":187
+ * 				self._reference = self._reference.translate(IUPAC_TABLE)
+ * 			elif self.wildcard_query:
+ * 				self._reference = self._reference.translate(ACGT_TABLE)             # <<<<<<<<<<<<<<
+ * 
+ * 	def locate(self, str query):
+ */
+    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_self->_reference, __pyx_n_s_translate); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_6 = NULL;
+    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
+      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_3);
+      if (likely(__pyx_t_6)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+        __Pyx_INCREF(__pyx_t_6);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_3, function);
+      }
+    }
+    if (!__pyx_t_6) {
+      __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_8cutadapt_6_align_ACGT_TABLE); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+    } else {
+      __pyx_t_5 = PyTuple_New(1+1); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_t_6); __pyx_t_6 = NULL;
+      __Pyx_INCREF(__pyx_v_8cutadapt_6_align_ACGT_TABLE);
+      __Pyx_GIVEREF(__pyx_v_8cutadapt_6_align_ACGT_TABLE);
+      PyTuple_SET_ITEM(__pyx_t_5, 0+1, __pyx_v_8cutadapt_6_align_ACGT_TABLE);
+      __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    if (!(likely(PyBytes_CheckExact(__pyx_t_4))||((__pyx_t_4) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_4)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 187; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GIVEREF(__pyx_t_4);
+    __Pyx_GOTREF(__pyx_v_self->_reference);
+    __Pyx_DECREF(__pyx_v_self->_reference);
+    __pyx_v_self->_reference = ((PyObject*)__pyx_t_4);
+    __pyx_t_4 = 0;
+    goto __pyx_L4;
+  }
+  __pyx_L4:;
+
+  /* "cutadapt/_align.pyx":177
+ * 			return self._reference
+ * 
+ * 		def __set__(self, str reference):             # <<<<<<<<<<<<<<
+ * 			mem = <_Entry*> PyMem_Realloc(self.column, (len(reference) + 1) * sizeof(_Entry))
+ * 			if not mem:
+ */
+
+  /* function exit code */
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("cutadapt._align.Aligner.reference.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "cutadapt/_align.pyx":189
+ * 				self._reference = self._reference.translate(ACGT_TABLE)
+ * 
+ * 	def locate(self, str query):             # <<<<<<<<<<<<<<
+ * 		"""
+ * 		locate(query) -> (refstart, refstop, querystart, querystop, matches, errors)
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_8cutadapt_6_align_7Aligner_3locate(PyObject *__pyx_v_self, PyObject *__pyx_v_query); /*proto*/
+static char __pyx_doc_8cutadapt_6_align_7Aligner_2locate[] = "\n\t\tlocate(query) -> (refstart, refstop, querystart, querystop, matches, errors)\n\n\t\tFind the query within the reference associated with this aligner. The\n\t\tintervals (querystart, querystop) and (refstart, refstop) give the\n\t\tlocation of the match.\n\n\t\tThat is, the substrings query[querystart:querystop] and\n\t\tself.reference[refstart:refstop] were found to align best to each other,\n\t\twith the given number of [...]
+static PyObject *__pyx_pw_8cutadapt_6_align_7Aligner_3locate(PyObject *__pyx_v_self, PyObject *__pyx_v_query) {
+  CYTHON_UNUSED int __pyx_lineno = 0;
+  CYTHON_UNUSED const char *__pyx_filename = NULL;
+  CYTHON_UNUSED int __pyx_clineno = 0;
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("locate (wrapper)", 0);
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_query), (&PyString_Type), 1, "query", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 189; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_r = __pyx_pf_8cutadapt_6_align_7Aligner_2locate(((struct __pyx_obj_8cutadapt_6_align_Aligner *)__pyx_v_self), ((PyObject*)__pyx_v_query));
+
+  /* function exit code */
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_8cutadapt_6_align_7Aligner_2locate(struct __pyx_obj_8cutadapt_6_align_Aligner *__pyx_v_self, PyObject *__pyx_v_query) {
+  char *__pyx_v_s1;
+  PyObject *__pyx_v_query_bytes = 0;
+  char *__pyx_v_s2;
+  int __pyx_v_m;
+  int __pyx_v_n;
+  __pyx_t_8cutadapt_6_align__Entry *__pyx_v_column;
+  double __pyx_v_max_error_rate;
+  int __pyx_v_start_in_ref;
+  int __pyx_v_start_in_query;
+  int __pyx_v_stop_in_ref;
+  int __pyx_v_stop_in_query;
+  int __pyx_v_compare_ascii;
+  int __pyx_v_i;
+  int __pyx_v_j;
+  int __pyx_v_k;
+  int __pyx_v_max_n;
+  int __pyx_v_min_n;
+  __pyx_t_8cutadapt_6_align__Match __pyx_v_best;
+  int __pyx_v_last;
+  int __pyx_v_cost_diag;
+  int __pyx_v_cost_deletion;
+  int __pyx_v_cost_insertion;
+  int __pyx_v_origin;
+  int __pyx_v_cost;
+  int __pyx_v_matches;
+  int __pyx_v_length;
+  int __pyx_v_characters_equal;
+  __pyx_t_8cutadapt_6_align__Entry __pyx_v_tmp_entry;
+  long __pyx_v_first_i;
+  int __pyx_v_start1;
+  int __pyx_v_start2;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  char *__pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  Py_ssize_t __pyx_t_5;
+  __pyx_t_8cutadapt_6_align__Entry *__pyx_t_6;
+  double __pyx_t_7;
+  int __pyx_t_8;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *__pyx_t_10 = NULL;
+  int __pyx_t_11;
+  int __pyx_t_12;
+  int __pyx_t_13;
+  long __pyx_t_14;
+  long __pyx_t_15;
+  int __pyx_t_16;
+  long __pyx_t_17;
+  PyObject *__pyx_t_18 = NULL;
+  PyObject *__pyx_t_19 = NULL;
+  PyObject *__pyx_t_20 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("locate", 0);
+
+  /* "cutadapt/_align.pyx":203
+ * 		The alignment itself is not returned.
+ * 		"""
+ * 		cdef char* s1 = self._reference             # <<<<<<<<<<<<<<
+ * 		cdef bytes query_bytes = query.encode('ascii')
+ * 		cdef char* s2 = query_bytes
+ */
+  __pyx_t_1 = __Pyx_PyObject_AsString(__pyx_v_self->_reference); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 203; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_s1 = __pyx_t_1;
+
+  /* "cutadapt/_align.pyx":204
+ * 		"""
+ * 		cdef char* s1 = self._reference
+ * 		cdef bytes query_bytes = query.encode('ascii')             # <<<<<<<<<<<<<<
+ * 		cdef char* s2 = query_bytes
+ * 		cdef int m = self.m
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_query, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (!(likely(PyBytes_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_query_bytes = ((PyObject*)__pyx_t_3);
+  __pyx_t_3 = 0;
+
+  /* "cutadapt/_align.pyx":205
+ * 		cdef char* s1 = self._reference
+ * 		cdef bytes query_bytes = query.encode('ascii')
+ * 		cdef char* s2 = query_bytes             # <<<<<<<<<<<<<<
+ * 		cdef int m = self.m
+ * 		cdef int n = len(query)
+ */
+  __pyx_t_1 = __Pyx_PyObject_AsString(__pyx_v_query_bytes); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 205; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_s2 = __pyx_t_1;
+
+  /* "cutadapt/_align.pyx":206
+ * 		cdef bytes query_bytes = query.encode('ascii')
+ * 		cdef char* s2 = query_bytes
+ * 		cdef int m = self.m             # <<<<<<<<<<<<<<
+ * 		cdef int n = len(query)
+ * 		cdef _Entry* column = self.column
+ */
+  __pyx_t_4 = __pyx_v_self->m;
+  __pyx_v_m = __pyx_t_4;
+
+  /* "cutadapt/_align.pyx":207
+ * 		cdef char* s2 = query_bytes
+ * 		cdef int m = self.m
+ * 		cdef int n = len(query)             # <<<<<<<<<<<<<<
+ * 		cdef _Entry* column = self.column
+ * 		cdef double max_error_rate = self.max_error_rate
+ */
+  __pyx_t_5 = PyObject_Length(__pyx_v_query); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 207; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_n = __pyx_t_5;
+
+  /* "cutadapt/_align.pyx":208
+ * 		cdef int m = self.m
+ * 		cdef int n = len(query)
+ * 		cdef _Entry* column = self.column             # <<<<<<<<<<<<<<
+ * 		cdef double max_error_rate = self.max_error_rate
+ * 		cdef bint start_in_ref = self.flags & START_WITHIN_SEQ1
+ */
+  __pyx_t_6 = __pyx_v_self->column;
+  __pyx_v_column = __pyx_t_6;
+
+  /* "cutadapt/_align.pyx":209
+ * 		cdef int n = len(query)
+ * 		cdef _Entry* column = self.column
+ * 		cdef double max_error_rate = self.max_error_rate             # <<<<<<<<<<<<<<
+ * 		cdef bint start_in_ref = self.flags & START_WITHIN_SEQ1
+ * 		cdef bint start_in_query = self.flags & START_WITHIN_SEQ2
+ */
+  __pyx_t_7 = __pyx_v_self->max_error_rate;
+  __pyx_v_max_error_rate = __pyx_t_7;
+
+  /* "cutadapt/_align.pyx":210
+ * 		cdef _Entry* column = self.column
+ * 		cdef double max_error_rate = self.max_error_rate
+ * 		cdef bint start_in_ref = self.flags & START_WITHIN_SEQ1             # <<<<<<<<<<<<<<
+ * 		cdef bint start_in_query = self.flags & START_WITHIN_SEQ2
+ * 		cdef bint stop_in_ref = self.flags & STOP_WITHIN_SEQ1
+ */
+  __pyx_v_start_in_ref = (__pyx_v_self->flags & 1);
+
+  /* "cutadapt/_align.pyx":211
+ * 		cdef double max_error_rate = self.max_error_rate
+ * 		cdef bint start_in_ref = self.flags & START_WITHIN_SEQ1
+ * 		cdef bint start_in_query = self.flags & START_WITHIN_SEQ2             # <<<<<<<<<<<<<<
+ * 		cdef bint stop_in_ref = self.flags & STOP_WITHIN_SEQ1
+ * 		cdef bint stop_in_query = self.flags & STOP_WITHIN_SEQ2
+ */
+  __pyx_v_start_in_query = (__pyx_v_self->flags & 2);
+
+  /* "cutadapt/_align.pyx":212
+ * 		cdef bint start_in_ref = self.flags & START_WITHIN_SEQ1
+ * 		cdef bint start_in_query = self.flags & START_WITHIN_SEQ2
+ * 		cdef bint stop_in_ref = self.flags & STOP_WITHIN_SEQ1             # <<<<<<<<<<<<<<
+ * 		cdef bint stop_in_query = self.flags & STOP_WITHIN_SEQ2
+ * 
+ */
+  __pyx_v_stop_in_ref = (__pyx_v_self->flags & 4);
+
+  /* "cutadapt/_align.pyx":213
+ * 		cdef bint start_in_query = self.flags & START_WITHIN_SEQ2
+ * 		cdef bint stop_in_ref = self.flags & STOP_WITHIN_SEQ1
+ * 		cdef bint stop_in_query = self.flags & STOP_WITHIN_SEQ2             # <<<<<<<<<<<<<<
+ * 
+ * 		if self.wildcard_query:
+ */
+  __pyx_v_stop_in_query = (__pyx_v_self->flags & 8);
+
+  /* "cutadapt/_align.pyx":215
+ * 		cdef bint stop_in_query = self.flags & STOP_WITHIN_SEQ2
+ * 
+ * 		if self.wildcard_query:             # <<<<<<<<<<<<<<
+ * 			query_bytes = query_bytes.translate(IUPAC_TABLE)
+ * 			s2 = query_bytes
+ */
+  __pyx_t_8 = (__pyx_v_self->wildcard_query != 0);
+  if (__pyx_t_8) {
+
+    /* "cutadapt/_align.pyx":216
+ * 
+ * 		if self.wildcard_query:
+ * 			query_bytes = query_bytes.translate(IUPAC_TABLE)             # <<<<<<<<<<<<<<
+ * 			s2 = query_bytes
+ * 		elif self.wildcard_ref:
+ */
+    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_query_bytes, __pyx_n_s_translate); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_9 = NULL;
+    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
+      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_2);
+      if (likely(__pyx_t_9)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+        __Pyx_INCREF(__pyx_t_9);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_2, function);
+      }
+    }
+    if (!__pyx_t_9) {
+      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_8cutadapt_6_align_IUPAC_TABLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+    } else {
+      __pyx_t_10 = PyTuple_New(1+1); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_10);
+      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_10, 0, __pyx_t_9); __pyx_t_9 = NULL;
+      __Pyx_INCREF(__pyx_v_8cutadapt_6_align_IUPAC_TABLE);
+      __Pyx_GIVEREF(__pyx_v_8cutadapt_6_align_IUPAC_TABLE);
+      PyTuple_SET_ITEM(__pyx_t_10, 0+1, __pyx_v_8cutadapt_6_align_IUPAC_TABLE);
+      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_10, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_10); __pyx_t_10 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    if (!(likely(PyBytes_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 216; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF_SET(__pyx_v_query_bytes, ((PyObject*)__pyx_t_3));
+    __pyx_t_3 = 0;
+
+    /* "cutadapt/_align.pyx":217
+ * 		if self.wildcard_query:
+ * 			query_bytes = query_bytes.translate(IUPAC_TABLE)
+ * 			s2 = query_bytes             # <<<<<<<<<<<<<<
+ * 		elif self.wildcard_ref:
+ * 			query_bytes = query_bytes.translate(ACGT_TABLE)
+ */
+    __pyx_t_1 = __Pyx_PyObject_AsString(__pyx_v_query_bytes); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 217; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_v_s2 = __pyx_t_1;
+    goto __pyx_L3;
+  }
+
+  /* "cutadapt/_align.pyx":218
+ * 			query_bytes = query_bytes.translate(IUPAC_TABLE)
+ * 			s2 = query_bytes
+ * 		elif self.wildcard_ref:             # <<<<<<<<<<<<<<
+ * 			query_bytes = query_bytes.translate(ACGT_TABLE)
+ * 			s2 = query_bytes
+ */
+  __pyx_t_8 = (__pyx_v_self->wildcard_ref != 0);
+  if (__pyx_t_8) {
+
+    /* "cutadapt/_align.pyx":219
+ * 			s2 = query_bytes
+ * 		elif self.wildcard_ref:
+ * 			query_bytes = query_bytes.translate(ACGT_TABLE)             # <<<<<<<<<<<<<<
+ * 			s2 = query_bytes
+ * 		cdef bint compare_ascii = not (self.wildcard_query or self.wildcard_ref)
+ */
+    __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_query_bytes, __pyx_n_s_translate); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_10 = NULL;
+    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
+      __pyx_t_10 = PyMethod_GET_SELF(__pyx_t_2);
+      if (likely(__pyx_t_10)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+        __Pyx_INCREF(__pyx_t_10);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_2, function);
+      }
+    }
+    if (!__pyx_t_10) {
+      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_v_8cutadapt_6_align_ACGT_TABLE); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+    } else {
+      __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_GIVEREF(__pyx_t_10); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_10); __pyx_t_10 = NULL;
+      __Pyx_INCREF(__pyx_v_8cutadapt_6_align_ACGT_TABLE);
+      __Pyx_GIVEREF(__pyx_v_8cutadapt_6_align_ACGT_TABLE);
+      PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_8cutadapt_6_align_ACGT_TABLE);
+      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    if (!(likely(PyBytes_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 219; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF_SET(__pyx_v_query_bytes, ((PyObject*)__pyx_t_3));
+    __pyx_t_3 = 0;
+
+    /* "cutadapt/_align.pyx":220
+ * 		elif self.wildcard_ref:
+ * 			query_bytes = query_bytes.translate(ACGT_TABLE)
+ * 			s2 = query_bytes             # <<<<<<<<<<<<<<
+ * 		cdef bint compare_ascii = not (self.wildcard_query or self.wildcard_ref)
+ * 		"""
+ */
+    __pyx_t_1 = __Pyx_PyObject_AsString(__pyx_v_query_bytes); if (unlikely((!__pyx_t_1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 220; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_v_s2 = __pyx_t_1;
+    goto __pyx_L3;
+  }
+  __pyx_L3:;
+
+  /* "cutadapt/_align.pyx":221
+ * 			query_bytes = query_bytes.translate(ACGT_TABLE)
+ * 			s2 = query_bytes
+ * 		cdef bint compare_ascii = not (self.wildcard_query or self.wildcard_ref)             # <<<<<<<<<<<<<<
+ * 		"""
+ * 		DP Matrix:
+ */
+  __pyx_t_11 = (__pyx_v_self->wildcard_query != 0);
+  if (!__pyx_t_11) {
+  } else {
+    __pyx_t_8 = __pyx_t_11;
+    goto __pyx_L4_bool_binop_done;
+  }
+  __pyx_t_11 = (__pyx_v_self->wildcard_ref != 0);
+  __pyx_t_8 = __pyx_t_11;
+  __pyx_L4_bool_binop_done:;
+  __pyx_v_compare_ascii = (!__pyx_t_8);
+
+  /* "cutadapt/_align.pyx":235
+ * 
+ * 		# maximum no. of errors
+ * 		cdef int k = <int> (max_error_rate * m)             # <<<<<<<<<<<<<<
+ * 
+ * 		# Determine largest and smallest column we need to compute
+ */
+  __pyx_v_k = ((int)(__pyx_v_max_error_rate * __pyx_v_m));
+
+  /* "cutadapt/_align.pyx":238
+ * 
+ * 		# Determine largest and smallest column we need to compute
+ * 		cdef int max_n = n             # <<<<<<<<<<<<<<
+ * 		cdef int min_n = 0
+ * 		if not start_in_query:
+ */
+  __pyx_v_max_n = __pyx_v_n;
+
+  /* "cutadapt/_align.pyx":239
+ * 		# Determine largest and smallest column we need to compute
+ * 		cdef int max_n = n
+ * 		cdef int min_n = 0             # <<<<<<<<<<<<<<
+ * 		if not start_in_query:
+ * 			# costs can only get worse after column m
+ */
+  __pyx_v_min_n = 0;
+
+  /* "cutadapt/_align.pyx":240
+ * 		cdef int max_n = n
+ * 		cdef int min_n = 0
+ * 		if not start_in_query:             # <<<<<<<<<<<<<<
+ * 			# costs can only get worse after column m
+ * 			max_n = min(n, m + k)
+ */
+  __pyx_t_8 = ((!(__pyx_v_start_in_query != 0)) != 0);
+  if (__pyx_t_8) {
+
+    /* "cutadapt/_align.pyx":242
+ * 		if not start_in_query:
+ * 			# costs can only get worse after column m
+ * 			max_n = min(n, m + k)             # <<<<<<<<<<<<<<
+ * 		if not stop_in_query:
+ * 			min_n = max(0, n - m - k)
+ */
+    __pyx_t_4 = (__pyx_v_m + __pyx_v_k);
+    __pyx_t_12 = __pyx_v_n;
+    if (((__pyx_t_4 < __pyx_t_12) != 0)) {
+      __pyx_t_13 = __pyx_t_4;
+    } else {
+      __pyx_t_13 = __pyx_t_12;
+    }
+    __pyx_v_max_n = __pyx_t_13;
+    goto __pyx_L6;
+  }
+  __pyx_L6:;
+
+  /* "cutadapt/_align.pyx":243
+ * 			# costs can only get worse after column m
+ * 			max_n = min(n, m + k)
+ * 		if not stop_in_query:             # <<<<<<<<<<<<<<
+ * 			min_n = max(0, n - m - k)
+ * 
+ */
+  __pyx_t_8 = ((!(__pyx_v_stop_in_query != 0)) != 0);
+  if (__pyx_t_8) {
+
+    /* "cutadapt/_align.pyx":244
+ * 			max_n = min(n, m + k)
+ * 		if not stop_in_query:
+ * 			min_n = max(0, n - m - k)             # <<<<<<<<<<<<<<
+ * 
+ * 		# Fill column min_n.
+ */
+    __pyx_t_13 = ((__pyx_v_n - __pyx_v_m) - __pyx_v_k);
+    __pyx_t_14 = 0;
+    if (((__pyx_t_13 > __pyx_t_14) != 0)) {
+      __pyx_t_15 = __pyx_t_13;
+    } else {
+      __pyx_t_15 = __pyx_t_14;
+    }
+    __pyx_v_min_n = __pyx_t_15;
+    goto __pyx_L7;
+  }
+  __pyx_L7:;
+
+  /* "cutadapt/_align.pyx":256
+ * 		# TODO (later)
+ * 		# fill out columns only until 'last'
+ * 		if not start_in_ref and not start_in_query:             # <<<<<<<<<<<<<<
+ * 			for i in range(0, m + 1):
+ * 				column[i].matches = 0
+ */
+  __pyx_t_11 = ((!(__pyx_v_start_in_ref != 0)) != 0);
+  if (__pyx_t_11) {
+  } else {
+    __pyx_t_8 = __pyx_t_11;
+    goto __pyx_L9_bool_binop_done;
+  }
+  __pyx_t_11 = ((!(__pyx_v_start_in_query != 0)) != 0);
+  __pyx_t_8 = __pyx_t_11;
+  __pyx_L9_bool_binop_done:;
+  if (__pyx_t_8) {
+
+    /* "cutadapt/_align.pyx":257
+ * 		# fill out columns only until 'last'
+ * 		if not start_in_ref and not start_in_query:
+ * 			for i in range(0, m + 1):             # <<<<<<<<<<<<<<
+ * 				column[i].matches = 0
+ * 				column[i].cost = max(i, min_n)
+ */
+    __pyx_t_15 = (__pyx_v_m + 1);
+    for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_15; __pyx_t_13+=1) {
+      __pyx_v_i = __pyx_t_13;
+
+      /* "cutadapt/_align.pyx":258
+ * 		if not start_in_ref and not start_in_query:
+ * 			for i in range(0, m + 1):
+ * 				column[i].matches = 0             # <<<<<<<<<<<<<<
+ * 				column[i].cost = max(i, min_n)
+ * 				column[i].origin = 0
+ */
+      (__pyx_v_column[__pyx_v_i]).matches = 0;
+
+      /* "cutadapt/_align.pyx":259
+ * 			for i in range(0, m + 1):
+ * 				column[i].matches = 0
+ * 				column[i].cost = max(i, min_n)             # <<<<<<<<<<<<<<
+ * 				column[i].origin = 0
+ * 		elif start_in_ref and not start_in_query:
+ */
+      __pyx_t_4 = __pyx_v_min_n;
+      __pyx_t_12 = __pyx_v_i;
+      if (((__pyx_t_4 > __pyx_t_12) != 0)) {
+        __pyx_t_16 = __pyx_t_4;
+      } else {
+        __pyx_t_16 = __pyx_t_12;
+      }
+      (__pyx_v_column[__pyx_v_i]).cost = __pyx_t_16;
+
+      /* "cutadapt/_align.pyx":260
+ * 				column[i].matches = 0
+ * 				column[i].cost = max(i, min_n)
+ * 				column[i].origin = 0             # <<<<<<<<<<<<<<
+ * 		elif start_in_ref and not start_in_query:
+ * 			for i in range(0, m + 1):
+ */
+      (__pyx_v_column[__pyx_v_i]).origin = 0;
+    }
+    goto __pyx_L8;
+  }
+
+  /* "cutadapt/_align.pyx":261
+ * 				column[i].cost = max(i, min_n)
+ * 				column[i].origin = 0
+ * 		elif start_in_ref and not start_in_query:             # <<<<<<<<<<<<<<
+ * 			for i in range(0, m + 1):
+ * 				column[i].matches = 0
+ */
+  __pyx_t_11 = (__pyx_v_start_in_ref != 0);
+  if (__pyx_t_11) {
+  } else {
+    __pyx_t_8 = __pyx_t_11;
+    goto __pyx_L13_bool_binop_done;
+  }
+  __pyx_t_11 = ((!(__pyx_v_start_in_query != 0)) != 0);
+  __pyx_t_8 = __pyx_t_11;
+  __pyx_L13_bool_binop_done:;
+  if (__pyx_t_8) {
+
+    /* "cutadapt/_align.pyx":262
+ * 				column[i].origin = 0
+ * 		elif start_in_ref and not start_in_query:
+ * 			for i in range(0, m + 1):             # <<<<<<<<<<<<<<
+ * 				column[i].matches = 0
+ * 				column[i].cost = min_n
+ */
+    __pyx_t_15 = (__pyx_v_m + 1);
+    for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_15; __pyx_t_13+=1) {
+      __pyx_v_i = __pyx_t_13;
+
+      /* "cutadapt/_align.pyx":263
+ * 		elif start_in_ref and not start_in_query:
+ * 			for i in range(0, m + 1):
+ * 				column[i].matches = 0             # <<<<<<<<<<<<<<
+ * 				column[i].cost = min_n
+ * 				column[i].origin = min(0, min_n - i)
+ */
+      (__pyx_v_column[__pyx_v_i]).matches = 0;
+
+      /* "cutadapt/_align.pyx":264
+ * 			for i in range(0, m + 1):
+ * 				column[i].matches = 0
+ * 				column[i].cost = min_n             # <<<<<<<<<<<<<<
+ * 				column[i].origin = min(0, min_n - i)
+ * 		elif not start_in_ref and start_in_query:
+ */
+      (__pyx_v_column[__pyx_v_i]).cost = __pyx_v_min_n;
+
+      /* "cutadapt/_align.pyx":265
+ * 				column[i].matches = 0
+ * 				column[i].cost = min_n
+ * 				column[i].origin = min(0, min_n - i)             # <<<<<<<<<<<<<<
+ * 		elif not start_in_ref and start_in_query:
+ * 			for i in range(0, m + 1):
+ */
+      __pyx_t_16 = (__pyx_v_min_n - __pyx_v_i);
+      __pyx_t_14 = 0;
+      if (((__pyx_t_16 < __pyx_t_14) != 0)) {
+        __pyx_t_17 = __pyx_t_16;
+      } else {
+        __pyx_t_17 = __pyx_t_14;
+      }
+      (__pyx_v_column[__pyx_v_i]).origin = __pyx_t_17;
+    }
+    goto __pyx_L8;
+  }
+
+  /* "cutadapt/_align.pyx":266
+ * 				column[i].cost = min_n
+ * 				column[i].origin = min(0, min_n - i)
+ * 		elif not start_in_ref and start_in_query:             # <<<<<<<<<<<<<<
+ * 			for i in range(0, m + 1):
+ * 				column[i].matches = 0
+ */
+  __pyx_t_11 = ((!(__pyx_v_start_in_ref != 0)) != 0);
+  if (__pyx_t_11) {
+  } else {
+    __pyx_t_8 = __pyx_t_11;
+    goto __pyx_L17_bool_binop_done;
+  }
+  __pyx_t_11 = (__pyx_v_start_in_query != 0);
+  __pyx_t_8 = __pyx_t_11;
+  __pyx_L17_bool_binop_done:;
+  if (__pyx_t_8) {
+
+    /* "cutadapt/_align.pyx":267
+ * 				column[i].origin = min(0, min_n - i)
+ * 		elif not start_in_ref and start_in_query:
+ * 			for i in range(0, m + 1):             # <<<<<<<<<<<<<<
+ * 				column[i].matches = 0
+ * 				column[i].cost = i
+ */
+    __pyx_t_15 = (__pyx_v_m + 1);
+    for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_15; __pyx_t_13+=1) {
+      __pyx_v_i = __pyx_t_13;
+
+      /* "cutadapt/_align.pyx":268
+ * 		elif not start_in_ref and start_in_query:
+ * 			for i in range(0, m + 1):
+ * 				column[i].matches = 0             # <<<<<<<<<<<<<<
+ * 				column[i].cost = i
+ * 				column[i].origin = max(0, min_n - i)
+ */
+      (__pyx_v_column[__pyx_v_i]).matches = 0;
+
+      /* "cutadapt/_align.pyx":269
+ * 			for i in range(0, m + 1):
+ * 				column[i].matches = 0
+ * 				column[i].cost = i             # <<<<<<<<<<<<<<
+ * 				column[i].origin = max(0, min_n - i)
+ * 		else:
+ */
+      (__pyx_v_column[__pyx_v_i]).cost = __pyx_v_i;
+
+      /* "cutadapt/_align.pyx":270
+ * 				column[i].matches = 0
+ * 				column[i].cost = i
+ * 				column[i].origin = max(0, min_n - i)             # <<<<<<<<<<<<<<
+ * 		else:
+ * 			for i in range(0, m + 1):
+ */
+      __pyx_t_16 = (__pyx_v_min_n - __pyx_v_i);
+      __pyx_t_17 = 0;
+      if (((__pyx_t_16 > __pyx_t_17) != 0)) {
+        __pyx_t_14 = __pyx_t_16;
+      } else {
+        __pyx_t_14 = __pyx_t_17;
+      }
+      (__pyx_v_column[__pyx_v_i]).origin = __pyx_t_14;
+    }
+    goto __pyx_L8;
+  }
+  /*else*/ {
+
+    /* "cutadapt/_align.pyx":272
+ * 				column[i].origin = max(0, min_n - i)
+ * 		else:
+ * 			for i in range(0, m + 1):             # <<<<<<<<<<<<<<
+ * 				column[i].matches = 0
+ * 				column[i].cost = min(i, min_n)
+ */
+    __pyx_t_15 = (__pyx_v_m + 1);
+    for (__pyx_t_13 = 0; __pyx_t_13 < __pyx_t_15; __pyx_t_13+=1) {
+      __pyx_v_i = __pyx_t_13;
+
+      /* "cutadapt/_align.pyx":273
+ * 		else:
+ * 			for i in range(0, m + 1):
+ * 				column[i].matches = 0             # <<<<<<<<<<<<<<
+ * 				column[i].cost = min(i, min_n)
+ * 				column[i].origin = min_n - i
+ */
+      (__pyx_v_column[__pyx_v_i]).matches = 0;
+
+      /* "cutadapt/_align.pyx":274
+ * 			for i in range(0, m + 1):
+ * 				column[i].matches = 0
+ * 				column[i].cost = min(i, min_n)             # <<<<<<<<<<<<<<
+ * 				column[i].origin = min_n - i
+ * 
+ */
+      __pyx_t_16 = __pyx_v_min_n;
+      __pyx_t_4 = __pyx_v_i;
+      if (((__pyx_t_16 < __pyx_t_4) != 0)) {
+        __pyx_t_12 = __pyx_t_16;
+      } else {
+        __pyx_t_12 = __pyx_t_4;
+      }
+      (__pyx_v_column[__pyx_v_i]).cost = __pyx_t_12;
+
+      /* "cutadapt/_align.pyx":275
+ * 				column[i].matches = 0
+ * 				column[i].cost = min(i, min_n)
+ * 				column[i].origin = min_n - i             # <<<<<<<<<<<<<<
+ * 
+ * 		cdef _Match best
+ */
+      (__pyx_v_column[__pyx_v_i]).origin = (__pyx_v_min_n - __pyx_v_i);
+    }
+  }
+  __pyx_L8:;
+
+  /* "cutadapt/_align.pyx":278
+ * 
+ * 		cdef _Match best
+ * 		best.ref_stop = m             # <<<<<<<<<<<<<<
+ * 		best.query_stop = n
+ * 		best.cost = m + n
+ */
+  __pyx_v_best.ref_stop = __pyx_v_m;
+
+  /* "cutadapt/_align.pyx":279
+ * 		cdef _Match best
+ * 		best.ref_stop = m
+ * 		best.query_stop = n             # <<<<<<<<<<<<<<
+ * 		best.cost = m + n
+ * 		best.origin = 0
+ */
+  __pyx_v_best.query_stop = __pyx_v_n;
+
+  /* "cutadapt/_align.pyx":280
+ * 		best.ref_stop = m
+ * 		best.query_stop = n
+ * 		best.cost = m + n             # <<<<<<<<<<<<<<
+ * 		best.origin = 0
+ * 		best.matches = 0
+ */
+  __pyx_v_best.cost = (__pyx_v_m + __pyx_v_n);
+
+  /* "cutadapt/_align.pyx":281
+ * 		best.query_stop = n
+ * 		best.cost = m + n
+ * 		best.origin = 0             # <<<<<<<<<<<<<<
+ * 		best.matches = 0
+ * 
+ */
+  __pyx_v_best.origin = 0;
+
+  /* "cutadapt/_align.pyx":282
+ * 		best.cost = m + n
+ * 		best.origin = 0
+ * 		best.matches = 0             # <<<<<<<<<<<<<<
+ * 
+ * 		# Ukkonen's trick: index of the last cell that is less than k.
+ */
+  __pyx_v_best.matches = 0;
+
+  /* "cutadapt/_align.pyx":285
+ * 
+ * 		# Ukkonen's trick: index of the last cell that is less than k.
+ * 		cdef int last = k + 1             # <<<<<<<<<<<<<<
+ * 		if start_in_ref:
+ * 			last = m
+ */
+  __pyx_v_last = (__pyx_v_k + 1);
+
+  /* "cutadapt/_align.pyx":286
+ * 		# Ukkonen's trick: index of the last cell that is less than k.
+ * 		cdef int last = k + 1
+ * 		if start_in_ref:             # <<<<<<<<<<<<<<
+ * 			last = m
+ * 
+ */
+  __pyx_t_8 = (__pyx_v_start_in_ref != 0);
+  if (__pyx_t_8) {
+
+    /* "cutadapt/_align.pyx":287
+ * 		cdef int last = k + 1
+ * 		if start_in_ref:
+ * 			last = m             # <<<<<<<<<<<<<<
+ * 
+ * 		cdef int cost_diag
+ */
+    __pyx_v_last = __pyx_v_m;
+    goto __pyx_L23;
+  }
+  __pyx_L23:;
+
+  /* "cutadapt/_align.pyx":298
+ * 
+ * 		# iterate over columns
+ * 		for j in range(min_n + 1, max_n + 1):             # <<<<<<<<<<<<<<
+ * 			# remember first entry
+ * 			tmp_entry = column[0]
+ */
+  __pyx_t_15 = (__pyx_v_max_n + 1);
+  for (__pyx_t_13 = (__pyx_v_min_n + 1); __pyx_t_13 < __pyx_t_15; __pyx_t_13+=1) {
+    __pyx_v_j = __pyx_t_13;
+
+    /* "cutadapt/_align.pyx":300
+ * 		for j in range(min_n + 1, max_n + 1):
+ * 			# remember first entry
+ * 			tmp_entry = column[0]             # <<<<<<<<<<<<<<
+ * 
+ * 			# fill in first entry in this column
+ */
+    __pyx_v_tmp_entry = (__pyx_v_column[0]);
+
+    /* "cutadapt/_align.pyx":303
+ * 
+ * 			# fill in first entry in this column
+ * 			if start_in_query:             # <<<<<<<<<<<<<<
+ * 				column[0].origin = j
+ * 			else:
+ */
+    __pyx_t_8 = (__pyx_v_start_in_query != 0);
+    if (__pyx_t_8) {
+
+      /* "cutadapt/_align.pyx":304
+ * 			# fill in first entry in this column
+ * 			if start_in_query:
+ * 				column[0].origin = j             # <<<<<<<<<<<<<<
+ * 			else:
+ * 				column[0].cost = j * INSERTION_COST
+ */
+      (__pyx_v_column[0]).origin = __pyx_v_j;
+      goto __pyx_L26;
+    }
+    /*else*/ {
+
+      /* "cutadapt/_align.pyx":306
+ * 				column[0].origin = j
+ * 			else:
+ * 				column[0].cost = j * INSERTION_COST             # <<<<<<<<<<<<<<
+ * 			for i in range(1, last + 1):
+ * 				if compare_ascii:
+ */
+      (__pyx_v_column[0]).cost = (__pyx_v_j * 1);
+    }
+    __pyx_L26:;
+
+    /* "cutadapt/_align.pyx":307
+ * 			else:
+ * 				column[0].cost = j * INSERTION_COST
+ * 			for i in range(1, last + 1):             # <<<<<<<<<<<<<<
+ * 				if compare_ascii:
+ * 					characters_equal = (s1[i-1] == s2[j-1])
+ */
+    __pyx_t_14 = (__pyx_v_last + 1);
+    for (__pyx_t_12 = 1; __pyx_t_12 < __pyx_t_14; __pyx_t_12+=1) {
+      __pyx_v_i = __pyx_t_12;
+
+      /* "cutadapt/_align.pyx":308
+ * 				column[0].cost = j * INSERTION_COST
+ * 			for i in range(1, last + 1):
+ * 				if compare_ascii:             # <<<<<<<<<<<<<<
+ * 					characters_equal = (s1[i-1] == s2[j-1])
+ * 				else:
+ */
+      __pyx_t_8 = (__pyx_v_compare_ascii != 0);
+      if (__pyx_t_8) {
+
+        /* "cutadapt/_align.pyx":309
+ * 			for i in range(1, last + 1):
+ * 				if compare_ascii:
+ * 					characters_equal = (s1[i-1] == s2[j-1])             # <<<<<<<<<<<<<<
+ * 				else:
+ * 					characters_equal = (s1[i-1] & s2[j-1]) != 0
+ */
+        __pyx_v_characters_equal = ((__pyx_v_s1[(__pyx_v_i - 1)]) == (__pyx_v_s2[(__pyx_v_j - 1)]));
+        goto __pyx_L29;
+      }
+      /*else*/ {
+
+        /* "cutadapt/_align.pyx":311
+ * 					characters_equal = (s1[i-1] == s2[j-1])
+ * 				else:
+ * 					characters_equal = (s1[i-1] & s2[j-1]) != 0             # <<<<<<<<<<<<<<
+ * 				if characters_equal:
+ * 					# Characters match: This cannot be an indel.
+ */
+        __pyx_v_characters_equal = (((__pyx_v_s1[(__pyx_v_i - 1)]) & (__pyx_v_s2[(__pyx_v_j - 1)])) != 0);
+      }
+      __pyx_L29:;
+
+      /* "cutadapt/_align.pyx":312
+ * 				else:
+ * 					characters_equal = (s1[i-1] & s2[j-1]) != 0
+ * 				if characters_equal:             # <<<<<<<<<<<<<<
+ * 					# Characters match: This cannot be an indel.
+ * 					cost = tmp_entry.cost
+ */
+      __pyx_t_8 = (__pyx_v_characters_equal != 0);
+      if (__pyx_t_8) {
+
+        /* "cutadapt/_align.pyx":314
+ * 				if characters_equal:
+ * 					# Characters match: This cannot be an indel.
+ * 					cost = tmp_entry.cost             # <<<<<<<<<<<<<<
+ * 					origin = tmp_entry.origin
+ * 					matches = tmp_entry.matches + 1
+ */
+        __pyx_t_16 = __pyx_v_tmp_entry.cost;
+        __pyx_v_cost = __pyx_t_16;
+
+        /* "cutadapt/_align.pyx":315
+ * 					# Characters match: This cannot be an indel.
+ * 					cost = tmp_entry.cost
+ * 					origin = tmp_entry.origin             # <<<<<<<<<<<<<<
+ * 					matches = tmp_entry.matches + 1
+ * 				else:
+ */
+        __pyx_t_16 = __pyx_v_tmp_entry.origin;
+        __pyx_v_origin = __pyx_t_16;
+
+        /* "cutadapt/_align.pyx":316
+ * 					cost = tmp_entry.cost
+ * 					origin = tmp_entry.origin
+ * 					matches = tmp_entry.matches + 1             # <<<<<<<<<<<<<<
+ * 				else:
+ * 					# Characters do not match.
+ */
+        __pyx_v_matches = (__pyx_v_tmp_entry.matches + 1);
+        goto __pyx_L30;
+      }
+      /*else*/ {
+
+        /* "cutadapt/_align.pyx":319
+ * 				else:
+ * 					# Characters do not match.
+ * 					cost_diag = tmp_entry.cost + 1             # <<<<<<<<<<<<<<
+ * 					cost_deletion = column[i].cost + DELETION_COST
+ * 					cost_insertion = column[i-1].cost + INSERTION_COST
+ */
+        __pyx_v_cost_diag = (__pyx_v_tmp_entry.cost + 1);
+
+        /* "cutadapt/_align.pyx":320
+ * 					# Characters do not match.
+ * 					cost_diag = tmp_entry.cost + 1
+ * 					cost_deletion = column[i].cost + DELETION_COST             # <<<<<<<<<<<<<<
+ * 					cost_insertion = column[i-1].cost + INSERTION_COST
+ * 
+ */
+        __pyx_v_cost_deletion = ((__pyx_v_column[__pyx_v_i]).cost + 1);
+
+        /* "cutadapt/_align.pyx":321
+ * 					cost_diag = tmp_entry.cost + 1
+ * 					cost_deletion = column[i].cost + DELETION_COST
+ * 					cost_insertion = column[i-1].cost + INSERTION_COST             # <<<<<<<<<<<<<<
+ * 
+ * 					if cost_diag <= cost_deletion and cost_diag <= cost_insertion:
+ */
+        __pyx_v_cost_insertion = ((__pyx_v_column[(__pyx_v_i - 1)]).cost + 1);
+
+        /* "cutadapt/_align.pyx":323
+ * 					cost_insertion = column[i-1].cost + INSERTION_COST
+ * 
+ * 					if cost_diag <= cost_deletion and cost_diag <= cost_insertion:             # <<<<<<<<<<<<<<
+ * 						# MISMATCH
+ * 						cost = cost_diag
+ */
+        __pyx_t_11 = ((__pyx_v_cost_diag <= __pyx_v_cost_deletion) != 0);
+        if (__pyx_t_11) {
+        } else {
+          __pyx_t_8 = __pyx_t_11;
+          goto __pyx_L32_bool_binop_done;
+        }
+        __pyx_t_11 = ((__pyx_v_cost_diag <= __pyx_v_cost_insertion) != 0);
+        __pyx_t_8 = __pyx_t_11;
+        __pyx_L32_bool_binop_done:;
+        if (__pyx_t_8) {
+
+          /* "cutadapt/_align.pyx":325
+ * 					if cost_diag <= cost_deletion and cost_diag <= cost_insertion:
+ * 						# MISMATCH
+ * 						cost = cost_diag             # <<<<<<<<<<<<<<
+ * 						origin = tmp_entry.origin
+ * 						matches = tmp_entry.matches
+ */
+          __pyx_v_cost = __pyx_v_cost_diag;
+
+          /* "cutadapt/_align.pyx":326
+ * 						# MISMATCH
+ * 						cost = cost_diag
+ * 						origin = tmp_entry.origin             # <<<<<<<<<<<<<<
+ * 						matches = tmp_entry.matches
+ * 					elif cost_insertion <= cost_deletion:
+ */
+          __pyx_t_16 = __pyx_v_tmp_entry.origin;
+          __pyx_v_origin = __pyx_t_16;
+
+          /* "cutadapt/_align.pyx":327
+ * 						cost = cost_diag
+ * 						origin = tmp_entry.origin
+ * 						matches = tmp_entry.matches             # <<<<<<<<<<<<<<
+ * 					elif cost_insertion <= cost_deletion:
+ * 						# INSERTION
+ */
+          __pyx_t_16 = __pyx_v_tmp_entry.matches;
+          __pyx_v_matches = __pyx_t_16;
+          goto __pyx_L31;
+        }
+
+        /* "cutadapt/_align.pyx":328
+ * 						origin = tmp_entry.origin
+ * 						matches = tmp_entry.matches
+ * 					elif cost_insertion <= cost_deletion:             # <<<<<<<<<<<<<<
+ * 						# INSERTION
+ * 						cost = cost_insertion
+ */
+        __pyx_t_8 = ((__pyx_v_cost_insertion <= __pyx_v_cost_deletion) != 0);
+        if (__pyx_t_8) {
+
+          /* "cutadapt/_align.pyx":330
+ * 					elif cost_insertion <= cost_deletion:
+ * 						# INSERTION
+ * 						cost = cost_insertion             # <<<<<<<<<<<<<<
+ * 						origin = column[i-1].origin
+ * 						matches = column[i-1].matches
+ */
+          __pyx_v_cost = __pyx_v_cost_insertion;
+
+          /* "cutadapt/_align.pyx":331
+ * 						# INSERTION
+ * 						cost = cost_insertion
+ * 						origin = column[i-1].origin             # <<<<<<<<<<<<<<
+ * 						matches = column[i-1].matches
+ * 					else:
+ */
+          __pyx_t_16 = (__pyx_v_column[(__pyx_v_i - 1)]).origin;
+          __pyx_v_origin = __pyx_t_16;
+
+          /* "cutadapt/_align.pyx":332
+ * 						cost = cost_insertion
+ * 						origin = column[i-1].origin
+ * 						matches = column[i-1].matches             # <<<<<<<<<<<<<<
+ * 					else:
+ * 						# DELETION
+ */
+          __pyx_t_16 = (__pyx_v_column[(__pyx_v_i - 1)]).matches;
+          __pyx_v_matches = __pyx_t_16;
+          goto __pyx_L31;
+        }
+        /*else*/ {
+
+          /* "cutadapt/_align.pyx":335
+ * 					else:
+ * 						# DELETION
+ * 						cost = cost_deletion             # <<<<<<<<<<<<<<
+ * 						origin = column[i].origin
+ * 						matches = column[i].matches
+ */
+          __pyx_v_cost = __pyx_v_cost_deletion;
+
+          /* "cutadapt/_align.pyx":336
+ * 						# DELETION
+ * 						cost = cost_deletion
+ * 						origin = column[i].origin             # <<<<<<<<<<<<<<
+ * 						matches = column[i].matches
+ * 
+ */
+          __pyx_t_16 = (__pyx_v_column[__pyx_v_i]).origin;
+          __pyx_v_origin = __pyx_t_16;
+
+          /* "cutadapt/_align.pyx":337
+ * 						cost = cost_deletion
+ * 						origin = column[i].origin
+ * 						matches = column[i].matches             # <<<<<<<<<<<<<<
+ * 
+ * 				# remember current cell for next iteration
+ */
+          __pyx_t_16 = (__pyx_v_column[__pyx_v_i]).matches;
+          __pyx_v_matches = __pyx_t_16;
+        }
+        __pyx_L31:;
+      }
+      __pyx_L30:;
+
+      /* "cutadapt/_align.pyx":340
+ * 
+ * 				# remember current cell for next iteration
+ * 				tmp_entry = column[i]             # <<<<<<<<<<<<<<
+ * 
+ * 				column[i].cost = cost
+ */
+      __pyx_v_tmp_entry = (__pyx_v_column[__pyx_v_i]);
+
+      /* "cutadapt/_align.pyx":342
+ * 				tmp_entry = column[i]
+ * 
+ * 				column[i].cost = cost             # <<<<<<<<<<<<<<
+ * 				column[i].origin = origin
+ * 				column[i].matches = matches
+ */
+      (__pyx_v_column[__pyx_v_i]).cost = __pyx_v_cost;
+
+      /* "cutadapt/_align.pyx":343
+ * 
+ * 				column[i].cost = cost
+ * 				column[i].origin = origin             # <<<<<<<<<<<<<<
+ * 				column[i].matches = matches
+ * 			while last >= 0 and column[last].cost > k:
+ */
+      (__pyx_v_column[__pyx_v_i]).origin = __pyx_v_origin;
+
+      /* "cutadapt/_align.pyx":344
+ * 				column[i].cost = cost
+ * 				column[i].origin = origin
+ * 				column[i].matches = matches             # <<<<<<<<<<<<<<
+ * 			while last >= 0 and column[last].cost > k:
+ * 				last -= 1
+ */
+      (__pyx_v_column[__pyx_v_i]).matches = __pyx_v_matches;
+    }
+
+    /* "cutadapt/_align.pyx":345
+ * 				column[i].origin = origin
+ * 				column[i].matches = matches
+ * 			while last >= 0 and column[last].cost > k:             # <<<<<<<<<<<<<<
+ * 				last -= 1
+ * 			# last can be -1 here, but will be incremented next.
+ */
+    while (1) {
+      __pyx_t_11 = ((__pyx_v_last >= 0) != 0);
+      if (__pyx_t_11) {
+      } else {
+        __pyx_t_8 = __pyx_t_11;
+        goto __pyx_L36_bool_binop_done;
+      }
+      __pyx_t_11 = (((__pyx_v_column[__pyx_v_last]).cost > __pyx_v_k) != 0);
+      __pyx_t_8 = __pyx_t_11;
+      __pyx_L36_bool_binop_done:;
+      if (!__pyx_t_8) break;
+
+      /* "cutadapt/_align.pyx":346
+ * 				column[i].matches = matches
+ * 			while last >= 0 and column[last].cost > k:
+ * 				last -= 1             # <<<<<<<<<<<<<<
+ * 			# last can be -1 here, but will be incremented next.
+ * 			# TODO if last is -1, can we stop searching?
+ */
+      __pyx_v_last = (__pyx_v_last - 1);
+    }
+
+    /* "cutadapt/_align.pyx":349
+ * 			# last can be -1 here, but will be incremented next.
+ * 			# TODO if last is -1, can we stop searching?
+ * 			if last < m:             # <<<<<<<<<<<<<<
+ * 				last += 1
+ * 			elif stop_in_query:
+ */
+    __pyx_t_8 = ((__pyx_v_last < __pyx_v_m) != 0);
+    if (__pyx_t_8) {
+
+      /* "cutadapt/_align.pyx":350
+ * 			# TODO if last is -1, can we stop searching?
+ * 			if last < m:
+ * 				last += 1             # <<<<<<<<<<<<<<
+ * 			elif stop_in_query:
+ * 				# Found a match. If requested, find best match in last row.
+ */
+      __pyx_v_last = (__pyx_v_last + 1);
+      goto __pyx_L38;
+    }
+
+    /* "cutadapt/_align.pyx":351
+ * 			if last < m:
+ * 				last += 1
+ * 			elif stop_in_query:             # <<<<<<<<<<<<<<
+ * 				# Found a match. If requested, find best match in last row.
+ * 				# length of the aligned part of the reference
+ */
+    __pyx_t_8 = (__pyx_v_stop_in_query != 0);
+    if (__pyx_t_8) {
+
+      /* "cutadapt/_align.pyx":354
+ * 				# Found a match. If requested, find best match in last row.
+ * 				# length of the aligned part of the reference
+ * 				length = m + min(column[m].origin, 0)             # <<<<<<<<<<<<<<
+ * 				cost = column[m].cost
+ * 				matches = column[m].matches
+ */
+      __pyx_t_14 = 0;
+      __pyx_t_12 = (__pyx_v_column[__pyx_v_m]).origin;
+      if (((__pyx_t_14 < __pyx_t_12) != 0)) {
+        __pyx_t_17 = __pyx_t_14;
+      } else {
+        __pyx_t_17 = __pyx_t_12;
+      }
+      __pyx_v_length = (__pyx_v_m + __pyx_t_17);
+
+      /* "cutadapt/_align.pyx":355
+ * 				# length of the aligned part of the reference
+ * 				length = m + min(column[m].origin, 0)
+ * 				cost = column[m].cost             # <<<<<<<<<<<<<<
+ * 				matches = column[m].matches
+ * 				if length >= self.min_overlap and cost <= length * max_error_rate and (matches > best.matches or (matches == best.matches and cost < best.cost)):
+ */
+      __pyx_t_12 = (__pyx_v_column[__pyx_v_m]).cost;
+      __pyx_v_cost = __pyx_t_12;
+
+      /* "cutadapt/_align.pyx":356
+ * 				length = m + min(column[m].origin, 0)
+ * 				cost = column[m].cost
+ * 				matches = column[m].matches             # <<<<<<<<<<<<<<
+ * 				if length >= self.min_overlap and cost <= length * max_error_rate and (matches > best.matches or (matches == best.matches and cost < best.cost)):
+ * 					# update
+ */
+      __pyx_t_12 = (__pyx_v_column[__pyx_v_m]).matches;
+      __pyx_v_matches = __pyx_t_12;
+
+      /* "cutadapt/_align.pyx":357
+ * 				cost = column[m].cost
+ * 				matches = column[m].matches
+ * 				if length >= self.min_overlap and cost <= length * max_error_rate and (matches > best.matches or (matches == best.matches and cost < best.cost)):             # <<<<<<<<<<<<<<
+ * 					# update
+ * 					best.matches = matches
+ */
+      __pyx_t_11 = ((__pyx_v_length >= __pyx_v_self->min_overlap) != 0);
+      if (__pyx_t_11) {
+      } else {
+        __pyx_t_8 = __pyx_t_11;
+        goto __pyx_L40_bool_binop_done;
+      }
+      __pyx_t_11 = ((__pyx_v_cost <= (__pyx_v_length * __pyx_v_max_error_rate)) != 0);
+      if (__pyx_t_11) {
+      } else {
+        __pyx_t_8 = __pyx_t_11;
+        goto __pyx_L40_bool_binop_done;
+      }
+      __pyx_t_11 = ((__pyx_v_matches > __pyx_v_best.matches) != 0);
+      if (!__pyx_t_11) {
+      } else {
+        __pyx_t_8 = __pyx_t_11;
+        goto __pyx_L40_bool_binop_done;
+      }
+      __pyx_t_11 = ((__pyx_v_matches == __pyx_v_best.matches) != 0);
+      if (__pyx_t_11) {
+      } else {
+        __pyx_t_8 = __pyx_t_11;
+        goto __pyx_L40_bool_binop_done;
+      }
+      __pyx_t_11 = ((__pyx_v_cost < __pyx_v_best.cost) != 0);
+      __pyx_t_8 = __pyx_t_11;
+      __pyx_L40_bool_binop_done:;
+      if (__pyx_t_8) {
+
+        /* "cutadapt/_align.pyx":359
+ * 				if length >= self.min_overlap and cost <= length * max_error_rate and (matches > best.matches or (matches == best.matches and cost < best.cost)):
+ * 					# update
+ * 					best.matches = matches             # <<<<<<<<<<<<<<
+ * 					best.cost = cost
+ * 					best.origin = column[m].origin
+ */
+        __pyx_v_best.matches = __pyx_v_matches;
+
+        /* "cutadapt/_align.pyx":360
+ * 					# update
+ * 					best.matches = matches
+ * 					best.cost = cost             # <<<<<<<<<<<<<<
+ * 					best.origin = column[m].origin
+ * 					best.ref_stop = m
+ */
+        __pyx_v_best.cost = __pyx_v_cost;
+
+        /* "cutadapt/_align.pyx":361
+ * 					best.matches = matches
+ * 					best.cost = cost
+ * 					best.origin = column[m].origin             # <<<<<<<<<<<<<<
+ * 					best.ref_stop = m
+ * 					best.query_stop = j
+ */
+        __pyx_t_12 = (__pyx_v_column[__pyx_v_m]).origin;
+        __pyx_v_best.origin = __pyx_t_12;
+
+        /* "cutadapt/_align.pyx":362
+ * 					best.cost = cost
+ * 					best.origin = column[m].origin
+ * 					best.ref_stop = m             # <<<<<<<<<<<<<<
+ * 					best.query_stop = j
+ * 					if cost == 0 and matches == m:
+ */
+        __pyx_v_best.ref_stop = __pyx_v_m;
+
+        /* "cutadapt/_align.pyx":363
+ * 					best.origin = column[m].origin
+ * 					best.ref_stop = m
+ * 					best.query_stop = j             # <<<<<<<<<<<<<<
+ * 					if cost == 0 and matches == m:
+ * 						# exact match, stop early
+ */
+        __pyx_v_best.query_stop = __pyx_v_j;
+
+        /* "cutadapt/_align.pyx":364
+ * 					best.ref_stop = m
+ * 					best.query_stop = j
+ * 					if cost == 0 and matches == m:             # <<<<<<<<<<<<<<
+ * 						# exact match, stop early
+ * 						break
+ */
+        __pyx_t_11 = ((__pyx_v_cost == 0) != 0);
+        if (__pyx_t_11) {
+        } else {
+          __pyx_t_8 = __pyx_t_11;
+          goto __pyx_L46_bool_binop_done;
+        }
+        __pyx_t_11 = ((__pyx_v_matches == __pyx_v_m) != 0);
+        __pyx_t_8 = __pyx_t_11;
+        __pyx_L46_bool_binop_done:;
+        if (__pyx_t_8) {
+
+          /* "cutadapt/_align.pyx":366
+ * 					if cost == 0 and matches == m:
+ * 						# exact match, stop early
+ * 						break             # <<<<<<<<<<<<<<
+ * 			# column finished
+ * 
+ */
+          goto __pyx_L25_break;
+        }
+        goto __pyx_L39;
+      }
+      __pyx_L39:;
+      goto __pyx_L38;
+    }
+    __pyx_L38:;
+  }
+  __pyx_L25_break:;
+
+  /* "cutadapt/_align.pyx":369
+ * 			# column finished
+ * 
+ * 		if max_n == n:             # <<<<<<<<<<<<<<
+ * 			first_i = 0 if stop_in_ref else m
+ * 			# search in last column # TODO last?
+ */
+  __pyx_t_8 = ((__pyx_v_max_n == __pyx_v_n) != 0);
+  if (__pyx_t_8) {
+
+    /* "cutadapt/_align.pyx":370
+ * 
+ * 		if max_n == n:
+ * 			first_i = 0 if stop_in_ref else m             # <<<<<<<<<<<<<<
+ * 			# search in last column # TODO last?
+ * 			for i in range(first_i, m+1):
+ */
+    if ((__pyx_v_stop_in_ref != 0)) {
+      __pyx_t_15 = 0;
+    } else {
+      __pyx_t_15 = __pyx_v_m;
+    }
+    __pyx_v_first_i = __pyx_t_15;
+
+    /* "cutadapt/_align.pyx":372
+ * 			first_i = 0 if stop_in_ref else m
+ * 			# search in last column # TODO last?
+ * 			for i in range(first_i, m+1):             # <<<<<<<<<<<<<<
+ * 				length = i + min(column[i].origin, 0)
+ * 				cost = column[i].cost
+ */
+    __pyx_t_15 = (__pyx_v_m + 1);
+    for (__pyx_t_13 = __pyx_v_first_i; __pyx_t_13 < __pyx_t_15; __pyx_t_13+=1) {
+      __pyx_v_i = __pyx_t_13;
+
+      /* "cutadapt/_align.pyx":373
+ * 			# search in last column # TODO last?
+ * 			for i in range(first_i, m+1):
+ * 				length = i + min(column[i].origin, 0)             # <<<<<<<<<<<<<<
+ * 				cost = column[i].cost
+ * 				matches = column[i].matches
+ */
+      __pyx_t_17 = 0;
+      __pyx_t_12 = (__pyx_v_column[__pyx_v_i]).origin;
+      if (((__pyx_t_17 < __pyx_t_12) != 0)) {
+        __pyx_t_14 = __pyx_t_17;
+      } else {
+        __pyx_t_14 = __pyx_t_12;
+      }
+      __pyx_v_length = (__pyx_v_i + __pyx_t_14);
+
+      /* "cutadapt/_align.pyx":374
+ * 			for i in range(first_i, m+1):
+ * 				length = i + min(column[i].origin, 0)
+ * 				cost = column[i].cost             # <<<<<<<<<<<<<<
+ * 				matches = column[i].matches
+ * 				if length >= self.min_overlap and cost <= length * max_error_rate and (matches > best.matches or (matches == best.matches and cost < best.cost)):
+ */
+      __pyx_t_12 = (__pyx_v_column[__pyx_v_i]).cost;
+      __pyx_v_cost = __pyx_t_12;
+
+      /* "cutadapt/_align.pyx":375
+ * 				length = i + min(column[i].origin, 0)
+ * 				cost = column[i].cost
+ * 				matches = column[i].matches             # <<<<<<<<<<<<<<
+ * 				if length >= self.min_overlap and cost <= length * max_error_rate and (matches > best.matches or (matches == best.matches and cost < best.cost)):
+ * 					# update best
+ */
+      __pyx_t_12 = (__pyx_v_column[__pyx_v_i]).matches;
+      __pyx_v_matches = __pyx_t_12;
+
+      /* "cutadapt/_align.pyx":376
+ * 				cost = column[i].cost
+ * 				matches = column[i].matches
+ * 				if length >= self.min_overlap and cost <= length * max_error_rate and (matches > best.matches or (matches == best.matches and cost < best.cost)):             # <<<<<<<<<<<<<<
+ * 					# update best
+ * 					best.matches = matches
+ */
+      __pyx_t_11 = ((__pyx_v_length >= __pyx_v_self->min_overlap) != 0);
+      if (__pyx_t_11) {
+      } else {
+        __pyx_t_8 = __pyx_t_11;
+        goto __pyx_L52_bool_binop_done;
+      }
+      __pyx_t_11 = ((__pyx_v_cost <= (__pyx_v_length * __pyx_v_max_error_rate)) != 0);
+      if (__pyx_t_11) {
+      } else {
+        __pyx_t_8 = __pyx_t_11;
+        goto __pyx_L52_bool_binop_done;
+      }
+      __pyx_t_11 = ((__pyx_v_matches > __pyx_v_best.matches) != 0);
+      if (!__pyx_t_11) {
+      } else {
+        __pyx_t_8 = __pyx_t_11;
+        goto __pyx_L52_bool_binop_done;
+      }
+      __pyx_t_11 = ((__pyx_v_matches == __pyx_v_best.matches) != 0);
+      if (__pyx_t_11) {
+      } else {
+        __pyx_t_8 = __pyx_t_11;
+        goto __pyx_L52_bool_binop_done;
+      }
+      __pyx_t_11 = ((__pyx_v_cost < __pyx_v_best.cost) != 0);
+      __pyx_t_8 = __pyx_t_11;
+      __pyx_L52_bool_binop_done:;
+      if (__pyx_t_8) {
+
+        /* "cutadapt/_align.pyx":378
+ * 				if length >= self.min_overlap and cost <= length * max_error_rate and (matches > best.matches or (matches == best.matches and cost < best.cost)):
+ * 					# update best
+ * 					best.matches = matches             # <<<<<<<<<<<<<<
+ * 					best.cost = cost
+ * 					best.origin = column[i].origin
+ */
+        __pyx_v_best.matches = __pyx_v_matches;
+
+        /* "cutadapt/_align.pyx":379
+ * 					# update best
+ * 					best.matches = matches
+ * 					best.cost = cost             # <<<<<<<<<<<<<<
+ * 					best.origin = column[i].origin
+ * 					best.ref_stop = i
+ */
+        __pyx_v_best.cost = __pyx_v_cost;
+
+        /* "cutadapt/_align.pyx":380
+ * 					best.matches = matches
+ * 					best.cost = cost
+ * 					best.origin = column[i].origin             # <<<<<<<<<<<<<<
+ * 					best.ref_stop = i
+ * 					best.query_stop = n
+ */
+        __pyx_t_12 = (__pyx_v_column[__pyx_v_i]).origin;
+        __pyx_v_best.origin = __pyx_t_12;
+
+        /* "cutadapt/_align.pyx":381
+ * 					best.cost = cost
+ * 					best.origin = column[i].origin
+ * 					best.ref_stop = i             # <<<<<<<<<<<<<<
+ * 					best.query_stop = n
+ * 
+ */
+        __pyx_v_best.ref_stop = __pyx_v_i;
+
+        /* "cutadapt/_align.pyx":382
+ * 					best.origin = column[i].origin
+ * 					best.ref_stop = i
+ * 					best.query_stop = n             # <<<<<<<<<<<<<<
+ * 
+ * 		if best.cost == m + n:
+ */
+        __pyx_v_best.query_stop = __pyx_v_n;
+        goto __pyx_L51;
+      }
+      __pyx_L51:;
+    }
+    goto __pyx_L48;
+  }
+  __pyx_L48:;
+
+  /* "cutadapt/_align.pyx":384
+ * 					best.query_stop = n
+ * 
+ * 		if best.cost == m + n:             # <<<<<<<<<<<<<<
+ * 			# best.cost was initialized with this value.
+ * 			# If it is unchanged, no alignment was found that has
+ */
+  __pyx_t_8 = ((__pyx_v_best.cost == (__pyx_v_m + __pyx_v_n)) != 0);
+  if (__pyx_t_8) {
+
+    /* "cutadapt/_align.pyx":388
+ * 			# If it is unchanged, no alignment was found that has
+ * 			# an error rate within the allowed range.
+ * 			return None             # <<<<<<<<<<<<<<
+ * 
+ * 		cdef int start1, start2
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(Py_None);
+    __pyx_r = Py_None;
+    goto __pyx_L0;
+  }
+
+  /* "cutadapt/_align.pyx":391
+ * 
+ * 		cdef int start1, start2
+ * 		if best.origin >= 0:             # <<<<<<<<<<<<<<
+ * 			start1 = 0
+ * 			start2 = best.origin
+ */
+  __pyx_t_8 = ((__pyx_v_best.origin >= 0) != 0);
+  if (__pyx_t_8) {
+
+    /* "cutadapt/_align.pyx":392
+ * 		cdef int start1, start2
+ * 		if best.origin >= 0:
+ * 			start1 = 0             # <<<<<<<<<<<<<<
+ * 			start2 = best.origin
+ * 		else:
+ */
+    __pyx_v_start1 = 0;
+
+    /* "cutadapt/_align.pyx":393
+ * 		if best.origin >= 0:
+ * 			start1 = 0
+ * 			start2 = best.origin             # <<<<<<<<<<<<<<
+ * 		else:
+ * 			start1 = -best.origin
+ */
+    __pyx_t_13 = __pyx_v_best.origin;
+    __pyx_v_start2 = __pyx_t_13;
+    goto __pyx_L58;
+  }
+  /*else*/ {
+
+    /* "cutadapt/_align.pyx":395
+ * 			start2 = best.origin
+ * 		else:
+ * 			start1 = -best.origin             # <<<<<<<<<<<<<<
+ * 			start2 = 0
+ * 
+ */
+    __pyx_v_start1 = (-__pyx_v_best.origin);
+
+    /* "cutadapt/_align.pyx":396
+ * 		else:
+ * 			start1 = -best.origin
+ * 			start2 = 0             # <<<<<<<<<<<<<<
+ * 
+ * 		assert best.ref_stop - start1 > 0  # Do not return empty alignments.
+ */
+    __pyx_v_start2 = 0;
+  }
+  __pyx_L58:;
+
+  /* "cutadapt/_align.pyx":398
+ * 			start2 = 0
+ * 
+ * 		assert best.ref_stop - start1 > 0  # Do not return empty alignments.             # <<<<<<<<<<<<<<
+ * 		return (start1, best.ref_stop, start2, best.query_stop, best.matches, best.cost)
+ * 
+ */
+  #ifndef CYTHON_WITHOUT_ASSERTIONS
+  if (unlikely(!Py_OptimizeFlag)) {
+    if (unlikely(!(((__pyx_v_best.ref_stop - __pyx_v_start1) > 0) != 0))) {
+      PyErr_SetNone(PyExc_AssertionError);
+      {__pyx_filename = __pyx_f[0]; __pyx_lineno = 398; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    }
+  }
+  #endif
+
+  /* "cutadapt/_align.pyx":399
+ * 
+ * 		assert best.ref_stop - start1 > 0  # Do not return empty alignments.
+ * 		return (start1, best.ref_stop, start2, best.query_stop, best.matches, best.cost)             # <<<<<<<<<<<<<<
+ * 
+ * 	def __dealloc__(self):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_start1); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_best.ref_stop); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_9 = __Pyx_PyInt_From_int(__pyx_v_start2); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_9);
+  __pyx_t_10 = __Pyx_PyInt_From_int(__pyx_v_best.query_stop); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_10);
+  __pyx_t_18 = __Pyx_PyInt_From_int(__pyx_v_best.matches); if (unlikely(!__pyx_t_18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_18);
+  __pyx_t_19 = __Pyx_PyInt_From_int(__pyx_v_best.cost); if (unlikely(!__pyx_t_19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_19);
+  __pyx_t_20 = PyTuple_New(6); if (unlikely(!__pyx_t_20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 399; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_20);
+  __Pyx_GIVEREF(__pyx_t_3);
+  PyTuple_SET_ITEM(__pyx_t_20, 0, __pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_2);
+  PyTuple_SET_ITEM(__pyx_t_20, 1, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_9);
+  PyTuple_SET_ITEM(__pyx_t_20, 2, __pyx_t_9);
+  __Pyx_GIVEREF(__pyx_t_10);
+  PyTuple_SET_ITEM(__pyx_t_20, 3, __pyx_t_10);
+  __Pyx_GIVEREF(__pyx_t_18);
+  PyTuple_SET_ITEM(__pyx_t_20, 4, __pyx_t_18);
+  __Pyx_GIVEREF(__pyx_t_19);
+  PyTuple_SET_ITEM(__pyx_t_20, 5, __pyx_t_19);
+  __pyx_t_3 = 0;
+  __pyx_t_2 = 0;
+  __pyx_t_9 = 0;
+  __pyx_t_10 = 0;
+  __pyx_t_18 = 0;
+  __pyx_t_19 = 0;
+  __pyx_r = __pyx_t_20;
+  __pyx_t_20 = 0;
+  goto __pyx_L0;
+
+  /* "cutadapt/_align.pyx":189
+ * 				self._reference = self._reference.translate(ACGT_TABLE)
+ * 
+ * 	def locate(self, str query):             # <<<<<<<<<<<<<<
+ * 		"""
+ * 		locate(query) -> (refstart, refstop, querystart, querystop, matches, errors)
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_XDECREF(__pyx_t_18);
+  __Pyx_XDECREF(__pyx_t_19);
+  __Pyx_XDECREF(__pyx_t_20);
+  __Pyx_AddTraceback("cutadapt._align.Aligner.locate", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_query_bytes);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "cutadapt/_align.pyx":401
+ * 		return (start1, best.ref_stop, start2, best.query_stop, best.matches, best.cost)
+ * 
+ * 	def __dealloc__(self):             # <<<<<<<<<<<<<<
+ * 		PyMem_Free(self.column)
+ * 
+ */
+
+/* Python wrapper */
+static void __pyx_pw_8cutadapt_6_align_7Aligner_5__dealloc__(PyObject *__pyx_v_self); /*proto*/
+static void __pyx_pw_8cutadapt_6_align_7Aligner_5__dealloc__(PyObject *__pyx_v_self) {
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__dealloc__ (wrapper)", 0);
+  __pyx_pf_8cutadapt_6_align_7Aligner_4__dealloc__(((struct __pyx_obj_8cutadapt_6_align_Aligner *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+}
+
+static void __pyx_pf_8cutadapt_6_align_7Aligner_4__dealloc__(struct __pyx_obj_8cutadapt_6_align_Aligner *__pyx_v_self) {
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__dealloc__", 0);
+
+  /* "cutadapt/_align.pyx":402
+ * 
+ * 	def __dealloc__(self):
+ * 		PyMem_Free(self.column)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  PyMem_Free(__pyx_v_self->column);
+
+  /* "cutadapt/_align.pyx":401
+ * 		return (start1, best.ref_stop, start2, best.query_stop, best.matches, best.cost)
+ * 
+ * 	def __dealloc__(self):             # <<<<<<<<<<<<<<
+ * 		PyMem_Free(self.column)
+ * 
+ */
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+}
+
+/* "cutadapt/_align.pyx":405
+ * 
+ * 
+ * def locate(str reference, str query, double max_error_rate, int flags=SEMIGLOBAL, int degenerate=0, int min_overlap=1):             # <<<<<<<<<<<<<<
+ * 	aligner = Aligner(reference, max_error_rate, flags, degenerate, min_overlap)
+ * 	return aligner.locate(query)
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_8cutadapt_6_align_5locate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_8cutadapt_6_align_5locate = {"locate", (PyCFunction)__pyx_pw_8cutadapt_6_align_5locate, METH_VARARGS|METH_KEYWORDS, 0};
+static PyObject *__pyx_pw_8cutadapt_6_align_5locate(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_reference = 0;
+  PyObject *__pyx_v_query = 0;
+  double __pyx_v_max_error_rate;
+  int __pyx_v_flags;
+  int __pyx_v_degenerate;
+  int __pyx_v_min_overlap;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("locate (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_reference,&__pyx_n_s_query,&__pyx_n_s_max_error_rate,&__pyx_n_s_flags,&__pyx_n_s_degenerate,&__pyx_n_s_min_overlap,0};
+    PyObject* values[6] = {0,0,0,0,0,0};
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
+        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_reference)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+        case  1:
+        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_query)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("locate", 0, 3, 6, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        }
+        case  2:
+        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_max_error_rate)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("locate", 0, 3, 6, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        }
+        case  3:
+        if (kw_args > 0) {
+          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_flags);
+          if (value) { values[3] = value; kw_args--; }
+        }
+        case  4:
+        if (kw_args > 0) {
+          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_degenerate);
+          if (value) { values[4] = value; kw_args--; }
+        }
+        case  5:
+        if (kw_args > 0) {
+          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_min_overlap);
+          if (value) { values[5] = value; kw_args--; }
+        }
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "locate") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    } else {
+      switch (PyTuple_GET_SIZE(__pyx_args)) {
+        case  6: values[5] = PyTuple_GET_ITEM(__pyx_args, 5);
+        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+    }
+    __pyx_v_reference = ((PyObject*)values[0]);
+    __pyx_v_query = ((PyObject*)values[1]);
+    __pyx_v_max_error_rate = __pyx_PyFloat_AsDouble(values[2]); if (unlikely((__pyx_v_max_error_rate == (double)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    if (values[3]) {
+      __pyx_v_flags = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_flags == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    } else {
+      __pyx_v_flags = ((int)15);
+    }
+    if (values[4]) {
+      __pyx_v_degenerate = __Pyx_PyInt_As_int(values[4]); if (unlikely((__pyx_v_degenerate == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    } else {
+      __pyx_v_degenerate = ((int)0);
+    }
+    if (values[5]) {
+      __pyx_v_min_overlap = __Pyx_PyInt_As_int(values[5]); if (unlikely((__pyx_v_min_overlap == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    } else {
+      __pyx_v_min_overlap = ((int)1);
+    }
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("locate", 0, 3, 6, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cutadapt._align.locate", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_reference), (&PyString_Type), 1, "reference", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_query), (&PyString_Type), 1, "query", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_r = __pyx_pf_8cutadapt_6_align_4locate(__pyx_self, __pyx_v_reference, __pyx_v_query, __pyx_v_max_error_rate, __pyx_v_flags, __pyx_v_degenerate, __pyx_v_min_overlap);
+
+  /* function exit code */
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_8cutadapt_6_align_4locate(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_reference, PyObject *__pyx_v_query, double __pyx_v_max_error_rate, int __pyx_v_flags, int __pyx_v_degenerate, int __pyx_v_min_overlap) {
+  struct __pyx_obj_8cutadapt_6_align_Aligner *__pyx_v_aligner = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("locate", 0);
+
+  /* "cutadapt/_align.pyx":406
+ * 
+ * def locate(str reference, str query, double max_error_rate, int flags=SEMIGLOBAL, int degenerate=0, int min_overlap=1):
+ * 	aligner = Aligner(reference, max_error_rate, flags, degenerate, min_overlap)             # <<<<<<<<<<<<<<
+ * 	return aligner.locate(query)
+ * 
+ */
+  __pyx_t_1 = PyFloat_FromDouble(__pyx_v_max_error_rate); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_flags); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_degenerate); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_min_overlap); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_5 = PyTuple_New(5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __Pyx_INCREF(__pyx_v_reference);
+  __Pyx_GIVEREF(__pyx_v_reference);
+  PyTuple_SET_ITEM(__pyx_t_5, 0, __pyx_v_reference);
+  __Pyx_GIVEREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_5, 1, __pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_2);
+  PyTuple_SET_ITEM(__pyx_t_5, 2, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_3);
+  PyTuple_SET_ITEM(__pyx_t_5, 3, __pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_4);
+  PyTuple_SET_ITEM(__pyx_t_5, 4, __pyx_t_4);
+  __pyx_t_1 = 0;
+  __pyx_t_2 = 0;
+  __pyx_t_3 = 0;
+  __pyx_t_4 = 0;
+  __pyx_t_4 = __Pyx_PyObject_Call(((PyObject *)((PyObject*)__pyx_ptype_8cutadapt_6_align_Aligner)), __pyx_t_5, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 406; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __pyx_v_aligner = ((struct __pyx_obj_8cutadapt_6_align_Aligner *)__pyx_t_4);
+  __pyx_t_4 = 0;
+
+  /* "cutadapt/_align.pyx":407
+ * def locate(str reference, str query, double max_error_rate, int flags=SEMIGLOBAL, int degenerate=0, int min_overlap=1):
+ * 	aligner = Aligner(reference, max_error_rate, flags, degenerate, min_overlap)
+ * 	return aligner.locate(query)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_5 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_aligner), __pyx_n_s_locate); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_3 = NULL;
+  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_5);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_5, function);
+    }
+  }
+  if (!__pyx_t_3) {
+    __pyx_t_4 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_query); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+  } else {
+    __pyx_t_2 = PyTuple_New(1+1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_GIVEREF(__pyx_t_3); PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_3); __pyx_t_3 = NULL;
+    __Pyx_INCREF(__pyx_v_query);
+    __Pyx_GIVEREF(__pyx_v_query);
+    PyTuple_SET_ITEM(__pyx_t_2, 0+1, __pyx_v_query);
+    __pyx_t_4 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_2, NULL); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 407; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __pyx_r = __pyx_t_4;
+  __pyx_t_4 = 0;
+  goto __pyx_L0;
+
+  /* "cutadapt/_align.pyx":405
+ * 
+ * 
+ * def locate(str reference, str query, double max_error_rate, int flags=SEMIGLOBAL, int degenerate=0, int min_overlap=1):             # <<<<<<<<<<<<<<
+ * 	aligner = Aligner(reference, max_error_rate, flags, degenerate, min_overlap)
+ * 	return aligner.locate(query)
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("cutadapt._align.locate", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XDECREF((PyObject *)__pyx_v_aligner);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "cutadapt/_align.pyx":410
+ * 
+ * 
+ * def compare_prefixes(str ref, str query, int degenerate=0):             # <<<<<<<<<<<<<<
+ * 	"""
+ * 	Find out whether one string is the prefix of the other one, allowing
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_8cutadapt_6_align_7compare_prefixes(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_8cutadapt_6_align_6compare_prefixes[] = "\n\tFind out whether one string is the prefix of the other one, allowing\n\tIUPAC wildcards if the appropriate bit is set in the degenerate flag\n\tparameter.\n\n\tThis is used to find an anchored 5' adapter (type 'FRONT') in the 'no indels' mode.\n\tThis is very simple as only the number of errors needs to be counted.\n\n\tThis function returns a tuple compatible with what Aligner.locate outputs.\n\t";
+static PyMethodDef __pyx_mdef_8cutadapt_6_align_7compare_prefixes = {"compare_prefixes", (PyCFunction)__pyx_pw_8cutadapt_6_align_7compare_prefixes, METH_VARARGS|METH_KEYWORDS, __pyx_doc_8cutadapt_6_align_6compare_prefixes};
+static PyObject *__pyx_pw_8cutadapt_6_align_7compare_prefixes(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_ref = 0;
+  PyObject *__pyx_v_query = 0;
+  int __pyx_v_degenerate;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("compare_prefixes (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_ref,&__pyx_n_s_query,&__pyx_n_s_degenerate,0};
+    PyObject* values[3] = {0,0,0};
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_ref)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+        case  1:
+        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_query)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("compare_prefixes", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        }
+        case  2:
+        if (kw_args > 0) {
+          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_degenerate);
+          if (value) { values[2] = value; kw_args--; }
+        }
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "compare_prefixes") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    } else {
+      switch (PyTuple_GET_SIZE(__pyx_args)) {
+        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+    }
+    __pyx_v_ref = ((PyObject*)values[0]);
+    __pyx_v_query = ((PyObject*)values[1]);
+    if (values[2]) {
+      __pyx_v_degenerate = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_degenerate == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    } else {
+      __pyx_v_degenerate = ((int)0);
+    }
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("compare_prefixes", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cutadapt._align.compare_prefixes", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_ref), (&PyString_Type), 1, "ref", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_query), (&PyString_Type), 1, "query", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_r = __pyx_pf_8cutadapt_6_align_6compare_prefixes(__pyx_self, __pyx_v_ref, __pyx_v_query, __pyx_v_degenerate);
+
+  /* function exit code */
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_8cutadapt_6_align_6compare_prefixes(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_ref, PyObject *__pyx_v_query, int __pyx_v_degenerate) {
+  int __pyx_v_m;
+  int __pyx_v_n;
+  PyObject *__pyx_v_query_bytes = 0;
+  PyObject *__pyx_v_ref_bytes = 0;
+  char *__pyx_v_r_ptr;
+  char *__pyx_v_q_ptr;
+  int __pyx_v_wildcard_ref;
+  int __pyx_v_wildcard_query;
+  int __pyx_v_length;
+  int __pyx_v_i;
+  int __pyx_v_matches;
+  int __pyx_v_compare_ascii;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  Py_ssize_t __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_t_4;
+  int __pyx_t_5;
+  int __pyx_t_6;
+  int __pyx_t_7;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  char *__pyx_t_10;
+  PyObject *__pyx_t_11 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("compare_prefixes", 0);
+
+  /* "cutadapt/_align.pyx":421
+ * 	This function returns a tuple compatible with what Aligner.locate outputs.
+ * 	"""
+ * 	cdef int m = len(ref)             # <<<<<<<<<<<<<<
+ * 	cdef int n = len(query)
+ * 	cdef bytes query_bytes = query.encode('ascii')
+ */
+  __pyx_t_1 = PyObject_Length(__pyx_v_ref); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 421; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_m = __pyx_t_1;
+
+  /* "cutadapt/_align.pyx":422
+ * 	"""
+ * 	cdef int m = len(ref)
+ * 	cdef int n = len(query)             # <<<<<<<<<<<<<<
+ * 	cdef bytes query_bytes = query.encode('ascii')
+ * 	cdef bytes ref_bytes = ref.encode('ascii')
+ */
+  __pyx_t_1 = PyObject_Length(__pyx_v_query); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 422; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_n = __pyx_t_1;
+
+  /* "cutadapt/_align.pyx":423
+ * 	cdef int m = len(ref)
+ * 	cdef int n = len(query)
+ * 	cdef bytes query_bytes = query.encode('ascii')             # <<<<<<<<<<<<<<
+ * 	cdef bytes ref_bytes = ref.encode('ascii')
+ * 	cdef char* r_ptr
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_query, __pyx_n_s_encode); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__7, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (!(likely(PyBytes_CheckExact(__pyx_t_3))||((__pyx_t_3) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_3)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_query_bytes = ((PyObject*)__pyx_t_3);
+  __pyx_t_3 = 0;
+
+  /* "cutadapt/_align.pyx":424
+ * 	cdef int n = len(query)
+ * 	cdef bytes query_bytes = query.encode('ascii')
+ * 	cdef bytes ref_bytes = ref.encode('ascii')             # <<<<<<<<<<<<<<
+ * 	cdef char* r_ptr
+ * 	cdef char* q_ptr
+ */
+  __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_ref, __pyx_n_s_encode); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_tuple__8, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_ref_bytes = ((PyObject*)__pyx_t_2);
+  __pyx_t_2 = 0;
+
+  /* "cutadapt/_align.pyx":427
+ * 	cdef char* r_ptr
+ * 	cdef char* q_ptr
+ * 	cdef bint wildcard_ref = degenerate & ALLOW_WILDCARD_SEQ1             # <<<<<<<<<<<<<<
+ * 	cdef bint wildcard_query = degenerate & ALLOW_WILDCARD_SEQ2
+ * 	cdef int length = min(m, n)
+ */
+  __pyx_v_wildcard_ref = (__pyx_v_degenerate & 1);
+
+  /* "cutadapt/_align.pyx":428
+ * 	cdef char* q_ptr
+ * 	cdef bint wildcard_ref = degenerate & ALLOW_WILDCARD_SEQ1
+ * 	cdef bint wildcard_query = degenerate & ALLOW_WILDCARD_SEQ2             # <<<<<<<<<<<<<<
+ * 	cdef int length = min(m, n)
+ * 	cdef int i, matches = 0
+ */
+  __pyx_v_wildcard_query = (__pyx_v_degenerate & 2);
+
+  /* "cutadapt/_align.pyx":429
+ * 	cdef bint wildcard_ref = degenerate & ALLOW_WILDCARD_SEQ1
+ * 	cdef bint wildcard_query = degenerate & ALLOW_WILDCARD_SEQ2
+ * 	cdef int length = min(m, n)             # <<<<<<<<<<<<<<
+ * 	cdef int i, matches = 0
+ * 	cdef bint compare_ascii = False
+ */
+  __pyx_t_4 = __pyx_v_n;
+  __pyx_t_5 = __pyx_v_m;
+  if (((__pyx_t_4 < __pyx_t_5) != 0)) {
+    __pyx_t_6 = __pyx_t_4;
+  } else {
+    __pyx_t_6 = __pyx_t_5;
+  }
+  __pyx_v_length = __pyx_t_6;
+
+  /* "cutadapt/_align.pyx":430
+ * 	cdef bint wildcard_query = degenerate & ALLOW_WILDCARD_SEQ2
+ * 	cdef int length = min(m, n)
+ * 	cdef int i, matches = 0             # <<<<<<<<<<<<<<
+ * 	cdef bint compare_ascii = False
+ * 
+ */
+  __pyx_v_matches = 0;
+
+  /* "cutadapt/_align.pyx":431
+ * 	cdef int length = min(m, n)
+ * 	cdef int i, matches = 0
+ * 	cdef bint compare_ascii = False             # <<<<<<<<<<<<<<
+ * 
+ * 	if wildcard_ref:
+ */
+  __pyx_v_compare_ascii = 0;
+
+  /* "cutadapt/_align.pyx":433
+ * 	cdef bint compare_ascii = False
+ * 
+ * 	if wildcard_ref:             # <<<<<<<<<<<<<<
+ * 		ref_bytes = ref_bytes.translate(IUPAC_TABLE)
+ * 	elif wildcard_query:
+ */
+  __pyx_t_7 = (__pyx_v_wildcard_ref != 0);
+  if (__pyx_t_7) {
+
+    /* "cutadapt/_align.pyx":434
+ * 
+ * 	if wildcard_ref:
+ * 		ref_bytes = ref_bytes.translate(IUPAC_TABLE)             # <<<<<<<<<<<<<<
+ * 	elif wildcard_query:
+ * 		ref_bytes = ref_bytes.translate(ACGT_TABLE)
+ */
+    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_ref_bytes, __pyx_n_s_translate); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_8 = NULL;
+    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
+      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
+      if (likely(__pyx_t_8)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+        __Pyx_INCREF(__pyx_t_8);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_3, function);
+      }
+    }
+    if (!__pyx_t_8) {
+      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_8cutadapt_6_align_IUPAC_TABLE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+    } else {
+      __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
+      __Pyx_INCREF(__pyx_v_8cutadapt_6_align_IUPAC_TABLE);
+      __Pyx_GIVEREF(__pyx_v_8cutadapt_6_align_IUPAC_TABLE);
+      PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_8cutadapt_6_align_IUPAC_TABLE);
+      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 434; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF_SET(__pyx_v_ref_bytes, ((PyObject*)__pyx_t_2));
+    __pyx_t_2 = 0;
+    goto __pyx_L3;
+  }
+
+  /* "cutadapt/_align.pyx":435
+ * 	if wildcard_ref:
+ * 		ref_bytes = ref_bytes.translate(IUPAC_TABLE)
+ * 	elif wildcard_query:             # <<<<<<<<<<<<<<
+ * 		ref_bytes = ref_bytes.translate(ACGT_TABLE)
+ * 	else:
+ */
+  __pyx_t_7 = (__pyx_v_wildcard_query != 0);
+  if (__pyx_t_7) {
+
+    /* "cutadapt/_align.pyx":436
+ * 		ref_bytes = ref_bytes.translate(IUPAC_TABLE)
+ * 	elif wildcard_query:
+ * 		ref_bytes = ref_bytes.translate(ACGT_TABLE)             # <<<<<<<<<<<<<<
+ * 	else:
+ * 		compare_ascii = True
+ */
+    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_ref_bytes, __pyx_n_s_translate); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_9 = NULL;
+    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
+      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3);
+      if (likely(__pyx_t_9)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+        __Pyx_INCREF(__pyx_t_9);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_3, function);
+      }
+    }
+    if (!__pyx_t_9) {
+      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_8cutadapt_6_align_ACGT_TABLE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+    } else {
+      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_8);
+      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_9); __pyx_t_9 = NULL;
+      __Pyx_INCREF(__pyx_v_8cutadapt_6_align_ACGT_TABLE);
+      __Pyx_GIVEREF(__pyx_v_8cutadapt_6_align_ACGT_TABLE);
+      PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_8cutadapt_6_align_ACGT_TABLE);
+      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 436; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF_SET(__pyx_v_ref_bytes, ((PyObject*)__pyx_t_2));
+    __pyx_t_2 = 0;
+    goto __pyx_L3;
+  }
+  /*else*/ {
+
+    /* "cutadapt/_align.pyx":438
+ * 		ref_bytes = ref_bytes.translate(ACGT_TABLE)
+ * 	else:
+ * 		compare_ascii = True             # <<<<<<<<<<<<<<
+ * 	if wildcard_query:
+ * 		query_bytes = query_bytes.translate(IUPAC_TABLE)
+ */
+    __pyx_v_compare_ascii = 1;
+  }
+  __pyx_L3:;
+
+  /* "cutadapt/_align.pyx":439
+ * 	else:
+ * 		compare_ascii = True
+ * 	if wildcard_query:             # <<<<<<<<<<<<<<
+ * 		query_bytes = query_bytes.translate(IUPAC_TABLE)
+ * 	elif wildcard_ref:
+ */
+  __pyx_t_7 = (__pyx_v_wildcard_query != 0);
+  if (__pyx_t_7) {
+
+    /* "cutadapt/_align.pyx":440
+ * 		compare_ascii = True
+ * 	if wildcard_query:
+ * 		query_bytes = query_bytes.translate(IUPAC_TABLE)             # <<<<<<<<<<<<<<
+ * 	elif wildcard_ref:
+ * 		query_bytes = query_bytes.translate(ACGT_TABLE)
+ */
+    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_query_bytes, __pyx_n_s_translate); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_8 = NULL;
+    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
+      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_3);
+      if (likely(__pyx_t_8)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+        __Pyx_INCREF(__pyx_t_8);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_3, function);
+      }
+    }
+    if (!__pyx_t_8) {
+      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_8cutadapt_6_align_IUPAC_TABLE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+    } else {
+      __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
+      __Pyx_INCREF(__pyx_v_8cutadapt_6_align_IUPAC_TABLE);
+      __Pyx_GIVEREF(__pyx_v_8cutadapt_6_align_IUPAC_TABLE);
+      PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_8cutadapt_6_align_IUPAC_TABLE);
+      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 440; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF_SET(__pyx_v_query_bytes, ((PyObject*)__pyx_t_2));
+    __pyx_t_2 = 0;
+    goto __pyx_L4;
+  }
+
+  /* "cutadapt/_align.pyx":441
+ * 	if wildcard_query:
+ * 		query_bytes = query_bytes.translate(IUPAC_TABLE)
+ * 	elif wildcard_ref:             # <<<<<<<<<<<<<<
+ * 		query_bytes = query_bytes.translate(ACGT_TABLE)
+ * 
+ */
+  __pyx_t_7 = (__pyx_v_wildcard_ref != 0);
+  if (__pyx_t_7) {
+
+    /* "cutadapt/_align.pyx":442
+ * 		query_bytes = query_bytes.translate(IUPAC_TABLE)
+ * 	elif wildcard_ref:
+ * 		query_bytes = query_bytes.translate(ACGT_TABLE)             # <<<<<<<<<<<<<<
+ * 
+ * 	if compare_ascii:
+ */
+    __pyx_t_3 = __Pyx_PyObject_GetAttrStr(__pyx_v_query_bytes, __pyx_n_s_translate); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_9 = NULL;
+    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_3))) {
+      __pyx_t_9 = PyMethod_GET_SELF(__pyx_t_3);
+      if (likely(__pyx_t_9)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_3);
+        __Pyx_INCREF(__pyx_t_9);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_3, function);
+      }
+    }
+    if (!__pyx_t_9) {
+      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_3, __pyx_v_8cutadapt_6_align_ACGT_TABLE); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+    } else {
+      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_8);
+      __Pyx_GIVEREF(__pyx_t_9); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_9); __pyx_t_9 = NULL;
+      __Pyx_INCREF(__pyx_v_8cutadapt_6_align_ACGT_TABLE);
+      __Pyx_GIVEREF(__pyx_v_8cutadapt_6_align_ACGT_TABLE);
+      PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_8cutadapt_6_align_ACGT_TABLE);
+      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_3, __pyx_t_8, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    if (!(likely(PyBytes_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 442; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF_SET(__pyx_v_query_bytes, ((PyObject*)__pyx_t_2));
+    __pyx_t_2 = 0;
+    goto __pyx_L4;
+  }
+  __pyx_L4:;
+
+  /* "cutadapt/_align.pyx":444
+ * 		query_bytes = query_bytes.translate(ACGT_TABLE)
+ * 
+ * 	if compare_ascii:             # <<<<<<<<<<<<<<
+ * 		for i in range(length):
+ * 			if ref[i] == query[i]:
+ */
+  __pyx_t_7 = (__pyx_v_compare_ascii != 0);
+  if (__pyx_t_7) {
+
+    /* "cutadapt/_align.pyx":445
+ * 
+ * 	if compare_ascii:
+ * 		for i in range(length):             # <<<<<<<<<<<<<<
+ * 			if ref[i] == query[i]:
+ * 				matches += 1
+ */
+    __pyx_t_6 = __pyx_v_length;
+    for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_6; __pyx_t_4+=1) {
+      __pyx_v_i = __pyx_t_4;
+
+      /* "cutadapt/_align.pyx":446
+ * 	if compare_ascii:
+ * 		for i in range(length):
+ * 			if ref[i] == query[i]:             # <<<<<<<<<<<<<<
+ * 				matches += 1
+ * 	else:
+ */
+      __pyx_t_2 = __Pyx_GetItemInt(__pyx_v_ref, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+      __Pyx_GOTREF(__pyx_t_2);
+      __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_query, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_t_8 = PyObject_RichCompare(__pyx_t_2, __pyx_t_3, Py_EQ); __Pyx_XGOTREF(__pyx_t_8); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+      __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+      __pyx_t_7 = __Pyx_PyObject_IsTrue(__pyx_t_8); if (unlikely(__pyx_t_7 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 446; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+      if (__pyx_t_7) {
+
+        /* "cutadapt/_align.pyx":447
+ * 		for i in range(length):
+ * 			if ref[i] == query[i]:
+ * 				matches += 1             # <<<<<<<<<<<<<<
+ * 	else:
+ * 		r_ptr = ref_bytes
+ */
+        __pyx_v_matches = (__pyx_v_matches + 1);
+        goto __pyx_L8;
+      }
+      __pyx_L8:;
+    }
+    goto __pyx_L5;
+  }
+  /*else*/ {
+
+    /* "cutadapt/_align.pyx":449
+ * 				matches += 1
+ * 	else:
+ * 		r_ptr = ref_bytes             # <<<<<<<<<<<<<<
+ * 		q_ptr = query_bytes
+ * 		for i in range(length):
+ */
+    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_ref_bytes); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 449; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_v_r_ptr = __pyx_t_10;
+
+    /* "cutadapt/_align.pyx":450
+ * 	else:
+ * 		r_ptr = ref_bytes
+ * 		q_ptr = query_bytes             # <<<<<<<<<<<<<<
+ * 		for i in range(length):
+ * 			if (r_ptr[i] & q_ptr[i]) != 0:
+ */
+    __pyx_t_10 = __Pyx_PyObject_AsString(__pyx_v_query_bytes); if (unlikely((!__pyx_t_10) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 450; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_v_q_ptr = __pyx_t_10;
+
+    /* "cutadapt/_align.pyx":451
+ * 		r_ptr = ref_bytes
+ * 		q_ptr = query_bytes
+ * 		for i in range(length):             # <<<<<<<<<<<<<<
+ * 			if (r_ptr[i] & q_ptr[i]) != 0:
+ * 				matches += 1
+ */
+    __pyx_t_6 = __pyx_v_length;
+    for (__pyx_t_4 = 0; __pyx_t_4 < __pyx_t_6; __pyx_t_4+=1) {
+      __pyx_v_i = __pyx_t_4;
+
+      /* "cutadapt/_align.pyx":452
+ * 		q_ptr = query_bytes
+ * 		for i in range(length):
+ * 			if (r_ptr[i] & q_ptr[i]) != 0:             # <<<<<<<<<<<<<<
+ * 				matches += 1
+ * 
+ */
+      __pyx_t_7 = ((((__pyx_v_r_ptr[__pyx_v_i]) & (__pyx_v_q_ptr[__pyx_v_i])) != 0) != 0);
+      if (__pyx_t_7) {
+
+        /* "cutadapt/_align.pyx":453
+ * 		for i in range(length):
+ * 			if (r_ptr[i] & q_ptr[i]) != 0:
+ * 				matches += 1             # <<<<<<<<<<<<<<
+ * 
+ * 	# length - matches = no. of errors
+ */
+        __pyx_v_matches = (__pyx_v_matches + 1);
+        goto __pyx_L11;
+      }
+      __pyx_L11:;
+    }
+  }
+  __pyx_L5:;
+
+  /* "cutadapt/_align.pyx":456
+ * 
+ * 	# length - matches = no. of errors
+ * 	return (0, length, 0, length, matches, length - matches)             # <<<<<<<<<<<<<<
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_8 = __Pyx_PyInt_From_int(__pyx_v_length); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_8);
+  __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_length); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_2 = __Pyx_PyInt_From_int(__pyx_v_matches); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_9 = __Pyx_PyInt_From_int((__pyx_v_length - __pyx_v_matches)); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_9);
+  __pyx_t_11 = PyTuple_New(6); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 456; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_11);
+  __Pyx_INCREF(__pyx_int_0);
+  __Pyx_GIVEREF(__pyx_int_0);
+  PyTuple_SET_ITEM(__pyx_t_11, 0, __pyx_int_0);
+  __Pyx_GIVEREF(__pyx_t_8);
+  PyTuple_SET_ITEM(__pyx_t_11, 1, __pyx_t_8);
+  __Pyx_INCREF(__pyx_int_0);
+  __Pyx_GIVEREF(__pyx_int_0);
+  PyTuple_SET_ITEM(__pyx_t_11, 2, __pyx_int_0);
+  __Pyx_GIVEREF(__pyx_t_3);
+  PyTuple_SET_ITEM(__pyx_t_11, 3, __pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_2);
+  PyTuple_SET_ITEM(__pyx_t_11, 4, __pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_9);
+  PyTuple_SET_ITEM(__pyx_t_11, 5, __pyx_t_9);
+  __pyx_t_8 = 0;
+  __pyx_t_3 = 0;
+  __pyx_t_2 = 0;
+  __pyx_t_9 = 0;
+  __pyx_r = __pyx_t_11;
+  __pyx_t_11 = 0;
+  goto __pyx_L0;
+
+  /* "cutadapt/_align.pyx":410
+ * 
+ * 
+ * def compare_prefixes(str ref, str query, int degenerate=0):             # <<<<<<<<<<<<<<
+ * 	"""
+ * 	Find out whether one string is the prefix of the other one, allowing
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_11);
+  __Pyx_AddTraceback("cutadapt._align.compare_prefixes", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_query_bytes);
+  __Pyx_XDECREF(__pyx_v_ref_bytes);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_tp_new_8cutadapt_6_align_Aligner(PyTypeObject *t, PyObject *a, PyObject *k) {
+  struct __pyx_obj_8cutadapt_6_align_Aligner *p;
+  PyObject *o;
+  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
+    o = (*t->tp_alloc)(t, 0);
+  } else {
+    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
+  }
+  if (unlikely(!o)) return 0;
+  p = ((struct __pyx_obj_8cutadapt_6_align_Aligner *)o);
+  p->_reference = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  if (unlikely(__pyx_pw_8cutadapt_6_align_7Aligner_1__cinit__(o, a, k) < 0)) {
+    Py_DECREF(o); o = 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_8cutadapt_6_align_Aligner(PyObject *o) {
+  struct __pyx_obj_8cutadapt_6_align_Aligner *p = (struct __pyx_obj_8cutadapt_6_align_Aligner *)o;
+  #if PY_VERSION_HEX >= 0x030400a1
+  if (unlikely(Py_TYPE(o)->tp_finalize) && (!PyType_IS_GC(Py_TYPE(o)) || !_PyGC_FINALIZED(o))) {
+    if (PyObject_CallFinalizerFromDealloc(o)) return;
+  }
+  #endif
+  {
+    PyObject *etype, *eval, *etb;
+    PyErr_Fetch(&etype, &eval, &etb);
+    ++Py_REFCNT(o);
+    __pyx_pw_8cutadapt_6_align_7Aligner_5__dealloc__(o);
+    --Py_REFCNT(o);
+    PyErr_Restore(etype, eval, etb);
+  }
+  Py_CLEAR(p->_reference);
+  (*Py_TYPE(o)->tp_free)(o);
+}
+
+static PyObject *__pyx_getprop_8cutadapt_6_align_7Aligner_reference(PyObject *o, CYTHON_UNUSED void *x) {
+  return __pyx_pw_8cutadapt_6_align_7Aligner_9reference_1__get__(o);
+}
+
+static int __pyx_setprop_8cutadapt_6_align_7Aligner_reference(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
+  if (v) {
+    return __pyx_pw_8cutadapt_6_align_7Aligner_9reference_3__set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyMethodDef __pyx_methods_8cutadapt_6_align_Aligner[] = {
+  {"locate", (PyCFunction)__pyx_pw_8cutadapt_6_align_7Aligner_3locate, METH_O, __pyx_doc_8cutadapt_6_align_7Aligner_2locate},
+  {0, 0, 0, 0}
+};
+
+static struct PyGetSetDef __pyx_getsets_8cutadapt_6_align_Aligner[] = {
+  {(char *)"reference", __pyx_getprop_8cutadapt_6_align_7Aligner_reference, __pyx_setprop_8cutadapt_6_align_7Aligner_reference, 0, 0},
+  {0, 0, 0, 0, 0}
+};
+
+static PyTypeObject __pyx_type_8cutadapt_6_align_Aligner = {
+  PyVarObject_HEAD_INIT(0, 0)
+  "cutadapt._align.Aligner", /*tp_name*/
+  sizeof(struct __pyx_obj_8cutadapt_6_align_Aligner), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_8cutadapt_6_align_Aligner, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*tp_repr*/
+  0, /*tp_as_number*/
+  0, /*tp_as_sequence*/
+  0, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  0, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE, /*tp_flags*/
+  "\n\tTODO documentation still uses s1 (reference) and s2 (query).\n\n\tLocate one string within another by computing an optimal semiglobal\n\talignment between string1 and string2.\n\n\tThe alignment uses unit costs, which means that mismatches, insertions and deletions are\n\tcounted as one error.\n\n\tflags is a bitwise 'or' of the allowed flags.\n\tTo allow skipping of a prefix of string1 at no cost, set the\n\tSTART_WITHIN_SEQ1 flag.\n\tTo allow skipping of a prefix of string2 at n [...]
+  0, /*tp_traverse*/
+  0, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_8cutadapt_6_align_Aligner, /*tp_methods*/
+  0, /*tp_members*/
+  __pyx_getsets_8cutadapt_6_align_Aligner, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_8cutadapt_6_align_Aligner, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  0, /*tp_version_tag*/
+  #if PY_VERSION_HEX >= 0x030400a1
+  0, /*tp_finalize*/
+  #endif
+};
+
+static PyMethodDef __pyx_methods[] = {
+  {0, 0, 0, 0}
+};
+
+#if PY_MAJOR_VERSION >= 3
+static struct PyModuleDef __pyx_moduledef = {
+  #if PY_VERSION_HEX < 0x03020000
+    { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
+  #else
+    PyModuleDef_HEAD_INIT,
+  #endif
+    "_align",
+    0, /* m_doc */
+    -1, /* m_size */
+    __pyx_methods /* m_methods */,
+    NULL, /* m_reload */
+    NULL, /* m_traverse */
+    NULL, /* m_clear */
+    NULL /* m_free */
+};
+#endif
+
+static __Pyx_StringTabEntry __pyx_string_tab[] = {
+  {&__pyx_kp_b_, __pyx_k_, sizeof(__pyx_k_), 0, 0, 0, 0},
+  {&__pyx_n_s_A, __pyx_k_A, sizeof(__pyx_k_A), 0, 0, 1, 1},
+  {&__pyx_n_s_B, __pyx_k_B, sizeof(__pyx_k_B), 0, 0, 1, 1},
+  {&__pyx_n_s_C, __pyx_k_C, sizeof(__pyx_k_C), 0, 0, 1, 1},
+  {&__pyx_n_s_D, __pyx_k_D, sizeof(__pyx_k_D), 0, 0, 1, 1},
+  {&__pyx_n_s_G, __pyx_k_G, sizeof(__pyx_k_G), 0, 0, 1, 1},
+  {&__pyx_n_s_H, __pyx_k_H, sizeof(__pyx_k_H), 0, 0, 1, 1},
+  {&__pyx_n_s_K, __pyx_k_K, sizeof(__pyx_k_K), 0, 0, 1, 1},
+  {&__pyx_n_s_M, __pyx_k_M, sizeof(__pyx_k_M), 0, 0, 1, 1},
+  {&__pyx_n_s_MemoryError, __pyx_k_MemoryError, sizeof(__pyx_k_MemoryError), 0, 0, 1, 1},
+  {&__pyx_n_s_N, __pyx_k_N, sizeof(__pyx_k_N), 0, 0, 1, 1},
+  {&__pyx_n_s_R, __pyx_k_R, sizeof(__pyx_k_R), 0, 0, 1, 1},
+  {&__pyx_n_s_S, __pyx_k_S, sizeof(__pyx_k_S), 0, 0, 1, 1},
+  {&__pyx_n_s_T, __pyx_k_T, sizeof(__pyx_k_T), 0, 0, 1, 1},
+  {&__pyx_n_s_U, __pyx_k_U, sizeof(__pyx_k_U), 0, 0, 1, 1},
+  {&__pyx_n_s_V, __pyx_k_V, sizeof(__pyx_k_V), 0, 0, 1, 1},
+  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
+  {&__pyx_n_s_W, __pyx_k_W, sizeof(__pyx_k_W), 0, 0, 1, 1},
+  {&__pyx_n_s_X, __pyx_k_X, sizeof(__pyx_k_X), 0, 0, 1, 1},
+  {&__pyx_n_s_Y, __pyx_k_Y, sizeof(__pyx_k_Y), 0, 0, 1, 1},
+  {&__pyx_n_s_acgt_table, __pyx_k_acgt_table, sizeof(__pyx_k_acgt_table), 0, 0, 1, 1},
+  {&__pyx_n_s_aligner, __pyx_k_aligner, sizeof(__pyx_k_aligner), 0, 0, 1, 1},
+  {&__pyx_n_s_ascii, __pyx_k_ascii, sizeof(__pyx_k_ascii), 0, 0, 1, 1},
+  {&__pyx_n_s_c, __pyx_k_c, sizeof(__pyx_k_c), 0, 0, 1, 1},
+  {&__pyx_n_s_compare_ascii, __pyx_k_compare_ascii, sizeof(__pyx_k_compare_ascii), 0, 0, 1, 1},
+  {&__pyx_n_s_compare_prefixes, __pyx_k_compare_prefixes, sizeof(__pyx_k_compare_prefixes), 0, 0, 1, 1},
+  {&__pyx_n_s_cutadapt__align, __pyx_k_cutadapt__align, sizeof(__pyx_k_cutadapt__align), 0, 0, 1, 1},
+  {&__pyx_n_s_d, __pyx_k_d, sizeof(__pyx_k_d), 0, 0, 1, 1},
+  {&__pyx_n_s_degenerate, __pyx_k_degenerate, sizeof(__pyx_k_degenerate), 0, 0, 1, 1},
+  {&__pyx_n_s_encode, __pyx_k_encode, sizeof(__pyx_k_encode), 0, 0, 1, 1},
+  {&__pyx_n_s_flags, __pyx_k_flags, sizeof(__pyx_k_flags), 0, 0, 1, 1},
+  {&__pyx_kp_s_home_marcel_scm_cutadapt_cutada, __pyx_k_home_marcel_scm_cutadapt_cutada, sizeof(__pyx_k_home_marcel_scm_cutadapt_cutada), 0, 0, 1, 0},
+  {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
+  {&__pyx_n_s_items, __pyx_k_items, sizeof(__pyx_k_items), 0, 0, 1, 1},
+  {&__pyx_n_s_iupac_table, __pyx_k_iupac_table, sizeof(__pyx_k_iupac_table), 0, 0, 1, 1},
+  {&__pyx_n_s_length, __pyx_k_length, sizeof(__pyx_k_length), 0, 0, 1, 1},
+  {&__pyx_n_s_locate, __pyx_k_locate, sizeof(__pyx_k_locate), 0, 0, 1, 1},
+  {&__pyx_n_s_lower, __pyx_k_lower, sizeof(__pyx_k_lower), 0, 0, 1, 1},
+  {&__pyx_n_s_m, __pyx_k_m, sizeof(__pyx_k_m), 0, 0, 1, 1},
+  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
+  {&__pyx_n_s_matches, __pyx_k_matches, sizeof(__pyx_k_matches), 0, 0, 1, 1},
+  {&__pyx_n_s_max_error_rate, __pyx_k_max_error_rate, sizeof(__pyx_k_max_error_rate), 0, 0, 1, 1},
+  {&__pyx_n_s_min_overlap, __pyx_k_min_overlap, sizeof(__pyx_k_min_overlap), 0, 0, 1, 1},
+  {&__pyx_kp_s_minimum_overlap_must_be_at_least, __pyx_k_minimum_overlap_must_be_at_least, sizeof(__pyx_k_minimum_overlap_must_be_at_least), 0, 0, 1, 0},
+  {&__pyx_n_s_n, __pyx_k_n, sizeof(__pyx_k_n), 0, 0, 1, 1},
+  {&__pyx_n_s_ord, __pyx_k_ord, sizeof(__pyx_k_ord), 0, 0, 1, 1},
+  {&__pyx_n_s_q_ptr, __pyx_k_q_ptr, sizeof(__pyx_k_q_ptr), 0, 0, 1, 1},
+  {&__pyx_n_s_query, __pyx_k_query, sizeof(__pyx_k_query), 0, 0, 1, 1},
+  {&__pyx_n_s_query_bytes, __pyx_k_query_bytes, sizeof(__pyx_k_query_bytes), 0, 0, 1, 1},
+  {&__pyx_n_s_r_ptr, __pyx_k_r_ptr, sizeof(__pyx_k_r_ptr), 0, 0, 1, 1},
+  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
+  {&__pyx_n_s_ref, __pyx_k_ref, sizeof(__pyx_k_ref), 0, 0, 1, 1},
+  {&__pyx_n_s_ref_bytes, __pyx_k_ref_bytes, sizeof(__pyx_k_ref_bytes), 0, 0, 1, 1},
+  {&__pyx_n_s_reference, __pyx_k_reference, sizeof(__pyx_k_reference), 0, 0, 1, 1},
+  {&__pyx_n_s_t, __pyx_k_t, sizeof(__pyx_k_t), 0, 0, 1, 1},
+  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
+  {&__pyx_n_s_translate, __pyx_k_translate, sizeof(__pyx_k_translate), 0, 0, 1, 1},
+  {&__pyx_n_s_v, __pyx_k_v, sizeof(__pyx_k_v), 0, 0, 1, 1},
+  {&__pyx_n_s_wildcard_query, __pyx_k_wildcard_query, sizeof(__pyx_k_wildcard_query), 0, 0, 1, 1},
+  {&__pyx_n_s_wildcard_ref, __pyx_k_wildcard_ref, sizeof(__pyx_k_wildcard_ref), 0, 0, 1, 1},
+  {0, 0, 0, 0, 0, 0, 0}
+};
+static int __Pyx_InitCachedBuiltins(void) {
+  __pyx_builtin_ord = __Pyx_GetBuiltinName(__pyx_n_s_ord); if (!__pyx_builtin_ord) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 43; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_MemoryError = __Pyx_GetBuiltinName(__pyx_n_s_MemoryError); if (!__pyx_builtin_MemoryError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 257; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  return 0;
+  __pyx_L1_error:;
+  return -1;
+}
+
+static int __Pyx_InitCachedConstants(void) {
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
+
+  /* "cutadapt/_align.pyx":41
+ * 	"""
+ * 	d = dict(A=1, C=2, G=4, T=8, U=8)
+ * 	t = bytearray(b'\0') * 256             # <<<<<<<<<<<<<<
+ * 	for c, v in d.items():
+ * 		t[ord(c)] = v
+ */
+  __pyx_tuple__2 = PyTuple_Pack(1, __pyx_kp_b_); if (unlikely(!__pyx_tuple__2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_tuple__2);
+  __Pyx_GIVEREF(__pyx_tuple__2);
+
+  /* "cutadapt/_align.pyx":81
+ * 		N=A|C|G|T
+ * 	)
+ * 	t = bytearray(b'\0') * 256             # <<<<<<<<<<<<<<
+ * 	for c, v in d.items():
+ * 		t[ord(c)] = v
+ */
+  __pyx_tuple__3 = PyTuple_Pack(1, __pyx_kp_b_); if (unlikely(!__pyx_tuple__3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 81; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_tuple__3);
+  __Pyx_GIVEREF(__pyx_tuple__3);
+
+  /* "cutadapt/_align.pyx":170
+ * 		self.reference = reference
+ * 		if min_overlap < 1:
+ * 			raise ValueError("minimum overlap must be at least 1")             # <<<<<<<<<<<<<<
+ * 		self.min_overlap = min_overlap
+ * 
+ */
+  __pyx_tuple__4 = PyTuple_Pack(1, __pyx_kp_s_minimum_overlap_must_be_at_least); if (unlikely(!__pyx_tuple__4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 170; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_tuple__4);
+  __Pyx_GIVEREF(__pyx_tuple__4);
+
+  /* "cutadapt/_align.pyx":182
+ * 				raise MemoryError()
+ * 			self.column = mem
+ * 			self._reference = reference.encode('ascii')             # <<<<<<<<<<<<<<
+ * 			self.m = len(reference)
+ * 			if self.wildcard_ref:
+ */
+  __pyx_tuple__5 = PyTuple_Pack(1, __pyx_n_s_ascii); if (unlikely(!__pyx_tuple__5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 182; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_tuple__5);
+  __Pyx_GIVEREF(__pyx_tuple__5);
+
+  /* "cutadapt/_align.pyx":204
+ * 		"""
+ * 		cdef char* s1 = self._reference
+ * 		cdef bytes query_bytes = query.encode('ascii')             # <<<<<<<<<<<<<<
+ * 		cdef char* s2 = query_bytes
+ * 		cdef int m = self.m
+ */
+  __pyx_tuple__6 = PyTuple_Pack(1, __pyx_n_s_ascii); if (unlikely(!__pyx_tuple__6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 204; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_tuple__6);
+  __Pyx_GIVEREF(__pyx_tuple__6);
+
+  /* "cutadapt/_align.pyx":423
+ * 	cdef int m = len(ref)
+ * 	cdef int n = len(query)
+ * 	cdef bytes query_bytes = query.encode('ascii')             # <<<<<<<<<<<<<<
+ * 	cdef bytes ref_bytes = ref.encode('ascii')
+ * 	cdef char* r_ptr
+ */
+  __pyx_tuple__7 = PyTuple_Pack(1, __pyx_n_s_ascii); if (unlikely(!__pyx_tuple__7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 423; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_tuple__7);
+  __Pyx_GIVEREF(__pyx_tuple__7);
+
+  /* "cutadapt/_align.pyx":424
+ * 	cdef int n = len(query)
+ * 	cdef bytes query_bytes = query.encode('ascii')
+ * 	cdef bytes ref_bytes = ref.encode('ascii')             # <<<<<<<<<<<<<<
+ * 	cdef char* r_ptr
+ * 	cdef char* q_ptr
+ */
+  __pyx_tuple__8 = PyTuple_Pack(1, __pyx_n_s_ascii); if (unlikely(!__pyx_tuple__8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 424; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_tuple__8);
+  __Pyx_GIVEREF(__pyx_tuple__8);
+
+  /* "cutadapt/_align.pyx":32
+ * 
+ * 
+ * def _acgt_table():             # <<<<<<<<<<<<<<
+ * 	"""
+ * 	Return a translation table that maps A, C, G, T characters to the lower
+ */
+  __pyx_tuple__9 = PyTuple_Pack(4, __pyx_n_s_d, __pyx_n_s_t, __pyx_n_s_c, __pyx_n_s_v); if (unlikely(!__pyx_tuple__9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_tuple__9);
+  __Pyx_GIVEREF(__pyx_tuple__9);
+  __pyx_codeobj__10 = (PyObject*)__Pyx_PyCode_New(0, 0, 4, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__9, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_marcel_scm_cutadapt_cutada, __pyx_n_s_acgt_table, 32, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "cutadapt/_align.pyx":48
+ * 
+ * 
+ * def _iupac_table():             # <<<<<<<<<<<<<<
+ * 	"""
+ * 	Return a translation table for IUPAC characters.
+ */
+  __pyx_tuple__11 = PyTuple_Pack(8, __pyx_n_s_A, __pyx_n_s_C, __pyx_n_s_G, __pyx_n_s_T, __pyx_n_s_d, __pyx_n_s_t, __pyx_n_s_c, __pyx_n_s_v); if (unlikely(!__pyx_tuple__11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_tuple__11);
+  __Pyx_GIVEREF(__pyx_tuple__11);
+  __pyx_codeobj__12 = (PyObject*)__Pyx_PyCode_New(0, 0, 8, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__11, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_marcel_scm_cutadapt_cutada, __pyx_n_s_iupac_table, 48, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "cutadapt/_align.pyx":405
+ * 
+ * 
+ * def locate(str reference, str query, double max_error_rate, int flags=SEMIGLOBAL, int degenerate=0, int min_overlap=1):             # <<<<<<<<<<<<<<
+ * 	aligner = Aligner(reference, max_error_rate, flags, degenerate, min_overlap)
+ * 	return aligner.locate(query)
+ */
+  __pyx_tuple__13 = PyTuple_Pack(7, __pyx_n_s_reference, __pyx_n_s_query, __pyx_n_s_max_error_rate, __pyx_n_s_flags, __pyx_n_s_degenerate, __pyx_n_s_min_overlap, __pyx_n_s_aligner); if (unlikely(!__pyx_tuple__13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_tuple__13);
+  __Pyx_GIVEREF(__pyx_tuple__13);
+  __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(6, 0, 7, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_marcel_scm_cutadapt_cutada, __pyx_n_s_locate, 405, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "cutadapt/_align.pyx":410
+ * 
+ * 
+ * def compare_prefixes(str ref, str query, int degenerate=0):             # <<<<<<<<<<<<<<
+ * 	"""
+ * 	Find out whether one string is the prefix of the other one, allowing
+ */
+  __pyx_tuple__15 = PyTuple_Pack(15, __pyx_n_s_ref, __pyx_n_s_query, __pyx_n_s_degenerate, __pyx_n_s_m, __pyx_n_s_n, __pyx_n_s_query_bytes, __pyx_n_s_ref_bytes, __pyx_n_s_r_ptr, __pyx_n_s_q_ptr, __pyx_n_s_wildcard_ref, __pyx_n_s_wildcard_query, __pyx_n_s_length, __pyx_n_s_i, __pyx_n_s_matches, __pyx_n_s_compare_ascii); if (unlikely(!__pyx_tuple__15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_tuple__15);
+  __Pyx_GIVEREF(__pyx_tuple__15);
+  __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(3, 0, 15, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__15, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_marcel_scm_cutadapt_cutada, __pyx_n_s_compare_prefixes, 410, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_RefNannyFinishContext();
+  return 0;
+  __pyx_L1_error:;
+  __Pyx_RefNannyFinishContext();
+  return -1;
+}
+
+static int __Pyx_InitGlobals(void) {
+  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_0 = PyInt_FromLong(0); if (unlikely(!__pyx_int_0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_int_1 = PyInt_FromLong(1); if (unlikely(!__pyx_int_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_int_2 = PyInt_FromLong(2); if (unlikely(!__pyx_int_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_int_4 = PyInt_FromLong(4); if (unlikely(!__pyx_int_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_int_8 = PyInt_FromLong(8); if (unlikely(!__pyx_int_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_int_256 = PyInt_FromLong(256); if (unlikely(!__pyx_int_256)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  return 0;
+  __pyx_L1_error:;
+  return -1;
+}
+
+#if PY_MAJOR_VERSION < 3
+PyMODINIT_FUNC init_align(void); /*proto*/
+PyMODINIT_FUNC init_align(void)
+#else
+PyMODINIT_FUNC PyInit__align(void); /*proto*/
+PyMODINIT_FUNC PyInit__align(void)
+#endif
+{
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannyDeclarations
+  #if CYTHON_REFNANNY
+  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
+  if (!__Pyx_RefNanny) {
+      PyErr_Clear();
+      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
+      if (!__Pyx_RefNanny)
+          Py_FatalError("failed to import 'refnanny' module");
+  }
+  #endif
+  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit__align(void)", 0);
+  if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #ifdef __Pyx_CyFunction_USED
+  if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #endif
+  #ifdef __Pyx_FusedFunction_USED
+  if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #endif
+  #ifdef __Pyx_Generator_USED
+  if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #endif
+  /*--- Library function declarations ---*/
+  /*--- Threads initialization code ---*/
+  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
+  #ifdef WITH_THREAD /* Python build with threading support? */
+  PyEval_InitThreads();
+  #endif
+  #endif
+  /*--- Module creation code ---*/
+  #if PY_MAJOR_VERSION < 3
+  __pyx_m = Py_InitModule4("_align", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
+  #else
+  __pyx_m = PyModule_Create(&__pyx_moduledef);
+  #endif
+  if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_INCREF(__pyx_d);
+  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #if CYTHON_COMPILING_IN_PYPY
+  Py_INCREF(__pyx_b);
+  #endif
+  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  /*--- Initialize various global constants etc. ---*/
+  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
+  if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #endif
+  if (__pyx_module_is_main_cutadapt___align) {
+    if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  }
+  #if PY_MAJOR_VERSION >= 3
+  {
+    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (!PyDict_GetItemString(modules, "cutadapt._align")) {
+      if (unlikely(PyDict_SetItemString(modules, "cutadapt._align", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    }
+  }
+  #endif
+  /*--- Builtin init code ---*/
+  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  /*--- Constants init code ---*/
+  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  /*--- Global init code ---*/
+  __pyx_v_8cutadapt_6_align_ACGT_TABLE = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  __pyx_v_8cutadapt_6_align_IUPAC_TABLE = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  /*--- Variable export code ---*/
+  /*--- Function export code ---*/
+  /*--- Type init code ---*/
+  if (PyType_Ready(&__pyx_type_8cutadapt_6_align_Aligner) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_type_8cutadapt_6_align_Aligner.tp_print = 0;
+  if (PyObject_SetAttrString(__pyx_m, "Aligner", (PyObject *)&__pyx_type_8cutadapt_6_align_Aligner) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_8cutadapt_6_align_Aligner = &__pyx_type_8cutadapt_6_align_Aligner;
+  /*--- Type import code ---*/
+  /*--- Variable import code ---*/
+  /*--- Function import code ---*/
+  /*--- Execution code ---*/
+
+  /* "cutadapt/_align.pyx":32
+ * 
+ * 
+ * def _acgt_table():             # <<<<<<<<<<<<<<
+ * 	"""
+ * 	Return a translation table that maps A, C, G, T characters to the lower
+ */
+  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8cutadapt_6_align_1_acgt_table, NULL, __pyx_n_s_cutadapt__align); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_acgt_table, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 32; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "cutadapt/_align.pyx":48
+ * 
+ * 
+ * def _iupac_table():             # <<<<<<<<<<<<<<
+ * 	"""
+ * 	Return a translation table for IUPAC characters.
+ */
+  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8cutadapt_6_align_3_iupac_table, NULL, __pyx_n_s_cutadapt__align); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_iupac_table, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "cutadapt/_align.pyx":88
+ * 
+ * 
+ * cdef bytes ACGT_TABLE = _acgt_table()             # <<<<<<<<<<<<<<
+ * cdef bytes IUPAC_TABLE = _iupac_table()
+ * 
+ */
+  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_acgt_table); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = NULL;
+  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (__pyx_t_3) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  } else {
+    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 88; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_XGOTREF(__pyx_v_8cutadapt_6_align_ACGT_TABLE);
+  __Pyx_DECREF_SET(__pyx_v_8cutadapt_6_align_ACGT_TABLE, ((PyObject*)__pyx_t_1));
+  __Pyx_GIVEREF(__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "cutadapt/_align.pyx":89
+ * 
+ * cdef bytes ACGT_TABLE = _acgt_table()
+ * cdef bytes IUPAC_TABLE = _iupac_table()             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_iupac_table); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = NULL;
+  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (__pyx_t_3) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  } else {
+    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  if (!(likely(PyBytes_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "bytes", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_XGOTREF(__pyx_v_8cutadapt_6_align_IUPAC_TABLE);
+  __Pyx_DECREF_SET(__pyx_v_8cutadapt_6_align_IUPAC_TABLE, ((PyObject*)__pyx_t_1));
+  __Pyx_GIVEREF(__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* "cutadapt/_align.pyx":405
+ * 
+ * 
+ * def locate(str reference, str query, double max_error_rate, int flags=SEMIGLOBAL, int degenerate=0, int min_overlap=1):             # <<<<<<<<<<<<<<
+ * 	aligner = Aligner(reference, max_error_rate, flags, degenerate, min_overlap)
+ * 	return aligner.locate(query)
+ */
+  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8cutadapt_6_align_5locate, NULL, __pyx_n_s_cutadapt__align); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_locate, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 405; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "cutadapt/_align.pyx":410
+ * 
+ * 
+ * def compare_prefixes(str ref, str query, int degenerate=0):             # <<<<<<<<<<<<<<
+ * 	"""
+ * 	Find out whether one string is the prefix of the other one, allowing
+ */
+  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8cutadapt_6_align_7compare_prefixes, NULL, __pyx_n_s_cutadapt__align); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_compare_prefixes, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 410; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "cutadapt/_align.pyx":1
+ * from cpython.mem cimport PyMem_Malloc, PyMem_Free, PyMem_Realloc             # <<<<<<<<<<<<<<
+ * 
+ * DEF START_WITHIN_SEQ1 = 1
+ */
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /*--- Wrapped vars code ---*/
+
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  if (__pyx_m) {
+    if (__pyx_d) {
+      __Pyx_AddTraceback("init cutadapt._align", __pyx_clineno, __pyx_lineno, __pyx_filename);
+    }
+    Py_DECREF(__pyx_m); __pyx_m = 0;
+  } else if (!PyErr_Occurred()) {
+    PyErr_SetString(PyExc_ImportError, "init cutadapt._align");
+  }
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  #if PY_MAJOR_VERSION < 3
+  return;
+  #else
+  return __pyx_m;
+  #endif
+}
+
+/* --- Runtime support code --- */
+#if CYTHON_REFNANNY
+static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
+    PyObject *m = NULL, *p = NULL;
+    void *r = NULL;
+    m = PyImport_ImportModule((char *)modname);
+    if (!m) goto end;
+    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
+    if (!p) goto end;
+    r = PyLong_AsVoidPtr(p);
+end:
+    Py_XDECREF(p);
+    Py_XDECREF(m);
+    return (__Pyx_RefNannyAPIStruct *)r;
+}
+#endif
+
+static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
+    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
+    if (unlikely(!result)) {
+        PyErr_Format(PyExc_NameError,
+#if PY_MAJOR_VERSION >= 3
+            "name '%U' is not defined", name);
+#else
+            "name '%.200s' is not defined", PyString_AS_STRING(name));
+#endif
+    }
+    return result;
+}
+
+#if CYTHON_COMPILING_IN_CPYTHON
+static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
+    PyObject *result;
+    ternaryfunc call = func->ob_type->tp_call;
+    if (unlikely(!call))
+        return PyObject_Call(func, arg, kw);
+    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
+        return NULL;
+    result = (*call)(func, arg, kw);
+    Py_LeaveRecursiveCall();
+    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
+        PyErr_SetString(
+            PyExc_SystemError,
+            "NULL result without error in PyObject_Call");
+    }
+    return result;
+}
+#endif
+
+#if CYTHON_COMPILING_IN_CPYTHON
+static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
+    PyObject *self, *result;
+    PyCFunction cfunc;
+    cfunc = PyCFunction_GET_FUNCTION(func);
+    self = PyCFunction_GET_SELF(func);
+    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
+        return NULL;
+    result = cfunc(self, arg);
+    Py_LeaveRecursiveCall();
+    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
+        PyErr_SetString(
+            PyExc_SystemError,
+            "NULL result without error in PyObject_Call");
+    }
+    return result;
+}
+#endif
+
+#if CYTHON_COMPILING_IN_CPYTHON
+static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
+    PyObject *result;
+    PyObject *args = PyTuple_New(1);
+    if (unlikely(!args)) return NULL;
+    Py_INCREF(arg);
+    PyTuple_SET_ITEM(args, 0, arg);
+    result = __Pyx_PyObject_Call(func, args, NULL);
+    Py_DECREF(args);
+    return result;
+}
+static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
+#ifdef __Pyx_CyFunction_USED
+    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
+#else
+    if (likely(PyCFunction_Check(func))) {
+#endif
+        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
+            return __Pyx_PyObject_CallMethO(func, arg);
+        }
+    }
+    return __Pyx__PyObject_CallOneArg(func, arg);
+}
+#else
+static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
+    PyObject* args = PyTuple_Pack(1, arg);
+    return (likely(args)) ? __Pyx_PyObject_Call(func, args, NULL) : NULL;
+}
+#endif
+
+static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
+    PyObject *method, *result = NULL;
+    method = __Pyx_PyObject_GetAttrStr(obj, method_name);
+    if (unlikely(!method)) goto bad;
+#if CYTHON_COMPILING_IN_CPYTHON
+    if (likely(PyMethod_Check(method))) {
+        PyObject *self = PyMethod_GET_SELF(method);
+        if (likely(self)) {
+            PyObject *args;
+            PyObject *function = PyMethod_GET_FUNCTION(method);
+            args = PyTuple_New(2);
+            if (unlikely(!args)) goto bad;
+            Py_INCREF(self);
+            PyTuple_SET_ITEM(args, 0, self);
+            Py_INCREF(arg);
+            PyTuple_SET_ITEM(args, 1, arg);
+            Py_INCREF(function);
+            Py_DECREF(method); method = NULL;
+            result = __Pyx_PyObject_Call(function, args, NULL);
+            Py_DECREF(args);
+            Py_DECREF(function);
+            return result;
+        }
+    }
+#endif
+    result = __Pyx_PyObject_CallOneArg(method, arg);
+bad:
+    Py_XDECREF(method);
+    return result;
+}
+
+static CYTHON_INLINE PyObject* __Pyx_PyDict_Items(PyObject* d) {
+    if (PY_MAJOR_VERSION >= 3)
+        return __Pyx_PyObject_CallMethod1((PyObject*)&PyDict_Type, __pyx_n_s_items, d);
+    else
+        return PyDict_Items(d);
+}
+
+static CYTHON_INLINE void __Pyx_RaiseTooManyValuesError(Py_ssize_t expected) {
+    PyErr_Format(PyExc_ValueError,
+                 "too many values to unpack (expected %" CYTHON_FORMAT_SSIZE_T "d)", expected);
+}
+
+static CYTHON_INLINE void __Pyx_RaiseNeedMoreValuesError(Py_ssize_t index) {
+    PyErr_Format(PyExc_ValueError,
+                 "need more than %" CYTHON_FORMAT_SSIZE_T "d value%.1s to unpack",
+                 index, (index == 1) ? "" : "s");
+}
+
+static CYTHON_INLINE int __Pyx_IterFinish(void) {
+#if CYTHON_COMPILING_IN_CPYTHON
+    PyThreadState *tstate = PyThreadState_GET();
+    PyObject* exc_type = tstate->curexc_type;
+    if (unlikely(exc_type)) {
+        if (likely(exc_type == PyExc_StopIteration) || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration)) {
+            PyObject *exc_value, *exc_tb;
+            exc_value = tstate->curexc_value;
+            exc_tb = tstate->curexc_traceback;
+            tstate->curexc_type = 0;
+            tstate->curexc_value = 0;
+            tstate->curexc_traceback = 0;
+            Py_DECREF(exc_type);
+            Py_XDECREF(exc_value);
+            Py_XDECREF(exc_tb);
+            return 0;
+        } else {
+            return -1;
+        }
+    }
+    return 0;
+#else
+    if (unlikely(PyErr_Occurred())) {
+        if (likely(PyErr_ExceptionMatches(PyExc_StopIteration))) {
+            PyErr_Clear();
+            return 0;
+        } else {
+            return -1;
+        }
+    }
+    return 0;
+#endif
+}
+
+static int __Pyx_IternextUnpackEndCheck(PyObject *retval, Py_ssize_t expected) {
+    if (unlikely(retval)) {
+        Py_DECREF(retval);
+        __Pyx_RaiseTooManyValuesError(expected);
+        return -1;
+    } else {
+        return __Pyx_IterFinish();
+    }
+    return 0;
+}
+
+#if CYTHON_COMPILING_IN_CPYTHON
+static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
+#ifdef __Pyx_CyFunction_USED
+    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
+#else
+    if (likely(PyCFunction_Check(func))) {
+#endif
+        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
+            return __Pyx_PyObject_CallMethO(func, NULL);
+        }
+    }
+    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
+}
+#endif
+
+static void __Pyx_RaiseArgtupleInvalid(
+    const char* func_name,
+    int exact,
+    Py_ssize_t num_min,
+    Py_ssize_t num_max,
+    Py_ssize_t num_found)
+{
+    Py_ssize_t num_expected;
+    const char *more_or_less;
+    if (num_found < num_min) {
+        num_expected = num_min;
+        more_or_less = "at least";
+    } else {
+        num_expected = num_max;
+        more_or_less = "at most";
+    }
+    if (exact) {
+        more_or_less = "exactly";
+    }
+    PyErr_Format(PyExc_TypeError,
+                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
+                 func_name, more_or_less, num_expected,
+                 (num_expected == 1) ? "" : "s", num_found);
+}
+
+static void __Pyx_RaiseDoubleKeywordsError(
+    const char* func_name,
+    PyObject* kw_name)
+{
+    PyErr_Format(PyExc_TypeError,
+        #if PY_MAJOR_VERSION >= 3
+        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
+        #else
+        "%s() got multiple values for keyword argument '%s'", func_name,
+        PyString_AsString(kw_name));
+        #endif
+}
+
+static int __Pyx_ParseOptionalKeywords(
+    PyObject *kwds,
+    PyObject **argnames[],
+    PyObject *kwds2,
+    PyObject *values[],
+    Py_ssize_t num_pos_args,
+    const char* function_name)
+{
+    PyObject *key = 0, *value = 0;
+    Py_ssize_t pos = 0;
+    PyObject*** name;
+    PyObject*** first_kw_arg = argnames + num_pos_args;
+    while (PyDict_Next(kwds, &pos, &key, &value)) {
+        name = first_kw_arg;
+        while (*name && (**name != key)) name++;
+        if (*name) {
+            values[name-argnames] = value;
+            continue;
+        }
+        name = first_kw_arg;
+        #if PY_MAJOR_VERSION < 3
+        if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
+            while (*name) {
+                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
+                        && _PyString_Eq(**name, key)) {
+                    values[name-argnames] = value;
+                    break;
+                }
+                name++;
+            }
+            if (*name) continue;
+            else {
+                PyObject*** argname = argnames;
+                while (argname != first_kw_arg) {
+                    if ((**argname == key) || (
+                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
+                             && _PyString_Eq(**argname, key))) {
+                        goto arg_passed_twice;
+                    }
+                    argname++;
+                }
+            }
+        } else
+        #endif
+        if (likely(PyUnicode_Check(key))) {
+            while (*name) {
+                int cmp = (**name == key) ? 0 :
+                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
+                    (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
+                #endif
+                    PyUnicode_Compare(**name, key);
+                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
+                if (cmp == 0) {
+                    values[name-argnames] = value;
+                    break;
+                }
+                name++;
+            }
+            if (*name) continue;
+            else {
+                PyObject*** argname = argnames;
+                while (argname != first_kw_arg) {
+                    int cmp = (**argname == key) ? 0 :
+                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
+                        (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
+                    #endif
+                        PyUnicode_Compare(**argname, key);
+                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
+                    if (cmp == 0) goto arg_passed_twice;
+                    argname++;
+                }
+            }
+        } else
+            goto invalid_keyword_type;
+        if (kwds2) {
+            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
+        } else {
+            goto invalid_keyword;
+        }
+    }
+    return 0;
+arg_passed_twice:
+    __Pyx_RaiseDoubleKeywordsError(function_name, key);
+    goto bad;
+invalid_keyword_type:
+    PyErr_Format(PyExc_TypeError,
+        "%.200s() keywords must be strings", function_name);
+    goto bad;
+invalid_keyword:
+    PyErr_Format(PyExc_TypeError,
+    #if PY_MAJOR_VERSION < 3
+        "%.200s() got an unexpected keyword argument '%.200s'",
+        function_name, PyString_AsString(key));
+    #else
+        "%s() got an unexpected keyword argument '%U'",
+        function_name, key);
+    #endif
+bad:
+    return -1;
+}
+
+static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) {
+    PyErr_Format(PyExc_TypeError,
+        "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
+        name, type->tp_name, Py_TYPE(obj)->tp_name);
+}
+static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
+    const char *name, int exact)
+{
+    if (unlikely(!type)) {
+        PyErr_SetString(PyExc_SystemError, "Missing type object");
+        return 0;
+    }
+    if (none_allowed && obj == Py_None) return 1;
+    else if (exact) {
+        if (likely(Py_TYPE(obj) == type)) return 1;
+        #if PY_MAJOR_VERSION == 2
+        else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
+        #endif
+    }
+    else {
+        if (likely(PyObject_TypeCheck(obj, type))) return 1;
+    }
+    __Pyx_RaiseArgumentTypeInvalid(name, obj, type);
+    return 0;
+}
+
+static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
+#if CYTHON_COMPILING_IN_CPYTHON
+    PyObject *tmp_type, *tmp_value, *tmp_tb;
+    PyThreadState *tstate = PyThreadState_GET();
+    tmp_type = tstate->curexc_type;
+    tmp_value = tstate->curexc_value;
+    tmp_tb = tstate->curexc_traceback;
+    tstate->curexc_type = type;
+    tstate->curexc_value = value;
+    tstate->curexc_traceback = tb;
+    Py_XDECREF(tmp_type);
+    Py_XDECREF(tmp_value);
+    Py_XDECREF(tmp_tb);
+#else
+    PyErr_Restore(type, value, tb);
+#endif
+}
+static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
+#if CYTHON_COMPILING_IN_CPYTHON
+    PyThreadState *tstate = PyThreadState_GET();
+    *type = tstate->curexc_type;
+    *value = tstate->curexc_value;
+    *tb = tstate->curexc_traceback;
+    tstate->curexc_type = 0;
+    tstate->curexc_value = 0;
+    tstate->curexc_traceback = 0;
+#else
+    PyErr_Fetch(type, value, tb);
+#endif
+}
+
+#if PY_MAJOR_VERSION < 3
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
+                        CYTHON_UNUSED PyObject *cause) {
+    Py_XINCREF(type);
+    if (!value || value == Py_None)
+        value = NULL;
+    else
+        Py_INCREF(value);
+    if (!tb || tb == Py_None)
+        tb = NULL;
+    else {
+        Py_INCREF(tb);
+        if (!PyTraceBack_Check(tb)) {
+            PyErr_SetString(PyExc_TypeError,
+                "raise: arg 3 must be a traceback or None");
+            goto raise_error;
+        }
+    }
+    if (PyType_Check(type)) {
+#if CYTHON_COMPILING_IN_PYPY
+        if (!value) {
+            Py_INCREF(Py_None);
+            value = Py_None;
+        }
+#endif
+        PyErr_NormalizeException(&type, &value, &tb);
+    } else {
+        if (value) {
+            PyErr_SetString(PyExc_TypeError,
+                "instance exception may not have a separate value");
+            goto raise_error;
+        }
+        value = type;
+        type = (PyObject*) Py_TYPE(type);
+        Py_INCREF(type);
+        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
+            PyErr_SetString(PyExc_TypeError,
+                "raise: exception class must be a subclass of BaseException");
+            goto raise_error;
+        }
+    }
+    __Pyx_ErrRestore(type, value, tb);
+    return;
+raise_error:
+    Py_XDECREF(value);
+    Py_XDECREF(type);
+    Py_XDECREF(tb);
+    return;
+}
+#else
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
+    PyObject* owned_instance = NULL;
+    if (tb == Py_None) {
+        tb = 0;
+    } else if (tb && !PyTraceBack_Check(tb)) {
+        PyErr_SetString(PyExc_TypeError,
+            "raise: arg 3 must be a traceback or None");
+        goto bad;
+    }
+    if (value == Py_None)
+        value = 0;
+    if (PyExceptionInstance_Check(type)) {
+        if (value) {
+            PyErr_SetString(PyExc_TypeError,
+                "instance exception may not have a separate value");
+            goto bad;
+        }
+        value = type;
+        type = (PyObject*) Py_TYPE(value);
+    } else if (PyExceptionClass_Check(type)) {
+        PyObject *instance_class = NULL;
+        if (value && PyExceptionInstance_Check(value)) {
+            instance_class = (PyObject*) Py_TYPE(value);
+            if (instance_class != type) {
+                int is_subclass = PyObject_IsSubclass(instance_class, type);
+                if (!is_subclass) {
+                    instance_class = NULL;
+                } else if (unlikely(is_subclass == -1)) {
+                    goto bad;
+                } else {
+                    type = instance_class;
+                }
+            }
+        }
+        if (!instance_class) {
+            PyObject *args;
+            if (!value)
+                args = PyTuple_New(0);
+            else if (PyTuple_Check(value)) {
+                Py_INCREF(value);
+                args = value;
+            } else
+                args = PyTuple_Pack(1, value);
+            if (!args)
+                goto bad;
+            owned_instance = PyObject_Call(type, args, NULL);
+            Py_DECREF(args);
+            if (!owned_instance)
+                goto bad;
+            value = owned_instance;
+            if (!PyExceptionInstance_Check(value)) {
+                PyErr_Format(PyExc_TypeError,
+                             "calling %R should have returned an instance of "
+                             "BaseException, not %R",
+                             type, Py_TYPE(value));
+                goto bad;
+            }
+        }
+    } else {
+        PyErr_SetString(PyExc_TypeError,
+            "raise: exception class must be a subclass of BaseException");
+        goto bad;
+    }
+#if PY_VERSION_HEX >= 0x03030000
+    if (cause) {
+#else
+    if (cause && cause != Py_None) {
+#endif
+        PyObject *fixed_cause;
+        if (cause == Py_None) {
+            fixed_cause = NULL;
+        } else if (PyExceptionClass_Check(cause)) {
+            fixed_cause = PyObject_CallObject(cause, NULL);
+            if (fixed_cause == NULL)
+                goto bad;
+        } else if (PyExceptionInstance_Check(cause)) {
+            fixed_cause = cause;
+            Py_INCREF(fixed_cause);
+        } else {
+            PyErr_SetString(PyExc_TypeError,
+                            "exception causes must derive from "
+                            "BaseException");
+            goto bad;
+        }
+        PyException_SetCause(value, fixed_cause);
+    }
+    PyErr_SetObject(type, value);
+    if (tb) {
+#if CYTHON_COMPILING_IN_PYPY
+        PyObject *tmp_type, *tmp_value, *tmp_tb;
+        PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
+        Py_INCREF(tb);
+        PyErr_Restore(tmp_type, tmp_value, tb);
+        Py_XDECREF(tmp_tb);
+#else
+        PyThreadState *tstate = PyThreadState_GET();
+        PyObject* tmp_tb = tstate->curexc_traceback;
+        if (tb != tmp_tb) {
+            Py_INCREF(tb);
+            tstate->curexc_traceback = tb;
+            Py_XDECREF(tmp_tb);
+        }
+#endif
+    }
+bad:
+    Py_XDECREF(owned_instance);
+    return;
+}
+#endif
+
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
+    PyObject *r;
+    if (!j) return NULL;
+    r = PyObject_GetItem(o, j);
+    Py_DECREF(j);
+    return r;
+}
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
+                                                              CYTHON_NCP_UNUSED int wraparound,
+                                                              CYTHON_NCP_UNUSED int boundscheck) {
+#if CYTHON_COMPILING_IN_CPYTHON
+    if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o);
+    if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
+        PyObject *r = PyList_GET_ITEM(o, i);
+        Py_INCREF(r);
+        return r;
+    }
+    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
+#else
+    return PySequence_GetItem(o, i);
+#endif
+}
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
+                                                              CYTHON_NCP_UNUSED int wraparound,
+                                                              CYTHON_NCP_UNUSED int boundscheck) {
+#if CYTHON_COMPILING_IN_CPYTHON
+    if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o);
+    if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
+        PyObject *r = PyTuple_GET_ITEM(o, i);
+        Py_INCREF(r);
+        return r;
+    }
+    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
+#else
+    return PySequence_GetItem(o, i);
+#endif
+}
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
+                                                     CYTHON_NCP_UNUSED int wraparound,
+                                                     CYTHON_NCP_UNUSED int boundscheck) {
+#if CYTHON_COMPILING_IN_CPYTHON
+    if (is_list || PyList_CheckExact(o)) {
+        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
+        if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
+            PyObject *r = PyList_GET_ITEM(o, n);
+            Py_INCREF(r);
+            return r;
+        }
+    }
+    else if (PyTuple_CheckExact(o)) {
+        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
+        if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
+            PyObject *r = PyTuple_GET_ITEM(o, n);
+            Py_INCREF(r);
+            return r;
+        }
+    } else {
+        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
+        if (likely(m && m->sq_item)) {
+            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
+                Py_ssize_t l = m->sq_length(o);
+                if (likely(l >= 0)) {
+                    i += l;
+                } else {
+                    if (PyErr_ExceptionMatches(PyExc_OverflowError))
+                        PyErr_Clear();
+                    else
+                        return NULL;
+                }
+            }
+            return m->sq_item(o, i);
+        }
+    }
+#else
+    if (is_list || PySequence_Check(o)) {
+        return PySequence_GetItem(o, i);
+    }
+#endif
+    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
+}
+
+static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
+    PyObject *result;
+#if CYTHON_COMPILING_IN_CPYTHON
+    result = PyDict_GetItem(__pyx_d, name);
+    if (likely(result)) {
+        Py_INCREF(result);
+    } else {
+#else
+    result = PyObject_GetItem(__pyx_d, name);
+    if (!result) {
+        PyErr_Clear();
+#endif
+        result = __Pyx_GetBuiltinName(name);
+    }
+    return result;
+}
+
+static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
+    int start = 0, mid = 0, end = count - 1;
+    if (end >= 0 && code_line > entries[end].code_line) {
+        return count;
+    }
+    while (start < end) {
+        mid = (start + end) / 2;
+        if (code_line < entries[mid].code_line) {
+            end = mid;
+        } else if (code_line > entries[mid].code_line) {
+             start = mid + 1;
+        } else {
+            return mid;
+        }
+    }
+    if (code_line <= entries[mid].code_line) {
+        return mid;
+    } else {
+        return mid + 1;
+    }
+}
+static PyCodeObject *__pyx_find_code_object(int code_line) {
+    PyCodeObject* code_object;
+    int pos;
+    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
+        return NULL;
+    }
+    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
+    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
+        return NULL;
+    }
+    code_object = __pyx_code_cache.entries[pos].code_object;
+    Py_INCREF(code_object);
+    return code_object;
+}
+static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
+    int pos, i;
+    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
+    if (unlikely(!code_line)) {
+        return;
+    }
+    if (unlikely(!entries)) {
+        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
+        if (likely(entries)) {
+            __pyx_code_cache.entries = entries;
+            __pyx_code_cache.max_count = 64;
+            __pyx_code_cache.count = 1;
+            entries[0].code_line = code_line;
+            entries[0].code_object = code_object;
+            Py_INCREF(code_object);
+        }
+        return;
+    }
+    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
+    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
+        PyCodeObject* tmp = entries[pos].code_object;
+        entries[pos].code_object = code_object;
+        Py_DECREF(tmp);
+        return;
+    }
+    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
+        int new_max = __pyx_code_cache.max_count + 64;
+        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
+            __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
+        if (unlikely(!entries)) {
+            return;
+        }
+        __pyx_code_cache.entries = entries;
+        __pyx_code_cache.max_count = new_max;
+    }
+    for (i=__pyx_code_cache.count; i>pos; i--) {
+        entries[i] = entries[i-1];
+    }
+    entries[pos].code_line = code_line;
+    entries[pos].code_object = code_object;
+    __pyx_code_cache.count++;
+    Py_INCREF(code_object);
+}
+
+#include "compile.h"
+#include "frameobject.h"
+#include "traceback.h"
+static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
+            const char *funcname, int c_line,
+            int py_line, const char *filename) {
+    PyCodeObject *py_code = 0;
+    PyObject *py_srcfile = 0;
+    PyObject *py_funcname = 0;
+    #if PY_MAJOR_VERSION < 3
+    py_srcfile = PyString_FromString(filename);
+    #else
+    py_srcfile = PyUnicode_FromString(filename);
+    #endif
+    if (!py_srcfile) goto bad;
+    if (c_line) {
+        #if PY_MAJOR_VERSION < 3
+        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
+        #else
+        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
+        #endif
+    }
+    else {
+        #if PY_MAJOR_VERSION < 3
+        py_funcname = PyString_FromString(funcname);
+        #else
+        py_funcname = PyUnicode_FromString(funcname);
+        #endif
+    }
+    if (!py_funcname) goto bad;
+    py_code = __Pyx_PyCode_New(
+        0,
+        0,
+        0,
+        0,
+        0,
+        __pyx_empty_bytes, /*PyObject *code,*/
+        __pyx_empty_tuple, /*PyObject *consts,*/
+        __pyx_empty_tuple, /*PyObject *names,*/
+        __pyx_empty_tuple, /*PyObject *varnames,*/
+        __pyx_empty_tuple, /*PyObject *freevars,*/
+        __pyx_empty_tuple, /*PyObject *cellvars,*/
+        py_srcfile,   /*PyObject *filename,*/
+        py_funcname,  /*PyObject *name,*/
+        py_line,
+        __pyx_empty_bytes  /*PyObject *lnotab*/
+    );
+    Py_DECREF(py_srcfile);
+    Py_DECREF(py_funcname);
+    return py_code;
+bad:
+    Py_XDECREF(py_srcfile);
+    Py_XDECREF(py_funcname);
+    return NULL;
+}
+static void __Pyx_AddTraceback(const char *funcname, int c_line,
+                               int py_line, const char *filename) {
+    PyCodeObject *py_code = 0;
+    PyFrameObject *py_frame = 0;
+    py_code = __pyx_find_code_object(c_line ? c_line : py_line);
+    if (!py_code) {
+        py_code = __Pyx_CreateCodeObjectForTraceback(
+            funcname, c_line, py_line, filename);
+        if (!py_code) goto bad;
+        __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
+    }
+    py_frame = PyFrame_New(
+        PyThreadState_GET(), /*PyThreadState *tstate,*/
+        py_code,             /*PyCodeObject *code,*/
+        __pyx_d,      /*PyObject *globals,*/
+        0                    /*PyObject *locals*/
+    );
+    if (!py_frame) goto bad;
+    py_frame->f_lineno = py_line;
+    PyTraceBack_Here(py_frame);
+bad:
+    Py_XDECREF(py_code);
+    Py_XDECREF(py_frame);
+}
+
+#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)       \
+    {                                                                     \
+        func_type value = func_value;                                     \
+        if (sizeof(target_type) < sizeof(func_type)) {                    \
+            if (unlikely(value != (func_type) (target_type) value)) {     \
+                func_type zero = 0;                                       \
+                if (is_unsigned && unlikely(value < zero))                \
+                    goto raise_neg_overflow;                              \
+                else                                                      \
+                    goto raise_overflow;                                  \
+            }                                                             \
+        }                                                                 \
+        return (target_type) value;                                       \
+    }
+
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+ #if CYTHON_USE_PYLONG_INTERNALS
+  #include "longintrepr.h"
+ #endif
+#endif
+
+static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
+    const int neg_one = (int) -1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_MAJOR_VERSION < 3
+    if (likely(PyInt_Check(x))) {
+        if (sizeof(int) < sizeof(long)) {
+            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
+        } else {
+            long val = PyInt_AS_LONG(x);
+            if (is_unsigned && unlikely(val < 0)) {
+                goto raise_neg_overflow;
+            }
+            return (int) val;
+        }
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+ #if CYTHON_USE_PYLONG_INTERNALS
+            switch (Py_SIZE(x)) {
+                case  0: return 0;
+                case  1: __PYX_VERIFY_RETURN_INT(int, digit, ((PyLongObject*)x)->ob_digit[0]);
+            }
+ #endif
+#endif
+#if CYTHON_COMPILING_IN_CPYTHON
+            if (unlikely(Py_SIZE(x) < 0)) {
+                goto raise_neg_overflow;
+            }
+#else
+            {
+                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
+                if (unlikely(result < 0))
+                    return (int) -1;
+                if (unlikely(result == 1))
+                    goto raise_neg_overflow;
+            }
+#endif
+            if (sizeof(int) <= sizeof(unsigned long)) {
+                __PYX_VERIFY_RETURN_INT(int, unsigned long, PyLong_AsUnsignedLong(x))
+            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
+            }
+        } else {
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+ #if CYTHON_USE_PYLONG_INTERNALS
+            switch (Py_SIZE(x)) {
+                case  0: return 0;
+                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +(((PyLongObject*)x)->ob_digit[0]));
+                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, -(sdigit) ((PyLongObject*)x)->ob_digit[0]);
+            }
+ #endif
+#endif
+            if (sizeof(int) <= sizeof(long)) {
+                __PYX_VERIFY_RETURN_INT(int, long, PyLong_AsLong(x))
+            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT(int, PY_LONG_LONG, PyLong_AsLongLong(x))
+            }
+        }
+        {
+#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
+            PyErr_SetString(PyExc_RuntimeError,
+                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
+#else
+            int val;
+            PyObject *v = __Pyx_PyNumber_Int(x);
+ #if PY_MAJOR_VERSION < 3
+            if (likely(v) && !PyLong_Check(v)) {
+                PyObject *tmp = v;
+                v = PyNumber_Long(tmp);
+                Py_DECREF(tmp);
+            }
+ #endif
+            if (likely(v)) {
+                int one = 1; int is_little = (int)*(unsigned char *)&one;
+                unsigned char *bytes = (unsigned char *)&val;
+                int ret = _PyLong_AsByteArray((PyLongObject *)v,
+                                              bytes, sizeof(val),
+                                              is_little, !is_unsigned);
+                Py_DECREF(v);
+                if (likely(!ret))
+                    return val;
+            }
+#endif
+            return (int) -1;
+        }
+    } else {
+        int val;
+        PyObject *tmp = __Pyx_PyNumber_Int(x);
+        if (!tmp) return (int) -1;
+        val = __Pyx_PyInt_As_int(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+raise_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "value too large to convert to int");
+    return (int) -1;
+raise_neg_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "can't convert negative value to int");
+    return (int) -1;
+}
+
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
+    const long neg_one = (long) -1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (is_unsigned) {
+        if (sizeof(long) < sizeof(long)) {
+            return PyInt_FromLong((long) value);
+        } else if (sizeof(long) <= sizeof(unsigned long)) {
+            return PyLong_FromUnsignedLong((unsigned long) value);
+        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
+            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
+        }
+    } else {
+        if (sizeof(long) <= sizeof(long)) {
+            return PyInt_FromLong((long) value);
+        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
+            return PyLong_FromLongLong((PY_LONG_LONG) value);
+        }
+    }
+    {
+        int one = 1; int little = (int)*(unsigned char *)&one;
+        unsigned char *bytes = (unsigned char *)&value;
+        return _PyLong_FromByteArray(bytes, sizeof(long),
+                                     little, !is_unsigned);
+    }
+}
+
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
+    const int neg_one = (int) -1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (is_unsigned) {
+        if (sizeof(int) < sizeof(long)) {
+            return PyInt_FromLong((long) value);
+        } else if (sizeof(int) <= sizeof(unsigned long)) {
+            return PyLong_FromUnsignedLong((unsigned long) value);
+        } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
+            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
+        }
+    } else {
+        if (sizeof(int) <= sizeof(long)) {
+            return PyInt_FromLong((long) value);
+        } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
+            return PyLong_FromLongLong((PY_LONG_LONG) value);
+        }
+    }
+    {
+        int one = 1; int little = (int)*(unsigned char *)&one;
+        unsigned char *bytes = (unsigned char *)&value;
+        return _PyLong_FromByteArray(bytes, sizeof(int),
+                                     little, !is_unsigned);
+    }
+}
+
+static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
+    const long neg_one = (long) -1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_MAJOR_VERSION < 3
+    if (likely(PyInt_Check(x))) {
+        if (sizeof(long) < sizeof(long)) {
+            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
+        } else {
+            long val = PyInt_AS_LONG(x);
+            if (is_unsigned && unlikely(val < 0)) {
+                goto raise_neg_overflow;
+            }
+            return (long) val;
+        }
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+ #if CYTHON_USE_PYLONG_INTERNALS
+            switch (Py_SIZE(x)) {
+                case  0: return 0;
+                case  1: __PYX_VERIFY_RETURN_INT(long, digit, ((PyLongObject*)x)->ob_digit[0]);
+            }
+ #endif
+#endif
+#if CYTHON_COMPILING_IN_CPYTHON
+            if (unlikely(Py_SIZE(x) < 0)) {
+                goto raise_neg_overflow;
+            }
+#else
+            {
+                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
+                if (unlikely(result < 0))
+                    return (long) -1;
+                if (unlikely(result == 1))
+                    goto raise_neg_overflow;
+            }
+#endif
+            if (sizeof(long) <= sizeof(unsigned long)) {
+                __PYX_VERIFY_RETURN_INT(long, unsigned long, PyLong_AsUnsignedLong(x))
+            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
+            }
+        } else {
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+ #if CYTHON_USE_PYLONG_INTERNALS
+            switch (Py_SIZE(x)) {
+                case  0: return 0;
+                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +(((PyLongObject*)x)->ob_digit[0]));
+                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, -(sdigit) ((PyLongObject*)x)->ob_digit[0]);
+            }
+ #endif
+#endif
+            if (sizeof(long) <= sizeof(long)) {
+                __PYX_VERIFY_RETURN_INT(long, long, PyLong_AsLong(x))
+            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT(long, PY_LONG_LONG, PyLong_AsLongLong(x))
+            }
+        }
+        {
+#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
+            PyErr_SetString(PyExc_RuntimeError,
+                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
+#else
+            long val;
+            PyObject *v = __Pyx_PyNumber_Int(x);
+ #if PY_MAJOR_VERSION < 3
+            if (likely(v) && !PyLong_Check(v)) {
+                PyObject *tmp = v;
+                v = PyNumber_Long(tmp);
+                Py_DECREF(tmp);
+            }
+ #endif
+            if (likely(v)) {
+                int one = 1; int is_little = (int)*(unsigned char *)&one;
+                unsigned char *bytes = (unsigned char *)&val;
+                int ret = _PyLong_AsByteArray((PyLongObject *)v,
+                                              bytes, sizeof(val),
+                                              is_little, !is_unsigned);
+                Py_DECREF(v);
+                if (likely(!ret))
+                    return val;
+            }
+#endif
+            return (long) -1;
+        }
+    } else {
+        long val;
+        PyObject *tmp = __Pyx_PyNumber_Int(x);
+        if (!tmp) return (long) -1;
+        val = __Pyx_PyInt_As_long(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+raise_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "value too large to convert to long");
+    return (long) -1;
+raise_neg_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "can't convert negative value to long");
+    return (long) -1;
+}
+
+static int __Pyx_check_binary_version(void) {
+    char ctversion[4], rtversion[4];
+    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
+    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
+    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
+        char message[200];
+        PyOS_snprintf(message, sizeof(message),
+                      "compiletime version %s of module '%.100s' "
+                      "does not match runtime version %s",
+                      ctversion, __Pyx_MODULE_NAME, rtversion);
+        return PyErr_WarnEx(NULL, message, 1);
+    }
+    return 0;
+}
+
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
+    while (t->p) {
+        #if PY_MAJOR_VERSION < 3
+        if (t->is_unicode) {
+            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
+        } else if (t->intern) {
+            *t->p = PyString_InternFromString(t->s);
+        } else {
+            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
+        }
+        #else
+        if (t->is_unicode | t->is_str) {
+            if (t->intern) {
+                *t->p = PyUnicode_InternFromString(t->s);
+            } else if (t->encoding) {
+                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
+            } else {
+                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
+            }
+        } else {
+            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
+        }
+        #endif
+        if (!*t->p)
+            return -1;
+        ++t;
+    }
+    return 0;
+}
+
+static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
+    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
+}
+static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
+    Py_ssize_t ignore;
+    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
+}
+static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
+#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
+    if (
+#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
+            __Pyx_sys_getdefaultencoding_not_ascii &&
+#endif
+            PyUnicode_Check(o)) {
+#if PY_VERSION_HEX < 0x03030000
+        char* defenc_c;
+        PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
+        if (!defenc) return NULL;
+        defenc_c = PyBytes_AS_STRING(defenc);
+#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
+        {
+            char* end = defenc_c + PyBytes_GET_SIZE(defenc);
+            char* c;
+            for (c = defenc_c; c < end; c++) {
+                if ((unsigned char) (*c) >= 128) {
+                    PyUnicode_AsASCIIString(o);
+                    return NULL;
+                }
+            }
+        }
+#endif
+        *length = PyBytes_GET_SIZE(defenc);
+        return defenc_c;
+#else
+        if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
+#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
+        if (PyUnicode_IS_ASCII(o)) {
+            *length = PyUnicode_GET_LENGTH(o);
+            return PyUnicode_AsUTF8(o);
+        } else {
+            PyUnicode_AsASCIIString(o);
+            return NULL;
+        }
+#else
+        return PyUnicode_AsUTF8AndSize(o, length);
+#endif
+#endif
+    } else
+#endif
+#if !CYTHON_COMPILING_IN_PYPY
+    if (PyByteArray_Check(o)) {
+        *length = PyByteArray_GET_SIZE(o);
+        return PyByteArray_AS_STRING(o);
+    } else
+#endif
+    {
+        char* result;
+        int r = PyBytes_AsStringAndSize(o, &result, length);
+        if (unlikely(r < 0)) {
+            return NULL;
+        } else {
+            return result;
+        }
+    }
+}
+static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
+   int is_true = x == Py_True;
+   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
+   else return PyObject_IsTrue(x);
+}
+static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
+  PyNumberMethods *m;
+  const char *name = NULL;
+  PyObject *res = NULL;
+#if PY_MAJOR_VERSION < 3
+  if (PyInt_Check(x) || PyLong_Check(x))
+#else
+  if (PyLong_Check(x))
+#endif
+    return Py_INCREF(x), x;
+  m = Py_TYPE(x)->tp_as_number;
+#if PY_MAJOR_VERSION < 3
+  if (m && m->nb_int) {
+    name = "int";
+    res = PyNumber_Int(x);
+  }
+  else if (m && m->nb_long) {
+    name = "long";
+    res = PyNumber_Long(x);
+  }
+#else
+  if (m && m->nb_int) {
+    name = "int";
+    res = PyNumber_Long(x);
+  }
+#endif
+  if (res) {
+#if PY_MAJOR_VERSION < 3
+    if (!PyInt_Check(res) && !PyLong_Check(res)) {
+#else
+    if (!PyLong_Check(res)) {
+#endif
+      PyErr_Format(PyExc_TypeError,
+                   "__%.4s__ returned non-%.4s (type %.200s)",
+                   name, name, Py_TYPE(res)->tp_name);
+      Py_DECREF(res);
+      return NULL;
+    }
+  }
+  else if (!PyErr_Occurred()) {
+    PyErr_SetString(PyExc_TypeError,
+                    "an integer is required");
+  }
+  return res;
+}
+static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
+  Py_ssize_t ival;
+  PyObject *x;
+#if PY_MAJOR_VERSION < 3
+  if (likely(PyInt_CheckExact(b)))
+      return PyInt_AS_LONG(b);
+#endif
+  if (likely(PyLong_CheckExact(b))) {
+    #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+     #if CYTHON_USE_PYLONG_INTERNALS
+       switch (Py_SIZE(b)) {
+       case -1: return -(sdigit)((PyLongObject*)b)->ob_digit[0];
+       case  0: return 0;
+       case  1: return ((PyLongObject*)b)->ob_digit[0];
+       }
+     #endif
+    #endif
+    return PyLong_AsSsize_t(b);
+  }
+  x = PyNumber_Index(b);
+  if (!x) return -1;
+  ival = PyInt_AsSsize_t(x);
+  Py_DECREF(x);
+  return ival;
+}
+static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
+    return PyInt_FromSize_t(ival);
+}
+
+
+#endif /* Py_PYTHON_H */
diff --git a/cutadapt/_align.pyx b/cutadapt/_align.pyx
new file mode 100644
index 0000000..1fe51b5
--- /dev/null
+++ b/cutadapt/_align.pyx
@@ -0,0 +1,456 @@
+from cpython.mem cimport PyMem_Malloc, PyMem_Free, PyMem_Realloc
+
+DEF START_WITHIN_SEQ1 = 1
+DEF START_WITHIN_SEQ2 = 2
+DEF STOP_WITHIN_SEQ1 = 4
+DEF STOP_WITHIN_SEQ2 = 8
+DEF SEMIGLOBAL = 15
+DEF ALLOW_WILDCARD_SEQ1 = 1
+DEF ALLOW_WILDCARD_SEQ2 = 2
+
+DEF INSERTION_COST = 1
+DEF DELETION_COST = 1
+DEF MATCH_COST = 0
+DEF MISMATCH_COST = 1
+DEF WILDCARD_CHAR = 'N'
+
+# structure for a DP matrix entry
+ctypedef struct _Entry:
+	int cost
+	int matches  # no. of matches in this alignment
+	int origin   # where the alignment originated: negative for positions within seq1, positive for pos. within seq2
+
+
+ctypedef struct _Match:
+	int origin
+	int cost
+	int matches
+	int ref_stop
+	int query_stop
+
+
+def _acgt_table():
+	"""
+	Return a translation table that maps A, C, G, T characters to the lower
+	four bits of a byte. Other characters (including possibly IUPAC characters)
+	are mapped to zero.
+
+	Lowercase versions are also translated, and U is treated the same as T.
+	"""
+	d = dict(A=1, C=2, G=4, T=8, U=8)
+	t = bytearray(b'\0') * 256
+	for c, v in d.items():
+		t[ord(c)] = v
+		t[ord(c.lower())] = v
+	return bytes(t)
+
+
+def _iupac_table():
+	"""
+	Return a translation table for IUPAC characters.
+
+	The table maps ASCII-encoded IUPAC nucleotide characters to bytes in which
+	the four least significant bits are used to represent one nucleotide each.
+
+	Whether two characters x and y match can then be checked with the
+	expression "x & y != 0".
+	"""
+	A = 1
+	C = 2
+	G = 4
+	T = 8
+	d = dict(
+		X=0,
+		A=A,
+		C=C,
+		G=G,
+		T=T,
+		U=T,
+		R=A|G,
+		Y=C|T,
+		S=G|C,
+		W=A|T,
+		K=G|T,
+		M=A|C,
+		B=C|G|T,
+		D=A|G|T,
+		H=A|C|T,
+		V=A|C|G,
+		N=A|C|G|T
+	)
+	t = bytearray(b'\0') * 256
+	for c, v in d.items():
+		t[ord(c)] = v
+		t[ord(c.lower())] = v
+	return bytes(t)
+
+
+cdef bytes ACGT_TABLE = _acgt_table()
+cdef bytes IUPAC_TABLE = _iupac_table()
+
+
+cdef class Aligner:
+	"""
+	TODO documentation still uses s1 (reference) and s2 (query).
+
+	Locate one string within another by computing an optimal semiglobal
+	alignment between string1 and string2.
+
+	The alignment uses unit costs, which means that mismatches, insertions and deletions are
+	counted as one error.
+
+	flags is a bitwise 'or' of the allowed flags.
+	To allow skipping of a prefix of string1 at no cost, set the
+	START_WITHIN_SEQ1 flag.
+	To allow skipping of a prefix of string2 at no cost, set the
+	START_WITHIN_SEQ2 flag.
+	If both are set, a prefix of string1 or of string1 is skipped,
+	never both.
+	Similarly, set STOP_WITHIN_SEQ1 and STOP_WITHIN_SEQ2 to
+	allow skipping of suffixes of string1 or string2. Again, when both
+	flags are set, never suffixes in both strings are skipped.
+	If all flags are set, this results in standard semiglobal alignment.
+
+	The skipped parts are described with two intervals (start1, stop1),
+	(start2, stop2).
+
+	For example, an optimal semiglobal alignment of SISSI and MISSISSIPPI looks like this:
+
+	---SISSI---
+	MISSISSIPPI
+
+	start1, stop1 = 0, 5
+	start2, stop2 = 3, 8
+	(with zero errors)
+
+	The aligned parts are string1[start1:stop1] and string2[start2:stop2].
+
+	The error rate is: errors / length where length is (stop1 - start1).
+
+	An optimal alignment fulfills all of these criteria:
+
+	- its error_rate is at most max_error_rate
+	- Among those alignments with error_rate <= max_error_rate, the alignment contains
+	  a maximal number of matches (there is no alignment with more matches).
+	- If there are multiple alignments with the same no. of matches, then one that
+	  has minimal no. of errors is chosen.
+	- If there are still multiple candidates, choose the alignment that starts at the
+	  leftmost position within the read.
+
+	The alignment itself is not returned, only the tuple
+	(start1, stop1, start2, stop2, matches, errors), where the first four fields have the
+	meaning as described, matches is the number of matches and errors is the number of
+	errors in the alignment.
+
+	It is always the case that at least one of start1 and start2 is zero.
+
+	IUPAC wildcard characters can be allowed in the reference and the query
+	by setting the appropriate bit in the 'degenerate' flag.
+
+	If neither flag is set, the full ASCII alphabet is used for comparison.
+	If any of the flags is set, all non-IUPAC characters in the sequences
+	compare as 'not equal'.
+	"""
+	cdef int m
+	cdef _Entry* column  # one column of the DP matrix
+	cdef double max_error_rate
+	cdef int flags
+	cdef int min_overlap
+	cdef bint wildcard_ref
+	cdef bint wildcard_query
+	cdef bytes _reference
+
+	def __cinit__(self, str reference, double max_error_rate, int flags=SEMIGLOBAL, int degenerate=0, int min_overlap=1):
+		self.max_error_rate = max_error_rate
+		self.flags = flags
+		self.wildcard_ref = degenerate & ALLOW_WILDCARD_SEQ1
+		self.wildcard_query = degenerate & ALLOW_WILDCARD_SEQ2
+		self.reference = reference
+		if min_overlap < 1:
+			raise ValueError("minimum overlap must be at least 1")
+		self.min_overlap = min_overlap
+
+	property reference:
+		def __get__(self):
+			return self._reference
+
+		def __set__(self, str reference):
+			mem = <_Entry*> PyMem_Realloc(self.column, (len(reference) + 1) * sizeof(_Entry))
+			if not mem:
+				raise MemoryError()
+			self.column = mem
+			self._reference = reference.encode('ascii')
+			self.m = len(reference)
+			if self.wildcard_ref:
+				self._reference = self._reference.translate(IUPAC_TABLE)
+			elif self.wildcard_query:
+				self._reference = self._reference.translate(ACGT_TABLE)
+
+	def locate(self, str query):
+		"""
+		locate(query) -> (refstart, refstop, querystart, querystop, matches, errors)
+
+		Find the query within the reference associated with this aligner. The
+		intervals (querystart, querystop) and (refstart, refstop) give the
+		location of the match.
+
+		That is, the substrings query[querystart:querystop] and
+		self.reference[refstart:refstop] were found to align best to each other,
+		with the given number of matches and the given number of errors.
+
+		The alignment itself is not returned.
+		"""
+		cdef char* s1 = self._reference
+		cdef bytes query_bytes = query.encode('ascii')
+		cdef char* s2 = query_bytes
+		cdef int m = self.m
+		cdef int n = len(query)
+		cdef _Entry* column = self.column
+		cdef double max_error_rate = self.max_error_rate
+		cdef bint start_in_ref = self.flags & START_WITHIN_SEQ1
+		cdef bint start_in_query = self.flags & START_WITHIN_SEQ2
+		cdef bint stop_in_ref = self.flags & STOP_WITHIN_SEQ1
+		cdef bint stop_in_query = self.flags & STOP_WITHIN_SEQ2
+
+		if self.wildcard_query:
+			query_bytes = query_bytes.translate(IUPAC_TABLE)
+			s2 = query_bytes
+		elif self.wildcard_ref:
+			query_bytes = query_bytes.translate(ACGT_TABLE)
+			s2 = query_bytes
+		cdef bint compare_ascii = not (self.wildcard_query or self.wildcard_ref)
+		"""
+		DP Matrix:
+		           query (j)
+		         ----------> n
+		        |
+		ref (i) |
+		        |
+		        V
+		       m
+		"""
+		cdef int i, j
+
+		# maximum no. of errors
+		cdef int k = <int> (max_error_rate * m)
+
+		# Determine largest and smallest column we need to compute
+		cdef int max_n = n
+		cdef int min_n = 0
+		if not start_in_query:
+			# costs can only get worse after column m
+			max_n = min(n, m + k)
+		if not stop_in_query:
+			min_n = max(0, n - m - k)
+
+		# Fill column min_n.
+		#
+		# Four cases:
+		# not startin1, not startin2: c(i,j) = max(i,j); origin(i, j) = 0
+		#     startin1, not startin2: c(i,j) = j       ; origin(i, j) = min(0, j - i)
+		# not startin1,     startin2: c(i,j) = i       ; origin(i, j) =
+		#     startin1,     startin2: c(i,j) = min(i,j)
+
+		# TODO (later)
+		# fill out columns only until 'last'
+		if not start_in_ref and not start_in_query:
+			for i in range(0, m + 1):
+				column[i].matches = 0
+				column[i].cost = max(i, min_n)
+				column[i].origin = 0
+		elif start_in_ref and not start_in_query:
+			for i in range(0, m + 1):
+				column[i].matches = 0
+				column[i].cost = min_n
+				column[i].origin = min(0, min_n - i)
+		elif not start_in_ref and start_in_query:
+			for i in range(0, m + 1):
+				column[i].matches = 0
+				column[i].cost = i
+				column[i].origin = max(0, min_n - i)
+		else:
+			for i in range(0, m + 1):
+				column[i].matches = 0
+				column[i].cost = min(i, min_n)
+				column[i].origin = min_n - i
+
+		cdef _Match best
+		best.ref_stop = m
+		best.query_stop = n
+		best.cost = m + n
+		best.origin = 0
+		best.matches = 0
+
+		# Ukkonen's trick: index of the last cell that is less than k.
+		cdef int last = k + 1
+		if start_in_ref:
+			last = m
+
+		cdef int cost_diag
+		cdef int cost_deletion
+		cdef int cost_insertion
+		cdef int origin, cost, matches
+		cdef int length
+		cdef bint characters_equal
+		cdef _Entry tmp_entry
+
+		# iterate over columns
+		for j in range(min_n + 1, max_n + 1):
+			# remember first entry
+			tmp_entry = column[0]
+
+			# fill in first entry in this column
+			if start_in_query:
+				column[0].origin = j
+			else:
+				column[0].cost = j * INSERTION_COST
+			for i in range(1, last + 1):
+				if compare_ascii:
+					characters_equal = (s1[i-1] == s2[j-1])
+				else:
+					characters_equal = (s1[i-1] & s2[j-1]) != 0
+				if characters_equal:
+					# Characters match: This cannot be an indel.
+					cost = tmp_entry.cost
+					origin = tmp_entry.origin
+					matches = tmp_entry.matches + 1
+				else:
+					# Characters do not match.
+					cost_diag = tmp_entry.cost + 1
+					cost_deletion = column[i].cost + DELETION_COST
+					cost_insertion = column[i-1].cost + INSERTION_COST
+
+					if cost_diag <= cost_deletion and cost_diag <= cost_insertion:
+						# MISMATCH
+						cost = cost_diag
+						origin = tmp_entry.origin
+						matches = tmp_entry.matches
+					elif cost_insertion <= cost_deletion:
+						# INSERTION
+						cost = cost_insertion
+						origin = column[i-1].origin
+						matches = column[i-1].matches
+					else:
+						# DELETION
+						cost = cost_deletion
+						origin = column[i].origin
+						matches = column[i].matches
+
+				# remember current cell for next iteration
+				tmp_entry = column[i]
+
+				column[i].cost = cost
+				column[i].origin = origin
+				column[i].matches = matches
+			while last >= 0 and column[last].cost > k:
+				last -= 1
+			# last can be -1 here, but will be incremented next.
+			# TODO if last is -1, can we stop searching?
+			if last < m:
+				last += 1
+			elif stop_in_query:
+				# Found a match. If requested, find best match in last row.
+				# length of the aligned part of the reference
+				length = m + min(column[m].origin, 0)
+				cost = column[m].cost
+				matches = column[m].matches
+				if length >= self.min_overlap and cost <= length * max_error_rate and (matches > best.matches or (matches == best.matches and cost < best.cost)):
+					# update
+					best.matches = matches
+					best.cost = cost
+					best.origin = column[m].origin
+					best.ref_stop = m
+					best.query_stop = j
+					if cost == 0 and matches == m:
+						# exact match, stop early
+						break
+			# column finished
+
+		if max_n == n:
+			first_i = 0 if stop_in_ref else m
+			# search in last column # TODO last?
+			for i in range(first_i, m+1):
+				length = i + min(column[i].origin, 0)
+				cost = column[i].cost
+				matches = column[i].matches
+				if length >= self.min_overlap and cost <= length * max_error_rate and (matches > best.matches or (matches == best.matches and cost < best.cost)):
+					# update best
+					best.matches = matches
+					best.cost = cost
+					best.origin = column[i].origin
+					best.ref_stop = i
+					best.query_stop = n
+
+		if best.cost == m + n:
+			# best.cost was initialized with this value.
+			# If it is unchanged, no alignment was found that has
+			# an error rate within the allowed range.
+			return None
+
+		cdef int start1, start2
+		if best.origin >= 0:
+			start1 = 0
+			start2 = best.origin
+		else:
+			start1 = -best.origin
+			start2 = 0
+
+		assert best.ref_stop - start1 > 0  # Do not return empty alignments.
+		return (start1, best.ref_stop, start2, best.query_stop, best.matches, best.cost)
+
+	def __dealloc__(self):
+		PyMem_Free(self.column)
+
+
+def locate(str reference, str query, double max_error_rate, int flags=SEMIGLOBAL, int degenerate=0, int min_overlap=1):
+	aligner = Aligner(reference, max_error_rate, flags, degenerate, min_overlap)
+	return aligner.locate(query)
+
+
+def compare_prefixes(str ref, str query, int degenerate=0):
+	"""
+	Find out whether one string is the prefix of the other one, allowing
+	IUPAC wildcards if the appropriate bit is set in the degenerate flag
+	parameter.
+
+	This is used to find an anchored 5' adapter (type 'FRONT') in the 'no indels' mode.
+	This is very simple as only the number of errors needs to be counted.
+
+	This function returns a tuple compatible with what Aligner.locate outputs.
+	"""
+	cdef int m = len(ref)
+	cdef int n = len(query)
+	cdef bytes query_bytes = query.encode('ascii')
+	cdef bytes ref_bytes = ref.encode('ascii')
+	cdef char* r_ptr
+	cdef char* q_ptr
+	cdef bint wildcard_ref = degenerate & ALLOW_WILDCARD_SEQ1
+	cdef bint wildcard_query = degenerate & ALLOW_WILDCARD_SEQ2
+	cdef int length = min(m, n)
+	cdef int i, matches = 0
+	cdef bint compare_ascii = False
+
+	if wildcard_ref:
+		ref_bytes = ref_bytes.translate(IUPAC_TABLE)
+	elif wildcard_query:
+		ref_bytes = ref_bytes.translate(ACGT_TABLE)
+	else:
+		compare_ascii = True
+	if wildcard_query:
+		query_bytes = query_bytes.translate(IUPAC_TABLE)
+	elif wildcard_ref:
+		query_bytes = query_bytes.translate(ACGT_TABLE)
+
+	if compare_ascii:
+		for i in range(length):
+			if ref[i] == query[i]:
+				matches += 1
+	else:
+		r_ptr = ref_bytes
+		q_ptr = query_bytes
+		for i in range(length):
+			if (r_ptr[i] & q_ptr[i]) != 0:
+				matches += 1
+
+	# length - matches = no. of errors
+	return (0, length, 0, length, matches, length - matches)
diff --git a/cutadapt/_align.so b/cutadapt/_align.so
new file mode 100755
index 0000000..cf9c75c
Binary files /dev/null and b/cutadapt/_align.so differ
diff --git a/cutadapt/_qualtrim.c b/cutadapt/_qualtrim.c
new file mode 100644
index 0000000..88caf62
--- /dev/null
+++ b/cutadapt/_qualtrim.c
@@ -0,0 +1,2336 @@
+/* Generated by Cython 0.20.2 (Debian 0.20.2-1) on Mon Mar 16 17:13:50 2015 */
+
+#define PY_SSIZE_T_CLEAN
+#ifndef CYTHON_USE_PYLONG_INTERNALS
+#ifdef PYLONG_BITS_IN_DIGIT
+#define CYTHON_USE_PYLONG_INTERNALS 0
+#else
+#include "pyconfig.h"
+#ifdef PYLONG_BITS_IN_DIGIT
+#define CYTHON_USE_PYLONG_INTERNALS 1
+#else
+#define CYTHON_USE_PYLONG_INTERNALS 0
+#endif
+#endif
+#endif
+#include "Python.h"
+#ifndef Py_PYTHON_H
+    #error Python headers needed to compile C extensions, please install development version of Python.
+#elif PY_VERSION_HEX < 0x02040000
+    #error Cython requires Python 2.4+.
+#else
+#define CYTHON_ABI "0_20_2"
+#include <stddef.h> /* For offsetof */
+#ifndef offsetof
+#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
+#endif
+#if !defined(WIN32) && !defined(MS_WINDOWS)
+  #ifndef __stdcall
+    #define __stdcall
+  #endif
+  #ifndef __cdecl
+    #define __cdecl
+  #endif
+  #ifndef __fastcall
+    #define __fastcall
+  #endif
+#endif
+#ifndef DL_IMPORT
+  #define DL_IMPORT(t) t
+#endif
+#ifndef DL_EXPORT
+  #define DL_EXPORT(t) t
+#endif
+#ifndef PY_LONG_LONG
+  #define PY_LONG_LONG LONG_LONG
+#endif
+#ifndef Py_HUGE_VAL
+  #define Py_HUGE_VAL HUGE_VAL
+#endif
+#ifdef PYPY_VERSION
+#define CYTHON_COMPILING_IN_PYPY 1
+#define CYTHON_COMPILING_IN_CPYTHON 0
+#else
+#define CYTHON_COMPILING_IN_PYPY 0
+#define CYTHON_COMPILING_IN_CPYTHON 1
+#endif
+#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600
+#define Py_OptimizeFlag 0
+#endif
+#if PY_VERSION_HEX < 0x02050000
+  typedef int Py_ssize_t;
+  #define PY_SSIZE_T_MAX INT_MAX
+  #define PY_SSIZE_T_MIN INT_MIN
+  #define PY_FORMAT_SIZE_T ""
+  #define CYTHON_FORMAT_SSIZE_T ""
+  #define PyInt_FromSsize_t(z) PyInt_FromLong(z)
+  #define PyInt_AsSsize_t(o)   __Pyx_PyInt_As_int(o)
+  #define PyNumber_Index(o)    ((PyNumber_Check(o) && !PyFloat_Check(o)) ? PyNumber_Int(o) : \
+                                (PyErr_Format(PyExc_TypeError, \
+                                              "expected index value, got %.200s", Py_TYPE(o)->tp_name), \
+                                 (PyObject*)0))
+  #define __Pyx_PyIndex_Check(o) (PyNumber_Check(o) && !PyFloat_Check(o) && \
+                                  !PyComplex_Check(o))
+  #define PyIndex_Check __Pyx_PyIndex_Check
+  #define PyErr_WarnEx(category, message, stacklevel) PyErr_Warn(category, message)
+  #define __PYX_BUILD_PY_SSIZE_T "i"
+#else
+  #define __PYX_BUILD_PY_SSIZE_T "n"
+  #define CYTHON_FORMAT_SSIZE_T "z"
+  #define __Pyx_PyIndex_Check PyIndex_Check
+#endif
+#if PY_VERSION_HEX < 0x02060000
+  #define Py_REFCNT(ob) (((PyObject*)(ob))->ob_refcnt)
+  #define Py_TYPE(ob)   (((PyObject*)(ob))->ob_type)
+  #define Py_SIZE(ob)   (((PyVarObject*)(ob))->ob_size)
+  #define PyVarObject_HEAD_INIT(type, size) \
+          PyObject_HEAD_INIT(type) size,
+  #define PyType_Modified(t)
+  typedef struct {
+     void *buf;
+     PyObject *obj;
+     Py_ssize_t len;
+     Py_ssize_t itemsize;
+     int readonly;
+     int ndim;
+     char *format;
+     Py_ssize_t *shape;
+     Py_ssize_t *strides;
+     Py_ssize_t *suboffsets;
+     void *internal;
+  } Py_buffer;
+  #define PyBUF_SIMPLE 0
+  #define PyBUF_WRITABLE 0x0001
+  #define PyBUF_FORMAT 0x0004
+  #define PyBUF_ND 0x0008
+  #define PyBUF_STRIDES (0x0010 | PyBUF_ND)
+  #define PyBUF_C_CONTIGUOUS (0x0020 | PyBUF_STRIDES)
+  #define PyBUF_F_CONTIGUOUS (0x0040 | PyBUF_STRIDES)
+  #define PyBUF_ANY_CONTIGUOUS (0x0080 | PyBUF_STRIDES)
+  #define PyBUF_INDIRECT (0x0100 | PyBUF_STRIDES)
+  #define PyBUF_RECORDS (PyBUF_STRIDES | PyBUF_FORMAT | PyBUF_WRITABLE)
+  #define PyBUF_FULL (PyBUF_INDIRECT | PyBUF_FORMAT | PyBUF_WRITABLE)
+  typedef int (*getbufferproc)(PyObject *, Py_buffer *, int);
+  typedef void (*releasebufferproc)(PyObject *, Py_buffer *);
+#endif
+#if PY_MAJOR_VERSION < 3
+  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
+  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
+          PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
+  #define __Pyx_DefaultClassType PyClass_Type
+#else
+  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
+  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
+          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
+  #define __Pyx_DefaultClassType PyType_Type
+#endif
+#if PY_VERSION_HEX < 0x02060000
+  #define PyUnicode_FromString(s) PyUnicode_Decode(s, strlen(s), "UTF-8", "strict")
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define Py_TPFLAGS_CHECKTYPES 0
+  #define Py_TPFLAGS_HAVE_INDEX 0
+#endif
+#if (PY_VERSION_HEX < 0x02060000) || (PY_MAJOR_VERSION >= 3)
+  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
+#endif
+#if PY_VERSION_HEX < 0x02060000
+  #define Py_TPFLAGS_HAVE_VERSION_TAG 0
+#endif
+#if PY_VERSION_HEX < 0x02060000 && !defined(Py_TPFLAGS_IS_ABSTRACT)
+  #define Py_TPFLAGS_IS_ABSTRACT 0
+#endif
+#if PY_VERSION_HEX < 0x030400a1 && !defined(Py_TPFLAGS_HAVE_FINALIZE)
+  #define Py_TPFLAGS_HAVE_FINALIZE 0
+#endif
+#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
+  #define CYTHON_PEP393_ENABLED 1
+  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ? \
+                                              0 : _PyUnicode_Ready((PyObject *)(op)))
+  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
+  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
+  #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
+  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
+  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
+#else
+  #define CYTHON_PEP393_ENABLED 0
+  #define __Pyx_PyUnicode_READY(op)       (0)
+  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
+  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
+  #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
+  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
+  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
+#endif
+#if CYTHON_COMPILING_IN_PYPY
+  #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
+  #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
+#else
+  #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
+  #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ? \
+      PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
+#endif
+#define __Pyx_PyString_FormatSafe(a, b)  ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
+#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
+#if PY_MAJOR_VERSION >= 3
+  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
+#else
+  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define PyBaseString_Type            PyUnicode_Type
+  #define PyStringObject               PyUnicodeObject
+  #define PyString_Type                PyUnicode_Type
+  #define PyString_Check               PyUnicode_Check
+  #define PyString_CheckExact          PyUnicode_CheckExact
+#endif
+#if PY_VERSION_HEX < 0x02060000
+  #define PyBytesObject                PyStringObject
+  #define PyBytes_Type                 PyString_Type
+  #define PyBytes_Check                PyString_Check
+  #define PyBytes_CheckExact           PyString_CheckExact
+  #define PyBytes_FromString           PyString_FromString
+  #define PyBytes_FromStringAndSize    PyString_FromStringAndSize
+  #define PyBytes_FromFormat           PyString_FromFormat
+  #define PyBytes_DecodeEscape         PyString_DecodeEscape
+  #define PyBytes_AsString             PyString_AsString
+  #define PyBytes_AsStringAndSize      PyString_AsStringAndSize
+  #define PyBytes_Size                 PyString_Size
+  #define PyBytes_AS_STRING            PyString_AS_STRING
+  #define PyBytes_GET_SIZE             PyString_GET_SIZE
+  #define PyBytes_Repr                 PyString_Repr
+  #define PyBytes_Concat               PyString_Concat
+  #define PyBytes_ConcatAndDel         PyString_ConcatAndDel
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
+  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
+#else
+  #define __Pyx_PyBaseString_Check(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj) || \
+                                         PyString_Check(obj) || PyUnicode_Check(obj))
+  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
+#endif
+#if PY_VERSION_HEX < 0x02060000
+  #define PySet_Check(obj)             PyObject_TypeCheck(obj, &PySet_Type)
+  #define PyFrozenSet_Check(obj)       PyObject_TypeCheck(obj, &PyFrozenSet_Type)
+#endif
+#ifndef PySet_CheckExact
+  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
+#endif
+#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
+#if PY_MAJOR_VERSION >= 3
+  #define PyIntObject                  PyLongObject
+  #define PyInt_Type                   PyLong_Type
+  #define PyInt_Check(op)              PyLong_Check(op)
+  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
+  #define PyInt_FromString             PyLong_FromString
+  #define PyInt_FromUnicode            PyLong_FromUnicode
+  #define PyInt_FromLong               PyLong_FromLong
+  #define PyInt_FromSize_t             PyLong_FromSize_t
+  #define PyInt_FromSsize_t            PyLong_FromSsize_t
+  #define PyInt_AsLong                 PyLong_AsLong
+  #define PyInt_AS_LONG                PyLong_AS_LONG
+  #define PyInt_AsSsize_t              PyLong_AsSsize_t
+  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
+  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
+  #define PyNumber_Int                 PyNumber_Long
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define PyBoolObject                 PyLongObject
+#endif
+#if PY_VERSION_HEX < 0x030200A4
+  typedef long Py_hash_t;
+  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
+  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
+#else
+  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
+  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
+#endif
+#if (PY_MAJOR_VERSION < 3) || (PY_VERSION_HEX >= 0x03010300)
+  #define __Pyx_PySequence_GetSlice(obj, a, b) PySequence_GetSlice(obj, a, b)
+  #define __Pyx_PySequence_SetSlice(obj, a, b, value) PySequence_SetSlice(obj, a, b, value)
+  #define __Pyx_PySequence_DelSlice(obj, a, b) PySequence_DelSlice(obj, a, b)
+#else
+  #define __Pyx_PySequence_GetSlice(obj, a, b) (unlikely(!(obj)) ? \
+        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), (PyObject*)0) : \
+        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_GetSlice(obj, a, b)) : \
+            (PyErr_Format(PyExc_TypeError, "'%.200s' object is unsliceable", (obj)->ob_type->tp_name), (PyObject*)0)))
+  #define __Pyx_PySequence_SetSlice(obj, a, b, value) (unlikely(!(obj)) ? \
+        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
+        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_SetSlice(obj, a, b, value)) : \
+            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice assignment", (obj)->ob_type->tp_name), -1)))
+  #define __Pyx_PySequence_DelSlice(obj, a, b) (unlikely(!(obj)) ? \
+        (PyErr_SetString(PyExc_SystemError, "null argument to internal routine"), -1) : \
+        (likely((obj)->ob_type->tp_as_mapping) ? (PySequence_DelSlice(obj, a, b)) : \
+            (PyErr_Format(PyExc_TypeError, "'%.200s' object doesn't support slice deletion", (obj)->ob_type->tp_name), -1)))
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
+#endif
+#if PY_VERSION_HEX < 0x02050000
+  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),((char *)(n)))
+  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),((char *)(n)),(a))
+  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),((char *)(n)))
+#else
+  #define __Pyx_GetAttrString(o,n)   PyObject_GetAttrString((o),(n))
+  #define __Pyx_SetAttrString(o,n,a) PyObject_SetAttrString((o),(n),(a))
+  #define __Pyx_DelAttrString(o,n)   PyObject_DelAttrString((o),(n))
+#endif
+#if PY_VERSION_HEX < 0x02050000
+  #define __Pyx_NAMESTR(n) ((char *)(n))
+  #define __Pyx_DOCSTR(n)  ((char *)(n))
+#else
+  #define __Pyx_NAMESTR(n) (n)
+  #define __Pyx_DOCSTR(n)  (n)
+#endif
+#ifndef CYTHON_INLINE
+  #if defined(__GNUC__)
+    #define CYTHON_INLINE __inline__
+  #elif defined(_MSC_VER)
+    #define CYTHON_INLINE __inline
+  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+    #define CYTHON_INLINE inline
+  #else
+    #define CYTHON_INLINE
+  #endif
+#endif
+#ifndef CYTHON_RESTRICT
+  #if defined(__GNUC__)
+    #define CYTHON_RESTRICT __restrict__
+  #elif defined(_MSC_VER) && _MSC_VER >= 1400
+    #define CYTHON_RESTRICT __restrict
+  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+    #define CYTHON_RESTRICT restrict
+  #else
+    #define CYTHON_RESTRICT
+  #endif
+#endif
+#ifdef NAN
+#define __PYX_NAN() ((float) NAN)
+#else
+static CYTHON_INLINE float __PYX_NAN() {
+  /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and
+   a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is
+   a quiet NaN. */
+  float value;
+  memset(&value, 0xFF, sizeof(value));
+  return value;
+}
+#endif
+#ifdef __cplusplus
+template<typename T>
+void __Pyx_call_destructor(T* x) {
+    x->~T();
+}
+#endif
+
+
+#if PY_MAJOR_VERSION >= 3
+  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
+  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
+#else
+  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_Divide(x,y)
+  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceDivide(x,y)
+#endif
+
+#ifndef __PYX_EXTERN_C
+  #ifdef __cplusplus
+    #define __PYX_EXTERN_C extern "C"
+  #else
+    #define __PYX_EXTERN_C extern
+  #endif
+#endif
+
+#if defined(WIN32) || defined(MS_WINDOWS)
+#define _USE_MATH_DEFINES
+#endif
+#include <math.h>
+#define __PYX_HAVE__cutadapt___qualtrim
+#define __PYX_HAVE_API__cutadapt___qualtrim
+#ifdef _OPENMP
+#include <omp.h>
+#endif /* _OPENMP */
+
+#ifdef PYREX_WITHOUT_ASSERTIONS
+#define CYTHON_WITHOUT_ASSERTIONS
+#endif
+
+#ifndef CYTHON_UNUSED
+# if defined(__GNUC__)
+#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
+#     define CYTHON_UNUSED __attribute__ ((__unused__))
+#   else
+#     define CYTHON_UNUSED
+#   endif
+# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
+#   define CYTHON_UNUSED __attribute__ ((__unused__))
+# else
+#   define CYTHON_UNUSED
+# endif
+#endif
+typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding;
+                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry; /*proto*/
+
+#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
+#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
+#define __PYX_DEFAULT_STRING_ENCODING ""
+#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
+#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
+#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (    \
+    (sizeof(type) < sizeof(Py_ssize_t))  ||             \
+    (sizeof(type) > sizeof(Py_ssize_t) &&               \
+          likely(v < (type)PY_SSIZE_T_MAX ||            \
+                 v == (type)PY_SSIZE_T_MAX)  &&         \
+          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||       \
+                                v == (type)PY_SSIZE_T_MIN)))  ||  \
+    (sizeof(type) == sizeof(Py_ssize_t) &&              \
+          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||        \
+                               v == (type)PY_SSIZE_T_MAX)))  )
+static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
+static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
+#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
+#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
+#define __Pyx_PyBytes_FromString        PyBytes_FromString
+#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
+static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
+#if PY_MAJOR_VERSION < 3
+    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
+    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
+#else
+    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
+    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
+#endif
+#define __Pyx_PyObject_AsSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
+#define __Pyx_PyObject_AsUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
+#define __Pyx_PyObject_FromUString(s)  __Pyx_PyObject_FromString((const char*)s)
+#define __Pyx_PyBytes_FromUString(s)   __Pyx_PyBytes_FromString((const char*)s)
+#define __Pyx_PyByteArray_FromUString(s)   __Pyx_PyByteArray_FromString((const char*)s)
+#define __Pyx_PyStr_FromUString(s)     __Pyx_PyStr_FromString((const char*)s)
+#define __Pyx_PyUnicode_FromUString(s) __Pyx_PyUnicode_FromString((const char*)s)
+#if PY_MAJOR_VERSION < 3
+static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
+{
+    const Py_UNICODE *u_end = u;
+    while (*u_end++) ;
+    return (size_t)(u_end - u - 1);
+}
+#else
+#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
+#endif
+#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
+#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
+#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
+#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
+#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
+static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
+static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
+static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
+static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
+#if CYTHON_COMPILING_IN_CPYTHON
+#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
+#else
+#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
+#endif
+#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
+#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
+static int __Pyx_sys_getdefaultencoding_not_ascii;
+static int __Pyx_init_sys_getdefaultencoding_params(void) {
+    PyObject* sys;
+    PyObject* default_encoding = NULL;
+    PyObject* ascii_chars_u = NULL;
+    PyObject* ascii_chars_b = NULL;
+    const char* default_encoding_c;
+    sys = PyImport_ImportModule("sys");
+    if (!sys) goto bad;
+    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
+    Py_DECREF(sys);
+    if (!default_encoding) goto bad;
+    default_encoding_c = PyBytes_AsString(default_encoding);
+    if (!default_encoding_c) goto bad;
+    if (strcmp(default_encoding_c, "ascii") == 0) {
+        __Pyx_sys_getdefaultencoding_not_ascii = 0;
+    } else {
+        char ascii_chars[128];
+        int c;
+        for (c = 0; c < 128; c++) {
+            ascii_chars[c] = c;
+        }
+        __Pyx_sys_getdefaultencoding_not_ascii = 1;
+        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
+        if (!ascii_chars_u) goto bad;
+        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
+        if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
+            PyErr_Format(
+                PyExc_ValueError,
+                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
+                default_encoding_c);
+            goto bad;
+        }
+        Py_DECREF(ascii_chars_u);
+        Py_DECREF(ascii_chars_b);
+    }
+    Py_DECREF(default_encoding);
+    return 0;
+bad:
+    Py_XDECREF(default_encoding);
+    Py_XDECREF(ascii_chars_u);
+    Py_XDECREF(ascii_chars_b);
+    return -1;
+}
+#endif
+#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
+#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
+#else
+#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
+#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
+static char* __PYX_DEFAULT_STRING_ENCODING;
+static int __Pyx_init_sys_getdefaultencoding_params(void) {
+    PyObject* sys;
+    PyObject* default_encoding = NULL;
+    char* default_encoding_c;
+    sys = PyImport_ImportModule("sys");
+    if (!sys) goto bad;
+    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
+    Py_DECREF(sys);
+    if (!default_encoding) goto bad;
+    default_encoding_c = PyBytes_AsString(default_encoding);
+    if (!default_encoding_c) goto bad;
+    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
+    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
+    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
+    Py_DECREF(default_encoding);
+    return 0;
+bad:
+    Py_XDECREF(default_encoding);
+    return -1;
+}
+#endif
+#endif
+
+
+/* Test for GCC > 2.95 */
+#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
+  #define likely(x)   __builtin_expect(!!(x), 1)
+  #define unlikely(x) __builtin_expect(!!(x), 0)
+#else /* !__GNUC__ or GCC < 2.95 */
+  #define likely(x)   (x)
+  #define unlikely(x) (x)
+#endif /* __GNUC__ */
+
+static PyObject *__pyx_m;
+static PyObject *__pyx_d;
+static PyObject *__pyx_b;
+static PyObject *__pyx_empty_tuple;
+static PyObject *__pyx_empty_bytes;
+static int __pyx_lineno;
+static int __pyx_clineno = 0;
+static const char * __pyx_cfilenm= __FILE__;
+static const char *__pyx_filename;
+
+
+static const char *__pyx_f[] = {
+  "_qualtrim.pyx",
+};
+
+/*--- Type declarations ---*/
+#ifndef CYTHON_REFNANNY
+  #define CYTHON_REFNANNY 0
+#endif
+#if CYTHON_REFNANNY
+  typedef struct {
+    void (*INCREF)(void*, PyObject*, int);
+    void (*DECREF)(void*, PyObject*, int);
+    void (*GOTREF)(void*, PyObject*, int);
+    void (*GIVEREF)(void*, PyObject*, int);
+    void* (*SetupContext)(const char*, int, const char*);
+    void (*FinishContext)(void**);
+  } __Pyx_RefNannyAPIStruct;
+  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
+  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname); /*proto*/
+  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
+#ifdef WITH_THREAD
+  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
+          if (acquire_gil) { \
+              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
+              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
+              PyGILState_Release(__pyx_gilstate_save); \
+          } else { \
+              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
+          }
+#else
+  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
+          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
+#endif
+  #define __Pyx_RefNannyFinishContext() \
+          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
+  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
+  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
+  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
+  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
+#else
+  #define __Pyx_RefNannyDeclarations
+  #define __Pyx_RefNannySetupContext(name, acquire_gil)
+  #define __Pyx_RefNannyFinishContext()
+  #define __Pyx_INCREF(r) Py_INCREF(r)
+  #define __Pyx_DECREF(r) Py_DECREF(r)
+  #define __Pyx_GOTREF(r)
+  #define __Pyx_GIVEREF(r)
+  #define __Pyx_XINCREF(r) Py_XINCREF(r)
+  #define __Pyx_XDECREF(r) Py_XDECREF(r)
+  #define __Pyx_XGOTREF(r)
+  #define __Pyx_XGIVEREF(r)
+#endif /* CYTHON_REFNANNY */
+#define __Pyx_XDECREF_SET(r, v) do {                            \
+        PyObject *tmp = (PyObject *) r;                         \
+        r = v; __Pyx_XDECREF(tmp);                              \
+    } while (0)
+#define __Pyx_DECREF_SET(r, v) do {                             \
+        PyObject *tmp = (PyObject *) r;                         \
+        r = v; __Pyx_DECREF(tmp);                               \
+    } while (0)
+#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
+#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
+
+#if CYTHON_COMPILING_IN_CPYTHON
+static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
+    PyTypeObject* tp = Py_TYPE(obj);
+    if (likely(tp->tp_getattro))
+        return tp->tp_getattro(obj, attr_name);
+#if PY_MAJOR_VERSION < 3
+    if (likely(tp->tp_getattr))
+        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
+#endif
+    return PyObject_GetAttr(obj, attr_name);
+}
+#else
+#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
+#endif
+
+static PyObject *__Pyx_GetBuiltinName(PyObject *name); /*proto*/
+
+static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
+    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found); /*proto*/
+
+static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name); /*proto*/
+
+static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \
+    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \
+    const char* function_name); /*proto*/
+
+static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
+    const char *name, int exact); /*proto*/
+
+#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
+    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
+    __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) : \
+    (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) : \
+               __Pyx_GetItemInt_Generic(o, to_py_func(i))))
+#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
+    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
+    __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
+    (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
+                                                              int wraparound, int boundscheck);
+#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
+    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
+    __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
+    (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
+                                                              int wraparound, int boundscheck);
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
+                                                     int is_list, int wraparound, int boundscheck);
+
+#if CYTHON_COMPILING_IN_CPYTHON
+static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw); /*proto*/
+#else
+#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
+#endif
+
+static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
+
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value);
+
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
+
+static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
+
+static int __Pyx_check_binary_version(void);
+
+typedef struct {
+    int code_line;
+    PyCodeObject* code_object;
+} __Pyx_CodeObjectCacheEntry;
+struct __Pyx_CodeObjectCache {
+    int count;
+    int max_count;
+    __Pyx_CodeObjectCacheEntry* entries;
+};
+static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
+static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
+static PyCodeObject *__pyx_find_code_object(int code_line);
+static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
+
+static void __Pyx_AddTraceback(const char *funcname, int c_line,
+                               int py_line, const char *filename); /*proto*/
+
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t); /*proto*/
+
+
+/* Module declarations from 'cutadapt._qualtrim' */
+#define __Pyx_MODULE_NAME "cutadapt._qualtrim"
+int __pyx_module_is_main_cutadapt___qualtrim = 0;
+
+/* Implementation of 'cutadapt._qualtrim' */
+static PyObject *__pyx_builtin_range;
+static PyObject *__pyx_builtin_ord;
+static PyObject *__pyx_builtin_reversed;
+static PyObject *__pyx_builtin_xrange;
+static PyObject *__pyx_pf_8cutadapt_9_qualtrim_quality_trim_index(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_qualities, int __pyx_v_cutoff_front, int __pyx_v_cutoff_back, int __pyx_v_base); /* proto */
+static char __pyx_k_i[] = "i";
+static char __pyx_k_s[] = "s";
+static char __pyx_k_ord[] = "ord";
+static char __pyx_k_base[] = "base";
+static char __pyx_k_main[] = "__main__";
+static char __pyx_k_stop[] = "stop";
+static char __pyx_k_test[] = "__test__";
+static char __pyx_k_range[] = "range";
+static char __pyx_k_start[] = "start";
+static char __pyx_k_xrange[] = "xrange";
+static char __pyx_k_max_qual[] = "max_qual";
+static char __pyx_k_reversed[] = "reversed";
+static char __pyx_k_qualities[] = "qualities";
+static char __pyx_k_cutoff_back[] = "cutoff_back";
+static char __pyx_k_cutoff_front[] = "cutoff_front";
+static char __pyx_k_Quality_trimming[] = "\nQuality trimming.\n";
+static char __pyx_k_cutadapt__qualtrim[] = "cutadapt._qualtrim";
+static char __pyx_k_quality_trim_index[] = "quality_trim_index";
+static char __pyx_k_home_marcel_scm_cutadapt_cutada[] = "/home/marcel/scm/cutadapt/cutadapt/_qualtrim.pyx";
+static PyObject *__pyx_n_s_base;
+static PyObject *__pyx_n_s_cutadapt__qualtrim;
+static PyObject *__pyx_n_s_cutoff_back;
+static PyObject *__pyx_n_s_cutoff_front;
+static PyObject *__pyx_kp_s_home_marcel_scm_cutadapt_cutada;
+static PyObject *__pyx_n_s_i;
+static PyObject *__pyx_n_s_main;
+static PyObject *__pyx_n_s_max_qual;
+static PyObject *__pyx_n_s_ord;
+static PyObject *__pyx_n_s_qualities;
+static PyObject *__pyx_n_s_quality_trim_index;
+static PyObject *__pyx_n_s_range;
+static PyObject *__pyx_n_s_reversed;
+static PyObject *__pyx_n_s_s;
+static PyObject *__pyx_n_s_start;
+static PyObject *__pyx_n_s_stop;
+static PyObject *__pyx_n_s_test;
+static PyObject *__pyx_n_s_xrange;
+static PyObject *__pyx_tuple_;
+static PyObject *__pyx_codeobj__2;
+
+/* "cutadapt/_qualtrim.pyx":6
+ * """
+ * 
+ * def quality_trim_index(str qualities, int cutoff_front, int cutoff_back, int base=33):             # <<<<<<<<<<<<<<
+ * 	"""
+ * 	Find the positions at which to trim low-quality ends from a nucleotide sequence.
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_8cutadapt_9_qualtrim_1quality_trim_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_8cutadapt_9_qualtrim_quality_trim_index[] = "\n\tFind the positions at which to trim low-quality ends from a nucleotide sequence.\n\tReturn tuple (start, stop) that indicates the good-quality segment.\n\n\tQualities are assumed to be ASCII-encoded as chr(qual + base).\n\n\tThe algorithm is the same as the one used by BWA within the function\n\t'bwa_trim_read':\n\t- Subtract the cutoff value from all qualities.\n\t- Compute partial sums from all indices to the end of [...]
+static PyMethodDef __pyx_mdef_8cutadapt_9_qualtrim_1quality_trim_index = {__Pyx_NAMESTR("quality_trim_index"), (PyCFunction)__pyx_pw_8cutadapt_9_qualtrim_1quality_trim_index, METH_VARARGS|METH_KEYWORDS, __Pyx_DOCSTR(__pyx_doc_8cutadapt_9_qualtrim_quality_trim_index)};
+static PyObject *__pyx_pw_8cutadapt_9_qualtrim_1quality_trim_index(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_qualities = 0;
+  int __pyx_v_cutoff_front;
+  int __pyx_v_cutoff_back;
+  int __pyx_v_base;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("quality_trim_index (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_qualities,&__pyx_n_s_cutoff_front,&__pyx_n_s_cutoff_back,&__pyx_n_s_base,0};
+    PyObject* values[4] = {0,0,0,0};
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_qualities)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+        case  1:
+        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_cutoff_front)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("quality_trim_index", 0, 3, 4, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        }
+        case  2:
+        if (likely((values[2] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_cutoff_back)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("quality_trim_index", 0, 3, 4, 2); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        }
+        case  3:
+        if (kw_args > 0) {
+          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_base);
+          if (value) { values[3] = value; kw_args--; }
+        }
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "quality_trim_index") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    } else {
+      switch (PyTuple_GET_SIZE(__pyx_args)) {
+        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+        values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+    }
+    __pyx_v_qualities = ((PyObject*)values[0]);
+    __pyx_v_cutoff_front = __Pyx_PyInt_As_int(values[1]); if (unlikely((__pyx_v_cutoff_front == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    __pyx_v_cutoff_back = __Pyx_PyInt_As_int(values[2]); if (unlikely((__pyx_v_cutoff_back == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    if (values[3]) {
+      __pyx_v_base = __Pyx_PyInt_As_int(values[3]); if (unlikely((__pyx_v_base == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    } else {
+      __pyx_v_base = ((int)33);
+    }
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("quality_trim_index", 0, 3, 4, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cutadapt._qualtrim.quality_trim_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_qualities), (&PyString_Type), 1, "qualities", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_r = __pyx_pf_8cutadapt_9_qualtrim_quality_trim_index(__pyx_self, __pyx_v_qualities, __pyx_v_cutoff_front, __pyx_v_cutoff_back, __pyx_v_base);
+
+  /* function exit code */
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_8cutadapt_9_qualtrim_quality_trim_index(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_qualities, int __pyx_v_cutoff_front, int __pyx_v_cutoff_back, int __pyx_v_base) {
+  int __pyx_v_s;
+  int __pyx_v_max_qual;
+  int __pyx_v_stop;
+  int __pyx_v_start;
+  int __pyx_v_i;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  Py_ssize_t __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  int __pyx_t_8;
+  int __pyx_t_9;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("quality_trim_index", 0);
+
+  /* "cutadapt/_qualtrim.pyx":21
+ * 	cdef int s
+ * 	cdef int max_qual
+ * 	cdef int stop = len(qualities)             # <<<<<<<<<<<<<<
+ * 	cdef int start = 0
+ * 	cdef int i
+ */
+  __pyx_t_1 = PyObject_Length(__pyx_v_qualities); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_stop = __pyx_t_1;
+
+  /* "cutadapt/_qualtrim.pyx":22
+ * 	cdef int max_qual
+ * 	cdef int stop = len(qualities)
+ * 	cdef int start = 0             # <<<<<<<<<<<<<<
+ * 	cdef int i
+ * 
+ */
+  __pyx_v_start = 0;
+
+  /* "cutadapt/_qualtrim.pyx":26
+ * 
+ * 	# find trim position for 5' end
+ * 	s = 0             # <<<<<<<<<<<<<<
+ * 	max_qual = 0
+ * 	for i in range(len(qualities)):
+ */
+  __pyx_v_s = 0;
+
+  /* "cutadapt/_qualtrim.pyx":27
+ * 	# find trim position for 5' end
+ * 	s = 0
+ * 	max_qual = 0             # <<<<<<<<<<<<<<
+ * 	for i in range(len(qualities)):
+ * 		s += cutoff_front - (ord(qualities[i]) - base)
+ */
+  __pyx_v_max_qual = 0;
+
+  /* "cutadapt/_qualtrim.pyx":28
+ * 	s = 0
+ * 	max_qual = 0
+ * 	for i in range(len(qualities)):             # <<<<<<<<<<<<<<
+ * 		s += cutoff_front - (ord(qualities[i]) - base)
+ * 		if s < 0:
+ */
+  __pyx_t_1 = PyObject_Length(__pyx_v_qualities); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  for (__pyx_t_2 = 0; __pyx_t_2 < __pyx_t_1; __pyx_t_2+=1) {
+    __pyx_v_i = __pyx_t_2;
+
+    /* "cutadapt/_qualtrim.pyx":29
+ * 	max_qual = 0
+ * 	for i in range(len(qualities)):
+ * 		s += cutoff_front - (ord(qualities[i]) - base)             # <<<<<<<<<<<<<<
+ * 		if s < 0:
+ * 			break
+ */
+    __pyx_t_3 = __Pyx_PyInt_From_int(__pyx_v_s); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_cutoff_front); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = __Pyx_GetItemInt(__pyx_v_qualities, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(__pyx_t_5 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = PyTuple_New(1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5);
+    __Pyx_GIVEREF(__pyx_t_5);
+    __pyx_t_5 = 0;
+    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_builtin_ord, __pyx_t_6, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_base); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_7 = PyNumber_Subtract(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __pyx_t_6 = PyNumber_Subtract(__pyx_t_4, __pyx_t_7); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __pyx_t_7 = PyNumber_InPlaceAdd(__pyx_t_3, __pyx_t_6); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_7); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __pyx_v_s = __pyx_t_8;
+
+    /* "cutadapt/_qualtrim.pyx":30
+ * 	for i in range(len(qualities)):
+ * 		s += cutoff_front - (ord(qualities[i]) - base)
+ * 		if s < 0:             # <<<<<<<<<<<<<<
+ * 			break
+ * 		if s > max_qual:
+ */
+    __pyx_t_9 = ((__pyx_v_s < 0) != 0);
+    if (__pyx_t_9) {
+
+      /* "cutadapt/_qualtrim.pyx":31
+ * 		s += cutoff_front - (ord(qualities[i]) - base)
+ * 		if s < 0:
+ * 			break             # <<<<<<<<<<<<<<
+ * 		if s > max_qual:
+ * 			max_qual = s
+ */
+      goto __pyx_L4_break;
+    }
+
+    /* "cutadapt/_qualtrim.pyx":32
+ * 		if s < 0:
+ * 			break
+ * 		if s > max_qual:             # <<<<<<<<<<<<<<
+ * 			max_qual = s
+ * 			start = i + 1
+ */
+    __pyx_t_9 = ((__pyx_v_s > __pyx_v_max_qual) != 0);
+    if (__pyx_t_9) {
+
+      /* "cutadapt/_qualtrim.pyx":33
+ * 			break
+ * 		if s > max_qual:
+ * 			max_qual = s             # <<<<<<<<<<<<<<
+ * 			start = i + 1
+ * 
+ */
+      __pyx_v_max_qual = __pyx_v_s;
+
+      /* "cutadapt/_qualtrim.pyx":34
+ * 		if s > max_qual:
+ * 			max_qual = s
+ * 			start = i + 1             # <<<<<<<<<<<<<<
+ * 
+ * 	# same for 3' end
+ */
+      __pyx_v_start = (__pyx_v_i + 1);
+      goto __pyx_L6;
+    }
+    __pyx_L6:;
+  }
+  __pyx_L4_break:;
+
+  /* "cutadapt/_qualtrim.pyx":37
+ * 
+ * 	# same for 3' end
+ * 	max_qual = 0             # <<<<<<<<<<<<<<
+ * 	s = 0
+ * 	for i in reversed(xrange(len(qualities))):
+ */
+  __pyx_v_max_qual = 0;
+
+  /* "cutadapt/_qualtrim.pyx":38
+ * 	# same for 3' end
+ * 	max_qual = 0
+ * 	s = 0             # <<<<<<<<<<<<<<
+ * 	for i in reversed(xrange(len(qualities))):
+ * 		s += cutoff_back - (ord(qualities[i]) - base)
+ */
+  __pyx_v_s = 0;
+
+  /* "cutadapt/_qualtrim.pyx":39
+ * 	max_qual = 0
+ * 	s = 0
+ * 	for i in reversed(xrange(len(qualities))):             # <<<<<<<<<<<<<<
+ * 		s += cutoff_back - (ord(qualities[i]) - base)
+ * 		if s < 0:
+ */
+  __pyx_t_1 = PyObject_Length(__pyx_v_qualities); if (unlikely(__pyx_t_1 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  for (__pyx_t_2 = __pyx_t_1-1; __pyx_t_2 >= 0; __pyx_t_2-=1) {
+    __pyx_v_i = __pyx_t_2;
+
+    /* "cutadapt/_qualtrim.pyx":40
+ * 	s = 0
+ * 	for i in reversed(xrange(len(qualities))):
+ * 		s += cutoff_back - (ord(qualities[i]) - base)             # <<<<<<<<<<<<<<
+ * 		if s < 0:
+ * 			break
+ */
+    __pyx_t_7 = __Pyx_PyInt_From_int(__pyx_v_s); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __pyx_t_6 = __Pyx_PyInt_From_int(__pyx_v_cutoff_back); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_3 = __Pyx_GetItemInt(__pyx_v_qualities, __pyx_v_i, int, 1, __Pyx_PyInt_From_int, 0, 1, 1); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_4 = PyTuple_New(1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    PyTuple_SET_ITEM(__pyx_t_4, 0, __pyx_t_3);
+    __Pyx_GIVEREF(__pyx_t_3);
+    __pyx_t_3 = 0;
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_builtin_ord, __pyx_t_4, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_base); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = PyNumber_Subtract(__pyx_t_3, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_4 = PyNumber_Subtract(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_5 = PyNumber_InPlaceAdd(__pyx_t_7, __pyx_t_4); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_8 = __Pyx_PyInt_As_int(__pyx_t_5); if (unlikely((__pyx_t_8 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 40; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_v_s = __pyx_t_8;
+
+    /* "cutadapt/_qualtrim.pyx":41
+ * 	for i in reversed(xrange(len(qualities))):
+ * 		s += cutoff_back - (ord(qualities[i]) - base)
+ * 		if s < 0:             # <<<<<<<<<<<<<<
+ * 			break
+ * 		if s > max_qual:
+ */
+    __pyx_t_9 = ((__pyx_v_s < 0) != 0);
+    if (__pyx_t_9) {
+
+      /* "cutadapt/_qualtrim.pyx":42
+ * 		s += cutoff_back - (ord(qualities[i]) - base)
+ * 		if s < 0:
+ * 			break             # <<<<<<<<<<<<<<
+ * 		if s > max_qual:
+ * 			max_qual = s
+ */
+      goto __pyx_L8_break;
+    }
+
+    /* "cutadapt/_qualtrim.pyx":43
+ * 		if s < 0:
+ * 			break
+ * 		if s > max_qual:             # <<<<<<<<<<<<<<
+ * 			max_qual = s
+ * 			stop = i
+ */
+    __pyx_t_9 = ((__pyx_v_s > __pyx_v_max_qual) != 0);
+    if (__pyx_t_9) {
+
+      /* "cutadapt/_qualtrim.pyx":44
+ * 			break
+ * 		if s > max_qual:
+ * 			max_qual = s             # <<<<<<<<<<<<<<
+ * 			stop = i
+ * 	if start >= stop:
+ */
+      __pyx_v_max_qual = __pyx_v_s;
+
+      /* "cutadapt/_qualtrim.pyx":45
+ * 		if s > max_qual:
+ * 			max_qual = s
+ * 			stop = i             # <<<<<<<<<<<<<<
+ * 	if start >= stop:
+ * 		start, stop = 0, 0
+ */
+      __pyx_v_stop = __pyx_v_i;
+      goto __pyx_L10;
+    }
+    __pyx_L10:;
+  }
+  __pyx_L8_break:;
+
+  /* "cutadapt/_qualtrim.pyx":46
+ * 			max_qual = s
+ * 			stop = i
+ * 	if start >= stop:             # <<<<<<<<<<<<<<
+ * 		start, stop = 0, 0
+ * 	return (start, stop)
+ */
+  __pyx_t_9 = ((__pyx_v_start >= __pyx_v_stop) != 0);
+  if (__pyx_t_9) {
+
+    /* "cutadapt/_qualtrim.pyx":47
+ * 			stop = i
+ * 	if start >= stop:
+ * 		start, stop = 0, 0             # <<<<<<<<<<<<<<
+ * 	return (start, stop)
+ */
+    __pyx_t_2 = 0;
+    __pyx_t_8 = 0;
+    __pyx_v_start = __pyx_t_2;
+    __pyx_v_stop = __pyx_t_8;
+    goto __pyx_L11;
+  }
+  __pyx_L11:;
+
+  /* "cutadapt/_qualtrim.pyx":48
+ * 	if start >= stop:
+ * 		start, stop = 0, 0
+ * 	return (start, stop)             # <<<<<<<<<<<<<<
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_5 = __Pyx_PyInt_From_int(__pyx_v_start); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_4 = __Pyx_PyInt_From_int(__pyx_v_stop); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_7 = PyTuple_New(2); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 48; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_7);
+  PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_5);
+  __Pyx_GIVEREF(__pyx_t_5);
+  PyTuple_SET_ITEM(__pyx_t_7, 1, __pyx_t_4);
+  __Pyx_GIVEREF(__pyx_t_4);
+  __pyx_t_5 = 0;
+  __pyx_t_4 = 0;
+  __pyx_r = __pyx_t_7;
+  __pyx_t_7 = 0;
+  goto __pyx_L0;
+
+  /* "cutadapt/_qualtrim.pyx":6
+ * """
+ * 
+ * def quality_trim_index(str qualities, int cutoff_front, int cutoff_back, int base=33):             # <<<<<<<<<<<<<<
+ * 	"""
+ * 	Find the positions at which to trim low-quality ends from a nucleotide sequence.
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_AddTraceback("cutadapt._qualtrim.quality_trim_index", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyMethodDef __pyx_methods[] = {
+  {0, 0, 0, 0}
+};
+
+#if PY_MAJOR_VERSION >= 3
+static struct PyModuleDef __pyx_moduledef = {
+  #if PY_VERSION_HEX < 0x03020000
+    { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
+  #else
+    PyModuleDef_HEAD_INIT,
+  #endif
+    __Pyx_NAMESTR("_qualtrim"),
+    __Pyx_DOCSTR(__pyx_k_Quality_trimming), /* m_doc */
+    -1, /* m_size */
+    __pyx_methods /* m_methods */,
+    NULL, /* m_reload */
+    NULL, /* m_traverse */
+    NULL, /* m_clear */
+    NULL /* m_free */
+};
+#endif
+
+static __Pyx_StringTabEntry __pyx_string_tab[] = {
+  {&__pyx_n_s_base, __pyx_k_base, sizeof(__pyx_k_base), 0, 0, 1, 1},
+  {&__pyx_n_s_cutadapt__qualtrim, __pyx_k_cutadapt__qualtrim, sizeof(__pyx_k_cutadapt__qualtrim), 0, 0, 1, 1},
+  {&__pyx_n_s_cutoff_back, __pyx_k_cutoff_back, sizeof(__pyx_k_cutoff_back), 0, 0, 1, 1},
+  {&__pyx_n_s_cutoff_front, __pyx_k_cutoff_front, sizeof(__pyx_k_cutoff_front), 0, 0, 1, 1},
+  {&__pyx_kp_s_home_marcel_scm_cutadapt_cutada, __pyx_k_home_marcel_scm_cutadapt_cutada, sizeof(__pyx_k_home_marcel_scm_cutadapt_cutada), 0, 0, 1, 0},
+  {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
+  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
+  {&__pyx_n_s_max_qual, __pyx_k_max_qual, sizeof(__pyx_k_max_qual), 0, 0, 1, 1},
+  {&__pyx_n_s_ord, __pyx_k_ord, sizeof(__pyx_k_ord), 0, 0, 1, 1},
+  {&__pyx_n_s_qualities, __pyx_k_qualities, sizeof(__pyx_k_qualities), 0, 0, 1, 1},
+  {&__pyx_n_s_quality_trim_index, __pyx_k_quality_trim_index, sizeof(__pyx_k_quality_trim_index), 0, 0, 1, 1},
+  {&__pyx_n_s_range, __pyx_k_range, sizeof(__pyx_k_range), 0, 0, 1, 1},
+  {&__pyx_n_s_reversed, __pyx_k_reversed, sizeof(__pyx_k_reversed), 0, 0, 1, 1},
+  {&__pyx_n_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 1},
+  {&__pyx_n_s_start, __pyx_k_start, sizeof(__pyx_k_start), 0, 0, 1, 1},
+  {&__pyx_n_s_stop, __pyx_k_stop, sizeof(__pyx_k_stop), 0, 0, 1, 1},
+  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
+  {&__pyx_n_s_xrange, __pyx_k_xrange, sizeof(__pyx_k_xrange), 0, 0, 1, 1},
+  {0, 0, 0, 0, 0, 0, 0}
+};
+static int __Pyx_InitCachedBuiltins(void) {
+  __pyx_builtin_range = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_range) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 28; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_ord = __Pyx_GetBuiltinName(__pyx_n_s_ord); if (!__pyx_builtin_ord) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 29; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_reversed = __Pyx_GetBuiltinName(__pyx_n_s_reversed); if (!__pyx_builtin_reversed) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #if PY_MAJOR_VERSION >= 3
+  __pyx_builtin_xrange = __Pyx_GetBuiltinName(__pyx_n_s_range); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #else
+  __pyx_builtin_xrange = __Pyx_GetBuiltinName(__pyx_n_s_xrange); if (!__pyx_builtin_xrange) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #endif
+  return 0;
+  __pyx_L1_error:;
+  return -1;
+}
+
+static int __Pyx_InitCachedConstants(void) {
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
+
+  /* "cutadapt/_qualtrim.pyx":6
+ * """
+ * 
+ * def quality_trim_index(str qualities, int cutoff_front, int cutoff_back, int base=33):             # <<<<<<<<<<<<<<
+ * 	"""
+ * 	Find the positions at which to trim low-quality ends from a nucleotide sequence.
+ */
+  __pyx_tuple_ = PyTuple_Pack(9, __pyx_n_s_qualities, __pyx_n_s_cutoff_front, __pyx_n_s_cutoff_back, __pyx_n_s_base, __pyx_n_s_s, __pyx_n_s_max_qual, __pyx_n_s_stop, __pyx_n_s_start, __pyx_n_s_i); if (unlikely(!__pyx_tuple_)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_tuple_);
+  __Pyx_GIVEREF(__pyx_tuple_);
+  __pyx_codeobj__2 = (PyObject*)__Pyx_PyCode_New(4, 0, 9, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple_, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_marcel_scm_cutadapt_cutada, __pyx_n_s_quality_trim_index, 6, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_RefNannyFinishContext();
+  return 0;
+  __pyx_L1_error:;
+  __Pyx_RefNannyFinishContext();
+  return -1;
+}
+
+static int __Pyx_InitGlobals(void) {
+  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  return 0;
+  __pyx_L1_error:;
+  return -1;
+}
+
+#if PY_MAJOR_VERSION < 3
+PyMODINIT_FUNC init_qualtrim(void); /*proto*/
+PyMODINIT_FUNC init_qualtrim(void)
+#else
+PyMODINIT_FUNC PyInit__qualtrim(void); /*proto*/
+PyMODINIT_FUNC PyInit__qualtrim(void)
+#endif
+{
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannyDeclarations
+  #if CYTHON_REFNANNY
+  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
+  if (!__Pyx_RefNanny) {
+      PyErr_Clear();
+      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
+      if (!__Pyx_RefNanny)
+          Py_FatalError("failed to import 'refnanny' module");
+  }
+  #endif
+  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit__qualtrim(void)", 0);
+  if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #ifdef __Pyx_CyFunction_USED
+  if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #endif
+  #ifdef __Pyx_FusedFunction_USED
+  if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #endif
+  #ifdef __Pyx_Generator_USED
+  if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #endif
+  /*--- Library function declarations ---*/
+  /*--- Threads initialization code ---*/
+  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
+  #ifdef WITH_THREAD /* Python build with threading support? */
+  PyEval_InitThreads();
+  #endif
+  #endif
+  /*--- Module creation code ---*/
+  #if PY_MAJOR_VERSION < 3
+  __pyx_m = Py_InitModule4(__Pyx_NAMESTR("_qualtrim"), __pyx_methods, __Pyx_DOCSTR(__pyx_k_Quality_trimming), 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
+  #else
+  __pyx_m = PyModule_Create(&__pyx_moduledef);
+  #endif
+  if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_INCREF(__pyx_d);
+  __pyx_b = PyImport_AddModule(__Pyx_NAMESTR(__Pyx_BUILTIN_MODULE_NAME)); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #if CYTHON_COMPILING_IN_PYPY
+  Py_INCREF(__pyx_b);
+  #endif
+  if (__Pyx_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  /*--- Initialize various global constants etc. ---*/
+  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
+  if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #endif
+  if (__pyx_module_is_main_cutadapt___qualtrim) {
+    if (__Pyx_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  }
+  #if PY_MAJOR_VERSION >= 3
+  {
+    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (!PyDict_GetItemString(modules, "cutadapt._qualtrim")) {
+      if (unlikely(PyDict_SetItemString(modules, "cutadapt._qualtrim", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    }
+  }
+  #endif
+  /*--- Builtin init code ---*/
+  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  /*--- Constants init code ---*/
+  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  /*--- Global init code ---*/
+  /*--- Variable export code ---*/
+  /*--- Function export code ---*/
+  /*--- Type init code ---*/
+  /*--- Type import code ---*/
+  /*--- Variable import code ---*/
+  /*--- Function import code ---*/
+  /*--- Execution code ---*/
+
+  /* "cutadapt/_qualtrim.pyx":6
+ * """
+ * 
+ * def quality_trim_index(str qualities, int cutoff_front, int cutoff_back, int base=33):             # <<<<<<<<<<<<<<
+ * 	"""
+ * 	Find the positions at which to trim low-quality ends from a nucleotide sequence.
+ */
+  __pyx_t_1 = PyCFunction_NewEx(&__pyx_mdef_8cutadapt_9_qualtrim_1quality_trim_index, NULL, __pyx_n_s_cutadapt__qualtrim); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_quality_trim_index, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 6; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "cutadapt/_qualtrim.pyx":1
+ * # kate: syntax Python;             # <<<<<<<<<<<<<<
+ * """
+ * Quality trimming.
+ */
+  __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  if (__pyx_m) {
+    __Pyx_AddTraceback("init cutadapt._qualtrim", __pyx_clineno, __pyx_lineno, __pyx_filename);
+    Py_DECREF(__pyx_m); __pyx_m = 0;
+  } else if (!PyErr_Occurred()) {
+    PyErr_SetString(PyExc_ImportError, "init cutadapt._qualtrim");
+  }
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  #if PY_MAJOR_VERSION < 3
+  return;
+  #else
+  return __pyx_m;
+  #endif
+}
+
+/* Runtime support code */
+#if CYTHON_REFNANNY
+static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
+    PyObject *m = NULL, *p = NULL;
+    void *r = NULL;
+    m = PyImport_ImportModule((char *)modname);
+    if (!m) goto end;
+    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
+    if (!p) goto end;
+    r = PyLong_AsVoidPtr(p);
+end:
+    Py_XDECREF(p);
+    Py_XDECREF(m);
+    return (__Pyx_RefNannyAPIStruct *)r;
+}
+#endif /* CYTHON_REFNANNY */
+
+static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
+    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
+    if (unlikely(!result)) {
+        PyErr_Format(PyExc_NameError,
+#if PY_MAJOR_VERSION >= 3
+            "name '%U' is not defined", name);
+#else
+            "name '%.200s' is not defined", PyString_AS_STRING(name));
+#endif
+    }
+    return result;
+}
+
+static void __Pyx_RaiseArgtupleInvalid(
+    const char* func_name,
+    int exact,
+    Py_ssize_t num_min,
+    Py_ssize_t num_max,
+    Py_ssize_t num_found)
+{
+    Py_ssize_t num_expected;
+    const char *more_or_less;
+    if (num_found < num_min) {
+        num_expected = num_min;
+        more_or_less = "at least";
+    } else {
+        num_expected = num_max;
+        more_or_less = "at most";
+    }
+    if (exact) {
+        more_or_less = "exactly";
+    }
+    PyErr_Format(PyExc_TypeError,
+                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
+                 func_name, more_or_less, num_expected,
+                 (num_expected == 1) ? "" : "s", num_found);
+}
+
+static void __Pyx_RaiseDoubleKeywordsError(
+    const char* func_name,
+    PyObject* kw_name)
+{
+    PyErr_Format(PyExc_TypeError,
+        #if PY_MAJOR_VERSION >= 3
+        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
+        #else
+        "%s() got multiple values for keyword argument '%s'", func_name,
+        PyString_AsString(kw_name));
+        #endif
+}
+
+static int __Pyx_ParseOptionalKeywords(
+    PyObject *kwds,
+    PyObject **argnames[],
+    PyObject *kwds2,
+    PyObject *values[],
+    Py_ssize_t num_pos_args,
+    const char* function_name)
+{
+    PyObject *key = 0, *value = 0;
+    Py_ssize_t pos = 0;
+    PyObject*** name;
+    PyObject*** first_kw_arg = argnames + num_pos_args;
+    while (PyDict_Next(kwds, &pos, &key, &value)) {
+        name = first_kw_arg;
+        while (*name && (**name != key)) name++;
+        if (*name) {
+            values[name-argnames] = value;
+            continue;
+        }
+        name = first_kw_arg;
+        #if PY_MAJOR_VERSION < 3
+        if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
+            while (*name) {
+                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
+                        && _PyString_Eq(**name, key)) {
+                    values[name-argnames] = value;
+                    break;
+                }
+                name++;
+            }
+            if (*name) continue;
+            else {
+                PyObject*** argname = argnames;
+                while (argname != first_kw_arg) {
+                    if ((**argname == key) || (
+                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
+                             && _PyString_Eq(**argname, key))) {
+                        goto arg_passed_twice;
+                    }
+                    argname++;
+                }
+            }
+        } else
+        #endif
+        if (likely(PyUnicode_Check(key))) {
+            while (*name) {
+                int cmp = (**name == key) ? 0 :
+                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
+                    (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
+                #endif
+                    PyUnicode_Compare(**name, key);
+                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
+                if (cmp == 0) {
+                    values[name-argnames] = value;
+                    break;
+                }
+                name++;
+            }
+            if (*name) continue;
+            else {
+                PyObject*** argname = argnames;
+                while (argname != first_kw_arg) {
+                    int cmp = (**argname == key) ? 0 :
+                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
+                        (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
+                    #endif
+                        PyUnicode_Compare(**argname, key);
+                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
+                    if (cmp == 0) goto arg_passed_twice;
+                    argname++;
+                }
+            }
+        } else
+            goto invalid_keyword_type;
+        if (kwds2) {
+            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
+        } else {
+            goto invalid_keyword;
+        }
+    }
+    return 0;
+arg_passed_twice:
+    __Pyx_RaiseDoubleKeywordsError(function_name, key);
+    goto bad;
+invalid_keyword_type:
+    PyErr_Format(PyExc_TypeError,
+        "%.200s() keywords must be strings", function_name);
+    goto bad;
+invalid_keyword:
+    PyErr_Format(PyExc_TypeError,
+    #if PY_MAJOR_VERSION < 3
+        "%.200s() got an unexpected keyword argument '%.200s'",
+        function_name, PyString_AsString(key));
+    #else
+        "%s() got an unexpected keyword argument '%U'",
+        function_name, key);
+    #endif
+bad:
+    return -1;
+}
+
+static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) {
+    PyErr_Format(PyExc_TypeError,
+        "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
+        name, type->tp_name, Py_TYPE(obj)->tp_name);
+}
+static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
+    const char *name, int exact)
+{
+    if (unlikely(!type)) {
+        PyErr_SetString(PyExc_SystemError, "Missing type object");
+        return 0;
+    }
+    if (none_allowed && obj == Py_None) return 1;
+    else if (exact) {
+        if (likely(Py_TYPE(obj) == type)) return 1;
+        #if PY_MAJOR_VERSION == 2
+        else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
+        #endif
+    }
+    else {
+        if (likely(PyObject_TypeCheck(obj, type))) return 1;
+    }
+    __Pyx_RaiseArgumentTypeInvalid(name, obj, type);
+    return 0;
+}
+
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
+    PyObject *r;
+    if (!j) return NULL;
+    r = PyObject_GetItem(o, j);
+    Py_DECREF(j);
+    return r;
+}
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
+                                                              int wraparound, int boundscheck) {
+#if CYTHON_COMPILING_IN_CPYTHON
+    if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o);
+    if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
+        PyObject *r = PyList_GET_ITEM(o, i);
+        Py_INCREF(r);
+        return r;
+    }
+    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
+#else
+    return PySequence_GetItem(o, i);
+#endif
+}
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
+                                                              int wraparound, int boundscheck) {
+#if CYTHON_COMPILING_IN_CPYTHON
+    if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o);
+    if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
+        PyObject *r = PyTuple_GET_ITEM(o, i);
+        Py_INCREF(r);
+        return r;
+    }
+    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
+#else
+    return PySequence_GetItem(o, i);
+#endif
+}
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
+                                                     int is_list, int wraparound, int boundscheck) {
+#if CYTHON_COMPILING_IN_CPYTHON
+    if (is_list || PyList_CheckExact(o)) {
+        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
+        if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
+            PyObject *r = PyList_GET_ITEM(o, n);
+            Py_INCREF(r);
+            return r;
+        }
+    }
+    else if (PyTuple_CheckExact(o)) {
+        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
+        if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
+            PyObject *r = PyTuple_GET_ITEM(o, n);
+            Py_INCREF(r);
+            return r;
+        }
+    } else {
+        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
+        if (likely(m && m->sq_item)) {
+            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
+                Py_ssize_t l = m->sq_length(o);
+                if (likely(l >= 0)) {
+                    i += l;
+                } else {
+                    if (PyErr_ExceptionMatches(PyExc_OverflowError))
+                        PyErr_Clear();
+                    else
+                        return NULL;
+                }
+            }
+            return m->sq_item(o, i);
+        }
+    }
+#else
+    if (is_list || PySequence_Check(o)) {
+        return PySequence_GetItem(o, i);
+    }
+#endif
+    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
+}
+
+#if CYTHON_COMPILING_IN_CPYTHON
+static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
+    PyObject *result;
+    ternaryfunc call = func->ob_type->tp_call;
+    if (unlikely(!call))
+        return PyObject_Call(func, arg, kw);
+#if PY_VERSION_HEX >= 0x02060000
+    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
+        return NULL;
+#endif
+    result = (*call)(func, arg, kw);
+#if PY_VERSION_HEX >= 0x02060000
+    Py_LeaveRecursiveCall();
+#endif
+    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
+        PyErr_SetString(
+            PyExc_SystemError,
+            "NULL result without error in PyObject_Call");
+    }
+    return result;
+}
+#endif
+
+#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func)             \
+    {                                                                     \
+        func_type value = func(x);                                        \
+        if (sizeof(target_type) < sizeof(func_type)) {                    \
+            if (unlikely(value != (func_type) (target_type) value)) {     \
+                func_type zero = 0;                                       \
+                PyErr_SetString(PyExc_OverflowError,                      \
+                    (is_unsigned && unlikely(value < zero)) ?             \
+                    "can't convert negative value to " #target_type :     \
+                    "value too large to convert to " #target_type);       \
+                return (target_type) -1;                                  \
+            }                                                             \
+        }                                                                 \
+        return (target_type) value;                                       \
+    }
+
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+ #if CYTHON_USE_PYLONG_INTERNALS
+  #include "longintrepr.h"
+ #endif
+#endif
+static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
+    const int neg_one = (int) -1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_MAJOR_VERSION < 3
+    if (likely(PyInt_Check(x))) {
+        if (sizeof(int) < sizeof(long)) {
+            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG)
+        } else {
+            long val = PyInt_AS_LONG(x);
+            if (is_unsigned && unlikely(val < 0)) {
+                PyErr_SetString(PyExc_OverflowError,
+                                "can't convert negative value to int");
+                return (int) -1;
+            }
+            return (int) val;
+        }
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+ #if CYTHON_USE_PYLONG_INTERNALS
+            if (sizeof(digit) <= sizeof(int)) {
+                switch (Py_SIZE(x)) {
+                    case  0: return 0;
+                    case  1: return (int) ((PyLongObject*)x)->ob_digit[0];
+                }
+            }
+ #endif
+#endif
+            if (unlikely(Py_SIZE(x) < 0)) {
+                PyErr_SetString(PyExc_OverflowError,
+                                "can't convert negative value to int");
+                return (int) -1;
+            }
+            if (sizeof(int) <= sizeof(unsigned long)) {
+                __PYX_VERIFY_RETURN_INT(int, unsigned long, PyLong_AsUnsignedLong)
+            } else if (sizeof(int) <= sizeof(unsigned long long)) {
+                __PYX_VERIFY_RETURN_INT(int, unsigned long long, PyLong_AsUnsignedLongLong)
+            }
+        } else {
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+ #if CYTHON_USE_PYLONG_INTERNALS
+            if (sizeof(digit) <= sizeof(int)) {
+                switch (Py_SIZE(x)) {
+                    case  0: return 0;
+                    case  1: return +(int) ((PyLongObject*)x)->ob_digit[0];
+                    case -1: return -(int) ((PyLongObject*)x)->ob_digit[0];
+                }
+            }
+ #endif
+#endif
+            if (sizeof(int) <= sizeof(long)) {
+                __PYX_VERIFY_RETURN_INT(int, long, PyLong_AsLong)
+            } else if (sizeof(int) <= sizeof(long long)) {
+                __PYX_VERIFY_RETURN_INT(int, long long, PyLong_AsLongLong)
+            }
+        }
+        {
+#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
+            PyErr_SetString(PyExc_RuntimeError,
+                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
+#else
+            int val;
+            PyObject *v = __Pyx_PyNumber_Int(x);
+ #if PY_MAJOR_VERSION < 3
+            if (likely(v) && !PyLong_Check(v)) {
+                PyObject *tmp = v;
+                v = PyNumber_Long(tmp);
+                Py_DECREF(tmp);
+            }
+ #endif
+            if (likely(v)) {
+                int one = 1; int is_little = (int)*(unsigned char *)&one;
+                unsigned char *bytes = (unsigned char *)&val;
+                int ret = _PyLong_AsByteArray((PyLongObject *)v,
+                                              bytes, sizeof(val),
+                                              is_little, !is_unsigned);
+                Py_DECREF(v);
+                if (likely(!ret))
+                    return val;
+            }
+#endif
+            return (int) -1;
+        }
+    } else {
+        int val;
+        PyObject *tmp = __Pyx_PyNumber_Int(x);
+        if (!tmp) return (int) -1;
+        val = __Pyx_PyInt_As_int(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+}
+
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_int(int value) {
+    const int neg_one = (int) -1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (is_unsigned) {
+        if (sizeof(int) < sizeof(long)) {
+            return PyInt_FromLong((long) value);
+        } else if (sizeof(int) <= sizeof(unsigned long)) {
+            return PyLong_FromUnsignedLong((unsigned long) value);
+        } else if (sizeof(int) <= sizeof(unsigned long long)) {
+            return PyLong_FromUnsignedLongLong((unsigned long long) value);
+        }
+    } else {
+        if (sizeof(int) <= sizeof(long)) {
+            return PyInt_FromLong((long) value);
+        } else if (sizeof(int) <= sizeof(long long)) {
+            return PyLong_FromLongLong((long long) value);
+        }
+    }
+    {
+        int one = 1; int little = (int)*(unsigned char *)&one;
+        unsigned char *bytes = (unsigned char *)&value;
+        return _PyLong_FromByteArray(bytes, sizeof(int),
+                                     little, !is_unsigned);
+    }
+}
+
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
+    const long neg_one = (long) -1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (is_unsigned) {
+        if (sizeof(long) < sizeof(long)) {
+            return PyInt_FromLong((long) value);
+        } else if (sizeof(long) <= sizeof(unsigned long)) {
+            return PyLong_FromUnsignedLong((unsigned long) value);
+        } else if (sizeof(long) <= sizeof(unsigned long long)) {
+            return PyLong_FromUnsignedLongLong((unsigned long long) value);
+        }
+    } else {
+        if (sizeof(long) <= sizeof(long)) {
+            return PyInt_FromLong((long) value);
+        } else if (sizeof(long) <= sizeof(long long)) {
+            return PyLong_FromLongLong((long long) value);
+        }
+    }
+    {
+        int one = 1; int little = (int)*(unsigned char *)&one;
+        unsigned char *bytes = (unsigned char *)&value;
+        return _PyLong_FromByteArray(bytes, sizeof(long),
+                                     little, !is_unsigned);
+    }
+}
+
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+ #if CYTHON_USE_PYLONG_INTERNALS
+  #include "longintrepr.h"
+ #endif
+#endif
+static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
+    const long neg_one = (long) -1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_MAJOR_VERSION < 3
+    if (likely(PyInt_Check(x))) {
+        if (sizeof(long) < sizeof(long)) {
+            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG)
+        } else {
+            long val = PyInt_AS_LONG(x);
+            if (is_unsigned && unlikely(val < 0)) {
+                PyErr_SetString(PyExc_OverflowError,
+                                "can't convert negative value to long");
+                return (long) -1;
+            }
+            return (long) val;
+        }
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+ #if CYTHON_USE_PYLONG_INTERNALS
+            if (sizeof(digit) <= sizeof(long)) {
+                switch (Py_SIZE(x)) {
+                    case  0: return 0;
+                    case  1: return (long) ((PyLongObject*)x)->ob_digit[0];
+                }
+            }
+ #endif
+#endif
+            if (unlikely(Py_SIZE(x) < 0)) {
+                PyErr_SetString(PyExc_OverflowError,
+                                "can't convert negative value to long");
+                return (long) -1;
+            }
+            if (sizeof(long) <= sizeof(unsigned long)) {
+                __PYX_VERIFY_RETURN_INT(long, unsigned long, PyLong_AsUnsignedLong)
+            } else if (sizeof(long) <= sizeof(unsigned long long)) {
+                __PYX_VERIFY_RETURN_INT(long, unsigned long long, PyLong_AsUnsignedLongLong)
+            }
+        } else {
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+ #if CYTHON_USE_PYLONG_INTERNALS
+            if (sizeof(digit) <= sizeof(long)) {
+                switch (Py_SIZE(x)) {
+                    case  0: return 0;
+                    case  1: return +(long) ((PyLongObject*)x)->ob_digit[0];
+                    case -1: return -(long) ((PyLongObject*)x)->ob_digit[0];
+                }
+            }
+ #endif
+#endif
+            if (sizeof(long) <= sizeof(long)) {
+                __PYX_VERIFY_RETURN_INT(long, long, PyLong_AsLong)
+            } else if (sizeof(long) <= sizeof(long long)) {
+                __PYX_VERIFY_RETURN_INT(long, long long, PyLong_AsLongLong)
+            }
+        }
+        {
+#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
+            PyErr_SetString(PyExc_RuntimeError,
+                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
+#else
+            long val;
+            PyObject *v = __Pyx_PyNumber_Int(x);
+ #if PY_MAJOR_VERSION < 3
+            if (likely(v) && !PyLong_Check(v)) {
+                PyObject *tmp = v;
+                v = PyNumber_Long(tmp);
+                Py_DECREF(tmp);
+            }
+ #endif
+            if (likely(v)) {
+                int one = 1; int is_little = (int)*(unsigned char *)&one;
+                unsigned char *bytes = (unsigned char *)&val;
+                int ret = _PyLong_AsByteArray((PyLongObject *)v,
+                                              bytes, sizeof(val),
+                                              is_little, !is_unsigned);
+                Py_DECREF(v);
+                if (likely(!ret))
+                    return val;
+            }
+#endif
+            return (long) -1;
+        }
+    } else {
+        long val;
+        PyObject *tmp = __Pyx_PyNumber_Int(x);
+        if (!tmp) return (long) -1;
+        val = __Pyx_PyInt_As_long(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+}
+
+static int __Pyx_check_binary_version(void) {
+    char ctversion[4], rtversion[4];
+    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
+    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
+    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
+        char message[200];
+        PyOS_snprintf(message, sizeof(message),
+                      "compiletime version %s of module '%.100s' "
+                      "does not match runtime version %s",
+                      ctversion, __Pyx_MODULE_NAME, rtversion);
+        #if PY_VERSION_HEX < 0x02050000
+        return PyErr_Warn(NULL, message);
+        #else
+        return PyErr_WarnEx(NULL, message, 1);
+        #endif
+    }
+    return 0;
+}
+
+static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
+    int start = 0, mid = 0, end = count - 1;
+    if (end >= 0 && code_line > entries[end].code_line) {
+        return count;
+    }
+    while (start < end) {
+        mid = (start + end) / 2;
+        if (code_line < entries[mid].code_line) {
+            end = mid;
+        } else if (code_line > entries[mid].code_line) {
+             start = mid + 1;
+        } else {
+            return mid;
+        }
+    }
+    if (code_line <= entries[mid].code_line) {
+        return mid;
+    } else {
+        return mid + 1;
+    }
+}
+static PyCodeObject *__pyx_find_code_object(int code_line) {
+    PyCodeObject* code_object;
+    int pos;
+    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
+        return NULL;
+    }
+    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
+    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
+        return NULL;
+    }
+    code_object = __pyx_code_cache.entries[pos].code_object;
+    Py_INCREF(code_object);
+    return code_object;
+}
+static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
+    int pos, i;
+    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
+    if (unlikely(!code_line)) {
+        return;
+    }
+    if (unlikely(!entries)) {
+        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
+        if (likely(entries)) {
+            __pyx_code_cache.entries = entries;
+            __pyx_code_cache.max_count = 64;
+            __pyx_code_cache.count = 1;
+            entries[0].code_line = code_line;
+            entries[0].code_object = code_object;
+            Py_INCREF(code_object);
+        }
+        return;
+    }
+    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
+    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
+        PyCodeObject* tmp = entries[pos].code_object;
+        entries[pos].code_object = code_object;
+        Py_DECREF(tmp);
+        return;
+    }
+    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
+        int new_max = __pyx_code_cache.max_count + 64;
+        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
+            __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
+        if (unlikely(!entries)) {
+            return;
+        }
+        __pyx_code_cache.entries = entries;
+        __pyx_code_cache.max_count = new_max;
+    }
+    for (i=__pyx_code_cache.count; i>pos; i--) {
+        entries[i] = entries[i-1];
+    }
+    entries[pos].code_line = code_line;
+    entries[pos].code_object = code_object;
+    __pyx_code_cache.count++;
+    Py_INCREF(code_object);
+}
+
+#include "compile.h"
+#include "frameobject.h"
+#include "traceback.h"
+static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
+            const char *funcname, int c_line,
+            int py_line, const char *filename) {
+    PyCodeObject *py_code = 0;
+    PyObject *py_srcfile = 0;
+    PyObject *py_funcname = 0;
+    #if PY_MAJOR_VERSION < 3
+    py_srcfile = PyString_FromString(filename);
+    #else
+    py_srcfile = PyUnicode_FromString(filename);
+    #endif
+    if (!py_srcfile) goto bad;
+    if (c_line) {
+        #if PY_MAJOR_VERSION < 3
+        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
+        #else
+        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
+        #endif
+    }
+    else {
+        #if PY_MAJOR_VERSION < 3
+        py_funcname = PyString_FromString(funcname);
+        #else
+        py_funcname = PyUnicode_FromString(funcname);
+        #endif
+    }
+    if (!py_funcname) goto bad;
+    py_code = __Pyx_PyCode_New(
+        0,            /*int argcount,*/
+        0,            /*int kwonlyargcount,*/
+        0,            /*int nlocals,*/
+        0,            /*int stacksize,*/
+        0,            /*int flags,*/
+        __pyx_empty_bytes, /*PyObject *code,*/
+        __pyx_empty_tuple, /*PyObject *consts,*/
+        __pyx_empty_tuple, /*PyObject *names,*/
+        __pyx_empty_tuple, /*PyObject *varnames,*/
+        __pyx_empty_tuple, /*PyObject *freevars,*/
+        __pyx_empty_tuple, /*PyObject *cellvars,*/
+        py_srcfile,   /*PyObject *filename,*/
+        py_funcname,  /*PyObject *name,*/
+        py_line,      /*int firstlineno,*/
+        __pyx_empty_bytes  /*PyObject *lnotab*/
+    );
+    Py_DECREF(py_srcfile);
+    Py_DECREF(py_funcname);
+    return py_code;
+bad:
+    Py_XDECREF(py_srcfile);
+    Py_XDECREF(py_funcname);
+    return NULL;
+}
+static void __Pyx_AddTraceback(const char *funcname, int c_line,
+                               int py_line, const char *filename) {
+    PyCodeObject *py_code = 0;
+    PyObject *py_globals = 0;
+    PyFrameObject *py_frame = 0;
+    py_code = __pyx_find_code_object(c_line ? c_line : py_line);
+    if (!py_code) {
+        py_code = __Pyx_CreateCodeObjectForTraceback(
+            funcname, c_line, py_line, filename);
+        if (!py_code) goto bad;
+        __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
+    }
+    py_globals = PyModule_GetDict(__pyx_m);
+    if (!py_globals) goto bad;
+    py_frame = PyFrame_New(
+        PyThreadState_GET(), /*PyThreadState *tstate,*/
+        py_code,             /*PyCodeObject *code,*/
+        py_globals,          /*PyObject *globals,*/
+        0                    /*PyObject *locals*/
+    );
+    if (!py_frame) goto bad;
+    py_frame->f_lineno = py_line;
+    PyTraceBack_Here(py_frame);
+bad:
+    Py_XDECREF(py_code);
+    Py_XDECREF(py_frame);
+}
+
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
+    while (t->p) {
+        #if PY_MAJOR_VERSION < 3
+        if (t->is_unicode) {
+            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
+        } else if (t->intern) {
+            *t->p = PyString_InternFromString(t->s);
+        } else {
+            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
+        }
+        #else  /* Python 3+ has unicode identifiers */
+        if (t->is_unicode | t->is_str) {
+            if (t->intern) {
+                *t->p = PyUnicode_InternFromString(t->s);
+            } else if (t->encoding) {
+                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
+            } else {
+                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
+            }
+        } else {
+            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
+        }
+        #endif
+        if (!*t->p)
+            return -1;
+        ++t;
+    }
+    return 0;
+}
+
+static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
+    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
+}
+static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
+    Py_ssize_t ignore;
+    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
+}
+static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
+#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
+    if (
+#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
+            __Pyx_sys_getdefaultencoding_not_ascii &&
+#endif
+            PyUnicode_Check(o)) {
+#if PY_VERSION_HEX < 0x03030000
+        char* defenc_c;
+        PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
+        if (!defenc) return NULL;
+        defenc_c = PyBytes_AS_STRING(defenc);
+#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
+        {
+            char* end = defenc_c + PyBytes_GET_SIZE(defenc);
+            char* c;
+            for (c = defenc_c; c < end; c++) {
+                if ((unsigned char) (*c) >= 128) {
+                    PyUnicode_AsASCIIString(o);
+                    return NULL;
+                }
+            }
+        }
+#endif /*__PYX_DEFAULT_STRING_ENCODING_IS_ASCII*/
+        *length = PyBytes_GET_SIZE(defenc);
+        return defenc_c;
+#else /* PY_VERSION_HEX < 0x03030000 */
+        if (PyUnicode_READY(o) == -1) return NULL;
+#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
+        if (PyUnicode_IS_ASCII(o)) {
+            *length = PyUnicode_GET_LENGTH(o);
+            return PyUnicode_AsUTF8(o);
+        } else {
+            PyUnicode_AsASCIIString(o);
+            return NULL;
+        }
+#else /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */
+        return PyUnicode_AsUTF8AndSize(o, length);
+#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII */
+#endif /* PY_VERSION_HEX < 0x03030000 */
+    } else
+#endif /* __PYX_DEFAULT_STRING_ENCODING_IS_ASCII  || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT */
+#if !CYTHON_COMPILING_IN_PYPY
+#if PY_VERSION_HEX >= 0x02060000
+    if (PyByteArray_Check(o)) {
+        *length = PyByteArray_GET_SIZE(o);
+        return PyByteArray_AS_STRING(o);
+    } else
+#endif
+#endif
+    {
+        char* result;
+        int r = PyBytes_AsStringAndSize(o, &result, length);
+        if (unlikely(r < 0)) {
+            return NULL;
+        } else {
+            return result;
+        }
+    }
+}
+static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
+   int is_true = x == Py_True;
+   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
+   else return PyObject_IsTrue(x);
+}
+static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
+  PyNumberMethods *m;
+  const char *name = NULL;
+  PyObject *res = NULL;
+#if PY_MAJOR_VERSION < 3
+  if (PyInt_Check(x) || PyLong_Check(x))
+#else
+  if (PyLong_Check(x))
+#endif
+    return Py_INCREF(x), x;
+  m = Py_TYPE(x)->tp_as_number;
+#if PY_MAJOR_VERSION < 3
+  if (m && m->nb_int) {
+    name = "int";
+    res = PyNumber_Int(x);
+  }
+  else if (m && m->nb_long) {
+    name = "long";
+    res = PyNumber_Long(x);
+  }
+#else
+  if (m && m->nb_int) {
+    name = "int";
+    res = PyNumber_Long(x);
+  }
+#endif
+  if (res) {
+#if PY_MAJOR_VERSION < 3
+    if (!PyInt_Check(res) && !PyLong_Check(res)) {
+#else
+    if (!PyLong_Check(res)) {
+#endif
+      PyErr_Format(PyExc_TypeError,
+                   "__%.4s__ returned non-%.4s (type %.200s)",
+                   name, name, Py_TYPE(res)->tp_name);
+      Py_DECREF(res);
+      return NULL;
+    }
+  }
+  else if (!PyErr_Occurred()) {
+    PyErr_SetString(PyExc_TypeError,
+                    "an integer is required");
+  }
+  return res;
+}
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+ #if CYTHON_USE_PYLONG_INTERNALS
+  #include "longintrepr.h"
+ #endif
+#endif
+static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
+  Py_ssize_t ival;
+  PyObject *x;
+#if PY_MAJOR_VERSION < 3
+  if (likely(PyInt_CheckExact(b)))
+      return PyInt_AS_LONG(b);
+#endif
+  if (likely(PyLong_CheckExact(b))) {
+    #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+     #if CYTHON_USE_PYLONG_INTERNALS
+       switch (Py_SIZE(b)) {
+       case -1: return -(sdigit)((PyLongObject*)b)->ob_digit[0];
+       case  0: return 0;
+       case  1: return ((PyLongObject*)b)->ob_digit[0];
+       }
+     #endif
+    #endif
+  #if PY_VERSION_HEX < 0x02060000
+    return PyInt_AsSsize_t(b);
+  #else
+    return PyLong_AsSsize_t(b);
+  #endif
+  }
+  x = PyNumber_Index(b);
+  if (!x) return -1;
+  ival = PyInt_AsSsize_t(x);
+  Py_DECREF(x);
+  return ival;
+}
+static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
+#if PY_VERSION_HEX < 0x02050000
+   if (ival <= LONG_MAX)
+       return PyInt_FromLong((long)ival);
+   else {
+       unsigned char *bytes = (unsigned char *) &ival;
+       int one = 1; int little = (int)*(unsigned char*)&one;
+       return _PyLong_FromByteArray(bytes, sizeof(size_t), little, 0);
+   }
+#else
+   return PyInt_FromSize_t(ival);
+#endif
+}
+
+
+#endif /* Py_PYTHON_H */
diff --git a/cutadapt/_qualtrim.pyx b/cutadapt/_qualtrim.pyx
new file mode 100644
index 0000000..4169c4c
--- /dev/null
+++ b/cutadapt/_qualtrim.pyx
@@ -0,0 +1,48 @@
+# kate: syntax Python;
+"""
+Quality trimming.
+"""
+
+def quality_trim_index(str qualities, int cutoff_front, int cutoff_back, int base=33):
+	"""
+	Find the positions at which to trim low-quality ends from a nucleotide sequence.
+	Return tuple (start, stop) that indicates the good-quality segment.
+
+	Qualities are assumed to be ASCII-encoded as chr(qual + base).
+
+	The algorithm is the same as the one used by BWA within the function
+	'bwa_trim_read':
+	- Subtract the cutoff value from all qualities.
+	- Compute partial sums from all indices to the end of the sequence.
+	- Trim sequence at the index at which the sum is minimal.
+	"""
+	cdef int s
+	cdef int max_qual
+	cdef int stop = len(qualities)
+	cdef int start = 0
+	cdef int i
+
+	# find trim position for 5' end
+	s = 0
+	max_qual = 0
+	for i in range(len(qualities)):
+		s += cutoff_front - (ord(qualities[i]) - base)
+		if s < 0:
+			break
+		if s > max_qual:
+			max_qual = s
+			start = i + 1
+
+	# same for 3' end
+	max_qual = 0
+	s = 0
+	for i in reversed(xrange(len(qualities))):
+		s += cutoff_back - (ord(qualities[i]) - base)
+		if s < 0:
+			break
+		if s > max_qual:
+			max_qual = s
+			stop = i
+	if start >= stop:
+		start, stop = 0, 0
+	return (start, stop)
diff --git a/cutadapt/_qualtrim.so b/cutadapt/_qualtrim.so
new file mode 100755
index 0000000..8846605
Binary files /dev/null and b/cutadapt/_qualtrim.so differ
diff --git a/cutadapt/_seqio.c b/cutadapt/_seqio.c
new file mode 100644
index 0000000..e291d29
--- /dev/null
+++ b/cutadapt/_seqio.c
@@ -0,0 +1,8436 @@
+/* Generated by Cython 0.22.1 */
+
+/* BEGIN: Cython Metadata
+{
+    "distutils": {}
+}
+END: Cython Metadata */
+
+#define PY_SSIZE_T_CLEAN
+#ifndef CYTHON_USE_PYLONG_INTERNALS
+#ifdef PYLONG_BITS_IN_DIGIT
+#define CYTHON_USE_PYLONG_INTERNALS 0
+#else
+#include "pyconfig.h"
+#ifdef PYLONG_BITS_IN_DIGIT
+#define CYTHON_USE_PYLONG_INTERNALS 1
+#else
+#define CYTHON_USE_PYLONG_INTERNALS 0
+#endif
+#endif
+#endif
+#include "Python.h"
+#ifndef Py_PYTHON_H
+    #error Python headers needed to compile C extensions, please install development version of Python.
+#elif PY_VERSION_HEX < 0x02060000 || (0x03000000 <= PY_VERSION_HEX && PY_VERSION_HEX < 0x03020000)
+    #error Cython requires Python 2.6+ or Python 3.2+.
+#else
+#define CYTHON_ABI "0_22_1"
+#include <stddef.h>
+#ifndef offsetof
+#define offsetof(type, member) ( (size_t) & ((type*)0) -> member )
+#endif
+#if !defined(WIN32) && !defined(MS_WINDOWS)
+  #ifndef __stdcall
+    #define __stdcall
+  #endif
+  #ifndef __cdecl
+    #define __cdecl
+  #endif
+  #ifndef __fastcall
+    #define __fastcall
+  #endif
+#endif
+#ifndef DL_IMPORT
+  #define DL_IMPORT(t) t
+#endif
+#ifndef DL_EXPORT
+  #define DL_EXPORT(t) t
+#endif
+#ifndef PY_LONG_LONG
+  #define PY_LONG_LONG LONG_LONG
+#endif
+#ifndef Py_HUGE_VAL
+  #define Py_HUGE_VAL HUGE_VAL
+#endif
+#ifdef PYPY_VERSION
+#define CYTHON_COMPILING_IN_PYPY 1
+#define CYTHON_COMPILING_IN_CPYTHON 0
+#else
+#define CYTHON_COMPILING_IN_PYPY 0
+#define CYTHON_COMPILING_IN_CPYTHON 1
+#endif
+#if CYTHON_COMPILING_IN_PYPY && PY_VERSION_HEX < 0x02070600 && !defined(Py_OptimizeFlag)
+#define Py_OptimizeFlag 0
+#endif
+#define __PYX_BUILD_PY_SSIZE_T "n"
+#define CYTHON_FORMAT_SSIZE_T "z"
+#if PY_MAJOR_VERSION < 3
+  #define __Pyx_BUILTIN_MODULE_NAME "__builtin__"
+  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
+          PyCode_New(a+k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
+  #define __Pyx_DefaultClassType PyClass_Type
+#else
+  #define __Pyx_BUILTIN_MODULE_NAME "builtins"
+  #define __Pyx_PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos) \
+          PyCode_New(a, k, l, s, f, code, c, n, v, fv, cell, fn, name, fline, lnos)
+  #define __Pyx_DefaultClassType PyType_Type
+#endif
+#ifndef Py_TPFLAGS_CHECKTYPES
+  #define Py_TPFLAGS_CHECKTYPES 0
+#endif
+#ifndef Py_TPFLAGS_HAVE_INDEX
+  #define Py_TPFLAGS_HAVE_INDEX 0
+#endif
+#ifndef Py_TPFLAGS_HAVE_NEWBUFFER
+  #define Py_TPFLAGS_HAVE_NEWBUFFER 0
+#endif
+#ifndef Py_TPFLAGS_HAVE_FINALIZE
+  #define Py_TPFLAGS_HAVE_FINALIZE 0
+#endif
+#if PY_VERSION_HEX > 0x03030000 && defined(PyUnicode_KIND)
+  #define CYTHON_PEP393_ENABLED 1
+  #define __Pyx_PyUnicode_READY(op)       (likely(PyUnicode_IS_READY(op)) ? \
+                                              0 : _PyUnicode_Ready((PyObject *)(op)))
+  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_LENGTH(u)
+  #define __Pyx_PyUnicode_READ_CHAR(u, i) PyUnicode_READ_CHAR(u, i)
+  #define __Pyx_PyUnicode_KIND(u)         PyUnicode_KIND(u)
+  #define __Pyx_PyUnicode_DATA(u)         PyUnicode_DATA(u)
+  #define __Pyx_PyUnicode_READ(k, d, i)   PyUnicode_READ(k, d, i)
+#else
+  #define CYTHON_PEP393_ENABLED 0
+  #define __Pyx_PyUnicode_READY(op)       (0)
+  #define __Pyx_PyUnicode_GET_LENGTH(u)   PyUnicode_GET_SIZE(u)
+  #define __Pyx_PyUnicode_READ_CHAR(u, i) ((Py_UCS4)(PyUnicode_AS_UNICODE(u)[i]))
+  #define __Pyx_PyUnicode_KIND(u)         (sizeof(Py_UNICODE))
+  #define __Pyx_PyUnicode_DATA(u)         ((void*)PyUnicode_AS_UNICODE(u))
+  #define __Pyx_PyUnicode_READ(k, d, i)   ((void)(k), (Py_UCS4)(((Py_UNICODE*)d)[i]))
+#endif
+#if CYTHON_COMPILING_IN_PYPY
+  #define __Pyx_PyUnicode_Concat(a, b)      PyNumber_Add(a, b)
+  #define __Pyx_PyUnicode_ConcatSafe(a, b)  PyNumber_Add(a, b)
+  #define __Pyx_PyFrozenSet_Size(s)         PyObject_Size(s)
+#else
+  #define __Pyx_PyUnicode_Concat(a, b)      PyUnicode_Concat(a, b)
+  #define __Pyx_PyUnicode_ConcatSafe(a, b)  ((unlikely((a) == Py_None) || unlikely((b) == Py_None)) ? \
+      PyNumber_Add(a, b) : __Pyx_PyUnicode_Concat(a, b))
+  #define __Pyx_PyFrozenSet_Size(s)         PySet_Size(s)
+#endif
+#if CYTHON_COMPILING_IN_PYPY && !defined(PyUnicode_Contains)
+  #define PyUnicode_Contains(u, s)  PySequence_Contains(u, s)
+#endif
+#define __Pyx_PyString_FormatSafe(a, b)   ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : __Pyx_PyString_Format(a, b))
+#define __Pyx_PyUnicode_FormatSafe(a, b)  ((unlikely((a) == Py_None)) ? PyNumber_Remainder(a, b) : PyUnicode_Format(a, b))
+#if PY_MAJOR_VERSION >= 3
+  #define __Pyx_PyString_Format(a, b)  PyUnicode_Format(a, b)
+#else
+  #define __Pyx_PyString_Format(a, b)  PyString_Format(a, b)
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define PyBaseString_Type            PyUnicode_Type
+  #define PyStringObject               PyUnicodeObject
+  #define PyString_Type                PyUnicode_Type
+  #define PyString_Check               PyUnicode_Check
+  #define PyString_CheckExact          PyUnicode_CheckExact
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define __Pyx_PyBaseString_Check(obj) PyUnicode_Check(obj)
+  #define __Pyx_PyBaseString_CheckExact(obj) PyUnicode_CheckExact(obj)
+#else
+  #define __Pyx_PyBaseString_Check(obj) (PyString_Check(obj) || PyUnicode_Check(obj))
+  #define __Pyx_PyBaseString_CheckExact(obj) (PyString_CheckExact(obj) || PyUnicode_CheckExact(obj))
+#endif
+#ifndef PySet_CheckExact
+  #define PySet_CheckExact(obj)        (Py_TYPE(obj) == &PySet_Type)
+#endif
+#define __Pyx_TypeCheck(obj, type) PyObject_TypeCheck(obj, (PyTypeObject *)type)
+#if PY_MAJOR_VERSION >= 3
+  #define PyIntObject                  PyLongObject
+  #define PyInt_Type                   PyLong_Type
+  #define PyInt_Check(op)              PyLong_Check(op)
+  #define PyInt_CheckExact(op)         PyLong_CheckExact(op)
+  #define PyInt_FromString             PyLong_FromString
+  #define PyInt_FromUnicode            PyLong_FromUnicode
+  #define PyInt_FromLong               PyLong_FromLong
+  #define PyInt_FromSize_t             PyLong_FromSize_t
+  #define PyInt_FromSsize_t            PyLong_FromSsize_t
+  #define PyInt_AsLong                 PyLong_AsLong
+  #define PyInt_AS_LONG                PyLong_AS_LONG
+  #define PyInt_AsSsize_t              PyLong_AsSsize_t
+  #define PyInt_AsUnsignedLongMask     PyLong_AsUnsignedLongMask
+  #define PyInt_AsUnsignedLongLongMask PyLong_AsUnsignedLongLongMask
+  #define PyNumber_Int                 PyNumber_Long
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define PyBoolObject                 PyLongObject
+#endif
+#if PY_MAJOR_VERSION >= 3 && CYTHON_COMPILING_IN_PYPY
+  #ifndef PyUnicode_InternFromString
+    #define PyUnicode_InternFromString(s) PyUnicode_FromString(s)
+  #endif
+#endif
+#if PY_VERSION_HEX < 0x030200A4
+  typedef long Py_hash_t;
+  #define __Pyx_PyInt_FromHash_t PyInt_FromLong
+  #define __Pyx_PyInt_AsHash_t   PyInt_AsLong
+#else
+  #define __Pyx_PyInt_FromHash_t PyInt_FromSsize_t
+  #define __Pyx_PyInt_AsHash_t   PyInt_AsSsize_t
+#endif
+#if PY_MAJOR_VERSION >= 3
+  #define __Pyx_PyMethod_New(func, self, klass) ((self) ? PyMethod_New(func, self) : PyInstanceMethod_New(func))
+#else
+  #define __Pyx_PyMethod_New(func, self, klass) PyMethod_New(func, self, klass)
+#endif
+#ifndef CYTHON_INLINE
+  #if defined(__GNUC__)
+    #define CYTHON_INLINE __inline__
+  #elif defined(_MSC_VER)
+    #define CYTHON_INLINE __inline
+  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+    #define CYTHON_INLINE inline
+  #else
+    #define CYTHON_INLINE
+  #endif
+#endif
+#ifndef CYTHON_RESTRICT
+  #if defined(__GNUC__)
+    #define CYTHON_RESTRICT __restrict__
+  #elif defined(_MSC_VER) && _MSC_VER >= 1400
+    #define CYTHON_RESTRICT __restrict
+  #elif defined (__STDC_VERSION__) && __STDC_VERSION__ >= 199901L
+    #define CYTHON_RESTRICT restrict
+  #else
+    #define CYTHON_RESTRICT
+  #endif
+#endif
+#ifdef NAN
+#define __PYX_NAN() ((float) NAN)
+#else
+static CYTHON_INLINE float __PYX_NAN() {
+  /* Initialize NaN. The sign is irrelevant, an exponent with all bits 1 and
+   a nonzero mantissa means NaN. If the first bit in the mantissa is 1, it is
+   a quiet NaN. */
+  float value;
+  memset(&value, 0xFF, sizeof(value));
+  return value;
+}
+#endif
+#define __Pyx_void_to_None(void_result) (void_result, Py_INCREF(Py_None), Py_None)
+#ifdef __cplusplus
+template<typename T>
+void __Pyx_call_destructor(T* x) {
+    x->~T();
+}
+template<typename T>
+class __Pyx_FakeReference {
+  public:
+    __Pyx_FakeReference() : ptr(NULL) { }
+    __Pyx_FakeReference(T& ref) : ptr(&ref) { }
+    T *operator->() { return ptr; }
+    operator T&() { return *ptr; }
+  private:
+    T *ptr;
+};
+#endif
+
+
+#if PY_MAJOR_VERSION >= 3
+  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
+  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
+#else
+  #define __Pyx_PyNumber_Divide(x,y)         PyNumber_TrueDivide(x,y)
+  #define __Pyx_PyNumber_InPlaceDivide(x,y)  PyNumber_InPlaceTrueDivide(x,y)
+#endif
+
+#ifndef __PYX_EXTERN_C
+  #ifdef __cplusplus
+    #define __PYX_EXTERN_C extern "C"
+  #else
+    #define __PYX_EXTERN_C extern
+  #endif
+#endif
+
+#if defined(WIN32) || defined(MS_WINDOWS)
+#define _USE_MATH_DEFINES
+#endif
+#include <math.h>
+#define __PYX_HAVE__cutadapt___seqio
+#define __PYX_HAVE_API__cutadapt___seqio
+#ifdef _OPENMP
+#include <omp.h>
+#endif /* _OPENMP */
+
+#ifdef PYREX_WITHOUT_ASSERTIONS
+#define CYTHON_WITHOUT_ASSERTIONS
+#endif
+
+#ifndef CYTHON_UNUSED
+# if defined(__GNUC__)
+#   if !(defined(__cplusplus)) || (__GNUC__ > 3 || (__GNUC__ == 3 && __GNUC_MINOR__ >= 4))
+#     define CYTHON_UNUSED __attribute__ ((__unused__))
+#   else
+#     define CYTHON_UNUSED
+#   endif
+# elif defined(__ICC) || (defined(__INTEL_COMPILER) && !defined(_MSC_VER))
+#   define CYTHON_UNUSED __attribute__ ((__unused__))
+# else
+#   define CYTHON_UNUSED
+# endif
+#endif
+#ifndef CYTHON_NCP_UNUSED
+# if CYTHON_COMPILING_IN_CPYTHON
+#  define CYTHON_NCP_UNUSED
+# else
+#  define CYTHON_NCP_UNUSED CYTHON_UNUSED
+# endif
+#endif
+typedef struct {PyObject **p; char *s; const Py_ssize_t n; const char* encoding;
+                const char is_unicode; const char is_str; const char intern; } __Pyx_StringTabEntry;
+
+#define __PYX_DEFAULT_STRING_ENCODING_IS_ASCII 0
+#define __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT 0
+#define __PYX_DEFAULT_STRING_ENCODING ""
+#define __Pyx_PyObject_FromString __Pyx_PyBytes_FromString
+#define __Pyx_PyObject_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
+#define __Pyx_fits_Py_ssize_t(v, type, is_signed)  (    \
+    (sizeof(type) < sizeof(Py_ssize_t))  ||             \
+    (sizeof(type) > sizeof(Py_ssize_t) &&               \
+          likely(v < (type)PY_SSIZE_T_MAX ||            \
+                 v == (type)PY_SSIZE_T_MAX)  &&         \
+          (!is_signed || likely(v > (type)PY_SSIZE_T_MIN ||       \
+                                v == (type)PY_SSIZE_T_MIN)))  ||  \
+    (sizeof(type) == sizeof(Py_ssize_t) &&              \
+          (is_signed || likely(v < (type)PY_SSIZE_T_MAX ||        \
+                               v == (type)PY_SSIZE_T_MAX)))  )
+static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject*);
+static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject*, Py_ssize_t* length);
+#define __Pyx_PyByteArray_FromString(s) PyByteArray_FromStringAndSize((const char*)s, strlen((const char*)s))
+#define __Pyx_PyByteArray_FromStringAndSize(s, l) PyByteArray_FromStringAndSize((const char*)s, l)
+#define __Pyx_PyBytes_FromString        PyBytes_FromString
+#define __Pyx_PyBytes_FromStringAndSize PyBytes_FromStringAndSize
+static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char*);
+#if PY_MAJOR_VERSION < 3
+    #define __Pyx_PyStr_FromString        __Pyx_PyBytes_FromString
+    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyBytes_FromStringAndSize
+#else
+    #define __Pyx_PyStr_FromString        __Pyx_PyUnicode_FromString
+    #define __Pyx_PyStr_FromStringAndSize __Pyx_PyUnicode_FromStringAndSize
+#endif
+#define __Pyx_PyObject_AsSString(s)    ((signed char*) __Pyx_PyObject_AsString(s))
+#define __Pyx_PyObject_AsUString(s)    ((unsigned char*) __Pyx_PyObject_AsString(s))
+#define __Pyx_PyObject_FromCString(s)  __Pyx_PyObject_FromString((const char*)s)
+#define __Pyx_PyBytes_FromCString(s)   __Pyx_PyBytes_FromString((const char*)s)
+#define __Pyx_PyByteArray_FromCString(s)   __Pyx_PyByteArray_FromString((const char*)s)
+#define __Pyx_PyStr_FromCString(s)     __Pyx_PyStr_FromString((const char*)s)
+#define __Pyx_PyUnicode_FromCString(s) __Pyx_PyUnicode_FromString((const char*)s)
+#if PY_MAJOR_VERSION < 3
+static CYTHON_INLINE size_t __Pyx_Py_UNICODE_strlen(const Py_UNICODE *u)
+{
+    const Py_UNICODE *u_end = u;
+    while (*u_end++) ;
+    return (size_t)(u_end - u - 1);
+}
+#else
+#define __Pyx_Py_UNICODE_strlen Py_UNICODE_strlen
+#endif
+#define __Pyx_PyUnicode_FromUnicode(u)       PyUnicode_FromUnicode(u, __Pyx_Py_UNICODE_strlen(u))
+#define __Pyx_PyUnicode_FromUnicodeAndLength PyUnicode_FromUnicode
+#define __Pyx_PyUnicode_AsUnicode            PyUnicode_AsUnicode
+#define __Pyx_Owned_Py_None(b) (Py_INCREF(Py_None), Py_None)
+#define __Pyx_PyBool_FromLong(b) ((b) ? (Py_INCREF(Py_True), Py_True) : (Py_INCREF(Py_False), Py_False))
+static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject*);
+static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x);
+static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject*);
+static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t);
+#if CYTHON_COMPILING_IN_CPYTHON
+#define __pyx_PyFloat_AsDouble(x) (PyFloat_CheckExact(x) ? PyFloat_AS_DOUBLE(x) : PyFloat_AsDouble(x))
+#else
+#define __pyx_PyFloat_AsDouble(x) PyFloat_AsDouble(x)
+#endif
+#define __pyx_PyFloat_AsFloat(x) ((float) __pyx_PyFloat_AsDouble(x))
+#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
+static int __Pyx_sys_getdefaultencoding_not_ascii;
+static int __Pyx_init_sys_getdefaultencoding_params(void) {
+    PyObject* sys;
+    PyObject* default_encoding = NULL;
+    PyObject* ascii_chars_u = NULL;
+    PyObject* ascii_chars_b = NULL;
+    const char* default_encoding_c;
+    sys = PyImport_ImportModule("sys");
+    if (!sys) goto bad;
+    default_encoding = PyObject_CallMethod(sys, (char*) "getdefaultencoding", NULL);
+    Py_DECREF(sys);
+    if (!default_encoding) goto bad;
+    default_encoding_c = PyBytes_AsString(default_encoding);
+    if (!default_encoding_c) goto bad;
+    if (strcmp(default_encoding_c, "ascii") == 0) {
+        __Pyx_sys_getdefaultencoding_not_ascii = 0;
+    } else {
+        char ascii_chars[128];
+        int c;
+        for (c = 0; c < 128; c++) {
+            ascii_chars[c] = c;
+        }
+        __Pyx_sys_getdefaultencoding_not_ascii = 1;
+        ascii_chars_u = PyUnicode_DecodeASCII(ascii_chars, 128, NULL);
+        if (!ascii_chars_u) goto bad;
+        ascii_chars_b = PyUnicode_AsEncodedString(ascii_chars_u, default_encoding_c, NULL);
+        if (!ascii_chars_b || !PyBytes_Check(ascii_chars_b) || memcmp(ascii_chars, PyBytes_AS_STRING(ascii_chars_b), 128) != 0) {
+            PyErr_Format(
+                PyExc_ValueError,
+                "This module compiled with c_string_encoding=ascii, but default encoding '%.200s' is not a superset of ascii.",
+                default_encoding_c);
+            goto bad;
+        }
+        Py_DECREF(ascii_chars_u);
+        Py_DECREF(ascii_chars_b);
+    }
+    Py_DECREF(default_encoding);
+    return 0;
+bad:
+    Py_XDECREF(default_encoding);
+    Py_XDECREF(ascii_chars_u);
+    Py_XDECREF(ascii_chars_b);
+    return -1;
+}
+#endif
+#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT && PY_MAJOR_VERSION >= 3
+#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_DecodeUTF8(c_str, size, NULL)
+#else
+#define __Pyx_PyUnicode_FromStringAndSize(c_str, size) PyUnicode_Decode(c_str, size, __PYX_DEFAULT_STRING_ENCODING, NULL)
+#if __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
+static char* __PYX_DEFAULT_STRING_ENCODING;
+static int __Pyx_init_sys_getdefaultencoding_params(void) {
+    PyObject* sys;
+    PyObject* default_encoding = NULL;
+    char* default_encoding_c;
+    sys = PyImport_ImportModule("sys");
+    if (!sys) goto bad;
+    default_encoding = PyObject_CallMethod(sys, (char*) (const char*) "getdefaultencoding", NULL);
+    Py_DECREF(sys);
+    if (!default_encoding) goto bad;
+    default_encoding_c = PyBytes_AsString(default_encoding);
+    if (!default_encoding_c) goto bad;
+    __PYX_DEFAULT_STRING_ENCODING = (char*) malloc(strlen(default_encoding_c));
+    if (!__PYX_DEFAULT_STRING_ENCODING) goto bad;
+    strcpy(__PYX_DEFAULT_STRING_ENCODING, default_encoding_c);
+    Py_DECREF(default_encoding);
+    return 0;
+bad:
+    Py_XDECREF(default_encoding);
+    return -1;
+}
+#endif
+#endif
+
+
+/* Test for GCC > 2.95 */
+#if defined(__GNUC__)     && (__GNUC__ > 2 || (__GNUC__ == 2 && (__GNUC_MINOR__ > 95)))
+  #define likely(x)   __builtin_expect(!!(x), 1)
+  #define unlikely(x) __builtin_expect(!!(x), 0)
+#else /* !__GNUC__ or GCC < 2.95 */
+  #define likely(x)   (x)
+  #define unlikely(x) (x)
+#endif /* __GNUC__ */
+
+static PyObject *__pyx_m;
+static PyObject *__pyx_d;
+static PyObject *__pyx_b;
+static PyObject *__pyx_empty_tuple;
+static PyObject *__pyx_empty_bytes;
+static int __pyx_lineno;
+static int __pyx_clineno = 0;
+static const char * __pyx_cfilenm= __FILE__;
+static const char *__pyx_filename;
+
+
+static const char *__pyx_f[] = {
+  "cutadapt/_seqio.pyx",
+};
+
+/*--- Type declarations ---*/
+struct __pyx_obj_8cutadapt_6_seqio_Sequence;
+struct __pyx_obj_8cutadapt_6_seqio___pyx_scope_struct____iter__;
+struct __pyx_defaults;
+typedef struct __pyx_defaults __pyx_defaults;
+struct __pyx_defaults {
+  PyObject *__pyx_arg_sequence_class;
+};
+
+/* "cutadapt/_seqio.pyx":25
+ * 
+ * 
+ * cdef class Sequence(object):             # <<<<<<<<<<<<<<
+ * 	"""
+ * 	A record in a FASTQ file. Also used for FASTA (then the qualities attribute
+ */
+struct __pyx_obj_8cutadapt_6_seqio_Sequence {
+  PyObject_HEAD
+  PyObject *name;
+  PyObject *sequence;
+  PyObject *qualities;
+  PyObject *match;
+  int twoheaders;
+};
+
+
+/* "cutadapt/_seqio.pyx":119
+ * 		self.delivers_qualities = True
+ * 
+ * 	def __iter__(self):             # <<<<<<<<<<<<<<
+ * 		"""
+ * 		Return tuples: (name, sequence, qualities).
+ */
+struct __pyx_obj_8cutadapt_6_seqio___pyx_scope_struct____iter__ {
+  PyObject_HEAD
+  int __pyx_v_i;
+  PyObject *__pyx_v_it;
+  PyObject *__pyx_v_line;
+  PyObject *__pyx_v_name;
+  PyObject *__pyx_v_qualities;
+  PyObject *__pyx_v_self;
+  PyObject *__pyx_v_sequence;
+  PyObject *__pyx_v_sequence_class;
+  int __pyx_v_strip;
+  int __pyx_v_twoheaders;
+  PyObject *__pyx_t_0;
+  Py_ssize_t __pyx_t_1;
+  PyObject *(*__pyx_t_2)(PyObject *);
+};
+
+
+/* --- Runtime support code (head) --- */
+#ifndef CYTHON_REFNANNY
+  #define CYTHON_REFNANNY 0
+#endif
+#if CYTHON_REFNANNY
+  typedef struct {
+    void (*INCREF)(void*, PyObject*, int);
+    void (*DECREF)(void*, PyObject*, int);
+    void (*GOTREF)(void*, PyObject*, int);
+    void (*GIVEREF)(void*, PyObject*, int);
+    void* (*SetupContext)(const char*, int, const char*);
+    void (*FinishContext)(void**);
+  } __Pyx_RefNannyAPIStruct;
+  static __Pyx_RefNannyAPIStruct *__Pyx_RefNanny = NULL;
+  static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname);
+  #define __Pyx_RefNannyDeclarations void *__pyx_refnanny = NULL;
+#ifdef WITH_THREAD
+  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
+          if (acquire_gil) { \
+              PyGILState_STATE __pyx_gilstate_save = PyGILState_Ensure(); \
+              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
+              PyGILState_Release(__pyx_gilstate_save); \
+          } else { \
+              __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__); \
+          }
+#else
+  #define __Pyx_RefNannySetupContext(name, acquire_gil) \
+          __pyx_refnanny = __Pyx_RefNanny->SetupContext((name), __LINE__, __FILE__)
+#endif
+  #define __Pyx_RefNannyFinishContext() \
+          __Pyx_RefNanny->FinishContext(&__pyx_refnanny)
+  #define __Pyx_INCREF(r)  __Pyx_RefNanny->INCREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_DECREF(r)  __Pyx_RefNanny->DECREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_GOTREF(r)  __Pyx_RefNanny->GOTREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_GIVEREF(r) __Pyx_RefNanny->GIVEREF(__pyx_refnanny, (PyObject *)(r), __LINE__)
+  #define __Pyx_XINCREF(r)  do { if((r) != NULL) {__Pyx_INCREF(r); }} while(0)
+  #define __Pyx_XDECREF(r)  do { if((r) != NULL) {__Pyx_DECREF(r); }} while(0)
+  #define __Pyx_XGOTREF(r)  do { if((r) != NULL) {__Pyx_GOTREF(r); }} while(0)
+  #define __Pyx_XGIVEREF(r) do { if((r) != NULL) {__Pyx_GIVEREF(r);}} while(0)
+#else
+  #define __Pyx_RefNannyDeclarations
+  #define __Pyx_RefNannySetupContext(name, acquire_gil)
+  #define __Pyx_RefNannyFinishContext()
+  #define __Pyx_INCREF(r) Py_INCREF(r)
+  #define __Pyx_DECREF(r) Py_DECREF(r)
+  #define __Pyx_GOTREF(r)
+  #define __Pyx_GIVEREF(r)
+  #define __Pyx_XINCREF(r) Py_XINCREF(r)
+  #define __Pyx_XDECREF(r) Py_XDECREF(r)
+  #define __Pyx_XGOTREF(r)
+  #define __Pyx_XGIVEREF(r)
+#endif
+#define __Pyx_XDECREF_SET(r, v) do {                            \
+        PyObject *tmp = (PyObject *) r;                         \
+        r = v; __Pyx_XDECREF(tmp);                              \
+    } while (0)
+#define __Pyx_DECREF_SET(r, v) do {                             \
+        PyObject *tmp = (PyObject *) r;                         \
+        r = v; __Pyx_DECREF(tmp);                               \
+    } while (0)
+#define __Pyx_CLEAR(r)    do { PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);} while(0)
+#define __Pyx_XCLEAR(r)   do { if((r) != NULL) {PyObject* tmp = ((PyObject*)(r)); r = NULL; __Pyx_DECREF(tmp);}} while(0)
+
+#if CYTHON_COMPILING_IN_CPYTHON
+static CYTHON_INLINE PyObject* __Pyx_PyObject_GetAttrStr(PyObject* obj, PyObject* attr_name) {
+    PyTypeObject* tp = Py_TYPE(obj);
+    if (likely(tp->tp_getattro))
+        return tp->tp_getattro(obj, attr_name);
+#if PY_MAJOR_VERSION < 3
+    if (likely(tp->tp_getattr))
+        return tp->tp_getattr(obj, PyString_AS_STRING(attr_name));
+#endif
+    return PyObject_GetAttr(obj, attr_name);
+}
+#else
+#define __Pyx_PyObject_GetAttrStr(o,n) PyObject_GetAttr(o,n)
+#endif
+
+static PyObject *__Pyx_GetBuiltinName(PyObject *name);
+
+static void __Pyx_RaiseDoubleKeywordsError(const char* func_name, PyObject* kw_name);
+
+static int __Pyx_ParseOptionalKeywords(PyObject *kwds, PyObject **argnames[], \
+    PyObject *kwds2, PyObject *values[], Py_ssize_t num_pos_args, \
+    const char* function_name);
+
+static void __Pyx_RaiseArgtupleInvalid(const char* func_name, int exact,
+    Py_ssize_t num_min, Py_ssize_t num_max, Py_ssize_t num_found);
+
+static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(
+        PyObject* obj, Py_ssize_t cstart, Py_ssize_t cstop,
+        PyObject** py_start, PyObject** py_stop, PyObject** py_slice,
+        int has_cstart, int has_cstop, int wraparound);
+
+static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
+    const char *name, int exact);
+
+static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name);
+
+#if CYTHON_COMPILING_IN_CPYTHON
+static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw);
+#else
+#define __Pyx_PyObject_Call(func, arg, kw) PyObject_Call(func, arg, kw)
+#endif
+
+#if CYTHON_COMPILING_IN_CPYTHON
+static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg);
+#endif
+
+static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg);
+
+static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb);
+static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb);
+
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause);
+
+#if CYTHON_COMPILING_IN_CPYTHON
+static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func);
+#else
+#define __Pyx_PyObject_CallNoArg(func) __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL)
+#endif
+
+#if CYTHON_COMPILING_IN_CPYTHON
+#define __Pyx_PyObject_DelAttrStr(o,n) __Pyx_PyObject_SetAttrStr(o,n,NULL)
+static CYTHON_INLINE int __Pyx_PyObject_SetAttrStr(PyObject* obj, PyObject* attr_name, PyObject* value) {
+    PyTypeObject* tp = Py_TYPE(obj);
+    if (likely(tp->tp_setattro))
+        return tp->tp_setattro(obj, attr_name, value);
+#if PY_MAJOR_VERSION < 3
+    if (likely(tp->tp_setattr))
+        return tp->tp_setattr(obj, PyString_AS_STRING(attr_name), value);
+#endif
+    return PyObject_SetAttr(obj, attr_name, value);
+}
+#else
+#define __Pyx_PyObject_DelAttrStr(o,n)   PyObject_DelAttr(o,n)
+#define __Pyx_PyObject_SetAttrStr(o,n,v) PyObject_SetAttr(o,n,v)
+#endif
+
+#define __Pyx_PyIter_Next(obj) __Pyx_PyIter_Next2(obj, NULL)
+static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject *, PyObject *);
+
+#define __Pyx_GetItemInt(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
+    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
+    __Pyx_GetItemInt_Fast(o, (Py_ssize_t)i, is_list, wraparound, boundscheck) : \
+    (is_list ? (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL) : \
+               __Pyx_GetItemInt_Generic(o, to_py_func(i))))
+#define __Pyx_GetItemInt_List(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
+    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
+    __Pyx_GetItemInt_List_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
+    (PyErr_SetString(PyExc_IndexError, "list index out of range"), (PyObject*)NULL))
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
+                                                              int wraparound, int boundscheck);
+#define __Pyx_GetItemInt_Tuple(o, i, type, is_signed, to_py_func, is_list, wraparound, boundscheck) \
+    (__Pyx_fits_Py_ssize_t(i, type, is_signed) ? \
+    __Pyx_GetItemInt_Tuple_Fast(o, (Py_ssize_t)i, wraparound, boundscheck) : \
+    (PyErr_SetString(PyExc_IndexError, "tuple index out of range"), (PyObject*)NULL))
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
+                                                              int wraparound, int boundscheck);
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j);
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i,
+                                                     int is_list, int wraparound, int boundscheck);
+
+#include <string.h>
+
+static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals);
+
+static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals);
+
+#if PY_MAJOR_VERSION >= 3
+#define __Pyx_PyString_Equals __Pyx_PyUnicode_Equals
+#else
+#define __Pyx_PyString_Equals __Pyx_PyBytes_Equals
+#endif
+
+static int __Pyx_PyBytes_SingleTailmatch(PyObject* self, PyObject* arg, Py_ssize_t start,
+                                         Py_ssize_t end, int direction)
+{
+    const char* self_ptr = PyBytes_AS_STRING(self);
+    Py_ssize_t self_len = PyBytes_GET_SIZE(self);
+    const char* sub_ptr;
+    Py_ssize_t sub_len;
+    int retval;
+    Py_buffer view;
+    view.obj = NULL;
+    if ( PyBytes_Check(arg) ) {
+        sub_ptr = PyBytes_AS_STRING(arg);
+        sub_len = PyBytes_GET_SIZE(arg);
+    }
+#if PY_MAJOR_VERSION < 3
+    else if ( PyUnicode_Check(arg) ) {
+        return PyUnicode_Tailmatch(self, arg, start, end, direction);
+    }
+#endif
+    else {
+        if (unlikely(PyObject_GetBuffer(self, &view, PyBUF_SIMPLE) == -1))
+            return -1;
+        sub_ptr = (const char*) view.buf;
+        sub_len = view.len;
+    }
+    if (end > self_len)
+        end = self_len;
+    else if (end < 0)
+        end += self_len;
+    if (end < 0)
+        end = 0;
+    if (start < 0)
+        start += self_len;
+    if (start < 0)
+        start = 0;
+    if (direction > 0) {
+        if (end-sub_len > start)
+            start = end - sub_len;
+    }
+    if (start + sub_len <= end)
+        retval = !memcmp(self_ptr+start, sub_ptr, (size_t)sub_len);
+    else
+        retval = 0;
+    if (view.obj)
+        PyBuffer_Release(&view);
+    return retval;
+}
+static int __Pyx_PyBytes_Tailmatch(PyObject* self, PyObject* substr, Py_ssize_t start,
+                                   Py_ssize_t end, int direction)
+{
+    if (unlikely(PyTuple_Check(substr))) {
+        Py_ssize_t i, count = PyTuple_GET_SIZE(substr);
+        for (i = 0; i < count; i++) {
+            int result;
+#if CYTHON_COMPILING_IN_CPYTHON
+            result = __Pyx_PyBytes_SingleTailmatch(self, PyTuple_GET_ITEM(substr, i),
+                                                   start, end, direction);
+#else
+            PyObject* sub = PySequence_ITEM(substr, i);
+            if (unlikely(!sub)) return -1;
+            result = __Pyx_PyBytes_SingleTailmatch(self, sub, start, end, direction);
+            Py_DECREF(sub);
+#endif
+            if (result) {
+                return result;
+            }
+        }
+        return 0;
+    }
+    return __Pyx_PyBytes_SingleTailmatch(self, substr, start, end, direction);
+}
+
+static int __Pyx_PyUnicode_Tailmatch(PyObject* s, PyObject* substr,
+                                     Py_ssize_t start, Py_ssize_t end, int direction) {
+    if (unlikely(PyTuple_Check(substr))) {
+        Py_ssize_t i, count = PyTuple_GET_SIZE(substr);
+        for (i = 0; i < count; i++) {
+            int result;
+#if CYTHON_COMPILING_IN_CPYTHON
+            result = PyUnicode_Tailmatch(s, PyTuple_GET_ITEM(substr, i),
+                                         start, end, direction);
+#else
+            PyObject* sub = PySequence_ITEM(substr, i);
+            if (unlikely(!sub)) return -1;
+            result = PyUnicode_Tailmatch(s, sub, start, end, direction);
+            Py_DECREF(sub);
+#endif
+            if (result) {
+                return result;
+            }
+        }
+        return 0;
+    }
+    return PyUnicode_Tailmatch(s, substr, start, end, direction);
+}
+
+static CYTHON_INLINE int __Pyx_PyStr_Tailmatch(PyObject* self, PyObject* arg, Py_ssize_t start,
+                                               Py_ssize_t end, int direction);
+
+static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname);
+
+static CYTHON_INLINE long __Pyx_mod_long(long, long); /* proto */
+
+static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name);
+
+static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases);
+
+static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name, PyObject *qualname,
+                                           PyObject *mkw, PyObject *modname, PyObject *doc);
+static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases, PyObject *dict,
+                                      PyObject *mkw, int calculate_metaclass, int allow_py2_metaclass);
+
+static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type);
+
+#define __Pyx_CyFunction_USED 1
+#include <structmember.h>
+#define __Pyx_CYFUNCTION_STATICMETHOD  0x01
+#define __Pyx_CYFUNCTION_CLASSMETHOD   0x02
+#define __Pyx_CYFUNCTION_CCLASS        0x04
+#define __Pyx_CyFunction_GetClosure(f) \
+    (((__pyx_CyFunctionObject *) (f))->func_closure)
+#define __Pyx_CyFunction_GetClassObj(f) \
+    (((__pyx_CyFunctionObject *) (f))->func_classobj)
+#define __Pyx_CyFunction_Defaults(type, f) \
+    ((type *)(((__pyx_CyFunctionObject *) (f))->defaults))
+#define __Pyx_CyFunction_SetDefaultsGetter(f, g) \
+    ((__pyx_CyFunctionObject *) (f))->defaults_getter = (g)
+typedef struct {
+    PyCFunctionObject func;
+#if PY_VERSION_HEX < 0x030500A0
+    PyObject *func_weakreflist;
+#endif
+    PyObject *func_dict;
+    PyObject *func_name;
+    PyObject *func_qualname;
+    PyObject *func_doc;
+    PyObject *func_globals;
+    PyObject *func_code;
+    PyObject *func_closure;
+    PyObject *func_classobj;
+    void *defaults;
+    int defaults_pyobjects;
+    int flags;
+    PyObject *defaults_tuple;
+    PyObject *defaults_kwdict;
+    PyObject *(*defaults_getter)(PyObject *);
+    PyObject *func_annotations;
+} __pyx_CyFunctionObject;
+static PyTypeObject *__pyx_CyFunctionType = 0;
+#define __Pyx_CyFunction_NewEx(ml, flags, qualname, self, module, globals, code) \
+    __Pyx_CyFunction_New(__pyx_CyFunctionType, ml, flags, qualname, self, module, globals, code)
+static PyObject *__Pyx_CyFunction_New(PyTypeObject *, PyMethodDef *ml,
+                                      int flags, PyObject* qualname,
+                                      PyObject *self,
+                                      PyObject *module, PyObject *globals,
+                                      PyObject* code);
+static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *m,
+                                                         size_t size,
+                                                         int pyobjects);
+static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *m,
+                                                            PyObject *tuple);
+static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *m,
+                                                             PyObject *dict);
+static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *m,
+                                                              PyObject *dict);
+static int __Pyx_CyFunction_init(void);
+
+typedef struct {
+    int code_line;
+    PyCodeObject* code_object;
+} __Pyx_CodeObjectCacheEntry;
+struct __Pyx_CodeObjectCache {
+    int count;
+    int max_count;
+    __Pyx_CodeObjectCacheEntry* entries;
+};
+static struct __Pyx_CodeObjectCache __pyx_code_cache = {0,0,NULL};
+static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line);
+static PyCodeObject *__pyx_find_code_object(int code_line);
+static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object);
+
+static void __Pyx_AddTraceback(const char *funcname, int c_line,
+                               int py_line, const char *filename);
+
+static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level);
+
+static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *);
+
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value);
+
+static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *);
+
+static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb);
+
+static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg);
+
+#define __Pyx_Generator_USED
+#include <structmember.h>
+#include <frameobject.h>
+typedef PyObject *(*__pyx_generator_body_t)(PyObject *, PyObject *);
+typedef struct {
+    PyObject_HEAD
+    __pyx_generator_body_t body;
+    PyObject *closure;
+    PyObject *exc_type;
+    PyObject *exc_value;
+    PyObject *exc_traceback;
+    PyObject *gi_weakreflist;
+    PyObject *classobj;
+    PyObject *yieldfrom;
+    PyObject *gi_name;
+    PyObject *gi_qualname;
+    int resume_label;
+    char is_running;
+} __pyx_GeneratorObject;
+static __pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body,
+                                                  PyObject *closure, PyObject *name, PyObject *qualname);
+static int __pyx_Generator_init(void);
+static int __Pyx_Generator_clear(PyObject* self);
+#if 1 || PY_VERSION_HEX < 0x030300B0
+static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue);
+#else
+#define __Pyx_PyGen_FetchStopIterationValue(pvalue) PyGen_FetchStopIterationValue(pvalue)
+#endif
+
+static int __Pyx_check_binary_version(void);
+
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t);
+
+
+/* Module declarations from 'cutadapt._seqio' */
+static PyTypeObject *__pyx_ptype_8cutadapt_6_seqio_Sequence = 0;
+static PyTypeObject *__pyx_ptype_8cutadapt_6_seqio___pyx_scope_struct____iter__ = 0;
+#define __Pyx_MODULE_NAME "cutadapt._seqio"
+int __pyx_module_is_main_cutadapt___seqio = 0;
+
+/* Implementation of 'cutadapt._seqio' */
+static PyObject *__pyx_builtin_Exception;
+static PyObject *__pyx_builtin_object;
+static PyObject *__pyx_builtin_NotImplementedError;
+static PyObject *__pyx_builtin_ValueError;
+static PyObject *__pyx_pf_8cutadapt_6_seqio__shorten(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_s, PyObject *__pyx_v_n); /* proto */
+static int __pyx_pf_8cutadapt_6_seqio_8Sequence___init__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_sequence, PyObject *__pyx_v_qualities, int __pyx_v_twoheaders, PyObject *__pyx_v_match); /* proto */
+static PyObject *__pyx_pf_8cutadapt_6_seqio_8Sequence_2__getitem__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self, PyObject *__pyx_v_key); /* proto */
+static PyObject *__pyx_pf_8cutadapt_6_seqio_8Sequence_4__repr__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self); /* proto */
+static Py_ssize_t __pyx_pf_8cutadapt_6_seqio_8Sequence_6__len__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_8cutadapt_6_seqio_8Sequence_8__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op); /* proto */
+static PyObject *__pyx_pf_8cutadapt_6_seqio_8Sequence_10__reduce__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_8cutadapt_6_seqio_8Sequence_12write(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self, PyObject *__pyx_v_outfile); /* proto */
+static PyObject *__pyx_pf_8cutadapt_6_seqio_8Sequence_4name___get__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self); /* proto */
+static int __pyx_pf_8cutadapt_6_seqio_8Sequence_4name_2__set__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
+static int __pyx_pf_8cutadapt_6_seqio_8Sequence_4name_4__del__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_8cutadapt_6_seqio_8Sequence_8sequence___get__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self); /* proto */
+static int __pyx_pf_8cutadapt_6_seqio_8Sequence_8sequence_2__set__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
+static int __pyx_pf_8cutadapt_6_seqio_8Sequence_8sequence_4__del__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_8cutadapt_6_seqio_8Sequence_9qualities___get__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self); /* proto */
+static int __pyx_pf_8cutadapt_6_seqio_8Sequence_9qualities_2__set__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
+static int __pyx_pf_8cutadapt_6_seqio_8Sequence_9qualities_4__del__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_8cutadapt_6_seqio_8Sequence_5match___get__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self); /* proto */
+static int __pyx_pf_8cutadapt_6_seqio_8Sequence_5match_2__set__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
+static int __pyx_pf_8cutadapt_6_seqio_8Sequence_5match_4__del__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_8cutadapt_6_seqio_8Sequence_10twoheaders___get__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self); /* proto */
+static int __pyx_pf_8cutadapt_6_seqio_8Sequence_10twoheaders_2__set__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self, PyObject *__pyx_v_value); /* proto */
+static PyObject *__pyx_pf_8cutadapt_6_seqio_11FastqReader_11__defaults__(CYTHON_UNUSED PyObject *__pyx_self); /* proto */
+static PyObject *__pyx_pf_8cutadapt_6_seqio_11FastqReader___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_file, PyObject *__pyx_v_sequence_class); /* proto */
+static PyObject *__pyx_pf_8cutadapt_6_seqio_11FastqReader_2__iter__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_8cutadapt_6_seqio_11FastqReader_5close(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_8cutadapt_6_seqio_11FastqReader_7__enter__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self); /* proto */
+static PyObject *__pyx_pf_8cutadapt_6_seqio_11FastqReader_9__exit__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args); /* proto */
+static PyObject *__pyx_tp_new_8cutadapt_6_seqio_Sequence(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
+static PyObject *__pyx_tp_new_8cutadapt_6_seqio___pyx_scope_struct____iter__(PyTypeObject *t, PyObject *a, PyObject *k); /*proto*/
+static char __pyx_k_[] = "...";
+static char __pyx_k_i[] = "i";
+static char __pyx_k_n[] = "n";
+static char __pyx_k_s[] = "s";
+static char __pyx_k__2[] = "";
+static char __pyx_k__3[] = "@";
+static char __pyx_k__4[] = "\n";
+static char __pyx_k__5[] = "\n+";
+static char __pyx_k__6[] = ">";
+static char __pyx_k__7[] = "\r\n";
+static char __pyx_k__8[] = "+\n";
+static char __pyx_k__9[] = "+";
+static char __pyx_k_fp[] = "fp";
+static char __pyx_k_it[] = "it";
+static char __pyx_k_doc[] = "__doc__";
+static char __pyx_k_args[] = "args";
+static char __pyx_k_exit[] = "__exit__";
+static char __pyx_k_file[] = "file";
+static char __pyx_k_init[] = "__init__";
+static char __pyx_k_iter[] = "__iter__";
+static char __pyx_k_line[] = "line";
+static char __pyx_k_main[] = "__main__";
+static char __pyx_k_name[] = "name";
+static char __pyx_k_self[] = "self";
+static char __pyx_k_send[] = "send";
+static char __pyx_k_test[] = "__test__";
+static char __pyx_k_class[] = "__class__";
+static char __pyx_k_close[] = "close";
+static char __pyx_k_enter[] = "__enter__";
+static char __pyx_k_match[] = "match";
+static char __pyx_k_strip[] = "strip";
+static char __pyx_k_throw[] = "throw";
+static char __pyx_k_write[] = "write";
+static char __pyx_k_xopen[] = "xopen";
+static char __pyx_k_format[] = "format";
+static char __pyx_k_import[] = "__import__";
+static char __pyx_k_module[] = "__module__";
+static char __pyx_k_object[] = "object";
+static char __pyx_k_rstrip[] = "rstrip";
+static char __pyx_k_prepare[] = "__prepare__";
+static char __pyx_k_shorten[] = "_shorten";
+static char __pyx_k_qualname[] = "__qualname__";
+static char __pyx_k_sequence[] = "sequence";
+static char __pyx_k_Exception[] = "Exception";
+static char __pyx_k_metaclass[] = "__metaclass__";
+static char __pyx_k_qualities[] = "qualities";
+static char __pyx_k_ValueError[] = "ValueError";
+static char __pyx_k_twoheaders[] = "twoheaders";
+static char __pyx_k_FastqReader[] = "FastqReader";
+static char __pyx_k_FormatError[] = "FormatError";
+static char __pyx_k_file_passed[] = "_file_passed";
+static char __pyx_k_qualities_0_r[] = ", qualities={0!r}";
+static char __pyx_k_sequence_class[] = "sequence_class";
+static char __pyx_k_cutadapt__seqio[] = "cutadapt._seqio";
+static char __pyx_k_FastqReader_close[] = "FastqReader.close";
+static char __pyx_k_FastqReader___exit[] = "FastqReader.__exit__";
+static char __pyx_k_FastqReader___init[] = "FastqReader.__init__";
+static char __pyx_k_FastqReader___iter[] = "FastqReader.__iter__";
+static char __pyx_k_delivers_qualities[] = "delivers_qualities";
+static char __pyx_k_FastqReader___enter[] = "FastqReader.__enter__";
+static char __pyx_k_NotImplementedError[] = "NotImplementedError";
+static char __pyx_k_FASTQ_file_ended_prematurely[] = "FASTQ file ended prematurely";
+static char __pyx_k_Sequence_name_0_r_sequence_1_r[] = "<Sequence(name={0!r}, sequence={1!r}{2})>";
+static char __pyx_k_At_line_0_Sequence_descriptions[] = "At line {0}: Sequence descriptions in the FASTQ file don't match ({1!r} != {2!r}).\nThe second sequence description must be either empty or equal to the first description.";
+static char __pyx_k_Raised_when_an_input_file_FASTA[] = "\n\tRaised when an input file (FASTA or FASTQ) is malformatted.\n\t";
+static char __pyx_k_Reader_for_FASTQ_files_Does_not[] = "\n\tReader for FASTQ files. Does not support multi-line FASTQ files.\n\t";
+static char __pyx_k_home_marcel_scm_cutadapt_cutada[] = "/home/marcel/scm/cutadapt/cutadapt/_seqio.pyx";
+static char __pyx_k_I_O_operation_on_closed_FastqRea[] = "I/O operation on closed FastqReader";
+static char __pyx_k_In_read_named_0_r_length_of_qual[] = "In read named {0!r}: length of quality sequence ({1}) and length of read ({2}) do not match";
+static char __pyx_k_at_line_0_expected_a_line_starti[] = "at line {0}, expected a line starting with '@'";
+static char __pyx_k_at_line_0_expected_a_line_starti_2[] = "at line {0}, expected a line starting with '+'";
+static PyObject *__pyx_kp_s_;
+static PyObject *__pyx_kp_s_At_line_0_Sequence_descriptions;
+static PyObject *__pyx_n_s_Exception;
+static PyObject *__pyx_kp_s_FASTQ_file_ended_prematurely;
+static PyObject *__pyx_n_s_FastqReader;
+static PyObject *__pyx_n_s_FastqReader___enter;
+static PyObject *__pyx_n_s_FastqReader___exit;
+static PyObject *__pyx_n_s_FastqReader___init;
+static PyObject *__pyx_n_s_FastqReader___iter;
+static PyObject *__pyx_n_s_FastqReader_close;
+static PyObject *__pyx_n_s_FormatError;
+static PyObject *__pyx_kp_s_I_O_operation_on_closed_FastqRea;
+static PyObject *__pyx_kp_s_In_read_named_0_r_length_of_qual;
+static PyObject *__pyx_n_s_NotImplementedError;
+static PyObject *__pyx_kp_s_Raised_when_an_input_file_FASTA;
+static PyObject *__pyx_kp_s_Reader_for_FASTQ_files_Does_not;
+static PyObject *__pyx_kp_s_Sequence_name_0_r_sequence_1_r;
+static PyObject *__pyx_n_s_ValueError;
+static PyObject *__pyx_kp_s__2;
+static PyObject *__pyx_kp_s__3;
+static PyObject *__pyx_kp_s__4;
+static PyObject *__pyx_kp_s__5;
+static PyObject *__pyx_kp_s__6;
+static PyObject *__pyx_kp_s__7;
+static PyObject *__pyx_kp_s__8;
+static PyObject *__pyx_kp_s__9;
+static PyObject *__pyx_n_s_args;
+static PyObject *__pyx_kp_s_at_line_0_expected_a_line_starti;
+static PyObject *__pyx_kp_s_at_line_0_expected_a_line_starti_2;
+static PyObject *__pyx_n_s_class;
+static PyObject *__pyx_n_s_close;
+static PyObject *__pyx_n_s_cutadapt__seqio;
+static PyObject *__pyx_n_s_delivers_qualities;
+static PyObject *__pyx_n_s_doc;
+static PyObject *__pyx_n_s_enter;
+static PyObject *__pyx_n_s_exit;
+static PyObject *__pyx_n_s_file;
+static PyObject *__pyx_n_s_file_passed;
+static PyObject *__pyx_n_s_format;
+static PyObject *__pyx_n_s_fp;
+static PyObject *__pyx_kp_s_home_marcel_scm_cutadapt_cutada;
+static PyObject *__pyx_n_s_i;
+static PyObject *__pyx_n_s_import;
+static PyObject *__pyx_n_s_init;
+static PyObject *__pyx_n_s_it;
+static PyObject *__pyx_n_s_iter;
+static PyObject *__pyx_n_s_line;
+static PyObject *__pyx_n_s_main;
+static PyObject *__pyx_n_s_match;
+static PyObject *__pyx_n_s_metaclass;
+static PyObject *__pyx_n_s_module;
+static PyObject *__pyx_n_s_n;
+static PyObject *__pyx_n_s_name;
+static PyObject *__pyx_n_s_object;
+static PyObject *__pyx_n_s_prepare;
+static PyObject *__pyx_n_s_qualities;
+static PyObject *__pyx_kp_s_qualities_0_r;
+static PyObject *__pyx_n_s_qualname;
+static PyObject *__pyx_n_s_rstrip;
+static PyObject *__pyx_n_s_s;
+static PyObject *__pyx_n_s_self;
+static PyObject *__pyx_n_s_send;
+static PyObject *__pyx_n_s_sequence;
+static PyObject *__pyx_n_s_sequence_class;
+static PyObject *__pyx_n_s_shorten;
+static PyObject *__pyx_n_s_strip;
+static PyObject *__pyx_n_s_test;
+static PyObject *__pyx_n_s_throw;
+static PyObject *__pyx_n_s_twoheaders;
+static PyObject *__pyx_n_s_write;
+static PyObject *__pyx_n_s_xopen;
+static PyObject *__pyx_int_3;
+static PyObject *__pyx_int_100;
+static PyObject *__pyx_tuple__10;
+static PyObject *__pyx_tuple__11;
+static PyObject *__pyx_tuple__12;
+static PyObject *__pyx_tuple__13;
+static PyObject *__pyx_tuple__15;
+static PyObject *__pyx_tuple__17;
+static PyObject *__pyx_tuple__19;
+static PyObject *__pyx_tuple__21;
+static PyObject *__pyx_tuple__23;
+static PyObject *__pyx_codeobj__14;
+static PyObject *__pyx_codeobj__16;
+static PyObject *__pyx_codeobj__18;
+static PyObject *__pyx_codeobj__20;
+static PyObject *__pyx_codeobj__22;
+static PyObject *__pyx_codeobj__24;
+
+/* "cutadapt/_seqio.pyx":16
+ * 
+ * 
+ * def _shorten(s, n=100):             # <<<<<<<<<<<<<<
+ * 	"""Shorten string s to at most n characters, appending "..." if necessary."""
+ * 	if s is None:
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_8cutadapt_6_seqio_1_shorten(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_8cutadapt_6_seqio__shorten[] = "Shorten string s to at most n characters, appending \"...\" if necessary.";
+static PyMethodDef __pyx_mdef_8cutadapt_6_seqio_1_shorten = {"_shorten", (PyCFunction)__pyx_pw_8cutadapt_6_seqio_1_shorten, METH_VARARGS|METH_KEYWORDS, __pyx_doc_8cutadapt_6_seqio__shorten};
+static PyObject *__pyx_pw_8cutadapt_6_seqio_1_shorten(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_s = 0;
+  PyObject *__pyx_v_n = 0;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("_shorten (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_s,&__pyx_n_s_n,0};
+    PyObject* values[2] = {0,0};
+    values[1] = ((PyObject *)__pyx_int_100);
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_s)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+        case  1:
+        if (kw_args > 0) {
+          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_n);
+          if (value) { values[1] = value; kw_args--; }
+        }
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "_shorten") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    } else {
+      switch (PyTuple_GET_SIZE(__pyx_args)) {
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+    }
+    __pyx_v_s = values[0];
+    __pyx_v_n = values[1];
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("_shorten", 0, 1, 2, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cutadapt._seqio._shorten", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio__shorten(__pyx_self, __pyx_v_s, __pyx_v_n);
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_8cutadapt_6_seqio__shorten(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_s, PyObject *__pyx_v_n) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  Py_ssize_t __pyx_t_3;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("_shorten", 0);
+  __Pyx_INCREF(__pyx_v_s);
+
+  /* "cutadapt/_seqio.pyx":18
+ * def _shorten(s, n=100):
+ * 	"""Shorten string s to at most n characters, appending "..." if necessary."""
+ * 	if s is None:             # <<<<<<<<<<<<<<
+ * 		return None
+ * 	if len(s) > n:
+ */
+  __pyx_t_1 = (__pyx_v_s == Py_None);
+  __pyx_t_2 = (__pyx_t_1 != 0);
+  if (__pyx_t_2) {
+
+    /* "cutadapt/_seqio.pyx":19
+ * 	"""Shorten string s to at most n characters, appending "..." if necessary."""
+ * 	if s is None:
+ * 		return None             # <<<<<<<<<<<<<<
+ * 	if len(s) > n:
+ * 		s = s[:n-3] + '...'
+ */
+    __Pyx_XDECREF(__pyx_r);
+    __Pyx_INCREF(Py_None);
+    __pyx_r = Py_None;
+    goto __pyx_L0;
+  }
+
+  /* "cutadapt/_seqio.pyx":20
+ * 	if s is None:
+ * 		return None
+ * 	if len(s) > n:             # <<<<<<<<<<<<<<
+ * 		s = s[:n-3] + '...'
+ * 	return s
+ */
+  __pyx_t_3 = PyObject_Length(__pyx_v_s); if (unlikely(__pyx_t_3 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_4 = PyInt_FromSsize_t(__pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_5 = PyObject_RichCompare(__pyx_t_4, __pyx_v_n, Py_GT); __Pyx_XGOTREF(__pyx_t_5); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_5); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 20; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  if (__pyx_t_2) {
+
+    /* "cutadapt/_seqio.pyx":21
+ * 		return None
+ * 	if len(s) > n:
+ * 		s = s[:n-3] + '...'             # <<<<<<<<<<<<<<
+ * 	return s
+ * 
+ */
+    __pyx_t_5 = PyNumber_Subtract(__pyx_v_n, __pyx_int_3); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_4 = __Pyx_PyObject_GetSlice(__pyx_v_s, 0, 0, NULL, &__pyx_t_5, NULL, 0, 0, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_5 = PyNumber_Add(__pyx_t_4, __pyx_kp_s_); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 21; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_5);
+    __pyx_t_5 = 0;
+    goto __pyx_L4;
+  }
+  __pyx_L4:;
+
+  /* "cutadapt/_seqio.pyx":22
+ * 	if len(s) > n:
+ * 		s = s[:n-3] + '...'
+ * 	return s             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_s);
+  __pyx_r = __pyx_v_s;
+  goto __pyx_L0;
+
+  /* "cutadapt/_seqio.pyx":16
+ * 
+ * 
+ * def _shorten(s, n=100):             # <<<<<<<<<<<<<<
+ * 	"""Shorten string s to at most n characters, appending "..." if necessary."""
+ * 	if s is None:
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_AddTraceback("cutadapt._seqio._shorten", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_s);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "cutadapt/_seqio.pyx":41
+ * 		public bint twoheaders
+ * 
+ * 	def __init__(self, str name, str sequence, str qualities=None,             # <<<<<<<<<<<<<<
+ * 			  bint twoheaders=False, match=None):
+ * 		"""Set qualities to None if there are no quality values"""
+ */
+
+/* Python wrapper */
+static int __pyx_pw_8cutadapt_6_seqio_8Sequence_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_8cutadapt_6_seqio_8Sequence___init__[] = "Set qualities to None if there are no quality values";
+#if CYTHON_COMPILING_IN_CPYTHON
+struct wrapperbase __pyx_wrapperbase_8cutadapt_6_seqio_8Sequence___init__;
+#endif
+static int __pyx_pw_8cutadapt_6_seqio_8Sequence_1__init__(PyObject *__pyx_v_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_name = 0;
+  PyObject *__pyx_v_sequence = 0;
+  PyObject *__pyx_v_qualities = 0;
+  int __pyx_v_twoheaders;
+  PyObject *__pyx_v_match = 0;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_name,&__pyx_n_s_sequence,&__pyx_n_s_qualities,&__pyx_n_s_twoheaders,&__pyx_n_s_match,0};
+    PyObject* values[5] = {0,0,0,0,0};
+    values[2] = ((PyObject*)Py_None);
+
+    /* "cutadapt/_seqio.pyx":42
+ * 
+ * 	def __init__(self, str name, str sequence, str qualities=None,
+ * 			  bint twoheaders=False, match=None):             # <<<<<<<<<<<<<<
+ * 		"""Set qualities to None if there are no quality values"""
+ * 		self.name = name
+ */
+    values[4] = ((PyObject *)Py_None);
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_name)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+        case  1:
+        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_sequence)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 5, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        }
+        case  2:
+        if (kw_args > 0) {
+          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_qualities);
+          if (value) { values[2] = value; kw_args--; }
+        }
+        case  3:
+        if (kw_args > 0) {
+          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_twoheaders);
+          if (value) { values[3] = value; kw_args--; }
+        }
+        case  4:
+        if (kw_args > 0) {
+          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_match);
+          if (value) { values[4] = value; kw_args--; }
+        }
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    } else {
+      switch (PyTuple_GET_SIZE(__pyx_args)) {
+        case  5: values[4] = PyTuple_GET_ITEM(__pyx_args, 4);
+        case  4: values[3] = PyTuple_GET_ITEM(__pyx_args, 3);
+        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+    }
+    __pyx_v_name = ((PyObject*)values[0]);
+    __pyx_v_sequence = ((PyObject*)values[1]);
+    __pyx_v_qualities = ((PyObject*)values[2]);
+    if (values[3]) {
+      __pyx_v_twoheaders = __Pyx_PyObject_IsTrue(values[3]); if (unlikely((__pyx_v_twoheaders == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 42; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+    } else {
+      __pyx_v_twoheaders = ((int)0);
+    }
+    __pyx_v_match = values[4];
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 5, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cutadapt._seqio.Sequence.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return -1;
+  __pyx_L4_argument_unpacking_done:;
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_name), (&PyString_Type), 1, "name", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_sequence), (&PyString_Type), 1, "sequence", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (unlikely(!__Pyx_ArgTypeTest(((PyObject *)__pyx_v_qualities), (&PyString_Type), 1, "qualities", 1))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 41; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_8Sequence___init__(((struct __pyx_obj_8cutadapt_6_seqio_Sequence *)__pyx_v_self), __pyx_v_name, __pyx_v_sequence, __pyx_v_qualities, __pyx_v_twoheaders, __pyx_v_match);
+
+  /* "cutadapt/_seqio.pyx":41
+ * 		public bint twoheaders
+ * 
+ * 	def __init__(self, str name, str sequence, str qualities=None,             # <<<<<<<<<<<<<<
+ * 			  bint twoheaders=False, match=None):
+ * 		"""Set qualities to None if there are no quality values"""
+ */
+
+  /* function exit code */
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static int __pyx_pf_8cutadapt_6_seqio_8Sequence___init__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self, PyObject *__pyx_v_name, PyObject *__pyx_v_sequence, PyObject *__pyx_v_qualities, int __pyx_v_twoheaders, PyObject *__pyx_v_match) {
+  PyObject *__pyx_v_rname = NULL;
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  int __pyx_t_3;
+  Py_ssize_t __pyx_t_4;
+  Py_ssize_t __pyx_t_5;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  PyObject *__pyx_t_10 = NULL;
+  PyObject *__pyx_t_11 = NULL;
+  PyObject *__pyx_t_12 = NULL;
+  PyObject *__pyx_t_13 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("__init__", 0);
+
+  /* "cutadapt/_seqio.pyx":44
+ * 			  bint twoheaders=False, match=None):
+ * 		"""Set qualities to None if there are no quality values"""
+ * 		self.name = name             # <<<<<<<<<<<<<<
+ * 		self.sequence = sequence
+ * 		self.qualities = qualities
+ */
+  __Pyx_INCREF(__pyx_v_name);
+  __Pyx_GIVEREF(__pyx_v_name);
+  __Pyx_GOTREF(__pyx_v_self->name);
+  __Pyx_DECREF(__pyx_v_self->name);
+  __pyx_v_self->name = __pyx_v_name;
+
+  /* "cutadapt/_seqio.pyx":45
+ * 		"""Set qualities to None if there are no quality values"""
+ * 		self.name = name
+ * 		self.sequence = sequence             # <<<<<<<<<<<<<<
+ * 		self.qualities = qualities
+ * 		self.twoheaders = twoheaders
+ */
+  __Pyx_INCREF(__pyx_v_sequence);
+  __Pyx_GIVEREF(__pyx_v_sequence);
+  __Pyx_GOTREF(__pyx_v_self->sequence);
+  __Pyx_DECREF(__pyx_v_self->sequence);
+  __pyx_v_self->sequence = __pyx_v_sequence;
+
+  /* "cutadapt/_seqio.pyx":46
+ * 		self.name = name
+ * 		self.sequence = sequence
+ * 		self.qualities = qualities             # <<<<<<<<<<<<<<
+ * 		self.twoheaders = twoheaders
+ * 		self.match = match
+ */
+  __Pyx_INCREF(__pyx_v_qualities);
+  __Pyx_GIVEREF(__pyx_v_qualities);
+  __Pyx_GOTREF(__pyx_v_self->qualities);
+  __Pyx_DECREF(__pyx_v_self->qualities);
+  __pyx_v_self->qualities = __pyx_v_qualities;
+
+  /* "cutadapt/_seqio.pyx":47
+ * 		self.sequence = sequence
+ * 		self.qualities = qualities
+ * 		self.twoheaders = twoheaders             # <<<<<<<<<<<<<<
+ * 		self.match = match
+ * 		if qualities is not None and len(qualities) != len(sequence):
+ */
+  __pyx_v_self->twoheaders = __pyx_v_twoheaders;
+
+  /* "cutadapt/_seqio.pyx":48
+ * 		self.qualities = qualities
+ * 		self.twoheaders = twoheaders
+ * 		self.match = match             # <<<<<<<<<<<<<<
+ * 		if qualities is not None and len(qualities) != len(sequence):
+ * 			rname = _shorten(name)
+ */
+  __Pyx_INCREF(__pyx_v_match);
+  __Pyx_GIVEREF(__pyx_v_match);
+  __Pyx_GOTREF(__pyx_v_self->match);
+  __Pyx_DECREF(__pyx_v_self->match);
+  __pyx_v_self->match = __pyx_v_match;
+
+  /* "cutadapt/_seqio.pyx":49
+ * 		self.twoheaders = twoheaders
+ * 		self.match = match
+ * 		if qualities is not None and len(qualities) != len(sequence):             # <<<<<<<<<<<<<<
+ * 			rname = _shorten(name)
+ * 			raise FormatError("In read named {0!r}: length of quality sequence ({1}) and length of read ({2}) do not match".format(
+ */
+  __pyx_t_2 = (__pyx_v_qualities != ((PyObject*)Py_None));
+  __pyx_t_3 = (__pyx_t_2 != 0);
+  if (__pyx_t_3) {
+  } else {
+    __pyx_t_1 = __pyx_t_3;
+    goto __pyx_L4_bool_binop_done;
+  }
+  __pyx_t_4 = PyObject_Length(__pyx_v_qualities); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_5 = PyObject_Length(__pyx_v_sequence); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 49; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_3 = ((__pyx_t_4 != __pyx_t_5) != 0);
+  __pyx_t_1 = __pyx_t_3;
+  __pyx_L4_bool_binop_done:;
+  if (__pyx_t_1) {
+
+    /* "cutadapt/_seqio.pyx":50
+ * 		self.match = match
+ * 		if qualities is not None and len(qualities) != len(sequence):
+ * 			rname = _shorten(name)             # <<<<<<<<<<<<<<
+ * 			raise FormatError("In read named {0!r}: length of quality sequence ({1}) and length of read ({2}) do not match".format(
+ * 				rname, len(qualities), len(sequence)))
+ */
+    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_shorten); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __pyx_t_8 = NULL;
+    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
+      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
+      if (likely(__pyx_t_8)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
+        __Pyx_INCREF(__pyx_t_8);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_7, function);
+      }
+    }
+    if (!__pyx_t_8) {
+      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_name); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+    } else {
+      __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
+      __Pyx_INCREF(__pyx_v_name);
+      __Pyx_GIVEREF(__pyx_v_name);
+      PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_name);
+      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 50; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __pyx_v_rname = __pyx_t_6;
+    __pyx_t_6 = 0;
+
+    /* "cutadapt/_seqio.pyx":51
+ * 		if qualities is not None and len(qualities) != len(sequence):
+ * 			rname = _shorten(name)
+ * 			raise FormatError("In read named {0!r}: length of quality sequence ({1}) and length of read ({2}) do not match".format(             # <<<<<<<<<<<<<<
+ * 				rname, len(qualities), len(sequence)))
+ * 
+ */
+    __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_FormatError); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __pyx_t_8 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_In_read_named_0_r_length_of_qual, __pyx_n_s_format); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_8);
+
+    /* "cutadapt/_seqio.pyx":52
+ * 			rname = _shorten(name)
+ * 			raise FormatError("In read named {0!r}: length of quality sequence ({1}) and length of read ({2}) do not match".format(
+ * 				rname, len(qualities), len(sequence)))             # <<<<<<<<<<<<<<
+ * 
+ * 	def __getitem__(self, key):
+ */
+    __pyx_t_5 = PyObject_Length(__pyx_v_qualities); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_10 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_10);
+    __pyx_t_5 = PyObject_Length(__pyx_v_sequence); if (unlikely(__pyx_t_5 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __pyx_t_11 = PyInt_FromSsize_t(__pyx_t_5); if (unlikely(!__pyx_t_11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 52; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_11);
+    __pyx_t_12 = NULL;
+    __pyx_t_5 = 0;
+    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_8))) {
+      __pyx_t_12 = PyMethod_GET_SELF(__pyx_t_8);
+      if (likely(__pyx_t_12)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_8);
+        __Pyx_INCREF(__pyx_t_12);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_8, function);
+        __pyx_t_5 = 1;
+      }
+    }
+    __pyx_t_13 = PyTuple_New(3+__pyx_t_5); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_13);
+    if (__pyx_t_12) {
+      __Pyx_GIVEREF(__pyx_t_12); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_12); __pyx_t_12 = NULL;
+    }
+    __Pyx_INCREF(__pyx_v_rname);
+    __Pyx_GIVEREF(__pyx_v_rname);
+    PyTuple_SET_ITEM(__pyx_t_13, 0+__pyx_t_5, __pyx_v_rname);
+    __Pyx_GIVEREF(__pyx_t_10);
+    PyTuple_SET_ITEM(__pyx_t_13, 1+__pyx_t_5, __pyx_t_10);
+    __Pyx_GIVEREF(__pyx_t_11);
+    PyTuple_SET_ITEM(__pyx_t_13, 2+__pyx_t_5, __pyx_t_11);
+    __pyx_t_10 = 0;
+    __pyx_t_11 = 0;
+    __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_8, __pyx_t_13, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_9);
+    __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+    __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    __pyx_t_8 = NULL;
+    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
+      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_7);
+      if (likely(__pyx_t_8)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
+        __Pyx_INCREF(__pyx_t_8);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_7, function);
+      }
+    }
+    if (!__pyx_t_8) {
+      __pyx_t_6 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_t_9); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __Pyx_GOTREF(__pyx_t_6);
+    } else {
+      __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_13);
+      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_8); __pyx_t_8 = NULL;
+      __Pyx_GIVEREF(__pyx_t_9);
+      PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_t_9);
+      __pyx_t_9 = 0;
+      __pyx_t_6 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_13, NULL); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+    __Pyx_Raise(__pyx_t_6, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 51; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+
+  /* "cutadapt/_seqio.pyx":41
+ * 		public bint twoheaders
+ * 
+ * 	def __init__(self, str name, str sequence, str qualities=None,             # <<<<<<<<<<<<<<
+ * 			  bint twoheaders=False, match=None):
+ * 		"""Set qualities to None if there are no quality values"""
+ */
+
+  /* function exit code */
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_10);
+  __Pyx_XDECREF(__pyx_t_11);
+  __Pyx_XDECREF(__pyx_t_12);
+  __Pyx_XDECREF(__pyx_t_13);
+  __Pyx_AddTraceback("cutadapt._seqio.Sequence.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_rname);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "cutadapt/_seqio.pyx":54
+ * 				rname, len(qualities), len(sequence)))
+ * 
+ * 	def __getitem__(self, key):             # <<<<<<<<<<<<<<
+ * 		"""slicing"""
+ * 		return self.__class__(
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_8cutadapt_6_seqio_8Sequence_3__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key); /*proto*/
+static char __pyx_doc_8cutadapt_6_seqio_8Sequence_2__getitem__[] = "slicing";
+#if CYTHON_COMPILING_IN_CPYTHON
+struct wrapperbase __pyx_wrapperbase_8cutadapt_6_seqio_8Sequence_2__getitem__;
+#endif
+static PyObject *__pyx_pw_8cutadapt_6_seqio_8Sequence_3__getitem__(PyObject *__pyx_v_self, PyObject *__pyx_v_key) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__getitem__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_8Sequence_2__getitem__(((struct __pyx_obj_8cutadapt_6_seqio_Sequence *)__pyx_v_self), ((PyObject *)__pyx_v_key));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_8cutadapt_6_seqio_8Sequence_2__getitem__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self, PyObject *__pyx_v_key) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  int __pyx_t_5;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  Py_ssize_t __pyx_t_8;
+  PyObject *__pyx_t_9 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("__getitem__", 0);
+
+  /* "cutadapt/_seqio.pyx":56
+ * 	def __getitem__(self, key):
+ * 		"""slicing"""
+ * 		return self.__class__(             # <<<<<<<<<<<<<<
+ * 			self.name,
+ * 			self.sequence[key],
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(((PyObject *)__pyx_v_self), __pyx_n_s_class); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+
+  /* "cutadapt/_seqio.pyx":58
+ * 		return self.__class__(
+ * 			self.name,
+ * 			self.sequence[key],             # <<<<<<<<<<<<<<
+ * 			self.qualities[key] if self.qualities is not None else None,
+ * 			self.twoheaders,
+ */
+  __pyx_t_3 = PyObject_GetItem(__pyx_v_self->sequence, __pyx_v_key); if (unlikely(__pyx_t_3 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 58; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __Pyx_GOTREF(__pyx_t_3);
+
+  /* "cutadapt/_seqio.pyx":59
+ * 			self.name,
+ * 			self.sequence[key],
+ * 			self.qualities[key] if self.qualities is not None else None,             # <<<<<<<<<<<<<<
+ * 			self.twoheaders,
+ * 			self.match)
+ */
+  __pyx_t_5 = (__pyx_v_self->qualities != ((PyObject*)Py_None));
+  if ((__pyx_t_5 != 0)) {
+    __pyx_t_6 = PyObject_GetItem(__pyx_v_self->qualities, __pyx_v_key); if (unlikely(__pyx_t_6 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 59; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_4 = __pyx_t_6;
+    __pyx_t_6 = 0;
+  } else {
+    __Pyx_INCREF(Py_None);
+    __pyx_t_4 = Py_None;
+  }
+
+  /* "cutadapt/_seqio.pyx":60
+ * 			self.sequence[key],
+ * 			self.qualities[key] if self.qualities is not None else None,
+ * 			self.twoheaders,             # <<<<<<<<<<<<<<
+ * 			self.match)
+ * 
+ */
+  __pyx_t_6 = __Pyx_PyBool_FromLong(__pyx_v_self->twoheaders); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 60; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_6);
+
+  /* "cutadapt/_seqio.pyx":61
+ * 			self.qualities[key] if self.qualities is not None else None,
+ * 			self.twoheaders,
+ * 			self.match)             # <<<<<<<<<<<<<<
+ * 
+ * 	def __repr__(self):
+ */
+  __pyx_t_7 = NULL;
+  __pyx_t_8 = 0;
+  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_7)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_7);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+      __pyx_t_8 = 1;
+    }
+  }
+  __pyx_t_9 = PyTuple_New(5+__pyx_t_8); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_9);
+  if (__pyx_t_7) {
+    __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
+  }
+  __Pyx_INCREF(__pyx_v_self->name);
+  __Pyx_GIVEREF(__pyx_v_self->name);
+  PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_8, __pyx_v_self->name);
+  __Pyx_GIVEREF(__pyx_t_3);
+  PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_8, __pyx_t_3);
+  __Pyx_GIVEREF(__pyx_t_4);
+  PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_8, __pyx_t_4);
+  __Pyx_GIVEREF(__pyx_t_6);
+  PyTuple_SET_ITEM(__pyx_t_9, 3+__pyx_t_8, __pyx_t_6);
+  __Pyx_INCREF(__pyx_v_self->match);
+  __Pyx_GIVEREF(__pyx_v_self->match);
+  PyTuple_SET_ITEM(__pyx_t_9, 4+__pyx_t_8, __pyx_v_self->match);
+  __pyx_t_3 = 0;
+  __pyx_t_4 = 0;
+  __pyx_t_6 = 0;
+  __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_t_9, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 56; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "cutadapt/_seqio.pyx":54
+ * 				rname, len(qualities), len(sequence)))
+ * 
+ * 	def __getitem__(self, key):             # <<<<<<<<<<<<<<
+ * 		"""slicing"""
+ * 		return self.__class__(
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_AddTraceback("cutadapt._seqio.Sequence.__getitem__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "cutadapt/_seqio.pyx":63
+ * 			self.match)
+ * 
+ * 	def __repr__(self):             # <<<<<<<<<<<<<<
+ * 		qstr = ''
+ * 		if self.qualities is not None:
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_8cutadapt_6_seqio_8Sequence_5__repr__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_8cutadapt_6_seqio_8Sequence_5__repr__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__repr__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_8Sequence_4__repr__(((struct __pyx_obj_8cutadapt_6_seqio_Sequence *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_8cutadapt_6_seqio_8Sequence_4__repr__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self) {
+  PyObject *__pyx_v_qstr = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  Py_ssize_t __pyx_t_10;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("__repr__", 0);
+
+  /* "cutadapt/_seqio.pyx":64
+ * 
+ * 	def __repr__(self):
+ * 		qstr = ''             # <<<<<<<<<<<<<<
+ * 		if self.qualities is not None:
+ * 			qstr = ', qualities={0!r}'.format(_shorten(self.qualities))
+ */
+  __Pyx_INCREF(__pyx_kp_s__2);
+  __pyx_v_qstr = __pyx_kp_s__2;
+
+  /* "cutadapt/_seqio.pyx":65
+ * 	def __repr__(self):
+ * 		qstr = ''
+ * 		if self.qualities is not None:             # <<<<<<<<<<<<<<
+ * 			qstr = ', qualities={0!r}'.format(_shorten(self.qualities))
+ * 		return '<Sequence(name={0!r}, sequence={1!r}{2})>'.format(_shorten(self.name), _shorten(self.sequence), qstr)
+ */
+  __pyx_t_1 = (__pyx_v_self->qualities != ((PyObject*)Py_None));
+  __pyx_t_2 = (__pyx_t_1 != 0);
+  if (__pyx_t_2) {
+
+    /* "cutadapt/_seqio.pyx":66
+ * 		qstr = ''
+ * 		if self.qualities is not None:
+ * 			qstr = ', qualities={0!r}'.format(_shorten(self.qualities))             # <<<<<<<<<<<<<<
+ * 		return '<Sequence(name={0!r}, sequence={1!r}{2})>'.format(_shorten(self.name), _shorten(self.sequence), qstr)
+ * 
+ */
+    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_qualities_0_r, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_6 = __Pyx_GetModuleGlobalName(__pyx_n_s_shorten); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_7 = NULL;
+    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_6))) {
+      __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_6);
+      if (likely(__pyx_t_7)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
+        __Pyx_INCREF(__pyx_t_7);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_6, function);
+      }
+    }
+    if (!__pyx_t_7) {
+      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_v_self->qualities); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+    } else {
+      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_8);
+      __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
+      __Pyx_INCREF(__pyx_v_self->qualities);
+      __Pyx_GIVEREF(__pyx_v_self->qualities);
+      PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_v_self->qualities);
+      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_8, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __pyx_t_6 = NULL;
+    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
+      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_4);
+      if (likely(__pyx_t_6)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+        __Pyx_INCREF(__pyx_t_6);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_4, function);
+      }
+    }
+    if (!__pyx_t_6) {
+      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_t_5); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_GOTREF(__pyx_t_3);
+    } else {
+      __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_8);
+      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_6); __pyx_t_6 = NULL;
+      __Pyx_GIVEREF(__pyx_t_5);
+      PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_5);
+      __pyx_t_5 = 0;
+      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_8, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 66; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF_SET(__pyx_v_qstr, __pyx_t_3);
+    __pyx_t_3 = 0;
+    goto __pyx_L3;
+  }
+  __pyx_L3:;
+
+  /* "cutadapt/_seqio.pyx":67
+ * 		if self.qualities is not None:
+ * 			qstr = ', qualities={0!r}'.format(_shorten(self.qualities))
+ * 		return '<Sequence(name={0!r}, sequence={1!r}{2})>'.format(_shorten(self.name), _shorten(self.sequence), qstr)             # <<<<<<<<<<<<<<
+ * 
+ * 	def __len__(self):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_Sequence_name_0_r_sequence_1_r, __pyx_n_s_format); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_5 = __Pyx_GetModuleGlobalName(__pyx_n_s_shorten); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_5);
+  __pyx_t_6 = NULL;
+  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_5))) {
+    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_5);
+    if (likely(__pyx_t_6)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+      __Pyx_INCREF(__pyx_t_6);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_5, function);
+    }
+  }
+  if (!__pyx_t_6) {
+    __pyx_t_8 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_v_self->name); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_8);
+  } else {
+    __pyx_t_7 = PyTuple_New(1+1); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_7, 0, __pyx_t_6); __pyx_t_6 = NULL;
+    __Pyx_INCREF(__pyx_v_self->name);
+    __Pyx_GIVEREF(__pyx_v_self->name);
+    PyTuple_SET_ITEM(__pyx_t_7, 0+1, __pyx_v_self->name);
+    __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_7, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_8);
+    __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+  __pyx_t_7 = __Pyx_GetModuleGlobalName(__pyx_n_s_shorten); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_7);
+  __pyx_t_6 = NULL;
+  if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_7))) {
+    __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_7);
+    if (likely(__pyx_t_6)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_7);
+      __Pyx_INCREF(__pyx_t_6);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_7, function);
+    }
+  }
+  if (!__pyx_t_6) {
+    __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_7, __pyx_v_self->sequence); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+  } else {
+    __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_9);
+    __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __pyx_t_6 = NULL;
+    __Pyx_INCREF(__pyx_v_self->sequence);
+    __Pyx_GIVEREF(__pyx_v_self->sequence);
+    PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_v_self->sequence);
+    __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_7, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+  __pyx_t_7 = NULL;
+  __pyx_t_10 = 0;
+  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
+    __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_4);
+    if (likely(__pyx_t_7)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+      __Pyx_INCREF(__pyx_t_7);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_4, function);
+      __pyx_t_10 = 1;
+    }
+  }
+  __pyx_t_9 = PyTuple_New(3+__pyx_t_10); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_9);
+  if (__pyx_t_7) {
+    __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_7); __pyx_t_7 = NULL;
+  }
+  __Pyx_GIVEREF(__pyx_t_8);
+  PyTuple_SET_ITEM(__pyx_t_9, 0+__pyx_t_10, __pyx_t_8);
+  __Pyx_GIVEREF(__pyx_t_5);
+  PyTuple_SET_ITEM(__pyx_t_9, 1+__pyx_t_10, __pyx_t_5);
+  __Pyx_INCREF(__pyx_v_qstr);
+  __Pyx_GIVEREF(__pyx_v_qstr);
+  PyTuple_SET_ITEM(__pyx_t_9, 2+__pyx_t_10, __pyx_v_qstr);
+  __pyx_t_8 = 0;
+  __pyx_t_5 = 0;
+  __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_9, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 67; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __pyx_r = __pyx_t_3;
+  __pyx_t_3 = 0;
+  goto __pyx_L0;
+
+  /* "cutadapt/_seqio.pyx":63
+ * 			self.match)
+ * 
+ * 	def __repr__(self):             # <<<<<<<<<<<<<<
+ * 		qstr = ''
+ * 		if self.qualities is not None:
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_AddTraceback("cutadapt._seqio.Sequence.__repr__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_qstr);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "cutadapt/_seqio.pyx":69
+ * 		return '<Sequence(name={0!r}, sequence={1!r}{2})>'.format(_shorten(self.name), _shorten(self.sequence), qstr)
+ * 
+ * 	def __len__(self):             # <<<<<<<<<<<<<<
+ * 		return len(self.sequence)
+ * 
+ */
+
+/* Python wrapper */
+static Py_ssize_t __pyx_pw_8cutadapt_6_seqio_8Sequence_7__len__(PyObject *__pyx_v_self); /*proto*/
+static Py_ssize_t __pyx_pw_8cutadapt_6_seqio_8Sequence_7__len__(PyObject *__pyx_v_self) {
+  Py_ssize_t __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__len__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_8Sequence_6__len__(((struct __pyx_obj_8cutadapt_6_seqio_Sequence *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static Py_ssize_t __pyx_pf_8cutadapt_6_seqio_8Sequence_6__len__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self) {
+  Py_ssize_t __pyx_r;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  Py_ssize_t __pyx_t_2;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("__len__", 0);
+
+  /* "cutadapt/_seqio.pyx":70
+ * 
+ * 	def __len__(self):
+ * 		return len(self.sequence)             # <<<<<<<<<<<<<<
+ * 
+ * 	def __richcmp__(self, other, int op):
+ */
+  __pyx_t_1 = __pyx_v_self->sequence;
+  __Pyx_INCREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_Length(__pyx_t_1); if (unlikely(__pyx_t_2 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 70; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_r = __pyx_t_2;
+  goto __pyx_L0;
+
+  /* "cutadapt/_seqio.pyx":69
+ * 		return '<Sequence(name={0!r}, sequence={1!r}{2})>'.format(_shorten(self.name), _shorten(self.sequence), qstr)
+ * 
+ * 	def __len__(self):             # <<<<<<<<<<<<<<
+ * 		return len(self.sequence)
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("cutadapt._seqio.Sequence.__len__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "cutadapt/_seqio.pyx":72
+ * 		return len(self.sequence)
+ * 
+ * 	def __richcmp__(self, other, int op):             # <<<<<<<<<<<<<<
+ * 		if 2 <= op <= 3:
+ * 			eq = self.name == other.name and \
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_8cutadapt_6_seqio_8Sequence_9__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op); /*proto*/
+static PyObject *__pyx_pw_8cutadapt_6_seqio_8Sequence_9__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__richcmp__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_8Sequence_8__richcmp__(((PyObject *)__pyx_v_self), ((PyObject *)__pyx_v_other), ((int)__pyx_v_op));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_8cutadapt_6_seqio_8Sequence_8__richcmp__(PyObject *__pyx_v_self, PyObject *__pyx_v_other, int __pyx_v_op) {
+  PyObject *__pyx_v_eq = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("__richcmp__", 0);
+
+  /* "cutadapt/_seqio.pyx":73
+ * 
+ * 	def __richcmp__(self, other, int op):
+ * 		if 2 <= op <= 3:             # <<<<<<<<<<<<<<
+ * 			eq = self.name == other.name and \
+ * 				self.sequence == other.sequence and \
+ */
+  __pyx_t_1 = (2 <= __pyx_v_op);
+  if (__pyx_t_1) {
+    __pyx_t_1 = (__pyx_v_op <= 3);
+  }
+  __pyx_t_2 = (__pyx_t_1 != 0);
+  if (__pyx_t_2) {
+
+    /* "cutadapt/_seqio.pyx":74
+ * 	def __richcmp__(self, other, int op):
+ * 		if 2 <= op <= 3:
+ * 			eq = self.name == other.name and \             # <<<<<<<<<<<<<<
+ * 				self.sequence == other.sequence and \
+ * 				self.qualities == other.qualities
+ */
+    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_name); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_name); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = PyObject_RichCompare(__pyx_t_4, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_6); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 74; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__pyx_t_2) {
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    } else {
+      __Pyx_INCREF(__pyx_t_6);
+      __pyx_t_3 = __pyx_t_6;
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+      goto __pyx_L4_bool_binop_done;
+    }
+
+    /* "cutadapt/_seqio.pyx":75
+ * 		if 2 <= op <= 3:
+ * 			eq = self.name == other.name and \
+ * 				self.sequence == other.sequence and \             # <<<<<<<<<<<<<<
+ * 				self.qualities == other.qualities
+ * 			if op == 2:
+ */
+    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_sequence); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_sequence); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_4 = PyObject_RichCompare(__pyx_t_6, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_t_4); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 75; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (__pyx_t_2) {
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    } else {
+      __Pyx_INCREF(__pyx_t_4);
+      __pyx_t_3 = __pyx_t_4;
+      __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+      goto __pyx_L4_bool_binop_done;
+    }
+
+    /* "cutadapt/_seqio.pyx":76
+ * 			eq = self.name == other.name and \
+ * 				self.sequence == other.sequence and \
+ * 				self.qualities == other.qualities             # <<<<<<<<<<<<<<
+ * 			if op == 2:
+ * 				return eq
+ */
+    __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_qualities); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_other, __pyx_n_s_qualities); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = PyObject_RichCompare(__pyx_t_4, __pyx_t_5, Py_EQ); __Pyx_XGOTREF(__pyx_t_6); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 76; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __Pyx_INCREF(__pyx_t_6);
+    __pyx_t_3 = __pyx_t_6;
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __pyx_L4_bool_binop_done:;
+    __pyx_v_eq = __pyx_t_3;
+    __pyx_t_3 = 0;
+
+    /* "cutadapt/_seqio.pyx":77
+ * 				self.sequence == other.sequence and \
+ * 				self.qualities == other.qualities
+ * 			if op == 2:             # <<<<<<<<<<<<<<
+ * 				return eq
+ * 			else:
+ */
+    __pyx_t_2 = ((__pyx_v_op == 2) != 0);
+    if (__pyx_t_2) {
+
+      /* "cutadapt/_seqio.pyx":78
+ * 				self.qualities == other.qualities
+ * 			if op == 2:
+ * 				return eq             # <<<<<<<<<<<<<<
+ * 			else:
+ * 				return not eq
+ */
+      __Pyx_XDECREF(__pyx_r);
+      __Pyx_INCREF(__pyx_v_eq);
+      __pyx_r = __pyx_v_eq;
+      goto __pyx_L0;
+    }
+    /*else*/ {
+
+      /* "cutadapt/_seqio.pyx":80
+ * 				return eq
+ * 			else:
+ * 				return not eq             # <<<<<<<<<<<<<<
+ * 		else:
+ * 			raise NotImplementedError()
+ */
+      __Pyx_XDECREF(__pyx_r);
+      __pyx_t_2 = __Pyx_PyObject_IsTrue(__pyx_v_eq); if (unlikely(__pyx_t_2 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_3 = __Pyx_PyBool_FromLong((!__pyx_t_2)); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 80; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __pyx_r = __pyx_t_3;
+      __pyx_t_3 = 0;
+      goto __pyx_L0;
+    }
+  }
+  /*else*/ {
+
+    /* "cutadapt/_seqio.pyx":82
+ * 				return not eq
+ * 		else:
+ * 			raise NotImplementedError()             # <<<<<<<<<<<<<<
+ * 
+ * 	def __reduce__(self):
+ */
+    __pyx_t_3 = __Pyx_PyObject_CallNoArg(__pyx_builtin_NotImplementedError); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_Raise(__pyx_t_3, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+
+  /* "cutadapt/_seqio.pyx":72
+ * 		return len(self.sequence)
+ * 
+ * 	def __richcmp__(self, other, int op):             # <<<<<<<<<<<<<<
+ * 		if 2 <= op <= 3:
+ * 			eq = self.name == other.name and \
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("cutadapt._seqio.Sequence.__richcmp__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_eq);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "cutadapt/_seqio.pyx":84
+ * 			raise NotImplementedError()
+ * 
+ * 	def __reduce__(self):             # <<<<<<<<<<<<<<
+ * 		return (Sequence, (self.name, self.sequence, self.qualities, self.twoheaders))
+ * 
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_8cutadapt_6_seqio_8Sequence_11__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused); /*proto*/
+static PyObject *__pyx_pw_8cutadapt_6_seqio_8Sequence_11__reduce__(PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *unused) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__reduce__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_8Sequence_10__reduce__(((struct __pyx_obj_8cutadapt_6_seqio_Sequence *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_8cutadapt_6_seqio_8Sequence_10__reduce__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("__reduce__", 0);
+
+  /* "cutadapt/_seqio.pyx":85
+ * 
+ * 	def __reduce__(self):
+ * 		return (Sequence, (self.name, self.sequence, self.qualities, self.twoheaders))             # <<<<<<<<<<<<<<
+ * 
+ * 	def write(self, outfile):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->twoheaders); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyTuple_New(4); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_v_self->name);
+  __Pyx_GIVEREF(__pyx_v_self->name);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_v_self->name);
+  __Pyx_INCREF(__pyx_v_self->sequence);
+  __Pyx_GIVEREF(__pyx_v_self->sequence);
+  PyTuple_SET_ITEM(__pyx_t_2, 1, __pyx_v_self->sequence);
+  __Pyx_INCREF(__pyx_v_self->qualities);
+  __Pyx_GIVEREF(__pyx_v_self->qualities);
+  PyTuple_SET_ITEM(__pyx_t_2, 2, __pyx_v_self->qualities);
+  __Pyx_GIVEREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_2, 3, __pyx_t_1);
+  __pyx_t_1 = 0;
+  __pyx_t_1 = PyTuple_New(2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 85; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_8cutadapt_6_seqio_Sequence)));
+  __Pyx_GIVEREF(((PyObject *)((PyObject*)__pyx_ptype_8cutadapt_6_seqio_Sequence)));
+  PyTuple_SET_ITEM(__pyx_t_1, 0, ((PyObject *)((PyObject*)__pyx_ptype_8cutadapt_6_seqio_Sequence)));
+  __Pyx_GIVEREF(__pyx_t_2);
+  PyTuple_SET_ITEM(__pyx_t_1, 1, __pyx_t_2);
+  __pyx_t_2 = 0;
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* "cutadapt/_seqio.pyx":84
+ * 			raise NotImplementedError()
+ * 
+ * 	def __reduce__(self):             # <<<<<<<<<<<<<<
+ * 		return (Sequence, (self.name, self.sequence, self.qualities, self.twoheaders))
+ * 
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("cutadapt._seqio.Sequence.__reduce__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "cutadapt/_seqio.pyx":87
+ * 		return (Sequence, (self.name, self.sequence, self.qualities, self.twoheaders))
+ * 
+ * 	def write(self, outfile):             # <<<<<<<<<<<<<<
+ * 		if self.qualities is not None:
+ * 			s = '@' + self.name + '\n' + self.sequence + '\n+'
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_8cutadapt_6_seqio_8Sequence_13write(PyObject *__pyx_v_self, PyObject *__pyx_v_outfile); /*proto*/
+static PyObject *__pyx_pw_8cutadapt_6_seqio_8Sequence_13write(PyObject *__pyx_v_self, PyObject *__pyx_v_outfile) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("write (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_8Sequence_12write(((struct __pyx_obj_8cutadapt_6_seqio_Sequence *)__pyx_v_self), ((PyObject *)__pyx_v_outfile));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_8cutadapt_6_seqio_8Sequence_12write(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self, PyObject *__pyx_v_outfile) {
+  PyObject *__pyx_v_s = NULL;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("write", 0);
+
+  /* "cutadapt/_seqio.pyx":88
+ * 
+ * 	def write(self, outfile):
+ * 		if self.qualities is not None:             # <<<<<<<<<<<<<<
+ * 			s = '@' + self.name + '\n' + self.sequence + '\n+'
+ * 			if self.twoheaders:
+ */
+  __pyx_t_1 = (__pyx_v_self->qualities != ((PyObject*)Py_None));
+  __pyx_t_2 = (__pyx_t_1 != 0);
+  if (__pyx_t_2) {
+
+    /* "cutadapt/_seqio.pyx":89
+ * 	def write(self, outfile):
+ * 		if self.qualities is not None:
+ * 			s = '@' + self.name + '\n' + self.sequence + '\n+'             # <<<<<<<<<<<<<<
+ * 			if self.twoheaders:
+ * 				s += self.name
+ */
+    __pyx_t_3 = PyNumber_Add(__pyx_kp_s__3, __pyx_v_self->name); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_kp_s__4); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_v_self->sequence); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_kp_s__5); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 89; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_v_s = __pyx_t_4;
+    __pyx_t_4 = 0;
+
+    /* "cutadapt/_seqio.pyx":90
+ * 		if self.qualities is not None:
+ * 			s = '@' + self.name + '\n' + self.sequence + '\n+'
+ * 			if self.twoheaders:             # <<<<<<<<<<<<<<
+ * 				s += self.name
+ * 			s += '\n' + self.qualities + '\n'
+ */
+    __pyx_t_2 = (__pyx_v_self->twoheaders != 0);
+    if (__pyx_t_2) {
+
+      /* "cutadapt/_seqio.pyx":91
+ * 			s = '@' + self.name + '\n' + self.sequence + '\n+'
+ * 			if self.twoheaders:
+ * 				s += self.name             # <<<<<<<<<<<<<<
+ * 			s += '\n' + self.qualities + '\n'
+ * 		else:
+ */
+      __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_s, __pyx_v_self->name); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 91; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_4);
+      __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_4);
+      __pyx_t_4 = 0;
+      goto __pyx_L4;
+    }
+    __pyx_L4:;
+
+    /* "cutadapt/_seqio.pyx":92
+ * 			if self.twoheaders:
+ * 				s += self.name
+ * 			s += '\n' + self.qualities + '\n'             # <<<<<<<<<<<<<<
+ * 		else:
+ * 			s = '>' + self.name + '\n' + self.sequence + '\n'
+ */
+    __pyx_t_4 = PyNumber_Add(__pyx_kp_s__4, __pyx_v_self->qualities); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_kp_s__4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_4 = PyNumber_InPlaceAdd(__pyx_v_s, __pyx_t_3); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 92; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __Pyx_DECREF_SET(__pyx_v_s, __pyx_t_4);
+    __pyx_t_4 = 0;
+    goto __pyx_L3;
+  }
+  /*else*/ {
+
+    /* "cutadapt/_seqio.pyx":94
+ * 			s += '\n' + self.qualities + '\n'
+ * 		else:
+ * 			s = '>' + self.name + '\n' + self.sequence + '\n'             # <<<<<<<<<<<<<<
+ * 		outfile.write(s)
+ * 
+ */
+    __pyx_t_4 = PyNumber_Add(__pyx_kp_s__6, __pyx_v_self->name); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_kp_s__4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_t_4 = PyNumber_Add(__pyx_t_3, __pyx_v_self->sequence); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+    __pyx_t_3 = PyNumber_Add(__pyx_t_4, __pyx_kp_s__4); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 94; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __pyx_v_s = __pyx_t_3;
+    __pyx_t_3 = 0;
+  }
+  __pyx_L3:;
+
+  /* "cutadapt/_seqio.pyx":95
+ * 		else:
+ * 			s = '>' + self.name + '\n' + self.sequence + '\n'
+ * 		outfile.write(s)             # <<<<<<<<<<<<<<
+ * 
+ * 
+ */
+  __pyx_t_4 = __Pyx_PyObject_GetAttrStr(__pyx_v_outfile, __pyx_n_s_write); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  __pyx_t_5 = NULL;
+  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_4))) {
+    __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
+    if (likely(__pyx_t_5)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+      __Pyx_INCREF(__pyx_t_5);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_4, function);
+    }
+  }
+  if (!__pyx_t_5) {
+    __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_s); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+  } else {
+    __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
+    __Pyx_INCREF(__pyx_v_s);
+    __Pyx_GIVEREF(__pyx_v_s);
+    PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_s);
+    __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 95; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_3);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+  }
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+
+  /* "cutadapt/_seqio.pyx":87
+ * 		return (Sequence, (self.name, self.sequence, self.qualities, self.twoheaders))
+ * 
+ * 	def write(self, outfile):             # <<<<<<<<<<<<<<
+ * 		if self.qualities is not None:
+ * 			s = '@' + self.name + '\n' + self.sequence + '\n+'
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("cutadapt._seqio.Sequence.write", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_s);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "cutadapt/_seqio.pyx":35
+ * 	"""
+ * 	cdef:
+ * 		public str name             # <<<<<<<<<<<<<<
+ * 		public str sequence
+ * 		public str qualities
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_8cutadapt_6_seqio_8Sequence_4name_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_8cutadapt_6_seqio_8Sequence_4name_1__get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_8Sequence_4name___get__(((struct __pyx_obj_8cutadapt_6_seqio_Sequence *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_8cutadapt_6_seqio_8Sequence_4name___get__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__", 0);
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_self->name);
+  __pyx_r = __pyx_v_self->name;
+  goto __pyx_L0;
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_8cutadapt_6_seqio_8Sequence_4name_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
+static int __pyx_pw_8cutadapt_6_seqio_8Sequence_4name_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_8Sequence_4name_2__set__(((struct __pyx_obj_8cutadapt_6_seqio_Sequence *)__pyx_v_self), ((PyObject *)__pyx_v_value));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static int __pyx_pf_8cutadapt_6_seqio_8Sequence_4name_2__set__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self, PyObject *__pyx_v_value) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("__set__", 0);
+  if (!(likely(PyString_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 35; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __pyx_v_value;
+  __Pyx_INCREF(__pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_GOTREF(__pyx_v_self->name);
+  __Pyx_DECREF(__pyx_v_self->name);
+  __pyx_v_self->name = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* function exit code */
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("cutadapt._seqio.Sequence.name.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_8cutadapt_6_seqio_8Sequence_4name_5__del__(PyObject *__pyx_v_self); /*proto*/
+static int __pyx_pw_8cutadapt_6_seqio_8Sequence_4name_5__del__(PyObject *__pyx_v_self) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_8Sequence_4name_4__del__(((struct __pyx_obj_8cutadapt_6_seqio_Sequence *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static int __pyx_pf_8cutadapt_6_seqio_8Sequence_4name_4__del__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__del__", 0);
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->name);
+  __Pyx_DECREF(__pyx_v_self->name);
+  __pyx_v_self->name = ((PyObject*)Py_None);
+
+  /* function exit code */
+  __pyx_r = 0;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "cutadapt/_seqio.pyx":36
+ * 	cdef:
+ * 		public str name
+ * 		public str sequence             # <<<<<<<<<<<<<<
+ * 		public str qualities
+ * 		public object match
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_8cutadapt_6_seqio_8Sequence_8sequence_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_8cutadapt_6_seqio_8Sequence_8sequence_1__get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_8Sequence_8sequence___get__(((struct __pyx_obj_8cutadapt_6_seqio_Sequence *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_8cutadapt_6_seqio_8Sequence_8sequence___get__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__", 0);
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_self->sequence);
+  __pyx_r = __pyx_v_self->sequence;
+  goto __pyx_L0;
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_8cutadapt_6_seqio_8Sequence_8sequence_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
+static int __pyx_pw_8cutadapt_6_seqio_8Sequence_8sequence_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_8Sequence_8sequence_2__set__(((struct __pyx_obj_8cutadapt_6_seqio_Sequence *)__pyx_v_self), ((PyObject *)__pyx_v_value));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static int __pyx_pf_8cutadapt_6_seqio_8Sequence_8sequence_2__set__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self, PyObject *__pyx_v_value) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("__set__", 0);
+  if (!(likely(PyString_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 36; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __pyx_v_value;
+  __Pyx_INCREF(__pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_GOTREF(__pyx_v_self->sequence);
+  __Pyx_DECREF(__pyx_v_self->sequence);
+  __pyx_v_self->sequence = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* function exit code */
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("cutadapt._seqio.Sequence.sequence.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_8cutadapt_6_seqio_8Sequence_8sequence_5__del__(PyObject *__pyx_v_self); /*proto*/
+static int __pyx_pw_8cutadapt_6_seqio_8Sequence_8sequence_5__del__(PyObject *__pyx_v_self) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_8Sequence_8sequence_4__del__(((struct __pyx_obj_8cutadapt_6_seqio_Sequence *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static int __pyx_pf_8cutadapt_6_seqio_8Sequence_8sequence_4__del__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__del__", 0);
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->sequence);
+  __Pyx_DECREF(__pyx_v_self->sequence);
+  __pyx_v_self->sequence = ((PyObject*)Py_None);
+
+  /* function exit code */
+  __pyx_r = 0;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "cutadapt/_seqio.pyx":37
+ * 		public str name
+ * 		public str sequence
+ * 		public str qualities             # <<<<<<<<<<<<<<
+ * 		public object match
+ * 		public bint twoheaders
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_8cutadapt_6_seqio_8Sequence_9qualities_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_8cutadapt_6_seqio_8Sequence_9qualities_1__get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_8Sequence_9qualities___get__(((struct __pyx_obj_8cutadapt_6_seqio_Sequence *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_8cutadapt_6_seqio_8Sequence_9qualities___get__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__", 0);
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_self->qualities);
+  __pyx_r = __pyx_v_self->qualities;
+  goto __pyx_L0;
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_8cutadapt_6_seqio_8Sequence_9qualities_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
+static int __pyx_pw_8cutadapt_6_seqio_8Sequence_9qualities_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_8Sequence_9qualities_2__set__(((struct __pyx_obj_8cutadapt_6_seqio_Sequence *)__pyx_v_self), ((PyObject *)__pyx_v_value));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static int __pyx_pf_8cutadapt_6_seqio_8Sequence_9qualities_2__set__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self, PyObject *__pyx_v_value) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("__set__", 0);
+  if (!(likely(PyString_CheckExact(__pyx_v_value))||((__pyx_v_value) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_v_value)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 37; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_t_1 = __pyx_v_value;
+  __Pyx_INCREF(__pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  __Pyx_GOTREF(__pyx_v_self->qualities);
+  __Pyx_DECREF(__pyx_v_self->qualities);
+  __pyx_v_self->qualities = ((PyObject*)__pyx_t_1);
+  __pyx_t_1 = 0;
+
+  /* function exit code */
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("cutadapt._seqio.Sequence.qualities.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_8cutadapt_6_seqio_8Sequence_9qualities_5__del__(PyObject *__pyx_v_self); /*proto*/
+static int __pyx_pw_8cutadapt_6_seqio_8Sequence_9qualities_5__del__(PyObject *__pyx_v_self) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_8Sequence_9qualities_4__del__(((struct __pyx_obj_8cutadapt_6_seqio_Sequence *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static int __pyx_pf_8cutadapt_6_seqio_8Sequence_9qualities_4__del__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__del__", 0);
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->qualities);
+  __Pyx_DECREF(__pyx_v_self->qualities);
+  __pyx_v_self->qualities = ((PyObject*)Py_None);
+
+  /* function exit code */
+  __pyx_r = 0;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "cutadapt/_seqio.pyx":38
+ * 		public str sequence
+ * 		public str qualities
+ * 		public object match             # <<<<<<<<<<<<<<
+ * 		public bint twoheaders
+ * 
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_8cutadapt_6_seqio_8Sequence_5match_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_8cutadapt_6_seqio_8Sequence_5match_1__get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_8Sequence_5match___get__(((struct __pyx_obj_8cutadapt_6_seqio_Sequence *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_8cutadapt_6_seqio_8Sequence_5match___get__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__", 0);
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_self->match);
+  __pyx_r = __pyx_v_self->match;
+  goto __pyx_L0;
+
+  /* function exit code */
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_8cutadapt_6_seqio_8Sequence_5match_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
+static int __pyx_pw_8cutadapt_6_seqio_8Sequence_5match_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_8Sequence_5match_2__set__(((struct __pyx_obj_8cutadapt_6_seqio_Sequence *)__pyx_v_self), ((PyObject *)__pyx_v_value));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static int __pyx_pf_8cutadapt_6_seqio_8Sequence_5match_2__set__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self, PyObject *__pyx_v_value) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__set__", 0);
+  __Pyx_INCREF(__pyx_v_value);
+  __Pyx_GIVEREF(__pyx_v_value);
+  __Pyx_GOTREF(__pyx_v_self->match);
+  __Pyx_DECREF(__pyx_v_self->match);
+  __pyx_v_self->match = __pyx_v_value;
+
+  /* function exit code */
+  __pyx_r = 0;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_8cutadapt_6_seqio_8Sequence_5match_5__del__(PyObject *__pyx_v_self); /*proto*/
+static int __pyx_pw_8cutadapt_6_seqio_8Sequence_5match_5__del__(PyObject *__pyx_v_self) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__del__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_8Sequence_5match_4__del__(((struct __pyx_obj_8cutadapt_6_seqio_Sequence *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static int __pyx_pf_8cutadapt_6_seqio_8Sequence_5match_4__del__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__del__", 0);
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  __Pyx_GOTREF(__pyx_v_self->match);
+  __Pyx_DECREF(__pyx_v_self->match);
+  __pyx_v_self->match = Py_None;
+
+  /* function exit code */
+  __pyx_r = 0;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "cutadapt/_seqio.pyx":39
+ * 		public str qualities
+ * 		public object match
+ * 		public bint twoheaders             # <<<<<<<<<<<<<<
+ * 
+ * 	def __init__(self, str name, str sequence, str qualities=None,
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_8cutadapt_6_seqio_8Sequence_10twoheaders_1__get__(PyObject *__pyx_v_self); /*proto*/
+static PyObject *__pyx_pw_8cutadapt_6_seqio_8Sequence_10twoheaders_1__get__(PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__get__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_8Sequence_10twoheaders___get__(((struct __pyx_obj_8cutadapt_6_seqio_Sequence *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_8cutadapt_6_seqio_8Sequence_10twoheaders___get__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("__get__", 0);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = __Pyx_PyBool_FromLong(__pyx_v_self->twoheaders); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_r = __pyx_t_1;
+  __pyx_t_1 = 0;
+  goto __pyx_L0;
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("cutadapt._seqio.Sequence.twoheaders.__get__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static int __pyx_pw_8cutadapt_6_seqio_8Sequence_10twoheaders_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value); /*proto*/
+static int __pyx_pw_8cutadapt_6_seqio_8Sequence_10twoheaders_3__set__(PyObject *__pyx_v_self, PyObject *__pyx_v_value) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__set__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_8Sequence_10twoheaders_2__set__(((struct __pyx_obj_8cutadapt_6_seqio_Sequence *)__pyx_v_self), ((PyObject *)__pyx_v_value));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static int __pyx_pf_8cutadapt_6_seqio_8Sequence_10twoheaders_2__set__(struct __pyx_obj_8cutadapt_6_seqio_Sequence *__pyx_v_self, PyObject *__pyx_v_value) {
+  int __pyx_r;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("__set__", 0);
+  __pyx_t_1 = __Pyx_PyObject_IsTrue(__pyx_v_value); if (unlikely((__pyx_t_1 == (int)-1) && PyErr_Occurred())) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 39; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_v_self->twoheaders = __pyx_t_1;
+
+  /* function exit code */
+  __pyx_r = 0;
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("cutadapt._seqio.Sequence.twoheaders.__set__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = -1;
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "cutadapt/_seqio.pyx":102
+ * 	Reader for FASTQ files. Does not support multi-line FASTQ files.
+ * 	"""
+ * 	def __init__(self, file, sequence_class=Sequence):             # <<<<<<<<<<<<<<
+ * 		"""
+ * 		file is a filename or a file-like object.
+ */
+
+static PyObject *__pyx_pf_8cutadapt_6_seqio_11FastqReader_11__defaults__(CYTHON_UNUSED PyObject *__pyx_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("__defaults__", 0);
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_t_1 = PyTuple_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(__Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self)->__pyx_arg_sequence_class);
+  __Pyx_GIVEREF(__Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self)->__pyx_arg_sequence_class);
+  PyTuple_SET_ITEM(__pyx_t_1, 0, __Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self)->__pyx_arg_sequence_class);
+  __pyx_t_2 = PyTuple_New(2); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_1);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_t_1);
+  __Pyx_INCREF(Py_None);
+  __Pyx_GIVEREF(Py_None);
+  PyTuple_SET_ITEM(__pyx_t_2, 1, Py_None);
+  __pyx_t_1 = 0;
+  __pyx_r = __pyx_t_2;
+  __pyx_t_2 = 0;
+  goto __pyx_L0;
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_AddTraceback("cutadapt._seqio.FastqReader.__defaults__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* Python wrapper */
+static PyObject *__pyx_pw_8cutadapt_6_seqio_11FastqReader_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static char __pyx_doc_8cutadapt_6_seqio_11FastqReader___init__[] = "\n\t\tfile is a filename or a file-like object.\n\t\tIf file is a filename, then .gz files are supported.\n\n\t\tcolorspace -- Usually (when this is False), there must be n characters in the sequence and\n\t\tn quality values. When this is True, there must be n+1 characters in the sequence and n quality values.\n\t\t";
+static PyMethodDef __pyx_mdef_8cutadapt_6_seqio_11FastqReader_1__init__ = {"__init__", (PyCFunction)__pyx_pw_8cutadapt_6_seqio_11FastqReader_1__init__, METH_VARARGS|METH_KEYWORDS, __pyx_doc_8cutadapt_6_seqio_11FastqReader___init__};
+static PyObject *__pyx_pw_8cutadapt_6_seqio_11FastqReader_1__init__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  PyObject *__pyx_v_file = 0;
+  PyObject *__pyx_v_sequence_class = 0;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__init__ (wrapper)", 0);
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,&__pyx_n_s_file,&__pyx_n_s_sequence_class,0};
+    PyObject* values[3] = {0,0,0};
+    __pyx_defaults *__pyx_dynamic_args = __Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_self);
+    values[2] = __pyx_dynamic_args->__pyx_arg_sequence_class;
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+        case  1:
+        if (likely((values[1] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_file)) != 0)) kw_args--;
+        else {
+          __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, 1); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+        }
+        case  2:
+        if (kw_args > 0) {
+          PyObject* value = PyDict_GetItem(__pyx_kwds, __pyx_n_s_sequence_class);
+          if (value) { values[2] = value; kw_args--; }
+        }
+      }
+      if (unlikely(kw_args > 0)) {
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, pos_args, "__init__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    } else {
+      switch (PyTuple_GET_SIZE(__pyx_args)) {
+        case  3: values[2] = PyTuple_GET_ITEM(__pyx_args, 2);
+        case  2: values[1] = PyTuple_GET_ITEM(__pyx_args, 1);
+        values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        break;
+        default: goto __pyx_L5_argtuple_error;
+      }
+    }
+    __pyx_v_self = values[0];
+    __pyx_v_file = values[1];
+    __pyx_v_sequence_class = values[2];
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("__init__", 0, 2, 3, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_AddTraceback("cutadapt._seqio.FastqReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_11FastqReader___init__(__pyx_self, __pyx_v_self, __pyx_v_file, __pyx_v_sequence_class);
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_8cutadapt_6_seqio_11FastqReader___init__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, PyObject *__pyx_v_file, PyObject *__pyx_v_sequence_class) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  int __pyx_t_2;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("__init__", 0);
+  __Pyx_INCREF(__pyx_v_file);
+
+  /* "cutadapt/_seqio.pyx":110
+ * 		n quality values. When this is True, there must be n+1 characters in the sequence and n quality values.
+ * 		"""
+ * 		if isinstance(file, basestring):             # <<<<<<<<<<<<<<
+ * 			file = xopen(file)
+ * 			self._file_passed = False
+ */
+  __pyx_t_1 = __Pyx_PyBaseString_Check(__pyx_v_file); 
+  __pyx_t_2 = (__pyx_t_1 != 0);
+  if (__pyx_t_2) {
+
+    /* "cutadapt/_seqio.pyx":111
+ * 		"""
+ * 		if isinstance(file, basestring):
+ * 			file = xopen(file)             # <<<<<<<<<<<<<<
+ * 			self._file_passed = False
+ * 		else:
+ */
+    __pyx_t_4 = __Pyx_GetModuleGlobalName(__pyx_n_s_xopen); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_4);
+    __pyx_t_5 = NULL;
+    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_4))) {
+      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_4);
+      if (likely(__pyx_t_5)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_4);
+        __Pyx_INCREF(__pyx_t_5);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_4, function);
+      }
+    }
+    if (!__pyx_t_5) {
+      __pyx_t_3 = __Pyx_PyObject_CallOneArg(__pyx_t_4, __pyx_v_file); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+    } else {
+      __pyx_t_6 = PyTuple_New(1+1); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_6);
+      __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_6, 0, __pyx_t_5); __pyx_t_5 = NULL;
+      __Pyx_INCREF(__pyx_v_file);
+      __Pyx_GIVEREF(__pyx_v_file);
+      PyTuple_SET_ITEM(__pyx_t_6, 0+1, __pyx_v_file);
+      __pyx_t_3 = __Pyx_PyObject_Call(__pyx_t_4, __pyx_t_6, NULL); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 111; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_3);
+      __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+    __Pyx_DECREF_SET(__pyx_v_file, __pyx_t_3);
+    __pyx_t_3 = 0;
+
+    /* "cutadapt/_seqio.pyx":112
+ * 		if isinstance(file, basestring):
+ * 			file = xopen(file)
+ * 			self._file_passed = False             # <<<<<<<<<<<<<<
+ * 		else:
+ * 			self._file_passed = True
+ */
+    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_file_passed, Py_False) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 112; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L3;
+  }
+  /*else*/ {
+
+    /* "cutadapt/_seqio.pyx":114
+ * 			self._file_passed = False
+ * 		else:
+ * 			self._file_passed = True             # <<<<<<<<<<<<<<
+ * 		self.fp = file
+ * 		self.sequence_class = sequence_class
+ */
+    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_file_passed, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 114; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __pyx_L3:;
+
+  /* "cutadapt/_seqio.pyx":115
+ * 		else:
+ * 			self._file_passed = True
+ * 		self.fp = file             # <<<<<<<<<<<<<<
+ * 		self.sequence_class = sequence_class
+ * 		self.delivers_qualities = True
+ */
+  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_fp, __pyx_v_file) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 115; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "cutadapt/_seqio.pyx":116
+ * 			self._file_passed = True
+ * 		self.fp = file
+ * 		self.sequence_class = sequence_class             # <<<<<<<<<<<<<<
+ * 		self.delivers_qualities = True
+ * 
+ */
+  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_sequence_class, __pyx_v_sequence_class) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 116; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "cutadapt/_seqio.pyx":117
+ * 		self.fp = file
+ * 		self.sequence_class = sequence_class
+ * 		self.delivers_qualities = True             # <<<<<<<<<<<<<<
+ * 
+ * 	def __iter__(self):
+ */
+  if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_delivers_qualities, Py_True) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 117; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "cutadapt/_seqio.pyx":102
+ * 	Reader for FASTQ files. Does not support multi-line FASTQ files.
+ * 	"""
+ * 	def __init__(self, file, sequence_class=Sequence):             # <<<<<<<<<<<<<<
+ * 		"""
+ * 		file is a filename or a file-like object.
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("cutadapt._seqio.FastqReader.__init__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_v_file);
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+static PyObject *__pyx_gb_8cutadapt_6_seqio_11FastqReader_4generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value); /* proto */
+
+/* "cutadapt/_seqio.pyx":119
+ * 		self.delivers_qualities = True
+ * 
+ * 	def __iter__(self):             # <<<<<<<<<<<<<<
+ * 		"""
+ * 		Return tuples: (name, sequence, qualities).
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_8cutadapt_6_seqio_11FastqReader_3__iter__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
+static char __pyx_doc_8cutadapt_6_seqio_11FastqReader_2__iter__[] = "\n\t\tReturn tuples: (name, sequence, qualities).\n\t\tqualities is a string and it contains the unmodified, encoded qualities.\n\t\t";
+static PyMethodDef __pyx_mdef_8cutadapt_6_seqio_11FastqReader_3__iter__ = {"__iter__", (PyCFunction)__pyx_pw_8cutadapt_6_seqio_11FastqReader_3__iter__, METH_O, __pyx_doc_8cutadapt_6_seqio_11FastqReader_2__iter__};
+static PyObject *__pyx_pw_8cutadapt_6_seqio_11FastqReader_3__iter__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__iter__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_11FastqReader_2__iter__(__pyx_self, ((PyObject *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_8cutadapt_6_seqio_11FastqReader_2__iter__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
+  struct __pyx_obj_8cutadapt_6_seqio___pyx_scope_struct____iter__ *__pyx_cur_scope;
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("__iter__", 0);
+  __pyx_cur_scope = (struct __pyx_obj_8cutadapt_6_seqio___pyx_scope_struct____iter__ *)__pyx_tp_new_8cutadapt_6_seqio___pyx_scope_struct____iter__(__pyx_ptype_8cutadapt_6_seqio___pyx_scope_struct____iter__, __pyx_empty_tuple, NULL);
+  if (unlikely(!__pyx_cur_scope)) {
+    __Pyx_RefNannyFinishContext();
+    return NULL;
+  }
+  __Pyx_GOTREF(__pyx_cur_scope);
+  __pyx_cur_scope->__pyx_v_self = __pyx_v_self;
+  __Pyx_INCREF(__pyx_cur_scope->__pyx_v_self);
+  __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_self);
+  {
+    __pyx_GeneratorObject *gen = __Pyx_Generator_New((__pyx_generator_body_t) __pyx_gb_8cutadapt_6_seqio_11FastqReader_4generator, (PyObject *) __pyx_cur_scope, __pyx_n_s_iter, __pyx_n_s_FastqReader___iter); if (unlikely(!gen)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_cur_scope);
+    __Pyx_RefNannyFinishContext();
+    return (PyObject *) gen;
+  }
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_AddTraceback("cutadapt._seqio.FastqReader.__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __Pyx_DECREF(((PyObject *)__pyx_cur_scope));
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_gb_8cutadapt_6_seqio_11FastqReader_4generator(__pyx_GeneratorObject *__pyx_generator, PyObject *__pyx_sent_value) /* generator body */
+{
+  struct __pyx_obj_8cutadapt_6_seqio___pyx_scope_struct____iter__ *__pyx_cur_scope = ((struct __pyx_obj_8cutadapt_6_seqio___pyx_scope_struct____iter__ *)__pyx_generator->closure);
+  PyObject *__pyx_r = NULL;
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  int __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  PyObject *__pyx_t_7 = NULL;
+  PyObject *__pyx_t_8 = NULL;
+  PyObject *__pyx_t_9 = NULL;
+  int __pyx_t_10;
+  Py_ssize_t __pyx_t_11;
+  PyObject *(*__pyx_t_12)(PyObject *);
+  PyObject *__pyx_t_13 = NULL;
+  Py_ssize_t __pyx_t_14;
+  PyObject *__pyx_t_15 = NULL;
+  Py_ssize_t __pyx_t_16;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("None", 0);
+  switch (__pyx_generator->resume_label) {
+    case 0: goto __pyx_L3_first_run;
+    case 1: goto __pyx_L19_resume_from_yield;
+    default: /* CPython raises the right error here */
+    __Pyx_RefNannyFinishContext();
+    return NULL;
+  }
+  __pyx_L3_first_run:;
+  if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "cutadapt/_seqio.pyx":124
+ * 		qualities is a string and it contains the unmodified, encoded qualities.
+ * 		"""
+ * 		cdef int i = 0             # <<<<<<<<<<<<<<
+ * 		cdef int strip
+ * 		cdef str line, name, qualities, sequence
+ */
+  __pyx_cur_scope->__pyx_v_i = 0;
+
+  /* "cutadapt/_seqio.pyx":128
+ * 		cdef str line, name, qualities, sequence
+ * 		cdef bint twoheaders
+ * 		sequence_class = self.sequence_class             # <<<<<<<<<<<<<<
+ * 
+ * 		it = iter(self.fp)
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_n_s_sequence_class); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 128; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_GIVEREF(__pyx_t_1);
+  __pyx_cur_scope->__pyx_v_sequence_class = __pyx_t_1;
+  __pyx_t_1 = 0;
+
+  /* "cutadapt/_seqio.pyx":130
+ * 		sequence_class = self.sequence_class
+ * 
+ * 		it = iter(self.fp)             # <<<<<<<<<<<<<<
+ * 		line = next(it)
+ * 		if not (line and line[0] == '@'):
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_self, __pyx_n_s_fp); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = PyObject_GetIter(__pyx_t_1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 130; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_GIVEREF(__pyx_t_2);
+  __pyx_cur_scope->__pyx_v_it = __pyx_t_2;
+  __pyx_t_2 = 0;
+
+  /* "cutadapt/_seqio.pyx":131
+ * 
+ * 		it = iter(self.fp)
+ * 		line = next(it)             # <<<<<<<<<<<<<<
+ * 		if not (line and line[0] == '@'):
+ * 			raise FormatError("at line {0}, expected a line starting with '@'".format(i+1))
+ */
+  __pyx_t_2 = __Pyx_PyIter_Next(__pyx_cur_scope->__pyx_v_it); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  if (!(likely(PyString_CheckExact(__pyx_t_2))||((__pyx_t_2) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_2)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 131; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GIVEREF(__pyx_t_2);
+  __pyx_cur_scope->__pyx_v_line = ((PyObject*)__pyx_t_2);
+  __pyx_t_2 = 0;
+
+  /* "cutadapt/_seqio.pyx":132
+ * 		it = iter(self.fp)
+ * 		line = next(it)
+ * 		if not (line and line[0] == '@'):             # <<<<<<<<<<<<<<
+ * 			raise FormatError("at line {0}, expected a line starting with '@'".format(i+1))
+ * 		strip = -2 if line.endswith('\r\n') else -1
+ */
+  __pyx_t_4 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_line); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if (__pyx_t_4) {
+  } else {
+    __pyx_t_3 = __pyx_t_4;
+    goto __pyx_L5_bool_binop_done;
+  }
+  __pyx_t_2 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_line, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_2 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = (__Pyx_PyString_Equals(__pyx_t_2, __pyx_kp_s__3, Py_EQ)); if (unlikely(__pyx_t_4 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 132; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_3 = __pyx_t_4;
+  __pyx_L5_bool_binop_done:;
+  __pyx_t_4 = ((!__pyx_t_3) != 0);
+  if (__pyx_t_4) {
+
+    /* "cutadapt/_seqio.pyx":133
+ * 		line = next(it)
+ * 		if not (line and line[0] == '@'):
+ * 			raise FormatError("at line {0}, expected a line starting with '@'".format(i+1))             # <<<<<<<<<<<<<<
+ * 		strip = -2 if line.endswith('\r\n') else -1
+ * 		name = line[1:strip]
+ */
+    __pyx_t_1 = __Pyx_GetModuleGlobalName(__pyx_n_s_FormatError); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_at_line_0_expected_a_line_starti, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __pyx_t_7 = __Pyx_PyInt_From_long((__pyx_cur_scope->__pyx_v_i + 1)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_7);
+    __pyx_t_8 = NULL;
+    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
+      __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
+      if (likely(__pyx_t_8)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
+        __Pyx_INCREF(__pyx_t_8);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_6, function);
+      }
+    }
+    if (!__pyx_t_8) {
+      __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+      __Pyx_GOTREF(__pyx_t_5);
+    } else {
+      __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_8); __pyx_t_8 = NULL;
+      __Pyx_GIVEREF(__pyx_t_7);
+      PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_7);
+      __pyx_t_7 = 0;
+      __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_9, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_5);
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __pyx_t_6 = NULL;
+    if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_1))) {
+      __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_1);
+      if (likely(__pyx_t_6)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_1);
+        __Pyx_INCREF(__pyx_t_6);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_1, function);
+      }
+    }
+    if (!__pyx_t_6) {
+      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_1, __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+      __Pyx_GOTREF(__pyx_t_2);
+    } else {
+      __pyx_t_9 = PyTuple_New(1+1); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_t_6); __pyx_t_6 = NULL;
+      __Pyx_GIVEREF(__pyx_t_5);
+      PyTuple_SET_ITEM(__pyx_t_9, 0+1, __pyx_t_5);
+      __pyx_t_5 = 0;
+      __pyx_t_2 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_t_9, NULL); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_2);
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+    }
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    __Pyx_Raise(__pyx_t_2, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 133; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+
+  /* "cutadapt/_seqio.pyx":134
+ * 		if not (line and line[0] == '@'):
+ * 			raise FormatError("at line {0}, expected a line starting with '@'".format(i+1))
+ * 		strip = -2 if line.endswith('\r\n') else -1             # <<<<<<<<<<<<<<
+ * 		name = line[1:strip]
+ * 
+ */
+  if (unlikely(__pyx_cur_scope->__pyx_v_line == Py_None)) {
+    PyErr_Format(PyExc_AttributeError, "'NoneType' object has no attribute '%s'", "endswith");
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __pyx_t_4 = __Pyx_PyStr_Tailmatch(__pyx_cur_scope->__pyx_v_line, __pyx_kp_s__7, 0, PY_SSIZE_T_MAX, 1); if (unlikely(__pyx_t_4 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 134; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  if ((__pyx_t_4 != 0)) {
+    __pyx_t_10 = -2;
+  } else {
+    __pyx_t_10 = -1;
+  }
+  __pyx_cur_scope->__pyx_v_strip = __pyx_t_10;
+
+  /* "cutadapt/_seqio.pyx":135
+ * 			raise FormatError("at line {0}, expected a line starting with '@'".format(i+1))
+ * 		strip = -2 if line.endswith('\r\n') else -1
+ * 		name = line[1:strip]             # <<<<<<<<<<<<<<
+ * 
+ * 		i = 1
+ */
+  if (unlikely(__pyx_cur_scope->__pyx_v_line == Py_None)) {
+    PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __pyx_t_2 = PySequence_GetSlice(__pyx_cur_scope->__pyx_v_line, 1, __pyx_cur_scope->__pyx_v_strip); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 135; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_GIVEREF(__pyx_t_2);
+  __pyx_cur_scope->__pyx_v_name = ((PyObject*)__pyx_t_2);
+  __pyx_t_2 = 0;
+
+  /* "cutadapt/_seqio.pyx":137
+ * 		name = line[1:strip]
+ * 
+ * 		i = 1             # <<<<<<<<<<<<<<
+ * 		for line in it:
+ * 			if i == 0:
+ */
+  __pyx_cur_scope->__pyx_v_i = 1;
+
+  /* "cutadapt/_seqio.pyx":138
+ * 
+ * 		i = 1
+ * 		for line in it:             # <<<<<<<<<<<<<<
+ * 			if i == 0:
+ * 				if not (line and line[0] == '@'):
+ */
+  if (likely(PyList_CheckExact(__pyx_cur_scope->__pyx_v_it)) || PyTuple_CheckExact(__pyx_cur_scope->__pyx_v_it)) {
+    __pyx_t_2 = __pyx_cur_scope->__pyx_v_it; __Pyx_INCREF(__pyx_t_2); __pyx_t_11 = 0;
+    __pyx_t_12 = NULL;
+  } else {
+    __pyx_t_11 = -1; __pyx_t_2 = PyObject_GetIter(__pyx_cur_scope->__pyx_v_it); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_12 = Py_TYPE(__pyx_t_2)->tp_iternext; if (unlikely(!__pyx_t_12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  for (;;) {
+    if (likely(!__pyx_t_12)) {
+      if (likely(PyList_CheckExact(__pyx_t_2))) {
+        if (__pyx_t_11 >= PyList_GET_SIZE(__pyx_t_2)) break;
+        #if CYTHON_COMPILING_IN_CPYTHON
+        __pyx_t_1 = PyList_GET_ITEM(__pyx_t_2, __pyx_t_11); __Pyx_INCREF(__pyx_t_1); __pyx_t_11++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        #else
+        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        #endif
+      } else {
+        if (__pyx_t_11 >= PyTuple_GET_SIZE(__pyx_t_2)) break;
+        #if CYTHON_COMPILING_IN_CPYTHON
+        __pyx_t_1 = PyTuple_GET_ITEM(__pyx_t_2, __pyx_t_11); __Pyx_INCREF(__pyx_t_1); __pyx_t_11++; if (unlikely(0 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        #else
+        __pyx_t_1 = PySequence_ITEM(__pyx_t_2, __pyx_t_11); __pyx_t_11++; if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        #endif
+      }
+    } else {
+      __pyx_t_1 = __pyx_t_12(__pyx_t_2);
+      if (unlikely(!__pyx_t_1)) {
+        PyObject* exc_type = PyErr_Occurred();
+        if (exc_type) {
+          if (likely(exc_type == PyExc_StopIteration || PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))) PyErr_Clear();
+          else {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        }
+        break;
+      }
+      __Pyx_GOTREF(__pyx_t_1);
+    }
+    if (!(likely(PyString_CheckExact(__pyx_t_1))||((__pyx_t_1) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_1)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 138; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_line);
+    __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_line, ((PyObject*)__pyx_t_1));
+    __Pyx_GIVEREF(__pyx_t_1);
+    __pyx_t_1 = 0;
+
+    /* "cutadapt/_seqio.pyx":163
+ * 					else:
+ * 						twoheaders = False
+ * 			elif i == 3:             # <<<<<<<<<<<<<<
+ * 				if len(line) == len(sequence) - strip:
+ * 					qualities = line[:strip]
+ */
+    switch (__pyx_cur_scope->__pyx_v_i) {
+
+      /* "cutadapt/_seqio.pyx":139
+ * 		i = 1
+ * 		for line in it:
+ * 			if i == 0:             # <<<<<<<<<<<<<<
+ * 				if not (line and line[0] == '@'):
+ * 					raise FormatError("at line {0}, expected a line starting with '@'".format(i+1))
+ */
+      case 0:
+
+      /* "cutadapt/_seqio.pyx":140
+ * 		for line in it:
+ * 			if i == 0:
+ * 				if not (line and line[0] == '@'):             # <<<<<<<<<<<<<<
+ * 					raise FormatError("at line {0}, expected a line starting with '@'".format(i+1))
+ * 				name = line[1:strip]
+ */
+      __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_line); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (__pyx_t_3) {
+      } else {
+        __pyx_t_4 = __pyx_t_3;
+        goto __pyx_L10_bool_binop_done;
+      }
+      __pyx_t_1 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_line, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_kp_s__3, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 140; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __pyx_t_4 = __pyx_t_3;
+      __pyx_L10_bool_binop_done:;
+      __pyx_t_3 = ((!__pyx_t_4) != 0);
+      if (__pyx_t_3) {
+
+        /* "cutadapt/_seqio.pyx":141
+ * 			if i == 0:
+ * 				if not (line and line[0] == '@'):
+ * 					raise FormatError("at line {0}, expected a line starting with '@'".format(i+1))             # <<<<<<<<<<<<<<
+ * 				name = line[1:strip]
+ * 			elif i == 1:
+ */
+        __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_FormatError); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_at_line_0_expected_a_line_starti, __pyx_n_s_format); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_6);
+        __pyx_t_7 = __Pyx_PyInt_From_long((__pyx_cur_scope->__pyx_v_i + 1)); if (unlikely(!__pyx_t_7)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_7);
+        __pyx_t_8 = NULL;
+        if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
+          __pyx_t_8 = PyMethod_GET_SELF(__pyx_t_6);
+          if (likely(__pyx_t_8)) {
+            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
+            __Pyx_INCREF(__pyx_t_8);
+            __Pyx_INCREF(function);
+            __Pyx_DECREF_SET(__pyx_t_6, function);
+          }
+        }
+        if (!__pyx_t_8) {
+          __pyx_t_5 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_7); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_DECREF(__pyx_t_7); __pyx_t_7 = 0;
+          __Pyx_GOTREF(__pyx_t_5);
+        } else {
+          __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_13);
+          __Pyx_GIVEREF(__pyx_t_8); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_8); __pyx_t_8 = NULL;
+          __Pyx_GIVEREF(__pyx_t_7);
+          PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_t_7);
+          __pyx_t_7 = 0;
+          __pyx_t_5 = __Pyx_PyObject_Call(__pyx_t_6, __pyx_t_13, NULL); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_5);
+          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+        }
+        __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+        __pyx_t_6 = NULL;
+        if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) {
+          __pyx_t_6 = PyMethod_GET_SELF(__pyx_t_9);
+          if (likely(__pyx_t_6)) {
+            PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
+            __Pyx_INCREF(__pyx_t_6);
+            __Pyx_INCREF(function);
+            __Pyx_DECREF_SET(__pyx_t_9, function);
+          }
+        }
+        if (!__pyx_t_6) {
+          __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_5); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+          __Pyx_GOTREF(__pyx_t_1);
+        } else {
+          __pyx_t_13 = PyTuple_New(1+1); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_13);
+          __Pyx_GIVEREF(__pyx_t_6); PyTuple_SET_ITEM(__pyx_t_13, 0, __pyx_t_6); __pyx_t_6 = NULL;
+          __Pyx_GIVEREF(__pyx_t_5);
+          PyTuple_SET_ITEM(__pyx_t_13, 0+1, __pyx_t_5);
+          __pyx_t_5 = 0;
+          __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_13, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_1);
+          __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+        }
+        __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+        __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 141; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      }
+
+      /* "cutadapt/_seqio.pyx":142
+ * 				if not (line and line[0] == '@'):
+ * 					raise FormatError("at line {0}, expected a line starting with '@'".format(i+1))
+ * 				name = line[1:strip]             # <<<<<<<<<<<<<<
+ * 			elif i == 1:
+ * 				sequence = line[:strip]
+ */
+      if (unlikely(__pyx_cur_scope->__pyx_v_line == Py_None)) {
+        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      }
+      __pyx_t_1 = PySequence_GetSlice(__pyx_cur_scope->__pyx_v_line, 1, __pyx_cur_scope->__pyx_v_strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 142; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_name);
+      __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_name, ((PyObject*)__pyx_t_1));
+      __Pyx_GIVEREF(__pyx_t_1);
+      __pyx_t_1 = 0;
+      break;
+
+      /* "cutadapt/_seqio.pyx":143
+ * 					raise FormatError("at line {0}, expected a line starting with '@'".format(i+1))
+ * 				name = line[1:strip]
+ * 			elif i == 1:             # <<<<<<<<<<<<<<
+ * 				sequence = line[:strip]
+ * 			elif i == 2:
+ */
+      case 1:
+
+      /* "cutadapt/_seqio.pyx":144
+ * 				name = line[1:strip]
+ * 			elif i == 1:
+ * 				sequence = line[:strip]             # <<<<<<<<<<<<<<
+ * 			elif i == 2:
+ * 				if line == '+\n':  # check most common case first
+ */
+      if (unlikely(__pyx_cur_scope->__pyx_v_line == Py_None)) {
+        PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+        {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      }
+      __pyx_t_1 = PySequence_GetSlice(__pyx_cur_scope->__pyx_v_line, 0, __pyx_cur_scope->__pyx_v_strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 144; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_sequence);
+      __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_sequence, ((PyObject*)__pyx_t_1));
+      __Pyx_GIVEREF(__pyx_t_1);
+      __pyx_t_1 = 0;
+      break;
+
+      /* "cutadapt/_seqio.pyx":145
+ * 			elif i == 1:
+ * 				sequence = line[:strip]
+ * 			elif i == 2:             # <<<<<<<<<<<<<<
+ * 				if line == '+\n':  # check most common case first
+ * 					twoheaders = False
+ */
+      case 2:
+
+      /* "cutadapt/_seqio.pyx":146
+ * 				sequence = line[:strip]
+ * 			elif i == 2:
+ * 				if line == '+\n':  # check most common case first             # <<<<<<<<<<<<<<
+ * 					twoheaders = False
+ * 				else:
+ */
+      __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_cur_scope->__pyx_v_line, __pyx_kp_s__8, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 146; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = (__pyx_t_3 != 0);
+      if (__pyx_t_4) {
+
+        /* "cutadapt/_seqio.pyx":147
+ * 			elif i == 2:
+ * 				if line == '+\n':  # check most common case first
+ * 					twoheaders = False             # <<<<<<<<<<<<<<
+ * 				else:
+ * 					line = line[:strip]
+ */
+        __pyx_cur_scope->__pyx_v_twoheaders = 0;
+        goto __pyx_L12;
+      }
+      /*else*/ {
+
+        /* "cutadapt/_seqio.pyx":149
+ * 					twoheaders = False
+ * 				else:
+ * 					line = line[:strip]             # <<<<<<<<<<<<<<
+ * 					if not (line and line[0] == '+'):
+ * 						raise FormatError("at line {0}, expected a line starting with '+'".format(i+1))
+ */
+        if (unlikely(__pyx_cur_scope->__pyx_v_line == Py_None)) {
+          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        }
+        __pyx_t_1 = PySequence_GetSlice(__pyx_cur_scope->__pyx_v_line, 0, __pyx_cur_scope->__pyx_v_strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 149; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_GOTREF(__pyx_cur_scope->__pyx_v_line);
+        __Pyx_DECREF_SET(__pyx_cur_scope->__pyx_v_line, ((PyObject*)__pyx_t_1));
+        __Pyx_GIVEREF(__pyx_t_1);
+        __pyx_t_1 = 0;
+
+        /* "cutadapt/_seqio.pyx":150
+ * 				else:
+ * 					line = line[:strip]
+ * 					if not (line and line[0] == '+'):             # <<<<<<<<<<<<<<
+ * 						raise FormatError("at line {0}, expected a line starting with '+'".format(i+1))
+ * 					if len(line) > 1:
+ */
+        __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_cur_scope->__pyx_v_line); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        if (__pyx_t_3) {
+        } else {
+          __pyx_t_4 = __pyx_t_3;
+          goto __pyx_L14_bool_binop_done;
+        }
+        __pyx_t_1 = __Pyx_GetItemInt(__pyx_cur_scope->__pyx_v_line, 0, long, 1, __Pyx_PyInt_From_long, 0, 0, 1); if (unlikely(__pyx_t_1 == NULL)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+        __Pyx_GOTREF(__pyx_t_1);
+        __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_kp_s__9, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 150; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        __pyx_t_4 = __pyx_t_3;
+        __pyx_L14_bool_binop_done:;
+        __pyx_t_3 = ((!__pyx_t_4) != 0);
+        if (__pyx_t_3) {
+
+          /* "cutadapt/_seqio.pyx":151
+ * 					line = line[:strip]
+ * 					if not (line and line[0] == '+'):
+ * 						raise FormatError("at line {0}, expected a line starting with '+'".format(i+1))             # <<<<<<<<<<<<<<
+ * 					if len(line) > 1:
+ * 						twoheaders = True
+ */
+          __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_FormatError); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_9);
+          __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_at_line_0_expected_a_line_starti_2, __pyx_n_s_format); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_5);
+          __pyx_t_6 = __Pyx_PyInt_From_long((__pyx_cur_scope->__pyx_v_i + 1)); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_6);
+          __pyx_t_7 = NULL;
+          if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_5))) {
+            __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_5);
+            if (likely(__pyx_t_7)) {
+              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_5);
+              __Pyx_INCREF(__pyx_t_7);
+              __Pyx_INCREF(function);
+              __Pyx_DECREF_SET(__pyx_t_5, function);
+            }
+          }
+          if (!__pyx_t_7) {
+            __pyx_t_13 = __Pyx_PyObject_CallOneArg(__pyx_t_5, __pyx_t_6); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+            __Pyx_GOTREF(__pyx_t_13);
+          } else {
+            __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __Pyx_GOTREF(__pyx_t_8);
+            __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_7); __pyx_t_7 = NULL;
+            __Pyx_GIVEREF(__pyx_t_6);
+            PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_6);
+            __pyx_t_6 = 0;
+            __pyx_t_13 = __Pyx_PyObject_Call(__pyx_t_5, __pyx_t_8, NULL); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __Pyx_GOTREF(__pyx_t_13);
+            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+          }
+          __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+          __pyx_t_5 = NULL;
+          if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) {
+            __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_9);
+            if (likely(__pyx_t_5)) {
+              PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
+              __Pyx_INCREF(__pyx_t_5);
+              __Pyx_INCREF(function);
+              __Pyx_DECREF_SET(__pyx_t_9, function);
+            }
+          }
+          if (!__pyx_t_5) {
+            __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_13); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+            __Pyx_GOTREF(__pyx_t_1);
+          } else {
+            __pyx_t_8 = PyTuple_New(1+1); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __Pyx_GOTREF(__pyx_t_8);
+            __Pyx_GIVEREF(__pyx_t_5); PyTuple_SET_ITEM(__pyx_t_8, 0, __pyx_t_5); __pyx_t_5 = NULL;
+            __Pyx_GIVEREF(__pyx_t_13);
+            PyTuple_SET_ITEM(__pyx_t_8, 0+1, __pyx_t_13);
+            __pyx_t_13 = 0;
+            __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_8, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __Pyx_GOTREF(__pyx_t_1);
+            __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+          }
+          __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+          __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 151; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        }
+
+        /* "cutadapt/_seqio.pyx":152
+ * 					if not (line and line[0] == '+'):
+ * 						raise FormatError("at line {0}, expected a line starting with '+'".format(i+1))
+ * 					if len(line) > 1:             # <<<<<<<<<<<<<<
+ * 						twoheaders = True
+ * 						if not line[1:] == name:
+ */
+        __pyx_t_14 = PyObject_Length(__pyx_cur_scope->__pyx_v_line); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 152; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __pyx_t_3 = ((__pyx_t_14 > 1) != 0);
+        if (__pyx_t_3) {
+
+          /* "cutadapt/_seqio.pyx":153
+ * 						raise FormatError("at line {0}, expected a line starting with '+'".format(i+1))
+ * 					if len(line) > 1:
+ * 						twoheaders = True             # <<<<<<<<<<<<<<
+ * 						if not line[1:] == name:
+ * 							raise FormatError(
+ */
+          __pyx_cur_scope->__pyx_v_twoheaders = 1;
+
+          /* "cutadapt/_seqio.pyx":154
+ * 					if len(line) > 1:
+ * 						twoheaders = True
+ * 						if not line[1:] == name:             # <<<<<<<<<<<<<<
+ * 							raise FormatError(
+ * 								"At line {0}: Sequence descriptions in the FASTQ file don't match "
+ */
+          __pyx_t_1 = PySequence_GetSlice(__pyx_cur_scope->__pyx_v_line, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_GOTREF(__pyx_t_1);
+          __pyx_t_3 = (__Pyx_PyString_Equals(__pyx_t_1, __pyx_cur_scope->__pyx_v_name, Py_EQ)); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 154; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+          __pyx_t_4 = ((!(__pyx_t_3 != 0)) != 0);
+          if (__pyx_t_4) {
+
+            /* "cutadapt/_seqio.pyx":155
+ * 						twoheaders = True
+ * 						if not line[1:] == name:
+ * 							raise FormatError(             # <<<<<<<<<<<<<<
+ * 								"At line {0}: Sequence descriptions in the FASTQ file don't match "
+ * 								"({1!r} != {2!r}).\n"
+ */
+            __pyx_t_9 = __Pyx_GetModuleGlobalName(__pyx_n_s_FormatError); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __Pyx_GOTREF(__pyx_t_9);
+
+            /* "cutadapt/_seqio.pyx":159
+ * 								"({1!r} != {2!r}).\n"
+ * 								"The second sequence description must be either empty "
+ * 								"or equal to the first description.".format(i+1,             # <<<<<<<<<<<<<<
+ * 									name, line[1:]))
+ * 					else:
+ */
+            __pyx_t_13 = __Pyx_PyObject_GetAttrStr(__pyx_kp_s_At_line_0_Sequence_descriptions, __pyx_n_s_format); if (unlikely(!__pyx_t_13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __Pyx_GOTREF(__pyx_t_13);
+            __pyx_t_5 = __Pyx_PyInt_From_long((__pyx_cur_scope->__pyx_v_i + 1)); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __Pyx_GOTREF(__pyx_t_5);
+
+            /* "cutadapt/_seqio.pyx":160
+ * 								"The second sequence description must be either empty "
+ * 								"or equal to the first description.".format(i+1,
+ * 									name, line[1:]))             # <<<<<<<<<<<<<<
+ * 					else:
+ * 						twoheaders = False
+ */
+            __pyx_t_6 = PySequence_GetSlice(__pyx_cur_scope->__pyx_v_line, 1, PY_SSIZE_T_MAX); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 160; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __Pyx_GOTREF(__pyx_t_6);
+            __pyx_t_7 = NULL;
+            __pyx_t_14 = 0;
+            if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_13))) {
+              __pyx_t_7 = PyMethod_GET_SELF(__pyx_t_13);
+              if (likely(__pyx_t_7)) {
+                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_13);
+                __Pyx_INCREF(__pyx_t_7);
+                __Pyx_INCREF(function);
+                __Pyx_DECREF_SET(__pyx_t_13, function);
+                __pyx_t_14 = 1;
+              }
+            }
+            __pyx_t_15 = PyTuple_New(3+__pyx_t_14); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __Pyx_GOTREF(__pyx_t_15);
+            if (__pyx_t_7) {
+              __Pyx_GIVEREF(__pyx_t_7); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_7); __pyx_t_7 = NULL;
+            }
+            __Pyx_GIVEREF(__pyx_t_5);
+            PyTuple_SET_ITEM(__pyx_t_15, 0+__pyx_t_14, __pyx_t_5);
+            __Pyx_INCREF(__pyx_cur_scope->__pyx_v_name);
+            __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_name);
+            PyTuple_SET_ITEM(__pyx_t_15, 1+__pyx_t_14, __pyx_cur_scope->__pyx_v_name);
+            __Pyx_GIVEREF(__pyx_t_6);
+            PyTuple_SET_ITEM(__pyx_t_15, 2+__pyx_t_14, __pyx_t_6);
+            __pyx_t_5 = 0;
+            __pyx_t_6 = 0;
+            __pyx_t_8 = __Pyx_PyObject_Call(__pyx_t_13, __pyx_t_15, NULL); if (unlikely(!__pyx_t_8)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 159; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+            __Pyx_GOTREF(__pyx_t_8);
+            __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+            __Pyx_DECREF(__pyx_t_13); __pyx_t_13 = 0;
+            __pyx_t_13 = NULL;
+            if (CYTHON_COMPILING_IN_CPYTHON && unlikely(PyMethod_Check(__pyx_t_9))) {
+              __pyx_t_13 = PyMethod_GET_SELF(__pyx_t_9);
+              if (likely(__pyx_t_13)) {
+                PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_9);
+                __Pyx_INCREF(__pyx_t_13);
+                __Pyx_INCREF(function);
+                __Pyx_DECREF_SET(__pyx_t_9, function);
+              }
+            }
+            if (!__pyx_t_13) {
+              __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_9, __pyx_t_8); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+              __Pyx_DECREF(__pyx_t_8); __pyx_t_8 = 0;
+              __Pyx_GOTREF(__pyx_t_1);
+            } else {
+              __pyx_t_15 = PyTuple_New(1+1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+              __Pyx_GOTREF(__pyx_t_15);
+              __Pyx_GIVEREF(__pyx_t_13); PyTuple_SET_ITEM(__pyx_t_15, 0, __pyx_t_13); __pyx_t_13 = NULL;
+              __Pyx_GIVEREF(__pyx_t_8);
+              PyTuple_SET_ITEM(__pyx_t_15, 0+1, __pyx_t_8);
+              __pyx_t_8 = 0;
+              __pyx_t_1 = __Pyx_PyObject_Call(__pyx_t_9, __pyx_t_15, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+              __Pyx_GOTREF(__pyx_t_1);
+              __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+            }
+            __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+            __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+            __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+            {__pyx_filename = __pyx_f[0]; __pyx_lineno = 155; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+          }
+          goto __pyx_L16;
+        }
+        /*else*/ {
+
+          /* "cutadapt/_seqio.pyx":162
+ * 									name, line[1:]))
+ * 					else:
+ * 						twoheaders = False             # <<<<<<<<<<<<<<
+ * 			elif i == 3:
+ * 				if len(line) == len(sequence) - strip:
+ */
+          __pyx_cur_scope->__pyx_v_twoheaders = 0;
+        }
+        __pyx_L16:;
+      }
+      __pyx_L12:;
+      break;
+
+      /* "cutadapt/_seqio.pyx":163
+ * 					else:
+ * 						twoheaders = False
+ * 			elif i == 3:             # <<<<<<<<<<<<<<
+ * 				if len(line) == len(sequence) - strip:
+ * 					qualities = line[:strip]
+ */
+      case 3:
+
+      /* "cutadapt/_seqio.pyx":164
+ * 						twoheaders = False
+ * 			elif i == 3:
+ * 				if len(line) == len(sequence) - strip:             # <<<<<<<<<<<<<<
+ * 					qualities = line[:strip]
+ * 				else:
+ */
+      __pyx_t_14 = PyObject_Length(__pyx_cur_scope->__pyx_v_line); if (unlikely(__pyx_t_14 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      if (unlikely(!__pyx_cur_scope->__pyx_v_sequence)) { __Pyx_RaiseUnboundLocalError("sequence"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
+      __pyx_t_16 = PyObject_Length(__pyx_cur_scope->__pyx_v_sequence); if (unlikely(__pyx_t_16 == -1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 164; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __pyx_t_4 = ((__pyx_t_14 == (__pyx_t_16 - __pyx_cur_scope->__pyx_v_strip)) != 0);
+      if (__pyx_t_4) {
+
+        /* "cutadapt/_seqio.pyx":165
+ * 			elif i == 3:
+ * 				if len(line) == len(sequence) - strip:
+ * 					qualities = line[:strip]             # <<<<<<<<<<<<<<
+ * 				else:
+ * 					qualities = line.rstrip('\r\n')
+ */
+        if (unlikely(__pyx_cur_scope->__pyx_v_line == Py_None)) {
+          PyErr_SetString(PyExc_TypeError, "'NoneType' object is not subscriptable");
+          {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        }
+        __pyx_t_1 = PySequence_GetSlice(__pyx_cur_scope->__pyx_v_line, 0, __pyx_cur_scope->__pyx_v_strip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 165; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_qualities);
+        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_qualities, ((PyObject*)__pyx_t_1));
+        __Pyx_GIVEREF(__pyx_t_1);
+        __pyx_t_1 = 0;
+        goto __pyx_L18;
+      }
+      /*else*/ {
+
+        /* "cutadapt/_seqio.pyx":167
+ * 					qualities = line[:strip]
+ * 				else:
+ * 					qualities = line.rstrip('\r\n')             # <<<<<<<<<<<<<<
+ * 				yield sequence_class(name, sequence, qualities, twoheaders=twoheaders)
+ * 			i = (i + 1) % 4
+ */
+        __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_cur_scope->__pyx_v_line, __pyx_n_s_rstrip); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_1);
+        __pyx_t_9 = __Pyx_PyObject_Call(__pyx_t_1, __pyx_tuple__10, NULL); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_GOTREF(__pyx_t_9);
+        __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+        if (!(likely(PyString_CheckExact(__pyx_t_9))||((__pyx_t_9) == Py_None)||(PyErr_Format(PyExc_TypeError, "Expected %.16s, got %.200s", "str", Py_TYPE(__pyx_t_9)->tp_name), 0))) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+        __Pyx_XGOTREF(__pyx_cur_scope->__pyx_v_qualities);
+        __Pyx_XDECREF_SET(__pyx_cur_scope->__pyx_v_qualities, ((PyObject*)__pyx_t_9));
+        __Pyx_GIVEREF(__pyx_t_9);
+        __pyx_t_9 = 0;
+      }
+      __pyx_L18:;
+
+      /* "cutadapt/_seqio.pyx":168
+ * 				else:
+ * 					qualities = line.rstrip('\r\n')
+ * 				yield sequence_class(name, sequence, qualities, twoheaders=twoheaders)             # <<<<<<<<<<<<<<
+ * 			i = (i + 1) % 4
+ * 		if i != 0:
+ */
+      if (unlikely(!__pyx_cur_scope->__pyx_v_sequence)) { __Pyx_RaiseUnboundLocalError("sequence"); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;} }
+      __pyx_t_9 = PyTuple_New(3); if (unlikely(!__pyx_t_9)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_9);
+      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_name);
+      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_name);
+      PyTuple_SET_ITEM(__pyx_t_9, 0, __pyx_cur_scope->__pyx_v_name);
+      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_sequence);
+      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_sequence);
+      PyTuple_SET_ITEM(__pyx_t_9, 1, __pyx_cur_scope->__pyx_v_sequence);
+      __Pyx_INCREF(__pyx_cur_scope->__pyx_v_qualities);
+      __Pyx_GIVEREF(__pyx_cur_scope->__pyx_v_qualities);
+      PyTuple_SET_ITEM(__pyx_t_9, 2, __pyx_cur_scope->__pyx_v_qualities);
+      __pyx_t_1 = PyDict_New(); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_1);
+      __pyx_t_15 = __Pyx_PyBool_FromLong(__pyx_cur_scope->__pyx_v_twoheaders); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_15);
+      if (PyDict_SetItem(__pyx_t_1, __pyx_n_s_twoheaders, __pyx_t_15) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+      __pyx_t_15 = __Pyx_PyObject_Call(__pyx_cur_scope->__pyx_v_sequence_class, __pyx_t_9, __pyx_t_1); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_GOTREF(__pyx_t_15);
+      __Pyx_DECREF(__pyx_t_9); __pyx_t_9 = 0;
+      __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+      __pyx_r = __pyx_t_15;
+      __pyx_t_15 = 0;
+      __Pyx_XGIVEREF(__pyx_t_2);
+      __pyx_cur_scope->__pyx_t_0 = __pyx_t_2;
+      __pyx_cur_scope->__pyx_t_1 = __pyx_t_11;
+      __pyx_cur_scope->__pyx_t_2 = __pyx_t_12;
+      __Pyx_XGIVEREF(__pyx_r);
+      __Pyx_RefNannyFinishContext();
+      /* return from generator, yielding value */
+      __pyx_generator->resume_label = 1;
+      return __pyx_r;
+      __pyx_L19_resume_from_yield:;
+      __pyx_t_2 = __pyx_cur_scope->__pyx_t_0;
+      __pyx_cur_scope->__pyx_t_0 = 0;
+      __Pyx_XGOTREF(__pyx_t_2);
+      __pyx_t_11 = __pyx_cur_scope->__pyx_t_1;
+      __pyx_t_12 = __pyx_cur_scope->__pyx_t_2;
+      if (unlikely(!__pyx_sent_value)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 168; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      break;
+      default: break;
+    }
+
+    /* "cutadapt/_seqio.pyx":169
+ * 					qualities = line.rstrip('\r\n')
+ * 				yield sequence_class(name, sequence, qualities, twoheaders=twoheaders)
+ * 			i = (i + 1) % 4             # <<<<<<<<<<<<<<
+ * 		if i != 0:
+ * 			raise FormatError("FASTQ file ended prematurely")
+ */
+    __pyx_cur_scope->__pyx_v_i = __Pyx_mod_long((__pyx_cur_scope->__pyx_v_i + 1), 4);
+
+    /* "cutadapt/_seqio.pyx":138
+ * 
+ * 		i = 1
+ * 		for line in it:             # <<<<<<<<<<<<<<
+ * 			if i == 0:
+ * 				if not (line and line[0] == '@'):
+ */
+  }
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "cutadapt/_seqio.pyx":170
+ * 				yield sequence_class(name, sequence, qualities, twoheaders=twoheaders)
+ * 			i = (i + 1) % 4
+ * 		if i != 0:             # <<<<<<<<<<<<<<
+ * 			raise FormatError("FASTQ file ended prematurely")
+ * 
+ */
+  __pyx_t_4 = ((__pyx_cur_scope->__pyx_v_i != 0) != 0);
+  if (__pyx_t_4) {
+
+    /* "cutadapt/_seqio.pyx":171
+ * 			i = (i + 1) % 4
+ * 		if i != 0:
+ * 			raise FormatError("FASTQ file ended prematurely")             # <<<<<<<<<<<<<<
+ * 
+ * 	def close(self):
+ */
+    __pyx_t_2 = __Pyx_GetModuleGlobalName(__pyx_n_s_FormatError); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_2);
+    __pyx_t_15 = __Pyx_PyObject_Call(__pyx_t_2, __pyx_tuple__11, NULL); if (unlikely(!__pyx_t_15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_15);
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+    __Pyx_Raise(__pyx_t_15, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_15); __pyx_t_15 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+
+  /* "cutadapt/_seqio.pyx":119
+ * 		self.delivers_qualities = True
+ * 
+ * 	def __iter__(self):             # <<<<<<<<<<<<<<
+ * 		"""
+ * 		Return tuples: (name, sequence, qualities).
+ */
+
+  /* function exit code */
+  PyErr_SetNone(PyExc_StopIteration);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_XDECREF(__pyx_t_7);
+  __Pyx_XDECREF(__pyx_t_8);
+  __Pyx_XDECREF(__pyx_t_9);
+  __Pyx_XDECREF(__pyx_t_13);
+  __Pyx_XDECREF(__pyx_t_15);
+  __Pyx_AddTraceback("__iter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_L0:;
+  __Pyx_XDECREF(__pyx_r);
+  __pyx_generator->resume_label = -1;
+  __Pyx_Generator_clear((PyObject*)__pyx_generator);
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+}
+
+/* "cutadapt/_seqio.pyx":173
+ * 			raise FormatError("FASTQ file ended prematurely")
+ * 
+ * 	def close(self):             # <<<<<<<<<<<<<<
+ * 		if not self._file_passed and self.fp is not None:
+ * 			self.fp.close()
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_8cutadapt_6_seqio_11FastqReader_6close(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
+static PyMethodDef __pyx_mdef_8cutadapt_6_seqio_11FastqReader_6close = {"close", (PyCFunction)__pyx_pw_8cutadapt_6_seqio_11FastqReader_6close, METH_O, 0};
+static PyObject *__pyx_pw_8cutadapt_6_seqio_11FastqReader_6close(PyObject *__pyx_self, PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("close (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_11FastqReader_5close(__pyx_self, ((PyObject *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_8cutadapt_6_seqio_11FastqReader_5close(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  int __pyx_t_1;
+  PyObject *__pyx_t_2 = NULL;
+  int __pyx_t_3;
+  int __pyx_t_4;
+  PyObject *__pyx_t_5 = NULL;
+  PyObject *__pyx_t_6 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("close", 0);
+
+  /* "cutadapt/_seqio.pyx":174
+ * 
+ * 	def close(self):
+ * 		if not self._file_passed and self.fp is not None:             # <<<<<<<<<<<<<<
+ * 			self.fp.close()
+ * 			self.fp = None
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_file_passed); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = __Pyx_PyObject_IsTrue(__pyx_t_2); if (unlikely(__pyx_t_3 < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_4 = ((!__pyx_t_3) != 0);
+  if (__pyx_t_4) {
+  } else {
+    __pyx_t_1 = __pyx_t_4;
+    goto __pyx_L4_bool_binop_done;
+  }
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fp); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 174; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_4 = (__pyx_t_2 != Py_None);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __pyx_t_3 = (__pyx_t_4 != 0);
+  __pyx_t_1 = __pyx_t_3;
+  __pyx_L4_bool_binop_done:;
+  if (__pyx_t_1) {
+
+    /* "cutadapt/_seqio.pyx":175
+ * 	def close(self):
+ * 		if not self._file_passed and self.fp is not None:
+ * 			self.fp.close()             # <<<<<<<<<<<<<<
+ * 			self.fp = None
+ * 
+ */
+    __pyx_t_5 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fp); if (unlikely(!__pyx_t_5)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_5);
+    __pyx_t_6 = __Pyx_PyObject_GetAttrStr(__pyx_t_5, __pyx_n_s_close); if (unlikely(!__pyx_t_6)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_6);
+    __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    __pyx_t_5 = NULL;
+    if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_6))) {
+      __pyx_t_5 = PyMethod_GET_SELF(__pyx_t_6);
+      if (likely(__pyx_t_5)) {
+        PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_6);
+        __Pyx_INCREF(__pyx_t_5);
+        __Pyx_INCREF(function);
+        __Pyx_DECREF_SET(__pyx_t_6, function);
+      }
+    }
+    if (__pyx_t_5) {
+      __pyx_t_2 = __Pyx_PyObject_CallOneArg(__pyx_t_6, __pyx_t_5); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+      __Pyx_DECREF(__pyx_t_5); __pyx_t_5 = 0;
+    } else {
+      __pyx_t_2 = __Pyx_PyObject_CallNoArg(__pyx_t_6); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 175; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    }
+    __Pyx_GOTREF(__pyx_t_2);
+    __Pyx_DECREF(__pyx_t_6); __pyx_t_6 = 0;
+    __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+    /* "cutadapt/_seqio.pyx":176
+ * 		if not self._file_passed and self.fp is not None:
+ * 			self.fp.close()
+ * 			self.fp = None             # <<<<<<<<<<<<<<
+ * 
+ * 	def __enter__(self):
+ */
+    if (__Pyx_PyObject_SetAttrStr(__pyx_v_self, __pyx_n_s_fp, Py_None) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 176; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    goto __pyx_L3;
+  }
+  __pyx_L3:;
+
+  /* "cutadapt/_seqio.pyx":173
+ * 			raise FormatError("FASTQ file ended prematurely")
+ * 
+ * 	def close(self):             # <<<<<<<<<<<<<<
+ * 		if not self._file_passed and self.fp is not None:
+ * 			self.fp.close()
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_5);
+  __Pyx_XDECREF(__pyx_t_6);
+  __Pyx_AddTraceback("cutadapt._seqio.FastqReader.close", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "cutadapt/_seqio.pyx":178
+ * 			self.fp = None
+ * 
+ * 	def __enter__(self):             # <<<<<<<<<<<<<<
+ * 		if self.fp is None:
+ * 			raise ValueError("I/O operation on closed FastqReader")
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_8cutadapt_6_seqio_11FastqReader_8__enter__(PyObject *__pyx_self, PyObject *__pyx_v_self); /*proto*/
+static PyMethodDef __pyx_mdef_8cutadapt_6_seqio_11FastqReader_8__enter__ = {"__enter__", (PyCFunction)__pyx_pw_8cutadapt_6_seqio_11FastqReader_8__enter__, METH_O, 0};
+static PyObject *__pyx_pw_8cutadapt_6_seqio_11FastqReader_8__enter__(PyObject *__pyx_self, PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__enter__ (wrapper)", 0);
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_11FastqReader_7__enter__(__pyx_self, ((PyObject *)__pyx_v_self));
+
+  /* function exit code */
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_8cutadapt_6_seqio_11FastqReader_7__enter__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  int __pyx_t_2;
+  int __pyx_t_3;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("__enter__", 0);
+
+  /* "cutadapt/_seqio.pyx":179
+ * 
+ * 	def __enter__(self):
+ * 		if self.fp is None:             # <<<<<<<<<<<<<<
+ * 			raise ValueError("I/O operation on closed FastqReader")
+ * 		return self
+ */
+  __pyx_t_1 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_fp); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 179; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_2 = (__pyx_t_1 == Py_None);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_3 = (__pyx_t_2 != 0);
+  if (__pyx_t_3) {
+
+    /* "cutadapt/_seqio.pyx":180
+ * 	def __enter__(self):
+ * 		if self.fp is None:
+ * 			raise ValueError("I/O operation on closed FastqReader")             # <<<<<<<<<<<<<<
+ * 		return self
+ * 
+ */
+    __pyx_t_1 = __Pyx_PyObject_Call(__pyx_builtin_ValueError, __pyx_tuple__12, NULL); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_GOTREF(__pyx_t_1);
+    __Pyx_Raise(__pyx_t_1, 0, 0, 0);
+    __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+    {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+
+  /* "cutadapt/_seqio.pyx":181
+ * 		if self.fp is None:
+ * 			raise ValueError("I/O operation on closed FastqReader")
+ * 		return self             # <<<<<<<<<<<<<<
+ * 
+ * 	def __exit__(self, *args):
+ */
+  __Pyx_XDECREF(__pyx_r);
+  __Pyx_INCREF(__pyx_v_self);
+  __pyx_r = __pyx_v_self;
+  goto __pyx_L0;
+
+  /* "cutadapt/_seqio.pyx":178
+ * 			self.fp = None
+ * 
+ * 	def __enter__(self):             # <<<<<<<<<<<<<<
+ * 		if self.fp is None:
+ * 			raise ValueError("I/O operation on closed FastqReader")
+ */
+
+  /* function exit code */
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_AddTraceback("cutadapt._seqio.FastqReader.__enter__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+/* "cutadapt/_seqio.pyx":183
+ * 		return self
+ * 
+ * 	def __exit__(self, *args):             # <<<<<<<<<<<<<<
+ * 		self.close()
+ */
+
+/* Python wrapper */
+static PyObject *__pyx_pw_8cutadapt_6_seqio_11FastqReader_10__exit__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds); /*proto*/
+static PyMethodDef __pyx_mdef_8cutadapt_6_seqio_11FastqReader_10__exit__ = {"__exit__", (PyCFunction)__pyx_pw_8cutadapt_6_seqio_11FastqReader_10__exit__, METH_VARARGS|METH_KEYWORDS, 0};
+static PyObject *__pyx_pw_8cutadapt_6_seqio_11FastqReader_10__exit__(PyObject *__pyx_self, PyObject *__pyx_args, PyObject *__pyx_kwds) {
+  PyObject *__pyx_v_self = 0;
+  CYTHON_UNUSED PyObject *__pyx_v_args = 0;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  PyObject *__pyx_r = 0;
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__exit__ (wrapper)", 0);
+  if (PyTuple_GET_SIZE(__pyx_args) > 1) {
+    __pyx_v_args = PyTuple_GetSlice(__pyx_args, 1, PyTuple_GET_SIZE(__pyx_args));
+    if (unlikely(!__pyx_v_args)) {
+      __Pyx_RefNannyFinishContext();
+      return NULL;
+    }
+    __Pyx_GOTREF(__pyx_v_args);
+  } else {
+    __pyx_v_args = __pyx_empty_tuple; __Pyx_INCREF(__pyx_empty_tuple);
+  }
+  {
+    static PyObject **__pyx_pyargnames[] = {&__pyx_n_s_self,0};
+    PyObject* values[1] = {0};
+    if (unlikely(__pyx_kwds)) {
+      Py_ssize_t kw_args;
+      const Py_ssize_t pos_args = PyTuple_GET_SIZE(__pyx_args);
+      switch (pos_args) {
+        default:
+        case  1: values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+        case  0: break;
+      }
+      kw_args = PyDict_Size(__pyx_kwds);
+      switch (pos_args) {
+        case  0:
+        if (likely((values[0] = PyDict_GetItem(__pyx_kwds, __pyx_n_s_self)) != 0)) kw_args--;
+        else goto __pyx_L5_argtuple_error;
+      }
+      if (unlikely(kw_args > 0)) {
+        const Py_ssize_t used_pos_args = (pos_args < 1) ? pos_args : 1;
+        if (unlikely(__Pyx_ParseOptionalKeywords(__pyx_kwds, __pyx_pyargnames, 0, values, used_pos_args, "__exit__") < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+      }
+    } else if (PyTuple_GET_SIZE(__pyx_args) < 1) {
+      goto __pyx_L5_argtuple_error;
+    } else {
+      values[0] = PyTuple_GET_ITEM(__pyx_args, 0);
+    }
+    __pyx_v_self = values[0];
+  }
+  goto __pyx_L4_argument_unpacking_done;
+  __pyx_L5_argtuple_error:;
+  __Pyx_RaiseArgtupleInvalid("__exit__", 0, 1, 1, PyTuple_GET_SIZE(__pyx_args)); {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L3_error;}
+  __pyx_L3_error:;
+  __Pyx_DECREF(__pyx_v_args); __pyx_v_args = 0;
+  __Pyx_AddTraceback("cutadapt._seqio.FastqReader.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __Pyx_RefNannyFinishContext();
+  return NULL;
+  __pyx_L4_argument_unpacking_done:;
+  __pyx_r = __pyx_pf_8cutadapt_6_seqio_11FastqReader_9__exit__(__pyx_self, __pyx_v_self, __pyx_v_args);
+
+  /* function exit code */
+  __Pyx_XDECREF(__pyx_v_args);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_pf_8cutadapt_6_seqio_11FastqReader_9__exit__(CYTHON_UNUSED PyObject *__pyx_self, PyObject *__pyx_v_self, CYTHON_UNUSED PyObject *__pyx_v_args) {
+  PyObject *__pyx_r = NULL;
+  __Pyx_RefNannyDeclarations
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannySetupContext("__exit__", 0);
+
+  /* "cutadapt/_seqio.pyx":184
+ * 
+ * 	def __exit__(self, *args):
+ * 		self.close()             # <<<<<<<<<<<<<<
+ */
+  __pyx_t_2 = __Pyx_PyObject_GetAttrStr(__pyx_v_self, __pyx_n_s_close); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __pyx_t_3 = NULL;
+  if (CYTHON_COMPILING_IN_CPYTHON && likely(PyMethod_Check(__pyx_t_2))) {
+    __pyx_t_3 = PyMethod_GET_SELF(__pyx_t_2);
+    if (likely(__pyx_t_3)) {
+      PyObject* function = PyMethod_GET_FUNCTION(__pyx_t_2);
+      __Pyx_INCREF(__pyx_t_3);
+      __Pyx_INCREF(function);
+      __Pyx_DECREF_SET(__pyx_t_2, function);
+    }
+  }
+  if (__pyx_t_3) {
+    __pyx_t_1 = __Pyx_PyObject_CallOneArg(__pyx_t_2, __pyx_t_3); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  } else {
+    __pyx_t_1 = __Pyx_PyObject_CallNoArg(__pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 184; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  }
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+
+  /* "cutadapt/_seqio.pyx":183
+ * 		return self
+ * 
+ * 	def __exit__(self, *args):             # <<<<<<<<<<<<<<
+ * 		self.close()
+ */
+
+  /* function exit code */
+  __pyx_r = Py_None; __Pyx_INCREF(Py_None);
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_AddTraceback("cutadapt._seqio.FastqReader.__exit__", __pyx_clineno, __pyx_lineno, __pyx_filename);
+  __pyx_r = NULL;
+  __pyx_L0:;
+  __Pyx_XGIVEREF(__pyx_r);
+  __Pyx_RefNannyFinishContext();
+  return __pyx_r;
+}
+
+static PyObject *__pyx_tp_new_8cutadapt_6_seqio_Sequence(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+  struct __pyx_obj_8cutadapt_6_seqio_Sequence *p;
+  PyObject *o;
+  if (likely((t->tp_flags & Py_TPFLAGS_IS_ABSTRACT) == 0)) {
+    o = (*t->tp_alloc)(t, 0);
+  } else {
+    o = (PyObject *) PyBaseObject_Type.tp_new(t, __pyx_empty_tuple, 0);
+  }
+  if (unlikely(!o)) return 0;
+  p = ((struct __pyx_obj_8cutadapt_6_seqio_Sequence *)o);
+  p->name = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  p->sequence = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  p->qualities = ((PyObject*)Py_None); Py_INCREF(Py_None);
+  p->match = Py_None; Py_INCREF(Py_None);
+  return o;
+}
+
+static void __pyx_tp_dealloc_8cutadapt_6_seqio_Sequence(PyObject *o) {
+  struct __pyx_obj_8cutadapt_6_seqio_Sequence *p = (struct __pyx_obj_8cutadapt_6_seqio_Sequence *)o;
+  #if PY_VERSION_HEX >= 0x030400a1
+  if (unlikely(Py_TYPE(o)->tp_finalize) && !_PyGC_FINALIZED(o)) {
+    if (PyObject_CallFinalizerFromDealloc(o)) return;
+  }
+  #endif
+  PyObject_GC_UnTrack(o);
+  Py_CLEAR(p->name);
+  Py_CLEAR(p->sequence);
+  Py_CLEAR(p->qualities);
+  Py_CLEAR(p->match);
+  (*Py_TYPE(o)->tp_free)(o);
+}
+
+static int __pyx_tp_traverse_8cutadapt_6_seqio_Sequence(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_8cutadapt_6_seqio_Sequence *p = (struct __pyx_obj_8cutadapt_6_seqio_Sequence *)o;
+  if (p->match) {
+    e = (*v)(p->match, a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_8cutadapt_6_seqio_Sequence(PyObject *o) {
+  PyObject* tmp;
+  struct __pyx_obj_8cutadapt_6_seqio_Sequence *p = (struct __pyx_obj_8cutadapt_6_seqio_Sequence *)o;
+  tmp = ((PyObject*)p->match);
+  p->match = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+static PyObject *__pyx_sq_item_8cutadapt_6_seqio_Sequence(PyObject *o, Py_ssize_t i) {
+  PyObject *r;
+  PyObject *x = PyInt_FromSsize_t(i); if(!x) return 0;
+  r = Py_TYPE(o)->tp_as_mapping->mp_subscript(o, x);
+  Py_DECREF(x);
+  return r;
+}
+
+static PyObject *__pyx_getprop_8cutadapt_6_seqio_8Sequence_name(PyObject *o, CYTHON_UNUSED void *x) {
+  return __pyx_pw_8cutadapt_6_seqio_8Sequence_4name_1__get__(o);
+}
+
+static int __pyx_setprop_8cutadapt_6_seqio_8Sequence_name(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
+  if (v) {
+    return __pyx_pw_8cutadapt_6_seqio_8Sequence_4name_3__set__(o, v);
+  }
+  else {
+    return __pyx_pw_8cutadapt_6_seqio_8Sequence_4name_5__del__(o);
+  }
+}
+
+static PyObject *__pyx_getprop_8cutadapt_6_seqio_8Sequence_sequence(PyObject *o, CYTHON_UNUSED void *x) {
+  return __pyx_pw_8cutadapt_6_seqio_8Sequence_8sequence_1__get__(o);
+}
+
+static int __pyx_setprop_8cutadapt_6_seqio_8Sequence_sequence(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
+  if (v) {
+    return __pyx_pw_8cutadapt_6_seqio_8Sequence_8sequence_3__set__(o, v);
+  }
+  else {
+    return __pyx_pw_8cutadapt_6_seqio_8Sequence_8sequence_5__del__(o);
+  }
+}
+
+static PyObject *__pyx_getprop_8cutadapt_6_seqio_8Sequence_qualities(PyObject *o, CYTHON_UNUSED void *x) {
+  return __pyx_pw_8cutadapt_6_seqio_8Sequence_9qualities_1__get__(o);
+}
+
+static int __pyx_setprop_8cutadapt_6_seqio_8Sequence_qualities(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
+  if (v) {
+    return __pyx_pw_8cutadapt_6_seqio_8Sequence_9qualities_3__set__(o, v);
+  }
+  else {
+    return __pyx_pw_8cutadapt_6_seqio_8Sequence_9qualities_5__del__(o);
+  }
+}
+
+static PyObject *__pyx_getprop_8cutadapt_6_seqio_8Sequence_match(PyObject *o, CYTHON_UNUSED void *x) {
+  return __pyx_pw_8cutadapt_6_seqio_8Sequence_5match_1__get__(o);
+}
+
+static int __pyx_setprop_8cutadapt_6_seqio_8Sequence_match(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
+  if (v) {
+    return __pyx_pw_8cutadapt_6_seqio_8Sequence_5match_3__set__(o, v);
+  }
+  else {
+    return __pyx_pw_8cutadapt_6_seqio_8Sequence_5match_5__del__(o);
+  }
+}
+
+static PyObject *__pyx_getprop_8cutadapt_6_seqio_8Sequence_twoheaders(PyObject *o, CYTHON_UNUSED void *x) {
+  return __pyx_pw_8cutadapt_6_seqio_8Sequence_10twoheaders_1__get__(o);
+}
+
+static int __pyx_setprop_8cutadapt_6_seqio_8Sequence_twoheaders(PyObject *o, PyObject *v, CYTHON_UNUSED void *x) {
+  if (v) {
+    return __pyx_pw_8cutadapt_6_seqio_8Sequence_10twoheaders_3__set__(o, v);
+  }
+  else {
+    PyErr_SetString(PyExc_NotImplementedError, "__del__");
+    return -1;
+  }
+}
+
+static PyMethodDef __pyx_methods_8cutadapt_6_seqio_Sequence[] = {
+  {"__reduce__", (PyCFunction)__pyx_pw_8cutadapt_6_seqio_8Sequence_11__reduce__, METH_NOARGS, 0},
+  {"write", (PyCFunction)__pyx_pw_8cutadapt_6_seqio_8Sequence_13write, METH_O, 0},
+  {0, 0, 0, 0}
+};
+
+static struct PyGetSetDef __pyx_getsets_8cutadapt_6_seqio_Sequence[] = {
+  {(char *)"name", __pyx_getprop_8cutadapt_6_seqio_8Sequence_name, __pyx_setprop_8cutadapt_6_seqio_8Sequence_name, 0, 0},
+  {(char *)"sequence", __pyx_getprop_8cutadapt_6_seqio_8Sequence_sequence, __pyx_setprop_8cutadapt_6_seqio_8Sequence_sequence, 0, 0},
+  {(char *)"qualities", __pyx_getprop_8cutadapt_6_seqio_8Sequence_qualities, __pyx_setprop_8cutadapt_6_seqio_8Sequence_qualities, 0, 0},
+  {(char *)"match", __pyx_getprop_8cutadapt_6_seqio_8Sequence_match, __pyx_setprop_8cutadapt_6_seqio_8Sequence_match, 0, 0},
+  {(char *)"twoheaders", __pyx_getprop_8cutadapt_6_seqio_8Sequence_twoheaders, __pyx_setprop_8cutadapt_6_seqio_8Sequence_twoheaders, 0, 0},
+  {0, 0, 0, 0, 0}
+};
+
+static PySequenceMethods __pyx_tp_as_sequence_Sequence = {
+  __pyx_pw_8cutadapt_6_seqio_8Sequence_7__len__, /*sq_length*/
+  0, /*sq_concat*/
+  0, /*sq_repeat*/
+  __pyx_sq_item_8cutadapt_6_seqio_Sequence, /*sq_item*/
+  0, /*sq_slice*/
+  0, /*sq_ass_item*/
+  0, /*sq_ass_slice*/
+  0, /*sq_contains*/
+  0, /*sq_inplace_concat*/
+  0, /*sq_inplace_repeat*/
+};
+
+static PyMappingMethods __pyx_tp_as_mapping_Sequence = {
+  __pyx_pw_8cutadapt_6_seqio_8Sequence_7__len__, /*mp_length*/
+  __pyx_pw_8cutadapt_6_seqio_8Sequence_3__getitem__, /*mp_subscript*/
+  0, /*mp_ass_subscript*/
+};
+
+static PyTypeObject __pyx_type_8cutadapt_6_seqio_Sequence = {
+  PyVarObject_HEAD_INIT(0, 0)
+  "cutadapt._seqio.Sequence", /*tp_name*/
+  sizeof(struct __pyx_obj_8cutadapt_6_seqio_Sequence), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_8cutadapt_6_seqio_Sequence, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #else
+  0, /*reserved*/
+  #endif
+  __pyx_pw_8cutadapt_6_seqio_8Sequence_5__repr__, /*tp_repr*/
+  0, /*tp_as_number*/
+  &__pyx_tp_as_sequence_Sequence, /*tp_as_sequence*/
+  &__pyx_tp_as_mapping_Sequence, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  0, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_BASETYPE|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  "\n\tA record in a FASTQ file. Also used for FASTA (then the qualities attribute\n\tis None). qualities is a string and it contains the qualities encoded as\n\tascii(qual+33).\n\n\tIf an adapter has been matched to the sequence, the 'match' attribute is\n\tset to the corresponding AdapterMatch instance.\n\t", /*tp_doc*/
+  __pyx_tp_traverse_8cutadapt_6_seqio_Sequence, /*tp_traverse*/
+  __pyx_tp_clear_8cutadapt_6_seqio_Sequence, /*tp_clear*/
+  __pyx_pw_8cutadapt_6_seqio_8Sequence_9__richcmp__, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  __pyx_methods_8cutadapt_6_seqio_Sequence, /*tp_methods*/
+  0, /*tp_members*/
+  __pyx_getsets_8cutadapt_6_seqio_Sequence, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  __pyx_pw_8cutadapt_6_seqio_8Sequence_1__init__, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_8cutadapt_6_seqio_Sequence, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  0, /*tp_version_tag*/
+  #if PY_VERSION_HEX >= 0x030400a1
+  0, /*tp_finalize*/
+  #endif
+};
+
+static struct __pyx_obj_8cutadapt_6_seqio___pyx_scope_struct____iter__ *__pyx_freelist_8cutadapt_6_seqio___pyx_scope_struct____iter__[8];
+static int __pyx_freecount_8cutadapt_6_seqio___pyx_scope_struct____iter__ = 0;
+
+static PyObject *__pyx_tp_new_8cutadapt_6_seqio___pyx_scope_struct____iter__(PyTypeObject *t, CYTHON_UNUSED PyObject *a, CYTHON_UNUSED PyObject *k) {
+  PyObject *o;
+  if (CYTHON_COMPILING_IN_CPYTHON && likely((__pyx_freecount_8cutadapt_6_seqio___pyx_scope_struct____iter__ > 0) & (t->tp_basicsize == sizeof(struct __pyx_obj_8cutadapt_6_seqio___pyx_scope_struct____iter__)))) {
+    o = (PyObject*)__pyx_freelist_8cutadapt_6_seqio___pyx_scope_struct____iter__[--__pyx_freecount_8cutadapt_6_seqio___pyx_scope_struct____iter__];
+    memset(o, 0, sizeof(struct __pyx_obj_8cutadapt_6_seqio___pyx_scope_struct____iter__));
+    (void) PyObject_INIT(o, t);
+    PyObject_GC_Track(o);
+  } else {
+    o = (*t->tp_alloc)(t, 0);
+    if (unlikely(!o)) return 0;
+  }
+  return o;
+}
+
+static void __pyx_tp_dealloc_8cutadapt_6_seqio___pyx_scope_struct____iter__(PyObject *o) {
+  struct __pyx_obj_8cutadapt_6_seqio___pyx_scope_struct____iter__ *p = (struct __pyx_obj_8cutadapt_6_seqio___pyx_scope_struct____iter__ *)o;
+  PyObject_GC_UnTrack(o);
+  Py_CLEAR(p->__pyx_v_it);
+  Py_CLEAR(p->__pyx_v_line);
+  Py_CLEAR(p->__pyx_v_name);
+  Py_CLEAR(p->__pyx_v_qualities);
+  Py_CLEAR(p->__pyx_v_self);
+  Py_CLEAR(p->__pyx_v_sequence);
+  Py_CLEAR(p->__pyx_v_sequence_class);
+  Py_CLEAR(p->__pyx_t_0);
+  if (CYTHON_COMPILING_IN_CPYTHON && ((__pyx_freecount_8cutadapt_6_seqio___pyx_scope_struct____iter__ < 8) & (Py_TYPE(o)->tp_basicsize == sizeof(struct __pyx_obj_8cutadapt_6_seqio___pyx_scope_struct____iter__)))) {
+    __pyx_freelist_8cutadapt_6_seqio___pyx_scope_struct____iter__[__pyx_freecount_8cutadapt_6_seqio___pyx_scope_struct____iter__++] = ((struct __pyx_obj_8cutadapt_6_seqio___pyx_scope_struct____iter__ *)o);
+  } else {
+    (*Py_TYPE(o)->tp_free)(o);
+  }
+}
+
+static int __pyx_tp_traverse_8cutadapt_6_seqio___pyx_scope_struct____iter__(PyObject *o, visitproc v, void *a) {
+  int e;
+  struct __pyx_obj_8cutadapt_6_seqio___pyx_scope_struct____iter__ *p = (struct __pyx_obj_8cutadapt_6_seqio___pyx_scope_struct____iter__ *)o;
+  if (p->__pyx_v_it) {
+    e = (*v)(p->__pyx_v_it, a); if (e) return e;
+  }
+  if (p->__pyx_v_self) {
+    e = (*v)(p->__pyx_v_self, a); if (e) return e;
+  }
+  if (p->__pyx_v_sequence_class) {
+    e = (*v)(p->__pyx_v_sequence_class, a); if (e) return e;
+  }
+  if (p->__pyx_t_0) {
+    e = (*v)(p->__pyx_t_0, a); if (e) return e;
+  }
+  return 0;
+}
+
+static int __pyx_tp_clear_8cutadapt_6_seqio___pyx_scope_struct____iter__(PyObject *o) {
+  PyObject* tmp;
+  struct __pyx_obj_8cutadapt_6_seqio___pyx_scope_struct____iter__ *p = (struct __pyx_obj_8cutadapt_6_seqio___pyx_scope_struct____iter__ *)o;
+  tmp = ((PyObject*)p->__pyx_v_it);
+  p->__pyx_v_it = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_self);
+  p->__pyx_v_self = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_v_sequence_class);
+  p->__pyx_v_sequence_class = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  tmp = ((PyObject*)p->__pyx_t_0);
+  p->__pyx_t_0 = Py_None; Py_INCREF(Py_None);
+  Py_XDECREF(tmp);
+  return 0;
+}
+
+static PyTypeObject __pyx_type_8cutadapt_6_seqio___pyx_scope_struct____iter__ = {
+  PyVarObject_HEAD_INIT(0, 0)
+  "cutadapt._seqio.__pyx_scope_struct____iter__", /*tp_name*/
+  sizeof(struct __pyx_obj_8cutadapt_6_seqio___pyx_scope_struct____iter__), /*tp_basicsize*/
+  0, /*tp_itemsize*/
+  __pyx_tp_dealloc_8cutadapt_6_seqio___pyx_scope_struct____iter__, /*tp_dealloc*/
+  0, /*tp_print*/
+  0, /*tp_getattr*/
+  0, /*tp_setattr*/
+  #if PY_MAJOR_VERSION < 3
+  0, /*tp_compare*/
+  #else
+  0, /*reserved*/
+  #endif
+  0, /*tp_repr*/
+  0, /*tp_as_number*/
+  0, /*tp_as_sequence*/
+  0, /*tp_as_mapping*/
+  0, /*tp_hash*/
+  0, /*tp_call*/
+  0, /*tp_str*/
+  0, /*tp_getattro*/
+  0, /*tp_setattro*/
+  0, /*tp_as_buffer*/
+  Py_TPFLAGS_DEFAULT|Py_TPFLAGS_HAVE_VERSION_TAG|Py_TPFLAGS_CHECKTYPES|Py_TPFLAGS_HAVE_NEWBUFFER|Py_TPFLAGS_HAVE_GC, /*tp_flags*/
+  0, /*tp_doc*/
+  __pyx_tp_traverse_8cutadapt_6_seqio___pyx_scope_struct____iter__, /*tp_traverse*/
+  __pyx_tp_clear_8cutadapt_6_seqio___pyx_scope_struct____iter__, /*tp_clear*/
+  0, /*tp_richcompare*/
+  0, /*tp_weaklistoffset*/
+  0, /*tp_iter*/
+  0, /*tp_iternext*/
+  0, /*tp_methods*/
+  0, /*tp_members*/
+  0, /*tp_getset*/
+  0, /*tp_base*/
+  0, /*tp_dict*/
+  0, /*tp_descr_get*/
+  0, /*tp_descr_set*/
+  0, /*tp_dictoffset*/
+  0, /*tp_init*/
+  0, /*tp_alloc*/
+  __pyx_tp_new_8cutadapt_6_seqio___pyx_scope_struct____iter__, /*tp_new*/
+  0, /*tp_free*/
+  0, /*tp_is_gc*/
+  0, /*tp_bases*/
+  0, /*tp_mro*/
+  0, /*tp_cache*/
+  0, /*tp_subclasses*/
+  0, /*tp_weaklist*/
+  0, /*tp_del*/
+  0, /*tp_version_tag*/
+  #if PY_VERSION_HEX >= 0x030400a1
+  0, /*tp_finalize*/
+  #endif
+};
+
+static PyMethodDef __pyx_methods[] = {
+  {0, 0, 0, 0}
+};
+
+#if PY_MAJOR_VERSION >= 3
+static struct PyModuleDef __pyx_moduledef = {
+  #if PY_VERSION_HEX < 0x03020000
+    { PyObject_HEAD_INIT(NULL) NULL, 0, NULL },
+  #else
+    PyModuleDef_HEAD_INIT,
+  #endif
+    "_seqio",
+    0, /* m_doc */
+    -1, /* m_size */
+    __pyx_methods /* m_methods */,
+    NULL, /* m_reload */
+    NULL, /* m_traverse */
+    NULL, /* m_clear */
+    NULL /* m_free */
+};
+#endif
+
+static __Pyx_StringTabEntry __pyx_string_tab[] = {
+  {&__pyx_kp_s_, __pyx_k_, sizeof(__pyx_k_), 0, 0, 1, 0},
+  {&__pyx_kp_s_At_line_0_Sequence_descriptions, __pyx_k_At_line_0_Sequence_descriptions, sizeof(__pyx_k_At_line_0_Sequence_descriptions), 0, 0, 1, 0},
+  {&__pyx_n_s_Exception, __pyx_k_Exception, sizeof(__pyx_k_Exception), 0, 0, 1, 1},
+  {&__pyx_kp_s_FASTQ_file_ended_prematurely, __pyx_k_FASTQ_file_ended_prematurely, sizeof(__pyx_k_FASTQ_file_ended_prematurely), 0, 0, 1, 0},
+  {&__pyx_n_s_FastqReader, __pyx_k_FastqReader, sizeof(__pyx_k_FastqReader), 0, 0, 1, 1},
+  {&__pyx_n_s_FastqReader___enter, __pyx_k_FastqReader___enter, sizeof(__pyx_k_FastqReader___enter), 0, 0, 1, 1},
+  {&__pyx_n_s_FastqReader___exit, __pyx_k_FastqReader___exit, sizeof(__pyx_k_FastqReader___exit), 0, 0, 1, 1},
+  {&__pyx_n_s_FastqReader___init, __pyx_k_FastqReader___init, sizeof(__pyx_k_FastqReader___init), 0, 0, 1, 1},
+  {&__pyx_n_s_FastqReader___iter, __pyx_k_FastqReader___iter, sizeof(__pyx_k_FastqReader___iter), 0, 0, 1, 1},
+  {&__pyx_n_s_FastqReader_close, __pyx_k_FastqReader_close, sizeof(__pyx_k_FastqReader_close), 0, 0, 1, 1},
+  {&__pyx_n_s_FormatError, __pyx_k_FormatError, sizeof(__pyx_k_FormatError), 0, 0, 1, 1},
+  {&__pyx_kp_s_I_O_operation_on_closed_FastqRea, __pyx_k_I_O_operation_on_closed_FastqRea, sizeof(__pyx_k_I_O_operation_on_closed_FastqRea), 0, 0, 1, 0},
+  {&__pyx_kp_s_In_read_named_0_r_length_of_qual, __pyx_k_In_read_named_0_r_length_of_qual, sizeof(__pyx_k_In_read_named_0_r_length_of_qual), 0, 0, 1, 0},
+  {&__pyx_n_s_NotImplementedError, __pyx_k_NotImplementedError, sizeof(__pyx_k_NotImplementedError), 0, 0, 1, 1},
+  {&__pyx_kp_s_Raised_when_an_input_file_FASTA, __pyx_k_Raised_when_an_input_file_FASTA, sizeof(__pyx_k_Raised_when_an_input_file_FASTA), 0, 0, 1, 0},
+  {&__pyx_kp_s_Reader_for_FASTQ_files_Does_not, __pyx_k_Reader_for_FASTQ_files_Does_not, sizeof(__pyx_k_Reader_for_FASTQ_files_Does_not), 0, 0, 1, 0},
+  {&__pyx_kp_s_Sequence_name_0_r_sequence_1_r, __pyx_k_Sequence_name_0_r_sequence_1_r, sizeof(__pyx_k_Sequence_name_0_r_sequence_1_r), 0, 0, 1, 0},
+  {&__pyx_n_s_ValueError, __pyx_k_ValueError, sizeof(__pyx_k_ValueError), 0, 0, 1, 1},
+  {&__pyx_kp_s__2, __pyx_k__2, sizeof(__pyx_k__2), 0, 0, 1, 0},
+  {&__pyx_kp_s__3, __pyx_k__3, sizeof(__pyx_k__3), 0, 0, 1, 0},
+  {&__pyx_kp_s__4, __pyx_k__4, sizeof(__pyx_k__4), 0, 0, 1, 0},
+  {&__pyx_kp_s__5, __pyx_k__5, sizeof(__pyx_k__5), 0, 0, 1, 0},
+  {&__pyx_kp_s__6, __pyx_k__6, sizeof(__pyx_k__6), 0, 0, 1, 0},
+  {&__pyx_kp_s__7, __pyx_k__7, sizeof(__pyx_k__7), 0, 0, 1, 0},
+  {&__pyx_kp_s__8, __pyx_k__8, sizeof(__pyx_k__8), 0, 0, 1, 0},
+  {&__pyx_kp_s__9, __pyx_k__9, sizeof(__pyx_k__9), 0, 0, 1, 0},
+  {&__pyx_n_s_args, __pyx_k_args, sizeof(__pyx_k_args), 0, 0, 1, 1},
+  {&__pyx_kp_s_at_line_0_expected_a_line_starti, __pyx_k_at_line_0_expected_a_line_starti, sizeof(__pyx_k_at_line_0_expected_a_line_starti), 0, 0, 1, 0},
+  {&__pyx_kp_s_at_line_0_expected_a_line_starti_2, __pyx_k_at_line_0_expected_a_line_starti_2, sizeof(__pyx_k_at_line_0_expected_a_line_starti_2), 0, 0, 1, 0},
+  {&__pyx_n_s_class, __pyx_k_class, sizeof(__pyx_k_class), 0, 0, 1, 1},
+  {&__pyx_n_s_close, __pyx_k_close, sizeof(__pyx_k_close), 0, 0, 1, 1},
+  {&__pyx_n_s_cutadapt__seqio, __pyx_k_cutadapt__seqio, sizeof(__pyx_k_cutadapt__seqio), 0, 0, 1, 1},
+  {&__pyx_n_s_delivers_qualities, __pyx_k_delivers_qualities, sizeof(__pyx_k_delivers_qualities), 0, 0, 1, 1},
+  {&__pyx_n_s_doc, __pyx_k_doc, sizeof(__pyx_k_doc), 0, 0, 1, 1},
+  {&__pyx_n_s_enter, __pyx_k_enter, sizeof(__pyx_k_enter), 0, 0, 1, 1},
+  {&__pyx_n_s_exit, __pyx_k_exit, sizeof(__pyx_k_exit), 0, 0, 1, 1},
+  {&__pyx_n_s_file, __pyx_k_file, sizeof(__pyx_k_file), 0, 0, 1, 1},
+  {&__pyx_n_s_file_passed, __pyx_k_file_passed, sizeof(__pyx_k_file_passed), 0, 0, 1, 1},
+  {&__pyx_n_s_format, __pyx_k_format, sizeof(__pyx_k_format), 0, 0, 1, 1},
+  {&__pyx_n_s_fp, __pyx_k_fp, sizeof(__pyx_k_fp), 0, 0, 1, 1},
+  {&__pyx_kp_s_home_marcel_scm_cutadapt_cutada, __pyx_k_home_marcel_scm_cutadapt_cutada, sizeof(__pyx_k_home_marcel_scm_cutadapt_cutada), 0, 0, 1, 0},
+  {&__pyx_n_s_i, __pyx_k_i, sizeof(__pyx_k_i), 0, 0, 1, 1},
+  {&__pyx_n_s_import, __pyx_k_import, sizeof(__pyx_k_import), 0, 0, 1, 1},
+  {&__pyx_n_s_init, __pyx_k_init, sizeof(__pyx_k_init), 0, 0, 1, 1},
+  {&__pyx_n_s_it, __pyx_k_it, sizeof(__pyx_k_it), 0, 0, 1, 1},
+  {&__pyx_n_s_iter, __pyx_k_iter, sizeof(__pyx_k_iter), 0, 0, 1, 1},
+  {&__pyx_n_s_line, __pyx_k_line, sizeof(__pyx_k_line), 0, 0, 1, 1},
+  {&__pyx_n_s_main, __pyx_k_main, sizeof(__pyx_k_main), 0, 0, 1, 1},
+  {&__pyx_n_s_match, __pyx_k_match, sizeof(__pyx_k_match), 0, 0, 1, 1},
+  {&__pyx_n_s_metaclass, __pyx_k_metaclass, sizeof(__pyx_k_metaclass), 0, 0, 1, 1},
+  {&__pyx_n_s_module, __pyx_k_module, sizeof(__pyx_k_module), 0, 0, 1, 1},
+  {&__pyx_n_s_n, __pyx_k_n, sizeof(__pyx_k_n), 0, 0, 1, 1},
+  {&__pyx_n_s_name, __pyx_k_name, sizeof(__pyx_k_name), 0, 0, 1, 1},
+  {&__pyx_n_s_object, __pyx_k_object, sizeof(__pyx_k_object), 0, 0, 1, 1},
+  {&__pyx_n_s_prepare, __pyx_k_prepare, sizeof(__pyx_k_prepare), 0, 0, 1, 1},
+  {&__pyx_n_s_qualities, __pyx_k_qualities, sizeof(__pyx_k_qualities), 0, 0, 1, 1},
+  {&__pyx_kp_s_qualities_0_r, __pyx_k_qualities_0_r, sizeof(__pyx_k_qualities_0_r), 0, 0, 1, 0},
+  {&__pyx_n_s_qualname, __pyx_k_qualname, sizeof(__pyx_k_qualname), 0, 0, 1, 1},
+  {&__pyx_n_s_rstrip, __pyx_k_rstrip, sizeof(__pyx_k_rstrip), 0, 0, 1, 1},
+  {&__pyx_n_s_s, __pyx_k_s, sizeof(__pyx_k_s), 0, 0, 1, 1},
+  {&__pyx_n_s_self, __pyx_k_self, sizeof(__pyx_k_self), 0, 0, 1, 1},
+  {&__pyx_n_s_send, __pyx_k_send, sizeof(__pyx_k_send), 0, 0, 1, 1},
+  {&__pyx_n_s_sequence, __pyx_k_sequence, sizeof(__pyx_k_sequence), 0, 0, 1, 1},
+  {&__pyx_n_s_sequence_class, __pyx_k_sequence_class, sizeof(__pyx_k_sequence_class), 0, 0, 1, 1},
+  {&__pyx_n_s_shorten, __pyx_k_shorten, sizeof(__pyx_k_shorten), 0, 0, 1, 1},
+  {&__pyx_n_s_strip, __pyx_k_strip, sizeof(__pyx_k_strip), 0, 0, 1, 1},
+  {&__pyx_n_s_test, __pyx_k_test, sizeof(__pyx_k_test), 0, 0, 1, 1},
+  {&__pyx_n_s_throw, __pyx_k_throw, sizeof(__pyx_k_throw), 0, 0, 1, 1},
+  {&__pyx_n_s_twoheaders, __pyx_k_twoheaders, sizeof(__pyx_k_twoheaders), 0, 0, 1, 1},
+  {&__pyx_n_s_write, __pyx_k_write, sizeof(__pyx_k_write), 0, 0, 1, 1},
+  {&__pyx_n_s_xopen, __pyx_k_xopen, sizeof(__pyx_k_xopen), 0, 0, 1, 1},
+  {0, 0, 0, 0, 0, 0, 0}
+};
+static int __Pyx_InitCachedBuiltins(void) {
+  __pyx_builtin_Exception = __Pyx_GetBuiltinName(__pyx_n_s_Exception); if (!__pyx_builtin_Exception) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_object = __Pyx_GetBuiltinName(__pyx_n_s_object); if (!__pyx_builtin_object) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_NotImplementedError = __Pyx_GetBuiltinName(__pyx_n_s_NotImplementedError); if (!__pyx_builtin_NotImplementedError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 82; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_builtin_ValueError = __Pyx_GetBuiltinName(__pyx_n_s_ValueError); if (!__pyx_builtin_ValueError) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  return 0;
+  __pyx_L1_error:;
+  return -1;
+}
+
+static int __Pyx_InitCachedConstants(void) {
+  __Pyx_RefNannyDeclarations
+  __Pyx_RefNannySetupContext("__Pyx_InitCachedConstants", 0);
+
+  /* "cutadapt/_seqio.pyx":167
+ * 					qualities = line[:strip]
+ * 				else:
+ * 					qualities = line.rstrip('\r\n')             # <<<<<<<<<<<<<<
+ * 				yield sequence_class(name, sequence, qualities, twoheaders=twoheaders)
+ * 			i = (i + 1) % 4
+ */
+  __pyx_tuple__10 = PyTuple_Pack(1, __pyx_kp_s__7); if (unlikely(!__pyx_tuple__10)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 167; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_tuple__10);
+  __Pyx_GIVEREF(__pyx_tuple__10);
+
+  /* "cutadapt/_seqio.pyx":171
+ * 			i = (i + 1) % 4
+ * 		if i != 0:
+ * 			raise FormatError("FASTQ file ended prematurely")             # <<<<<<<<<<<<<<
+ * 
+ * 	def close(self):
+ */
+  __pyx_tuple__11 = PyTuple_Pack(1, __pyx_kp_s_FASTQ_file_ended_prematurely); if (unlikely(!__pyx_tuple__11)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 171; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_tuple__11);
+  __Pyx_GIVEREF(__pyx_tuple__11);
+
+  /* "cutadapt/_seqio.pyx":180
+ * 	def __enter__(self):
+ * 		if self.fp is None:
+ * 			raise ValueError("I/O operation on closed FastqReader")             # <<<<<<<<<<<<<<
+ * 		return self
+ * 
+ */
+  __pyx_tuple__12 = PyTuple_Pack(1, __pyx_kp_s_I_O_operation_on_closed_FastqRea); if (unlikely(!__pyx_tuple__12)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 180; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_tuple__12);
+  __Pyx_GIVEREF(__pyx_tuple__12);
+
+  /* "cutadapt/_seqio.pyx":16
+ * 
+ * 
+ * def _shorten(s, n=100):             # <<<<<<<<<<<<<<
+ * 	"""Shorten string s to at most n characters, appending "..." if necessary."""
+ * 	if s is None:
+ */
+  __pyx_tuple__13 = PyTuple_Pack(2, __pyx_n_s_s, __pyx_n_s_n); if (unlikely(!__pyx_tuple__13)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_tuple__13);
+  __Pyx_GIVEREF(__pyx_tuple__13);
+  __pyx_codeobj__14 = (PyObject*)__Pyx_PyCode_New(2, 0, 2, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__13, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_marcel_scm_cutadapt_cutada, __pyx_n_s_shorten, 16, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__14)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "cutadapt/_seqio.pyx":102
+ * 	Reader for FASTQ files. Does not support multi-line FASTQ files.
+ * 	"""
+ * 	def __init__(self, file, sequence_class=Sequence):             # <<<<<<<<<<<<<<
+ * 		"""
+ * 		file is a filename or a file-like object.
+ */
+  __pyx_tuple__15 = PyTuple_Pack(3, __pyx_n_s_self, __pyx_n_s_file, __pyx_n_s_sequence_class); if (unlikely(!__pyx_tuple__15)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_tuple__15);
+  __Pyx_GIVEREF(__pyx_tuple__15);
+  __pyx_codeobj__16 = (PyObject*)__Pyx_PyCode_New(3, 0, 3, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__15, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_marcel_scm_cutadapt_cutada, __pyx_n_s_init, 102, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__16)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "cutadapt/_seqio.pyx":119
+ * 		self.delivers_qualities = True
+ * 
+ * 	def __iter__(self):             # <<<<<<<<<<<<<<
+ * 		"""
+ * 		Return tuples: (name, sequence, qualities).
+ */
+  __pyx_tuple__17 = PyTuple_Pack(10, __pyx_n_s_self, __pyx_n_s_i, __pyx_n_s_strip, __pyx_n_s_line, __pyx_n_s_name, __pyx_n_s_qualities, __pyx_n_s_sequence, __pyx_n_s_twoheaders, __pyx_n_s_sequence_class, __pyx_n_s_it); if (unlikely(!__pyx_tuple__17)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_tuple__17);
+  __Pyx_GIVEREF(__pyx_tuple__17);
+  __pyx_codeobj__18 = (PyObject*)__Pyx_PyCode_New(1, 0, 10, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__17, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_marcel_scm_cutadapt_cutada, __pyx_n_s_iter, 119, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__18)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "cutadapt/_seqio.pyx":173
+ * 			raise FormatError("FASTQ file ended prematurely")
+ * 
+ * 	def close(self):             # <<<<<<<<<<<<<<
+ * 		if not self._file_passed and self.fp is not None:
+ * 			self.fp.close()
+ */
+  __pyx_tuple__19 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__19)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_tuple__19);
+  __Pyx_GIVEREF(__pyx_tuple__19);
+  __pyx_codeobj__20 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__19, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_marcel_scm_cutadapt_cutada, __pyx_n_s_close, 173, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__20)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "cutadapt/_seqio.pyx":178
+ * 			self.fp = None
+ * 
+ * 	def __enter__(self):             # <<<<<<<<<<<<<<
+ * 		if self.fp is None:
+ * 			raise ValueError("I/O operation on closed FastqReader")
+ */
+  __pyx_tuple__21 = PyTuple_Pack(1, __pyx_n_s_self); if (unlikely(!__pyx_tuple__21)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_tuple__21);
+  __Pyx_GIVEREF(__pyx_tuple__21);
+  __pyx_codeobj__22 = (PyObject*)__Pyx_PyCode_New(1, 0, 1, 0, 0, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__21, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_marcel_scm_cutadapt_cutada, __pyx_n_s_enter, 178, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__22)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+
+  /* "cutadapt/_seqio.pyx":183
+ * 		return self
+ * 
+ * 	def __exit__(self, *args):             # <<<<<<<<<<<<<<
+ * 		self.close()
+ */
+  __pyx_tuple__23 = PyTuple_Pack(2, __pyx_n_s_self, __pyx_n_s_args); if (unlikely(!__pyx_tuple__23)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_tuple__23);
+  __Pyx_GIVEREF(__pyx_tuple__23);
+  __pyx_codeobj__24 = (PyObject*)__Pyx_PyCode_New(1, 0, 2, 0, CO_VARARGS, __pyx_empty_bytes, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_tuple__23, __pyx_empty_tuple, __pyx_empty_tuple, __pyx_kp_s_home_marcel_scm_cutadapt_cutada, __pyx_n_s_exit, 183, __pyx_empty_bytes); if (unlikely(!__pyx_codeobj__24)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_RefNannyFinishContext();
+  return 0;
+  __pyx_L1_error:;
+  __Pyx_RefNannyFinishContext();
+  return -1;
+}
+
+static int __Pyx_InitGlobals(void) {
+  if (__Pyx_InitStrings(__pyx_string_tab) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  __pyx_int_3 = PyInt_FromLong(3); if (unlikely(!__pyx_int_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_int_100 = PyInt_FromLong(100); if (unlikely(!__pyx_int_100)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  return 0;
+  __pyx_L1_error:;
+  return -1;
+}
+
+#if PY_MAJOR_VERSION < 3
+PyMODINIT_FUNC init_seqio(void); /*proto*/
+PyMODINIT_FUNC init_seqio(void)
+#else
+PyMODINIT_FUNC PyInit__seqio(void); /*proto*/
+PyMODINIT_FUNC PyInit__seqio(void)
+#endif
+{
+  PyObject *__pyx_t_1 = NULL;
+  PyObject *__pyx_t_2 = NULL;
+  PyObject *__pyx_t_3 = NULL;
+  PyObject *__pyx_t_4 = NULL;
+  int __pyx_lineno = 0;
+  const char *__pyx_filename = NULL;
+  int __pyx_clineno = 0;
+  __Pyx_RefNannyDeclarations
+  #if CYTHON_REFNANNY
+  __Pyx_RefNanny = __Pyx_RefNannyImportAPI("refnanny");
+  if (!__Pyx_RefNanny) {
+      PyErr_Clear();
+      __Pyx_RefNanny = __Pyx_RefNannyImportAPI("Cython.Runtime.refnanny");
+      if (!__Pyx_RefNanny)
+          Py_FatalError("failed to import 'refnanny' module");
+  }
+  #endif
+  __Pyx_RefNannySetupContext("PyMODINIT_FUNC PyInit__seqio(void)", 0);
+  if ( __Pyx_check_binary_version() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_empty_tuple = PyTuple_New(0); if (unlikely(!__pyx_empty_tuple)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_empty_bytes = PyBytes_FromStringAndSize("", 0); if (unlikely(!__pyx_empty_bytes)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #ifdef __Pyx_CyFunction_USED
+  if (__Pyx_CyFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #endif
+  #ifdef __Pyx_FusedFunction_USED
+  if (__pyx_FusedFunction_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #endif
+  #ifdef __Pyx_Generator_USED
+  if (__pyx_Generator_init() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #endif
+  /*--- Library function declarations ---*/
+  /*--- Threads initialization code ---*/
+  #if defined(__PYX_FORCE_INIT_THREADS) && __PYX_FORCE_INIT_THREADS
+  #ifdef WITH_THREAD /* Python build with threading support? */
+  PyEval_InitThreads();
+  #endif
+  #endif
+  /*--- Module creation code ---*/
+  #if PY_MAJOR_VERSION < 3
+  __pyx_m = Py_InitModule4("_seqio", __pyx_methods, 0, 0, PYTHON_API_VERSION); Py_XINCREF(__pyx_m);
+  #else
+  __pyx_m = PyModule_Create(&__pyx_moduledef);
+  #endif
+  if (unlikely(!__pyx_m)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_d = PyModule_GetDict(__pyx_m); if (unlikely(!__pyx_d)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  Py_INCREF(__pyx_d);
+  __pyx_b = PyImport_AddModule(__Pyx_BUILTIN_MODULE_NAME); if (unlikely(!__pyx_b)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #if CYTHON_COMPILING_IN_PYPY
+  Py_INCREF(__pyx_b);
+  #endif
+  if (PyObject_SetAttrString(__pyx_m, "__builtins__", __pyx_b) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  /*--- Initialize various global constants etc. ---*/
+  if (unlikely(__Pyx_InitGlobals() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #if PY_MAJOR_VERSION < 3 && (__PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT)
+  if (__Pyx_init_sys_getdefaultencoding_params() < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  #endif
+  if (__pyx_module_is_main_cutadapt___seqio) {
+    if (PyObject_SetAttrString(__pyx_m, "__name__", __pyx_n_s_main) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;};
+  }
+  #if PY_MAJOR_VERSION >= 3
+  {
+    PyObject *modules = PyImport_GetModuleDict(); if (unlikely(!modules)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (!PyDict_GetItemString(modules, "cutadapt._seqio")) {
+      if (unlikely(PyDict_SetItemString(modules, "cutadapt._seqio", __pyx_m) < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    }
+  }
+  #endif
+  /*--- Builtin init code ---*/
+  if (unlikely(__Pyx_InitCachedBuiltins() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  /*--- Constants init code ---*/
+  if (unlikely(__Pyx_InitCachedConstants() < 0)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  /*--- Global init code ---*/
+  /*--- Variable export code ---*/
+  /*--- Function export code ---*/
+  /*--- Type init code ---*/
+  if (PyType_Ready(&__pyx_type_8cutadapt_6_seqio_Sequence) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_type_8cutadapt_6_seqio_Sequence.tp_print = 0;
+  #if CYTHON_COMPILING_IN_CPYTHON
+  {
+    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_8cutadapt_6_seqio_Sequence, "__init__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
+      __pyx_wrapperbase_8cutadapt_6_seqio_8Sequence___init__ = *((PyWrapperDescrObject *)wrapper)->d_base;
+      __pyx_wrapperbase_8cutadapt_6_seqio_8Sequence___init__.doc = __pyx_doc_8cutadapt_6_seqio_8Sequence___init__;
+      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_8cutadapt_6_seqio_8Sequence___init__;
+    }
+  }
+  #endif
+  #if CYTHON_COMPILING_IN_CPYTHON
+  {
+    PyObject *wrapper = PyObject_GetAttrString((PyObject *)&__pyx_type_8cutadapt_6_seqio_Sequence, "__getitem__"); if (unlikely(!wrapper)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+    if (Py_TYPE(wrapper) == &PyWrapperDescr_Type) {
+      __pyx_wrapperbase_8cutadapt_6_seqio_8Sequence_2__getitem__ = *((PyWrapperDescrObject *)wrapper)->d_base;
+      __pyx_wrapperbase_8cutadapt_6_seqio_8Sequence_2__getitem__.doc = __pyx_doc_8cutadapt_6_seqio_8Sequence_2__getitem__;
+      ((PyWrapperDescrObject *)wrapper)->d_base = &__pyx_wrapperbase_8cutadapt_6_seqio_8Sequence_2__getitem__;
+    }
+  }
+  #endif
+  if (PyObject_SetAttrString(__pyx_m, "Sequence", (PyObject *)&__pyx_type_8cutadapt_6_seqio_Sequence) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 25; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_ptype_8cutadapt_6_seqio_Sequence = &__pyx_type_8cutadapt_6_seqio_Sequence;
+  if (PyType_Ready(&__pyx_type_8cutadapt_6_seqio___pyx_scope_struct____iter__) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __pyx_type_8cutadapt_6_seqio___pyx_scope_struct____iter__.tp_print = 0;
+  __pyx_ptype_8cutadapt_6_seqio___pyx_scope_struct____iter__ = &__pyx_type_8cutadapt_6_seqio___pyx_scope_struct____iter__;
+  /*--- Type import code ---*/
+  /*--- Variable import code ---*/
+  /*--- Function import code ---*/
+  /*--- Execution code ---*/
+
+  /* "cutadapt/_seqio.pyx":4
+ * # cython: profile=False
+ * from __future__ import print_function, division, absolute_import
+ * from .xopen import xopen             # <<<<<<<<<<<<<<
+ * 
+ * # TODO
+ */
+  __pyx_t_1 = PyList_New(1); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __Pyx_INCREF(__pyx_n_s_xopen);
+  __Pyx_GIVEREF(__pyx_n_s_xopen);
+  PyList_SET_ITEM(__pyx_t_1, 0, __pyx_n_s_xopen);
+  __pyx_t_2 = __Pyx_Import(__pyx_n_s_xopen, __pyx_t_1, 1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __pyx_t_1 = __Pyx_ImportFrom(__pyx_t_2, __pyx_n_s_xopen); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_xopen, __pyx_t_1) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 4; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "cutadapt/_seqio.pyx":10
+ * # since we would get circular imports
+ * 
+ * class FormatError(Exception):             # <<<<<<<<<<<<<<
+ * 	"""
+ * 	Raised when an input file (FASTA or FASTQ) is malformatted.
+ */
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_builtin_Exception);
+  __Pyx_GIVEREF(__pyx_builtin_Exception);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_builtin_Exception);
+  __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_2, __pyx_n_s_FormatError, __pyx_n_s_FormatError, (PyObject *) NULL, __pyx_n_s_cutadapt__seqio, __pyx_kp_s_Raised_when_an_input_file_FASTA); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+  __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_FormatError, __pyx_t_2, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_FormatError, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 10; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "cutadapt/_seqio.pyx":16
+ * 
+ * 
+ * def _shorten(s, n=100):             # <<<<<<<<<<<<<<
+ * 	"""Shorten string s to at most n characters, appending "..." if necessary."""
+ * 	if s is None:
+ */
+  __pyx_t_2 = PyCFunction_NewEx(&__pyx_mdef_8cutadapt_6_seqio_1_shorten, NULL, __pyx_n_s_cutadapt__seqio); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_shorten, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 16; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "cutadapt/_seqio.pyx":98
+ * 
+ * 
+ * class FastqReader(object):             # <<<<<<<<<<<<<<
+ * 	"""
+ * 	Reader for FASTQ files. Does not support multi-line FASTQ files.
+ */
+  __pyx_t_2 = PyTuple_New(1); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  __Pyx_INCREF(__pyx_builtin_object);
+  __Pyx_GIVEREF(__pyx_builtin_object);
+  PyTuple_SET_ITEM(__pyx_t_2, 0, __pyx_builtin_object);
+  __pyx_t_1 = __Pyx_CalculateMetaclass(NULL, __pyx_t_2); if (unlikely(!__pyx_t_1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_1);
+  __pyx_t_3 = __Pyx_Py3MetaclassPrepare(__pyx_t_1, __pyx_t_2, __pyx_n_s_FastqReader, __pyx_n_s_FastqReader, (PyObject *) NULL, __pyx_n_s_cutadapt__seqio, __pyx_kp_s_Reader_for_FASTQ_files_Does_not); if (unlikely(!__pyx_t_3)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_3);
+
+  /* "cutadapt/_seqio.pyx":102
+ * 	Reader for FASTQ files. Does not support multi-line FASTQ files.
+ * 	"""
+ * 	def __init__(self, file, sequence_class=Sequence):             # <<<<<<<<<<<<<<
+ * 		"""
+ * 		file is a filename or a file-like object.
+ */
+  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_8cutadapt_6_seqio_11FastqReader_1__init__, 0, __pyx_n_s_FastqReader___init, NULL, __pyx_n_s_cutadapt__seqio, __pyx_d, ((PyObject *)__pyx_codeobj__16)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  if (!__Pyx_CyFunction_InitDefaults(__pyx_t_4, sizeof(__pyx_defaults), 1)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_INCREF(((PyObject *)((PyObject*)__pyx_ptype_8cutadapt_6_seqio_Sequence)));
+  __Pyx_CyFunction_Defaults(__pyx_defaults, __pyx_t_4)->__pyx_arg_sequence_class = ((PyObject *)((PyObject*)__pyx_ptype_8cutadapt_6_seqio_Sequence));
+  __Pyx_GIVEREF(((PyObject*)__pyx_ptype_8cutadapt_6_seqio_Sequence));
+  __Pyx_CyFunction_SetDefaultsGetter(__pyx_t_4, __pyx_pf_8cutadapt_6_seqio_11FastqReader_11__defaults__);
+  if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_init, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 102; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "cutadapt/_seqio.pyx":119
+ * 		self.delivers_qualities = True
+ * 
+ * 	def __iter__(self):             # <<<<<<<<<<<<<<
+ * 		"""
+ * 		Return tuples: (name, sequence, qualities).
+ */
+  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_8cutadapt_6_seqio_11FastqReader_3__iter__, 0, __pyx_n_s_FastqReader___iter, NULL, __pyx_n_s_cutadapt__seqio, __pyx_d, ((PyObject *)__pyx_codeobj__18)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_iter, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 119; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "cutadapt/_seqio.pyx":173
+ * 			raise FormatError("FASTQ file ended prematurely")
+ * 
+ * 	def close(self):             # <<<<<<<<<<<<<<
+ * 		if not self._file_passed and self.fp is not None:
+ * 			self.fp.close()
+ */
+  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_8cutadapt_6_seqio_11FastqReader_6close, 0, __pyx_n_s_FastqReader_close, NULL, __pyx_n_s_cutadapt__seqio, __pyx_d, ((PyObject *)__pyx_codeobj__20)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_close, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 173; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "cutadapt/_seqio.pyx":178
+ * 			self.fp = None
+ * 
+ * 	def __enter__(self):             # <<<<<<<<<<<<<<
+ * 		if self.fp is None:
+ * 			raise ValueError("I/O operation on closed FastqReader")
+ */
+  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_8cutadapt_6_seqio_11FastqReader_8__enter__, 0, __pyx_n_s_FastqReader___enter, NULL, __pyx_n_s_cutadapt__seqio, __pyx_d, ((PyObject *)__pyx_codeobj__22)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_enter, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 178; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "cutadapt/_seqio.pyx":183
+ * 		return self
+ * 
+ * 	def __exit__(self, *args):             # <<<<<<<<<<<<<<
+ * 		self.close()
+ */
+  __pyx_t_4 = __Pyx_CyFunction_NewEx(&__pyx_mdef_8cutadapt_6_seqio_11FastqReader_10__exit__, 0, __pyx_n_s_FastqReader___exit, NULL, __pyx_n_s_cutadapt__seqio, __pyx_d, ((PyObject *)__pyx_codeobj__24)); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  if (PyObject_SetItem(__pyx_t_3, __pyx_n_s_exit, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 183; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+
+  /* "cutadapt/_seqio.pyx":98
+ * 
+ * 
+ * class FastqReader(object):             # <<<<<<<<<<<<<<
+ * 	"""
+ * 	Reader for FASTQ files. Does not support multi-line FASTQ files.
+ */
+  __pyx_t_4 = __Pyx_Py3ClassCreate(__pyx_t_1, __pyx_n_s_FastqReader, __pyx_t_2, __pyx_t_3, NULL, 0, 1); if (unlikely(!__pyx_t_4)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_4);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_FastqReader, __pyx_t_4) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 98; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_4); __pyx_t_4 = 0;
+  __Pyx_DECREF(__pyx_t_3); __pyx_t_3 = 0;
+  __Pyx_DECREF(__pyx_t_1); __pyx_t_1 = 0;
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /* "cutadapt/_seqio.pyx":1
+ * # kate: syntax Python;             # <<<<<<<<<<<<<<
+ * # cython: profile=False
+ * from __future__ import print_function, division, absolute_import
+ */
+  __pyx_t_2 = PyDict_New(); if (unlikely(!__pyx_t_2)) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_GOTREF(__pyx_t_2);
+  if (PyDict_SetItem(__pyx_d, __pyx_n_s_test, __pyx_t_2) < 0) {__pyx_filename = __pyx_f[0]; __pyx_lineno = 1; __pyx_clineno = __LINE__; goto __pyx_L1_error;}
+  __Pyx_DECREF(__pyx_t_2); __pyx_t_2 = 0;
+
+  /*--- Wrapped vars code ---*/
+
+  goto __pyx_L0;
+  __pyx_L1_error:;
+  __Pyx_XDECREF(__pyx_t_1);
+  __Pyx_XDECREF(__pyx_t_2);
+  __Pyx_XDECREF(__pyx_t_3);
+  __Pyx_XDECREF(__pyx_t_4);
+  if (__pyx_m) {
+    if (__pyx_d) {
+      __Pyx_AddTraceback("init cutadapt._seqio", __pyx_clineno, __pyx_lineno, __pyx_filename);
+    }
+    Py_DECREF(__pyx_m); __pyx_m = 0;
+  } else if (!PyErr_Occurred()) {
+    PyErr_SetString(PyExc_ImportError, "init cutadapt._seqio");
+  }
+  __pyx_L0:;
+  __Pyx_RefNannyFinishContext();
+  #if PY_MAJOR_VERSION < 3
+  return;
+  #else
+  return __pyx_m;
+  #endif
+}
+
+/* --- Runtime support code --- */
+#if CYTHON_REFNANNY
+static __Pyx_RefNannyAPIStruct *__Pyx_RefNannyImportAPI(const char *modname) {
+    PyObject *m = NULL, *p = NULL;
+    void *r = NULL;
+    m = PyImport_ImportModule((char *)modname);
+    if (!m) goto end;
+    p = PyObject_GetAttrString(m, (char *)"RefNannyAPI");
+    if (!p) goto end;
+    r = PyLong_AsVoidPtr(p);
+end:
+    Py_XDECREF(p);
+    Py_XDECREF(m);
+    return (__Pyx_RefNannyAPIStruct *)r;
+}
+#endif
+
+static PyObject *__Pyx_GetBuiltinName(PyObject *name) {
+    PyObject* result = __Pyx_PyObject_GetAttrStr(__pyx_b, name);
+    if (unlikely(!result)) {
+        PyErr_Format(PyExc_NameError,
+#if PY_MAJOR_VERSION >= 3
+            "name '%U' is not defined", name);
+#else
+            "name '%.200s' is not defined", PyString_AS_STRING(name));
+#endif
+    }
+    return result;
+}
+
+static void __Pyx_RaiseDoubleKeywordsError(
+    const char* func_name,
+    PyObject* kw_name)
+{
+    PyErr_Format(PyExc_TypeError,
+        #if PY_MAJOR_VERSION >= 3
+        "%s() got multiple values for keyword argument '%U'", func_name, kw_name);
+        #else
+        "%s() got multiple values for keyword argument '%s'", func_name,
+        PyString_AsString(kw_name));
+        #endif
+}
+
+static int __Pyx_ParseOptionalKeywords(
+    PyObject *kwds,
+    PyObject **argnames[],
+    PyObject *kwds2,
+    PyObject *values[],
+    Py_ssize_t num_pos_args,
+    const char* function_name)
+{
+    PyObject *key = 0, *value = 0;
+    Py_ssize_t pos = 0;
+    PyObject*** name;
+    PyObject*** first_kw_arg = argnames + num_pos_args;
+    while (PyDict_Next(kwds, &pos, &key, &value)) {
+        name = first_kw_arg;
+        while (*name && (**name != key)) name++;
+        if (*name) {
+            values[name-argnames] = value;
+            continue;
+        }
+        name = first_kw_arg;
+        #if PY_MAJOR_VERSION < 3
+        if (likely(PyString_CheckExact(key)) || likely(PyString_Check(key))) {
+            while (*name) {
+                if ((CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**name) == PyString_GET_SIZE(key))
+                        && _PyString_Eq(**name, key)) {
+                    values[name-argnames] = value;
+                    break;
+                }
+                name++;
+            }
+            if (*name) continue;
+            else {
+                PyObject*** argname = argnames;
+                while (argname != first_kw_arg) {
+                    if ((**argname == key) || (
+                            (CYTHON_COMPILING_IN_PYPY || PyString_GET_SIZE(**argname) == PyString_GET_SIZE(key))
+                             && _PyString_Eq(**argname, key))) {
+                        goto arg_passed_twice;
+                    }
+                    argname++;
+                }
+            }
+        } else
+        #endif
+        if (likely(PyUnicode_Check(key))) {
+            while (*name) {
+                int cmp = (**name == key) ? 0 :
+                #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
+                    (PyUnicode_GET_SIZE(**name) != PyUnicode_GET_SIZE(key)) ? 1 :
+                #endif
+                    PyUnicode_Compare(**name, key);
+                if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
+                if (cmp == 0) {
+                    values[name-argnames] = value;
+                    break;
+                }
+                name++;
+            }
+            if (*name) continue;
+            else {
+                PyObject*** argname = argnames;
+                while (argname != first_kw_arg) {
+                    int cmp = (**argname == key) ? 0 :
+                    #if !CYTHON_COMPILING_IN_PYPY && PY_MAJOR_VERSION >= 3
+                        (PyUnicode_GET_SIZE(**argname) != PyUnicode_GET_SIZE(key)) ? 1 :
+                    #endif
+                        PyUnicode_Compare(**argname, key);
+                    if (cmp < 0 && unlikely(PyErr_Occurred())) goto bad;
+                    if (cmp == 0) goto arg_passed_twice;
+                    argname++;
+                }
+            }
+        } else
+            goto invalid_keyword_type;
+        if (kwds2) {
+            if (unlikely(PyDict_SetItem(kwds2, key, value))) goto bad;
+        } else {
+            goto invalid_keyword;
+        }
+    }
+    return 0;
+arg_passed_twice:
+    __Pyx_RaiseDoubleKeywordsError(function_name, key);
+    goto bad;
+invalid_keyword_type:
+    PyErr_Format(PyExc_TypeError,
+        "%.200s() keywords must be strings", function_name);
+    goto bad;
+invalid_keyword:
+    PyErr_Format(PyExc_TypeError,
+    #if PY_MAJOR_VERSION < 3
+        "%.200s() got an unexpected keyword argument '%.200s'",
+        function_name, PyString_AsString(key));
+    #else
+        "%s() got an unexpected keyword argument '%U'",
+        function_name, key);
+    #endif
+bad:
+    return -1;
+}
+
+static void __Pyx_RaiseArgtupleInvalid(
+    const char* func_name,
+    int exact,
+    Py_ssize_t num_min,
+    Py_ssize_t num_max,
+    Py_ssize_t num_found)
+{
+    Py_ssize_t num_expected;
+    const char *more_or_less;
+    if (num_found < num_min) {
+        num_expected = num_min;
+        more_or_less = "at least";
+    } else {
+        num_expected = num_max;
+        more_or_less = "at most";
+    }
+    if (exact) {
+        more_or_less = "exactly";
+    }
+    PyErr_Format(PyExc_TypeError,
+                 "%.200s() takes %.8s %" CYTHON_FORMAT_SSIZE_T "d positional argument%.1s (%" CYTHON_FORMAT_SSIZE_T "d given)",
+                 func_name, more_or_less, num_expected,
+                 (num_expected == 1) ? "" : "s", num_found);
+}
+
+static CYTHON_INLINE PyObject* __Pyx_PyObject_GetSlice(PyObject* obj,
+        Py_ssize_t cstart, Py_ssize_t cstop,
+        PyObject** _py_start, PyObject** _py_stop, PyObject** _py_slice,
+        int has_cstart, int has_cstop, CYTHON_UNUSED int wraparound) {
+#if CYTHON_COMPILING_IN_CPYTHON
+    PyMappingMethods* mp;
+#if PY_MAJOR_VERSION < 3
+    PySequenceMethods* ms = Py_TYPE(obj)->tp_as_sequence;
+    if (likely(ms && ms->sq_slice)) {
+        if (!has_cstart) {
+            if (_py_start && (*_py_start != Py_None)) {
+                cstart = __Pyx_PyIndex_AsSsize_t(*_py_start);
+                if ((cstart == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
+            } else
+                cstart = 0;
+        }
+        if (!has_cstop) {
+            if (_py_stop && (*_py_stop != Py_None)) {
+                cstop = __Pyx_PyIndex_AsSsize_t(*_py_stop);
+                if ((cstop == (Py_ssize_t)-1) && PyErr_Occurred()) goto bad;
+            } else
+                cstop = PY_SSIZE_T_MAX;
+        }
+        if (wraparound && unlikely((cstart < 0) | (cstop < 0)) && likely(ms->sq_length)) {
+            Py_ssize_t l = ms->sq_length(obj);
+            if (likely(l >= 0)) {
+                if (cstop < 0) {
+                    cstop += l;
+                    if (cstop < 0) cstop = 0;
+                }
+                if (cstart < 0) {
+                    cstart += l;
+                    if (cstart < 0) cstart = 0;
+                }
+            } else {
+                if (PyErr_ExceptionMatches(PyExc_OverflowError))
+                    PyErr_Clear();
+                else
+                    goto bad;
+            }
+        }
+        return ms->sq_slice(obj, cstart, cstop);
+    }
+#endif
+    mp = Py_TYPE(obj)->tp_as_mapping;
+    if (likely(mp && mp->mp_subscript))
+#endif
+    {
+        PyObject* result;
+        PyObject *py_slice, *py_start, *py_stop;
+        if (_py_slice) {
+            py_slice = *_py_slice;
+        } else {
+            PyObject* owned_start = NULL;
+            PyObject* owned_stop = NULL;
+            if (_py_start) {
+                py_start = *_py_start;
+            } else {
+                if (has_cstart) {
+                    owned_start = py_start = PyInt_FromSsize_t(cstart);
+                    if (unlikely(!py_start)) goto bad;
+                } else
+                    py_start = Py_None;
+            }
+            if (_py_stop) {
+                py_stop = *_py_stop;
+            } else {
+                if (has_cstop) {
+                    owned_stop = py_stop = PyInt_FromSsize_t(cstop);
+                    if (unlikely(!py_stop)) {
+                        Py_XDECREF(owned_start);
+                        goto bad;
+                    }
+                } else
+                    py_stop = Py_None;
+            }
+            py_slice = PySlice_New(py_start, py_stop, Py_None);
+            Py_XDECREF(owned_start);
+            Py_XDECREF(owned_stop);
+            if (unlikely(!py_slice)) goto bad;
+        }
+#if CYTHON_COMPILING_IN_CPYTHON
+        result = mp->mp_subscript(obj, py_slice);
+#else
+        result = PyObject_GetItem(obj, py_slice);
+#endif
+        if (!_py_slice) {
+            Py_DECREF(py_slice);
+        }
+        return result;
+    }
+    PyErr_Format(PyExc_TypeError,
+        "'%.200s' object is unsliceable", Py_TYPE(obj)->tp_name);
+bad:
+    return NULL;
+}
+
+static void __Pyx_RaiseArgumentTypeInvalid(const char* name, PyObject *obj, PyTypeObject *type) {
+    PyErr_Format(PyExc_TypeError,
+        "Argument '%.200s' has incorrect type (expected %.200s, got %.200s)",
+        name, type->tp_name, Py_TYPE(obj)->tp_name);
+}
+static CYTHON_INLINE int __Pyx_ArgTypeTest(PyObject *obj, PyTypeObject *type, int none_allowed,
+    const char *name, int exact)
+{
+    if (unlikely(!type)) {
+        PyErr_SetString(PyExc_SystemError, "Missing type object");
+        return 0;
+    }
+    if (none_allowed && obj == Py_None) return 1;
+    else if (exact) {
+        if (likely(Py_TYPE(obj) == type)) return 1;
+        #if PY_MAJOR_VERSION == 2
+        else if ((type == &PyBaseString_Type) && likely(__Pyx_PyBaseString_CheckExact(obj))) return 1;
+        #endif
+    }
+    else {
+        if (likely(PyObject_TypeCheck(obj, type))) return 1;
+    }
+    __Pyx_RaiseArgumentTypeInvalid(name, obj, type);
+    return 0;
+}
+
+static CYTHON_INLINE PyObject *__Pyx_GetModuleGlobalName(PyObject *name) {
+    PyObject *result;
+#if CYTHON_COMPILING_IN_CPYTHON
+    result = PyDict_GetItem(__pyx_d, name);
+    if (likely(result)) {
+        Py_INCREF(result);
+    } else {
+#else
+    result = PyObject_GetItem(__pyx_d, name);
+    if (!result) {
+        PyErr_Clear();
+#endif
+        result = __Pyx_GetBuiltinName(name);
+    }
+    return result;
+}
+
+#if CYTHON_COMPILING_IN_CPYTHON
+static CYTHON_INLINE PyObject* __Pyx_PyObject_Call(PyObject *func, PyObject *arg, PyObject *kw) {
+    PyObject *result;
+    ternaryfunc call = func->ob_type->tp_call;
+    if (unlikely(!call))
+        return PyObject_Call(func, arg, kw);
+    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
+        return NULL;
+    result = (*call)(func, arg, kw);
+    Py_LeaveRecursiveCall();
+    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
+        PyErr_SetString(
+            PyExc_SystemError,
+            "NULL result without error in PyObject_Call");
+    }
+    return result;
+}
+#endif
+
+#if CYTHON_COMPILING_IN_CPYTHON
+static CYTHON_INLINE PyObject* __Pyx_PyObject_CallMethO(PyObject *func, PyObject *arg) {
+    PyObject *self, *result;
+    PyCFunction cfunc;
+    cfunc = PyCFunction_GET_FUNCTION(func);
+    self = PyCFunction_GET_SELF(func);
+    if (unlikely(Py_EnterRecursiveCall((char*)" while calling a Python object")))
+        return NULL;
+    result = cfunc(self, arg);
+    Py_LeaveRecursiveCall();
+    if (unlikely(!result) && unlikely(!PyErr_Occurred())) {
+        PyErr_SetString(
+            PyExc_SystemError,
+            "NULL result without error in PyObject_Call");
+    }
+    return result;
+}
+#endif
+
+#if CYTHON_COMPILING_IN_CPYTHON
+static PyObject* __Pyx__PyObject_CallOneArg(PyObject *func, PyObject *arg) {
+    PyObject *result;
+    PyObject *args = PyTuple_New(1);
+    if (unlikely(!args)) return NULL;
+    Py_INCREF(arg);
+    PyTuple_SET_ITEM(args, 0, arg);
+    result = __Pyx_PyObject_Call(func, args, NULL);
+    Py_DECREF(args);
+    return result;
+}
+static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
+#ifdef __Pyx_CyFunction_USED
+    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
+#else
+    if (likely(PyCFunction_Check(func))) {
+#endif
+        if (likely(PyCFunction_GET_FLAGS(func) & METH_O)) {
+            return __Pyx_PyObject_CallMethO(func, arg);
+        }
+    }
+    return __Pyx__PyObject_CallOneArg(func, arg);
+}
+#else
+static CYTHON_INLINE PyObject* __Pyx_PyObject_CallOneArg(PyObject *func, PyObject *arg) {
+    PyObject* args = PyTuple_Pack(1, arg);
+    return (likely(args)) ? __Pyx_PyObject_Call(func, args, NULL) : NULL;
+}
+#endif
+
+static CYTHON_INLINE void __Pyx_ErrRestore(PyObject *type, PyObject *value, PyObject *tb) {
+#if CYTHON_COMPILING_IN_CPYTHON
+    PyObject *tmp_type, *tmp_value, *tmp_tb;
+    PyThreadState *tstate = PyThreadState_GET();
+    tmp_type = tstate->curexc_type;
+    tmp_value = tstate->curexc_value;
+    tmp_tb = tstate->curexc_traceback;
+    tstate->curexc_type = type;
+    tstate->curexc_value = value;
+    tstate->curexc_traceback = tb;
+    Py_XDECREF(tmp_type);
+    Py_XDECREF(tmp_value);
+    Py_XDECREF(tmp_tb);
+#else
+    PyErr_Restore(type, value, tb);
+#endif
+}
+static CYTHON_INLINE void __Pyx_ErrFetch(PyObject **type, PyObject **value, PyObject **tb) {
+#if CYTHON_COMPILING_IN_CPYTHON
+    PyThreadState *tstate = PyThreadState_GET();
+    *type = tstate->curexc_type;
+    *value = tstate->curexc_value;
+    *tb = tstate->curexc_traceback;
+    tstate->curexc_type = 0;
+    tstate->curexc_value = 0;
+    tstate->curexc_traceback = 0;
+#else
+    PyErr_Fetch(type, value, tb);
+#endif
+}
+
+#if PY_MAJOR_VERSION < 3
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb,
+                        CYTHON_UNUSED PyObject *cause) {
+    Py_XINCREF(type);
+    if (!value || value == Py_None)
+        value = NULL;
+    else
+        Py_INCREF(value);
+    if (!tb || tb == Py_None)
+        tb = NULL;
+    else {
+        Py_INCREF(tb);
+        if (!PyTraceBack_Check(tb)) {
+            PyErr_SetString(PyExc_TypeError,
+                "raise: arg 3 must be a traceback or None");
+            goto raise_error;
+        }
+    }
+    if (PyType_Check(type)) {
+#if CYTHON_COMPILING_IN_PYPY
+        if (!value) {
+            Py_INCREF(Py_None);
+            value = Py_None;
+        }
+#endif
+        PyErr_NormalizeException(&type, &value, &tb);
+    } else {
+        if (value) {
+            PyErr_SetString(PyExc_TypeError,
+                "instance exception may not have a separate value");
+            goto raise_error;
+        }
+        value = type;
+        type = (PyObject*) Py_TYPE(type);
+        Py_INCREF(type);
+        if (!PyType_IsSubtype((PyTypeObject *)type, (PyTypeObject *)PyExc_BaseException)) {
+            PyErr_SetString(PyExc_TypeError,
+                "raise: exception class must be a subclass of BaseException");
+            goto raise_error;
+        }
+    }
+    __Pyx_ErrRestore(type, value, tb);
+    return;
+raise_error:
+    Py_XDECREF(value);
+    Py_XDECREF(type);
+    Py_XDECREF(tb);
+    return;
+}
+#else
+static void __Pyx_Raise(PyObject *type, PyObject *value, PyObject *tb, PyObject *cause) {
+    PyObject* owned_instance = NULL;
+    if (tb == Py_None) {
+        tb = 0;
+    } else if (tb && !PyTraceBack_Check(tb)) {
+        PyErr_SetString(PyExc_TypeError,
+            "raise: arg 3 must be a traceback or None");
+        goto bad;
+    }
+    if (value == Py_None)
+        value = 0;
+    if (PyExceptionInstance_Check(type)) {
+        if (value) {
+            PyErr_SetString(PyExc_TypeError,
+                "instance exception may not have a separate value");
+            goto bad;
+        }
+        value = type;
+        type = (PyObject*) Py_TYPE(value);
+    } else if (PyExceptionClass_Check(type)) {
+        PyObject *instance_class = NULL;
+        if (value && PyExceptionInstance_Check(value)) {
+            instance_class = (PyObject*) Py_TYPE(value);
+            if (instance_class != type) {
+                int is_subclass = PyObject_IsSubclass(instance_class, type);
+                if (!is_subclass) {
+                    instance_class = NULL;
+                } else if (unlikely(is_subclass == -1)) {
+                    goto bad;
+                } else {
+                    type = instance_class;
+                }
+            }
+        }
+        if (!instance_class) {
+            PyObject *args;
+            if (!value)
+                args = PyTuple_New(0);
+            else if (PyTuple_Check(value)) {
+                Py_INCREF(value);
+                args = value;
+            } else
+                args = PyTuple_Pack(1, value);
+            if (!args)
+                goto bad;
+            owned_instance = PyObject_Call(type, args, NULL);
+            Py_DECREF(args);
+            if (!owned_instance)
+                goto bad;
+            value = owned_instance;
+            if (!PyExceptionInstance_Check(value)) {
+                PyErr_Format(PyExc_TypeError,
+                             "calling %R should have returned an instance of "
+                             "BaseException, not %R",
+                             type, Py_TYPE(value));
+                goto bad;
+            }
+        }
+    } else {
+        PyErr_SetString(PyExc_TypeError,
+            "raise: exception class must be a subclass of BaseException");
+        goto bad;
+    }
+#if PY_VERSION_HEX >= 0x03030000
+    if (cause) {
+#else
+    if (cause && cause != Py_None) {
+#endif
+        PyObject *fixed_cause;
+        if (cause == Py_None) {
+            fixed_cause = NULL;
+        } else if (PyExceptionClass_Check(cause)) {
+            fixed_cause = PyObject_CallObject(cause, NULL);
+            if (fixed_cause == NULL)
+                goto bad;
+        } else if (PyExceptionInstance_Check(cause)) {
+            fixed_cause = cause;
+            Py_INCREF(fixed_cause);
+        } else {
+            PyErr_SetString(PyExc_TypeError,
+                            "exception causes must derive from "
+                            "BaseException");
+            goto bad;
+        }
+        PyException_SetCause(value, fixed_cause);
+    }
+    PyErr_SetObject(type, value);
+    if (tb) {
+#if CYTHON_COMPILING_IN_PYPY
+        PyObject *tmp_type, *tmp_value, *tmp_tb;
+        PyErr_Fetch(&tmp_type, &tmp_value, &tmp_tb);
+        Py_INCREF(tb);
+        PyErr_Restore(tmp_type, tmp_value, tb);
+        Py_XDECREF(tmp_tb);
+#else
+        PyThreadState *tstate = PyThreadState_GET();
+        PyObject* tmp_tb = tstate->curexc_traceback;
+        if (tb != tmp_tb) {
+            Py_INCREF(tb);
+            tstate->curexc_traceback = tb;
+            Py_XDECREF(tmp_tb);
+        }
+#endif
+    }
+bad:
+    Py_XDECREF(owned_instance);
+    return;
+}
+#endif
+
+#if CYTHON_COMPILING_IN_CPYTHON
+static CYTHON_INLINE PyObject* __Pyx_PyObject_CallNoArg(PyObject *func) {
+#ifdef __Pyx_CyFunction_USED
+    if (likely(PyCFunction_Check(func) || PyObject_TypeCheck(func, __pyx_CyFunctionType))) {
+#else
+    if (likely(PyCFunction_Check(func))) {
+#endif
+        if (likely(PyCFunction_GET_FLAGS(func) & METH_NOARGS)) {
+            return __Pyx_PyObject_CallMethO(func, NULL);
+        }
+    }
+    return __Pyx_PyObject_Call(func, __pyx_empty_tuple, NULL);
+}
+#endif
+
+static CYTHON_INLINE PyObject *__Pyx_PyIter_Next2(PyObject* iterator, PyObject* defval) {
+    PyObject* next;
+    iternextfunc iternext = Py_TYPE(iterator)->tp_iternext;
+#if CYTHON_COMPILING_IN_CPYTHON
+    if (unlikely(!iternext)) {
+#else
+    if (unlikely(!iternext) || unlikely(!PyIter_Check(iterator))) {
+#endif
+        PyErr_Format(PyExc_TypeError,
+            "%.200s object is not an iterator", Py_TYPE(iterator)->tp_name);
+        return NULL;
+    }
+    next = iternext(iterator);
+    if (likely(next))
+        return next;
+#if CYTHON_COMPILING_IN_CPYTHON
+#if PY_VERSION_HEX >= 0x02070000
+    if (unlikely(iternext == &_PyObject_NextNotImplemented))
+        return NULL;
+#endif
+#endif
+    if (defval) {
+        PyObject* exc_type = PyErr_Occurred();
+        if (exc_type) {
+            if (unlikely(exc_type != PyExc_StopIteration) &&
+                    !PyErr_GivenExceptionMatches(exc_type, PyExc_StopIteration))
+                return NULL;
+            PyErr_Clear();
+        }
+        Py_INCREF(defval);
+        return defval;
+    }
+    if (!PyErr_Occurred())
+        PyErr_SetNone(PyExc_StopIteration);
+    return NULL;
+}
+
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Generic(PyObject *o, PyObject* j) {
+    PyObject *r;
+    if (!j) return NULL;
+    r = PyObject_GetItem(o, j);
+    Py_DECREF(j);
+    return r;
+}
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_List_Fast(PyObject *o, Py_ssize_t i,
+                                                              CYTHON_NCP_UNUSED int wraparound,
+                                                              CYTHON_NCP_UNUSED int boundscheck) {
+#if CYTHON_COMPILING_IN_CPYTHON
+    if (wraparound & unlikely(i < 0)) i += PyList_GET_SIZE(o);
+    if ((!boundscheck) || likely((0 <= i) & (i < PyList_GET_SIZE(o)))) {
+        PyObject *r = PyList_GET_ITEM(o, i);
+        Py_INCREF(r);
+        return r;
+    }
+    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
+#else
+    return PySequence_GetItem(o, i);
+#endif
+}
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Tuple_Fast(PyObject *o, Py_ssize_t i,
+                                                              CYTHON_NCP_UNUSED int wraparound,
+                                                              CYTHON_NCP_UNUSED int boundscheck) {
+#if CYTHON_COMPILING_IN_CPYTHON
+    if (wraparound & unlikely(i < 0)) i += PyTuple_GET_SIZE(o);
+    if ((!boundscheck) || likely((0 <= i) & (i < PyTuple_GET_SIZE(o)))) {
+        PyObject *r = PyTuple_GET_ITEM(o, i);
+        Py_INCREF(r);
+        return r;
+    }
+    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
+#else
+    return PySequence_GetItem(o, i);
+#endif
+}
+static CYTHON_INLINE PyObject *__Pyx_GetItemInt_Fast(PyObject *o, Py_ssize_t i, int is_list,
+                                                     CYTHON_NCP_UNUSED int wraparound,
+                                                     CYTHON_NCP_UNUSED int boundscheck) {
+#if CYTHON_COMPILING_IN_CPYTHON
+    if (is_list || PyList_CheckExact(o)) {
+        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyList_GET_SIZE(o);
+        if ((!boundscheck) || (likely((n >= 0) & (n < PyList_GET_SIZE(o))))) {
+            PyObject *r = PyList_GET_ITEM(o, n);
+            Py_INCREF(r);
+            return r;
+        }
+    }
+    else if (PyTuple_CheckExact(o)) {
+        Py_ssize_t n = ((!wraparound) | likely(i >= 0)) ? i : i + PyTuple_GET_SIZE(o);
+        if ((!boundscheck) || likely((n >= 0) & (n < PyTuple_GET_SIZE(o)))) {
+            PyObject *r = PyTuple_GET_ITEM(o, n);
+            Py_INCREF(r);
+            return r;
+        }
+    } else {
+        PySequenceMethods *m = Py_TYPE(o)->tp_as_sequence;
+        if (likely(m && m->sq_item)) {
+            if (wraparound && unlikely(i < 0) && likely(m->sq_length)) {
+                Py_ssize_t l = m->sq_length(o);
+                if (likely(l >= 0)) {
+                    i += l;
+                } else {
+                    if (PyErr_ExceptionMatches(PyExc_OverflowError))
+                        PyErr_Clear();
+                    else
+                        return NULL;
+                }
+            }
+            return m->sq_item(o, i);
+        }
+    }
+#else
+    if (is_list || PySequence_Check(o)) {
+        return PySequence_GetItem(o, i);
+    }
+#endif
+    return __Pyx_GetItemInt_Generic(o, PyInt_FromSsize_t(i));
+}
+
+static CYTHON_INLINE int __Pyx_PyBytes_Equals(PyObject* s1, PyObject* s2, int equals) {
+#if CYTHON_COMPILING_IN_PYPY
+    return PyObject_RichCompareBool(s1, s2, equals);
+#else
+    if (s1 == s2) {
+        return (equals == Py_EQ);
+    } else if (PyBytes_CheckExact(s1) & PyBytes_CheckExact(s2)) {
+        const char *ps1, *ps2;
+        Py_ssize_t length = PyBytes_GET_SIZE(s1);
+        if (length != PyBytes_GET_SIZE(s2))
+            return (equals == Py_NE);
+        ps1 = PyBytes_AS_STRING(s1);
+        ps2 = PyBytes_AS_STRING(s2);
+        if (ps1[0] != ps2[0]) {
+            return (equals == Py_NE);
+        } else if (length == 1) {
+            return (equals == Py_EQ);
+        } else {
+            int result = memcmp(ps1, ps2, (size_t)length);
+            return (equals == Py_EQ) ? (result == 0) : (result != 0);
+        }
+    } else if ((s1 == Py_None) & PyBytes_CheckExact(s2)) {
+        return (equals == Py_NE);
+    } else if ((s2 == Py_None) & PyBytes_CheckExact(s1)) {
+        return (equals == Py_NE);
+    } else {
+        int result;
+        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
+        if (!py_result)
+            return -1;
+        result = __Pyx_PyObject_IsTrue(py_result);
+        Py_DECREF(py_result);
+        return result;
+    }
+#endif
+}
+
+static CYTHON_INLINE int __Pyx_PyUnicode_Equals(PyObject* s1, PyObject* s2, int equals) {
+#if CYTHON_COMPILING_IN_PYPY
+    return PyObject_RichCompareBool(s1, s2, equals);
+#else
+#if PY_MAJOR_VERSION < 3
+    PyObject* owned_ref = NULL;
+#endif
+    int s1_is_unicode, s2_is_unicode;
+    if (s1 == s2) {
+        goto return_eq;
+    }
+    s1_is_unicode = PyUnicode_CheckExact(s1);
+    s2_is_unicode = PyUnicode_CheckExact(s2);
+#if PY_MAJOR_VERSION < 3
+    if ((s1_is_unicode & (!s2_is_unicode)) && PyString_CheckExact(s2)) {
+        owned_ref = PyUnicode_FromObject(s2);
+        if (unlikely(!owned_ref))
+            return -1;
+        s2 = owned_ref;
+        s2_is_unicode = 1;
+    } else if ((s2_is_unicode & (!s1_is_unicode)) && PyString_CheckExact(s1)) {
+        owned_ref = PyUnicode_FromObject(s1);
+        if (unlikely(!owned_ref))
+            return -1;
+        s1 = owned_ref;
+        s1_is_unicode = 1;
+    } else if (((!s2_is_unicode) & (!s1_is_unicode))) {
+        return __Pyx_PyBytes_Equals(s1, s2, equals);
+    }
+#endif
+    if (s1_is_unicode & s2_is_unicode) {
+        Py_ssize_t length;
+        int kind;
+        void *data1, *data2;
+        if (unlikely(__Pyx_PyUnicode_READY(s1) < 0) || unlikely(__Pyx_PyUnicode_READY(s2) < 0))
+            return -1;
+        length = __Pyx_PyUnicode_GET_LENGTH(s1);
+        if (length != __Pyx_PyUnicode_GET_LENGTH(s2)) {
+            goto return_ne;
+        }
+        kind = __Pyx_PyUnicode_KIND(s1);
+        if (kind != __Pyx_PyUnicode_KIND(s2)) {
+            goto return_ne;
+        }
+        data1 = __Pyx_PyUnicode_DATA(s1);
+        data2 = __Pyx_PyUnicode_DATA(s2);
+        if (__Pyx_PyUnicode_READ(kind, data1, 0) != __Pyx_PyUnicode_READ(kind, data2, 0)) {
+            goto return_ne;
+        } else if (length == 1) {
+            goto return_eq;
+        } else {
+            int result = memcmp(data1, data2, (size_t)(length * kind));
+            #if PY_MAJOR_VERSION < 3
+            Py_XDECREF(owned_ref);
+            #endif
+            return (equals == Py_EQ) ? (result == 0) : (result != 0);
+        }
+    } else if ((s1 == Py_None) & s2_is_unicode) {
+        goto return_ne;
+    } else if ((s2 == Py_None) & s1_is_unicode) {
+        goto return_ne;
+    } else {
+        int result;
+        PyObject* py_result = PyObject_RichCompare(s1, s2, equals);
+        if (!py_result)
+            return -1;
+        result = __Pyx_PyObject_IsTrue(py_result);
+        Py_DECREF(py_result);
+        return result;
+    }
+return_eq:
+    #if PY_MAJOR_VERSION < 3
+    Py_XDECREF(owned_ref);
+    #endif
+    return (equals == Py_EQ);
+return_ne:
+    #if PY_MAJOR_VERSION < 3
+    Py_XDECREF(owned_ref);
+    #endif
+    return (equals == Py_NE);
+#endif
+}
+
+static CYTHON_INLINE int __Pyx_PyStr_Tailmatch(PyObject* self, PyObject* arg, Py_ssize_t start,
+                                               Py_ssize_t end, int direction)
+{
+    if (PY_MAJOR_VERSION < 3)
+        return __Pyx_PyBytes_Tailmatch(self, arg, start, end, direction);
+    else
+        return __Pyx_PyUnicode_Tailmatch(self, arg, start, end, direction);
+}
+
+static CYTHON_INLINE void __Pyx_RaiseUnboundLocalError(const char *varname) {
+    PyErr_Format(PyExc_UnboundLocalError, "local variable '%s' referenced before assignment", varname);
+}
+
+static CYTHON_INLINE long __Pyx_mod_long(long a, long b) {
+    long r = a % b;
+    r += ((r != 0) & ((r ^ b) < 0)) * b;
+    return r;
+}
+
+static PyObject* __Pyx_ImportFrom(PyObject* module, PyObject* name) {
+    PyObject* value = __Pyx_PyObject_GetAttrStr(module, name);
+    if (unlikely(!value) && PyErr_ExceptionMatches(PyExc_AttributeError)) {
+        PyErr_Format(PyExc_ImportError,
+        #if PY_MAJOR_VERSION < 3
+            "cannot import name %.230s", PyString_AS_STRING(name));
+        #else
+            "cannot import name %S", name);
+        #endif
+    }
+    return value;
+}
+
+static PyObject *__Pyx_CalculateMetaclass(PyTypeObject *metaclass, PyObject *bases) {
+    Py_ssize_t i, nbases = PyTuple_GET_SIZE(bases);
+    for (i=0; i < nbases; i++) {
+        PyTypeObject *tmptype;
+        PyObject *tmp = PyTuple_GET_ITEM(bases, i);
+        tmptype = Py_TYPE(tmp);
+#if PY_MAJOR_VERSION < 3
+        if (tmptype == &PyClass_Type)
+            continue;
+#endif
+        if (!metaclass) {
+            metaclass = tmptype;
+            continue;
+        }
+        if (PyType_IsSubtype(metaclass, tmptype))
+            continue;
+        if (PyType_IsSubtype(tmptype, metaclass)) {
+            metaclass = tmptype;
+            continue;
+        }
+        PyErr_SetString(PyExc_TypeError,
+                        "metaclass conflict: "
+                        "the metaclass of a derived class "
+                        "must be a (non-strict) subclass "
+                        "of the metaclasses of all its bases");
+        return NULL;
+    }
+    if (!metaclass) {
+#if PY_MAJOR_VERSION < 3
+        metaclass = &PyClass_Type;
+#else
+        metaclass = &PyType_Type;
+#endif
+    }
+    Py_INCREF((PyObject*) metaclass);
+    return (PyObject*) metaclass;
+}
+
+static PyObject *__Pyx_Py3MetaclassPrepare(PyObject *metaclass, PyObject *bases, PyObject *name,
+                                           PyObject *qualname, PyObject *mkw, PyObject *modname, PyObject *doc) {
+    PyObject *ns;
+    if (metaclass) {
+        PyObject *prep = __Pyx_PyObject_GetAttrStr(metaclass, __pyx_n_s_prepare);
+        if (prep) {
+            PyObject *pargs = PyTuple_Pack(2, name, bases);
+            if (unlikely(!pargs)) {
+                Py_DECREF(prep);
+                return NULL;
+            }
+            ns = PyObject_Call(prep, pargs, mkw);
+            Py_DECREF(prep);
+            Py_DECREF(pargs);
+        } else {
+            if (unlikely(!PyErr_ExceptionMatches(PyExc_AttributeError)))
+                return NULL;
+            PyErr_Clear();
+            ns = PyDict_New();
+        }
+    } else {
+        ns = PyDict_New();
+    }
+    if (unlikely(!ns))
+        return NULL;
+    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_module, modname) < 0)) goto bad;
+    if (unlikely(PyObject_SetItem(ns, __pyx_n_s_qualname, qualname) < 0)) goto bad;
+    if (unlikely(doc && PyObject_SetItem(ns, __pyx_n_s_doc, doc) < 0)) goto bad;
+    return ns;
+bad:
+    Py_DECREF(ns);
+    return NULL;
+}
+static PyObject *__Pyx_Py3ClassCreate(PyObject *metaclass, PyObject *name, PyObject *bases,
+                                      PyObject *dict, PyObject *mkw,
+                                      int calculate_metaclass, int allow_py2_metaclass) {
+    PyObject *result, *margs;
+    PyObject *owned_metaclass = NULL;
+    if (allow_py2_metaclass) {
+        owned_metaclass = PyObject_GetItem(dict, __pyx_n_s_metaclass);
+        if (owned_metaclass) {
+            metaclass = owned_metaclass;
+        } else if (likely(PyErr_ExceptionMatches(PyExc_KeyError))) {
+            PyErr_Clear();
+        } else {
+            return NULL;
+        }
+    }
+    if (calculate_metaclass && (!metaclass || PyType_Check(metaclass))) {
+        metaclass = __Pyx_CalculateMetaclass((PyTypeObject*) metaclass, bases);
+        Py_XDECREF(owned_metaclass);
+        if (unlikely(!metaclass))
+            return NULL;
+        owned_metaclass = metaclass;
+    }
+    margs = PyTuple_Pack(3, name, bases, dict);
+    if (unlikely(!margs)) {
+        result = NULL;
+    } else {
+        result = PyObject_Call(metaclass, margs, mkw);
+        Py_DECREF(margs);
+    }
+    Py_XDECREF(owned_metaclass);
+    return result;
+}
+
+static PyTypeObject* __Pyx_FetchCommonType(PyTypeObject* type) {
+    PyObject* fake_module;
+    PyTypeObject* cached_type = NULL;
+    fake_module = PyImport_AddModule((char*) "_cython_" CYTHON_ABI);
+    if (!fake_module) return NULL;
+    Py_INCREF(fake_module);
+    cached_type = (PyTypeObject*) PyObject_GetAttrString(fake_module, type->tp_name);
+    if (cached_type) {
+        if (!PyType_Check((PyObject*)cached_type)) {
+            PyErr_Format(PyExc_TypeError,
+                "Shared Cython type %.200s is not a type object",
+                type->tp_name);
+            goto bad;
+        }
+        if (cached_type->tp_basicsize != type->tp_basicsize) {
+            PyErr_Format(PyExc_TypeError,
+                "Shared Cython type %.200s has the wrong size, try recompiling",
+                type->tp_name);
+            goto bad;
+        }
+    } else {
+        if (!PyErr_ExceptionMatches(PyExc_AttributeError)) goto bad;
+        PyErr_Clear();
+        if (PyType_Ready(type) < 0) goto bad;
+        if (PyObject_SetAttrString(fake_module, type->tp_name, (PyObject*) type) < 0)
+            goto bad;
+        Py_INCREF(type);
+        cached_type = type;
+    }
+done:
+    Py_DECREF(fake_module);
+    return cached_type;
+bad:
+    Py_XDECREF(cached_type);
+    cached_type = NULL;
+    goto done;
+}
+
+static PyObject *
+__Pyx_CyFunction_get_doc(__pyx_CyFunctionObject *op, CYTHON_UNUSED void *closure)
+{
+    if (unlikely(op->func_doc == NULL)) {
+        if (op->func.m_ml->ml_doc) {
+#if PY_MAJOR_VERSION >= 3
+            op->func_doc = PyUnicode_FromString(op->func.m_ml->ml_doc);
+#else
+            op->func_doc = PyString_FromString(op->func.m_ml->ml_doc);
+#endif
+            if (unlikely(op->func_doc == NULL))
+                return NULL;
+        } else {
+            Py_INCREF(Py_None);
+            return Py_None;
+        }
+    }
+    Py_INCREF(op->func_doc);
+    return op->func_doc;
+}
+static int
+__Pyx_CyFunction_set_doc(__pyx_CyFunctionObject *op, PyObject *value)
+{
+    PyObject *tmp = op->func_doc;
+    if (value == NULL) {
+        value = Py_None;
+    }
+    Py_INCREF(value);
+    op->func_doc = value;
+    Py_XDECREF(tmp);
+    return 0;
+}
+static PyObject *
+__Pyx_CyFunction_get_name(__pyx_CyFunctionObject *op)
+{
+    if (unlikely(op->func_name == NULL)) {
+#if PY_MAJOR_VERSION >= 3
+        op->func_name = PyUnicode_InternFromString(op->func.m_ml->ml_name);
+#else
+        op->func_name = PyString_InternFromString(op->func.m_ml->ml_name);
+#endif
+        if (unlikely(op->func_name == NULL))
+            return NULL;
+    }
+    Py_INCREF(op->func_name);
+    return op->func_name;
+}
+static int
+__Pyx_CyFunction_set_name(__pyx_CyFunctionObject *op, PyObject *value)
+{
+    PyObject *tmp;
+#if PY_MAJOR_VERSION >= 3
+    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
+#else
+    if (unlikely(value == NULL || !PyString_Check(value))) {
+#endif
+        PyErr_SetString(PyExc_TypeError,
+                        "__name__ must be set to a string object");
+        return -1;
+    }
+    tmp = op->func_name;
+    Py_INCREF(value);
+    op->func_name = value;
+    Py_XDECREF(tmp);
+    return 0;
+}
+static PyObject *
+__Pyx_CyFunction_get_qualname(__pyx_CyFunctionObject *op)
+{
+    Py_INCREF(op->func_qualname);
+    return op->func_qualname;
+}
+static int
+__Pyx_CyFunction_set_qualname(__pyx_CyFunctionObject *op, PyObject *value)
+{
+    PyObject *tmp;
+#if PY_MAJOR_VERSION >= 3
+    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
+#else
+    if (unlikely(value == NULL || !PyString_Check(value))) {
+#endif
+        PyErr_SetString(PyExc_TypeError,
+                        "__qualname__ must be set to a string object");
+        return -1;
+    }
+    tmp = op->func_qualname;
+    Py_INCREF(value);
+    op->func_qualname = value;
+    Py_XDECREF(tmp);
+    return 0;
+}
+static PyObject *
+__Pyx_CyFunction_get_self(__pyx_CyFunctionObject *m, CYTHON_UNUSED void *closure)
+{
+    PyObject *self;
+    self = m->func_closure;
+    if (self == NULL)
+        self = Py_None;
+    Py_INCREF(self);
+    return self;
+}
+static PyObject *
+__Pyx_CyFunction_get_dict(__pyx_CyFunctionObject *op)
+{
+    if (unlikely(op->func_dict == NULL)) {
+        op->func_dict = PyDict_New();
+        if (unlikely(op->func_dict == NULL))
+            return NULL;
+    }
+    Py_INCREF(op->func_dict);
+    return op->func_dict;
+}
+static int
+__Pyx_CyFunction_set_dict(__pyx_CyFunctionObject *op, PyObject *value)
+{
+    PyObject *tmp;
+    if (unlikely(value == NULL)) {
+        PyErr_SetString(PyExc_TypeError,
+               "function's dictionary may not be deleted");
+        return -1;
+    }
+    if (unlikely(!PyDict_Check(value))) {
+        PyErr_SetString(PyExc_TypeError,
+               "setting function's dictionary to a non-dict");
+        return -1;
+    }
+    tmp = op->func_dict;
+    Py_INCREF(value);
+    op->func_dict = value;
+    Py_XDECREF(tmp);
+    return 0;
+}
+static PyObject *
+__Pyx_CyFunction_get_globals(__pyx_CyFunctionObject *op)
+{
+    Py_INCREF(op->func_globals);
+    return op->func_globals;
+}
+static PyObject *
+__Pyx_CyFunction_get_closure(CYTHON_UNUSED __pyx_CyFunctionObject *op)
+{
+    Py_INCREF(Py_None);
+    return Py_None;
+}
+static PyObject *
+__Pyx_CyFunction_get_code(__pyx_CyFunctionObject *op)
+{
+    PyObject* result = (op->func_code) ? op->func_code : Py_None;
+    Py_INCREF(result);
+    return result;
+}
+static int
+__Pyx_CyFunction_init_defaults(__pyx_CyFunctionObject *op) {
+    PyObject *res = op->defaults_getter((PyObject *) op);
+    if (unlikely(!res))
+        return -1;
+    op->defaults_tuple = PyTuple_GET_ITEM(res, 0);
+    Py_INCREF(op->defaults_tuple);
+    op->defaults_kwdict = PyTuple_GET_ITEM(res, 1);
+    Py_INCREF(op->defaults_kwdict);
+    Py_DECREF(res);
+    return 0;
+}
+static int
+__Pyx_CyFunction_set_defaults(__pyx_CyFunctionObject *op, PyObject* value) {
+    PyObject* tmp;
+    if (!value) {
+        value = Py_None;
+    } else if (value != Py_None && !PyTuple_Check(value)) {
+        PyErr_SetString(PyExc_TypeError,
+                        "__defaults__ must be set to a tuple object");
+        return -1;
+    }
+    Py_INCREF(value);
+    tmp = op->defaults_tuple;
+    op->defaults_tuple = value;
+    Py_XDECREF(tmp);
+    return 0;
+}
+static PyObject *
+__Pyx_CyFunction_get_defaults(__pyx_CyFunctionObject *op) {
+    PyObject* result = op->defaults_tuple;
+    if (unlikely(!result)) {
+        if (op->defaults_getter) {
+            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
+            result = op->defaults_tuple;
+        } else {
+            result = Py_None;
+        }
+    }
+    Py_INCREF(result);
+    return result;
+}
+static int
+__Pyx_CyFunction_set_kwdefaults(__pyx_CyFunctionObject *op, PyObject* value) {
+    PyObject* tmp;
+    if (!value) {
+        value = Py_None;
+    } else if (value != Py_None && !PyDict_Check(value)) {
+        PyErr_SetString(PyExc_TypeError,
+                        "__kwdefaults__ must be set to a dict object");
+        return -1;
+    }
+    Py_INCREF(value);
+    tmp = op->defaults_kwdict;
+    op->defaults_kwdict = value;
+    Py_XDECREF(tmp);
+    return 0;
+}
+static PyObject *
+__Pyx_CyFunction_get_kwdefaults(__pyx_CyFunctionObject *op) {
+    PyObject* result = op->defaults_kwdict;
+    if (unlikely(!result)) {
+        if (op->defaults_getter) {
+            if (__Pyx_CyFunction_init_defaults(op) < 0) return NULL;
+            result = op->defaults_kwdict;
+        } else {
+            result = Py_None;
+        }
+    }
+    Py_INCREF(result);
+    return result;
+}
+static int
+__Pyx_CyFunction_set_annotations(__pyx_CyFunctionObject *op, PyObject* value) {
+    PyObject* tmp;
+    if (!value || value == Py_None) {
+        value = NULL;
+    } else if (!PyDict_Check(value)) {
+        PyErr_SetString(PyExc_TypeError,
+                        "__annotations__ must be set to a dict object");
+        return -1;
+    }
+    Py_XINCREF(value);
+    tmp = op->func_annotations;
+    op->func_annotations = value;
+    Py_XDECREF(tmp);
+    return 0;
+}
+static PyObject *
+__Pyx_CyFunction_get_annotations(__pyx_CyFunctionObject *op) {
+    PyObject* result = op->func_annotations;
+    if (unlikely(!result)) {
+        result = PyDict_New();
+        if (unlikely(!result)) return NULL;
+        op->func_annotations = result;
+    }
+    Py_INCREF(result);
+    return result;
+}
+static PyGetSetDef __pyx_CyFunction_getsets[] = {
+    {(char *) "func_doc", (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
+    {(char *) "__doc__",  (getter)__Pyx_CyFunction_get_doc, (setter)__Pyx_CyFunction_set_doc, 0, 0},
+    {(char *) "func_name", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
+    {(char *) "__name__", (getter)__Pyx_CyFunction_get_name, (setter)__Pyx_CyFunction_set_name, 0, 0},
+    {(char *) "__qualname__", (getter)__Pyx_CyFunction_get_qualname, (setter)__Pyx_CyFunction_set_qualname, 0, 0},
+    {(char *) "__self__", (getter)__Pyx_CyFunction_get_self, 0, 0, 0},
+    {(char *) "func_dict", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
+    {(char *) "__dict__", (getter)__Pyx_CyFunction_get_dict, (setter)__Pyx_CyFunction_set_dict, 0, 0},
+    {(char *) "func_globals", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
+    {(char *) "__globals__", (getter)__Pyx_CyFunction_get_globals, 0, 0, 0},
+    {(char *) "func_closure", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
+    {(char *) "__closure__", (getter)__Pyx_CyFunction_get_closure, 0, 0, 0},
+    {(char *) "func_code", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
+    {(char *) "__code__", (getter)__Pyx_CyFunction_get_code, 0, 0, 0},
+    {(char *) "func_defaults", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
+    {(char *) "__defaults__", (getter)__Pyx_CyFunction_get_defaults, (setter)__Pyx_CyFunction_set_defaults, 0, 0},
+    {(char *) "__kwdefaults__", (getter)__Pyx_CyFunction_get_kwdefaults, (setter)__Pyx_CyFunction_set_kwdefaults, 0, 0},
+    {(char *) "__annotations__", (getter)__Pyx_CyFunction_get_annotations, (setter)__Pyx_CyFunction_set_annotations, 0, 0},
+    {0, 0, 0, 0, 0}
+};
+static PyMemberDef __pyx_CyFunction_members[] = {
+    {(char *) "__module__", T_OBJECT, offsetof(__pyx_CyFunctionObject, func.m_module), PY_WRITE_RESTRICTED, 0},
+    {0, 0, 0,  0, 0}
+};
+static PyObject *
+__Pyx_CyFunction_reduce(__pyx_CyFunctionObject *m, CYTHON_UNUSED PyObject *args)
+{
+#if PY_MAJOR_VERSION >= 3
+    return PyUnicode_FromString(m->func.m_ml->ml_name);
+#else
+    return PyString_FromString(m->func.m_ml->ml_name);
+#endif
+}
+static PyMethodDef __pyx_CyFunction_methods[] = {
+    {"__reduce__", (PyCFunction)__Pyx_CyFunction_reduce, METH_VARARGS, 0},
+    {0, 0, 0, 0}
+};
+#if PY_VERSION_HEX < 0x030500A0
+#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func_weakreflist)
+#else
+#define __Pyx_CyFunction_weakreflist(cyfunc) ((cyfunc)->func.m_weakreflist)
+#endif
+static PyObject *__Pyx_CyFunction_New(PyTypeObject *type, PyMethodDef *ml, int flags, PyObject* qualname,
+                                      PyObject *closure, PyObject *module, PyObject* globals, PyObject* code) {
+    __pyx_CyFunctionObject *op = PyObject_GC_New(__pyx_CyFunctionObject, type);
+    if (op == NULL)
+        return NULL;
+    op->flags = flags;
+    __Pyx_CyFunction_weakreflist(op) = NULL;
+    op->func.m_ml = ml;
+    op->func.m_self = (PyObject *) op;
+    Py_XINCREF(closure);
+    op->func_closure = closure;
+    Py_XINCREF(module);
+    op->func.m_module = module;
+    op->func_dict = NULL;
+    op->func_name = NULL;
+    Py_INCREF(qualname);
+    op->func_qualname = qualname;
+    op->func_doc = NULL;
+    op->func_classobj = NULL;
+    op->func_globals = globals;
+    Py_INCREF(op->func_globals);
+    Py_XINCREF(code);
+    op->func_code = code;
+    op->defaults_pyobjects = 0;
+    op->defaults = NULL;
+    op->defaults_tuple = NULL;
+    op->defaults_kwdict = NULL;
+    op->defaults_getter = NULL;
+    op->func_annotations = NULL;
+    PyObject_GC_Track(op);
+    return (PyObject *) op;
+}
+static int
+__Pyx_CyFunction_clear(__pyx_CyFunctionObject *m)
+{
+    Py_CLEAR(m->func_closure);
+    Py_CLEAR(m->func.m_module);
+    Py_CLEAR(m->func_dict);
+    Py_CLEAR(m->func_name);
+    Py_CLEAR(m->func_qualname);
+    Py_CLEAR(m->func_doc);
+    Py_CLEAR(m->func_globals);
+    Py_CLEAR(m->func_code);
+    Py_CLEAR(m->func_classobj);
+    Py_CLEAR(m->defaults_tuple);
+    Py_CLEAR(m->defaults_kwdict);
+    Py_CLEAR(m->func_annotations);
+    if (m->defaults) {
+        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
+        int i;
+        for (i = 0; i < m->defaults_pyobjects; i++)
+            Py_XDECREF(pydefaults[i]);
+        PyMem_Free(m->defaults);
+        m->defaults = NULL;
+    }
+    return 0;
+}
+static void __Pyx_CyFunction_dealloc(__pyx_CyFunctionObject *m)
+{
+    PyObject_GC_UnTrack(m);
+    if (__Pyx_CyFunction_weakreflist(m) != NULL)
+        PyObject_ClearWeakRefs((PyObject *) m);
+    __Pyx_CyFunction_clear(m);
+    PyObject_GC_Del(m);
+}
+static int __Pyx_CyFunction_traverse(__pyx_CyFunctionObject *m, visitproc visit, void *arg)
+{
+    Py_VISIT(m->func_closure);
+    Py_VISIT(m->func.m_module);
+    Py_VISIT(m->func_dict);
+    Py_VISIT(m->func_name);
+    Py_VISIT(m->func_qualname);
+    Py_VISIT(m->func_doc);
+    Py_VISIT(m->func_globals);
+    Py_VISIT(m->func_code);
+    Py_VISIT(m->func_classobj);
+    Py_VISIT(m->defaults_tuple);
+    Py_VISIT(m->defaults_kwdict);
+    if (m->defaults) {
+        PyObject **pydefaults = __Pyx_CyFunction_Defaults(PyObject *, m);
+        int i;
+        for (i = 0; i < m->defaults_pyobjects; i++)
+            Py_VISIT(pydefaults[i]);
+    }
+    return 0;
+}
+static PyObject *__Pyx_CyFunction_descr_get(PyObject *func, PyObject *obj, PyObject *type)
+{
+    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
+    if (m->flags & __Pyx_CYFUNCTION_STATICMETHOD) {
+        Py_INCREF(func);
+        return func;
+    }
+    if (m->flags & __Pyx_CYFUNCTION_CLASSMETHOD) {
+        if (type == NULL)
+            type = (PyObject *)(Py_TYPE(obj));
+        return __Pyx_PyMethod_New(func, type, (PyObject *)(Py_TYPE(type)));
+    }
+    if (obj == Py_None)
+        obj = NULL;
+    return __Pyx_PyMethod_New(func, obj, type);
+}
+static PyObject*
+__Pyx_CyFunction_repr(__pyx_CyFunctionObject *op)
+{
+#if PY_MAJOR_VERSION >= 3
+    return PyUnicode_FromFormat("<cyfunction %U at %p>",
+                                op->func_qualname, (void *)op);
+#else
+    return PyString_FromFormat("<cyfunction %s at %p>",
+                               PyString_AsString(op->func_qualname), (void *)op);
+#endif
+}
+#if CYTHON_COMPILING_IN_PYPY
+static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
+    PyCFunctionObject* f = (PyCFunctionObject*)func;
+    PyCFunction meth = PyCFunction_GET_FUNCTION(func);
+    PyObject *self = PyCFunction_GET_SELF(func);
+    Py_ssize_t size;
+    switch (PyCFunction_GET_FLAGS(func) & ~(METH_CLASS | METH_STATIC | METH_COEXIST)) {
+    case METH_VARARGS:
+        if (likely(kw == NULL) || PyDict_Size(kw) == 0)
+            return (*meth)(self, arg);
+        break;
+    case METH_VARARGS | METH_KEYWORDS:
+        return (*(PyCFunctionWithKeywords)meth)(self, arg, kw);
+    case METH_NOARGS:
+        if (likely(kw == NULL) || PyDict_Size(kw) == 0) {
+            size = PyTuple_GET_SIZE(arg);
+            if (size == 0)
+                return (*meth)(self, NULL);
+            PyErr_Format(PyExc_TypeError,
+                "%.200s() takes no arguments (%" CYTHON_FORMAT_SSIZE_T "d given)",
+                f->m_ml->ml_name, size);
+            return NULL;
+        }
+        break;
+    case METH_O:
+        if (likely(kw == NULL) || PyDict_Size(kw) == 0) {
+            size = PyTuple_GET_SIZE(arg);
+            if (size == 1)
+                return (*meth)(self, PyTuple_GET_ITEM(arg, 0));
+            PyErr_Format(PyExc_TypeError,
+                "%.200s() takes exactly one argument (%" CYTHON_FORMAT_SSIZE_T "d given)",
+                f->m_ml->ml_name, size);
+            return NULL;
+        }
+        break;
+    default:
+        PyErr_SetString(PyExc_SystemError, "Bad call flags in "
+                        "__Pyx_CyFunction_Call. METH_OLDARGS is no "
+                        "longer supported!");
+        return NULL;
+    }
+    PyErr_Format(PyExc_TypeError, "%.200s() takes no keyword arguments",
+                 f->m_ml->ml_name);
+    return NULL;
+}
+#else
+static PyObject * __Pyx_CyFunction_Call(PyObject *func, PyObject *arg, PyObject *kw) {
+	return PyCFunction_Call(func, arg, kw);
+}
+#endif
+static PyTypeObject __pyx_CyFunctionType_type = {
+    PyVarObject_HEAD_INIT(0, 0)
+    "cython_function_or_method",
+    sizeof(__pyx_CyFunctionObject),
+    0,
+    (destructor) __Pyx_CyFunction_dealloc,
+    0,
+    0,
+    0,
+#if PY_MAJOR_VERSION < 3
+    0,
+#else
+    0,
+#endif
+    (reprfunc) __Pyx_CyFunction_repr,
+    0,
+    0,
+    0,
+    0,
+    __Pyx_CyFunction_Call,
+    0,
+    0,
+    0,
+    0,
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC,
+    0,
+    (traverseproc) __Pyx_CyFunction_traverse,
+    (inquiry) __Pyx_CyFunction_clear,
+    0,
+#if PY_VERSION_HEX < 0x030500A0
+    offsetof(__pyx_CyFunctionObject, func_weakreflist),
+#else
+    offsetof(PyCFunctionObject, m_weakreflist),
+#endif
+    0,
+    0,
+    __pyx_CyFunction_methods,
+    __pyx_CyFunction_members,
+    __pyx_CyFunction_getsets,
+    0,
+    0,
+    __Pyx_CyFunction_descr_get,
+    0,
+    offsetof(__pyx_CyFunctionObject, func_dict),
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+#if PY_VERSION_HEX >= 0x030400a1
+    0,
+#endif
+};
+static int __Pyx_CyFunction_init(void) {
+#if !CYTHON_COMPILING_IN_PYPY
+    __pyx_CyFunctionType_type.tp_call = PyCFunction_Call;
+#endif
+    __pyx_CyFunctionType = __Pyx_FetchCommonType(&__pyx_CyFunctionType_type);
+    if (__pyx_CyFunctionType == NULL) {
+        return -1;
+    }
+    return 0;
+}
+static CYTHON_INLINE void *__Pyx_CyFunction_InitDefaults(PyObject *func, size_t size, int pyobjects) {
+    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
+    m->defaults = PyMem_Malloc(size);
+    if (!m->defaults)
+        return PyErr_NoMemory();
+    memset(m->defaults, 0, size);
+    m->defaults_pyobjects = pyobjects;
+    return m->defaults;
+}
+static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsTuple(PyObject *func, PyObject *tuple) {
+    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
+    m->defaults_tuple = tuple;
+    Py_INCREF(tuple);
+}
+static CYTHON_INLINE void __Pyx_CyFunction_SetDefaultsKwDict(PyObject *func, PyObject *dict) {
+    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
+    m->defaults_kwdict = dict;
+    Py_INCREF(dict);
+}
+static CYTHON_INLINE void __Pyx_CyFunction_SetAnnotationsDict(PyObject *func, PyObject *dict) {
+    __pyx_CyFunctionObject *m = (__pyx_CyFunctionObject *) func;
+    m->func_annotations = dict;
+    Py_INCREF(dict);
+}
+
+static int __pyx_bisect_code_objects(__Pyx_CodeObjectCacheEntry* entries, int count, int code_line) {
+    int start = 0, mid = 0, end = count - 1;
+    if (end >= 0 && code_line > entries[end].code_line) {
+        return count;
+    }
+    while (start < end) {
+        mid = (start + end) / 2;
+        if (code_line < entries[mid].code_line) {
+            end = mid;
+        } else if (code_line > entries[mid].code_line) {
+             start = mid + 1;
+        } else {
+            return mid;
+        }
+    }
+    if (code_line <= entries[mid].code_line) {
+        return mid;
+    } else {
+        return mid + 1;
+    }
+}
+static PyCodeObject *__pyx_find_code_object(int code_line) {
+    PyCodeObject* code_object;
+    int pos;
+    if (unlikely(!code_line) || unlikely(!__pyx_code_cache.entries)) {
+        return NULL;
+    }
+    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
+    if (unlikely(pos >= __pyx_code_cache.count) || unlikely(__pyx_code_cache.entries[pos].code_line != code_line)) {
+        return NULL;
+    }
+    code_object = __pyx_code_cache.entries[pos].code_object;
+    Py_INCREF(code_object);
+    return code_object;
+}
+static void __pyx_insert_code_object(int code_line, PyCodeObject* code_object) {
+    int pos, i;
+    __Pyx_CodeObjectCacheEntry* entries = __pyx_code_cache.entries;
+    if (unlikely(!code_line)) {
+        return;
+    }
+    if (unlikely(!entries)) {
+        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Malloc(64*sizeof(__Pyx_CodeObjectCacheEntry));
+        if (likely(entries)) {
+            __pyx_code_cache.entries = entries;
+            __pyx_code_cache.max_count = 64;
+            __pyx_code_cache.count = 1;
+            entries[0].code_line = code_line;
+            entries[0].code_object = code_object;
+            Py_INCREF(code_object);
+        }
+        return;
+    }
+    pos = __pyx_bisect_code_objects(__pyx_code_cache.entries, __pyx_code_cache.count, code_line);
+    if ((pos < __pyx_code_cache.count) && unlikely(__pyx_code_cache.entries[pos].code_line == code_line)) {
+        PyCodeObject* tmp = entries[pos].code_object;
+        entries[pos].code_object = code_object;
+        Py_DECREF(tmp);
+        return;
+    }
+    if (__pyx_code_cache.count == __pyx_code_cache.max_count) {
+        int new_max = __pyx_code_cache.max_count + 64;
+        entries = (__Pyx_CodeObjectCacheEntry*)PyMem_Realloc(
+            __pyx_code_cache.entries, (size_t)new_max*sizeof(__Pyx_CodeObjectCacheEntry));
+        if (unlikely(!entries)) {
+            return;
+        }
+        __pyx_code_cache.entries = entries;
+        __pyx_code_cache.max_count = new_max;
+    }
+    for (i=__pyx_code_cache.count; i>pos; i--) {
+        entries[i] = entries[i-1];
+    }
+    entries[pos].code_line = code_line;
+    entries[pos].code_object = code_object;
+    __pyx_code_cache.count++;
+    Py_INCREF(code_object);
+}
+
+#include "compile.h"
+#include "frameobject.h"
+#include "traceback.h"
+static PyCodeObject* __Pyx_CreateCodeObjectForTraceback(
+            const char *funcname, int c_line,
+            int py_line, const char *filename) {
+    PyCodeObject *py_code = 0;
+    PyObject *py_srcfile = 0;
+    PyObject *py_funcname = 0;
+    #if PY_MAJOR_VERSION < 3
+    py_srcfile = PyString_FromString(filename);
+    #else
+    py_srcfile = PyUnicode_FromString(filename);
+    #endif
+    if (!py_srcfile) goto bad;
+    if (c_line) {
+        #if PY_MAJOR_VERSION < 3
+        py_funcname = PyString_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
+        #else
+        py_funcname = PyUnicode_FromFormat( "%s (%s:%d)", funcname, __pyx_cfilenm, c_line);
+        #endif
+    }
+    else {
+        #if PY_MAJOR_VERSION < 3
+        py_funcname = PyString_FromString(funcname);
+        #else
+        py_funcname = PyUnicode_FromString(funcname);
+        #endif
+    }
+    if (!py_funcname) goto bad;
+    py_code = __Pyx_PyCode_New(
+        0,
+        0,
+        0,
+        0,
+        0,
+        __pyx_empty_bytes, /*PyObject *code,*/
+        __pyx_empty_tuple, /*PyObject *consts,*/
+        __pyx_empty_tuple, /*PyObject *names,*/
+        __pyx_empty_tuple, /*PyObject *varnames,*/
+        __pyx_empty_tuple, /*PyObject *freevars,*/
+        __pyx_empty_tuple, /*PyObject *cellvars,*/
+        py_srcfile,   /*PyObject *filename,*/
+        py_funcname,  /*PyObject *name,*/
+        py_line,
+        __pyx_empty_bytes  /*PyObject *lnotab*/
+    );
+    Py_DECREF(py_srcfile);
+    Py_DECREF(py_funcname);
+    return py_code;
+bad:
+    Py_XDECREF(py_srcfile);
+    Py_XDECREF(py_funcname);
+    return NULL;
+}
+static void __Pyx_AddTraceback(const char *funcname, int c_line,
+                               int py_line, const char *filename) {
+    PyCodeObject *py_code = 0;
+    PyFrameObject *py_frame = 0;
+    py_code = __pyx_find_code_object(c_line ? c_line : py_line);
+    if (!py_code) {
+        py_code = __Pyx_CreateCodeObjectForTraceback(
+            funcname, c_line, py_line, filename);
+        if (!py_code) goto bad;
+        __pyx_insert_code_object(c_line ? c_line : py_line, py_code);
+    }
+    py_frame = PyFrame_New(
+        PyThreadState_GET(), /*PyThreadState *tstate,*/
+        py_code,             /*PyCodeObject *code,*/
+        __pyx_d,      /*PyObject *globals,*/
+        0                    /*PyObject *locals*/
+    );
+    if (!py_frame) goto bad;
+    py_frame->f_lineno = py_line;
+    PyTraceBack_Here(py_frame);
+bad:
+    Py_XDECREF(py_code);
+    Py_XDECREF(py_frame);
+}
+
+static PyObject *__Pyx_Import(PyObject *name, PyObject *from_list, int level) {
+    PyObject *empty_list = 0;
+    PyObject *module = 0;
+    PyObject *global_dict = 0;
+    PyObject *empty_dict = 0;
+    PyObject *list;
+    #if PY_VERSION_HEX < 0x03030000
+    PyObject *py_import;
+    py_import = __Pyx_PyObject_GetAttrStr(__pyx_b, __pyx_n_s_import);
+    if (!py_import)
+        goto bad;
+    #endif
+    if (from_list)
+        list = from_list;
+    else {
+        empty_list = PyList_New(0);
+        if (!empty_list)
+            goto bad;
+        list = empty_list;
+    }
+    global_dict = PyModule_GetDict(__pyx_m);
+    if (!global_dict)
+        goto bad;
+    empty_dict = PyDict_New();
+    if (!empty_dict)
+        goto bad;
+    {
+        #if PY_MAJOR_VERSION >= 3
+        if (level == -1) {
+            if (strchr(__Pyx_MODULE_NAME, '.')) {
+                #if PY_VERSION_HEX < 0x03030000
+                PyObject *py_level = PyInt_FromLong(1);
+                if (!py_level)
+                    goto bad;
+                module = PyObject_CallFunctionObjArgs(py_import,
+                    name, global_dict, empty_dict, list, py_level, NULL);
+                Py_DECREF(py_level);
+                #else
+                module = PyImport_ImportModuleLevelObject(
+                    name, global_dict, empty_dict, list, 1);
+                #endif
+                if (!module) {
+                    if (!PyErr_ExceptionMatches(PyExc_ImportError))
+                        goto bad;
+                    PyErr_Clear();
+                }
+            }
+            level = 0;
+        }
+        #endif
+        if (!module) {
+            #if PY_VERSION_HEX < 0x03030000
+            PyObject *py_level = PyInt_FromLong(level);
+            if (!py_level)
+                goto bad;
+            module = PyObject_CallFunctionObjArgs(py_import,
+                name, global_dict, empty_dict, list, py_level, NULL);
+            Py_DECREF(py_level);
+            #else
+            module = PyImport_ImportModuleLevelObject(
+                name, global_dict, empty_dict, list, level);
+            #endif
+        }
+    }
+bad:
+    #if PY_VERSION_HEX < 0x03030000
+    Py_XDECREF(py_import);
+    #endif
+    Py_XDECREF(empty_list);
+    Py_XDECREF(empty_dict);
+    return module;
+}
+
+#define __PYX_VERIFY_RETURN_INT(target_type, func_type, func_value)       \
+    {                                                                     \
+        func_type value = func_value;                                     \
+        if (sizeof(target_type) < sizeof(func_type)) {                    \
+            if (unlikely(value != (func_type) (target_type) value)) {     \
+                func_type zero = 0;                                       \
+                if (is_unsigned && unlikely(value < zero))                \
+                    goto raise_neg_overflow;                              \
+                else                                                      \
+                    goto raise_overflow;                                  \
+            }                                                             \
+        }                                                                 \
+        return (target_type) value;                                       \
+    }
+
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+ #if CYTHON_USE_PYLONG_INTERNALS
+  #include "longintrepr.h"
+ #endif
+#endif
+
+static CYTHON_INLINE int __Pyx_PyInt_As_int(PyObject *x) {
+    const int neg_one = (int) -1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_MAJOR_VERSION < 3
+    if (likely(PyInt_Check(x))) {
+        if (sizeof(int) < sizeof(long)) {
+            __PYX_VERIFY_RETURN_INT(int, long, PyInt_AS_LONG(x))
+        } else {
+            long val = PyInt_AS_LONG(x);
+            if (is_unsigned && unlikely(val < 0)) {
+                goto raise_neg_overflow;
+            }
+            return (int) val;
+        }
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+ #if CYTHON_USE_PYLONG_INTERNALS
+            switch (Py_SIZE(x)) {
+                case  0: return 0;
+                case  1: __PYX_VERIFY_RETURN_INT(int, digit, ((PyLongObject*)x)->ob_digit[0]);
+            }
+ #endif
+#endif
+#if CYTHON_COMPILING_IN_CPYTHON
+            if (unlikely(Py_SIZE(x) < 0)) {
+                goto raise_neg_overflow;
+            }
+#else
+            {
+                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
+                if (unlikely(result < 0))
+                    return (int) -1;
+                if (unlikely(result == 1))
+                    goto raise_neg_overflow;
+            }
+#endif
+            if (sizeof(int) <= sizeof(unsigned long)) {
+                __PYX_VERIFY_RETURN_INT(int, unsigned long, PyLong_AsUnsignedLong(x))
+            } else if (sizeof(int) <= sizeof(unsigned PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT(int, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
+            }
+        } else {
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+ #if CYTHON_USE_PYLONG_INTERNALS
+            switch (Py_SIZE(x)) {
+                case  0: return 0;
+                case  1: __PYX_VERIFY_RETURN_INT(int,  digit, +(((PyLongObject*)x)->ob_digit[0]));
+                case -1: __PYX_VERIFY_RETURN_INT(int, sdigit, -(sdigit) ((PyLongObject*)x)->ob_digit[0]);
+            }
+ #endif
+#endif
+            if (sizeof(int) <= sizeof(long)) {
+                __PYX_VERIFY_RETURN_INT(int, long, PyLong_AsLong(x))
+            } else if (sizeof(int) <= sizeof(PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT(int, PY_LONG_LONG, PyLong_AsLongLong(x))
+            }
+        }
+        {
+#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
+            PyErr_SetString(PyExc_RuntimeError,
+                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
+#else
+            int val;
+            PyObject *v = __Pyx_PyNumber_Int(x);
+ #if PY_MAJOR_VERSION < 3
+            if (likely(v) && !PyLong_Check(v)) {
+                PyObject *tmp = v;
+                v = PyNumber_Long(tmp);
+                Py_DECREF(tmp);
+            }
+ #endif
+            if (likely(v)) {
+                int one = 1; int is_little = (int)*(unsigned char *)&one;
+                unsigned char *bytes = (unsigned char *)&val;
+                int ret = _PyLong_AsByteArray((PyLongObject *)v,
+                                              bytes, sizeof(val),
+                                              is_little, !is_unsigned);
+                Py_DECREF(v);
+                if (likely(!ret))
+                    return val;
+            }
+#endif
+            return (int) -1;
+        }
+    } else {
+        int val;
+        PyObject *tmp = __Pyx_PyNumber_Int(x);
+        if (!tmp) return (int) -1;
+        val = __Pyx_PyInt_As_int(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+raise_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "value too large to convert to int");
+    return (int) -1;
+raise_neg_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "can't convert negative value to int");
+    return (int) -1;
+}
+
+static CYTHON_INLINE PyObject* __Pyx_PyInt_From_long(long value) {
+    const long neg_one = (long) -1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+    if (is_unsigned) {
+        if (sizeof(long) < sizeof(long)) {
+            return PyInt_FromLong((long) value);
+        } else if (sizeof(long) <= sizeof(unsigned long)) {
+            return PyLong_FromUnsignedLong((unsigned long) value);
+        } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
+            return PyLong_FromUnsignedLongLong((unsigned PY_LONG_LONG) value);
+        }
+    } else {
+        if (sizeof(long) <= sizeof(long)) {
+            return PyInt_FromLong((long) value);
+        } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
+            return PyLong_FromLongLong((PY_LONG_LONG) value);
+        }
+    }
+    {
+        int one = 1; int little = (int)*(unsigned char *)&one;
+        unsigned char *bytes = (unsigned char *)&value;
+        return _PyLong_FromByteArray(bytes, sizeof(long),
+                                     little, !is_unsigned);
+    }
+}
+
+static CYTHON_INLINE long __Pyx_PyInt_As_long(PyObject *x) {
+    const long neg_one = (long) -1, const_zero = 0;
+    const int is_unsigned = neg_one > const_zero;
+#if PY_MAJOR_VERSION < 3
+    if (likely(PyInt_Check(x))) {
+        if (sizeof(long) < sizeof(long)) {
+            __PYX_VERIFY_RETURN_INT(long, long, PyInt_AS_LONG(x))
+        } else {
+            long val = PyInt_AS_LONG(x);
+            if (is_unsigned && unlikely(val < 0)) {
+                goto raise_neg_overflow;
+            }
+            return (long) val;
+        }
+    } else
+#endif
+    if (likely(PyLong_Check(x))) {
+        if (is_unsigned) {
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+ #if CYTHON_USE_PYLONG_INTERNALS
+            switch (Py_SIZE(x)) {
+                case  0: return 0;
+                case  1: __PYX_VERIFY_RETURN_INT(long, digit, ((PyLongObject*)x)->ob_digit[0]);
+            }
+ #endif
+#endif
+#if CYTHON_COMPILING_IN_CPYTHON
+            if (unlikely(Py_SIZE(x) < 0)) {
+                goto raise_neg_overflow;
+            }
+#else
+            {
+                int result = PyObject_RichCompareBool(x, Py_False, Py_LT);
+                if (unlikely(result < 0))
+                    return (long) -1;
+                if (unlikely(result == 1))
+                    goto raise_neg_overflow;
+            }
+#endif
+            if (sizeof(long) <= sizeof(unsigned long)) {
+                __PYX_VERIFY_RETURN_INT(long, unsigned long, PyLong_AsUnsignedLong(x))
+            } else if (sizeof(long) <= sizeof(unsigned PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT(long, unsigned PY_LONG_LONG, PyLong_AsUnsignedLongLong(x))
+            }
+        } else {
+#if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+ #if CYTHON_USE_PYLONG_INTERNALS
+            switch (Py_SIZE(x)) {
+                case  0: return 0;
+                case  1: __PYX_VERIFY_RETURN_INT(long,  digit, +(((PyLongObject*)x)->ob_digit[0]));
+                case -1: __PYX_VERIFY_RETURN_INT(long, sdigit, -(sdigit) ((PyLongObject*)x)->ob_digit[0]);
+            }
+ #endif
+#endif
+            if (sizeof(long) <= sizeof(long)) {
+                __PYX_VERIFY_RETURN_INT(long, long, PyLong_AsLong(x))
+            } else if (sizeof(long) <= sizeof(PY_LONG_LONG)) {
+                __PYX_VERIFY_RETURN_INT(long, PY_LONG_LONG, PyLong_AsLongLong(x))
+            }
+        }
+        {
+#if CYTHON_COMPILING_IN_PYPY && !defined(_PyLong_AsByteArray)
+            PyErr_SetString(PyExc_RuntimeError,
+                            "_PyLong_AsByteArray() not available in PyPy, cannot convert large numbers");
+#else
+            long val;
+            PyObject *v = __Pyx_PyNumber_Int(x);
+ #if PY_MAJOR_VERSION < 3
+            if (likely(v) && !PyLong_Check(v)) {
+                PyObject *tmp = v;
+                v = PyNumber_Long(tmp);
+                Py_DECREF(tmp);
+            }
+ #endif
+            if (likely(v)) {
+                int one = 1; int is_little = (int)*(unsigned char *)&one;
+                unsigned char *bytes = (unsigned char *)&val;
+                int ret = _PyLong_AsByteArray((PyLongObject *)v,
+                                              bytes, sizeof(val),
+                                              is_little, !is_unsigned);
+                Py_DECREF(v);
+                if (likely(!ret))
+                    return val;
+            }
+#endif
+            return (long) -1;
+        }
+    } else {
+        long val;
+        PyObject *tmp = __Pyx_PyNumber_Int(x);
+        if (!tmp) return (long) -1;
+        val = __Pyx_PyInt_As_long(tmp);
+        Py_DECREF(tmp);
+        return val;
+    }
+raise_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "value too large to convert to long");
+    return (long) -1;
+raise_neg_overflow:
+    PyErr_SetString(PyExc_OverflowError,
+        "can't convert negative value to long");
+    return (long) -1;
+}
+
+static CYTHON_INLINE void __Pyx_ExceptionSwap(PyObject **type, PyObject **value, PyObject **tb) {
+    PyObject *tmp_type, *tmp_value, *tmp_tb;
+#if CYTHON_COMPILING_IN_CPYTHON
+    PyThreadState *tstate = PyThreadState_GET();
+    tmp_type = tstate->exc_type;
+    tmp_value = tstate->exc_value;
+    tmp_tb = tstate->exc_traceback;
+    tstate->exc_type = *type;
+    tstate->exc_value = *value;
+    tstate->exc_traceback = *tb;
+#else
+    PyErr_GetExcInfo(&tmp_type, &tmp_value, &tmp_tb);
+    PyErr_SetExcInfo(*type, *value, *tb);
+#endif
+    *type = tmp_type;
+    *value = tmp_value;
+    *tb = tmp_tb;
+}
+
+static PyObject* __Pyx_PyObject_CallMethod1(PyObject* obj, PyObject* method_name, PyObject* arg) {
+    PyObject *method, *result = NULL;
+    method = __Pyx_PyObject_GetAttrStr(obj, method_name);
+    if (unlikely(!method)) goto bad;
+#if CYTHON_COMPILING_IN_CPYTHON
+    if (likely(PyMethod_Check(method))) {
+        PyObject *self = PyMethod_GET_SELF(method);
+        if (likely(self)) {
+            PyObject *args;
+            PyObject *function = PyMethod_GET_FUNCTION(method);
+            args = PyTuple_New(2);
+            if (unlikely(!args)) goto bad;
+            Py_INCREF(self);
+            PyTuple_SET_ITEM(args, 0, self);
+            Py_INCREF(arg);
+            PyTuple_SET_ITEM(args, 1, arg);
+            Py_INCREF(function);
+            Py_DECREF(method); method = NULL;
+            result = __Pyx_PyObject_Call(function, args, NULL);
+            Py_DECREF(args);
+            Py_DECREF(function);
+            return result;
+        }
+    }
+#endif
+    result = __Pyx_PyObject_CallOneArg(method, arg);
+bad:
+    Py_XDECREF(method);
+    return result;
+}
+
+static PyObject *__Pyx_Generator_Next(PyObject *self);
+static PyObject *__Pyx_Generator_Send(PyObject *self, PyObject *value);
+static PyObject *__Pyx_Generator_Close(PyObject *self);
+static PyObject *__Pyx_Generator_Throw(PyObject *gen, PyObject *args);
+static PyTypeObject *__pyx_GeneratorType = 0;
+#define __Pyx_Generator_CheckExact(obj) (Py_TYPE(obj) == __pyx_GeneratorType)
+#define __Pyx_Generator_Undelegate(gen) Py_CLEAR((gen)->yieldfrom)
+#if 1 || PY_VERSION_HEX < 0x030300B0
+static int __Pyx_PyGen_FetchStopIterationValue(PyObject **pvalue) {
+    PyObject *et, *ev, *tb;
+    PyObject *value = NULL;
+    int result;
+    __Pyx_ErrFetch(&et, &ev, &tb);
+    if (!et) {
+        Py_XDECREF(tb);
+        Py_XDECREF(ev);
+        Py_INCREF(Py_None);
+        *pvalue = Py_None;
+        return 0;
+    }
+    if (unlikely(et != PyExc_StopIteration) &&
+            unlikely(!PyErr_GivenExceptionMatches(et, PyExc_StopIteration))) {
+        __Pyx_ErrRestore(et, ev, tb);
+        return -1;
+    }
+    if (likely(et == PyExc_StopIteration)) {
+        int error = 0;
+        if (!ev || !(error = PyObject_IsInstance(ev, PyExc_StopIteration))) {
+            if (!ev) {
+                Py_INCREF(Py_None);
+                ev = Py_None;
+            }
+            Py_XDECREF(tb);
+            Py_DECREF(et);
+            *pvalue = ev;
+            return 0;
+        }
+        if (unlikely(error == -1)) {
+            return -1;
+        }
+    }
+    PyErr_NormalizeException(&et, &ev, &tb);
+    result = PyObject_IsInstance(ev, PyExc_StopIteration);
+    if (unlikely(!result)) {
+        __Pyx_ErrRestore(et, ev, tb);
+        return -1;
+    }
+    Py_XDECREF(tb);
+    Py_DECREF(et);
+    if (unlikely(result == -1)) {
+        Py_DECREF(ev);
+        return -1;
+    }
+#if PY_VERSION_HEX >= 0x030300A0
+    value = ((PyStopIterationObject *)ev)->value;
+    Py_INCREF(value);
+    Py_DECREF(ev);
+#else
+    {
+        PyObject* args = PyObject_GetAttr(ev, __pyx_n_s_args);
+        Py_DECREF(ev);
+        if (likely(args)) {
+            value = PySequence_GetItem(args, 0);
+            Py_DECREF(args);
+        }
+        if (unlikely(!value)) {
+            __Pyx_ErrRestore(NULL, NULL, NULL);
+            Py_INCREF(Py_None);
+            value = Py_None;
+        }
+    }
+#endif
+    *pvalue = value;
+    return 0;
+}
+#endif
+static CYTHON_INLINE
+void __Pyx_Generator_ExceptionClear(__pyx_GeneratorObject *self) {
+    PyObject *exc_type = self->exc_type;
+    PyObject *exc_value = self->exc_value;
+    PyObject *exc_traceback = self->exc_traceback;
+    self->exc_type = NULL;
+    self->exc_value = NULL;
+    self->exc_traceback = NULL;
+    Py_XDECREF(exc_type);
+    Py_XDECREF(exc_value);
+    Py_XDECREF(exc_traceback);
+}
+static CYTHON_INLINE
+int __Pyx_Generator_CheckRunning(__pyx_GeneratorObject *gen) {
+    if (unlikely(gen->is_running)) {
+        PyErr_SetString(PyExc_ValueError,
+                        "generator already executing");
+        return 1;
+    }
+    return 0;
+}
+static CYTHON_INLINE
+PyObject *__Pyx_Generator_SendEx(__pyx_GeneratorObject *self, PyObject *value) {
+    PyObject *retval;
+    assert(!self->is_running);
+    if (unlikely(self->resume_label == 0)) {
+        if (unlikely(value && value != Py_None)) {
+            PyErr_SetString(PyExc_TypeError,
+                            "can't send non-None value to a "
+                            "just-started generator");
+            return NULL;
+        }
+    }
+    if (unlikely(self->resume_label == -1)) {
+        PyErr_SetNone(PyExc_StopIteration);
+        return NULL;
+    }
+    if (value) {
+#if CYTHON_COMPILING_IN_PYPY
+#else
+        if (self->exc_traceback) {
+            PyThreadState *tstate = PyThreadState_GET();
+            PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
+            PyFrameObject *f = tb->tb_frame;
+            Py_XINCREF(tstate->frame);
+            assert(f->f_back == NULL);
+            f->f_back = tstate->frame;
+        }
+#endif
+        __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
+                            &self->exc_traceback);
+    } else {
+        __Pyx_Generator_ExceptionClear(self);
+    }
+    self->is_running = 1;
+    retval = self->body((PyObject *) self, value);
+    self->is_running = 0;
+    if (retval) {
+        __Pyx_ExceptionSwap(&self->exc_type, &self->exc_value,
+                            &self->exc_traceback);
+#if CYTHON_COMPILING_IN_PYPY
+#else
+        if (self->exc_traceback) {
+            PyTracebackObject *tb = (PyTracebackObject *) self->exc_traceback;
+            PyFrameObject *f = tb->tb_frame;
+            Py_CLEAR(f->f_back);
+        }
+#endif
+    } else {
+        __Pyx_Generator_ExceptionClear(self);
+    }
+    return retval;
+}
+static CYTHON_INLINE
+PyObject *__Pyx_Generator_MethodReturn(PyObject *retval) {
+    if (unlikely(!retval && !PyErr_Occurred())) {
+        PyErr_SetNone(PyExc_StopIteration);
+    }
+    return retval;
+}
+static CYTHON_INLINE
+PyObject *__Pyx_Generator_FinishDelegation(__pyx_GeneratorObject *gen) {
+    PyObject *ret;
+    PyObject *val = NULL;
+    __Pyx_Generator_Undelegate(gen);
+    __Pyx_PyGen_FetchStopIterationValue(&val);
+    ret = __Pyx_Generator_SendEx(gen, val);
+    Py_XDECREF(val);
+    return ret;
+}
+static PyObject *__Pyx_Generator_Next(PyObject *self) {
+    __pyx_GeneratorObject *gen = (__pyx_GeneratorObject*) self;
+    PyObject *yf = gen->yieldfrom;
+    if (unlikely(__Pyx_Generator_CheckRunning(gen)))
+        return NULL;
+    if (yf) {
+        PyObject *ret;
+        gen->is_running = 1;
+        ret = Py_TYPE(yf)->tp_iternext(yf);
+        gen->is_running = 0;
+        if (likely(ret)) {
+            return ret;
+        }
+        return __Pyx_Generator_FinishDelegation(gen);
+    }
+    return __Pyx_Generator_SendEx(gen, Py_None);
+}
+static PyObject *__Pyx_Generator_Send(PyObject *self, PyObject *value) {
+    PyObject *retval;
+    __pyx_GeneratorObject *gen = (__pyx_GeneratorObject*) self;
+    PyObject *yf = gen->yieldfrom;
+    if (unlikely(__Pyx_Generator_CheckRunning(gen)))
+        return NULL;
+    if (yf) {
+        PyObject *ret;
+        gen->is_running = 1;
+        if (__Pyx_Generator_CheckExact(yf)) {
+            ret = __Pyx_Generator_Send(yf, value);
+        } else {
+            if (value == Py_None)
+                ret = PyIter_Next(yf);
+            else
+                ret = __Pyx_PyObject_CallMethod1(yf, __pyx_n_s_send, value);
+        }
+        gen->is_running = 0;
+        if (likely(ret)) {
+            return ret;
+        }
+        retval = __Pyx_Generator_FinishDelegation(gen);
+    } else {
+        retval = __Pyx_Generator_SendEx(gen, value);
+    }
+    return __Pyx_Generator_MethodReturn(retval);
+}
+static int __Pyx_Generator_CloseIter(__pyx_GeneratorObject *gen, PyObject *yf) {
+    PyObject *retval = NULL;
+    int err = 0;
+    if (__Pyx_Generator_CheckExact(yf)) {
+        retval = __Pyx_Generator_Close(yf);
+        if (!retval)
+            return -1;
+    } else {
+        PyObject *meth;
+        gen->is_running = 1;
+        meth = PyObject_GetAttr(yf, __pyx_n_s_close);
+        if (unlikely(!meth)) {
+            if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
+                PyErr_WriteUnraisable(yf);
+            }
+            PyErr_Clear();
+        } else {
+            retval = PyObject_CallFunction(meth, NULL);
+            Py_DECREF(meth);
+            if (!retval)
+                err = -1;
+        }
+        gen->is_running = 0;
+    }
+    Py_XDECREF(retval);
+    return err;
+}
+static PyObject *__Pyx_Generator_Close(PyObject *self) {
+    __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
+    PyObject *retval, *raised_exception;
+    PyObject *yf = gen->yieldfrom;
+    int err = 0;
+    if (unlikely(__Pyx_Generator_CheckRunning(gen)))
+        return NULL;
+    if (yf) {
+        Py_INCREF(yf);
+        err = __Pyx_Generator_CloseIter(gen, yf);
+        __Pyx_Generator_Undelegate(gen);
+        Py_DECREF(yf);
+    }
+    if (err == 0)
+        PyErr_SetNone(PyExc_GeneratorExit);
+    retval = __Pyx_Generator_SendEx(gen, NULL);
+    if (retval) {
+        Py_DECREF(retval);
+        PyErr_SetString(PyExc_RuntimeError,
+                        "generator ignored GeneratorExit");
+        return NULL;
+    }
+    raised_exception = PyErr_Occurred();
+    if (!raised_exception
+        || raised_exception == PyExc_StopIteration
+        || raised_exception == PyExc_GeneratorExit
+        || PyErr_GivenExceptionMatches(raised_exception, PyExc_GeneratorExit)
+        || PyErr_GivenExceptionMatches(raised_exception, PyExc_StopIteration))
+    {
+        if (raised_exception) PyErr_Clear();
+        Py_INCREF(Py_None);
+        return Py_None;
+    }
+    return NULL;
+}
+static PyObject *__Pyx_Generator_Throw(PyObject *self, PyObject *args) {
+    __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
+    PyObject *typ;
+    PyObject *tb = NULL;
+    PyObject *val = NULL;
+    PyObject *yf = gen->yieldfrom;
+    if (!PyArg_UnpackTuple(args, (char *)"throw", 1, 3, &typ, &val, &tb))
+        return NULL;
+    if (unlikely(__Pyx_Generator_CheckRunning(gen)))
+        return NULL;
+    if (yf) {
+        PyObject *ret;
+        Py_INCREF(yf);
+        if (PyErr_GivenExceptionMatches(typ, PyExc_GeneratorExit)) {
+            int err = __Pyx_Generator_CloseIter(gen, yf);
+            Py_DECREF(yf);
+            __Pyx_Generator_Undelegate(gen);
+            if (err < 0)
+                return __Pyx_Generator_MethodReturn(__Pyx_Generator_SendEx(gen, NULL));
+            goto throw_here;
+        }
+        gen->is_running = 1;
+        if (__Pyx_Generator_CheckExact(yf)) {
+            ret = __Pyx_Generator_Throw(yf, args);
+        } else {
+            PyObject *meth = PyObject_GetAttr(yf, __pyx_n_s_throw);
+            if (unlikely(!meth)) {
+                Py_DECREF(yf);
+                if (!PyErr_ExceptionMatches(PyExc_AttributeError)) {
+                    gen->is_running = 0;
+                    return NULL;
+                }
+                PyErr_Clear();
+                __Pyx_Generator_Undelegate(gen);
+                gen->is_running = 0;
+                goto throw_here;
+            }
+            ret = PyObject_CallObject(meth, args);
+            Py_DECREF(meth);
+        }
+        gen->is_running = 0;
+        Py_DECREF(yf);
+        if (!ret) {
+            ret = __Pyx_Generator_FinishDelegation(gen);
+        }
+        return __Pyx_Generator_MethodReturn(ret);
+    }
+throw_here:
+    __Pyx_Raise(typ, val, tb, NULL);
+    return __Pyx_Generator_MethodReturn(__Pyx_Generator_SendEx(gen, NULL));
+}
+static int __Pyx_Generator_traverse(PyObject *self, visitproc visit, void *arg) {
+    __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
+    Py_VISIT(gen->closure);
+    Py_VISIT(gen->classobj);
+    Py_VISIT(gen->yieldfrom);
+    Py_VISIT(gen->exc_type);
+    Py_VISIT(gen->exc_value);
+    Py_VISIT(gen->exc_traceback);
+    return 0;
+}
+static int __Pyx_Generator_clear(PyObject *self) {
+    __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
+    Py_CLEAR(gen->closure);
+    Py_CLEAR(gen->classobj);
+    Py_CLEAR(gen->yieldfrom);
+    Py_CLEAR(gen->exc_type);
+    Py_CLEAR(gen->exc_value);
+    Py_CLEAR(gen->exc_traceback);
+    Py_CLEAR(gen->gi_name);
+    Py_CLEAR(gen->gi_qualname);
+    return 0;
+}
+static void __Pyx_Generator_dealloc(PyObject *self) {
+    __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
+    PyObject_GC_UnTrack(gen);
+    if (gen->gi_weakreflist != NULL)
+        PyObject_ClearWeakRefs(self);
+    if (gen->resume_label > 0) {
+        PyObject_GC_Track(self);
+#if PY_VERSION_HEX >= 0x030400a1
+        if (PyObject_CallFinalizerFromDealloc(self))
+#else
+        Py_TYPE(gen)->tp_del(self);
+        if (self->ob_refcnt > 0)
+#endif
+        {
+            return;
+        }
+        PyObject_GC_UnTrack(self);
+    }
+    __Pyx_Generator_clear(self);
+    PyObject_GC_Del(gen);
+}
+static void __Pyx_Generator_del(PyObject *self) {
+    PyObject *res;
+    PyObject *error_type, *error_value, *error_traceback;
+    __pyx_GeneratorObject *gen = (__pyx_GeneratorObject *) self;
+    if (gen->resume_label <= 0)
+        return ;
+#if PY_VERSION_HEX < 0x030400a1
+    assert(self->ob_refcnt == 0);
+    self->ob_refcnt = 1;
+#endif
+    __Pyx_ErrFetch(&error_type, &error_value, &error_traceback);
+    res = __Pyx_Generator_Close(self);
+    if (res == NULL)
+        PyErr_WriteUnraisable(self);
+    else
+        Py_DECREF(res);
+    __Pyx_ErrRestore(error_type, error_value, error_traceback);
+#if PY_VERSION_HEX < 0x030400a1
+    assert(self->ob_refcnt > 0);
+    if (--self->ob_refcnt == 0) {
+        return;
+    }
+    {
+        Py_ssize_t refcnt = self->ob_refcnt;
+        _Py_NewReference(self);
+        self->ob_refcnt = refcnt;
+    }
+#if CYTHON_COMPILING_IN_CPYTHON
+    assert(PyType_IS_GC(self->ob_type) &&
+           _Py_AS_GC(self)->gc.gc_refs != _PyGC_REFS_UNTRACKED);
+    _Py_DEC_REFTOTAL;
+#endif
+#ifdef COUNT_ALLOCS
+    --Py_TYPE(self)->tp_frees;
+    --Py_TYPE(self)->tp_allocs;
+#endif
+#endif
+}
+static PyObject *
+__Pyx_Generator_get_name(__pyx_GeneratorObject *self)
+{
+    Py_INCREF(self->gi_name);
+    return self->gi_name;
+}
+static int
+__Pyx_Generator_set_name(__pyx_GeneratorObject *self, PyObject *value)
+{
+    PyObject *tmp;
+#if PY_MAJOR_VERSION >= 3
+    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
+#else
+    if (unlikely(value == NULL || !PyString_Check(value))) {
+#endif
+        PyErr_SetString(PyExc_TypeError,
+                        "__name__ must be set to a string object");
+        return -1;
+    }
+    tmp = self->gi_name;
+    Py_INCREF(value);
+    self->gi_name = value;
+    Py_XDECREF(tmp);
+    return 0;
+}
+static PyObject *
+__Pyx_Generator_get_qualname(__pyx_GeneratorObject *self)
+{
+    Py_INCREF(self->gi_qualname);
+    return self->gi_qualname;
+}
+static int
+__Pyx_Generator_set_qualname(__pyx_GeneratorObject *self, PyObject *value)
+{
+    PyObject *tmp;
+#if PY_MAJOR_VERSION >= 3
+    if (unlikely(value == NULL || !PyUnicode_Check(value))) {
+#else
+    if (unlikely(value == NULL || !PyString_Check(value))) {
+#endif
+        PyErr_SetString(PyExc_TypeError,
+                        "__qualname__ must be set to a string object");
+        return -1;
+    }
+    tmp = self->gi_qualname;
+    Py_INCREF(value);
+    self->gi_qualname = value;
+    Py_XDECREF(tmp);
+    return 0;
+}
+static PyGetSetDef __pyx_Generator_getsets[] = {
+    {(char *) "__name__", (getter)__Pyx_Generator_get_name, (setter)__Pyx_Generator_set_name,
+     (char*) PyDoc_STR("name of the generator"), 0},
+    {(char *) "__qualname__", (getter)__Pyx_Generator_get_qualname, (setter)__Pyx_Generator_set_qualname,
+     (char*) PyDoc_STR("qualified name of the generator"), 0},
+    {0, 0, 0, 0, 0}
+};
+static PyMemberDef __pyx_Generator_memberlist[] = {
+    {(char *) "gi_running", T_BOOL, offsetof(__pyx_GeneratorObject, is_running), READONLY, NULL},
+    {0, 0, 0, 0, 0}
+};
+static PyMethodDef __pyx_Generator_methods[] = {
+    {"send", (PyCFunction) __Pyx_Generator_Send, METH_O, 0},
+    {"throw", (PyCFunction) __Pyx_Generator_Throw, METH_VARARGS, 0},
+    {"close", (PyCFunction) __Pyx_Generator_Close, METH_NOARGS, 0},
+    {0, 0, 0, 0}
+};
+static PyTypeObject __pyx_GeneratorType_type = {
+    PyVarObject_HEAD_INIT(0, 0)
+    "generator",
+    sizeof(__pyx_GeneratorObject),
+    0,
+    (destructor) __Pyx_Generator_dealloc,
+    0,
+    0,
+    0,
+#if PY_MAJOR_VERSION < 3
+    0,
+#else
+    0,
+#endif
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC | Py_TPFLAGS_HAVE_FINALIZE,
+    0,
+    (traverseproc) __Pyx_Generator_traverse,
+    0,
+    0,
+    offsetof(__pyx_GeneratorObject, gi_weakreflist),
+    0,
+    (iternextfunc) __Pyx_Generator_Next,
+    __pyx_Generator_methods,
+    __pyx_Generator_memberlist,
+    __pyx_Generator_getsets,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+    0,
+#if PY_VERSION_HEX >= 0x030400a1
+    0,
+#else
+    __Pyx_Generator_del,
+#endif
+    0,
+#if PY_VERSION_HEX >= 0x030400a1
+    __Pyx_Generator_del,
+#endif
+};
+static __pyx_GeneratorObject *__Pyx_Generator_New(__pyx_generator_body_t body,
+                                                  PyObject *closure, PyObject *name, PyObject *qualname) {
+    __pyx_GeneratorObject *gen =
+        PyObject_GC_New(__pyx_GeneratorObject, __pyx_GeneratorType);
+    if (gen == NULL)
+        return NULL;
+    gen->body = body;
+    gen->closure = closure;
+    Py_XINCREF(closure);
+    gen->is_running = 0;
+    gen->resume_label = 0;
+    gen->classobj = NULL;
+    gen->yieldfrom = NULL;
+    gen->exc_type = NULL;
+    gen->exc_value = NULL;
+    gen->exc_traceback = NULL;
+    gen->gi_weakreflist = NULL;
+    Py_XINCREF(qualname);
+    gen->gi_qualname = qualname;
+    Py_XINCREF(name);
+    gen->gi_name = name;
+    PyObject_GC_Track(gen);
+    return gen;
+}
+static int __pyx_Generator_init(void) {
+    __pyx_GeneratorType_type.tp_getattro = PyObject_GenericGetAttr;
+    __pyx_GeneratorType_type.tp_iter = PyObject_SelfIter;
+    __pyx_GeneratorType = __Pyx_FetchCommonType(&__pyx_GeneratorType_type);
+    if (__pyx_GeneratorType == NULL) {
+        return -1;
+    }
+    return 0;
+}
+
+static int __Pyx_check_binary_version(void) {
+    char ctversion[4], rtversion[4];
+    PyOS_snprintf(ctversion, 4, "%d.%d", PY_MAJOR_VERSION, PY_MINOR_VERSION);
+    PyOS_snprintf(rtversion, 4, "%s", Py_GetVersion());
+    if (ctversion[0] != rtversion[0] || ctversion[2] != rtversion[2]) {
+        char message[200];
+        PyOS_snprintf(message, sizeof(message),
+                      "compiletime version %s of module '%.100s' "
+                      "does not match runtime version %s",
+                      ctversion, __Pyx_MODULE_NAME, rtversion);
+        return PyErr_WarnEx(NULL, message, 1);
+    }
+    return 0;
+}
+
+static int __Pyx_InitStrings(__Pyx_StringTabEntry *t) {
+    while (t->p) {
+        #if PY_MAJOR_VERSION < 3
+        if (t->is_unicode) {
+            *t->p = PyUnicode_DecodeUTF8(t->s, t->n - 1, NULL);
+        } else if (t->intern) {
+            *t->p = PyString_InternFromString(t->s);
+        } else {
+            *t->p = PyString_FromStringAndSize(t->s, t->n - 1);
+        }
+        #else
+        if (t->is_unicode | t->is_str) {
+            if (t->intern) {
+                *t->p = PyUnicode_InternFromString(t->s);
+            } else if (t->encoding) {
+                *t->p = PyUnicode_Decode(t->s, t->n - 1, t->encoding, NULL);
+            } else {
+                *t->p = PyUnicode_FromStringAndSize(t->s, t->n - 1);
+            }
+        } else {
+            *t->p = PyBytes_FromStringAndSize(t->s, t->n - 1);
+        }
+        #endif
+        if (!*t->p)
+            return -1;
+        ++t;
+    }
+    return 0;
+}
+
+static CYTHON_INLINE PyObject* __Pyx_PyUnicode_FromString(const char* c_str) {
+    return __Pyx_PyUnicode_FromStringAndSize(c_str, (Py_ssize_t)strlen(c_str));
+}
+static CYTHON_INLINE char* __Pyx_PyObject_AsString(PyObject* o) {
+    Py_ssize_t ignore;
+    return __Pyx_PyObject_AsStringAndSize(o, &ignore);
+}
+static CYTHON_INLINE char* __Pyx_PyObject_AsStringAndSize(PyObject* o, Py_ssize_t *length) {
+#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII || __PYX_DEFAULT_STRING_ENCODING_IS_DEFAULT
+    if (
+#if PY_MAJOR_VERSION < 3 && __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
+            __Pyx_sys_getdefaultencoding_not_ascii &&
+#endif
+            PyUnicode_Check(o)) {
+#if PY_VERSION_HEX < 0x03030000
+        char* defenc_c;
+        PyObject* defenc = _PyUnicode_AsDefaultEncodedString(o, NULL);
+        if (!defenc) return NULL;
+        defenc_c = PyBytes_AS_STRING(defenc);
+#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
+        {
+            char* end = defenc_c + PyBytes_GET_SIZE(defenc);
+            char* c;
+            for (c = defenc_c; c < end; c++) {
+                if ((unsigned char) (*c) >= 128) {
+                    PyUnicode_AsASCIIString(o);
+                    return NULL;
+                }
+            }
+        }
+#endif
+        *length = PyBytes_GET_SIZE(defenc);
+        return defenc_c;
+#else
+        if (__Pyx_PyUnicode_READY(o) == -1) return NULL;
+#if __PYX_DEFAULT_STRING_ENCODING_IS_ASCII
+        if (PyUnicode_IS_ASCII(o)) {
+            *length = PyUnicode_GET_LENGTH(o);
+            return PyUnicode_AsUTF8(o);
+        } else {
+            PyUnicode_AsASCIIString(o);
+            return NULL;
+        }
+#else
+        return PyUnicode_AsUTF8AndSize(o, length);
+#endif
+#endif
+    } else
+#endif
+#if !CYTHON_COMPILING_IN_PYPY
+    if (PyByteArray_Check(o)) {
+        *length = PyByteArray_GET_SIZE(o);
+        return PyByteArray_AS_STRING(o);
+    } else
+#endif
+    {
+        char* result;
+        int r = PyBytes_AsStringAndSize(o, &result, length);
+        if (unlikely(r < 0)) {
+            return NULL;
+        } else {
+            return result;
+        }
+    }
+}
+static CYTHON_INLINE int __Pyx_PyObject_IsTrue(PyObject* x) {
+   int is_true = x == Py_True;
+   if (is_true | (x == Py_False) | (x == Py_None)) return is_true;
+   else return PyObject_IsTrue(x);
+}
+static CYTHON_INLINE PyObject* __Pyx_PyNumber_Int(PyObject* x) {
+  PyNumberMethods *m;
+  const char *name = NULL;
+  PyObject *res = NULL;
+#if PY_MAJOR_VERSION < 3
+  if (PyInt_Check(x) || PyLong_Check(x))
+#else
+  if (PyLong_Check(x))
+#endif
+    return Py_INCREF(x), x;
+  m = Py_TYPE(x)->tp_as_number;
+#if PY_MAJOR_VERSION < 3
+  if (m && m->nb_int) {
+    name = "int";
+    res = PyNumber_Int(x);
+  }
+  else if (m && m->nb_long) {
+    name = "long";
+    res = PyNumber_Long(x);
+  }
+#else
+  if (m && m->nb_int) {
+    name = "int";
+    res = PyNumber_Long(x);
+  }
+#endif
+  if (res) {
+#if PY_MAJOR_VERSION < 3
+    if (!PyInt_Check(res) && !PyLong_Check(res)) {
+#else
+    if (!PyLong_Check(res)) {
+#endif
+      PyErr_Format(PyExc_TypeError,
+                   "__%.4s__ returned non-%.4s (type %.200s)",
+                   name, name, Py_TYPE(res)->tp_name);
+      Py_DECREF(res);
+      return NULL;
+    }
+  }
+  else if (!PyErr_Occurred()) {
+    PyErr_SetString(PyExc_TypeError,
+                    "an integer is required");
+  }
+  return res;
+}
+static CYTHON_INLINE Py_ssize_t __Pyx_PyIndex_AsSsize_t(PyObject* b) {
+  Py_ssize_t ival;
+  PyObject *x;
+#if PY_MAJOR_VERSION < 3
+  if (likely(PyInt_CheckExact(b)))
+      return PyInt_AS_LONG(b);
+#endif
+  if (likely(PyLong_CheckExact(b))) {
+    #if CYTHON_COMPILING_IN_CPYTHON && PY_MAJOR_VERSION >= 3
+     #if CYTHON_USE_PYLONG_INTERNALS
+       switch (Py_SIZE(b)) {
+       case -1: return -(sdigit)((PyLongObject*)b)->ob_digit[0];
+       case  0: return 0;
+       case  1: return ((PyLongObject*)b)->ob_digit[0];
+       }
+     #endif
+    #endif
+    return PyLong_AsSsize_t(b);
+  }
+  x = PyNumber_Index(b);
+  if (!x) return -1;
+  ival = PyInt_AsSsize_t(x);
+  Py_DECREF(x);
+  return ival;
+}
+static CYTHON_INLINE PyObject * __Pyx_PyInt_FromSize_t(size_t ival) {
+    return PyInt_FromSize_t(ival);
+}
+
+
+#endif /* Py_PYTHON_H */
diff --git a/cutadapt/_seqio.pyx b/cutadapt/_seqio.pyx
new file mode 100644
index 0000000..80d9249
--- /dev/null
+++ b/cutadapt/_seqio.pyx
@@ -0,0 +1,184 @@
+# kate: syntax Python;
+# cython: profile=False
+from __future__ import print_function, division, absolute_import
+from .xopen import xopen
+
+# TODO
+# the following function and class cannot be imported from seqio.py
+# since we would get circular imports
+
+class FormatError(Exception):
+	"""
+	Raised when an input file (FASTA or FASTQ) is malformatted.
+	"""
+
+
+def _shorten(s, n=100):
+	"""Shorten string s to at most n characters, appending "..." if necessary."""
+	if s is None:
+		return None
+	if len(s) > n:
+		s = s[:n-3] + '...'
+	return s
+
+
+cdef class Sequence(object):
+	"""
+	A record in a FASTQ file. Also used for FASTA (then the qualities attribute
+	is None). qualities is a string and it contains the qualities encoded as
+	ascii(qual+33).
+
+	If an adapter has been matched to the sequence, the 'match' attribute is
+	set to the corresponding AdapterMatch instance.
+	"""
+	cdef:
+		public str name
+		public str sequence
+		public str qualities
+		public object match
+		public bint twoheaders
+
+	def __init__(self, str name, str sequence, str qualities=None,
+			  bint twoheaders=False, match=None):
+		"""Set qualities to None if there are no quality values"""
+		self.name = name
+		self.sequence = sequence
+		self.qualities = qualities
+		self.twoheaders = twoheaders
+		self.match = match
+		if qualities is not None and len(qualities) != len(sequence):
+			rname = _shorten(name)
+			raise FormatError("In read named {0!r}: length of quality sequence ({1}) and length of read ({2}) do not match".format(
+				rname, len(qualities), len(sequence)))
+
+	def __getitem__(self, key):
+		"""slicing"""
+		return self.__class__(
+			self.name,
+			self.sequence[key],
+			self.qualities[key] if self.qualities is not None else None,
+			self.twoheaders,
+			self.match)
+
+	def __repr__(self):
+		qstr = ''
+		if self.qualities is not None:
+			qstr = ', qualities={0!r}'.format(_shorten(self.qualities))
+		return '<Sequence(name={0!r}, sequence={1!r}{2})>'.format(_shorten(self.name), _shorten(self.sequence), qstr)
+
+	def __len__(self):
+		return len(self.sequence)
+
+	def __richcmp__(self, other, int op):
+		if 2 <= op <= 3:
+			eq = self.name == other.name and \
+				self.sequence == other.sequence and \
+				self.qualities == other.qualities
+			if op == 2:
+				return eq
+			else:
+				return not eq
+		else:
+			raise NotImplementedError()
+
+	def __reduce__(self):
+		return (Sequence, (self.name, self.sequence, self.qualities, self.twoheaders))
+
+	def write(self, outfile):
+		if self.qualities is not None:
+			s = '@' + self.name + '\n' + self.sequence + '\n+'
+			if self.twoheaders:
+				s += self.name
+			s += '\n' + self.qualities + '\n'
+		else:
+			s = '>' + self.name + '\n' + self.sequence + '\n'
+		outfile.write(s)
+
+
+class FastqReader(object):
+	"""
+	Reader for FASTQ files. Does not support multi-line FASTQ files.
+	"""
+	def __init__(self, file, sequence_class=Sequence):
+		"""
+		file is a filename or a file-like object.
+		If file is a filename, then .gz files are supported.
+
+		colorspace -- Usually (when this is False), there must be n characters in the sequence and
+		n quality values. When this is True, there must be n+1 characters in the sequence and n quality values.
+		"""
+		if isinstance(file, basestring):
+			file = xopen(file)
+			self._file_passed = False
+		else:
+			self._file_passed = True
+		self.fp = file
+		self.sequence_class = sequence_class
+		self.delivers_qualities = True
+
+	def __iter__(self):
+		"""
+		Return tuples: (name, sequence, qualities).
+		qualities is a string and it contains the unmodified, encoded qualities.
+		"""
+		cdef int i = 0
+		cdef int strip
+		cdef str line, name, qualities, sequence
+		cdef bint twoheaders
+		sequence_class = self.sequence_class
+
+		it = iter(self.fp)
+		line = next(it)
+		if not (line and line[0] == '@'):
+			raise FormatError("at line {0}, expected a line starting with '@'".format(i+1))
+		strip = -2 if line.endswith('\r\n') else -1
+		name = line[1:strip]
+
+		i = 1
+		for line in it:
+			if i == 0:
+				if not (line and line[0] == '@'):
+					raise FormatError("at line {0}, expected a line starting with '@'".format(i+1))
+				name = line[1:strip]
+			elif i == 1:
+				sequence = line[:strip]
+			elif i == 2:
+				if line == '+\n':  # check most common case first
+					twoheaders = False
+				else:
+					line = line[:strip]
+					if not (line and line[0] == '+'):
+						raise FormatError("at line {0}, expected a line starting with '+'".format(i+1))
+					if len(line) > 1:
+						twoheaders = True
+						if not line[1:] == name:
+							raise FormatError(
+								"At line {0}: Sequence descriptions in the FASTQ file don't match "
+								"({1!r} != {2!r}).\n"
+								"The second sequence description must be either empty "
+								"or equal to the first description.".format(i+1,
+									name, line[1:]))
+					else:
+						twoheaders = False
+			elif i == 3:
+				if len(line) == len(sequence) - strip:
+					qualities = line[:strip]
+				else:
+					qualities = line.rstrip('\r\n')
+				yield sequence_class(name, sequence, qualities, twoheaders=twoheaders)
+			i = (i + 1) % 4
+		if i != 0:
+			raise FormatError("FASTQ file ended prematurely")
+
+	def close(self):
+		if not self._file_passed and self.fp is not None:
+			self.fp.close()
+			self.fp = None
+
+	def __enter__(self):
+		if self.fp is None:
+			raise ValueError("I/O operation on closed FastqReader")
+		return self
+
+	def __exit__(self, *args):
+		self.close()
diff --git a/cutadapt/_seqio.so b/cutadapt/_seqio.so
new file mode 100755
index 0000000..fbbf139
Binary files /dev/null and b/cutadapt/_seqio.so differ
diff --git a/cutadapt/adapters.py b/cutadapt/adapters.py
new file mode 100644
index 0000000..5267967
--- /dev/null
+++ b/cutadapt/adapters.py
@@ -0,0 +1,399 @@
+# coding: utf-8
+"""
+Adapters
+"""
+from __future__ import print_function, division, absolute_import
+import sys
+import re
+from collections import defaultdict
+from cutadapt import align, colorspace
+from cutadapt.seqio import ColorspaceSequence, FastaReader
+
+# Constants for the find_best_alignment function.
+# The function is called with SEQ1 as the adapter, SEQ2 as the read.
+BACK = align.START_WITHIN_SEQ2 | align.STOP_WITHIN_SEQ2 | align.STOP_WITHIN_SEQ1
+FRONT = align.START_WITHIN_SEQ2 | align.STOP_WITHIN_SEQ2 | align.START_WITHIN_SEQ1
+PREFIX = align.STOP_WITHIN_SEQ2
+SUFFIX = align.START_WITHIN_SEQ2
+ANYWHERE = align.SEMIGLOBAL
+
+
+def parse_adapter_name(seq):
+	"""
+	Parse an adapter given as 'name=adapt' into 'name' and 'adapt'.
+	"""
+	fields = seq.split('=', 1)
+	if len(fields) > 1:
+		name, seq = fields
+		name = name.strip()
+	else:
+		name = None
+	seq = seq.strip()
+	return name, seq
+
+
+def parse_adapter(sequence, where):
+	"""
+	Recognize anchored adapter sequences and return a corrected tuple
+	(sequence, where).
+	"""
+	if where == FRONT and sequence.startswith('^'):
+		return (sequence[1:], PREFIX)
+	if where == BACK and sequence.endswith('$'):
+		return (sequence[:-1], SUFFIX)
+	return (sequence, where)
+
+
+def gather_adapters(back, anywhere, front):
+	"""
+	Yield (name, seq, where) tuples from which Adapter instances can be built.
+	This generator deals with the notation for anchored 5'/3' adapters and also
+	understands the ``file:`` syntax for reading adapters from an external FASTA
+	file.
+	"""
+	for adapter_list, where in ((back, BACK), (anywhere, ANYWHERE), (front, FRONT)):
+		for seq in adapter_list:
+			if seq.startswith('file:'):
+				# read adapter sequences from a file
+				path = seq[5:]
+				with FastaReader(path) as fasta:
+					for record in fasta:
+						name = record.name.split(None, 1)[0]
+						seq, w = parse_adapter(record.sequence, where)
+						yield (name, seq, w)
+			else:
+				name, seq = parse_adapter_name(seq)
+				seq, w = parse_adapter(seq, where)
+				yield (name, seq, w)
+
+
+class AdapterMatch(object):
+	"""
+	TODO creating instances of this class is relatively slow and responsible for quite some runtime.
+	"""
+	__slots__ = ['astart', 'astop', 'rstart', 'rstop', 'matches', 'errors', 'front', 'adapter', 'read', 'length']
+	def __init__(self, astart, astop, rstart, rstop, matches, errors, front, adapter, read):
+		self.astart = astart
+		self.astop = astop
+		self.rstart = rstart
+		self.rstop = rstop
+		self.matches = matches
+		self.errors = errors
+		self.front = self._guess_is_front() if front is None else front
+		self.adapter = adapter
+		self.read = read
+		# Number of aligned characters in the adapter. If there are
+		# indels, this may be different from the number of characters
+		# in the read.
+		self.length = self.astop - self.astart
+
+	def __str__(self):
+		return 'AdapterMatch(astart={0}, astop={1}, rstart={2}, rstop={3}, matches={4}, errors={5})'.format(
+			self.astart, self.astop, self.rstart, self.rstop, self.matches, self.errors)
+
+	def _guess_is_front(self):
+		"""
+		Return whether this is guessed to be a front adapter.
+
+		The match is assumed to be a front adapter when the first base of
+		the read is involved in the alignment to the adapter.
+		"""
+		return self.rstart == 0
+
+	def wildcards(self, wildcard_char='N'):
+		"""
+		Return a string that contains, for each wildcard character,
+		the character that it matches. For example, if the adapter
+		ATNGNA matches ATCGTA, then the string 'CT' is returned.
+
+		If there are indels, this is not reliable as the full alignment
+		is not available.
+		"""
+		wildcards = [ self.read.sequence[self.rstart + i:self.rstart + i + 1] for i in range(self.length)
+			if self.adapter.sequence[self.astart + i] == wildcard_char and self.rstart + i < len(self.read.sequence) ]
+		return ''.join(wildcards)
+
+	def rest(self):
+		"""
+		Return the part of the read before this match if this is a
+		'front' (5') adapter,
+		return the part after the match if this is not a 'front' adapter (3').
+		This can be an empty string.
+		"""
+		if self.front:
+			return self.read.sequence[:self.rstart]
+		else:
+			return self.read.sequence[self.rstop:]
+
+
+class Adapter(object):
+	"""
+	An adapter knows how to match itself to a read.
+	In particular, it knows where it should be within the read and how to interpret
+	wildcard characters.
+
+	where --  One of the BACK, FRONT, PREFIX, SUFFIX or ANYWHERE constants.
+		This influences where the adapter is allowed to appear within in the
+		read and also which part of the read is removed.
+
+	sequence -- The adapter sequence as string. Will be converted to uppercase.
+		Also, Us will be converted to Ts.
+
+	max_error_rate -- Maximum allowed error rate. The error rate is
+		the number of errors in the alignment divided by the length
+		of the part of the alignment that matches the adapter.
+
+	minimum_overlap -- Minimum length of the part of the alignment
+		that matches the adapter.
+
+	read_wildcards -- Whether IUPAC wildcards in the read are allowed.
+
+	adapter_wildcards -- Whether IUPAC wildcards in the adapter are
+		allowed.
+
+	name -- optional name of the adapter. If not provided, the name is set to a
+		unique number.
+	"""
+	automatic_name = 1
+
+	def __init__(self, sequence, where, max_error_rate, min_overlap=3,
+			read_wildcards=False, adapter_wildcards=True,
+			name=None, indels=True):
+		if name is None:
+			self.name = str(self.__class__.automatic_name)
+			self.__class__.automatic_name += 1
+			self.name_is_generated = True
+		else:
+			self.name = name
+			self.name_is_generated = False
+
+		self.sequence = self.parse_braces(sequence.upper().replace('U', 'T'))
+		self.where = where
+		self.max_error_rate = max_error_rate
+		self.min_overlap = min_overlap
+		self.indels = indels
+		assert where in (PREFIX, SUFFIX) or self.indels
+		self.wildcard_flags = 0
+		self.adapter_wildcards = adapter_wildcards and not set(self.sequence) <= set('ACGT')
+		if read_wildcards:
+			self.wildcard_flags |= align.ALLOW_WILDCARD_SEQ2
+		if self.adapter_wildcards:
+			self.wildcard_flags |= align.ALLOW_WILDCARD_SEQ1
+		# redirect trimmed() to appropriate function depending on adapter type
+		trimmers = {
+			FRONT: self._trimmed_front,
+			PREFIX: self._trimmed_front,
+			BACK: self._trimmed_back,
+			SUFFIX: self._trimmed_back,
+			ANYWHERE: self._trimmed_anywhere
+		}
+		self.trimmed = trimmers[where]
+		if where == ANYWHERE:
+			self._front_flag = None  # means: guess
+		else:
+			self._front_flag = where not in (BACK, SUFFIX)
+		# statistics about length of removed sequences
+		self.lengths_front = defaultdict(int)
+		self.lengths_back = defaultdict(int)
+		self.errors_front = defaultdict(lambda: defaultdict(int))
+		self.errors_back = defaultdict(lambda: defaultdict(int))
+		self.adjacent_bases = { 'A': 0, 'C': 0, 'G': 0, 'T': 0, '': 0 }
+
+		self.aligner = align.Aligner(self.sequence, self.max_error_rate,
+			flags=self.where, degenerate=self.wildcard_flags,
+			min_overlap=self.min_overlap)
+
+	def __repr__(self):
+		read_wildcards = bool(align.ALLOW_WILDCARD_SEQ2 & self.wildcard_flags)
+		return '<Adapter(name="{name}", sequence="{sequence}", where={where}, '\
+			'max_error_rate={max_error_rate}, min_overlap={min_overlap}, '\
+			'read_wildcards={read_wildcards}, '\
+			'adapter_wildcards={adapter_wildcards}, '\
+			'indels={indels})>'.format(
+				read_wildcards=read_wildcards,
+				**vars(self))
+
+	@staticmethod
+	def parse_braces(sequence):
+		"""
+		Replace all occurrences of ``x{n}`` (where x is any character) with n
+		occurrences of x. Raise ValueError if the expression cannot be parsed.
+
+		>>> parse_braces('TGA{5}CT')
+		TGAAAAACT
+		"""
+		# Simple DFA with four states, encoded in prev
+		result = ''
+		prev = None
+		for s in re.split('(\{|\})', sequence):
+			if s == '':
+				continue
+			if prev is None:
+				if s == '{':
+					raise ValueError('"{" must be used after a character')
+				if s == '}':
+					raise ValueError('"}" cannot be used here')
+				prev = s
+				result += s
+			elif prev == '{':
+				prev = int(s)
+				if not 0 <= prev <= 10000:
+					raise ValueError('Value {} invalid'.format(prev))
+			elif isinstance(prev, int):
+				if s != '}':
+					raise ValueError('"}" expected')
+				result = result[:-1] + result[-1] * prev
+				prev = None
+			else:
+				if s != '{':
+					raise ValueError('Expected "{"')
+				prev = '{'
+		# Check if we are in a non-terminating state
+		if isinstance(prev, int) or prev == '{':
+			raise ValueError("Unterminated expression")
+		return result
+
+	def match_to(self, read):
+		"""
+		Try to match this adapter to the given read and return an AdapterMatch instance.
+
+		Return None if the minimum overlap length is not met or the error rate is too high.
+		"""
+		read_seq = read.sequence.upper()
+		pos = -1
+		# try to find an exact match first unless wildcards are allowed
+		if not self.adapter_wildcards:
+			if self.where == PREFIX:
+				pos = 0 if read_seq.startswith(self.sequence) else -1
+			elif self.where == SUFFIX:
+				pos = (len(read_seq) - len(self.sequence)) if read_seq.endswith(self.sequence) else -1
+			else:
+				pos = read_seq.find(self.sequence)
+		if pos >= 0:
+			match = AdapterMatch(
+				0, len(self.sequence), pos, pos + len(self.sequence),
+				len(self.sequence), 0, self._front_flag, self, read)
+		else:
+			# try approximate matching
+			if not self.indels:
+				assert self.where in (PREFIX, SUFFIX)
+				if self.where == PREFIX:
+					alignment = align.compare_prefixes(self.sequence, read_seq, self.wildcard_flags)
+				else:
+					alignment = align.compare_suffixes(self.sequence, read_seq, self.wildcard_flags)
+				astart, astop, rstart, rstop, matches, errors = alignment
+				if astop - astart >= self.min_overlap and errors / (astop - astart) <= self.max_error_rate:
+					match = AdapterMatch(*(alignment + (self._front_flag, self, read)))
+				else:
+					match = None
+			else:
+				alignment = self.aligner.locate(read_seq)
+				if alignment is None:
+					match = None
+				else:
+					astart, astop, rstart, rstop, matches, errors = alignment
+					match = AdapterMatch(astart, astop, rstart, rstop, matches, errors, self._front_flag, self, read)
+
+		if match is None:
+			return None
+		assert match.length > 0 and match.errors / match.length <= self.max_error_rate, match
+		assert match.length >= self.min_overlap
+		return match
+
+	def _trimmed_anywhere(self, match):
+		"""Return a trimmed read"""
+		if match.front:
+			return self._trimmed_front(match)
+		else:
+			return self._trimmed_back(match)
+
+	def _trimmed_front(self, match):
+		"""Return a trimmed read"""
+		# TODO move away
+		self.lengths_front[match.rstop] += 1
+		self.errors_front[match.rstop][match.errors] += 1
+		return match.read[match.rstop:]
+
+	def _trimmed_back(self, match):
+		"""Return a trimmed read without the 3' (back) adapter"""
+		# TODO move away
+		self.lengths_back[len(match.read) - match.rstart] += 1
+		self.errors_back[len(match.read) - match.rstart][match.errors] += 1
+		adjacent_base = match.read.sequence[match.rstart-1:match.rstart]
+		if adjacent_base not in 'ACGT':
+			adjacent_base = ''
+		self.adjacent_bases[adjacent_base] += 1
+		return match.read[:match.rstart]
+
+	def __len__(self):
+		return len(self.sequence)
+
+
+class ColorspaceAdapter(Adapter):
+	def __init__(self, *args, **kwargs):
+		super(ColorspaceAdapter, self).__init__(*args, **kwargs)
+		has_nucleotide_seq = False
+		if set(self.sequence) <= set('ACGT'):
+			# adapter was given in basespace
+			self.nucleotide_sequence = self.sequence
+			has_nucleotide_seq = True
+			self.sequence = colorspace.encode(self.sequence)[1:]
+		if self.where in (PREFIX, FRONT) and not has_nucleotide_seq:
+			raise ValueError("A 5' colorspace adapter needs to be given in nucleotide space")
+		self.aligner.reference = self.sequence
+
+	def match_to(self, read):
+		"""Return AdapterMatch instance"""
+		if self.where != PREFIX:
+			return super(ColorspaceAdapter, self).match_to(read)
+		# create artificial adapter that includes a first color that encodes the
+		# transition from primer base into adapter
+		asequence = colorspace.ENCODE[read.primer + self.nucleotide_sequence[0:1]] + self.sequence
+
+		pos = 0 if read.sequence.startswith(asequence) else -1
+		if pos >= 0:
+			match = AdapterMatch(
+				0, len(asequence), pos, pos + len(asequence),
+				len(asequence), 0, self._front_flag, self, read)
+		else:
+			# try approximate matching
+			self.aligner.reference = asequence
+			alignment = self.aligner.locate(read.sequence)
+			if alignment is not None:
+				match = AdapterMatch(*(alignment + (self._front_flag, self, read)))
+			else:
+				match = None
+
+		if match is None:
+			return None
+		assert match.length > 0 and match.errors / match.length <= self.max_error_rate
+		assert match.length >= self.min_overlap
+		return match
+
+	def _trimmed_front(self, match):
+		"""Return a trimmed read"""
+		read = match.read
+		self.lengths_front[match.rstop] += 1
+		self.errors_front[match.rstop][match.errors] += 1
+		# to remove a front adapter, we need to re-encode the first color following the adapter match
+		color_after_adapter = read.sequence[match.rstop:match.rstop + 1]
+		if not color_after_adapter:
+			# the read is empty
+			return read[match.rstop:]
+		base_after_adapter = colorspace.DECODE[self.nucleotide_sequence[-1:] + color_after_adapter]
+		new_first_color = colorspace.ENCODE[read.primer + base_after_adapter]
+		new_read = read[:]
+		new_read.sequence = new_first_color + read.sequence[(match.rstop + 1):]
+		new_read.qualities = read.qualities[match.rstop:] if read.qualities else None
+		return new_read
+
+	def _trimmed_back(self, match):
+		"""Return a trimmed read"""
+		# trim one more color if long enough
+		adjusted_rstart = max(match.rstart - 1, 0)
+		self.lengths_back[len(match.read) - adjusted_rstart] += 1
+		self.errors_back[len(match.read) - adjusted_rstart][match.errors] += 1
+		return match.read[:adjusted_rstart]
+
+	def __repr__(self):
+		return '<ColorspaceAdapter(sequence={0!r}, where={1})>'.format(self.sequence, self.where)
diff --git a/cutadapt/align.py b/cutadapt/align.py
new file mode 100644
index 0000000..e8da3e8
--- /dev/null
+++ b/cutadapt/align.py
@@ -0,0 +1,39 @@
+# coding: utf-8
+"""
+Alignment module.
+"""
+from __future__ import print_function, division, absolute_import
+
+import sys
+
+from cutadapt._align import Aligner, compare_prefixes, locate
+
+# flags for global alignment
+
+# The interpretation of the first flag is:
+# An initial portion of seq1 may be skipped at no cost.
+# This is equivalent to saying that in the alignment,
+# gaps in the beginning of seq2 are free.
+#
+# The other flags have an equivalent meaning.
+START_WITHIN_SEQ1 = 1
+START_WITHIN_SEQ2 = 2
+STOP_WITHIN_SEQ1 = 4
+STOP_WITHIN_SEQ2 = 8
+ALLOW_WILDCARD_SEQ1 = 1
+ALLOW_WILDCARD_SEQ2 = 2
+
+# Use this to get regular semiglobal alignment
+# (all gaps in the beginning or end are free)
+SEMIGLOBAL = START_WITHIN_SEQ1 | START_WITHIN_SEQ2 | STOP_WITHIN_SEQ1 | STOP_WITHIN_SEQ2
+
+
+def compare_suffixes(s1, s2, degenerate=0):
+	"""
+	Find out whether one string is the suffix of the other one, allowing
+	mismatches. Used to find an anchored 3' adapter when no indels are allowed.
+	"""
+	s1 = s1[::-1]
+	s2 = s2[::-1]
+	_, length, _, _, matches, errors = compare_prefixes(s1, s2, degenerate)
+	return (len(s1) - length, len(s1), len(s2) - length, len(s2), matches, errors)
diff --git a/cutadapt/colorspace.py b/cutadapt/colorspace.py
new file mode 100644
index 0000000..4512941
--- /dev/null
+++ b/cutadapt/colorspace.py
@@ -0,0 +1,83 @@
+# coding: utf-8
+"""
+Colorspace conversion routines.
+
+Inspired by agapython/util/Dibase.py from Corona lite,
+but reimplemented to avoid licensing issues.
+
+Encoding Table
+
+  A C G T
+A 0 1 2 3
+C 1 0 3 2
+G 2 3 0 1
+T 3 2 1 0
+"""
+from __future__ import print_function, division, absolute_import
+
+__author__ = 'Marcel Martin'
+
+
+def _initialize_dicts():
+	"""
+	Create the colorspace encoding and decoding dictionaries.
+	"""
+	enc = {}
+	for i, c1 in enumerate("ACGT"):
+		enc['N' + c1] = '4'
+		enc[c1 + 'N'] = '4'
+		enc['.' + c1] = '4'
+		enc[c1 + '.'] = '4'
+		for j, c2 in enumerate("ACGT"):
+			# XOR of nucleotides gives color
+			enc[c1 + c2] = chr(ord('0') + (i ^ j))
+	enc.update({ 'NN': '4', 'N.': '4', '.N': '4', '..': '4'})
+
+	dec = {}
+	for i, c1 in enumerate("ACGT"):
+		dec['.' + str(i)] = 'N'
+		dec['N' + str(i)] = 'N'
+		dec[c1 + '4'] = 'N'
+		dec[c1 + '.'] = 'N'
+		for j, c2 in enumerate("ACGT"):
+			# XOR of nucleotides gives color
+			dec[c1 + chr(ord('0') + (i ^ j))] = c2
+	dec['N4'] = 'N'
+
+	return (enc, dec)
+
+
+def encode(s):
+	"""
+	Given a sequence of nucleotides, convert them to
+	colorspace. Only uppercase characters are allowed.
+	>>> encode("ACGGTC")
+	"A13012"
+	"""
+	if not s:
+		return s
+	r = s[0:1]
+	for i in range(len(s) - 1):
+		r += ENCODE[s[i:i+2]]
+	return r
+
+
+def decode(s):
+	"""
+	Decode a sequence of colors to nucleotide space.
+	The first character in s must be a nucleotide.
+	Only uppercase characters are allowed.
+	>>> decode("A13012")
+	"ACGGTC"
+	"""
+	if len(s) < 2:
+		return s
+	x = s[0]
+	result = x
+	for c in s[1:]:
+		x = DECODE[x + c]
+		result += x
+	return result
+
+
+(ENCODE, DECODE) = _initialize_dicts()
diff --git a/cutadapt/compat.py b/cutadapt/compat.py
new file mode 100644
index 0000000..2289948
--- /dev/null
+++ b/cutadapt/compat.py
@@ -0,0 +1,45 @@
+# coding: utf-8
+"""
+Minimal Py2/Py3 compatibility library.
+"""
+from __future__ import print_function, division, absolute_import
+import sys
+PY3 = sys.version > '3'
+
+
+if PY3:
+	maketrans = str.maketrans
+	basestring = str
+	zip = zip
+	next = next
+
+	def bytes_to_str(s):
+		return s.decode('ascii')
+
+	def str_to_bytes(s):
+		return s.encode('ascii')
+
+	def force_str(s):
+		if isinstance(s, bytes):
+			return s.decode('ascii')
+		else:
+			return s
+	from io import StringIO
+
+else:
+	def bytes_to_str(s):
+		return s
+
+	def str_to_bytes(s):
+		return s
+
+	def force_str(s):
+		return s
+
+	def next(it):
+		return it.next()
+
+	from string import maketrans
+	basestring = basestring
+	from itertools import izip as zip
+	from StringIO import StringIO
diff --git a/cutadapt/filters.py b/cutadapt/filters.py
new file mode 100644
index 0000000..8db02da
--- /dev/null
+++ b/cutadapt/filters.py
@@ -0,0 +1,190 @@
+# coding: utf-8
+"""
+Classes for writing and filtering of processed reads.
+
+To determine what happens to a read, a list of filters is created and each
+one is called in turn (via its __call__ method) until one returns True.
+The read is then assumed to have been "consumed", that is, either written
+somewhere or filtered (should be discarded). Filters and writers are currently
+not distinguished: The idea is that at least one of the filters will apply.
+"""
+from __future__ import print_function, division, absolute_import
+from cutadapt.xopen import xopen
+
+# Constants used when returning from a Filter’s __call__ method to improve
+# readability (it is unintuitive that "return True" means "discard the read").
+DISCARD = True
+KEEP = False
+
+
+class Filter(object):
+	"""Abstract base class for filters"""
+	def __init__(self, check_second=True):
+		"""
+		check_second -- whether the second read in a pair is also checked for
+		its length. If True, the read is discarded if *any* of the two reads are
+		fulfills the criteria for discarding a read.
+		"""
+		self.check_second = check_second
+		self.filtered = 0  # statistics
+
+	def discard(self, read):
+		"""
+		Return True if read should be discarded (implement this in a derived class).
+		"""
+		raise NotImplementedError()
+
+	def __call__(self, read1, read2=None):
+		if self.discard(read1) or (
+				self.check_second and read2 is not None and self.discard(read2)):
+			self.filtered += 1
+			return DISCARD
+		return KEEP
+
+
+class RedirectingFilter(Filter):
+	"""
+	Abstract base class for a filter that can send the reads it discards to a
+	separate output file.
+	"""
+	def __init__(self, outfile=None, paired_outfile=None, check_second=True):
+		super(RedirectingFilter, self).__init__(check_second)
+		self.outfile = outfile
+		self.paired_outfile = paired_outfile
+		self.written = 0  # no of written reads or read pairs
+		self.written_bp = [0, 0]
+
+	def __call__(self, read1, read2=None):
+		if super(RedirectingFilter, self).__call__(read1, read2) == DISCARD:
+			if self.outfile is not None:
+				read1.write(self.outfile)
+				self.written += 1
+				self.written_bp[0] += len(read1)
+			if read2 is not None and self.paired_outfile is not None:
+				read2.write(self.paired_outfile)
+				self.written_bp[1] += len(read2)
+			return DISCARD
+		return KEEP
+
+
+class TooShortReadFilter(RedirectingFilter):
+	def __init__(self, minimum_length, too_short_outfile, check_second=True):
+		# TODO paired_outfile is left at its default value None (read2 is silently discarded)
+		super(TooShortReadFilter, self).__init__(outfile=too_short_outfile, check_second=check_second)
+		self.minimum_length = minimum_length
+
+	def discard(self, read):
+		return len(read) < self.minimum_length
+
+
+class TooLongReadFilter(RedirectingFilter):
+	def __init__(self, maximum_length, too_long_outfile, check_second=True):
+		super(TooLongReadFilter, self).__init__(outfile=too_long_outfile, check_second=check_second)
+		self.maximum_length = maximum_length
+
+	def discard(self, read):
+		return len(read) > self.maximum_length
+
+
+class NContentFilter(Filter):
+	"""
+	Discards reads over a given threshold of N's. It handles both raw counts of Ns as well
+	as proportions. Note, for raw counts, it is a greater than comparison, so a cutoff
+	of '1' will keep reads with a single N in it.
+	"""
+	def __init__(self, count, check_second=True):
+		"""
+		Count -- if it is below 1.0, it will be considered a proportion, and above and equal to
+		1 will be considered as discarding reads with a number of N's greater than this cutoff.
+		"""
+		super(NContentFilter, self).__init__(check_second)
+		assert count >= 0
+		self.is_proportion = count < 1.0
+		self.cutoff = count
+
+	def discard(self, read):
+		n_count = read.sequence.lower().count('n')
+		if self.is_proportion:
+			if len(read) == 0:
+				return False
+			return n_count / len(read) > self.cutoff
+		else:
+			return n_count > self.cutoff
+		return False
+
+
+class DiscardUntrimmedFilter(RedirectingFilter):
+	"""
+	A Filter that discards untrimmed reads.
+	"""
+	def __init__(self, untrimmed_outfile, untrimmed_paired_outfile, check_second=True):
+		super(DiscardUntrimmedFilter, self).__init__(
+			outfile=untrimmed_outfile,
+			paired_outfile=untrimmed_paired_outfile,
+			check_second=check_second)
+
+	def discard(self, read):
+		return read.match is None
+
+
+class DiscardTrimmedFilter(RedirectingFilter):
+	"""
+	A filter that discards trimmed reads.
+	"""
+	def __init__(self, trimmed_outfile, trimmed_paired_outfile, check_second=True):
+		super(DiscardTrimmedFilter, self).__init__(
+			outfile=trimmed_outfile,
+			paired_outfile=trimmed_paired_outfile,
+			check_second=check_second)
+
+	def discard(self, read):
+		return read.match is not None
+
+
+class Demultiplexer(object):
+	"""
+	Demultiplex trimmed reads. Reads are written to different output files
+	depending on which adapter matches. Files are created when the first read
+	is written to them.
+	"""
+	def __init__(self, path_template, untrimmed_path):
+		"""
+		path_template must contain the string '{name}', which will be replaced
+		with the name of the adapter to form the final output path.
+		Reads without an adapter match are written to the file named by
+		untrimmed_path.
+		"""
+		assert '{name}' in path_template
+		self.template = path_template
+		self.untrimmed_path = untrimmed_path
+		self.untrimmed_outfile = None
+		self.files = dict()
+		self.written = 0
+		self.written_bp = [0, 0]
+
+	def __call__(self, read1, read2=None):
+		if read2 is None:
+			# single-end read
+			if read1.match is None:
+				if self.untrimmed_outfile is None and self.untrimmed_path is not None:
+					self.untrimmed_outfile = xopen(self.untrimmed_path, 'w')
+				if self.untrimmed_outfile is not None:
+					self.written += 1
+					self.written_bp[0] += len(read1)
+					read1.write(self.untrimmed_outfile)
+			else:
+				name = read1.match.adapter.name
+				if name not in self.files:
+					self.files[name] = xopen(self.template.format(name=name), 'w')
+				self.written += 1
+				self.written_bp[0] += len(read1)
+				read1.write(self.files[name])
+			return DISCARD
+		else:
+			assert False, "Not supported"  # pragma: no cover
+
+	def close(self):
+		for f in self.files.values():
+			f.close()
+		if self.untrimmed_outfile is not None:
+			self.untrimmed_outfile.close()
diff --git a/cutadapt/modifiers.py b/cutadapt/modifiers.py
new file mode 100644
index 0000000..37a9cc1
--- /dev/null
+++ b/cutadapt/modifiers.py
@@ -0,0 +1,127 @@
+# coding: utf-8
+from __future__ import print_function, division, absolute_import
+import re
+from cutadapt.qualtrim import quality_trim_index
+from cutadapt.compat import maketrans
+
+
+class UnconditionalCutter(object):
+	"""
+	A modifier that unconditionally removes the first n or the last n bases from a read.
+
+	If the length is positive, the bases are removed from the beginning of the read.
+	If the length is negative, the bases are removed from the end of the read.
+	"""
+	def __init__(self, length):
+		self.length = length
+
+	def __call__(self, read):
+		if self.length > 0:
+			return read[self.length:]
+		elif self.length < 0:
+			return read[:self.length]
+
+
+class LengthTagModifier(object):
+	"""
+	Replace "length=..." strings in read names.
+	"""
+	def __init__(self, length_tag):
+		self.regex = re.compile(r"\b" + length_tag + r"[0-9]*\b")
+		self.length_tag = length_tag
+
+	def __call__(self, read):
+		read = read[:]
+		if read.name.find(self.length_tag) >= 0:
+			read.name = self.regex.sub(self.length_tag + str(len(read.sequence)), read.name)
+		return read
+
+
+class SuffixRemover(object):
+	"""
+	Remove a given suffix from read names.
+	"""
+	def __init__(self, suffix):
+		self.suffix = suffix
+
+	def __call__(self, read):
+		read = read[:]
+		if read.name.endswith(self.suffix):
+			read.name = read.name[:-len(self.suffix)]
+		return read
+
+
+class PrefixSuffixAdder(object):
+	"""
+	Add a suffix and a prefix to read names
+	"""
+	def __init__(self, prefix, suffix):
+		self.prefix = prefix
+		self.suffix = suffix
+
+	def __call__(self, read):
+		read = read[:]
+		read.name = self.prefix + read.name + self.suffix
+		return read
+
+
+class DoubleEncoder(object):
+	"""
+	Double-encode colorspace reads, using characters ACGTN to represent colors.
+	"""
+	def __init__(self):
+		self.double_encode_trans = maketrans('0123.', 'ACGTN')
+
+	def __call__(self, read):
+		read = read[:]
+		read.sequence = read.sequence.translate(self.double_encode_trans)
+		return read
+
+
+class ZeroCapper(object):
+	"""
+	Change negative quality values of a read to zero
+	"""
+	def __init__(self, quality_base=33):
+		qb = quality_base
+		self.zero_cap_trans = maketrans(''.join(map(chr, range(qb))), chr(qb) * qb)
+
+	def __call__(self, read):
+		read = read[:]
+		read.qualities = read.qualities.translate(self.zero_cap_trans)
+		return read
+
+
+def PrimerTrimmer(read):
+	"""Trim primer base from colorspace reads"""
+	read = read[1:]
+	read.primer = ''
+	return read
+
+
+class QualityTrimmer(object):
+	def __init__(self, cutoff_front, cutoff_back, base):
+		self.cutoff_front = cutoff_front
+		self.cutoff_back = cutoff_back
+		self.base = base
+		self.trimmed_bases = 0
+
+	def __call__(self, read):
+		start, stop = quality_trim_index(read.qualities, self.cutoff_front, self.cutoff_back, self.base)
+		self.trimmed_bases += len(read) - (stop - start)
+		return read[start:stop]
+
+
+class NEndTrimmer(object):
+	"""Trims Ns from the 3' and 5' end of reads"""
+	def __init__(self):
+		self.start_trim = re.compile(r'^N+')
+		self.end_trim = re.compile(r'N+$')
+
+	def __call__(self, read):
+		sequence = read.sequence
+		start_cut = self.start_trim.match(sequence)
+		end_cut = self.end_trim.search(sequence)
+		start_cut = start_cut.end() if start_cut else 0
+		end_cut = end_cut.start() if end_cut else len(read)
+		return read[start_cut:end_cut]
diff --git a/cutadapt/qualtrim.py b/cutadapt/qualtrim.py
new file mode 100644
index 0000000..37ebb47
--- /dev/null
+++ b/cutadapt/qualtrim.py
@@ -0,0 +1,41 @@
+# coding: utf-8
+"""
+Quality trimming.
+"""
+from __future__ import print_function, division, absolute_import
+
+import sys
+
+if sys.version > '3':
+	xrange = range
+
+
+def quality_trim_index(qualities, cutoff, base=33):
+	"""
+	Find the position at which to trim a low-quality end from a nucleotide sequence.
+
+	Qualities are assumed to be ASCII-encoded as chr(qual + base).
+
+	The algorithm is the same as the one used by BWA within the function
+	'bwa_trim_read':
+	- Subtract the cutoff value from all qualities.
+	- Compute partial sums from all indices to the end of the sequence.
+	- Trim sequence at the index at which the sum is minimal.
+	"""
+	s = 0
+	max_qual = 0
+	max_i = len(qualities)
+	for i in reversed(xrange(max_i)):
+		q = ord(qualities[i]) - base
+		s += cutoff - q
+		if s < 0:
+			break
+		if s > max_qual:
+			max_qual = s
+			max_i = i
+	return max_i
+
+try:
+	from cutadapt._qualtrim import quality_trim_index
+except:
+	pass
diff --git a/cutadapt/report.py b/cutadapt/report.py
new file mode 100644
index 0000000..88cfe5e
--- /dev/null
+++ b/cutadapt/report.py
@@ -0,0 +1,291 @@
+# coding: utf-8
+"""
+Routines for printing a report.
+"""
+from __future__ import print_function, division, absolute_import
+
+import sys
+from collections import namedtuple
+from contextlib import contextmanager
+import textwrap
+from .adapters import BACK, FRONT, PREFIX, SUFFIX, ANYWHERE
+from .modifiers import QualityTrimmer
+from .filters import (TooShortReadFilter, TooLongReadFilter,
+	DiscardTrimmedFilter, DiscardUntrimmedFilter, Demultiplexer, NContentFilter)
+
+
+class Statistics:
+	def __init__(self, n, total_bp1, total_bp2):
+		"""
+		n -- total number of reads
+		total_bp1 -- number of bases in first reads
+		total_bp2 -- number of bases in second reads (set to None for single-end data)
+		"""
+		self.n = n
+		self.total_bp = total_bp1
+		self.total_bp1 = total_bp1
+		if total_bp2 is None:
+			self.paired = False
+		else:
+			self.paired = True
+			self.total_bp2 = total_bp2
+			self.total_bp += total_bp2
+
+	def collect(self, adapters_pair, time, modifiers, modifiers2, writers):
+		self.time = max(time, 0.01)
+		self.too_short = None
+		self.too_long = None
+		self.written = 0
+		self.written_bp = [0, 0]
+		self.too_many_n = None
+		for w in writers:
+			if isinstance(w, TooShortReadFilter):
+				self.too_short = w.filtered
+			elif isinstance(w, TooLongReadFilter):
+				self.too_long = w.filtered
+			elif isinstance(w, NContentFilter):
+				self.too_many_n = w.filtered
+			elif isinstance(w, (DiscardTrimmedFilter, DiscardUntrimmedFilter, Demultiplexer)):
+				self.written += w.written
+				if self.n > 0:
+					self.written_fraction = self.written / self.n
+				self.written_bp = self.written_bp[0] + w.written_bp[0], self.written_bp[1] + w.written_bp[1]
+		assert self.written is not None
+
+		self.with_adapters = [0, 0]
+		for i in (0, 1):
+			for adapter in adapters_pair[i]:
+				self.with_adapters[i] += sum(adapter.lengths_front.values())
+				self.with_adapters[i] += sum(adapter.lengths_back.values())
+		self.with_adapters_fraction = [ (v / self.n if self.n > 0 else 0) for v in self.with_adapters ]
+
+		self.quality_trimmed_bp = [qtrimmed(modifiers), qtrimmed(modifiers2)]
+
+		if self.quality_trimmed_bp[0] is not None or self.quality_trimmed_bp[1] is not None:
+			self.did_quality_trimming = True
+			if self.quality_trimmed_bp[0] is None:
+				self.quality_trimmed_bp[0] = 0
+			if self.quality_trimmed_bp[1] is None:
+				self.quality_trimmed_bp[1] = 0
+			self.quality_trimmed = sum(self.quality_trimmed_bp)
+			self.quality_trimmed_fraction = self.quality_trimmed / self.total_bp if self.total_bp > 0 else 0.0
+		else:
+			self.did_quality_trimming = False
+
+		self.total_written_bp = sum(self.written_bp)
+		self.total_written_bp_fraction = self.total_written_bp / self.total_bp if self.total_bp > 0 else 0.0
+
+		if self.n > 0:
+			if self.too_short is not None:
+				self.too_short_fraction = self.too_short / self.n
+			if self.too_long is not None:
+				self.too_long_fraction = self.too_long / self.n
+			if self.too_many_n is not None:
+				self.too_many_n_fraction = self.too_many_n / self.n
+
+
+ADAPTER_TYPES = {
+	BACK: "regular 3'",
+	FRONT: "regular 5'",
+	PREFIX: "anchored 5'",
+	SUFFIX: "anchored 3'",
+	ANYWHERE: "variable 5'/3'"
+}
+
+
+def print_error_ranges(adapter_length, error_rate):
+	print("No. of allowed errors:")
+	prev = 0
+	for errors in range(1, int(error_rate * adapter_length) + 1):
+		r = int(errors / error_rate)
+		print("{0}-{1} bp: {2};".format(prev, r - 1, errors - 1), end=' ')
+		prev = r
+	if prev == adapter_length:
+		print("{0} bp: {1}".format(adapter_length, int(error_rate * adapter_length)))
+	else:
+		print("{0}-{1} bp: {2}".format(prev, adapter_length, int(error_rate * adapter_length)))
+	print()
+
+
+def print_histogram(d, adapter_length, n, error_rate, errors):
+	"""
+	Print a histogram. Also, print the no. of reads expected to be
+	trimmed by chance (assuming a uniform distribution of nucleotides in the reads).
+	d -- a dictionary mapping lengths of trimmed sequences to their respective frequency
+	adapter_length -- adapter length
+	n -- total no. of reads.
+	"""
+	h = []
+	for length in sorted(d):
+		# when length surpasses adapter_length, the
+		# probability does not increase anymore
+		estimated = n * 0.25 ** min(length, adapter_length)
+		h.append( (length, d[length], estimated) )
+
+	print("length", "count", "expect", "max.err", "error counts", sep="\t")
+	for length, count, estimate in h:
+		max_errors = max(errors[length].keys())
+		errs = ' '.join(str(errors[length][e]) for e in range(max_errors+1))
+		print(length, count, "{0:.1F}".format(estimate), int(error_rate*min(length, adapter_length)), errs, sep="\t")
+	print()
+
+
+def print_adjacent_bases(bases, sequence):
+	"""
+	Print a summary of the bases preceding removed adapter sequences.
+	Print a warning if one of the bases is overrepresented and there are
+	at least 20 preceding bases available.
+
+	Return whether a warning was printed.
+	"""
+	total = sum(bases.values())
+	if total == 0:
+		return False
+	print('Bases preceding removed adapters:')
+	warnbase = None
+	for base in ['A', 'C', 'G', 'T', '']:
+		b = base if base != '' else 'none/other'
+		fraction = 1.0 * bases[base] / total
+		print('  {0}: {1:.1%}'.format(b, fraction))
+		if fraction > 0.8 and base != '':
+			warnbase = b
+	if total >= 20 and warnbase is not None:
+		print('WARNING:')
+		print('    The adapter is preceded by "{0}" extremely often.'.format(warnbase))
+		print('    The provided adapter sequence may be incomplete.')
+		print('    To fix the problem, add "{0}" to the beginning of the adapter sequence.'.format(warnbase))
+		print()
+		return True
+	print()
+	return False
+
+
+def qtrimmed(modifiers):
+	"""
+	Look for a QualityTrimmer in the given list of modifiers and return its
+	trimmed_bases attribute. If not found, return None.
+	"""
+	for m in modifiers:
+		if isinstance(m, QualityTrimmer):
+			return m.trimmed_bases
+	return None
+
+
+ at contextmanager
+def redirect_standard_output(file):
+	if file is None:
+		yield
+		return
+	old_stdout = sys.stdout
+	sys.stdout = file
+	yield
+	sys.stdout = old_stdout
+
+
+def print_report(stats, adapters_pair):
+	"""Print report to standard output."""
+	if stats.n == 0:
+		print("No reads processed! Either your input file is empty or you used the wrong -f/--format parameter.")
+		return
+	print("Finished in {0:.2F} s ({1:.0F} us/read; {2:.2F} M reads/minute).".format(
+		stats.time, 1E6 * stats.time / stats.n, stats.n / stats.time * 60 / 1E6))
+
+	report = "\n=== Summary ===\n\n"
+	if stats.paired:
+		report += textwrap.dedent("""\
+		Total read pairs processed:      {n:13,d}
+		  Read 1 with adapter:           {with_adapters[0]:13,d} ({with_adapters_fraction[0]:.1%})
+		  Read 2 with adapter:           {with_adapters[1]:13,d} ({with_adapters_fraction[1]:.1%})
+		""")
+	else:
+		report += textwrap.dedent("""\
+		Total reads processed:           {n:13,d}
+		Reads with adapters:             {with_adapters[0]:13,d} ({with_adapters_fraction[0]:.1%})
+		""")
+	if stats.too_short is not None:
+		report += "{pairs_or_reads} that were too short:       {too_short:13,d} ({too_short_fraction:.1%})\n"
+	if stats.too_long is not None:
+		report += "{pairs_or_reads} that were too long:        {too_long:13,d} ({too_long_fraction:.1%})\n"
+	if stats.too_many_n is not None:
+		report += "{pairs_or_reads} with too many N:           {too_many_n:13,d} ({too_many_n_fraction:.1%})\n"
+
+	report += textwrap.dedent("""\
+	{pairs_or_reads} written (passing filters): {written:13,d} ({written_fraction:.1%})
+
+	Total basepairs processed: {total_bp:13,d} bp
+	""")
+	if stats.paired:
+		report += "  Read 1: {total_bp1:13,d} bp\n"
+		report += "  Read 2: {total_bp2:13,d} bp\n"
+
+	if stats.did_quality_trimming:
+		report += "Quality-trimmed:           {quality_trimmed:13,d} bp ({quality_trimmed_fraction:.1%})\n"
+		if stats.paired:
+			report += "  Read 1: {quality_trimmed_bp[0]:13,d} bp\n"
+			report += "  Read 2: {quality_trimmed_bp[1]:13,d} bp\n"
+
+	report += "Total written (filtered):  {total_written_bp:13,d} bp ({total_written_bp_fraction:.1%})\n"
+	if stats.paired:
+		report += "  Read 1: {written_bp[0]:13,d} bp\n"
+		report += "  Read 2: {written_bp[1]:13,d} bp\n"
+	v = vars(stats)
+	v['pairs_or_reads'] = "Pairs" if stats.paired else "Reads"
+	try:
+		report = report.format(**v)
+	except ValueError:
+		# Python 2.6 does not support the comma format specifier (PEP 378)
+		report = report.replace(",d}", "d}").format(**v)
+	print(report)
+
+	warning = False
+	for which_in_pair in (0, 1):
+		for adapter in adapters_pair[which_in_pair]:
+			total_front = sum(adapter.lengths_front.values())
+			total_back = sum(adapter.lengths_back.values())
+			total = total_front + total_back
+			where = adapter.where
+			assert where == ANYWHERE or (where in (BACK, SUFFIX) and total_front == 0) or (where in (FRONT, PREFIX) and total_back == 0)
+
+			name = str(adapter.name)
+			if not adapter.name_is_generated:
+				name = "'{0}'".format(name)
+			if stats.paired:
+				extra = 'First read: ' if which_in_pair == 0 else 'Second read: '
+			else:
+				extra = ''
+
+			print("=" * 3, extra + "Adapter", name, "=" * 3)
+			print()
+			print("Sequence: {0}; Type: {1}; Length: {2}; Trimmed: {3} times.".
+				format(adapter.sequence, ADAPTER_TYPES[adapter.where],
+					len(adapter.sequence), total))
+			if total == 0:
+				print()
+				continue
+			if where == ANYWHERE:
+				print(total_front, "times, it overlapped the 5' end of a read")
+				print(total_back, "times, it overlapped the 3' end or was within the read")
+				print()
+				print_error_ranges(len(adapter), adapter.max_error_rate)
+				print("Overview of removed sequences (5')")
+				print_histogram(adapter.lengths_front, len(adapter), stats.n, adapter.max_error_rate, adapter.errors_front)
+				print()
+				print("Overview of removed sequences (3' or within)")
+				print_histogram(adapter.lengths_back, len(adapter), stats.n, adapter.max_error_rate, adapter.errors_back)
+			elif where in (FRONT, PREFIX):
+				print()
+				print_error_ranges(len(adapter), adapter.max_error_rate)
+				print("Overview of removed sequences")
+				print_histogram(adapter.lengths_front, len(adapter), stats.n, adapter.max_error_rate, adapter.errors_front)
+			else:
+				assert where in (BACK, SUFFIX)
+				print()
+				print_error_ranges(len(adapter), adapter.max_error_rate)
+				warning = warning or print_adjacent_bases(adapter.adjacent_bases, adapter.sequence)
+				print("Overview of removed sequences")
+				print_histogram(adapter.lengths_back, len(adapter), stats.n, adapter.max_error_rate, adapter.errors_back)
+
+	if warning:
+		print('WARNING:')
+		print('    One or more of your adapter sequences may be incomplete.')
+		print('    Please see the detailed output above.')
diff --git a/cutadapt/scripts/__init__.py b/cutadapt/scripts/__init__.py
new file mode 100644
index 0000000..e69de29
diff --git a/cutadapt/scripts/cutadapt.py b/cutadapt/scripts/cutadapt.py
new file mode 100755
index 0000000..f84318d
--- /dev/null
+++ b/cutadapt/scripts/cutadapt.py
@@ -0,0 +1,855 @@
+#!/usr/bin/env python
+# -*- coding: utf-8 -*-
+# kate: word-wrap off; remove-trailing-spaces all;
+#
+# Copyright (c) 2010-2015 Marcel Martin <marcel.martin at scilifelab.se>
+#
+# Permission is hereby granted, free of charge, to any person obtaining a copy
+# of this software and associated documentation files (the "Software"), to deal
+# in the Software without restriction, including without limitation the rights
+# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+# copies of the Software, and to permit persons to whom the Software is
+# furnished to do so, subject to the following conditions:
+#
+# The above copyright notice and this permission notice shall be included in
+# all copies or substantial portions of the Software.
+#
+# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+# THE SOFTWARE.
+
+"""
+cutadapt version %version
+Copyright (C) 2010-2015 Marcel Martin <marcel.martin at scilifelab.se>
+
+cutadapt removes adapter sequences from high-throughput sequencing reads.
+
+Usage:
+    cutadapt -a ADAPTER [options] [-o output.fastq] input.fastq
+
+For paired-end reads:
+    cutadapt -a ADAPT1 -A ADAPT2 [options] -o out1.fastq -p out2.fastq in1.fastq in2.fastq
+
+Replace "ADAPTER" with the actual sequence of your 3' adapter. IUPAC wildcard
+characters are supported. The reverse complement is *not* automatically
+searched. All reads from input.fastq will be written to output.fastq with the
+adapter sequence removed. Adapter matching is error-tolerant. Multiple adapter
+sequences can be given (use further -a options), but only the best-matching
+adapter will be removed.
+
+Input may also be in FASTA format. Compressed input and output is supported and
+auto-detected from the file name (.gz, .xz, .bz2). Use the file name '-' for
+standard input/output. Without the -o option, output is sent to standard output.
+
+Some other available features are:
+  * Various other adapter types (5' adapters, "mixed" 5'/3' adapters etc.)
+  * Trimming a fixed number of bases
+  * Quality trimming
+  * Trimming colorspace reads
+  * Filtering reads by various criteria
+
+Use "cutadapt --help" to see all command-line options.
+See http://cutadapt.readthedocs.org/ for full documentation.
+"""
+
+from __future__ import print_function, division, absolute_import
+
+# Print a helpful error message if the extension modules cannot be imported.
+from cutadapt import check_importability
+check_importability()
+
+import sys
+import time
+import errno
+from optparse import OptionParser, OptionGroup, SUPPRESS_HELP
+import logging
+import platform
+
+from cutadapt import seqio, __version__
+from cutadapt.xopen import xopen
+from cutadapt.adapters import (Adapter, ColorspaceAdapter, gather_adapters,
+	BACK, FRONT, PREFIX, SUFFIX, ANYWHERE)
+from cutadapt.modifiers import (LengthTagModifier, SuffixRemover, PrefixSuffixAdder,
+	DoubleEncoder, ZeroCapper, PrimerTrimmer, QualityTrimmer, UnconditionalCutter,
+	NEndTrimmer)
+from cutadapt.filters import (TooShortReadFilter, TooLongReadFilter,
+	Demultiplexer, NContentFilter, DiscardUntrimmedFilter, DiscardTrimmedFilter)
+from cutadapt.report import Statistics, print_report, redirect_standard_output
+from cutadapt.compat import next
+
+logger = logging.getLogger(__name__)
+
+class CutadaptOptionParser(OptionParser):
+	def get_usage(self):
+		return self.usage.lstrip().replace('%version', __version__)
+
+
+class RestFileWriter(object):
+	def __init__(self, file):
+		self.file = file
+
+	def write(self, match):
+		rest = match.rest()
+		if len(rest) > 0:
+			print(rest, match.read.name, file=self.file)
+
+
+class AdapterCutter(object):
+	"""
+	Repeatedly find one of multiple adapters in reads.
+	The number of times the search is repeated is specified by the
+	times parameter.
+	"""
+
+	def __init__(self, adapters, times=1, wildcard_file=None, info_file=None,
+			rest_writer=None, action='trim'):
+		"""
+		adapters -- list of Adapter objects
+
+		action -- What to do with a found adapter: None, 'trim', or 'mask'
+		"""
+		self.adapters = adapters
+		self.times = times
+		self.wildcard_file = wildcard_file
+		self.info_file = info_file
+		self.rest_writer = rest_writer
+		self.action = action
+		self.reads_matched = 0
+
+	def _best_match(self, read):
+		"""
+		Find the best matching adapter in the given read.
+
+		Return either an AdapterMatch instance or None if there are no matches.
+		"""
+		best = None
+		for adapter in self.adapters:
+			match = adapter.match_to(read)
+			if match is None:
+				continue
+
+			# the no. of matches determines which adapter fits best
+			if best is None or match.matches > best.matches:
+				best = match
+		return best
+
+	def _write_info(self, read, matches):
+		"""
+		Write to the info, wildcard and rest files.
+		# TODO
+		# This design with a read having a .match attribute and
+		# a match having a .read attribute is really confusing.
+		"""
+		match = read.match
+		if self.rest_writer and match:
+			self.rest_writer.write(match)
+
+		if self.wildcard_file and match:
+			print(match.wildcards(), read.name, file=self.wildcard_file)
+
+		if self.info_file:
+			if match:
+				for m in matches:
+					seq = m.read.sequence
+					print(
+						m.read.name,
+						m.errors,
+						m.rstart,
+						m.rstop,
+						seq[0:m.rstart],
+						seq[m.rstart:m.rstop],
+						seq[m.rstop:],
+						m.adapter.name,
+						sep='\t', file=self.info_file
+					)
+			else:
+				seq = read.sequence
+				print(read.name, -1, seq, sep='\t', file=self.info_file)
+
+	def __call__(self, read):
+		"""
+		Determine the adapter that best matches the given read.
+		Since the best adapter is searched repeatedly, a list
+		of AdapterMatch instances is returned, which
+		need to be applied consecutively to the read.
+		The list is empty if there are no adapter matches.
+
+		The read is converted to uppercase before it is compared to the adapter
+		sequences.
+
+		Cut found adapters from a single read. Return modified read.
+		"""
+		matches = []
+
+		# try at most self.times times to remove an adapter
+		trimmed_read = read
+		for t in range(self.times):
+			match = self._best_match(trimmed_read)
+			if match is None:
+				# nothing found
+				break
+			assert match.length > 0
+			assert match.errors / match.length <= match.adapter.max_error_rate
+			assert match.length - match.errors > 0
+			matches.append(match)
+			trimmed_read = match.adapter.trimmed(match)
+
+		trimmed_read.match = matches[-1] if matches else None
+		self._write_info(trimmed_read, matches)
+
+		if not matches:
+			return trimmed_read
+
+		if __debug__:
+			assert len(trimmed_read) < len(read), "Trimmed read isn't shorter than original"
+
+		if self.action == 'trim':
+			# read is already trimmed, nothing to do
+			pass
+		elif self.action == 'mask':
+			# add N from last modification
+			masked_sequence = trimmed_read.sequence
+			for match in sorted(matches, reverse=True, key=lambda m: m.astart):
+				ns = 'N' * (len(match.read.sequence) -
+							len(match.adapter.trimmed(match).sequence))
+				# add N depending on match position
+				if match.front:
+					masked_sequence = ns + masked_sequence
+				else:
+					masked_sequence += ns
+			# set masked sequence as sequence with original quality
+			trimmed_read.sequence = masked_sequence
+			trimmed_read.qualities = matches[0].read.qualities
+
+			assert len(trimmed_read.sequence) == len(read)
+		elif self.action is None:
+			trimmed_read = read
+			trimmed_read.match = matches[-1]
+
+		self.reads_matched += 1  # TODO move to filter class
+
+		return trimmed_read
+
+
+def process_single_reads(reader, modifiers, writers):
+	"""
+	Loop over reads, find adapters, trim reads, apply modifiers and
+	output modified reads.
+
+	Return a Statistics object.
+	"""
+	n = 0  # no. of processed reads
+	total_bp = 0
+	for read in reader:
+		n += 1
+		total_bp += len(read.sequence)
+		for modifier in modifiers:
+			read = modifier(read)
+		for writer in writers:
+			if writer(read):
+				break
+
+	return Statistics(n=n, total_bp1=total_bp, total_bp2=None)
+
+
+def process_paired_reads(paired_reader, modifiers, modifiers2, writers):
+	"""
+	Loop over reads, find adapters, trim reads, apply modifiers and
+	output modified reads.
+
+	Return a Statistics object.
+	"""
+	n = 0  # no. of processed reads
+	total1_bp = 0
+	total2_bp = 0
+	for read1, read2 in paired_reader:
+		n += 1
+		total1_bp += len(read1.sequence)
+		total2_bp += len(read2.sequence)
+		for modifier in modifiers:
+			read1 = modifier(read1)
+		for modifier in modifiers2:
+			read2 = modifier(read2)
+		for writer in writers:
+			# Stop writing as soon as one of the writers was successful.
+			if writer(read1, read2):
+				break
+	return Statistics(n=n, total_bp1=total1_bp, total_bp2=total2_bp)
+
+
+def trimmed_and_untrimmed_files(
+		default_output,
+		output_path,
+		untrimmed_path,
+		discard_trimmed,
+		discard_untrimmed
+		):
+	"""
+	Figure out (from command-line parameters) where trimmed and untrimmed reads
+	should be written.
+
+	Return a pair (trimmed, untrimmed). The values are either open file-like
+	objects or None, in which case no output should be produced. The objects may
+	be identical (for example: (sys.stdout, sys.stdout)).
+
+	The parameters are sorted: Later parameters have higher precedence.
+
+	default_output -- If nothing else is specified below, this file-like object
+		is returned for both trimmed and untrimmed output.
+	output_path -- Path to output file for both trimmed and untrimmed output.
+	untrimmed_path -- Path to an output file for untrimmed reads.
+	discard_trimmed -- bool, overrides earlier options.
+	discard_untrimmed -- bool, overrides earlier options.
+	"""
+	if discard_trimmed:
+		if discard_untrimmed:
+			untrimmed = None
+		elif untrimmed_path is not None:
+			untrimmed = xopen(untrimmed_path, 'w')
+		elif output_path is not None:
+			untrimmed = xopen(output_path, 'w')
+		else:
+			untrimmed = default_output
+		return (None, untrimmed)
+	if discard_untrimmed:
+		trimmed = default_output
+		if output_path is not None:
+			trimmed = xopen(output_path, 'w')
+		return (trimmed, None)
+
+	trimmed = default_output
+	untrimmed = default_output
+	if output_path is not None:
+		trimmed = untrimmed = xopen(output_path, 'w')
+	if untrimmed_path is not None:
+		untrimmed = xopen(untrimmed_path, 'w')
+
+	return (trimmed, untrimmed)
+
+
+def get_option_parser():
+	parser = CutadaptOptionParser(usage=__doc__, version=__version__)
+
+	parser.add_option("-f", "--format",
+		help="Input file format; can be either 'fasta', 'fastq' or 'sra-fastq'. "
+			"Ignored when reading csfasta/qual files (default: auto-detect "
+			"from file name extension).")
+
+	group = OptionGroup(parser, "Options that influence how the adapters are found",
+		description="Each of the following three parameters (-a, -b, -g) can be used "
+			"multiple times and in any combination to search for an entire set of "
+			"adapters of possibly different types. Only the best matching "
+			"adapter is trimmed from each read (but see the --times option). "
+			"Instead of giving an adapter directly, you can also write "
+			"file:FILE and the adapter sequences will be read from the given "
+			"FILE (which must be in FASTA format).")
+	group.add_option("-a", "--adapter", action="append", default=[], metavar="ADAPTER",
+		dest="adapters",
+		help="Sequence of an adapter that was ligated to the 3' end. The "
+			"adapter itself and anything that follows is trimmed. If the "
+			"adapter sequence ends with the '$' character, the adapter is "
+			"anchored to the end of the read and only found if it is a "
+			"suffix of the read.")
+	group.add_option("-g", "--front", action="append", default=[], metavar="ADAPTER",
+		help="Sequence of an adapter that was ligated to the 5' end. If the "
+		"adapter sequence starts with the character '^', the adapter is "
+		"'anchored'. An anchored adapter must appear in its entirety at the "
+		"5' end of the read (it is a prefix of the read). A non-anchored adapter may "
+		"appear partially at the 5' end, or it may occur within the read. If it is "
+		"found within a read, the sequence preceding the adapter is also trimmed. "
+		"In all cases, the adapter itself is trimmed.")
+	group.add_option("-b", "--anywhere", action="append", default=[], metavar="ADAPTER",
+		help="Sequence of an adapter that was ligated to the 5' or 3' end. If "
+			"the adapter is found within the read or overlapping the 3' end of "
+			"the read, the behavior is the same as for the -a option. If the "
+			"adapter overlaps the 5' end (beginning of the read), the initial "
+			"portion of the read matching the adapter is trimmed, but anything "
+			"that follows is kept.")
+	group.add_option("-e", "--error-rate", type=float, default=0.1,
+		help="Maximum allowed error rate (no. of errors divided by the length "
+			"of the matching region) (default: %default)")
+	group.add_option("--no-indels", action='store_false', dest='indels', default=True,
+		help="Do not allow indels in the alignments (allow only mismatches). "
+			"Currently only supported for anchored adapters. (default: allow "
+			"both mismatches and indels)")
+	group.add_option("-n", "--times", type=int, metavar="COUNT", default=1,
+		help="Try to remove adapters at most COUNT times. Useful when an "
+			"adapter gets appended multiple times (default: %default).")
+	group.add_option("-O", "--overlap", type=int, metavar="LENGTH", default=3,
+		help="Minimum overlap length. If the overlap between the read and the "
+			"adapter is shorter than LENGTH, the read is not modified. "
+			"This reduces the no. of bases trimmed purely due to short random "
+			"adapter matches (default: %default).")
+	group.add_option("--match-read-wildcards", action="store_true", default=False,
+		help="Allow IUPAC wildcards in reads (default: %default).")
+	group.add_option("-N", "--no-match-adapter-wildcards", action="store_false",
+		default=True, dest='match_adapter_wildcards',
+		help="Do not interpret IUPAC wildcards in adapters.")
+	parser.add_option_group(group)
+
+	group = OptionGroup(parser, "Options for filtering of processed reads")
+	group.add_option("--discard-trimmed", "--discard", action='store_true', default=False,
+		help="Discard reads that contain the adapter instead of trimming them. "
+			"Also use -O in order to avoid throwing away too many randomly "
+			"matching reads!")
+	group.add_option("--discard-untrimmed", "--trimmed-only", action='store_true', default=False,
+		help="Discard reads that do not contain the adapter.")
+	group.add_option("-m", "--minimum-length", type=int, default=0, metavar="LENGTH",
+		help="Discard trimmed reads that are shorter than LENGTH. Reads that "
+			"are too short even before adapter removal are also discarded. In "
+			"colorspace, an initial primer is not counted (default: 0).")
+	group.add_option("-M", "--maximum-length", type=int, default=sys.maxsize, metavar="LENGTH",
+		help="Discard trimmed reads that are longer than LENGTH. "
+			"Reads that are too long even before adapter removal "
+			"are also discarded. In colorspace, an initial primer "
+			"is not counted (default: no limit).")
+	group.add_option("--no-trim", dest='action', action='store_const', const=None,
+		help="Match and redirect reads to output/untrimmed-output as usual, "
+			"but do not remove adapters.")
+	group.add_option("--max-n", type=float, default=-1.0, metavar="LENGTH",
+		help="The max proportion of N's allowed in a read. A number < 1 will be treated as a proportion while"
+			 " a number > 1 will be treated as the maximum number of N's contained.")
+	group.add_option("--mask-adapter", dest='action', action='store_const', const='mask',
+		help="Mask adapters with 'N' characters instead of trimming them.")
+	parser.add_option_group(group)
+
+	group = OptionGroup(parser, "Options that influence what gets output to where")
+	group.add_option("--quiet", default=False, action='store_true',
+		help="Do not print a report at the end.")
+	group.add_option("-o", "--output", metavar="FILE",
+		help="Write modified reads to FILE. FASTQ or FASTA format is chosen "
+			"depending on input. The summary report is sent to standard output. "
+			"Use '{name}' in FILE to demultiplex reads into multiple "
+			"files. (default: trimmed reads are written to standard output)")
+	group.add_option("--info-file", metavar="FILE",
+		help="Write information about each read and its adapter matches into FILE. "
+			"See the documentation for the file format.")
+	group.add_option("-r", "--rest-file", metavar="FILE",
+		help="When the adapter matches in the middle of a read, write the "
+			"rest (after the adapter) into FILE.")
+	group.add_option("--wildcard-file", metavar="FILE",
+		help="When the adapter has wildcard bases ('N's), write adapter bases "
+			"matching wildcard positions to FILE. When there are indels in the "
+			"alignment, this will often not be accurate.")
+	group.add_option("--too-short-output", metavar="FILE",
+		help="Write reads that are too short (according to length specified by -m) to FILE. (default: discard reads)")
+	group.add_option("--too-long-output", metavar="FILE",
+		help="Write reads that are too long (according to length specified by -M) to FILE. (default: discard reads)")
+	group.add_option("--untrimmed-output", default=None, metavar="FILE",
+		help="Write reads that do not contain the adapter to FILE. (default: "
+			"output to same file as trimmed reads)")
+	parser.add_option_group(group)
+
+	group = OptionGroup(parser, "Additional modifications to the reads")
+	group.add_option("-u", "--cut", action='append', default=[], type=int, metavar="LENGTH",
+		help="Remove LENGTH bases from the beginning or end of each read. "
+			"If LENGTH is positive, the bases are removed from the beginning of each read. "
+			"If LENGTH is negative, the bases are removed from the end of each read. "
+			"This option can be specified twice if the LENGTHs have different signs.")
+	group.add_option("-q", "--quality-cutoff", default=None, metavar="[5'CUTOFF,]3'CUTOFF",
+		help="Trim low-quality bases from 5' and/or 3' ends of reads before "
+			"adapter removal. If one value is given, only the 3' end is trimmed. "
+			"If two comma-separated cutoffs are given, the 5' end is trimmed with "
+			"the first cutoff, the 3' end with the second. The algorithm is the "
+			"same as the one used by BWA (see documentation). (default: no trimming)")
+	group.add_option("--quality-base", type=int, default=33,
+		help="Assume that quality values are encoded as ascii(quality + QUALITY_BASE). The default (33) is usually correct, "
+			 "except for reads produced by some versions of the Illumina pipeline, where this should be set to 64. (Default: %default)")
+	group.add_option("--trim-n", action='store_true', default=False,
+		help="Trim N's on ends of reads.")
+	group.add_option("-x", "--prefix", default='',
+		help="Add this prefix to read names")
+	group.add_option("-y", "--suffix", default='',
+		help="Add this suffix to read names")
+	group.add_option("--strip-suffix", action='append', default=[],
+		help="Remove this suffix from read names if present. Can be given multiple times.")
+	group.add_option("-c", "--colorspace", action='store_true', default=False,
+		help="Colorspace mode: Also trim the color that is adjacent to the found adapter.")
+	group.add_option("-d", "--double-encode", action='store_true', default=False,
+		help="When in colorspace, double-encode colors (map 0,1,2,3,4 to A,C,G,T,N).")
+	group.add_option("-t", "--trim-primer", action='store_true', default=False,
+		help="When in colorspace, trim primer base and the first color "
+			"(which is the transition to the first nucleotide)")
+	group.add_option("--strip-f3", action='store_true', default=False,
+		help="For colorspace: Strip the _F3 suffix of read names")
+	group.add_option("--maq", "--bwa", action='store_true', default=False,
+		help="MAQ- and BWA-compatible colorspace output. This enables -c, -d, -t, --strip-f3 and -y '/1'.")
+	group.add_option("--length-tag", metavar="TAG",
+		help="Search for TAG followed by a decimal number in the description "
+			"field of the read. Replace the decimal number with the correct "
+			"length of the trimmed read. For example, use --length-tag 'length=' "
+			"to correct fields like 'length=123'.")
+	group.add_option("--no-zero-cap", dest='zero_cap', action='store_false',
+		help="Do not change negative quality values to zero. Colorspace "
+			"quality values of -1 would appear as spaces in the output FASTQ "
+			"file. Since many tools have problems with that, negative qualities "
+			"are converted to zero when trimming colorspace data. Use this "
+			"option to keep negative qualities.")
+	group.add_option("--zero-cap", "-z", action='store_true',
+		help="Change negative quality values to zero. This is enabled "
+		"by default when -c/--colorspace is also enabled. Use the above option "
+		"to disable it.")
+	parser.set_defaults(zero_cap=None, action='trim')
+	parser.add_option_group(group)
+
+	group = OptionGroup(parser, "Paired-end options.", description="The "
+		"-A/-G/-B/-U options work like their -a/-b/-g/-u counterparts.")
+	group.add_option("-A", dest='adapters2', action='append', default=[], metavar='ADAPTER',
+		help="3' adapter to be removed from the second read in a pair.")
+	group.add_option("-G", dest='front2', action='append', default=[], metavar='ADAPTER',
+		help="5' adapter to be removed from the second read in a pair.")
+	group.add_option("-B", dest='anywhere2', action='append', default=[], metavar='ADAPTER',
+		help="5'/3 adapter to be removed from the second read in a pair.")
+	group.add_option("-U", dest='cut2', action='append', default=[], type=int, metavar="LENGTH",
+		help="Remove LENGTH bases from the beginning or end of each read (see --cut).")
+	group.add_option("-p", "--paired-output", metavar="FILE",
+		help="Write second read in a pair to FILE.")
+	group.add_option("--untrimmed-paired-output", metavar="FILE",
+		help="Write the second read in a pair to this FILE when no adapter "
+			"was found in the first read. Use this option together with "
+			"--untrimmed-output when trimming paired-end reads. (Default: output "
+			"to same file as trimmed reads.)")
+	parser.add_option_group(group)
+
+	return parser
+
+
+def main(cmdlineargs=None, default_outfile=sys.stdout):
+	"""
+	Main function that evaluates command-line parameters and iterates
+	over all reads.
+
+	default_outfile is the file to which trimmed reads are sent if the ``-o``
+	parameter is not used.
+	"""
+	logging.basicConfig(level=logging.INFO, format='%(message)s')  #  %(levelname)s
+	parser = get_option_parser()
+	if cmdlineargs is None:
+		cmdlineargs = sys.argv[1:]
+	options, args = parser.parse_args(args=cmdlineargs)
+
+	if len(args) == 0:
+		parser.error("At least one parameter needed: name of a FASTA or FASTQ file.")
+	elif len(args) > 2:
+		parser.error("Too many parameters.")
+	input_filename = args[0]
+
+	# Find out which 'mode' we need to use.
+	# Default: single-read trimming (neither -p nor -A/-G/-B/-U given)
+	paired = False
+	if options.paired_output:
+		# Modify first read only, keep second in sync (-p given, but not -A/-G/-B/-U).
+		# This exists for backwards compatibility ('legacy mode').
+		paired = 'first'
+	if options.adapters2 or options.front2 or options.anywhere2 or options.cut2:
+		# Full paired-end trimming when both -p and -A/-G/-B/-U given
+		# Also the read modifications (such as quality trimming) are applied
+		# to second read.
+		paired = 'both'
+
+	if paired and len(args) == 1:
+		parser.error("When paired-end trimming is enabled via -A/-G/-B/-U or -p, "
+			"two input files are required.")
+	if paired:
+		input_paired_filename = args[1]
+		quality_filename = None
+	else:
+		input_paired_filename = None
+		if len(args) == 2:
+			if args[0].endswith('.qual'):
+				parser.error("The QUAL file must be the second argument.")
+			quality_filename = args[1]
+		else:
+			quality_filename = None
+
+	if paired:
+		if not options.paired_output:
+			parser.error("When paired-end trimming is enabled via -A/-G/-B/-U, "
+				"a second output file needs to be specified via -p (--paired-output).")
+		if bool(options.untrimmed_output) != bool(options.untrimmed_paired_output):
+			parser.error("When trimming paired-end reads, you must use either none "
+				"or both of the --untrimmed-output/--untrimmed-paired-output options.")
+	else:
+		if options.untrimmed_paired_output:
+			parser.error("Option --untrimmed-paired-output can only be used when "
+				"trimming paired-end reads (with option -p).")
+		if input_filename.endswith('.qual'):
+			parser.error("Need a FASTA file in addition to the QUAL file.")
+		if options.format is not None and quality_filename is not None:
+			parser.error("If a pair of .fasta and .qual files is given, the -f/--format parameter cannot be used.")
+
+	if options.format is not None and options.format.lower() not in ['fasta', 'fastq', 'sra-fastq']:
+		parser.error("The input file format must be either 'fasta', 'fastq' or "
+			"'sra-fastq' (not '{0}').".format(options.format))
+
+	if options.quality_cutoff is not None:
+		cutoffs = options.quality_cutoff.split(',')
+		if len(cutoffs) == 1:
+			try:
+				cutoffs = [0, int(cutoffs[0])]
+			except ValueError as e:
+				parser.error("Quality cutoff value not recognized: {0}".format(e))
+		elif len(cutoffs) == 2:
+			try:
+				cutoffs = [int(cutoffs[0]), int(cutoffs[1])]
+			except ValueError as e:
+				parser.error("Quality cutoff value not recognized: {0}".format(e))
+		else:
+			parser.error("Expected one value or two values separated by comma for the quality cutoff")
+	else:
+		cutoffs = None
+	writers = []
+	too_short_outfile = None  # too short reads go here
+	too_short_filter = None
+	# TODO pass file name to TooShortReadFilter, add a .close() method?
+	if options.minimum_length > 0:
+		if options.too_short_output:
+			too_short_outfile = xopen(options.too_short_output, 'w')
+		else:
+			too_short_outfile = None
+		too_short_filter = TooShortReadFilter(options.minimum_length,
+			too_short_outfile, paired=='both')
+		writers.append(too_short_filter)
+	too_long_outfile = None  # too long reads go here
+	too_long_filter = None
+	if options.maximum_length < sys.maxsize:
+		if options.too_long_output is not None:
+			too_long_outfile = xopen(options.too_long_output, 'w')
+		else:
+			too_long_outfile = None
+		too_long_filter = TooLongReadFilter(options.maximum_length,
+			too_long_outfile, check_second=paired=='both')
+		writers.append(too_long_filter)
+
+	if options.max_n != -1:
+		writers.append(NContentFilter(options.max_n, check_second=paired=='both'))
+
+	demultiplexer = None
+	if options.output is not None and '{name}' in options.output:
+		if options.discard_trimmed:
+			parser.error("Do not use --discard-trimmed when demultiplexing.")
+		if paired:
+			parser.error("Demultiplexing not supported for paired-end files, yet.")
+		untrimmed = options.output.format(name='unknown')
+		if options.untrimmed_output:
+			untrimmed = options.untrimmed_output
+		if options.discard_untrimmed:
+			untrimmed = None
+		demultiplexer = Demultiplexer(options.output, untrimmed)
+		writers.append(demultiplexer)
+		trimmed_outfile, untrimmed_outfile = None, None
+		trimmed_paired_outfile, untrimmed_paired_outfile = None, None
+	else:
+		trimmed_outfile, untrimmed_outfile = trimmed_and_untrimmed_files(
+			default_outfile,
+			options.output,
+			options.untrimmed_output,
+			options.discard_trimmed,
+			options.discard_untrimmed)
+
+		trimmed_paired_outfile, untrimmed_paired_outfile = trimmed_and_untrimmed_files(
+			None,  # applies when not trimming paired-end data
+			options.paired_output,
+			options.untrimmed_paired_output,
+			options.discard_trimmed,
+			options.discard_untrimmed)
+
+		if untrimmed_outfile or untrimmed_paired_outfile:
+			writers.append(DiscardUntrimmedFilter(untrimmed_outfile,
+				untrimmed_paired_outfile, check_second=paired=='both'))
+		writer = DiscardTrimmedFilter(
+			trimmed_outfile, trimmed_paired_outfile,
+			check_second=paired=='both'
+		)
+		writers.append(writer)
+		del writer
+
+	if options.maq:
+		options.colorspace = True
+		options.double_encode = True
+		options.trim_primer = True
+		options.strip_suffix.append('_F3')
+		options.suffix = "/1"
+	if options.zero_cap is None:
+		options.zero_cap = options.colorspace
+	if options.trim_primer and not options.colorspace:
+		parser.error("Trimming the primer makes only sense in colorspace.")
+	if options.double_encode and not options.colorspace:
+		parser.error("Double-encoding makes only sense in colorspace.")
+	if options.anywhere and options.colorspace:
+		parser.error("Using --anywhere with colorspace reads is currently not supported (if you think this may be useful, contact the author).")
+	if not (0 <= options.error_rate <= 1.):
+		parser.error("The maximum error rate must be between 0 and 1.")
+	if options.overlap < 1:
+		parser.error("The overlap must be at least 1.")
+
+	if options.rest_file is not None:
+		options.rest_file = xopen(options.rest_file, 'w')
+		rest_writer = RestFileWriter(options.rest_file)
+	else:
+		rest_writer = None
+	if options.info_file is not None:
+		options.info_file = xopen(options.info_file, 'w')
+	if options.wildcard_file is not None:
+		options.wildcard_file = xopen(options.wildcard_file, 'w')
+
+	if options.colorspace:
+		if options.match_read_wildcards:
+			parser.error('IUPAC wildcards not supported in colorspace')
+		options.match_adapter_wildcards = False
+
+	ADAPTER_CLASS = ColorspaceAdapter if options.colorspace else Adapter
+	try:
+		# TODO refactor this a bit
+		def collect(back, anywhere, front):
+			adapters = []
+			for name, seq, where in gather_adapters(back, anywhere, front):
+				if not seq:
+					parser.error("The adapter sequence is empty.")
+				if not options.indels and where not in (PREFIX, SUFFIX):
+					parser.error("Not allowing indels is currently supported only for anchored 5' and 3' adapters.")
+				adapter = ADAPTER_CLASS(seq, where, options.error_rate,
+					options.overlap, options.match_read_wildcards,
+					options.match_adapter_wildcards, name=name, indels=options.indels)
+				adapters.append(adapter)
+			return adapters
+
+		adapters = collect(options.adapters, options.anywhere, options.front)
+		adapters2 = collect(options.adapters2, options.anywhere2, options.front2)
+	except IOError as e:
+		if e.errno == errno.ENOENT:
+			parser.error(e)
+		raise
+
+	if not adapters and not adapters2 and not cutoffs and \
+			options.cut == [] and options.cut2 == [] and \
+			options.minimum_length == 0 and \
+			options.maximum_length == sys.maxsize and \
+			quality_filename is None and \
+			options.max_n == -1:
+		parser.error("You need to provide at least one adapter sequence.")
+
+	try:
+		reader = seqio.open(input_filename, file2=input_paired_filename,
+				qualfile=quality_filename, colorspace=options.colorspace,
+				fileformat=options.format)
+	except (seqio.UnknownFileType, IOError) as e:
+		parser.error(e)
+
+	# Create the processing pipeline consisting of a list of "modifiers".
+	modifiers = []
+	if options.cut:
+		if len(options.cut) > 2:
+			parser.error("You cannot remove bases from more than two ends.")
+		if len(options.cut) == 2 and options.cut[0] * options.cut[1] > 0:
+			parser.error("You cannot remove bases from the same end twice.")
+		for cut in options.cut:
+			if cut != 0:
+				modifiers.append(UnconditionalCutter(cut))
+
+	if cutoffs:
+		modifiers.append(QualityTrimmer(cutoffs[0], cutoffs[1], options.quality_base))
+	if adapters:
+		adapter_cutter = AdapterCutter(adapters, options.times,
+				options.wildcard_file, options.info_file,
+				rest_writer, options.action)
+		modifiers.append(adapter_cutter)
+	else:
+		adapter_cutter = None
+
+	# Modifiers that apply to both reads of paired-end reads
+	modifiers_both = []
+	if options.trim_n:
+		modifiers_both.append(NEndTrimmer())
+	if options.length_tag:
+		modifiers_both.append(LengthTagModifier(options.length_tag))
+	if options.strip_f3:
+		options.strip_suffix.append('_F3')
+	for suffix in options.strip_suffix:
+		modifiers_both.append(SuffixRemover(suffix))
+	if options.prefix or options.suffix:
+		modifiers_both.append(PrefixSuffixAdder(options.prefix, options.suffix))
+	if options.double_encode:
+		modifiers_both.append(DoubleEncoder())
+	if options.zero_cap and reader.delivers_qualities:
+		modifiers_both.append(ZeroCapper(quality_base=options.quality_base))
+	if options.trim_primer:
+		modifiers_both.append(PrimerTrimmer)
+	modifiers.extend(modifiers_both)
+
+	# For paired-end data, create a second processing pipeline.
+	# However, if no second-read adapters were given (via -A/-G/-B/-U), we need to
+	# be backwards compatible and *no modifications* are done to the second read.
+	modifiers2 = []
+	if paired == 'both':
+		if options.cut2:
+			if len(options.cut2) > 2:
+				parser.error("You cannot remove bases from more than two ends.")
+			if len(options.cut2) == 2 and options.cut2[0] * options.cut2[1] > 0:
+				parser.error("You cannot remove bases from the same end twice.")
+			for cut in options.cut2:
+				if cut != 0:
+					modifiers2.append(UnconditionalCutter(cut))
+
+		if cutoffs:
+			modifiers2.append(QualityTrimmer(cutoffs[0], cutoffs[1], options.quality_base))
+		if adapters2:
+			adapter_cutter2 = AdapterCutter(adapters2, options.times,
+					None, None, None, options.action)
+			modifiers2.append(adapter_cutter2)
+		else:
+			adapter_cutter2 = None
+		modifiers2.extend(modifiers_both)
+
+	# Due to backwards compatibility, from here on logging output needs to be
+	# sent to standard output instead of standard error if the -o option is used.
+	if options.output:
+		logger.root.handlers = []
+		logging.basicConfig(level=logging.INFO, format='%(message)s', stream=sys.stdout)
+	logger.info("This is cutadapt %s with Python %s", __version__, platform.python_version())
+	logger.info("Command line parameters: %s", " ".join(cmdlineargs))
+	logger.info("Trimming %s adapter%s with at most %.1f%% errors in %s mode ...",
+		len(adapters) + len(adapters2), 's' if len(adapters) + len(adapters2) != 1 else '',
+		options.error_rate * 100,
+		{ False: 'single-end', 'first': 'paired-end legacy', 'both': 'paired-end' }[paired])
+
+	start_time = time.clock()
+	try:
+		if paired:
+			stats = process_paired_reads(reader, modifiers, modifiers2, writers)
+		else:
+			stats = process_single_reads(reader, modifiers, writers)
+	except KeyboardInterrupt as e:
+		print("Interrupted", file=sys.stderr)
+		sys.exit(130)
+	except IOError as e:
+		if e.errno == errno.EPIPE:
+			sys.exit(1)
+		raise
+	except (seqio.FormatError, EOFError) as e:
+		sys.exit("cutadapt: error: {0}".format(e))
+
+	# close open files
+	for f in [trimmed_outfile, untrimmed_outfile, trimmed_paired_outfile,
+			untrimmed_paired_outfile, options.rest_file, options.wildcard_file,
+			options.info_file, too_short_outfile, too_long_outfile,
+			options.info_file, demultiplexer]:
+		if f is not None and f is not sys.stdin and f is not sys.stdout:
+			f.close()
+
+	elapsed_time = time.clock() - start_time
+	if not options.quiet:
+		stats.collect((adapters, adapters2), elapsed_time,
+			modifiers, modifiers2, writers)
+		# send statistics to stderr if result was sent to stdout
+		stat_file = sys.stderr if options.output is None else None
+		with redirect_standard_output(stat_file):
+			print_report(stats, (adapters, adapters2))
+
+
+if __name__ == '__main__':
+	main()
diff --git a/cutadapt/seqio.py b/cutadapt/seqio.py
new file mode 100644
index 0000000..39b2e3f
--- /dev/null
+++ b/cutadapt/seqio.py
@@ -0,0 +1,498 @@
+# coding: utf-8
+from __future__ import print_function, division, absolute_import
+import sys
+from os.path import splitext
+from cutadapt.xopen import xopen
+from cutadapt.compat import zip, basestring
+
+__author__ = "Marcel Martin"
+
+
+class FormatError(Exception):
+	"""
+	Raised when an input file (FASTA or FASTQ) is malformatted.
+	"""
+
+
+def _shorten(s, n=100):
+	"""Shorten string s to at most n characters, appending "..." if necessary."""
+	if s is None:
+		return None
+	if len(s) > n:
+		s = s[:n-3] + '...'
+	return s
+
+
+class Sequence(object):
+	"""qualities is a string and it contains the qualities encoded as ascii(qual+33)."""
+
+	def __init__(self, name, sequence, qualities=None, twoheaders=False, match=None):
+		"""Set qualities to None if there are no quality values"""
+		self.name = name
+		self.sequence = sequence
+		self.qualities = qualities
+		self.twoheaders = twoheaders
+		self.match = match
+		if qualities is not None:
+			if len(qualities) != len(sequence):
+				rname = _shorten(name)
+				raise FormatError("In read named {0!r}: Length of quality sequence ({1}) and length of read ({2}) do not match".format(
+					rname, len(qualities), len(sequence)))
+
+	def __getitem__(self, key):
+		"""slicing"""
+		return self.__class__(
+			self.name,
+			self.sequence[key],
+			self.qualities[key] if self.qualities is not None else None,
+		    self.twoheaders,
+		    self.match)
+
+	def __repr__(self):
+		qstr = ''
+		if self.qualities is not None:
+			qstr = ', qualities={0!r}'.format(_shorten(self.qualities))
+		return '<Sequence(name={0!r}, sequence={1!r}{2})>'.format(_shorten(self.name), _shorten(self.sequence), qstr)
+
+	def __len__(self):
+		return len(self.sequence)
+
+	def __eq__(self, other):
+		return self.name == other.name and \
+			self.sequence == other.sequence and \
+			self.qualities == other.qualities
+
+	def __ne__(self, other):
+		return not self.__eq__(other)
+
+	def write(self, outfile):
+		if self.qualities is not None:
+			s = '@' + self.name + '\n' + self.sequence + '\n+'
+			if self.twoheaders:
+				s += self.name
+			s += '\n' + self.qualities + '\n'
+		else:
+			s = '>' + self.name + '\n' + self.sequence + '\n'
+		outfile.write(s)
+
+
+try:
+	from ._seqio import Sequence
+except ImportError:
+	pass
+
+
+class ColorspaceSequence(Sequence):
+	def __init__(self, name, sequence, qualities, primer=None, twoheaders=False, match=None):
+		# In colorspace, the first character is the last nucleotide of the primer base
+		# and the second character encodes the transition from the primer base to the
+		# first real base of the read.
+		if primer is None:
+			self.primer = sequence[0:1]
+			sequence = sequence[1:]
+		else:
+			self.primer = primer
+		if qualities is not None and len(sequence) != len(qualities):
+			rname = _shorten(name)
+			raise FormatError("In read named {0!r}: length of colorspace quality "
+				"sequence ({1}) and length of read ({2}) do not match (primer "
+				"is: {3!r})".format(rname, len(qualities), len(sequence), self.primer))
+		super(ColorspaceSequence, self).__init__(name, sequence, qualities, twoheaders, match)
+		if not self.primer in ('A', 'C', 'G', 'T'):
+			raise FormatError("Primer base is {0!r} in read {1!r}, but it "
+				"should be one of A, C, G, T.".format(
+					self.primer, _shorten(name)))
+
+	def __repr__(self):
+		qstr = ''
+		if self.qualities is not None:
+			qstr = ', qualities={0!r}'.format(_shorten(self.qualities))
+		return '<ColorspaceSequence(name={0!r}, primer={1!r}, sequence={2!r}{3})>'.format(_shorten(self.name), self.primer, _shorten(self.sequence), qstr)
+
+	def __getitem__(self, key):
+		return self.__class__(
+			self.name,
+			self.sequence[key],
+			self.qualities[key] if self.qualities is not None else None,
+			self.primer,
+			self.twoheaders,
+			self.match)
+
+	def write(self, outfile):
+		if self.qualities is not None:
+			s = '@' + self.name + '\n' + self.primer + self.sequence + '\n+'
+			if self.twoheaders:
+				s += self.name
+			s += '\n' + self.qualities + '\n'
+		else:
+			s = '>' + self.name + '\n' + self.primer + self.sequence + '\n'
+		outfile.write(s)
+
+
+def sra_colorspace_sequence(name, sequence, qualities, twoheaders):
+	"""Factory for an SRA colorspace sequence (which has one quality value too many)"""
+	return ColorspaceSequence(name, sequence, qualities[1:], twoheaders=twoheaders)
+
+
+class FileWithPrependedLine(object):
+	"""
+	A file-like object that allows to "prepend" a single
+	line to an already opened file. That is, further
+	reads on the file will return the provided line and
+	only then the actual content. This is needed to solve
+	the problem of autodetecting input from a stream:
+	As soon as the first line has been read, we know
+	the file type, but also that line is "gone" and
+	unavailable for further processing.
+	"""
+	def __init__(self, file, line):
+		"""
+		file is an already opened file-like object.
+		line is a single string (newline will be appended if not included)
+		"""
+		if not line.endswith('\n'):
+			line += '\n'
+		self.first_line = line
+		self.file = file
+
+	def __iter__(self):
+		yield self.first_line
+		for line in self.file:
+			yield line
+
+	def close(self):
+		self.file.close()
+
+
+class FastaReader(object):
+	"""
+	Reader for FASTA files.
+	"""
+	def __init__(self, file, keep_linebreaks=False, sequence_class=Sequence):
+		"""
+		file is a filename or a file-like object.
+		If file is a filename, then it is passed to xopen().
+
+		keep_linebreaks -- whether to keep newline characters in the sequence
+		"""
+		if isinstance(file, basestring):
+			file = xopen(file)
+			self._file_passed = False
+		else:
+			self._file_passed = True
+		self.fp = file
+		self.sequence_class = sequence_class
+		self.delivers_qualities = False
+		self._delimiter = '\n' if keep_linebreaks else ''
+
+	def __iter__(self):
+		"""
+		Read next entry from the file (single entry at a time).
+		"""
+		name = None
+		seq = []
+		for i, line in enumerate(self.fp):
+			# strip() also removes DOS line breaks
+			line = line.strip()
+			if not line:
+				continue
+			if line and line[0] == '>':
+				if name is not None:
+					yield self.sequence_class(name, self._delimiter.join(seq), None)
+				name = line[1:]
+				seq = []
+			elif line and line[0] == '#':
+				continue
+			elif name is not None:
+				seq.append(line)
+			else:
+				raise FormatError("At line {0}: Expected '>' at beginning of "
+					"FASTA record, but got {1!r}.".format(i+1, _shorten(line)))
+
+		if name is not None:
+			yield self.sequence_class(name, self._delimiter.join(seq), None)
+
+	def close(self):
+		if not self._file_passed and self.fp is not None:
+			self.fp.close()
+			self.fp = None
+
+	def __enter__(self):
+		if self.fp is None:
+			raise ValueError("I/O operation on closed FastaReader")
+		return self
+
+	def __exit__(self, *args):
+		self.close()
+
+
+class ColorspaceFastaReader(FastaReader):
+	def __init__(self, file, keep_linebreaks=False):
+		super(ColorspaceFastaReader, self).__init__(file, keep_linebreaks, sequence_class=ColorspaceSequence)
+
+
+class FastqReader(object):
+	"""
+	Reader for FASTQ files. Does not support multi-line FASTQ files.
+	"""
+	def __init__(self, file, sequence_class=Sequence):
+		"""
+		file is a filename or a file-like object.
+		If file is a filename, then .gz files are supported.
+
+		The sequence_class should be a class such as Sequence or
+		ColorspaceSequence.
+		"""
+		if isinstance(file, basestring):
+			file = xopen(file)
+			self._file_passed = False
+		else:
+			self._file_passed = True
+		self.fp = file
+		self.sequence_class = sequence_class
+		self.delivers_qualities = True
+
+	def __iter__(self):
+		"""
+		Return tuples: (name, sequence, qualities).
+		qualities is a string and it contains the unmodified, encoded qualities.
+		"""
+		for i, line in enumerate(self.fp):
+			if i % 4 == 0:
+				if not line.startswith('@'):
+					raise FormatError("At line {0}: Expected a line starting with '@'".format(i+1))
+				name = line.strip()[1:]
+			elif i % 4 == 1:
+				sequence = line.strip()
+			elif i % 4 == 2:
+				line = line.strip()
+				if not line.startswith('+'):
+					raise FormatError("At line {0}: Expected a line starting with '+'".format(i+1))
+				if len(line) > 1:
+					twoheaders = True
+					if not line[1:] == name:
+						raise FormatError(
+							"At line {0}: Sequence descriptions in the FASTQ file do not match "
+							"({1!r} != {2!r}).\n"
+							"The second sequence description must be either empty "
+							"or equal to the first description.".format(
+								i+1, name, line.rstrip()[1:]))
+				else:
+					twoheaders = False
+			elif i % 4 == 3:
+				qualities = line.rstrip('\n\r')
+				yield self.sequence_class(name, sequence, qualities, twoheaders=twoheaders)
+
+	def close(self):
+		if not self._file_passed and self.fp is not None:
+			self.fp.close()
+			self.fp = None
+
+	def __enter__(self):
+		if self.fp is None:
+			raise ValueError("I/O operation on closed FastqReader")
+		return self
+
+	def __exit__(self, *args):
+		self.close()
+
+
+try:
+	from ._seqio import FastqReader, FormatError
+except ImportError:
+	pass
+
+
+class ColorspaceFastqReader(FastqReader):
+	def __init__(self, file):
+		super(ColorspaceFastqReader, self).__init__(file, sequence_class=ColorspaceSequence)
+
+
+class SRAColorspaceFastqReader(FastqReader):
+	def __init__(self, file):
+		super(SRAColorspaceFastqReader, self).__init__(file, sequence_class=sra_colorspace_sequence)
+
+
+class FastaQualReader(object):
+	"""
+	Reader for reads that are stored in .(CS)FASTA and .QUAL files.
+	"""
+	def __init__(self, fastafile, qualfile, sequence_class=Sequence):
+		"""
+		fastafile and qualfile are filenames or file-like objects.
+		If a filename is used, then .gz files are recognized.
+
+		The objects returned when iteritng over this file are instances of the
+		given sequence_class.
+		"""
+		self.fastareader = FastaReader(fastafile)
+		self.qualreader = FastaReader(qualfile, keep_linebreaks=True)
+		self.sequence_class = sequence_class
+		self.delivers_qualities = True
+
+	def __iter__(self):
+		"""
+		Yield Sequence objects.
+		"""
+		# conversion dictionary: maps strings to the appropriate ASCII-encoded character
+		conv = dict()
+		for i in range(-5, 256 - 33):
+			conv[str(i)] = chr(i + 33)
+		for fastaread, qualread in zip(self.fastareader, self.qualreader):
+			if fastaread.name != qualread.name:
+				raise FormatError("The read names in the FASTA and QUAL file do not match ({0!r} != {1!r})".format(fastaread.name, qualread.name))
+			try:
+				qualities = ''.join([conv[value] for value in qualread.sequence.split()])
+			except KeyError as e:
+				raise FormatError("Within read named {0!r}: Found invalid quality value {1}".format(fastaread.name, e))
+			assert fastaread.name == qualread.name
+			yield self.sequence_class(fastaread.name, fastaread.sequence, qualities)
+
+	def close(self):
+		self.fastareader.close()
+		self.qualreader.close()
+
+	def __enter__(self):
+		return self
+
+	def __exit__(self, *args):
+		self.close()
+
+
+class ColorspaceFastaQualReader(FastaQualReader):
+	def __init__(self, fastafile, qualfile):
+		super(ColorspaceFastaQualReader, self).__init__(fastafile, qualfile, sequence_class=ColorspaceSequence)
+
+
+class PairedSequenceReader(object):
+	"""
+	Wrap two SequenceReader instances, making sure that reads are
+	properly paired.
+	"""
+	def __init__(self, file1, file2, colorspace=False, fileformat=None):
+		self.reader1 = open(file1, colorspace=colorspace, fileformat=fileformat)
+		self.reader2 = open(file2, colorspace=colorspace, fileformat=fileformat)
+		self.delivers_qualities = self.reader1.delivers_qualities
+
+	def __iter__(self):
+		# Avoid usage of zip() below since it will consume one item too many.
+		it1, it2 = iter(self.reader1), iter(self.reader2)
+		while True:
+			try:
+				r1 = next(it1)
+			except StopIteration:
+				# End of file 1. Make sure that file 2 is also at end.
+				try:
+					next(it2)
+					raise FormatError("Reads are improperly paired. There are more reads in file 2 than in file 1.")
+				except StopIteration:
+					pass
+				break
+			try:
+				r2 = next(it2)
+			except StopIteration:
+				raise FormatError("Reads are improperly paired. There are more reads in file 1 than in file 2.")
+
+			name1 = r1.name.split(None, 1)[0]
+			name2 = r2.name.split(None, 1)[0]
+			if name1[-2:-1] == '/':
+				name1 = name1[:-2]
+			if name2[-2:-1] == '/':
+				name2 = name2[:-2]
+			if name1 != name2:
+				raise FormatError("Reads are improperly paired. Read name '{0}' in file 1 not equal to '{1}' in file 2.".format(name1, name2))
+			yield (r1, r2)
+
+
+class UnknownFileType(Exception):
+	"""
+	Raised when open could not autodetect the file type.
+	"""
+
+
+def open(file1, file2=None, qualfile=None, colorspace=False, fileformat=None):
+	"""
+	Open sequence file in FASTA or FASTQ format. Parameters file1, file2 and
+	qualfile will be passed to xopen and can therefore be paths to regular or
+	compressed files or file-like objects. If only file1 is provided, a
+	FastaReader or FastqReader (for single-end reads) is returned. If file2
+	is also provided, a PairedSequenceReader is returned. If qualfile is
+	given, a FastaQualReader from file1 and qualfile is returned. One of file2
+	and qualfile must always be None (no paired-end data is supported when
+	reading qualfiles).
+
+	If the colorspace parameter is set to True, the returned readers are
+	ColorspaceFastaReader, ColorspaceFastqReader or ColorspaceFastaQualReader
+	instead.
+
+	If possible, file format is autodetected by inspecting the file name:
+	.fasta/.fa, .fastq/.fq and some other extensions are allowed. If the
+	file name is not available (when reading from standard input), the file is
+	read and the file type determined from the content. The autodetection can
+	be skipped by setting fileformat to one of 'fasta', 'fastq', 'sra-fastq'.
+	Colorspace is not auto-detected and must always be requested explicitly.
+	"""
+	if file2 is not None and qualfile is not None:
+		raise ValueError("Setting both file2 and qualfile is not supported")
+	if file2 is not None:
+		return PairedSequenceReader(file1, file2, colorspace, fileformat)
+
+	if qualfile is not None:
+		if colorspace:
+			# read from .(CS)FASTA/.QUAL
+			return ColorspaceFastaQualReader(file1, qualfile)
+		else:
+			return FastaQualReader(file1, qualfile)
+	# read from FASTA or FASTQ
+	fastq_reader = ColorspaceFastqReader if colorspace else FastqReader
+	fasta_reader = ColorspaceFastaReader if colorspace else FastaReader
+
+	if fileformat is not None:
+		fileformat = fileformat.lower()
+		if fileformat == 'fasta':
+			return fasta_reader(file1)
+		elif fileformat == 'fastq':
+			return fastq_reader(file1)
+		elif fileformat == 'sra-fastq' and colorspace:
+			return SRAColorspaceFastqReader(file1)
+		else:
+			raise UnknownFileType("File format {0} is unknown (expected "
+				"'sra-fastq' (only for colorspace), 'fasta' or 'fastq').".format(fileformat))
+
+	name = None
+	if file1 == "-":
+		file1 = sys.stdin
+	elif isinstance(file1, basestring):
+		name = file1
+	elif hasattr(file1, "name"):
+		# Assume that 'file1' is an open file1
+		name = file1.name
+
+	if name is not None:
+		if name.endswith('.gz'):
+			name = name[:-3]
+		elif name.endswith('.xz'):
+			name = name[:-3]
+		elif name.endswith('.bz2'):
+			name = name[:-4]
+		name, ext = splitext(name)
+		ext = ext.lower()
+		if ext in ['.fasta', '.fa', '.fna', '.csfasta', '.csfa']:
+			return fasta_reader(file1)
+		elif ext in ['.fastq', '.fq'] or (ext == '.txt' and name.endswith('_sequence')):
+			return fastq_reader(file1)
+		else:
+			raise UnknownFileType("Could not determine whether this is FASTA "
+				"or FASTQ: file name extension {0} not recognized".format(ext))
+
+	# No name available.
+	# autodetect type by reading from the file
+	for line in file1:
+		if line.startswith('#'):
+			# Skip comment lines (needed for csfasta)
+			continue
+		if line.startswith('>'):
+			return fasta_reader(FileWithPrependedLine(file1, line))
+		if line.startswith('@'):
+			return fastq_reader(FileWithPrependedLine(file1, line))
+	raise UnknownFileType("File is neither FASTQ nor FASTA.")
diff --git a/cutadapt/xopen.py b/cutadapt/xopen.py
new file mode 100644
index 0000000..dffb2e4
--- /dev/null
+++ b/cutadapt/xopen.py
@@ -0,0 +1,178 @@
+"""
+Open compressed files transparently.
+"""
+from __future__ import print_function, division, absolute_import
+__author__ = 'Marcel Martin'
+
+import gzip
+import sys
+import io
+import os
+from subprocess import Popen, PIPE
+from .compat import PY3, basestring
+
+try:
+	import bz2
+except ImportError:
+	bz2 = None
+
+try:
+	import lzma
+except ImportError:
+	lzma = None
+
+if sys.version_info < (2, 7):
+	buffered_reader = lambda x: x
+	buffered_writer = lambda x: x
+else:
+	buffered_reader = io.BufferedReader
+	buffered_writer = io.BufferedWriter
+
+
+class GzipWriter:
+	def __init__(self, path, mode='w'):
+		self.outfile = open(path, mode)
+		self.devnull = open(os.devnull, 'w')
+		try:
+			# Setting close_fds to True is necessary due to
+			# http://bugs.python.org/issue12786
+			self.process = Popen(['gzip'], stdin=PIPE, stdout=self.outfile,
+				stderr=self.devnull, close_fds=True)
+		except IOError as e:
+			self.outfile.close()
+			self.devnull.close()
+			raise
+
+	def write(self, arg):
+		self.process.stdin.write(arg)
+
+	def close(self):
+		self.process.stdin.close()
+		retcode = self.process.wait()
+		self.outfile.close()
+		self.devnull.close()
+		if retcode != 0:
+			raise IOError("Output gzip process terminated with exit code {0}".format(retcode))
+
+	def __enter__(self):
+		return self
+
+	def __exit__(self, *exc_info):
+		self.close()
+
+
+class GzipReader:
+	def __init__(self, path):
+		self.process = Popen(['gzip', '-cd', path], stdout=PIPE)
+
+	def close(self):
+		retcode = self.process.poll()
+		if retcode is None:
+			# still running
+			self.process.terminate()
+		self._raise_if_error()
+
+	def __iter__(self):
+		for line in self.process.stdout:
+			yield line
+		self.process.wait()
+		self._raise_if_error()
+
+	def _raise_if_error(self):
+		"""
+		Raise EOFError if process is not running anymore and the
+		exit code is nonzero.
+		"""
+		retcode = self.process.poll()
+		if retcode is not None and retcode != 0:
+			raise EOFError("gzip process returned non-zero exit code {0}. Is the input file truncated or corrupt?".format(retcode))
+
+	def read(self, *args):
+		data = self.process.stdout.read(*args)
+		if len(args) == 0 or args[0] <= 0:
+			# wait for process to terminate until we check the exit code
+			self.process.wait()
+		self._raise_if_error()
+
+	def __enter__(self):
+		return self
+
+	def __exit__(self, *exc_info):
+		self.close()
+
+def xopen(filename, mode='r'):
+	"""
+	Replacement for the "open" function that can also open files that have
+	been compressed with gzip or bzip2. If the filename is '-', standard
+	output (mode 'w') or input (mode 'r') is returned. If the filename ends
+	with .gz, the file is opened with a pipe to the gzip program. If that
+	does not work, then gzip.open() is used (the gzip module is slower than
+	the pipe to the gzip program). If the filename ends with .bz2, it's
+	opened as a bz2.BZ2File. Otherwise, the regular open() is used.
+
+	mode can be: 'rt', 'rb', 'a', 'wt', or 'wb'
+	Instead of 'rt' and 'wt', 'r' and 'w' can be used as abbreviations.
+
+	In Python 2, the 't' and 'b' characters are ignored.
+
+	Append mode ('a') is unavailable with BZ2 compression and will raise an error.
+	"""
+	if mode == 'r':
+		mode = 'rt'
+	elif mode == 'w':
+		mode = 'wt'
+	if mode not in ('rt', 'rb', 'wt', 'wb', 'a'):
+		raise ValueError("mode '{0}' not supported".format(mode))
+	if not PY3:
+		mode = mode[0]
+	if not isinstance(filename, basestring):
+		raise ValueError("the filename must be a string")
+
+	# standard input and standard output handling
+	if filename == '-':
+		if not PY3:
+			return sys.stdin if 'r' in mode else sys.stdout
+		return dict(
+			rt=sys.stdin,
+			wt=sys.stdout,
+			rb=sys.stdin.buffer,
+			wb=sys.stdout.buffer)[mode]
+
+	if filename.endswith('.bz2'):
+		if bz2 is None:
+			raise ImportError("Cannot open bz2 files: The bz2 module is not available")
+		if PY3:
+			if 't' in mode:
+				return io.TextIOWrapper(bz2.BZ2File(filename, mode[0]))
+			else:
+				return bz2.BZ2File(filename, mode)
+		else:
+			return bz2.BZ2File(filename, mode)
+	elif filename.endswith('.xz'):
+		if lzma is None:
+			raise ImportError("Cannot open xz files: The lzma module is not available (use Python 3.3 or newer)")
+		return lzma.open(filename, mode)
+	elif filename.endswith('.gz'):
+		if PY3:
+			if 't' in mode:
+				return io.TextIOWrapper(gzip.open(filename, mode[0]))
+			else:
+				if 'r' in mode:
+					return io.BufferedReader(gzip.open(filename, mode))
+				else:
+					return io.BufferedWriter(gzip.open(filename, mode))
+		else:
+			# rb/rt are equivalent in Py2
+			if 'r' in mode:
+				try:
+					return GzipReader(filename)
+				except IOError:
+					# gzip not installed
+					return buffered_reader(gzip.open(filename, mode))
+			else:
+				try:
+					return GzipWriter(filename, mode)
+				except IOError:
+					return buffered_writer(gzip.open(filename, mode))
+	else:
+		return open(filename, mode)
diff --git a/doc/Makefile b/doc/Makefile
new file mode 100644
index 0000000..d5b1f21
--- /dev/null
+++ b/doc/Makefile
@@ -0,0 +1,179 @@
+# Makefile for Sphinx documentation
+#
+
+# You can set these variables from the command line.
+SPHINXOPTS    =
+SPHINXBUILD   = sphinx-build
+PAPER         =
+BUILDDIR      = _build
+
+# User-friendly check for sphinx-build
+ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
+$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
+endif
+
+# Internal variables.
+PAPEROPT_a4     = -D latex_paper_size=a4
+PAPEROPT_letter = -D latex_paper_size=letter
+ALLSPHINXOPTS   = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+# the i18n builder cannot share the environment and doctrees with the others
+I18NSPHINXOPTS  = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) .
+
+.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
+
+all: html
+
+help:
+	@echo "Please use \`make <target>' where <target> is one of"
+	@echo "  html       to make standalone HTML files"
+	@echo "  dirhtml    to make HTML files named index.html in directories"
+	@echo "  singlehtml to make a single large HTML file"
+	@echo "  pickle     to make pickle files"
+	@echo "  json       to make JSON files"
+	@echo "  htmlhelp   to make HTML files and a HTML help project"
+	@echo "  qthelp     to make HTML files and a qthelp project"
+	@echo "  devhelp    to make HTML files and a Devhelp project"
+	@echo "  epub       to make an epub"
+	@echo "  latex      to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
+	@echo "  latexpdf   to make LaTeX files and run them through pdflatex"
+	@echo "  latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
+	@echo "  text       to make text files"
+	@echo "  man        to make manual pages"
+	@echo "  texinfo    to make Texinfo files"
+	@echo "  info       to make Texinfo files and run them through makeinfo"
+	@echo "  gettext    to make PO message catalogs"
+	@echo "  changes    to make an overview of all changed/added/deprecated items"
+	@echo "  xml        to make Docutils-native XML files"
+	@echo "  pseudoxml  to make pseudoxml-XML files for display purposes"
+	@echo "  linkcheck  to check all external links for integrity"
+	@echo "  doctest    to run all doctests embedded in the documentation (if enabled)"
+
+clean:
+	rm -rf $(BUILDDIR)/*
+
+html:
+	$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
+
+dirhtml:
+	$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
+	@echo
+	@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
+
+singlehtml:
+	$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
+	@echo
+	@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
+
+pickle:
+	$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
+	@echo
+	@echo "Build finished; now you can process the pickle files."
+
+json:
+	$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
+	@echo
+	@echo "Build finished; now you can process the JSON files."
+
+htmlhelp:
+	$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
+	@echo
+	@echo "Build finished; now you can run HTML Help Workshop with the" \
+	      ".hhp project file in $(BUILDDIR)/htmlhelp."
+
+qthelp:
+	$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
+	@echo
+	@echo "Build finished; now you can run "qcollectiongenerator" with the" \
+	      ".qhcp project file in $(BUILDDIR)/qthelp, like this:"
+	@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/cutadapt.qhcp"
+	@echo "To view the help file:"
+	@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/cutadapt.qhc"
+
+devhelp:
+	$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
+	@echo
+	@echo "Build finished."
+	@echo "To view the help file:"
+	@echo "# mkdir -p $$HOME/.local/share/devhelp/cutadapt"
+	@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/cutadapt"
+	@echo "# devhelp"
+
+epub:
+	$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
+	@echo
+	@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
+
+latex:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo
+	@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
+	@echo "Run \`make' in that directory to run these through (pdf)latex" \
+	      "(use \`make latexpdf' here to do that automatically)."
+
+latexpdf:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo "Running LaTeX files through pdflatex..."
+	$(MAKE) -C $(BUILDDIR)/latex all-pdf
+	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+latexpdfja:
+	$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
+	@echo "Running LaTeX files through platex and dvipdfmx..."
+	$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
+	@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
+
+text:
+	$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
+	@echo
+	@echo "Build finished. The text files are in $(BUILDDIR)/text."
+
+man:
+	$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
+	@echo
+	@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
+
+texinfo:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo
+	@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
+	@echo "Run \`make' in that directory to run these through makeinfo" \
+	      "(use \`make info' here to do that automatically)."
+
+info:
+	$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
+	@echo "Running Texinfo files through makeinfo..."
+	make -C $(BUILDDIR)/texinfo info
+	@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
+
+gettext:
+	$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
+	@echo
+	@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
+
+changes:
+	$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
+	@echo
+	@echo "The overview file is in $(BUILDDIR)/changes."
+
+linkcheck:
+	$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
+	@echo
+	@echo "Link check complete; look for any errors in the above output " \
+	      "or in $(BUILDDIR)/linkcheck/output.txt."
+
+doctest:
+	$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
+	@echo "Testing of doctests in the sources finished, look at the " \
+	      "results in $(BUILDDIR)/doctest/output.txt."
+
+xml:
+	$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
+	@echo
+	@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
+
+pseudoxml:
+	$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
+	@echo
+	@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
diff --git a/doc/changes.rst b/doc/changes.rst
new file mode 100644
index 0000000..d9e113e
--- /dev/null
+++ b/doc/changes.rst
@@ -0,0 +1 @@
+.. include:: ../CHANGES.rst
diff --git a/doc/colorspace.rst b/doc/colorspace.rst
new file mode 100644
index 0000000..9b60078
--- /dev/null
+++ b/doc/colorspace.rst
@@ -0,0 +1,107 @@
+Colorspace reads
+================
+
+Cutadapt was designed to work with colorspace reads from the ABi SOLiD
+sequencer. Colorspace trimming is activated by the ``--colorspace``
+option (or use ``-c`` for short). The input reads can be given either:
+
+-  in a FASTA file
+-  in a FASTQ file
+-  in a ``.csfasta`` and a ``.qual`` file (this is the native SOLiD
+   format).
+
+In all cases, the colors must be represented by the characters 0, 1, 2,
+3. Example input files are in the cutadapt distribution at
+``tests/data/solid.*``. The ``.csfasta``/``.qual`` file format is
+automatically assumed if two input files are given to cutadapt.
+
+In colorspace mode, the adapter sequences given to the ``-a``, ``-b``
+and ``-g`` options can be given both as colors or as nucleotides. If
+given as nucleotides, they will automatically be converted to
+colorspace. For example, to trim an adapter from ``solid.csfasta`` and
+``solid.qual``, use this command-line::
+
+    cutadapt -c -a CGCCTTGGCCGTACAGCAG solid.csfasta solid.qual > output.fastq
+
+In case you know the colorspace adapter sequence, you can also write
+``330201030313112312`` instead of ``CGCCTTGGCCGTACAGCAG`` and the result
+is the same.
+
+Ambiguity in colorspace
+-----------------------
+
+The ambiguity of colorspace encoding leads to some effects to be aware
+of when trimming 3' adapters from colorspace reads. For example, when
+trimming the adapter ``AACTC``, cutadapt searches for its
+colorspace-encoded version ``0122``. But also ``TTGAG``, ``CCAGA`` and
+``GGTCT`` have an encoding of ``0122``. This means that effectively four
+different adapter sequences are searched and trimmed at the same time.
+There is no way around this, unless the decoded sequence were available,
+but that is usually only the case after read mapping.
+
+The effect should usually be quite small. The number of false positives
+is multiplied by four, but with a sufficiently large overlap (3 or 4 is
+already enough), this is still only around 0.2 bases lost per read on
+average. If inspecting k-mer frequencies or using small overlaps, you
+need to be aware of the effect, however.
+
+
+Double-encoding, BWA and MAQ
+----------------------------
+
+The read mappers MAQ and BWA (and possibly others) need their colorspace
+input reads to be in a so-called "double encoding". This simply means
+that they cannot deal with the characters 0, 1, 2, 3 in the reads, but
+require that the letters A, C, G, T be used for colors. For example, the
+colorspace sequence ``0011321`` would be ``AACCTGC`` in double-encoded
+form. This is not the same as conversion to basespace! The read is still
+in colorspace, only letters are used instead of digits. If that sounds
+confusing, that is because it is.
+
+Note that MAQ is unmaintained and should not be used in new projects.
+
+BWA’s colorspace support was dropped in versions more recent than 0.5.9,
+but that version works well.
+
+When you want to trim reads that will be mapped with BWA or MAQ, you can
+use the ``--bwa`` option, which enables colorspace mode (``-c``),
+double-encoding (``-d``), primer trimming (``-t``), all of which are
+required for BWA, in addition to some other useful options.
+
+The ``--maq`` option is an alias for ``--bwa``.
+
+
+Colorspace examples
+-------------------
+
+To cut an adapter from SOLiD data given in ``solid.csfasta`` and
+``solid.qual``, to produce MAQ- and BWA-compatible output, allow the
+default of 10% errors and write the resulting FASTQ file to
+output.fastq::
+
+    cutadapt --bwa -a CGCCTTGGCCGTACAGCAG solid.csfasta solid.qual > output.fastq
+
+Instead of redirecting standard output with ``>``, the ``-o`` option can
+be used. This also shows that you can give the adapter in colorspace and
+how to use a different error rate::
+
+    cutadapt --bwa -e 0.15 -a 330201030313112312 -o output.fastq solid.csfasta solid.qual
+
+This does the same as above, but produces BFAST-compatible output,
+strips the \_F3 suffix from read names and adds the prefix "abc:" to
+them::
+
+    cutadapt -c -e 0.15 -a 330201030313112312 -x abc: --strip-f3 solid.csfasta solid.qual > output.fastq
+
+
+Bowtie
+------
+
+Quality values of colorspace reads are sometimes negative. Bowtie gets
+confused and prints this message:
+
+    Encountered a space parsing the quality string for read xyz
+
+BWA also has a problem with such data. Cutadapt therefore converts
+negative quality values to zero in colorspace data. Use the option
+``--no-zero-cap`` to turn this off.
diff --git a/doc/conf.py b/doc/conf.py
new file mode 100644
index 0000000..981d1f3
--- /dev/null
+++ b/doc/conf.py
@@ -0,0 +1,270 @@
+# -*- coding: utf-8 -*-
+#
+# cutadapt documentation build configuration file, created by
+# sphinx-quickstart on Fri Sep 12 09:11:16 2014.
+#
+# This file is execfile()d with the current directory set to its
+# containing dir.
+#
+# Note that not all possible configuration values are present in this
+# autogenerated file.
+#
+# All configuration values have a default; values that are commented out
+# serve to show the default.
+
+import sys
+import os
+
+# If extensions (or modules to document with autodoc) are in another directory,
+# add these directories to sys.path here. If the directory is relative to the
+# documentation root, use os.path.abspath to make it absolute, like shown here.
+sys.path.insert(0, os.path.abspath(os.pardir))
+
+# -- General configuration ------------------------------------------------
+
+# If your documentation needs a minimal Sphinx version, state it here.
+#needs_sphinx = '1.0'
+
+# Add any Sphinx extension module names here, as strings. They can be
+# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
+# ones.
+extensions = [
+    'sphinx.ext.autodoc',
+]
+
+# Add any paths that contain templates here, relative to this directory.
+templates_path = ['_templates']
+
+# The suffix of source filenames.
+source_suffix = '.rst'
+
+# The encoding of source files.
+#source_encoding = 'utf-8-sig'
+
+# The master toctree document.
+master_doc = 'index'
+
+# General information about the project.
+project = u'cutadapt'
+copyright = u'2010-2014, Marcel Martin'
+
+# The version info for the project you're documenting, acts as replacement for
+# |version| and |release|, also used in various other places throughout the
+# built documents.
+
+from cutadapt import __version__
+
+#
+# The short X.Y version.
+version = __version__
+# The full version, including alpha/beta/rc tags.
+release = __version__
+
+# The language for content autogenerated by Sphinx. Refer to documentation
+# for a list of supported languages.
+#language = None
+
+# There are two options for replacing |today|: either, you set today to some
+# non-false value, then it is used:
+#today = ''
+# Else, today_fmt is used as the format for a strftime call.
+#today_fmt = '%B %d, %Y'
+
+# List of patterns, relative to source directory, that match files and
+# directories to ignore when looking for source files.
+exclude_patterns = ['_build']
+
+# The reST default role (used for this markup: `text`) to use for all
+# documents.
+#default_role = None
+
+# If true, '()' will be appended to :func: etc. cross-reference text.
+#add_function_parentheses = True
+
+# If true, the current module name will be prepended to all description
+# unit titles (such as .. function::).
+#add_module_names = True
+
+# If true, sectionauthor and moduleauthor directives will be shown in the
+# output. They are ignored by default.
+#show_authors = False
+
+# The name of the Pygments (syntax highlighting) style to use.
+pygments_style = 'sphinx'
+
+# A list of ignored prefixes for module index sorting.
+#modindex_common_prefix = []
+
+# If true, keep warnings as "system message" paragraphs in the built documents.
+#keep_warnings = False
+
+
+# -- Options for HTML output ----------------------------------------------
+
+# The theme to use for HTML and HTML Help pages.  See the documentation for
+# a list of builtin themes.
+html_theme = 'default'
+try:
+	from better import better_theme_path
+	html_theme_path = [better_theme_path]
+	html_theme = 'better'
+except ImportError:
+	pass
+
+
+# Theme options are theme-specific and customize the look and feel of a theme
+# further.  For a list of options available for each theme, see the
+# documentation.
+#html_theme_options = {}
+
+# Add any paths that contain custom themes here, relative to this directory.
+#html_theme_path = []
+
+# The name for this set of Sphinx documents.  If None, it defaults to
+# "<project> v<release> documentation".
+#html_title = None
+
+# A shorter title for the navigation bar.  Default is the same as html_title.
+#html_short_title = None
+
+# The name of an image file (relative to this directory) to place at the top
+# of the sidebar.
+#html_logo = 'logo.png'
+
+# The name of an image file (within the static path) to use as favicon of the
+# docs.  This file should be a Windows icon file (.ico) being 16x16 or 32x32
+# pixels large.
+#html_favicon = None
+
+# Add any paths that contain custom static files (such as style sheets) here,
+# relative to this directory. They are copied after the builtin static files,
+# so a file named "default.css" will overwrite the builtin "default.css".
+html_static_path = ['_static']
+
+# Add any extra paths that contain custom files (such as robots.txt or
+# .htaccess) here, relative to this directory. These files are copied
+# directly to the root of the documentation.
+#html_extra_path = []
+
+# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
+# using the given strftime format.
+#html_last_updated_fmt = '%b %d, %Y'
+
+# If true, SmartyPants will be used to convert quotes and dashes to
+# typographically correct entities.
+html_use_smartypants = True
+
+# Custom sidebar templates, maps document names to template names.
+#html_sidebars = {}
+
+# Additional templates that should be rendered to pages, maps page names to
+# template names.
+#html_additional_pages = {}
+
+# If false, no module index is generated.
+#html_domain_indices = True
+
+# If false, no index is generated.
+#html_use_index = True
+
+# If true, the index is split into individual pages for each letter.
+#html_split_index = False
+
+# If true, links to the reST sources are added to the pages.
+#html_show_sourcelink = True
+
+# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
+#html_show_sphinx = True
+
+# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
+#html_show_copyright = True
+
+# If true, an OpenSearch description file will be output, and all pages will
+# contain a <link> tag referring to it.  The value of this option must be the
+# base URL from which the finished HTML is served.
+#html_use_opensearch = ''
+
+# This is the file name suffix for HTML files (e.g. ".xhtml").
+#html_file_suffix = None
+
+# Output file base name for HTML help builder.
+htmlhelp_basename = 'cutadaptdoc'
+
+
+# -- Options for LaTeX output ---------------------------------------------
+
+latex_elements = {
+# The paper size ('letterpaper' or 'a4paper').
+'papersize': 'a4paper',
+
+# The font size ('10pt', '11pt' or '12pt').
+#'pointsize': '10pt',
+
+# Additional stuff for the LaTeX preamble.
+#'preamble': '',
+}
+
+# Grouping the document tree into LaTeX files. List of tuples
+# (source start file, target name, title,
+#  author, documentclass [howto, manual, or own class]).
+latex_documents = [
+  ('index', 'cutadapt.tex', u'cutadapt Documentation',
+   u'Marcel Martin', 'manual'),
+]
+
+# The name of an image file (relative to this directory) to place at the top of
+# the title page.
+#latex_logo = None
+
+# For "manual" documents, if this is true, then toplevel headings are parts,
+# not chapters.
+#latex_use_parts = False
+
+# If true, show page references after internal links.
+#latex_show_pagerefs = False
+
+# If true, show URL addresses after external links.
+#latex_show_urls = False
+
+# Documents to append as an appendix to all manuals.
+#latex_appendices = []
+
+# If false, no module index is generated.
+#latex_domain_indices = True
+
+
+# -- Options for manual page output ---------------------------------------
+
+# One entry per manual page. List of tuples
+# (source start file, name, description, authors, manual section).
+man_pages = [
+    ('index', 'cutadapt', u'cutadapt Documentation',
+     [u'Marcel Martin'], 1)
+]
+
+# If true, show URL addresses after external links.
+#man_show_urls = False
+
+
+# -- Options for Texinfo output -------------------------------------------
+
+# Grouping the document tree into Texinfo files. List of tuples
+# (source start file, target name, title, author,
+#  dir menu entry, description, category)
+texinfo_documents = [
+  ('index', 'cutadapt', u'cutadapt Documentation',
+   u'Marcel Martin', 'cutadapt', 'One line description of project.',
+   'Miscellaneous'),
+]
+
+# Documents to append as an appendix to all manuals.
+#texinfo_appendices = []
+
+# If false, no module index is generated.
+#texinfo_domain_indices = True
+
+# How to display URL addresses: 'footnote', 'no', or 'inline'.
+#texinfo_show_urls = 'footnote'
+
+# If true, do not generate a @detailmenu in the "Top" node's menu.
+#texinfo_no_detailmenu = False
diff --git a/doc/guide.rst b/doc/guide.rst
new file mode 100644
index 0000000..e6b665c
--- /dev/null
+++ b/doc/guide.rst
@@ -0,0 +1,1181 @@
+==========
+User guide
+==========
+
+Basic usage
+===========
+
+If you just want to trim a 3' adapter, the basic command-line for cutadapt is::
+
+    cutadapt -a AACCGGTT -o output.fastq input.fastq
+
+The sequence of the adapter is given with the ``-a`` option. Of course, you
+need to replace ``AACCGGTT`` with your actual adapter sequence. Reads are read
+from the input file ``input.fastq`` and written to the output file
+``output.fastq``.
+
+Cutadapt searches for the adapter in all reads and removes it when it finds it.
+All reads that were present in the input file will also be present in the output
+file, some of them trimmed, some of them not. Even reads that were trimmed
+entirely (because the adapter was found in the very beginning) are output. All
+of this can be changed with command-line options, explained further down.
+
+A report is printed after cutadapt has finished processing the reads.
+
+
+Input and output file formats
+-----------------------------
+
+Input files for cutadapt need to be in one the these formats:
+
+* FASTA (file name extensions: ``.fasta``, ``.fa``, ``.fna``, ``.csfasta``, ``.csfa``)
+* FASTQ (extensions: ``.fastq``, ``.fq``)
+* A pair of a FASTA file and a ``.(cs)qual`` file
+
+The latter format is (or was) used for colorspace data from the SOLiD
+instruments.
+
+The input file format is recognized from the file name extension (given in
+parentheses in the list above). You can also explicitly specify which format
+the input has by using the ``--format`` option.
+
+The output format is the same as the input format, except for the FASTA/QUAL
+pairs -- those will always be converted to FASTQ. Also, cutadapt does not check
+the output file name: If you input FASTQ data, but use ``-o output.fasta``, then
+the output file will actually be in FASTQ format.
+
+
+Compressed files
+----------------
+
+Cutadapt supports compressed input and output files. Whether an input file
+needs to be decompressed or an output file needs to be compressed is detected
+automatically by inspecting the file name: If it ends in ``.gz``, then gzip
+compression is assumed. You can therefore run cutadapt like this and it works
+as expected::
+
+    cutadapt -a AACCGGTT -o output.fastq.gz input.fastq.gz
+
+Note that the all of cutadapt's options that expect a file name support this.
+
+Files compressed with bzip2 (``.bz2``) or xz (``.xz``) are also supported, but
+only if the Python installation includes the proper modules. xz files require
+Python 3.3 or later.
+
+
+Standard input and output
+-------------------------
+
+If no output file is specified via the ``-o`` option, then the output is sent to
+the standard output stream. Instead of the example command line from above, you
+can therefore also write::
+
+    cutadapt -a AACCGGTT input.fastq > output.fastq
+
+There is one difference in behavior if you use cutadapt without ``-o``: The
+report is sent to the standard error stream instead of standard output. You
+can redirect it to a file like this::
+
+    cutadapt -a AACCGGTT input.fastq > output.fastq 2> report.txt
+
+Anywhere cutadapt expects a file name, you can also write a dash (``-``) in
+order to specify that standard input or output should be used. For example::
+
+    tail -n 4 input.fastq | cutadapt -a AACCGGTT - > output.fastq
+
+The ``tail -n 4`` prints out only the last four lines of ``input.fastq``, which
+are then piped into cutadapt. Thus, cutadapt will work only on the last read in
+the input file.
+
+In most cases, you should probably use ``-`` at most once for an input file and
+at most once for an output file, in order not to get mixed output.
+
+You cannot combine ``-`` and gzip compression since cutadapt needs to know the
+file name of the output or input file. if you want to have a gzip-compressed
+output file, use ``-o`` with an explicit name.
+
+One last "trick" is to use ``/dev/null`` as an output file name. This special
+file discards everything you send into it. If you only want to see the
+statistics output, for example, and do not care about the trimmed reads at all,
+you could use something like this::
+
+    cutadapt -a AACCGGTT -o /dev/null input.fastq
+
+
+Trimming reads
+==============
+
+Cutadapt supports trimming of multiple types of adapters:
+
+=================================================== ===========================
+Adapter type                                        Command-line option
+=================================================== ===========================
+:ref:`3' adapter <three-prime-adapters>`            ``-a ADAPTER``
+:ref:`5' adapter <five-prime-adapters>`             ``-g ADAPTER``
+:ref:`Anchored 3' adapter <anchored-3adapters>`     ``-a ADAPTER$``
+:ref:`Anchored 5' adapter <anchored-5adapters>`     ``-g ^ADAPTER``
+:ref:`5' or 3' (both possible) <anywhere-adapters>` ``-b ADAPTER``
+=================================================== ===========================
+
+Here is an illustration of the allowed adapter locations relative to the read
+and depending on the adapter type:
+
+|
+
+.. image:: _static/adapters.svg
+
+|
+
+By default, all adapters :ref:`are searched error-tolerantly <error-tolerance>`.
+Adapter sequences :ref:`may also contain the "N" wildcard
+character <wildcards>`.
+
+In addition, it is possible to :ref:`remove a fixed number of
+bases <cut-bases>` from the beginning or end of each read, and to :ref:`remove
+low-quality bases (quality trimming) <quality-trimming>` from the 3' and 5' ends.
+
+
+.. _three-prime-adapters:
+
+3' adapters
+-----------
+
+A 3' adapter is a piece of DNA ligated to the 3' end of the DNA fragment you
+are interested in. The sequencer starts the sequencing process at the 5' end of
+the fragment and sequences into the adapter if the read is long enough.
+The read that it outputs will then have a part of the adapter in the
+end. Or, if the adapter was short and the read length quite long, then the
+adapter will be somewhere within the read (followed by other bases).
+
+For example, assume your fragment of interest is *MYSEQUENCE* and the adapter is
+*ADAPTER*. Depending on the read length, you will get reads that look like this::
+
+    MYSEQUEN
+    MYSEQUENCEADAP
+    MYSEQUENCEADAPTER
+    MYSEQUENCEADAPTERSOMETHINGELSE
+
+Use cutadapt's ``-a ADAPTER`` option to remove this type of adapter. This will
+be the result::
+
+    MYSEQUEN
+    MYSEQUENCE
+    MYSEQUENCE
+    MYSEQUENCE
+
+As can be seen, cutadapt correctly deals with partial adapter matches, and also
+with any trailing sequences after the adapter. Cutadapt deals with 3' adapters
+by removing the adapter itself and any sequence that may follow. If the sequence
+starts with an adapter, like this::
+
+    ADAPTERSOMETHING
+
+Then the sequence will be empty after trimming. Note that, by default, empty
+reads are not discarded and will appear in the output.
+
+
+.. _five-prime-adapters:
+
+5' adapters
+-----------
+
+.. note::
+    Unless your adapter may also occur in a degraded form, you probably
+    want to use an anchored 5' adapter, described in the next section.
+
+A 5' adapter is a piece of DNA ligated to the 5' end of the DNA fragment of
+interest. The adapter sequence is expected to appear at the start of the read,
+but may be partially degraded. The sequence may also appear somewhere within
+the read. In all cases, the adapter itself and the sequence preceding it is
+removed.
+
+Again, assume your fragment of interest is *MYSEQUENCE* and the adapter is
+*ADAPTER*. The reads may look like this::
+
+    ADAPTERMYSEQUENCE
+    DAPTERMYSEQUENCE
+    TERMYSEQUENCE
+    SOMETHINGADAPTERMYSEQUENCE
+
+All the above sequences are trimmed to ``MYSEQUENCE`` when you use `-g ADAPTER`.
+As with 3' adapters, the resulting read may have a length of zero when the
+sequence ends with the adapter. For example, the read ::
+
+    SOMETHINGADAPTER
+
+will be empty after trimming.
+
+
+.. _anchored-5adapters:
+
+Anchored 5' adapters
+--------------------
+
+In many cases, the above behavior is not really what you want for trimming 5'
+adapters. You may know, for example, that degradation does not occur and that
+the adapter is also not expected to be within the read. Thus, you always expect
+the read to look like the first example from above::
+
+    ADAPTERSOMETHING
+
+If you want to trim only this type of adapter, use ``-g ^ADAPTER``. The ``^`` is
+supposed to indicate the the adapter is "anchored" at the beginning of the read.
+In other words: The adapter is expected to be a prefix of the read. Note that
+cases like these are also recognized::
+
+    ADAPTER
+    ADAPT
+    ADA
+
+The read will simply be empty after trimming.
+
+Be aware that cutadapt still searches for adapters error-tolerantly and, in
+particular, allows insertions. So if your maximum error rate is sufficiently
+high, even this read will be trimmed::
+
+    BADAPTERSOMETHING
+
+The ``B`` in the beginnig is seen as an insertion. If you also want to prevent
+this from happening, use the option ``--no-indels`` to disallow insertions and
+deletions entirely.
+
+
+.. _anchored-3adapters:
+
+Anchored 3' adapters
+--------------------
+
+It is also possible to anchor 3' adapters to the end of the read. This is
+rarely necessary, but if you have, for example, merged overlapping paired-end
+reads, then this may be useful. Add the ``$`` character to the end of an
+adapter sequence specified via ``-a`` in order to anchor the adapter to the
+end of the read, such as ``-a ADAPTER$``. The adapter will only be found if it
+as a *suffix* of the read, but errors are still allowed as for 5' adapters.
+You can disable insertions and deletions with ``--no-indels``.
+
+Anchored 3' adapters work as if you had reversed the sequence and used an
+appropriate anchored 5' adapter.
+
+As an example, assume you have these reads::
+
+    MYSEQUENCEADAP
+    MYSEQUENCEADAPTER
+    MYSEQUENCEADAPTERSOMETHINGELSE
+
+Using ``-a ADAPTER$`` will result in::
+
+    MYSEQUENCEADAP
+    MYSEQUENCE
+    MYSEQUENCEADAPTERSOMETHINGELSE
+
+That is, only the middle read is trimmed at all.
+
+
+.. _anywhere-adapters:
+
+5' or 3' adapters
+-----------------
+
+The last type of adapter is a combination of the 5' and 3' adapter. You can use
+it when your adapter is ligated to the 5' end for some reads and to the 3' end
+in other reads. This probably does not happen very often, and this adapter type
+was in fact originally implemented because the library preparation in an
+experiment did not work as it was supposed to.
+
+For this type of adapter, the sequence is specified with ``-b ADAPTER`` (or use
+the longer spelling ``--anywhere ADAPTER``). The adapter may appear in the
+beginning (even degraded), within the read, or at the end of the read (even
+partially). The decision which part of the read to remove is made as follows: If
+there is at least one base before the found adapter, then the adapter is
+considered to be a 3' adapter and the adapter itself and everything
+following it is removed. Otherwise, the adapter is considered to be a 5'
+adapter and it is removed from the read, but the sequence after it it remains.
+
+Here are some examples.
+
+============================== =================== =====================
+Read before trimming           Read after trimming Detected adapter type
+============================== =================== =====================
+``MYSEQUENCEADAPTERSOMETHING`` ``MYSEQUENCE``      3' adapter
+``MYSEQUENCEADAPTER``          ``MYSEQUENCE``      3' adapter
+``MYSEQUENCEADAP``             ``MYSEQUENCE``      3' adapter
+``MADAPTER``                   ``M``               3' adapter
+``ADAPTERMYSEQUENCE``          ``MYSEQUENCE``      5' adapter
+``PTERMYSEQUENCE``             ``MYSEQUENCE``      5' adapter
+``TERMYSEQUENCE``              ``MYSEQUENCE``      5' adapter
+============================== =================== =====================
+
+The ``-b`` option does not work with colorspace data.
+
+
+.. _error-tolerance:
+
+Error tolerance
+---------------
+
+All searches for adapter sequences are error tolerant. Allowed errors are
+mismatches, insertions and deletions. For example, if you search for the
+adapter sequence ``ADAPTER`` and the error tolerance is set appropriately
+(as explained below), then also ``ADABTER`` will be found (with 1 mismatch),
+as well as ``ADAPTR`` (with 1 deletion), and also ``ADAPPTER`` (with 1
+insertion).
+
+The level of error tolerance is adjusted by specifying a *maximum error rate*,
+which is 0.1 (=10%) by default. Use the ``-e`` option to set a different value.
+To determine the number of allowed errors, the maximum error rate is multiplied
+by the length of the match (and then rounded off).
+
+What does that mean?
+Assume you have a long adapter ``LONGADAPTER`` and it appears in full somewhere
+within the read. The length of the match is 11 characters since the full adapter
+has a length of 11, therefore 11·0.1=1.1 errors are allowed with the default
+maximum error rate of 0.1. This is rounded off to 1 allowed error. So the
+adapter will be found within this read::
+
+    SEQUENCELONGADUPTERSOMETHING
+
+If the match is a bit shorter, however, the result is different::
+
+    SEQUENCELONGADUPT
+
+Only 9 characters of the adapter match: ``LONGADAPT`` matches ``LONGADUPT``
+with one substitution. Therefore, only 9·0.1=0.9 errors are allowed. Since this
+is rounded off to zero allowed errors, the adapter will not be found.
+
+The number of errors allowed for a given adapter match length is also shown in
+the report that cutadapt prints::
+
+    Sequence: 'LONGADAPTER'; Length: 11; Trimmed: 2 times.
+
+    No. of allowed errors:
+    0-9 bp: 0; 10-11 bp: 1
+
+This tells us what we now already know: For match lengths of 0-9 bases, zero
+errors are allowed and for matches of length 10-11 bases, one error is allowed.
+
+The reason for this behavior is to ensure that short matches are not favored
+unfairly. For example, assume the adapter has 40 bases and the maximum error
+rate is 0.1, which means that four errors are allowed for full-length matches.
+If four errors were allowed even for a short match such as one with 10 bases, this would
+mean that the error rate for such a case is 40%, which is clearly not what was
+desired.
+
+Insertions and deletions can be disallowed by using the option
+``--no-indels``.
+
+See also the :ref:`section on details of the alignment algorithm <algorithm>`.
+
+
+Reducing random matches
+-----------------------
+
+Since cutadapt allows partial matches between the read and the adapter sequence,
+short matches can occur by chance, leading to erroneously trimmed bases. For
+example, roughly 25% of all reads end with a base that is identical to the
+first base of the adapter. To reduce the number of falsely trimmed bases,
+the alignment algorithm requires that at least *three bases* match between
+adapter and read. The minimum overlap length can be changed with the
+``--overlap``(short: ``-O``) parameter. Shorter matches are simply
+ignored, and the bases are not trimmed.
+
+Requiring at least three bases to match is quite conservative. Even if no
+minimum overlap was required, we can compute that we lose only about 0.44 bases
+per read on average, see `Section 2.3.3 in my
+thesis <http://hdl.handle.net/2003/31824>`_. With the default minimum
+overlap length of 3, only about 0.07 bases are lost per read.
+
+When choosing an appropriate minimum overlap length, take into account that
+true adapter matches are also lost when the overlap length is higher than
+1, reducing cutadapt's sensitivity.
+
+
+.. _wildcards:
+
+Wildcards
+---------
+
+All `IUPAC nucleotide codes <http://www.bioinformatics.org/sms/iupac.html>`_
+(wildcard characters) are supported. For example, use an ``N`` in the adapter
+sequence to match any nucleotide in the read, or use ``-a YACGT`` for an adapter
+that matches both ``CACGT`` and ``TACGT``. The wildcard character ``N`` is
+useful for trimming adapters with an embedded variable barcode::
+
+    cutadapt -a ACGTAANNNNTTAGC -o output.fastq input.fastq
+
+Wildcard characters in the adapter are enabled by default. Use the option ``-N``
+to disable this.
+
+Matching of wildcards in the reads is also possible, but disabled by default
+in order to avoid matches in reads that consist of many (often low-quality)
+``N`` bases. Use ``--match-read-wildcards`` to enable wildcards also in reads.
+
+If wildcards are disabled entirely (that is, you use ``-N`` and *do not* use
+``--match-read-wildcards``), then cutadapt compares characters by ASCII value.
+Thus, both the read and adapter can be arbitrary strings (such as ``SEQUENCE``
+or ``ADAPTER`` as used here in the examples).
+
+Wildcards do not work in colorspace.
+
+
+Repeated bases in the adapter sequence
+--------------------------------------
+
+If you have many repeated bases in the adapter sequence, such as many ``N``s or
+many ``A``s, you do not have to spell them out. For example, instead of writing
+ten ``A`` in a row (``AAAAAAAAAA``), write ``A{10}`` instead. The number within
+the curly braces specifies how often the character that preceeds it will be
+repeated. This works also for IUPAC wildcard characters, as in ``N{5}``.
+
+It is recommended that you use quotation marks around your adapter sequence if
+you use this feature. For poly-A trimming, for example, you would write::
+
+    cutadapt -a "A{100}" -o output.fastq input.fastq
+
+
+.. _cut-bases:
+
+Removing a fixed number of bases
+--------------------------------
+
+By using the ``--cut`` option or its abbreviation ``-u``, it is possible to
+unconditionally remove bases from the beginning or end of each read. If
+the given length is positive, the bases are removed from the beginning
+of each read. If it is negative, the bases are removed from the end.
+
+For example, to remove the first five bases of each read::
+
+    cutadapt -u 5 -o trimmed.fastq reads.fastq
+
+To remove the last seven bases of each read::
+
+    cutadapt -u -7 -o trimmed.fastq reads.fastq
+
+The ``-u``/``--cut`` option can be combined with the other options, but
+the desired bases are removed *before* any adapter trimming.
+
+
+.. _quality-trimming:
+
+Quality trimming
+----------------
+
+The ``-q`` (or ``--trim-qualities``) parameter can be used to trim
+low-quality ends from reads before adapter removal. For this to work
+correctly, the quality values must be encoded as ascii(phred quality +
+33). If they are encoded as ascii(phred quality + 64), you need to add
+``--quality-base=64`` to the command line.
+
+Quality trimming can be done without adapter trimming, so this will work::
+
+    cutadapt -q 10 -o output.fastq input.fastq
+
+By default, only the 3' end of each read is quality-trimmed. If you want to
+trim the 5' end as well, use the ``-q`` option with two comma-separated cutoffs::
+
+    cutadapt -q 15,10 -o output.fastq input.fastq
+
+The 5' end will then be trimmed with a cutoff of 15, and the 3' will be trimmed
+with a cutoff of 10. If you only want to trim the 5' end, then use a cutoff of
+0 for the 3' end, as in ``-q 10,0``.
+
+
+Quality trimming algorithm
+~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+The trimming algorithm is the same as the one used by BWA, but applied to both
+ends of the read in turn (if requested). That is: Subtract the given cutoff
+from all qualities; compute partial sums from all indices to the end of the
+sequence; cut the sequence at the index at which the sum is minimal. If both
+ends are to be trimmed, repeat this for the other end.
+
+The basic idea is to remove all bases starting from the end of the read whose
+quality is smaller than the given threshold. This is refined a bit by allowing
+some good-quality bases among the bad-quality ones. In the following example,
+we assume that the 3' end is to be quality-trimmed.
+
+Assume you use a threshold of 10 and have these quality values:
+
+42, 40, 26, 27, 8, 7, 11, 4, 2, 3
+
+Subtracting the threshold gives:
+
+32, 30, 16, 17, -2, -3, 1, -6, -8, -7
+
+Then sum up the numbers, starting from the end (partial sums). Stop early if
+the sum is greater than zero:
+
+(70), (38), 8, -8, -25, -23, -20, -21, -15, -7
+
+The numbers in parentheses are not computed (because 8 is greater than zero),
+but shown here for completeness. The position of the minimum (-25) is used as
+the trimming position. Therefore, the read is trimmed to the first four bases,
+which have quality values 42, 40, 26, 27.
+
+
+.. _paired-end:
+
+Trimming paired-end reads
+=========================
+
+Cutadapt supports trimming of paired-end reads. Starting with cutadapt 1.8,
+both reads in a pair can be trimmed at the same time. It is no longer necessary
+to run cutadapt twice.
+
+Assume the input is in ``reads.1.fastq`` and ``reads.2.fastq`` and that
+``ADAPTER_FWD`` should be trimmed from the forward reads (first file)
+and ``ADAPTER_REV`` from the reverse reads (second file).
+
+The basic command-line is (``-p`` is the short form of ``--paired-output``)::
+
+    cutadapt -a ADAPTER_FWD -A ADAPTER_REV -o out.1.fastq -p out.2.fastq reads.1.fastq reads.2.fastq
+
+The option ``-A`` is used here to specify an adapter sequence that cutadapt
+should remove from the second read in each pair. There are also the options
+``-G``, ``-B``. All of them work just like their lowercase counterparts,
+except that the adapter is searched for in the second read in each paired-end
+read. There is also option ``-U``, which you can use to remove a fixed number
+of bases from the second read in a pair.
+
+While it is possible to run cutadapt on the two files separately, processing
+both files at the same time is highly recommended since the program can check
+for problems in your input files only when they are processed together.
+
+When you use ``-p``/``--paired-output``, cutadapt checks whether the files are
+properly paired. An error is raised if one of the files contains more reads than
+the other or if the read names in the two files do not match. Only the part of
+the read name before the first space is considered. If the read name ends with
+``/1`` or ``/2``, then that is also ignored. For example, two FASTQ headers that
+would be considered to denote properly paired reads are::
+
+    @my_read/1 a comment
+
+and::
+
+    @my_read/2 another comment
+
+As soon as you start to use one of the filtering options that discard reads, it
+is mandatory you process both files at the same time to make sure that the
+output files are kept synchronized: If a read is removed from one of the files,
+cutadapt will ensure it is also removed from the other file.
+
+The following command-line options are applied to *both* reads:
+
+* ``-q``
+* ``--quality-base``
+* ``--times`` applies to all the adapters given
+* ``--no-trim``
+* ``--mask``
+* ``--length-tag``
+* ``--prefix``, ``--suffix``
+* ``--strip-f3``
+* ``--colorspace``, ``--bwa``, ``-z``, ``--no-zero-cap``, ``--double-encode``,
+  ``--trim-primer``
+
+In paired-end mode, the filtering options discard the read pair if *any*
+of the two reads fulfill the criteria. That is, ``--max-n`` discards the pair
+if one of the two reads has too many ``N`` bases; ``--discard-untrimmed``
+discards the pair if one of the reads does not contain an adapter;
+``--minimum-length`` discards the pair if one of the reads is too short;
+and ``--maximum-length`` discards the pair if one of the reads is too long.
+
+The following limitations still exist:
+
+* The ``--info-file``, ``--rest-file`` and ``--wildcard-file`` options write out
+  information only from the first read.
+* Demultiplexing is not yet supported with paired-end data.
+
+
+Legacy paired-end read trimming
+-------------------------------
+
+.. note::
+    This section describes the way paired-end trimming was done
+    in cutadapt before 1.8, where the ``-A``, ``-G``, ``-B`` options were not
+    available. It is less safe and more complicated, but you can still use it.
+
+If you do not use any of the filtering options that discard reads, such
+as ``--discard``, ``--minimum-length`` or ``--maximum-length``, you can run
+cutadapt on each file separately::
+
+    cutadapt -a ADAPTER_FWD -o trimmed.1.fastq reads1.fastq
+    cutadapt -a ADAPTER_REV -o trimmed.2.fastq reads2.fastq
+
+You can use the options that are listed under 'Additional modifications'
+in cutadapt's help output without problems. For example, if you want to
+quality-trim the first read in each pair with a threshold of 10, and the
+second read in each pair with a threshold of 15, then the commands could
+be::
+
+    cutadapt -q 10 -a ADAPTER_FWD -o trimmed.1.fastq reads1.fastq
+    cutadapt -q 15 -a ADAPTER_REV -o trimmed.2.fastq reads2.fastq
+
+If you use any of the filtering options, you must use cutadapt in the following
+way (with the ``-p`` option) to make sure that read pairs remain sychronized.
+
+First trim the forward read, writing output to temporary files (we also
+add some quality trimming)::
+
+    cutadapt -q 10 -a ADAPTER_FWD --minimum-length 20 -o tmp.1.fastq -p tmp.2.fastq reads.1.fastq reads.2.fastq
+
+Then trim the reverse read, using the temporary files as input::
+
+    cutadapt -q 15 -a ADAPTER_REV --minimum-length 20 -o trimmed.2.fastq -p trimmed.1.fastq tmp.2.fastq tmp.1.fastq
+
+Finally, remove the temporary files::
+
+    rm tmp.1.fastq tmp.2.fastq
+
+Please see the previous section for a much simpler way of trimming paired-end
+reads!
+
+In the legacy paired-end mode, the read-modifying options such as ``-q`` only
+apply to the first file in each call to cutadapt (first ``reads.1.fastq``, then
+``tmp.2.fastq`` in this example). Reads in the second file are not affected by those
+options, but by the filtering options: If a read in the first file is
+discarded, then the matching read in the second file is also filtered
+and not written to the output given by ``--paired-output`` in order to
+keep both output files synchronized.
+
+
+.. _multiple-adapters:
+
+Multiple adapters
+=================
+
+It is possible to specify more than one adapter sequence by using the options
+``-a``, ``-b`` and ``-g`` more than once. Any combination is allowed, such as
+five ``-a`` adapters and two ``-g`` adapters. Each read will be searched for
+all given adapters, but **only the best matching adapter is removed**. (But it
+is possible to :ref:`trim more than one adapter from each
+read <more-than-one>`). This is how a command may look like to trim one of two
+possible 3' adapters::
+
+    cutadapt -a TGAGACACGCA -a AGGCACACAGGG -o output.fastq input.fastq
+
+The adapter sequences can also be read from a FASTA file. Instead of giving an
+explicit adapter sequence, you need to write ``file:`` followed by the name of
+the FASTA file::
+
+    cutadapt -a file:adapters.fasta -o output.fastq input.fastq
+
+All of the sequences in the file ``adapters.fasta`` will be used as 3'
+adapters. The other adapter options ``-b`` and ``-g`` also support this. Again,
+only the best matching adapter is trimmed from each read.
+
+When cutadapt has multiple adapter sequences to work with, either specified
+explicitly on the command line or via a FASTA file, it decides in the
+following way which adapter should be trimmed:
+
+* All given adapter sequences are matched to the read.
+* Adapter matches where the overlap length (see the ``-O`` parameter) is too
+  small or where the error rate is too high (``-e``) are removed from further
+  consideration.
+* Among the remaining matches, the one with the **greatest number of matching
+  bases** is chosen.
+* If there is a tie, the first adapter wins. The order of adapters is the order
+  in which they are given on the command line or in which they are found in the
+  FASTA file.
+
+If your adapter sequences are all similar and differ only by a variable barcode
+sequence, you should use a single adapter sequence instead that
+:ref:`contains wildcard characters <wildcards>`.
+
+
+.. _named-adapters:
+
+Named adapters
+--------------
+
+Cutadapt reports statistics for each adapter separately. To identify the
+adapters, they are numbered and the adapter sequence is also printed::
+
+    === Adapter 1 ===
+
+    Sequence: AACCGGTT; Length 8; Trimmed: 5 times.
+
+If you want this to look a bit nicer, you can give each adapter a name in this
+way::
+
+    cutadapt -a My_Adapter=AACCGGTT -o output.fastq input.fastq
+
+The actual adapter sequence in this example is ``AACCGGTT`` and the name
+assigned to it is ``My_Adapter``. The report will then contain this name in
+addition to the other information::
+
+    === Adapter 'My_Adapter' ===
+
+    Sequence: TTAGACATATCTCCGTCG; Length 18; Trimmed: 5 times.
+
+When adapters are read from a FASTA file, the sequence header is used as the
+adapter name.
+
+Adapter names are also used in column 8 of :ref:`info files <info-file>`.
+
+
+.. _demultiplexing:
+
+Demultiplexing
+--------------
+
+Cutadapt supports demultiplexing: That is, reads can be written to different
+output files depending on which adapter was found in them. To use this, include
+the string ``{name}`` in the name of the output file and give each adapter a name.
+The path is then interpreted as a template and each trimmed read is written
+to the path in which ``{name}`` is replaced with the name of the adapter that
+was found in the read. Reads in which no adapter was found will be written to a
+file in which ``{name}`` is replaced with ``unknown``.
+
+.. note:
+    Demultiplexing is currently only supported for single-end reads. Paired-end
+    support is planned for the next version.
+
+Example::
+
+    cutadapt -a one=TATA -a two=GCGC -o trimmed-{name}.fastq.gz input.fastq.gz
+
+This command will create the three files ``demulti-one.fastq.gz``,
+``demulti-two.fastq.gz`` and ``demulti-unknown.fastq.gz``. You can :ref:`also
+provide adapter sequences in a FASTA file <multiple-adapters>`.
+
+In order to not trim the input files at all, but to only do multiplexing, use
+option ``--no-trim``. And if you want to output the reads in which no
+adapters were found to a different file, use the ``--untrimmed-output``
+parameter with a file name. Here is an example that uses both parameters and
+reads the adapters from a FASTA file (note that ``--untrimmed-output`` can be
+abbreviated)::
+
+    cutadapt -a file:barcodes.fasta --no-trim --untrimmed-o untrimmed.fastq.gz -o trimmed-{name}.fastq.gz input.fastq.gz
+
+
+.. _more-than-one:
+
+Trimming more than one adapter from each read
+---------------------------------------------
+
+By default, at most one adapter sequence is removed from each read, even if
+multiple adapter sequences were provided. This can be changed by using the
+``--times`` option (or its abbreviated form ``-n``). Cutadapt will then search
+for all the given adapter sequences repeatedly, either until no adapter match
+was found or until the specified number of rounds was reached.
+
+As an example, assume you have a protocol in which a 5' adapter gets ligated
+to your DNA fragment, but it's possible that the adapter is ligated more than
+once. So your sequence could look like this::
+
+    ADAPTERADAPTERADAPTERMYSEQUENCE
+
+To be on the safe side, you assume that there are at most 5 copies of the
+adapter sequence. This command can be used to trim the reads correctly::
+
+    cutadapt -g ^ADAPTER -n 5 -o output.fastq input.fastq
+
+This feature can also be used to search for *5'/3' linked adapters*. For example,
+when the 5' adapter is *FIRST* and the 3' adapter is *SECOND*, then the read
+could look like this::
+
+    FIRSTMYSEQUENCESECOND
+
+That is, the sequence of interest is framed by the 5' and the 3' adapter. The
+following command can be used to trim such a read::
+
+    cutadapt -g ^FIRST -a SECOND -n 2 ...
+
+Support for linked adapters is currently incomplete. For example, it is not
+possible to specify that SECOND should only be trimmed when FIRST also occurs.
+`See also this feature
+request <https://code.google.com/p/cutadapt/issues/detail?id=34>`_, and
+comment on it if you would like to see this implemented.
+
+
+.. _truseq:
+
+Illumina TruSeq
+===============
+
+If you have reads containing Illumina TruSeq adapters, follow these
+steps.
+
+Single-end reads as well as the first reads of paired-end data need to be
+trimmed with ``A`` + the “TruSeq Indexed Adapter”. Use only the prefix of the
+adapter sequence that is common to all Indexed Adapter sequences::
+
+    cutadapt -a AGATCGGAAGAGCACACGTCTGAACTCCAGTCAC -o trimmed.fastq.gz reads.fastq.gz
+
+If you have paired-end data, trim also read 2 with the reverse complement of the
+“TruSeq Universal Adapter”. The full command-line looks as follows::
+
+    cutadapt \
+		-a AGATCGGAAGAGCACACGTCTGAACTCCAGTCAC \
+		-A AGATCGGAAGAGCGTCGTGTAGGGAAAGAGTGTAGATCTCGGTGGTCGCCGTATCATT \
+		-o trimmed.1.fastq.gz -p trimmed.2.fastq.gz \
+		reads.1.fastq.gz reads.2.fastq.gz
+
+See also the :ref:`section about paired-end adapter trimming above <paired-end>`.
+
+If you want to simplify this a bit, you can also use the common prefix
+``AGATCGGAAGAGC`` as the adapter sequence in both cases::
+
+    cutadapt \
+		-a AGATCGGAAGAGC -A AGATCGGAAGAGC \
+		-o trimmed.1.fastq.gz -p trimmed.2.fastq.gz \
+		reads.1.fastq.gz reads.2.fastq.gz
+
+The adapter sequences can be found in the document `Illumina TruSeq Adapters
+De-Mystified <http://tucf-genomics.tufts.edu/documents/protocols/TUCF_Understanding_Illumina_TruSeq_Adapters.pdf>`__.
+
+
+.. _warnbase:
+
+Warning about incomplete adapter sequences
+------------------------------------------
+
+Sometimes cutadapt’s report ends with these lines::
+
+    WARNING:
+        One or more of your adapter sequences may be incomplete.
+        Please see the detailed output above.
+
+Further up, you’ll see a message like this::
+
+    Bases preceding removed adapters:
+      A: 95.5%
+      C: 1.0%
+      G: 1.6%
+      T: 1.6%
+      none/other: 0.3%
+    WARNING:
+        The adapter is preceded by "A" extremely often.
+        The provided adapter sequence may be incomplete.
+        To fix the problem, add "A" to the beginning of the adapter sequence.
+
+This means that in 95.5% of the cases in which an adapter was removed from a
+read, the base coming *before* that was an ``A``. If your DNA fragments are
+not random, such as in amplicon sequencing, then this is to be expected and
+the warning can be ignored. If the DNA fragments are supposed to be random,
+then the message may be genuine: The adapter sequence may be incomplete and
+should include an additional ``A`` in the beginning.
+
+This warning exists because some documents list the Illumina TruSeq adapters
+as starting with ``GATCGGA...``. While that is technically correct, the
+library preparation actually results in an additional ``A`` before that
+sequence, which also needs to be removed. See the :ref:`previous
+section <truseq>` for the correct sequence.
+
+
+.. _dealing-with-ns:
+
+Dealing with ``N`` bases
+========================
+
+Cutadapt supports the following options to deal with ``N`` bases in your reads:
+
+``--max-n COUNT``
+    Discard reads containing more than *COUNT* ``N`` bases. A fractional *COUNT*
+    between 0 and 1 can also be given and will be treated as the proportion of
+    maximally allowed ``N`` bases in the read.
+
+``--trim-n``
+    Remove flanking ``N`` bases from each read. That is, a read such as this::
+
+        NNACGTACGTNNNN
+
+    Is trimmed to just ``ACGTACGT``. This option is applied *after* adapter
+    trimming. If you want to get rid of ``N`` bases before adapter removal, use
+    quality trimming: ``N`` bases typically also have a low quality value
+    associated with them.
+
+
+.. _bisulfite:
+
+Bisulfite sequencing (RRBS)
+===========================
+
+When trimming reads that come from a library prepared with the RRBS (reduced
+representation bisulfit sequencing) protocol, the last two 3' bases must be
+removed in addition to the adapter itself. This can be achieved by using not
+the adapter sequence itself, but by adding two wildcard characters to its
+beginning. If the adapter sequence is ``ADAPTER``, the command for trimming
+should be::
+
+    cutadapt -a NNADAPTER -o output.fastq input.fastq
+
+Details can be found in `Babraham bioinformatics' "Brief guide to
+RRBS" <http://www.bioinformatics.babraham.ac.uk/projects/bismark/RRBS_Guide.pdf>`_.
+A summary follows.
+
+During RRBS library preparation, DNA is digested with the restriction enzyme
+MspI, generating a two-base overhang on the 5' end (``CG``). MspI recognizes
+the sequence ``CCGG`` and cuts
+between ``C`` and ``CGG``. A double-stranded DNA fragment is cut in this way::
+
+    5'-NNNC|CGGNNN-3'
+    3'-NNNGGC|CNNN-5'
+
+The fragment between two MspI restriction sites looks like this::
+
+    5'-CGGNNN...NNNC-3'
+      3'-CNNN...NNNGGC-5'
+
+Before sequencing (or PCR) adapters can be ligated, the missing base positions
+must be filled in with GTP and CTP::
+
+    5'-ADAPTER-CGGNNN...NNNCcg-ADAPTER-3'
+    3'-ADAPTER-gcCNNN...NNNGGC-ADAPTER-5'
+
+The filled-in bases, marked in lowercase above, do not contain any original
+methylation information, and must therefore not be used for methylation calling.
+By prefixing the adapter sequence with ``NN``, the bases will be automatically
+stripped during adapter trimming.
+
+
+Cutadapt's output
+=================
+
+
+Where trimmed and untrimmed reads go
+------------------------------------
+
+By default, all processed reads, no matter whether they were trimmed are not,
+are written to the output file specified by the ``-o`` option (or to standard
+output if ``-o`` was not provided). For paired-end reads, the second read in a
+pair is always written to the file specified by the ``-p`` option.
+
+The options described in the following make it possible to redirect the reads
+to other files depending on their length and depending on whether they were
+trimmed or not. However, the basic rule here is that *each read is written to
+at most one file*. You cannot write reads to more than one output file.
+
+In the following, the term "processed read" refers to a read which has been
+quality trimmed (if ``-q`` has been used) and in which all found adapters have
+been removed. A processed read may be identical with the input read if no
+bases were quality-trimmed and no adapters were found.
+
+``--minimum-length N`` or ``-m N``
+    Use this to throw away processed reads shorter than *N* bases.
+
+``--too-short-output FILE``
+    Instead of throwing away the reads that are too short (according to ``-m``),
+    write them to *FILE* (in FASTA/FASTQ format).
+
+``--maximum-length N`` or ``-M N``
+    Use this to throw away processed reads longer than *N* bases.
+
+``--too-long-output FILE``
+    Instead of throwing away the reads that are too long (according to ``-M``),
+    write them to *FILE* (in FASTA/FASTQ format).
+
+``--untrimmed-output FILE``
+    Write all reads without adapters to *FILE* (in FASTA/FASTQ format) instead
+    of writing them to the regular output file.
+
+``--discard-trimmed``
+   Throw away reads in which an adapter was found.
+
+``--discard-untrimmed``
+   Throw away read in which no adapter was found. This has the same effect as
+   specifying ``--untrimmed-output /dev/null``.
+
+The options ``--too-short-output`` and ``--too-long-output`` are applied first.
+This means, for example, that a read that is too long will never end up in the
+``--untrimmed-output`` file when ``--too-long-output`` was given, no matter
+whether it was trimmed or not.
+
+The following options apply only when trimming paired-end data.
+
+``--paired-output FILE`` or ``-p FILE``
+    The second read in a pair is written to *FILE* (in FASTA/FASTQ format), but
+    only if also the first read was written to the first file.
+
+``--untrimmed-paired-output FILE``
+    When the first read in a pair was not trimmed, write the second read to
+    *FILE* instead of writing it to the regular output file. Use this together
+    with ``--untrimmed-output`` when trimming paired-end data.
+
+Note that the option names can be abbreviated as long as it is clear which
+option is meant (unique prefix). For example, instead of ``--untrimmed-output``
+and ``--untrimmed-paired-output``, you can write ``--untrimmed-o`` and
+``--untrimmed-p``.
+
+
+How to read the report
+----------------------
+
+After every run, cutadapt prints out per-adapter statistics. The output
+starts with something like this::
+
+    Sequence: 'ACGTACGTACGTTAGCTAGC'; Length: 20; Trimmed: 2402 times.
+
+The meaning of this should be obvious.
+
+The next piece of information is this::
+
+    No. of allowed errors:
+    0-9 bp: 0; 10-19 bp: 1; 20 bp: 2
+
+The adapter has, as was shown above, has a length of 20
+characters. We are using the default error rate of 0.1. What this
+implies is shown above: Matches up to a length of 9 bp are allowed to
+have no errors. Matches of lengths 10-19 bp are allowd to have 1 error
+and matches of length 20 can have 2 errors. See also :ref:`the section about
+error-tolerant matching <error-tolerance>`.
+
+Finally, a table is output that gives more detailed information about
+the lengths of the removed sequences. The following is only an excerpt;
+some rows are left out::
+
+    Overview of removed sequences
+    length  count   expect  max.err error counts
+    3       140     156.2   0       140
+    4       57      39.1    0       57
+    5       50      9.8     0       50
+    6       35      2.4     0       35
+    ...
+    100     397     0.0     3       358 36 3
+
+The first row tells us the following: Three bases were removed in 140
+reads; randomly, one would expect this to occur 156.2 times; the maximum
+number of errors at that match length is 0 (this is actually redundant
+since we know already that no errors are allowed at lengths 0-9 bp).
+
+The last column shows the number of reads that had 0, 1, 2 ... errors.
+In the last row, for example, 358 reads matched the adapter with zero
+errors, 36 with 1 error, and 3 matched with 2 errors.
+
+The "expect" column gives only a rough estimate of the number of
+sequences that is expected to match randomly (it assumes a GC content of
+50%, for example), but it can help to estimate whether the matches that
+were found are true adapter matches or if they are due to chance. At
+lengths 6, for example, only 2.4 reads are expected, but 35 do match,
+which hints that most of these matches are due to actual adapters.
+
+Note that the "length" column refers to the length of the removed
+sequence. That is, the actual length of the match in the above row at
+length 100 is 20 since that is the adapter length. Assuming the read
+length is 100, the adapter was found in the beginning of 397 reads and
+therefore those reads were trimmed to a length of zero.
+
+The table may also be useful in case the given adapter sequence contains
+an error. In that case, it may look like this::
+
+    ...
+    length  count   expect  max.err error counts
+    10      53      0.0     1       51 2
+    11      45      0.0     1       42 3
+    12      51      0.0     1       48 3
+    13      39      0.0     1       0 39
+    14      40      0.0     1       0 40
+    15      36      0.0     1       0 36
+    ...
+
+We can see that no matches longer than 12 have zero errors. In this
+case, it indicates that the 13th base of the given adapter sequence is
+incorrect.
+
+
+.. _info-file:
+
+Format of the info file
+-----------------------
+
+When the ``--info-file`` command-line parameter is given, detailed
+information about the found adapters is written to the given file. The
+output is a tab-separated text file. Each line corresponds to one read
+of the input file (unless `--times` is used, see below). The fields are:
+
+1. Read name
+2. Number of errors
+3. 0-based start coordinate of the adapter match
+4. 0-based end coordinate of the adapter match
+5. Sequence of the read to the left of the adapter match (can be empty)
+6. Sequence of the read that was matched to the adapter
+7. Sequence of the read to the right of the adapter match (can be empty)
+8. Name of the found adapter.
+
+The concatenation of the fields 5-7 yields the full read sequence. Column 8
+identifies the found adapter. `The section about named
+adapters <named-adapters>` describes how to give a name to an adapter. Adapters
+without a name are numbered starting from 1.
+
+If no adapter was found, the format is as follows:
+
+1.  Read name
+2.  The value -1
+3.  The read sequence
+
+When parsing that file, be aware that additional columns may be added in
+the future. Note also that some fields can be empty, resulting in
+consecutive tabs within a line.
+
+If the ``--times`` option is used and greater than 1, each read can appear
+more than once in the info file. There will be one line for each found adapter,
+all with identical read names. Only for the first of those lines will the
+concatenation of columns 5-7 be identical to the original read sequence. For
+subsequent lines, the shown sequence are the ones that were used in subsequent
+rounds of adapter trimming, that is, they get successively shorter.
+
+
+.. _algorithm:
+
+The alignment algorithm
+=======================
+
+Since the publication of the `EMBnet journal application note about
+cutadapt <http://dx.doi.org/10.14806/ej.17.1.200>`_, the alignment algorithm
+used for finding adapters has changed significantly. An overview of this new
+algorithm is given in this section. An even more detailed description is
+available in Chapter 2 of my PhD thesis `Algorithms and tools for the analysis
+of high-throughput DNA sequencing data <http://hdl.handle.net/2003/31824>`_.
+
+The algorithm is based on *semiglobal alignment*, also called *free-shift*,
+*ends-free* or *overlap* alignment. In a regular (global) alignment, the
+two sequences are compared from end to end and all differences occuring over
+that length are counted. In semiglobal alignment, the sequences are allowed to
+freely shift relative to each other and differences are only penalized in the
+overlapping region between them::
+
+      FANTASTIC
+   ELEFANT
+
+The prefix ``ELE`` and the suffix ``ASTIC`` do not have a counterpart in the
+respective other row, but this is not counted as an error. The overlap ``FANT``
+has a length of four characters.
+
+Traditionally, *alignment scores* are used to find an optimal overlap aligment:
+This means that the scoring function assigns a positive value to matches,
+while mismatches, insertions and deletions get negative values. The optimal
+alignment is then the one that has the maximal total score. Usage of scores
+has the disadvantage that they are not at all intuitive: What does a total score
+of *x* mean? Is that good or bad? How should a threshold be chosen in order to
+avoid finding alignments with too many errors?
+
+For cutadapt, the adapter alignment algorithm uses *unit costs* instead.
+Mismatches, insertions and deletions are therefore counted as one error, which
+is easier to understand and always to specify a single parameter for the
+algorithm (the maximum error rate) in order to describe how many errors are
+acceptable.
+
+There is a problem with this: When using costs instead of scores, we would like
+to minimize the total costs in order to find an optimal alignment. But then the
+best alignment would always be the one in which the two sequences do not overlap
+at all! This would be correct, but meaningless for the purpose of finding an
+adapter sequence.
+
+The optimization criteria are therefore a bit different. The basic idea is to
+consider the alignment optimal that maximizes the overlap between the two
+sequences, as long as the allowed error rate is not exceeded.
+
+Conceptually, the procedure is as follows:
+
+1. Consider all possible overlaps between the two sequences and compute an
+   alignment for each, minimizing the total number of errors in each one.
+2. Keep only those alignments that do not exceed the specified maximum error
+   rate.
+3. Then, keep only those alignments that have a maximal number of matches
+   (that is, there is no alignment with more matches).
+4. If there are multiple alignments with the same number of matches, then keep
+   only those that have the smallest error rate.
+5. If there are still multiple candidates left, choose the alignment that starts
+   at the leftmost position within the read.
+
+In Step 1, the different adapter types are taken into account: Only those
+overlaps that are actually allowed by the adapter type are actually considered.
diff --git a/doc/ideas.rst b/doc/ideas.rst
new file mode 100644
index 0000000..a474205
--- /dev/null
+++ b/doc/ideas.rst
@@ -0,0 +1,70 @@
+Ideas/To Do
+===========
+
+This is a rather unsorted list of features that would be nice to have, of
+things that could be improved in the source code, and of possible algorithmic
+improvements.
+
+- show average error rate
+- In colorspace and probably also for Illumina data, gapped alignment
+  is not necessary
+- ``--progress``
+- run pylint, pychecker
+- length histogram
+- check whether input is FASTQ although -f fasta is given
+- search for adapters in the order in which they are given on the
+  command line
+- more tests for the alignment algorithm
+- deprecate ``--rest-file``
+- ``--detect`` prints out best guess which of the given adapters is the correct one
+- alignment algorithm: make a 'banded' version
+- it seems the str.find optimization isn't very helpful. In any case, it should be
+  moved into the Aligner class.
+- allow to remove not the adapter itself, but the sequence before or after it
+- convert adapter to lowercase
+- warn when given adapter sequence contains non-IUPAC characters
+- try multithreading again, this time use os.pipe()
+
+
+Specifying adapters
+-------------------
+
+The idea is to deprecate the ``-b`` and ``-g`` parameters. Only ``-a`` is used
+with a special syntax for each adapter type. This makes it a bit easier to add
+new adapter types in the feature.
+
+.. csv-table::
+
+    back,``-a ADAPTER``,``-a ADAPTER`` or ``-a ...ADAPTER``
+    suffix,``-a ADAPTER$``,``-a ...ADAPTER$``
+    front,``-g ADAPTER``,``-a ADAPTER...``
+    prefix,``-g ^ADAPTER``,``-a ^ADAPTER...``
+    anywhere,``-b ADAPTER``, ``-a ...ADAPTER...`` ???
+    paired,(not implemented),``-a ADAPTER...ADAPTER`` or ``-a ^ADAPTER...ADAPTER``
+
+Or add only ``-a ADAPTER...`` as an alias for ``-g ^ADAPTER`` and
+``-a ...ADAPTER`` as an alias for ``-a ADAPTER``.
+
+The ``...`` would be equivalent to ``N*`` as in regular expressions.
+
+Another idea: Allow something such as ``-a ADAP$TER`` or ``-a ADAPTER$NNN``.
+This would be a way to specify less strict anchoring.
+
+Make it possible to specify that the rightmost or leftmost match should be
+picked. Default right now: Leftmost, even for -g adapters.
+
+Allow ``N{3,10}`` as in regular expressions (for a variable-length sequence).
+
+
+Paired-end trimming
+-------------------
+
+* Could also use a paired-end read merger, then remove adapters with -a and -g
+* Should minimum overlap be sum of the two overlaps in each read?
+
+
+Single-letter command-line options
+----------------------------------
+
+Remaining characters: All uppercase letters except A, B, G, M, N, O
+Lowercase letters: i, j, k, l, s, w
diff --git a/doc/index.rst b/doc/index.rst
new file mode 100644
index 0000000..f42e58f
--- /dev/null
+++ b/doc/index.rst
@@ -0,0 +1,25 @@
+.. include:: ../README.rst
+
+=================
+Table of contents
+=================
+
+.. toctree::
+   :maxdepth: 2
+
+   installation
+   guide
+   colorspace
+   recipes
+   ideas
+   changes
+
+
+..
+   Indices and tables
+   ==================
+   
+   * :ref:`genindex`
+   * :ref:`modindex`
+   * :ref:`search`
+
diff --git a/doc/installation.rst b/doc/installation.rst
new file mode 100644
index 0000000..fa349de
--- /dev/null
+++ b/doc/installation.rst
@@ -0,0 +1,87 @@
+============
+Installation
+============
+
+Quickstart
+----------
+
+The easiest way to install cutadapt is to use ``pip`` on the command line::
+
+    pip install --user --upgrade cutadapt
+
+This will download the software from `PyPI (the Python packaging
+index) <https://pypi.python.org/pypi/cutadapt/>`_, and
+install the cutadapt binary into ``$HOME/.local/bin``. If an old version of
+cutadapt exists on your system, the ``--upgrade`` parameter is required in order
+to install a newer version. You can then run the program like this::
+
+    ~/.local/bin/cutadapt --help
+
+If you want to avoid typing the full path, add the directory
+``$HOME/.local/bin`` to your ``$PATH`` environment variable.
+
+If the above does not work, keep reading.
+
+
+Dependencies
+------------
+
+Cutadapt requires this software to be installed:
+
+* One of Python 2.6, 2.7, 3.3 or 3.4. Python 2.7 is a bit faster than the other
+  versions.
+* A C compiler.
+
+Under Ubuntu, you may need to install the packages ``build-essential`` and
+``python-dev``.
+
+
+Installation
+------------
+
+If you have already downloaded and unpacked the ``.tar.gz`` file, then
+installation is done like this (replace "python" with "python3" to
+install the Python 3 version)::
+
+    python setup.py install --user
+
+If you get an error message::
+
+    error: command 'gcc' failed with exit status 1
+
+Then check the entire error message. If it says something about a missing ``Python.h``
+file, then you need to install the Python development packages. The
+appropriate package is called ``python-dev`` in Ubuntu (or ``python3-dev``
+for Python 3).
+
+
+System-wide installation
+------------------------
+
+If you have root access, then you can install cutadapt system-wide by running::
+
+    sudo pip install cutadapt
+
+This installs cutadapt into `/usr/local/bin`.
+
+If you want to upgrade from an older version, use this command instead::
+
+    sudo pip install --upgrade cutadapt
+
+
+Use without installation
+------------------------
+
+Build the C extension module (you can try to skip this step -- a
+compiled version of the module for Linux x86\_64 is already included)::
+
+    python setup.py build_ext -i
+
+Then simply run the script from where it is, similar to this::
+
+    bin/cutadapt --help
+
+If you get any errors, first try to explicitly request a specific Python
+version by running cutadapt like this::
+
+    python2.7 bin/cutadapt --help
diff --git a/doc/recipes.rst b/doc/recipes.rst
new file mode 100644
index 0000000..3020be4
--- /dev/null
+++ b/doc/recipes.rst
@@ -0,0 +1,83 @@
+=======
+Recipes
+=======
+
+For some trimming applications, the pre-defined adapter types behave differently
+from what you would like to have. In this section, we show some ways in which
+cutadapt can be made to behave in the desired way.
+
+.. note:: This section is still being written.
+
+
+Forcing matches to be at the end of the read
+--------------------------------------------
+
+Use ``-a TACGGCATXXX``. The ``X`` is always counted as a mismatch and will force
+the adapter match to be at the end. This is not the same as an anchored 3'
+adapter since partial matches are still allowed.
+
+
+Removing more than one adapter
+------------------------------
+
+If you want to remove more than one adapter, let's say a 5' adapter and a 3'
+adapter, you have two options.
+
+First, you can specify both adapters and also ``--times=2`` (or the short
+version ``-n 2``). For example::
+
+	cutadapt -g ^TTAAGGCC -a TACGGACT -n 2 -o output.fastq input.fastq
+
+This instructs cutadapt to run two rounds of adapter finding and removal. That
+means that, after the first round and only when an adapter was actually found,
+another round is performed. In both rounds, all given adapters (two in this
+case) are searched and removed. The problem is that it could happen that one
+adapter is found twice (so the 3' adapter, for example, could be removed twice).
+
+The second option is to not use the ``-n`` option, but to run cutadapt twice,
+first removing one adapter and then the other. It is easiest if you use a pipe
+as in this example::
+
+	cutadapt -g ^TTAAGGCC input.fastq | cutadapt -a TACGGACT - > output.fastq
+
+
+Trimming poly-A tails
+---------------------
+
+If you want to trim a poly-A tail from the 3' end of your reads, use the 3'
+adapter type (``-a``) with an adapter sequence of many repeated ``A``
+nucleotides. Starting with version 1.8 of cutadapt, you can use the
+following notation to specify a sequence that consists of 100 ``A``::
+
+	cutadapt -a "A{100}" -o output.fastq input.fastq
+
+This also works when there are sequencing errors in the poly-A tail. So this
+read ::
+
+	TACGTACGTACGTACGAAATAAAAAAAAAAA
+
+will be trimmed to::
+
+	TACGTACGTACGTACG
+
+If for some reason you would like to use a shorter sequence of ``A``, you can
+do so: The matching algorithm always picks the leftmost match that it can find,
+so cutadapt will do the right thing even when the tail has more ``A`` than you
+used in the adapter sequence. However, sequencing errors may result in shorter
+matches than desired. For example, using ``-a "A{10}"``, the read above (where
+the ``AAAT`` is followed by eleven ``A``) would be trimmed to::
+
+	TACGTACGTACGTACGAAAT
+
+Depending on your application, perhaps a variant of ``-a A{10}N{90}`` is an
+alternative, forcing the match to be located as much to the left as possible,
+while still allowing for non-``A`` bases towards the end of the read.
+
+
+Other things (unfinished)
+-------------------------
+
+* How to detect adapters
+* Use cutadapt for quality-trimming only
+* Use it for minimum/maximum length filtering
+* Use it for conversion to FASTQ
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..b8ce553
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,123 @@
+"""
+Build cutadapt.
+
+Cython is run when
+* no pre-generated C sources are found,
+* or the pre-generated C sources are out of date,
+* or when --cython is given on the command line.
+"""
+import sys
+import os.path
+from distutils.core import setup, Extension
+from distutils.version import LooseVersion
+
+from cutadapt import __version__
+
+MIN_CYTHON_VERSION = '0.17'
+
+if sys.version_info < (2, 6):
+	sys.stdout.write("At least Python 2.6 is required.\n")
+	sys.exit(1)
+
+
+def out_of_date(extensions):
+	"""
+	Check whether any pyx source is newer than the corresponding generated
+	C source or whether any C source is missing.
+	"""
+	for extension in extensions:
+		for pyx in extension.sources:
+			path, ext = os.path.splitext(pyx)
+			if ext not in ('.pyx', '.py'):
+				continue
+			if extension.language == 'c++':
+				csource = path + '.cpp'
+			else:
+				csource = path + '.c'
+			# When comparing modification times, allow five seconds slack:
+			# If the installation is being run from pip, modification
+			# times are not preserved and therefore depends on the order in
+			# which files were unpacked.
+			if not os.path.exists(csource) or (
+				os.path.getmtime(pyx) > os.path.getmtime(csource) + 5):
+				return True
+	return False
+
+
+def no_cythonize(extensions, **_ignore):
+	"""
+	Change file extensions from .pyx to .c or .cpp.
+
+	Copied from Cython documentation
+	"""
+	for extension in extensions:
+		sources = []
+		for sfile in extension.sources:
+			path, ext = os.path.splitext(sfile)
+			if ext in ('.pyx', '.py'):
+				if extension.language == 'c++':
+					ext = '.cpp'
+				else:
+					ext = '.c'
+				sfile = path + ext
+			sources.append(sfile)
+		extension.sources[:] = sources
+	return extensions
+
+
+def cythonize_if_necessary(extensions):
+	if '--cython' in sys.argv:
+		sys.argv.remove('--cython')
+	elif out_of_date(extensions):
+		sys.stdout.write('At least one C source file is missing or out of date.\n')
+	else:
+		return no_cythonize(extensions)
+
+	try:
+		from Cython import __version__ as cyversion
+	except ImportError:
+		sys.stdout.write(
+			"ERROR: Cython is not installed. Install at least Cython version " +
+			str(MIN_CYTHON_VERSION) + " to continue.\n")
+		sys.exit(1)
+	if LooseVersion(cyversion) < LooseVersion(MIN_CYTHON_VERSION):
+		sys.stdout.write(
+			"ERROR: Your Cython is at version '" + str(cyversion) +
+			"', but at least version " + str(MIN_CYTHON_VERSION) + " is required.\n")
+		sys.exit(1)
+
+	from Cython.Build import cythonize
+	return cythonize(extensions)
+
+
+extensions = [
+	Extension('cutadapt._align', sources=['cutadapt/_align.pyx']),
+	Extension('cutadapt._qualtrim', sources=['cutadapt/_qualtrim.pyx']),
+	Extension('cutadapt._seqio', sources=['cutadapt/_seqio.pyx']),
+]
+extensions = cythonize_if_necessary(extensions)
+
+setup(
+	name = 'cutadapt',
+	version = __version__,
+	author = 'Marcel Martin',
+	author_email = 'marcel.martin at scilifelab.se',
+	url = 'https://cutadapt.readthedocs.org/',
+	description = 'trim adapters from high-throughput sequencing reads',
+	license = 'MIT',
+	ext_modules = extensions,
+	packages = ['cutadapt', 'cutadapt.scripts'],
+	scripts = ['bin/cutadapt'],
+	classifiers = [
+		"Development Status :: 5 - Production/Stable",
+		"Environment :: Console",
+		"Intended Audience :: Science/Research",
+		"License :: OSI Approved :: MIT License",
+		"Natural Language :: English",
+		"Programming Language :: Cython",
+		"Programming Language :: Python :: 2.6",
+		"Programming Language :: Python :: 2.7",
+		"Programming Language :: Python :: 3",
+		"Topic :: Scientific/Engineering :: Bio-Informatics"
+	]
+)
diff --git a/tests/cut/454.fa b/tests/cut/454.fa
new file mode 100644
index 0000000..7d4f345
--- /dev/null
+++ b/tests/cut/454.fa
@@ -0,0 +1,118 @@
+>000163_1255_2627 length=8 uaccno=E0R4ISW01DCIQD
+GTGTGGTG
+>000652_1085_0667 length=80 uaccno=E0R4ISW01CXJXP
+ATTGAAGAGGTTGGTAAGTTTTAAGTTGGTAGGTGGTTGGGGAGTGGTTGGAGAGGAGTTGTTGGGAGTTTGTGTCCTGC
+>000653_1285_1649 length=92 uaccno=E0R4ISW01DE4SJ
+AATTAGTCGAGCGTTGTGGTGGGTATTTGTAATTTTAGCTACTCTGAAGGCTGAGGCAGGAGAACTGCTTGAACCCGGGAGGCGGAGGTTGC
+>000902_0715_2005 length=50 uaccno=E0R4ISW01B03K3
+GGGTGTTGAATTTAATATGTAGTATATTGATTTGTGATGATTATTTTGCC
+>001146_1255_0340 length=50 uaccno=E0R4ISW01DCGYU
+GGGTGTTGAATTTAATATGTAGTATATTGATTTGTGATGATTATTTTGCC
+>001210_1147_1026 length=124 uaccno=E0R4ISW01C2Z5W
+GAGGTGGTGAGTGTTGTGTGTTTAGATTGTGTGTGGTGGTTGGGAGTGGGAGTTGTATTTTAGGGTGTGGGTTGGGAGAGTGAAAGTTGTGGGTGTTTTGGATGGTGGGTTAGGTGGTTGTGCC
+>001278_1608_2022 length=66 uaccno=E0R4ISW01D7HW4
+CACACACACTCTTCCCCATACCTACTCACACACACACACACACACACAAACATACACAAATAATTC
+>001333_1518_1176 length=100 uaccno=E0R4ISW01DZKTM
+AATTGTCGTTTGATTGTTGGAAAGTAGAGGGTCGGGTTGGGGTAGATTCGAAAGGGGAATTTTGAGAAAAGAAATGGAGGGAGGTAGGAAAATTTTTTGC
+>001398_1584_1549 length=112 uaccno=E0R4ISW01D5DPB
+TAATGAAATGGAATGGAATGGAATGGAATGAAATGGAATGGAATGGAATGGAATGGAATGGAATGGAATGGAATGGAATGAAATGGAATGGAGTATAAAGGAATGGAATTAC
+>001455_1136_2179 length=50 uaccno=E0R4ISW01C12AD
+GGGTGTTGAATTTAATATGTAGTATATTGATTTGTGATGATTATTTTGCC
+>001481_1165_0549 length=50 uaccno=E0R4ISW01C4KON
+GGGTGTTGAATTTAATATGTAGTATATTGATTTGTGATGATTATTTTGCC
+>001744_1376_3512 length=101 uaccno=E0R4ISW01DM5T2
+TAAGTAGGGAAGGTTTGAGGTTGTTGGTGTTGGTAGTAGGGGTGTTTTAGTTAGGGGTTGTAGTTTGTTAAGGGAATTTTATTTGAGTTTAGAATTGAGGC
+>001893_1084_1137 length=120 uaccno=E0R4ISW01CXG4Z
+TGTATATTTTGTTGGGTTTGTATATATTGTTAGGTGTGGTTGGTGAGTTGTATTGGTGGTGGTGTAAGGTGAGTGGAAATGGGAATGGATTGTAGATATGTTGGATTTGTGGTTTTTGGT
+>001927_0254_0706 length=139 uaccno=E0R4ISW01AWLLG
+TGGAATCATCTAAGGGACACAAATAGAATCATCATTGAATGGAATCGAATGGAATCATCTAATGTACTCGAATGGAATTATTATTGAATAGAATAGAATGGAATTATCGAATGGAATCAAATGGAATGTAATGGAATGC
+>002007_1338_1037 length=95 uaccno=E0R4ISW01DJRTR
+GGGTTGTGTATTTGGATAGTATGTGGAAAATGGTATTAAAAAGAATTTGTAGTTGGATTGTTGGTGGTTATTTAGTTTTTGGGTAATGGGTAGAT
+>002186_1130_0654 length=50 uaccno=E0R4ISW01C1H5C
+GGGTGTTGAATTTAATATGTAGTATATTGATTTGTGATGATTATTTTGCC
+>002282_1237_2702 length=92 uaccno=E0R4ISW01DAXWG
+AATTAGCCGGGCGTGATGGCGGGCGTTTGTAGTTTTAGTTATTCGGGAGGTTGAGGTAGGAGAATGGCGTGAATTCGGGAAGCGGAGTTTGC
+>002382_1259_0997 length=64 uaccno=E0R4ISW01DCT37
+TAAGGGTTGAAGCGAGGTAGGTAGTTTGTTTGTGGTTTTGTTTCGTATTTTTGTTTCGTATCCC
+>002477_0657_0655 length=131 uaccno=E0R4ISW01BVY8H
+TTTTTGGAAAGTTGGGTGGGTATAGTTTTGAGTAGTTAGAGGTATTATAATAGTATTAGGAAGTTGAATGTGAGGGTATAAGAGTTAATTTGATTTTTCGTTGATATGTTTGTTGTTTGAAGTTAGAGTGC
+>003149_1553_2333 length=128 uaccno=E0R4ISW01D2OBZ
+TATTTAGTTTTAGTTTGTTTAGGTGGTTATAGAATACGGAGTTTATGAAGTTGATTAGGAATATTATTAGTTGAATTAAGAATTGGGAAGAGAGGGGAACGGGAAGGGACGTGAGTGATTATTATTGC
+>003194_1475_2845 length=58 uaccno=E0R4ISW01DVT7J
+TATTTTGGGTTAAGTCGGGTTTAGTTGTTAGGGCGAGAAGTTAGTTGTTGACCCCTGC
+>003206_1315_0479 length=52 uaccno=E0R4ISW01DHQPD
+GGGTTGGATAATATGATGGTGTTGGGGAATATTTAGGTATGTGGTTTGTGGC
+>003271_0173_0314 length=82 uaccno=E0R4ISW01APHAK
+GTTTATTTGTTATTTATTTTTAGGTTTAGAAGAGTGTTTGGTATTTATTGAGGATTTAGTATTTGTTAGAAGGATTGGATTC
+>003443_1737_2250 length=21 uaccno=E0R4ISW01EITSS
+TGTAGGTTGTGTTGTAGGTTG
+>002633_1776_1582 length=40 uaccno=E0R4ISW01EL8JK
+CAGGGTGGATTGGGGAACACACAGTGTGGCCGCGTGATTC
+>002663_0725_3154 length=84 uaccno=E0R4ISW01B1Z2S
+GCGTTTTATATTATAATTTAATATTTTGGAGGTTGGGTGCGGTGGTTTACGTTTGTAGTTTAGTATTTGGGAGGTTAAGGTAGC
+>002761_1056_4055 length=72 uaccno=E0R4ISW01CU2V9
+AATTTTATTCGATTTATGTGATGATTTATTTATTTTATTTGAAGATGATTTTATTCGAGATTATTCGATGAT
+>002843_0289_2275 length=80 uaccno=E0R4ISW01AZPE9
+ATTGAAGAGGTTGGTAAGTTTTAAGTTGGTAGGTGGTTGGGGAGTGGTTGGAGAGGAGTTGTTGGGAGTTTGTGTCCTGC
+>002934_1762_2177 length=50 uaccno=E0R4ISW01EK0Q7
+GGGTGTTGAATTTAATATGTAGTATATTGATTTGTGATGATTATTTTGCC
+>003515_1711_1058 length=79 uaccno=E0R4ISW01EGIPG
+AATTGAATGGAATTATTATTGAATGGATTCGAATGGAATTATTATTGAATGGAATCATCGAGTGGAATCGAATGGAATC
+>003541_1276_1589 length=70 uaccno=E0R4ISW01DECAV
+TAGTTTAGGGTGGTAGTTTGGATAAGGTAGTTTTACGGTTTAGTAGTAGTAGGTTAAGTAGGAAAACTGC
+>003587_1522_1804 length=109 uaccno=E0R4ISW01DZXX6
+AATTTATGTAGTGGAAGTAGGATATAAAGAATAGGTTAATGGATTTTGAGATATTAAAAAGAGTAGGAAATTAGTTGAGAGGTTAAGTAGTAGTTTATTTTAGCCACCC
+>003592_0076_0430 length=92 uaccno=E0R4ISW01AGYTC
+AATTAGTTAGGCGTGGTGGCGGGTGTTTGTAGTTTTAGTTATTCGGGAGGTTGAGGTAGGAGAATGTTGTGAATTTAGGAGGTGGAGTTTGC
+>003957_0595_0965 length=130 uaccno=E0R4ISW01BQJIV
+TAATATTAGGTGTCAATTTGACTGGATCGAGGGATGTGTGTCGGTGAGAGTCTCACTAGAGGTTGATATTTGAGTCGTTAGACTGGGAGAGGAAGACCGAACTGTCAAGTGTATGGGCGCCATCCAATTC
+>003986_1127_2937 length=61 uaccno=E0R4ISW01C1AFF
+TAATGGAATGGAATTTTCGGAATGGAATGGAATGGAATGGAATGGAATGGAATGGAATTAC
+>004012_1559_1491 length=72 uaccno=E0R4ISW01D26M9
+TAGTGGATATAAATGGAATGGATTGGAATGGAATGGATACGAATGGAATGGATTGGAGTGGAATGGATTGAC
+>004030_1508_2061 length=123 uaccno=E0R4ISW01DYPWF
+TACGTATATACGCGTACGCGTATACGTATATACGCGTATACGTATACGCGTACGTATATATACGCGTATACGTTTACGTACGTACGCGTATATACGTACGTATACACACACGCATATGCATAC
+>004038_1061_2047 length=109 uaccno=E0R4ISW01CVG5D
+AATTGATTCGAATGGAATGGATTGGAATGGAACGGATTTGAATGGAATGGATTGGAATGGAATGGATTGAATGGAATGGATTGGAGAGGATTGGATTTGAATGGAATTC
+>004105_1121_0391 length=92 uaccno=E0R4ISW01C0PH1
+AATTAGTTGGGCGTGGTGGCGAGTGTTTGTAATTTTAGTTATTTAGGAGGTTGAGGTAGGAGAATTATTTGAACCCGGTAGACGGAAGTTGC
+>004129_1618_3423 length=79 uaccno=E0R4ISW01D8ELT
+AATTGAATGGTATTGAAAGGTATTAATTTAGTGGAATGGAATGGAATGTATTGGAATGGAAAATAATGGAATGGAGTGC
+>004203_0451_0902 length=72 uaccno=E0R4ISW01BDWC4
+TAGTTGGTGTGTTGTAATCGAGACGTAGTTGGTTGGTACGGGTTAGGGTTTTGATTGGGTTGTTGTGTTTGC
+>004626_1937_0919 length=180 uaccno=E0R4ISW01E0CVD
+TAGAGTAGATAGTAGGGTTAGAGAAGGTAGGGTACGTTTAGTTTGTTAGTAAGGTTTAAGTTTTGGGTGGGAAAGGTTAGTGGCGGGAAGGGACGAAGGTGGTAATCGAGAGTAGATTTAGAGAAGTTTTTGAAGTGGGCGTTGGGAGTTTTCGAAGTATTGAGAGAGAGGAGCTTGTGC
+>004913_0641_2071 length=92 uaccno=E0R4ISW01BULRD
+AATTAGTCGAGCGTTGTGGTGGGTATTTGTAATTTTAGCTACTCTGAAGGCTGAGGCAGGAGAACTGCTTGAACCCGGGAGGCGGAGGTTGC
+>005063_0599_1983 length=84 uaccno=E0R4ISW01BQWX9
+ATGTGGTGAAGATTGGTTTTAGGTGTTTTAATGTGGATTTTCAGGGGTTTTAAAAGGGTTGGGAGAGTGAAATATATATAAGGC
+>005140_0759_3209 length=74 uaccno=E0R4ISW01B4ZKR
+TAGTATAGAGGGTTTGTGGTCGTGAGGGTGTTGATGGCGGGAGGGTTTTGATGGTAGGAGGGCCCGTGCTGTGC
+>005351_0883_3221 length=95 uaccno=E0R4ISW01CFVHJ
+TTAGGTGTTATAGTTGAGTGAGATGTTAGTGTTTAATGGTTTTATTTAGGTTGATGGGTTAATGAGGGGGTATTTGATAGTTTTGAAGATTTGAC
+>005380_1702_1187 length=160 uaccno=E0R4ISW01EFQC1
+GTTTTTCGAGTATATATTTAGTAGTACGCTCGACTTCTCTTATATAAAGGTTTTGGTTTTTATAGGTTTTTCCATTGTGTCTGCCTGGGGGAGGGCCCTTCTCCTTCAGGATACTGTAGCTTCTCTGCGTGATAAGCCAGCATTCACGGCTTTCAGGTGC
+>005568_1060_1943 length=20 uaccno=E0R4ISW01CVDWP
+ATAGCGTATTTCTCACCTGC
+>005740_1536_2697 length=116 uaccno=E0R4ISW01D06VV
+TAAAGAGGTGTTATTATTAGTTAGGAGAGGAGGTGGTTAGATAGTAGTGGGATTATAGGGGAATATAGAGTTGTTAGTTTAGGGATAAGGGATTGATCGATGGGTTAGGTCTCTGC
+>005753_1884_3877 length=53 uaccno=E0R4ISW01EVRNB
+AAACTGAGTTGTGATGTTTGCATTCAACTCACAGAGTTCAACATTCCTTTAAC
+>read_equals_adapter 1a
+
+>read_equals_start_of_adapter 1b
+
+>read_equals_end_of_adapter 1c
+
+>read_equals_middle_of_adapter 1d
+
+>read_ends_with_adapter 2a
+GCTACTCTGAAGGCTGAGGCAGGAGAACTGCTTGAACCCGGGAGGCG
+>read_ends_with_start_of_adapter 2b
+GCTACTCTGAAGGCTGAGGCAGGAGAACTGCTTGAACCCGGGAGGCG
+>read_contains_adapter_in_the_middle 3
+CGTAGTTGGTTGGTACG
+>read_starts_with_adapter 4a
+AAAGGTTTTGGTTTTTATAGGTTTTT
+>read_starts_with_end_of_adapter 4b
+AAAGGTTTTGGTTTTTATAGGTTTTT
diff --git a/tests/cut/anchored-back.fasta b/tests/cut/anchored-back.fasta
new file mode 100644
index 0000000..c65f89a
--- /dev/null
+++ b/tests/cut/anchored-back.fasta
@@ -0,0 +1,8 @@
+>read1
+sequence
+>read2
+sequenceBACKADAPTERblabla
+>read3
+sequenceBACKADA
+>read4
+sequence
diff --git a/tests/cut/anchored.fasta b/tests/cut/anchored.fasta
new file mode 100644
index 0000000..cca3279
--- /dev/null
+++ b/tests/cut/anchored.fasta
@@ -0,0 +1,8 @@
+>read1
+sequence
+>read2
+blablaFRONTADAPTsequence
+>read3
+NTADAPTsequence
+>read4
+sequence
diff --git a/tests/cut/anchored_no_indels.fasta b/tests/cut/anchored_no_indels.fasta
new file mode 100644
index 0000000..b189dd4
--- /dev/null
+++ b/tests/cut/anchored_no_indels.fasta
@@ -0,0 +1,12 @@
+>no_mismatch (adapter: TTAGACATAT)
+GAGGTCAG
+>one_mismatch
+GAGGTCAG
+>two_mismatches
+TAAGACGTATGAGGTCAG
+>insertion
+ATTAGACATATGAGGTCAG
+>deletion
+TAGACATATGAGGTCAG
+>mismatch_plus_wildcard
+TNAGACGTATGAGGTCAG
diff --git a/tests/cut/anchored_no_indels_wildcard.fasta b/tests/cut/anchored_no_indels_wildcard.fasta
new file mode 100644
index 0000000..245cd41
--- /dev/null
+++ b/tests/cut/anchored_no_indels_wildcard.fasta
@@ -0,0 +1,12 @@
+>no_mismatch (adapter: TTAGACATAT)
+GAGGTCAG
+>one_mismatch
+GAGGTCAG
+>two_mismatches
+TAAGACGTATGAGGTCAG
+>insertion
+ATTAGACATATGAGGTCAG
+>deletion
+TAGACATATGAGGTCAG
+>mismatch_plus_wildcard
+GAGGTCAG
diff --git a/tests/cut/anywhere_repeat.fastq b/tests/cut/anywhere_repeat.fastq
new file mode 100644
index 0000000..e5ae7f3
--- /dev/null
+++ b/tests/cut/anywhere_repeat.fastq
@@ -0,0 +1,28 @@
+ at prefix:1_13_1400/1
+CGTCCGAANTAGCTACCACCCTGATTAGACAAAT
++
+)3%)&&&&!.1&(6:<'67..*,:75)'77&&&5
+ at prefix:1_13_1500/1
+NNNNANNNNNNNNNNNNNNNNNNNNNNNNNNNNN
++
+<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
+ at prefix:1_13_1550/1
+NNNNANNNNNNNNNNNNNNNNNNNNNNNNNNNNN
++
+<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
+ at prefix:1_13_1600/1
+NNNNATGTCCCCTGCCACATTGCCCTAGTNNNNN
++
+<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
+ at prefix:1_13_1700/1
+NNNNATGTCCCCTGCCACATTGCCCTAGTTTATT
++
+<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
+ at prefix:1_13_1800/1
+GTTCATGTCCCCTGCCACATTGCCCTAGTTTATT
++
+<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
+ at prefix:1_13_1900/1
+ATGGCTGTCCCCTGCCACATTGCCCTAGTNNNNN
++
+<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
diff --git a/tests/cut/discard-untrimmed.fastq b/tests/cut/discard-untrimmed.fastq
new file mode 100644
index 0000000..5caed44
--- /dev/null
+++ b/tests/cut/discard-untrimmed.fastq
@@ -0,0 +1,4 @@
+ at prefix:1_13_1440/1
+CTNCCCTGCCACATTGCCCTAGTTAAAC
++
+57!7<';<6?5;;6:+:=)71>70<,=:
diff --git a/tests/cut/discard.fastq b/tests/cut/discard.fastq
new file mode 100644
index 0000000..d3668fd
--- /dev/null
+++ b/tests/cut/discard.fastq
@@ -0,0 +1,4 @@
+ at prefix:1_13_1440/1
+CAAGATCTNCCCTGCCACATTGCCCTAGTTAAAC
++
+<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
diff --git a/tests/cut/dos.fastq b/tests/cut/dos.fastq
new file mode 100644
index 0000000..a3437d1
--- /dev/null
+++ b/tests/cut/dos.fastq
@@ -0,0 +1,12 @@
+ at prefix:1_13_573/1
+CGTCCGAANTAGCTACCACCCTGA
++
+)3%)&&&&!.1&(6:<'67..*,:
+ at prefix:1_13_1259/1
+AGCCGCTANGACGGGTTGGCCC
++
+;<:&:A;A!9<<<,7:<=3=;:
+ at prefix:1_13_1440/1
+CAAGATCTNCCCTGCCACATTGCCCTAGTTAAAC
++
+<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
diff --git a/tests/cut/empty.fastq b/tests/cut/empty.fastq
new file mode 100644
index 0000000..e69de29
diff --git a/tests/cut/example.fa b/tests/cut/example.fa
new file mode 100644
index 0000000..50ab75e
--- /dev/null
+++ b/tests/cut/example.fa
@@ -0,0 +1,18 @@
+>read1
+MYSEQUENCE
+>read2
+MYSEQUENCE
+>read3
+MYSEQUENCE
+>read4
+MYSEQUENCEADABTER
+>read5
+MYSEQUENCEADAPTR
+>read6
+MYSEQUENCEADAPPTER
+>read7
+MYSEQUENCE
+>read8
+MYSEQUENCE
+>read9
+SOMETHING
diff --git a/tests/cut/examplefront.fa b/tests/cut/examplefront.fa
new file mode 100644
index 0000000..b60e194
--- /dev/null
+++ b/tests/cut/examplefront.fa
@@ -0,0 +1,18 @@
+>read1
+
+>read2
+MYSEQUENCEADAP
+>read3
+SOMETHINGELSE
+>read4
+MYSEQUENCEADABTER
+>read5
+MYSEQUENCEADAPTR
+>read6
+MYSEQUENCEADAPPTER
+>read7
+MYSEQUENCE
+>read8
+MYSEQUENCE
+>read9
+MYSEQUENCE
diff --git a/tests/cut/illumina.fastq b/tests/cut/illumina.fastq
new file mode 100644
index 0000000..9e74b7d
--- /dev/null
+++ b/tests/cut/illumina.fastq
@@ -0,0 +1,400 @@
+ at SEQ:1:1101:9010:3891#0/1 adapter start: 51
+ATAACCGGAGTAGTTGAAATGGTAATAAGACGACCAATCTGACCAGCAAGG
++
+FFFFFEDBE at 79@@>@CBCBFDBDFDDDDD<@C>ADD at B;5:978 at CBDDF
+ at SEQ:1:1101:9240:3898#0/1
+CCAGCAAGGAAGCCAAGATGGGAAAGGTCATGCGGCATACGCTCGGCGCCAGTTTGAATATTAGACATAATTTATCCTCAAGTAAGGGGCCGAAGCCCCTG
++
+GHGHGHHHHGGGDHHGDCGFEEFHHGDFGEHHGFHHHHHGHEAFDHHGFHHEEFHGHFHHFHGEHFBHHFHHHH at GGGDGDFEEFC@=D?GBGFGF:FB6D
+ at SEQ:1:1101:9207:3899#0/1 adapter start: 64
+TTAACTTCTCAGTAACAGATACAAACTCATCACGAACGTCAGAAGCAGCCTTATGGCCGTCAAC
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHFHHHHHHCFHHF
+ at SEQ:1:1101:9148:3908#0/1 adapter start: 28
+ACGACGCAATGGAGAAAGACGGAGAGCG
++
+HHHHHHHHHHHHGHHHHGHHHHHHHHHH
+ at SEQ:1:1101:9044:3916#0/1 adapter start: 78
+AACAGAAGGAGTCTACTGCTCGCGTTGCGTCTATTATGGAAAACACCAATCTTTCCAAGCAACAGCAGGTTTCCGAGA
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHGHHHHGHHHHHHHHHHHHFHEBFHFFEFHE
+ at SEQ:1:1101:9235:3923#0/1
+TTGATGCGGTTATCCATCTGCTTATGGAAGCCAAGCATTGGGGATTGAGAAAGAGTAGAAATGCCACAAGCCTCAATAGCAGGTTTAAGAGCCTCGATACG
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHFHBHHFHFHHHHHFHHCHHFFHHHHEHHFDHCEEHHHFHHFHFEHHHHHHHHHEHHGFHH<FGGFABGGG?
+ at SEQ:1:1101:9086:3930#0/1 adapter start: 46
+CCATCCAAAGGATAAACATCATAGGCAGTCGGGAGGGTAGTCGGAA
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH at HHEHHHFH
+ at SEQ:1:1101:9028:3936#0/1
+CTTGATATTAATAACACTATAGACCACCGCCCCGAAGGGGACGAAAAATGGTTTTTAGAGAACGAGAAGACGGTTACGCAGTTTTGCCGCAAGCTGGCTGC
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHFHHHHHHHHCHFHHFHGBEFFFEFEFHEHHHFEHHFEEC>CDCEEEFDFFHHHCFFEFE?EBFEB?3
+ at SEQ:1:1101:9185:3939#0/1
+CGTTGAGGCTTGCGTTTATGGTACGCTGGACTTTGTAGGATACCCTCGCTTTCCTGCTCCTGTTGAGTTTATTGCTGCCGTCATTGCTTATTATGTTCATC
++
+HHHHHHHHHHHHHHFHHEHHHDHHFGHHHCHHHHHDHHHHFECEGBD<DCFHBHBBEEEGCCCDB?C9DECCC3CD<@DA<@>@@?A?DAFF9F<@@08?<
+ at SEQ:1:1101:9140:3961#0/1 adapter start: 66
+CAGGAGAAACATACGAAGGCGCATAACGATACCACTGACCCTCAGCAATCTTAAACTTCTTAGACG
++
+HHHHHHHGHHHHHHHHHHHGHHHHHHHHHHHHHHHHFHHHHHHFGHHHHHHHHHHHHHHHHDHHFH
+ at SEQ:1:1101:9073:3961#0/1 adapter start: 49
+GTGGCAAGTCTGCCGCTGATAAAGGAAAGGATACTCGTGATTATCTTGC
++
+HHHHHHHHFHHHHHHGHHHHHHHHHEHHGHHGHHHHHHHHHHGEHHHHH
+ at SEQ:1:1101:9196:3971#0/1 adapter start: 18
+ACCAGAAGGCGGTTCCTG
++
+HHHHHHHHHFHHHHHHHH
+ at SEQ:1:1101:9053:3973#0/1
+TTCACGTTCTGGTTGGTTGTGGCCTGTTGATGCTAAAGGTGAGCCGCTTAAAGCTACCAGGTTTATTGCTGTTTGTTTCTATGTGGCTTAAAACGTTACCA
++
+A39>A################################################################################################
+ at SEQ:1:1101:9120:3979#0/1
+GGCGTTGACAGATGTATCCATCTGAATGCAATGAAGAAAACCACCATTACCAGCATTAACCGTCAAACTATCAAAATATAACGTTGACGATGTAGCTTTAG
++
+HHHHHHHHHHHGHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHFFGFFDHBHHHFGEHHHFGHHHEHHHGH
+ at SEQ:1:1101:9045:3988#0/1 adapter start: 91
+TAACCCTGAAACAAATGCTTAGGGATTTTATTGGTATCAGGGTTAATCGTGCCAAGAAAAGCGGCATGGTCAATATAACCAGCAGTGTTAA
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHFHHHHHHHFHHHHHHHHHHHFHHHHHHDHHHHHHHFHFFHHGHEHHGHHHGHGHHFH
+ at SEQ:1:1101:9418:3756#0/1
+TAATCGTGCCAAGAAAAGCGGCATGGTCAATATAACCAGTAGTGTTAACAGTCGGGAGAGGAGTGGCATTAACACCATCCTTCATGAACTTAATCCACTGT
++
+HHHHHHHHHHHHHHHHFHHHGHEHHHFHHHHFFEHHFHHHHGHHFHFHHHGHHHDHFHCHFCFBCFEFDEHHHHHG at GGGGHHGHFFEG=AB at C:EDEEEH
+ at SEQ:1:1101:9394:3759#0/1
+CCCTCGCTTTCCTGCTCCTGTTGAGGTTATTGCTGCCGTCATTGCTTATTATGTTCATCTCGGCAACATTCATACGGTCTGGCTTATCCGTGCAGAGACTG
++
+#####################################################################################################
+ at SEQ:1:1101:9365:3766#0/1
+AAGCACATCACCTTGAATGCCACCGGAGGCGGCTTTTTGACCGCCTCCAAACAATTTAGACATGGCGCCACCAGCAAGAGCAGAAGCAATACCGCCAGCAA
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHFFHHHHFHHHHEHHFGHHHHFEHHHHFEHHFDFFAFHEFHFHDFFFFHHDH?DFABFDHADFDHHHFBF
+ at SEQ:1:1101:9436:3776#0/1
+GAAGGACGTCAATAGTCACACAGTCCTTGACGGTATAATAACCACCATCATGGCGACCATCCAAAGGATAAACATCATAGGCAGTCGGGAGGGGAGTCGGA
++
+HHHHHHHHHHHHGHHHHHHHHHHHHHHHHHHHHFHGHHHHHHHGHHHHHHFDHHHHHHHHHHHHHFH?HHHHHFBHEH at GHHGD=EEEE88==%893A@@;
+ at SEQ:1:1101:9354:3801#0/1
+CCAGCAAGAGCAGAAGCAATACCGCCAGCAATAGCACCAAACATAAATCACCTCACTTAAGTGGCTGGAGACAAATAATCTCTTTAATAACCTGATTCAGC
++
+HHHHHHHHHGHHGHHEGHHEHFGFEHHGHGGHHHHHHHFHGHHFHHEFFFHEHHFHHHDHE5EDFCAC+C)4&27DDA?7HFHDHEFGFG,<@7>?>??<A
+ at SEQ:1:1101:9389:3804#0/1 adapter start: 28
+ATTAGAGCCAATACCATCAGCTTTACCG
++
+GGGGFDGGHFHHHFFFGBEFGGGGGEFE
+ at SEQ:1:1101:9477:3819#0/1 adapter start: 28
+ATAAAGGAAAGGATACTCGTGATTATCT
++
+HHHHHHHHHHHHHHHHGHHHHHHHHHHH
+ at SEQ:1:1101:9428:3823#0/1
+CGTCAGTAAGAACGTCAGTGTTTCCTGCGCGTACACGCAAGGTAAACGCGAACAATTCAGCGGCTTTAACCGGACGCTCGACGCCATTAATAATGTTTTCC
++
+HHHHHHHHHHHHHHHHHHHHHHHHHFHHHHHFGHGHHHHHHHEHHHHFHHHHHFHHHFHH?FHEFFFDGFDAFDCFAFDBFGBFGFHHHHHHHHHFHFH;8
+ at SEQ:1:1101:9403:3824#0/1 adapter start: 70
+GCTCAGGAACAAAGAAACGCGGCACAGAATGTTTATAGGTCTGTTGAACACGACCAGAAAACTGGCCTAA
++
+HHHHHHHHHHHHHHHHHHHEHHHHHHHHHHHHHHHHGDHDHHHHHHHHHGHHHHGHEHGHHHHFFHHHHH
+ at SEQ:1:1101:9362:3824#0/1
+ACCATGAAACCAACATAAACATTATTGCCCGGCGTACGGGGAAGGACGTCAATAGTCACACAGTCCTTGACGGTATAATAACCACCATCATGGCGACCATC
++
+HHHHHHHGHHHHHHHHHHHHHHHGHHHHHFHHHHHHHHFHHFHHHFHHHHHHHHHFHEHHHFHBHFHHHFCEFDEHHHHGHHHHHHHHHEFFFHHFFFDAG
+ at SEQ:1:1101:9480:3842#0/1 adapter start: 54
+GTACGGATTGTTCAGTAACTTGACTCATGATTTCTTACCTATTAGTGGTTGAAC
++
+BDCCC at 5<<<@BBB7DDDDD<<<9>::@<5DDDDDCDCBEDCDDDDBDDDBAA1
+ at SEQ:1:1101:9286:3846#0/1
+TGATTAAACTCCTAAGCAGAAAACCTACCGCGCTTCGCTTGGTCAACCCCTCAGCGGCAAAAATTAAAATTTTTACCGCTTCGGCGTTATAACCTCACACT
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHFHFHHDGCEGGHHHHFHHFHEHHFHEGHGHGF
+ at SEQ:1:1101:9403:3867#0/1 adapter start: 1
+G
++
+H
+ at SEQ:1:1101:9341:3873#0/1 adapter start: 88
+CCTAAGCAGAAAACCTACCGCGCTTCGCTTGGTCAACCCCTCAGCGGCAAAAATTAAAATTTTTACCGCTTCGGCGTTATAACCTCAC
++
+HHHHHHHGGFHGHHHHHGHHHHFGHGHHHHEHHHFHFHFHFHH?CEEEDFCEFCDFFHFEABEDF.ECDCDFEEEEEGGFADACDHHH
+ at SEQ:1:1101:9381:3881#0/1 adapter start: 41
+ACGTTCTGGTTGGTTGTGGCCTGTTGATGCTAAAGGTGAGC
++
+HHHHHHHHHHHHGHGHDHHHHHHHHFEHHHGGGGFFBGFFF
+ at SEQ:1:1101:9360:3884#0/1
+TAATACCTTTCTTTTTGGGGTAATTATACTCATCGCGAATATCCTTAAGAGGGCGTTCAGCAGCCAGCTTGCGGCAAAACTGCGTAACCGTCTTCTCGTTC
++
+HGDEHGHDGHFGFGHFDFFF7EEEEGGFGGEGHEGHHHHFFFEHHHFHEHFBFFF>?DEEBF=?CDB:DFBGFBBGDFFHF?FAFGGABFGGFAFE6EDDC
+ at SEQ:1:1101:9323:3894#0/1 adapter start: 100
+ATACCGATATTGCTGGCGACCCTGTTTTGTATGGCAACTTGCCGCCGCGTGAAATTTCTATGAAGGATGTTTTCCGTTCTGGTGATTCGTCTAAGAAGTTG
++
+HHGHHHHHHHHHHHHHHHHHHHEHDHHHHHGEHHFFHHFFFHHHHHHHHFHDHHBHGHB?HHDFFF?EFEHFHBFGEGGFFFDFBHFHHHHHFHHEFFFCF
+ at SEQ:1:1101:9267:3900#0/1 adapter start: 89
+GTTTTGGATTTAACCGAAGATGATTTCGATTTTCTGACGAGTAACAAAGTTTGGATTGCTACTGACCGCTCTCGTGCTCGTCGCTGCGT
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHFHHHHHHHHHHHHHHFHHHHEHHEHHHFHHHHHHHHHHFHFHECFFHABGGGIGHHHGGFFGF
+ at SEQ:1:1101:9416:3909#0/1
+TAAACGTGACGATGAGGGACATAAAAAGTAAAAATGTCTACAGTAGAGTCAATAGCAAGGCCACGACGCAATGGAGAAAGACGGAGAGCGCCAACGGCGTC
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHFHHHHHHHHHHHHHHHHHHHEHHGHHFEFHEFHFFDHEFHFAFFFA?GDFGFE at FFFB?B7EEFEFE?DAA##
+ at SEQ:1:1101:9360:3917#0/1 adapter start: 68
+ATGCTTGGGAGCGTGCTGGTGCTGATGCTTCCTCTGCTGGTATGGTTGACGCCGGATTTGAGAATCAA
++
+HHHHHHHHHHHHHHHHHHHFHHHHHHHHHHFHHHHHHHFHEFHHHEHHCFFEFEE9AFFBBDCDCAEE
+ at SEQ:1:1101:9337:3918#0/1 adapter start: 14
+CATCAGCACCAGCA
++
+FDEGGGCDBEFCDF
+ at SEQ:1:1101:9307:3927#0/1 adapter start: 15
+TCAGCGCCTTCCATG
++
+FFFFFFFFFFFFFDF
+ at SEQ:1:1101:9479:3929#0/1 adapter start: 9
+GACAAATTA
++
+HHHHHHHHH
+ at SEQ:1:1101:9277:3934#0/1 adapter start: 71
+CTGTCTTTTCGTATGCAGGGCGTTGAGTTCGATAATGGTGATATGTATGTTGACGGCCATAAGGCTGCTTC
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHFHHHHHHEHFHHHHFHHHHHFHHEHFHHHFHHFDHHFHHE
+ at SEQ:1:1101:9442:3934#0/1
+AGACCCATAATGTCAATAGATGTGGTAGAAGTCGTCATTTGGCGAGAAAGCTCAGTCTCAGGAGGAAGCGGAGCAGTCCAAATGTTTTTGAGATGGCAGCA
++
+HHHHHHHHHGHHHHHFGHHBHHEHGFHHDHGDEGDHHHHHFHHHHHAHHH?FEEBEFDFBEBEEFEHFE7ECCDCG=FDFFDFFFHHHHFEEBEF;BEAEG
+ at SEQ:1:1101:9329:3935#0/1
+AGATGGATAACCGCATCAAGCTCTTGGAAGAGATTCTGTCTTTTCGTATGCAGGGCGTTGAGTTCGATAATGGTGATATGTATGTTGACGGCCATAAGGCT
++
+GFGGGEEGDHHHGGEHHHHHHGGFHHEAHHAGDEGEGGEDG at GGGHHGHHFGGH6@CADDHHBEEE at 8EBGEEFGGGHFHHHHGEGFGGEFBGEDDE?E7E
+ at SEQ:1:1101:9445:3956#0/1 adapter start: 81
+TGCAACAACTGAACGGACTGGAAACACTGGTCATAATCATGGTGGCGAATAAGTACGCGTTCTTGCAAATCACCAGAAGGC
++
+HHHHHHHHHGFHHHHHHHHHHHHHHGHHHHFHHHHHHHHHHHFGHHHFGHHHHFGHHFHEHHHHHHHHHHHHGBHHHHGFG
+ at SEQ:1:1101:9357:3957#0/1
+TTAATCGTGCCAAGAAAAGCGGCATGGTCAATATAACCAGTAGTGTTAACAGTCGGGAGAGGAGTGGCATTAACACCATCCTTCATGAACTTAATCCACTG
++
+HHHHHHGHHHHHHHHHHGHEHHHHHGHEHHHHHHHHHHHHHHGHEBGGFGFFFFFBH?HCEEED<FEEEFFHHDHHHHEHHHGFHHH:BHHHHFHEFFHFF
+ at SEQ:1:1101:9487:3957#0/1
+CAATAAAATCCCTAAGCATTTGTTTCAGGGTTATTTGAATATCTATAACAACTATTTTAAAGCGCCGTGGATGCCTGACCGTACCGAGGCTAACCCTAATG
++
+HHHHHHHHHHHHHHHGEHHHGHHHHHHHEGFHGHHHGHHHHGGHHHHHGHHHHHHHHHHFHHB>EFHFHBHFHCFHHGGGHEGHEGHEF at GHHFHEDHH;H
+ at SEQ:1:1101:9309:3957#0/1 adapter start: 72
+GTCAGATATGGACCTTGCTGCTAAAGGTCTAGGAGCTAAAGAATGGAACAACTCACTAAAAACCAAGCTGTC
++
+HHHHHHHHHHHHHHHHHHHHHHHHHGHFHHHFHHHHHHHHGHHHFHHHHHHHFHDHHHHHHFHCHHEAHHDG
+ at SEQ:1:1101:9425:3960#0/1
+CTGACGCAGAAGAAAACGTGCGTCAAAAATTACGTGCAGAAGGAGTGATGTAATGTCTAAAGGTAAAAAACGTTCTGGCGCTCGCCCTGGTCGTCCGCAGC
++
+8?8?C?BC at BD=ABB==BD?CADD=AD>C@@CCBBDD at B/143'3.>>@9BCBDDDC8@@;<A=<DDDDB?A:A;9:2-74,<82;9877CBCDD/B at 5;<
+ at SEQ:1:1101:9337:3969#0/1
+GAATTAAATCGAAGTGGACTGCTGGCGGAAAATGAGAAAATTCGACCTATCCTTGCGCAGCTCGAGAAGCTCTTACTTTGCGACCTTTCGCCATCAACTAA
++
+DBFEFFDEEEBFFFFF8FF=D=DDDEEE=E>@???FB=DFB=>C=EEFFFFFEFFFFF:FEF at FEF<FFFFF?DFDD8DDBD=DBFEB at E6FECF@EB8E?
+ at SEQ:1:1101:9388:3971#0/1
+CTGAATCTCTTTAGTCGCAGTAGGCGGAAAACGAACAAGCGCAAGAGTAAACATAGTGCCATGCTCAGGAACAAAGAAACGCGGCACAGAATGTTTATAGG
++
+HHHHHHFHHHHHHHHHHHHHHHHHHHHFHHGHHHFHHHHHHGHHHHHEFHHHFHHFEHHFEHHFFHHHHECFDF?HHHHGEGGHHHFHHHFEGCFFFFF=E
+ at SEQ:1:1101:9414:3978#0/1 adapter start: 99
+TTATTGGTATCAGGGTTAATCGTGCCAAGAAAAGCGGCATGGTCAATATAACCAGTAGTGTTAACAGTCGGGAGAGGAGTGGCATTAACACCATCCTTCGC
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHGHHHHHHHHHHHHHHHHHHHHHHFHHHHHHHHHHHHHFFHHHHG at HFHDHGHDHHHHHHFGHHGHG
+ at SEQ:1:1101:9494:3983#0/1 adapter start: 72
+TAGCACCAAACATAAATCACCTCACTTAAGTGGCTGGAGACAAATAATCTCTTTAATAACCTGATTCAGCGA
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHGHHHHBF?FBHHFEHB?HEFEHBGEDEEBEDEEFACAFE>
+ at SEQ:1:1101:9363:3989#0/1 adapter start: 95
+CCTCCAAGATTTGGAGGCATGAAAACATACAATTGGGAGGGTGTCAATCCTGACGGTTATTTCCTAGACAAATTAGAGCCAATACCATCAGCTTTGCCTAA
++
+HHHHHHHHHHHHHHHHHHHHHGHHHHHHHHHHGHHHHHHHG<GFGGGGFGHHHHHHEEEEHHDEFHHFHHHFHHDHEGHHHHBHHGCGF8ECEEFFEDBA=
+ at SEQ:1:1101:9436:3998#0/1 adapter start: 67
+TAAATTGTTTGGAGGCGGTCAAAAAGCCGCCTCCGGTGGCATTCAAGGTGATGTGCTTGCTACCGAT
++
+HHHHHHHHHHHHHHHHGGDHHHHHHFHHFGHHHHHHDHHFFDFGEFFHDFCFFEBDFHFFFFEEDEB
+ at SEQ:1:1101:9621:3755#0/1
+AGCCAATACCATCAGCTTTACCGTCTTTCCAGAAATTGTTCCAAGTATCGGCAACAGCTTTATCAATACCATGAAAAATATCAACCACACCAGAAGCAGCA
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHFHHFHHFF?FHHFHFHHHHEHHC at FEHFHFHBGGGFHHHHHHDHHFFHGFHA
+ at SEQ:1:1101:9738:3756#0/1 adapter start: 1
+T
++
+H
+ at SEQ:1:1101:9580:3761#0/1 adapter start: 49
+TATTAAGCTCATTCAGGCTTCTGCCGTTTTGGATTTAACCGAAGATGAT
++
+HHHHHHHHHGGHHHHHEHHHFHEHHGEGGHFGDFGHFHFGHHFFDH?EF
+ at SEQ:1:1101:9533:3764#0/1 adapter start: 20
+TCTGTTGAACACGACCAGAA
++
+FEFFFF at FFDFFEFFDDBDD
+ at SEQ:1:1101:9636:3775#0/1
+ATAAGGCCACGTATTTTGCAAGCTATTTAACTGGCGGCGATTGCGTACCCGACGACCAAAATTAGGGTCAACGCTACCTGTAGGAAGTGTCCGCATAAAGT
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHFHHHFH6HHHHHHHHHHFFHFCHFDCHFE;DAD9BDDDDGFGDGDGGB<FDCDCDGF>GEEGB;5
+ at SEQ:1:1101:9554:3781#0/1
+CACGCTCTTTTAAAATGTCAACAAGAGAATCTCTACCATGAACAAAATGTGACTCATATCTAAACCAGTCCTTGACGAACGTGCCAAGCATATTAAGCCAC
++
+HHHHHHHHHHHHHGGHHHHHHGHFHHHHHHEHHFHHHEHHHHHHHEHHGHHHHEHHHGFHHHEHHHHHHEEFFEDFEDFF>ACBAHGHHHHECEGHBCFEE
+ at SEQ:1:1101:9695:3783#0/1 adapter start: 52
+AATAACCCTGAAACAAATGCTTAGGGATTTTATTGGTATCAGGGTTAATCGT
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHGHHHHHHHHHHHHHGHHHHHHHHHHF
+ at SEQ:1:1101:9572:3788#0/1
+ACCAACACGGCGAGTACAACGGCCCAGCTCAGAAGCGAGAACCAGCTGCGCTTGGGTGGGGCGATGGTGATGGTTTGCATGTTTGGCTCCGGTCTGTAGGC
++
+FFFFFFFFF=EBEB0A at A@<BD:EEFFA at EEEDE?EDE8<E?EE=E:BBB>>A?;FED;;<7??A>>9A>?DA1ADD?D:FF:BC;@##############
+ at SEQ:1:1101:9601:3793#0/1
+GCCGCTAATCAGGTTGTTTCTGTTGGTGCTGATATTGCTTTTGATGCCGACCCTAAATTTTTTGCCTGTTTGGTTCGCTTTGAGTCTTCTTCGGTTCCGAC
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHGHHHEHEGHFHHHHHHHHFHFHCHHHFHFFHHHHHH at HHHHHHGHHHFHHGFHHCFHEGGGFEGE?GCDAD6AD
+ at SEQ:1:1101:9634:3800#0/1
+TTTATGCGGACACTTCCTACAGGTAGCGTTGACCCTAATTTTGGTCGTCGGGTACGCAATCGCCGCCAGTTAAATAGCTTGCAAAATACGTGGCCTTATGG
++
+HHGHFHFHHHHCGHHFHHHHHHGEHHHHHGFBEFHHFEHDHHHGFHHEHHFF9ECD?CEEHED<HBDEEBFEDEEE<FDFDGFBEHHEHCE>F?GEEDEEG
+ at SEQ:1:1101:9501:3800#0/1 adapter start: 42
+TGACCACCTACATACCAAAGACGAGCGCCTTTACGCTTGCCT
++
+HHHHHHHHHHHHHHHHFHHHHHHHHFHHHHHHHHHHHHHHHH
+ at SEQ:1:1101:9703:3807#0/1 adapter start: 27
+TAATAACCTGATTCAGCGAAACCAATC
++
+HHHHHHHHHHHHHHHHHHHHHHGHHHG
+ at SEQ:1:1101:9728:3808#0/1 adapter start: 7
+CAGAAAA
++
+HHHFHHH
+ at SEQ:1:1101:9676:3812#0/1 adapter start: 1
+T
++
+H
+ at SEQ:1:1101:9620:3815#0/1
+TCGCGTAGAGGCTTTGCTATTCAGCGTTTGATGAATGCAATGCGACAGGCTCATGCTGATGGTTGGTTTATCGTTTTTGACACTCTCACGTTGGCTGACGA
++
+HHHHHHHHHHGGHHHGHHGHHHHHHHHHHGFHGHHHHHHHHHFHDHHHDDHFHFHFHHHHFF9EFF>DG?FCBCDFFFEBFFE at DFEGGEEG?GF>>:;@A
+ at SEQ:1:1101:9720:3834#0/1 adapter start: 74
+TAGACATTTTTACTTTTTATGTCCCTCATCGTCACGTTTATGGTGAACAGTGGATTAAGTTCATGAAGGATGGT
++
+HGHHHHHHHHHHHHHHHGGHEGGFGHFGHFHHDGHGHGHHHHHHHHHHFHHHHHFHFHFFHEFHF=FFHFHHFF
+ at SEQ:1:1101:9635:3844#0/1 adapter start: 4
+GACC
++
+HHHH
+ at SEQ:1:1101:9744:3849#0/1 adapter start: 55
+AAACATAGTGCCATGCTCAGGAACAAAGAAACGCGGCACAGAATGTTTATAGGTC
++
+HHHHHHHGCHHFHHFHHFFHEHFGCHHGDGHEFFHFHEHHGBBGFCDGFEEFDCF
+ at SEQ:1:1101:9725:3850#0/1
+ATAACCCTGAAACAAATGCTTAGGGATTTTATTGGTATCAGGGTTAATCGTGCCAAGAAAAGCGGCATGGTCAATATAACCAGTAGTGTTAACAGTCGGGA
++
+FDGGGDGGGEGGGGGBGBEGFFFDFFFFGGFGGGGFBGGGGGEFDFFGEGFFEFEDGGEEF9DCF?EFBBEDBBGFGGEGGGGCFGFEB at B7C>CDEEE##
+ at SEQ:1:1101:9544:3854#0/1
+TAGCGGTAAAGTTAGACCAAACCATGAAACCAACATAAACATTATTGCCCGGCGTACGGGGAAGGACGTCAATAGTCACACAGTCCTTGACGGTATAATAA
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHFHHHHHHHHHHHHFFHHHHHHHHHBFHHHHHFHHHHHHHHHHHHHHFCHHHBHE
+ at SEQ:1:1101:9581:3856#0/1
+GGGCGGTGGTCTATAGTGTTATTAATATCAAGTTGGGGGAGCACATTGTAGCATTGTGCCAATTCATCCATTAACTTCTCAGTAACAGATACAAACTCATC
++
+HHHHHHEHHHHHHHGHHHHHHHHHHHHHHHHHHHHHHHFHHHHGHHHHHHHHHHHHHHHGGHHHFHHHHHGHFGHGEGHHHHHHFEHFHGDGGFFGHH at DH
+ at SEQ:1:1101:9649:3858#0/1 adapter start: 33
+CCTCCAAACAATTTAGACATGGCGCCACCAGCA
++
+B<B at A@AAB>FEEEE@@BA at 3>8<>CCDDBEE@
+ at SEQ:1:1101:9616:3862#0/1 adapter start: 91
+GAATTAAATCGAAGTGGACTGCTGGCGGAAAATGAGAAAATTCGACCTATCCTTGCGCAGCTCGAGAAGCTCTTACTTTGCGACCTTTCGC
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHFHHHHHHHEHHHHHHHHHHHHHHFHHHHHHHFFFHFDHHEHHHGHHHHGDEHHGHHEGH
+ at SEQ:1:1101:9696:3866#0/1
+CAAGTTGCCATACAAAACAGGGTCGCCAGCAATATCGGTATAAGTCAAAGCACCTTTAGCGTTAAGGTACTGAATCTCTTTAGTCGCAGTAGGCGGAAAAC
++
+HHHHHHHHHHHHHHHHHHHHEHEHHHEHHHHFHHHHHHFHHHFHFHHHHHHHHFHHHHFHHFEHBHFEHHHHCEEHHFHHHHHHHHHHHHEHHHHCAFEFG
+ at SEQ:1:1101:9512:3869#0/1
+GCTCGACGCCATTAATAATGTTTTCCGTAAATTCAGCGCCTTCCATGATGAGACAGGCCGTTTGAATGTTGACGGGATGAACATAATAAGCAATGACGGCA
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHFHHHHFHHHDHHHEHHFFFFFFHFAFEFH?E at FFGGGFGHFHAEFGFFFCEEFF
+ at SEQ:1:1101:9723:3870#0/1 adapter start: 66
+CTTTAGCAGCAAGGTATATATCTGACTTTTTGTTAACGTATTTAGCCACATAGCAACCAACAGACA
++
+##################################################################
+ at SEQ:1:1101:9667:3874#0/1
+CTGCTGCATTTCCTGAGCTTAATGCTTGGGAGCGTGCTGGTGCTGATGCTTCCTCTGCTGGTATGGTTGACGCCGGATTTGAGAATCAAAAAGAGCTTACT
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHAHHHHEHHD=DAD>D6ADGE at EBE;@?BCGGE?4>ADAAC
+ at SEQ:1:1101:9565:3879#0/1 adapter start: 24
+AGCCTTATGGCCGTCAACATACAT
++
+HHHHHHHHHHHHHHHHHFHHGFFH
+ at SEQ:1:1101:9721:3885#0/1 adapter start: 51
+TTCCTCAAACGCTTGTTCGGTGGATAAGTTATGGCATTAATCGATTTATTT
++
+>BC?:A?=<>::A=528882.53)5.77;407)*9@:AA8CAA########
+ at SEQ:1:1101:9707:3894#0/1 adapter start: 40
+AACACCATCCTTCATGAACTTAATCCACTGTTCACCATAA
++
+F at F8DEE@EEBCCCCFFEFDDC=DCCFFF=ADD=D>@AA@
+ at SEQ:1:1101:9560:3900#0/1 adapter start: 6
+AGAAGT
++
+GGGGGF
+ at SEQ:1:1101:9696:3913#0/1 adapter start: 2
+CC
++
+HH
+ at SEQ:1:1101:9574:3914#0/1 adapter start: 5
+GAACA
++
+HHHHH
+ at SEQ:1:1101:9508:3931#0/1 adapter start: 91
+TAGAGAACGAGAAGACGGTTACGCAGTTTTGCCGCAAGCTGGCTGCTGAACGCCCTCTTAAGGATATTCGCGATGAGTATAATTACCCCAA
++
+HGHHHHHHHHHHHHHHHHHHGHHHHHFHHHGHHHHFHHHHHHHHHD?ACFEF9FFEEBHBAEFB?E<F5CAD(DAEE;AE at C?D at BDGF?F
+ at SEQ:1:1101:9617:3935#0/1
+TAAATTTAATGTGACCGTTTATCGCAATCTGCCGACCACTCGCGATTCAATCATGACTTCGTGATAAAAGATTGAGTGTGAGGTTATAACGCCGAAGCGGT
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHFHHHHHGHHHHHHHHHHHHHHHHHFHHHFFEDFEFHFHHFHFHGHHFHHHFHHEHHHFHHHHFB
+ at SEQ:1:1101:9667:3950#0/1 adapter start: 66
+CTTTAGCCATAGCACCAGAAACAAAACTAGGGACGGCCTCATCAGGGTTAGGAACATTAGAGCCTT
++
+HHHHHHHHHHHHHHHHGHHHHHHHHGHHHHHHHHHHHHHHHHHHHHHEHHHHDGHFHHHHHHHBHH
+ at SEQ:1:1101:9705:3951#0/1 adapter start: 29
+ATTGCGTACCCGACGACCAAAATTAGGGT
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHH
+ at SEQ:1:1101:9527:3965#0/1
+AACATAGTGCCATGCTCAGGAACAAAGAAACGCGGCACAGAATGTTTATAGGTCTGTTGAACACGACCAGAAAACTGGCCTAACGACGTTTGGTCAGTTCC
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHGHHHHHHHHHHHHHFHHGHHFHEHHHEFEFF at HFHFGGGDGGHFGDFHFGHGHHFGHG
+ at SEQ:1:1101:9550:3969#0/1
+AGAGTAAACATAGTGCCATGCTCAGGAACAAAGAAACGCGGCACAGAATGTTTATAGGTCTGTTGAACACGACCAGAAAACTGGCCTAACGACGTTTGGTC
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHFHHHHHHFHHHHHHHHHHHHFHHHFHHFEHHHHHHHHHHHHHGHHFHHHHFHHHHHHHHHHHG
+ at SEQ:1:1101:9636:3973#0/1 adapter start: 9
+CAAGCGCAA
++
+HHHHHHHHH
+ at SEQ:1:1101:9726:3981#0/1 adapter start: 66
+TTGCTGCCATCTCAAAAACATTTGGACTGCTCCGCTTCCTCCTGAGACTGAGCTTTCTCGCCAAAT
++
+HHFEHHHHHHHHHHHHHHHHHHHHHHGHGHHGHGHHHHHHHHHHGGHHHEHHGFHHHHHEHHEHGH
+ at SEQ:1:1101:9603:3981#0/1 adapter start: 32
+TCTAAGAAGTTTAAGATTGCTGAGGGTCAGTG
++
+HHHHHHHHHHHHHHHFHHHHHHHHHHEHHHHH
+ at SEQ:1:1101:9533:3990#0/1 adapter start: 1
+G
++
+B
+ at SEQ:1:1101:9583:3992#0/1 adapter start: 20
+AAGGTACTGAATCTCTTTAG
++
+98583=>><>B at CBCD==BB
+ at SEQ:1:1101:9903:3754#0/1
+ACCAAAATTAGGGTCAACGCTACCTGTAGGAAGTGTCCGCATAAAGTGCACCGCATGGAAATGAAGACGGCCATCAGCTGTACCATACTCAGGCACACAAA
++
+GFEGGGGGBGE at EAEEGGFGGEGGFGEFFGFGFFGGEGGGGEFGCFCEFBF7FGEGEF?BFEEFDFFE??AADD+D at C@CGFCE6FDFFDFBGFDD at DAAD
+ at SEQ:1:1101:9878:3755#0/1 adapter start: 32
+AGAACGTGAAAAAGCGTCCTGCGTGTAGCGAA
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
+ at SEQ:1:1101:9833:3756#0/1 adapter start: 65
+TCATCGTCACGTTTATGGTGAACAGTGGATTAAGTTCATGAAGGATGGTGTTAATGCCACTCCTC
++
+HHHHHHHHHHHHHHHHHFHHHHHHHHHHHHHHHHFHHHHGHHFHHHHHEHEHHHHFHEHHHEHFH
+ at SEQ:1:1101:9991:3777#0/1
+GCTTTGAGTCTTCTTCGGTTCCGACTACCCTCCCGACTGCCTATGATGTTTATCCTTTGGATGGTCGCCATGATGGTGGTTATTATACCGTCAAGGACTGT
++
+HHHHHHHHHHHHHHHHHHHHHHGHHHGHHHHHHHGHHHHHHGHHHHHHHHHHHHHFHHFFDFFFCFFDHCFF;BFGEFGEGFGGFFF.CFDCCEDB=CBC@
diff --git a/tests/cut/illumina.info.txt b/tests/cut/illumina.info.txt
new file mode 100644
index 0000000..e424484
--- /dev/null
+++ b/tests/cut/illumina.info.txt
@@ -0,0 +1,100 @@
+SEQ:1:1101:9010:3891#0/1 adapter start: 51	1	51	81	ATAACCGGAGTAGTTGAAATGGTAATAAGACGACCAATCTGACCAGCAAGG	GCCTAACTTCTTAGACTGCCTTAAGGACGT	AAGCCAAGATGGGAAAGGTC	adapt
+SEQ:1:1101:9240:3898#0/1	-1	CCAGCAAGGAAGCCAAGATGGGAAAGGTCATGCGGCATACGCTCGGCGCCAGTTTGAATATTAGACATAATTTATCCTCAAGTAAGGGGCCGAAGCCCCTG
+SEQ:1:1101:9207:3899#0/1 adapter start: 64	1	64	94	TTAACTTCTCAGTAACAGATACAAACTCATCACGAACGTCAGAAGCAGCCTTATGGCCGTCAAC	GCCTAACTTCTTAGACTGCCTTAAGGACGT	ATACATA	adapt
+SEQ:1:1101:9148:3908#0/1 adapter start: 28	1	28	58	ACGACGCAATGGAGAAAGACGGAGAGCG	GCCTAACTTCTTAGACTGCCTTAAGGACGT	CCAACGGCGTCCATCTCGAAGGAGTCGCCAGCGATAACCGGAG	adapt
+SEQ:1:1101:9044:3916#0/1 adapter start: 78	1	78	101	AACAGAAGGAGTCTACTGCTCGCGTTGCGTCTATTATGGAAAACACCAATCTTTCCAAGCAACAGCAGGTTTCCGAGA	GCCTAACTTCTTAGACTGCCTTA		adapt
+SEQ:1:1101:9235:3923#0/1	-1	TTGATGCGGTTATCCATCTGCTTATGGAAGCCAAGCATTGGGGATTGAGAAAGAGTAGAAATGCCACAAGCCTCAATAGCAGGTTTAAGAGCCTCGATACG
+SEQ:1:1101:9086:3930#0/1 adapter start: 46	1	46	76	CCATCCAAAGGATAAACATCATAGGCAGTCGGGAGGGTAGTCGGAA	GCCTAACTTCTTAGACTGCCTTAAGGACGT	CCGAAGAAGACTCAAAGCGAACCAA	adapt
+SEQ:1:1101:9028:3936#0/1	-1	CTTGATATTAATAACACTATAGACCACCGCCCCGAAGGGGACGAAAAATGGTTTTTAGAGAACGAGAAGACGGTTACGCAGTTTTGCCGCAAGCTGGCTGC
+SEQ:1:1101:9185:3939#0/1	-1	CGTTGAGGCTTGCGTTTATGGTACGCTGGACTTTGTAGGATACCCTCGCTTTCCTGCTCCTGTTGAGTTTATTGCTGCCGTCATTGCTTATTATGTTCATC
+SEQ:1:1101:9140:3961#0/1 adapter start: 66	1	66	96	CAGGAGAAACATACGAAGGCGCATAACGATACCACTGACCCTCAGCAATCTTAAACTTCTTAGACG	GCCTAACTTCTTAGACTGCCTTAAGGACGT	AATCA	adapt
+SEQ:1:1101:9073:3961#0/1 adapter start: 49	1	49	79	GTGGCAAGTCTGCCGCTGATAAAGGAAAGGATACTCGTGATTATCTTGC	GCCTAACTTCTTAGACTGCCTTAAGGACGT	TGCTGCATTTCCTGAGCTTAAT	adapt
+SEQ:1:1101:9196:3971#0/1 adapter start: 18	1	18	48	ACCAGAAGGCGGTTCCTG	GCCTAACTTCTTAGACTGCCTTAAGGACGT	AATGAATGGGAAGCCTTCAAGAAGGTGATAAGCAGGAGAAACATACGAAGGCG	adapt
+SEQ:1:1101:9053:3973#0/1	-1	TTCACGTTCTGGTTGGTTGTGGCCTGTTGATGCTAAAGGTGAGCCGCTTAAAGCTACCAGGTTTATTGCTGTTTGTTTCTATGTGGCTTAAAACGTTACCA
+SEQ:1:1101:9120:3979#0/1	-1	GGCGTTGACAGATGTATCCATCTGAATGCAATGAAGAAAACCACCATTACCAGCATTAACCGTCAAACTATCAAAATATAACGTTGACGATGTAGCTTTAG
+SEQ:1:1101:9045:3988#0/1 adapter start: 91	1	91	101	TAACCCTGAAACAAATGCTTAGGGATTTTATTGGTATCAGGGTTAATCGTGCCAAGAAAAGCGGCATGGTCAATATAACCAGCAGTGTTAA	GCCTAACTTC		adapt
+SEQ:1:1101:9418:3756#0/1	-1	TAATCGTGCCAAGAAAAGCGGCATGGTCAATATAACCAGTAGTGTTAACAGTCGGGAGAGGAGTGGCATTAACACCATCCTTCATGAACTTAATCCACTGT
+SEQ:1:1101:9394:3759#0/1	-1	CCCTCGCTTTCCTGCTCCTGTTGAGGTTATTGCTGCCGTCATTGCTTATTATGTTCATCTCGGCAACATTCATACGGTCTGGCTTATCCGTGCAGAGACTG
+SEQ:1:1101:9365:3766#0/1	-1	AAGCACATCACCTTGAATGCCACCGGAGGCGGCTTTTTGACCGCCTCCAAACAATTTAGACATGGCGCCACCAGCAAGAGCAGAAGCAATACCGCCAGCAA
+SEQ:1:1101:9436:3776#0/1	-1	GAAGGACGTCAATAGTCACACAGTCCTTGACGGTATAATAACCACCATCATGGCGACCATCCAAAGGATAAACATCATAGGCAGTCGGGAGGGGAGTCGGA
+SEQ:1:1101:9354:3801#0/1	-1	CCAGCAAGAGCAGAAGCAATACCGCCAGCAATAGCACCAAACATAAATCACCTCACTTAAGTGGCTGGAGACAAATAATCTCTTTAATAACCTGATTCAGC
+SEQ:1:1101:9389:3804#0/1 adapter start: 28	1	28	58	ATTAGAGCCAATACCATCAGCTTTACCG	GCCTAACTTCTTAGACTGCCTTAAGGACGT	TCTTTCCAGAAATTGTTCCAAGTATCGGCAACAGCTTTATCAA	adapt
+SEQ:1:1101:9477:3819#0/1 adapter start: 28	1	28	58	ATAAAGGAAAGGATACTCGTGATTATCT	GCCTAACTTCTTAGACTGCCTTAAGGACGT	TGCTGCTGCATTTCCTGAGCTTAATGCTTGGGAGCGTGCTGGT	adapt
+SEQ:1:1101:9428:3823#0/1	-1	CGTCAGTAAGAACGTCAGTGTTTCCTGCGCGTACACGCAAGGTAAACGCGAACAATTCAGCGGCTTTAACCGGACGCTCGACGCCATTAATAATGTTTTCC
+SEQ:1:1101:9403:3824#0/1 adapter start: 70	1	70	100	GCTCAGGAACAAAGAAACGCGGCACAGAATGTTTATAGGTCTGTTGAACACGACCAGAAAACTGGCCTAA	GCCTAACTTCTTAGACTGCCTTAAGGACGT	C	adapt
+SEQ:1:1101:9362:3824#0/1	-1	ACCATGAAACCAACATAAACATTATTGCCCGGCGTACGGGGAAGGACGTCAATAGTCACACAGTCCTTGACGGTATAATAACCACCATCATGGCGACCATC
+SEQ:1:1101:9480:3842#0/1 adapter start: 54	1	54	84	GTACGGATTGTTCAGTAACTTGACTCATGATTTCTTACCTATTAGTGGTTGAAC	GCCTAACTTCTTAGACTGCCTTAAGGACGT	CGCATCGGACTCAGATA	adapt
+SEQ:1:1101:9286:3846#0/1	-1	TGATTAAACTCCTAAGCAGAAAACCTACCGCGCTTCGCTTGGTCAACCCCTCAGCGGCAAAAATTAAAATTTTTACCGCTTCGGCGTTATAACCTCACACT
+SEQ:1:1101:9403:3867#0/1 adapter start: 1	1	1	31	G	GCCTAACTTCTTAGACTGCCTTAAGGACGT	GAACAAAGAAACGCGGCACAGAATGTTTATAGGTCTGTTGAACACGACCAGAAAACTGGCCTAACGACGT	adapt
+SEQ:1:1101:9341:3873#0/1 adapter start: 88	1	88	101	CCTAAGCAGAAAACCTACCGCGCTTCGCTTGGTCAACCCCTCAGCGGCAAAAATTAAAATTTTTACCGCTTCGGCGTTATAACCTCAC	GCCTAACTTCTTA		adapt
+SEQ:1:1101:9381:3881#0/1 adapter start: 41	1	41	71	ACGTTCTGGTTGGTTGTGGCCTGTTGATGCTAAAGGTGAGC	GCCTAACTTCTTAGACTGCCTTAAGGACGT	CGCTTAAAGCTACCAGTTATATGGCTGTTG	adapt
+SEQ:1:1101:9360:3884#0/1	-1	TAATACCTTTCTTTTTGGGGTAATTATACTCATCGCGAATATCCTTAAGAGGGCGTTCAGCAGCCAGCTTGCGGCAAAACTGCGTAACCGTCTTCTCGTTC
+SEQ:1:1101:9323:3894#0/1 adapter start: 100	-1	ATACCGATATTGCTGGCGACCCTGTTTTGTATGGCAACTTGCCGCCGCGTGAAATTTCTATGAAGGATGTTTTCCGTTCTGGTGATTCGTCTAAGAAGTTG
+SEQ:1:1101:9267:3900#0/1 adapter start: 89	1	89	101	GTTTTGGATTTAACCGAAGATGATTTCGATTTTCTGACGAGTAACAAAGTTTGGATTGCTACTGACCGCTCTCGTGCTCGTCGCTGCGT	GCCTAACTTCTT		adapt
+SEQ:1:1101:9416:3909#0/1	-1	TAAACGTGACGATGAGGGACATAAAAAGTAAAAATGTCTACAGTAGAGTCAATAGCAAGGCCACGACGCAATGGAGAAAGACGGAGAGCGCCAACGGCGTC
+SEQ:1:1101:9360:3917#0/1 adapter start: 68	1	68	98	ATGCTTGGGAGCGTGCTGGTGCTGATGCTTCCTCTGCTGGTATGGTTGACGCCGGATTTGAGAATCAA	GCCTAACTTCTTAGACTGCCTTAAGGACGT	AAA	adapt
+SEQ:1:1101:9337:3918#0/1 adapter start: 14	1	14	44	CATCAGCACCAGCA	GCCTAACTTCTTAGACTGCCTTAAGGACGT	CGCTCCCAAGCATTAAGCTCAGGAAATGCAGCAGCAAGATAATCACGAGTATCCTTT	adapt
+SEQ:1:1101:9307:3927#0/1 adapter start: 15	1	15	45	TCAGCGCCTTCCATG	GCCTAACTTCTTAGACTGCCTTAAGGACGT	ATGAGACAGGCCGTTTGAATGTTGACGGGATGAACATAATAAGCAATGACGGCAGC	adapt
+SEQ:1:1101:9479:3929#0/1 adapter start: 9	1	9	39	GACAAATTA	GCCTAACTTCTTAGACTGCCTTAAGGACGT	GAGCCAATACCATCAGCTTTACCGTCTTTCCAGAAATTGTTCCAAGTATCGGCAACAGCTTT	adapt
+SEQ:1:1101:9277:3934#0/1 adapter start: 71	1	71	101	CTGTCTTTTCGTATGCAGGGCGTTGAGTTCGATAATGGTGATATGTATGTTGACGGCCATAAGGCTGCTTC	GCCTAACTTCTTAGACTGCCTTAAGGACGT		adapt
+SEQ:1:1101:9442:3934#0/1	-1	AGACCCATAATGTCAATAGATGTGGTAGAAGTCGTCATTTGGCGAGAAAGCTCAGTCTCAGGAGGAAGCGGAGCAGTCCAAATGTTTTTGAGATGGCAGCA
+SEQ:1:1101:9329:3935#0/1	-1	AGATGGATAACCGCATCAAGCTCTTGGAAGAGATTCTGTCTTTTCGTATGCAGGGCGTTGAGTTCGATAATGGTGATATGTATGTTGACGGCCATAAGGCT
+SEQ:1:1101:9445:3956#0/1 adapter start: 81	1	81	101	TGCAACAACTGAACGGACTGGAAACACTGGTCATAATCATGGTGGCGAATAAGTACGCGTTCTTGCAAATCACCAGAAGGC	GCCTAACTTCTTAGACTGCC		adapt
+SEQ:1:1101:9357:3957#0/1	-1	TTAATCGTGCCAAGAAAAGCGGCATGGTCAATATAACCAGTAGTGTTAACAGTCGGGAGAGGAGTGGCATTAACACCATCCTTCATGAACTTAATCCACTG
+SEQ:1:1101:9487:3957#0/1	-1	CAATAAAATCCCTAAGCATTTGTTTCAGGGTTATTTGAATATCTATAACAACTATTTTAAAGCGCCGTGGATGCCTGACCGTACCGAGGCTAACCCTAATG
+SEQ:1:1101:9309:3957#0/1 adapter start: 72	1	72	101	GTCAGATATGGACCTTGCTGCTAAAGGTCTAGGAGCTAAAGAATGGAACAACTCACTAAAAACCAAGCTGTC	GCCTAACTTCTTAGACTGCCTTAAGGACG		adapt
+SEQ:1:1101:9425:3960#0/1	-1	CTGACGCAGAAGAAAACGTGCGTCAAAAATTACGTGCAGAAGGAGTGATGTAATGTCTAAAGGTAAAAAACGTTCTGGCGCTCGCCCTGGTCGTCCGCAGC
+SEQ:1:1101:9337:3969#0/1	-1	GAATTAAATCGAAGTGGACTGCTGGCGGAAAATGAGAAAATTCGACCTATCCTTGCGCAGCTCGAGAAGCTCTTACTTTGCGACCTTTCGCCATCAACTAA
+SEQ:1:1101:9388:3971#0/1	-1	CTGAATCTCTTTAGTCGCAGTAGGCGGAAAACGAACAAGCGCAAGAGTAAACATAGTGCCATGCTCAGGAACAAAGAAACGCGGCACAGAATGTTTATAGG
+SEQ:1:1101:9414:3978#0/1 adapter start: 99	-1	TTATTGGTATCAGGGTTAATCGTGCCAAGAAAAGCGGCATGGTCAATATAACCAGTAGTGTTAACAGTCGGGAGAGGAGTGGCATTAACACCATCCTTCGC
+SEQ:1:1101:9494:3983#0/1 adapter start: 72	1	72	101	TAGCACCAAACATAAATCACCTCACTTAAGTGGCTGGAGACAAATAATCTCTTTAATAACCTGATTCAGCGA	GCCTAACTTCTTAGACTGCCTTAAGGACG		adapt
+SEQ:1:1101:9363:3989#0/1 adapter start: 95	-1	CCTCCAAGATTTGGAGGCATGAAAACATACAATTGGGAGGGTGTCAATCCTGACGGTTATTTCCTAGACAAATTAGAGCCAATACCATCAGCTTTGCCTAA
+SEQ:1:1101:9436:3998#0/1 adapter start: 67	1	67	97	TAAATTGTTTGGAGGCGGTCAAAAAGCCGCCTCCGGTGGCATTCAAGGTGATGTGCTTGCTACCGAT	GCCTAACTTCTTAGACTGCCTTAAGGACGT	AACA	adapt
+SEQ:1:1101:9621:3755#0/1	-1	AGCCAATACCATCAGCTTTACCGTCTTTCCAGAAATTGTTCCAAGTATCGGCAACAGCTTTATCAATACCATGAAAAATATCAACCACACCAGAAGCAGCA
+SEQ:1:1101:9738:3756#0/1 adapter start: 1	1	1	31	T	GCCTAACTTCTTAGACTGCCTTAAGGACGT	AAGTCAAAGCACCTTTAGCGTTAAGGTACTGAATCTCTTTAGTCGCAGTAGGCGGAAAACGAACAAGCGC	adapt
+SEQ:1:1101:9580:3761#0/1 adapter start: 49	1	49	79	TATTAAGCTCATTCAGGCTTCTGCCGTTTTGGATTTAACCGAAGATGAT	GCCTAACTTCTTAGACTGCCTTAAGGACGT	TTCGATTTTCTGACGAGTAACA	adapt
+SEQ:1:1101:9533:3764#0/1 adapter start: 20	1	20	50	TCTGTTGAACACGACCAGAA	GCCTAACTTCTTAGACTGCCTTAAGGACGT	AACTGGCCTAACGACGTTTGGTCAGTTCCATCAACATCATAGCCAGATGCC	adapt
+SEQ:1:1101:9636:3775#0/1	-1	ATAAGGCCACGTATTTTGCAAGCTATTTAACTGGCGGCGATTGCGTACCCGACGACCAAAATTAGGGTCAACGCTACCTGTAGGAAGTGTCCGCATAAAGT
+SEQ:1:1101:9554:3781#0/1	-1	CACGCTCTTTTAAAATGTCAACAAGAGAATCTCTACCATGAACAAAATGTGACTCATATCTAAACCAGTCCTTGACGAACGTGCCAAGCATATTAAGCCAC
+SEQ:1:1101:9695:3783#0/1 adapter start: 52	1	52	82	AATAACCCTGAAACAAATGCTTAGGGATTTTATTGGTATCAGGGTTAATCGT	GCCTAACTTCTTAGACTGCCTTAAGGACGT	GCCAAGAAAAGCGGCATGG	adapt
+SEQ:1:1101:9572:3788#0/1	-1	ACCAACACGGCGAGTACAACGGCCCAGCTCAGAAGCGAGAACCAGCTGCGCTTGGGTGGGGCGATGGTGATGGTTTGCATGTTTGGCTCCGGTCTGTAGGC
+SEQ:1:1101:9601:3793#0/1	-1	GCCGCTAATCAGGTTGTTTCTGTTGGTGCTGATATTGCTTTTGATGCCGACCCTAAATTTTTTGCCTGTTTGGTTCGCTTTGAGTCTTCTTCGGTTCCGAC
+SEQ:1:1101:9634:3800#0/1	-1	TTTATGCGGACACTTCCTACAGGTAGCGTTGACCCTAATTTTGGTCGTCGGGTACGCAATCGCCGCCAGTTAAATAGCTTGCAAAATACGTGGCCTTATGG
+SEQ:1:1101:9501:3800#0/1 adapter start: 42	1	42	72	TGACCACCTACATACCAAAGACGAGCGCCTTTACGCTTGCCT	GCCTAACTTCTTAGACTGCCTTAAGGACGT	TTAGTACCTCGCAACGGCTGCGGACGACC	adapt
+SEQ:1:1101:9703:3807#0/1 adapter start: 27	1	27	57	TAATAACCTGATTCAGCGAAACCAATC	GCCTAACTTCTTAGACTGCCTTAAGGACGT	CGCGGCATTTAGTAGCGGTAAAGTTAGACCAAACCATGAAACCA	adapt
+SEQ:1:1101:9728:3808#0/1 adapter start: 7	1	7	37	CAGAAAA	GCCTAACTTCTTAGACTGCCTTAAGGACGT	CCTACCGCGCTTCGCTTGGTCAACCCCTCAGCGGCAAAAATTAAAATTTTTACCGCTTCGGCGT	adapt
+SEQ:1:1101:9676:3812#0/1 adapter start: 1	1	1	31	T	GCCTAACTTCTTAGACTGCCTTAAGGACGT	TATTGCCCGGCGTACGGGGAAGGACGTCAATAGTCACACAGTCCTTGACGGTATAATAACCACCATCATG	adapt
+SEQ:1:1101:9620:3815#0/1	-1	TCGCGTAGAGGCTTTGCTATTCAGCGTTTGATGAATGCAATGCGACAGGCTCATGCTGATGGTTGGTTTATCGTTTTTGACACTCTCACGTTGGCTGACGA
+SEQ:1:1101:9720:3834#0/1 adapter start: 74	1	74	101	TAGACATTTTTACTTTTTATGTCCCTCATCGTCACGTTTATGGTGAACAGTGGATTAAGTTCATGAAGGATGGT	GCCTAACTTCTTAGACTGCCTTAAGGA		adapt
+SEQ:1:1101:9635:3844#0/1 adapter start: 4	1	4	34	GACC	GCCTAACTTCTTAGACTGCCTTAAGGACGT	ATCCAAAGGATAAACATCATAGGCAGTCGGGAGGGTAGTCGGAACCGAAGAAGACTCAAAGCGAACC	adapt
+SEQ:1:1101:9744:3849#0/1 adapter start: 55	1	55	85	AAACATAGTGCCATGCTCAGGAACAAAGAAACGCGGCACAGAATGTTTATAGGTC	GCCTAACTTCTTAGACTGCCTTAAGGACGT	TGTTGAACACGACCAG	adapt
+SEQ:1:1101:9725:3850#0/1	-1	ATAACCCTGAAACAAATGCTTAGGGATTTTATTGGTATCAGGGTTAATCGTGCCAAGAAAAGCGGCATGGTCAATATAACCAGTAGTGTTAACAGTCGGGA
+SEQ:1:1101:9544:3854#0/1	-1	TAGCGGTAAAGTTAGACCAAACCATGAAACCAACATAAACATTATTGCCCGGCGTACGGGGAAGGACGTCAATAGTCACACAGTCCTTGACGGTATAATAA
+SEQ:1:1101:9581:3856#0/1	-1	GGGCGGTGGTCTATAGTGTTATTAATATCAAGTTGGGGGAGCACATTGTAGCATTGTGCCAATTCATCCATTAACTTCTCAGTAACAGATACAAACTCATC
+SEQ:1:1101:9649:3858#0/1 adapter start: 33	1	33	63	CCTCCAAACAATTTAGACATGGCGCCACCAGCA	GCCTAACTTCTTAGACTGCCTTAAGGACGT	AGAGCAGAAGCAATACCGCCAGCAATAGCAACAAACAT	adapt
+SEQ:1:1101:9616:3862#0/1 adapter start: 91	1	91	101	GAATTAAATCGAAGTGGACTGCTGGCGGAAAATGAGAAAATTCGACCTATCCTTGCGCAGCTCGAGAAGCTCTTACTTTGCGACCTTTCGC	GCCTAACTTC		adapt
+SEQ:1:1101:9696:3866#0/1	-1	CAAGTTGCCATACAAAACAGGGTCGCCAGCAATATCGGTATAAGTCAAAGCACCTTTAGCGTTAAGGTACTGAATCTCTTTAGTCGCAGTAGGCGGAAAAC
+SEQ:1:1101:9512:3869#0/1	-1	GCTCGACGCCATTAATAATGTTTTCCGTAAATTCAGCGCCTTCCATGATGAGACAGGCCGTTTGAATGTTGACGGGATGAACATAATAAGCAATGACGGCA
+SEQ:1:1101:9723:3870#0/1 adapter start: 66	1	66	96	CTTTAGCAGCAAGGTATATATCTGACTTTTTGTTAACGTATTTAGCCACATAGCAACCAACAGACA	GCCTAACTTCTTAGACTGCCTTAAGGACGT	TATAA	adapt
+SEQ:1:1101:9667:3874#0/1	-1	CTGCTGCATTTCCTGAGCTTAATGCTTGGGAGCGTGCTGGTGCTGATGCTTCCTCTGCTGGTATGGTTGACGCCGGATTTGAGAATCAAAAAGAGCTTACT
+SEQ:1:1101:9565:3879#0/1 adapter start: 24	1	24	54	AGCCTTATGGCCGTCAACATACAT	GCCTAACTTCTTAGACTGCCTTAAGGACGT	ATCACCATTATCGAACTCAACGCCCTGCATACGAAAAGACAGAATCT	adapt
+SEQ:1:1101:9721:3885#0/1 adapter start: 51	1	51	81	TTCCTCAAACGCTTGTTCGGTGGATAAGTTATGGCATTAATCGATTTATTT	GCCTAACTTCTTAGACTGCCTTAAGGACGT	ATCTCGCGGAAGAAAAACAC	adapt
+SEQ:1:1101:9707:3894#0/1 adapter start: 40	1	40	70	AACACCATCCTTCATGAACTTAATCCACTGTTCACCATAA	GCCTAACTTCTTAGACTGCCTTAAGGACGT	ACGTGACGATGAGGGACATAAAAAGTAAAAA	adapt
+SEQ:1:1101:9560:3900#0/1 adapter start: 6	1	6	36	AGAAGT	GCCTAACTTCTTAGACTGCCTTAAGGACGT	GCCAGCCTGCAACGTACCTTCAAGAAGTCCTTTACCAGCTTTAGCCATAGCACCAGAAACAAAAC	adapt
+SEQ:1:1101:9696:3913#0/1 adapter start: 2	1	2	32	CC	GCCTAACTTCTTAGACTGCCTTAAGGACGT	ATGCTCAGGAACAAAGAAACGCGGCACAGAATGTTTATAGGTCTGTTGAACACGACCAGAAAACTGGCC	adapt
+SEQ:1:1101:9574:3914#0/1 adapter start: 5	1	5	35	GAACA	GCCTAACTTCTTAGACTGCCTTAAGGACGT	AGCGCAAGAGTAAACATAGTGCCATGCTCAGGAACAAAGAAACGCGGCACAGAATGTTTATAGGTC	adapt
+SEQ:1:1101:9508:3931#0/1 adapter start: 91	1	91	101	TAGAGAACGAGAAGACGGTTACGCAGTTTTGCCGCAAGCTGGCTGCTGAACGCCCTCTTAAGGATATTCGCGATGAGTATAATTACCCCAA	GCCTAACTTC		adapt
+SEQ:1:1101:9617:3935#0/1	-1	TAAATTTAATGTGACCGTTTATCGCAATCTGCCGACCACTCGCGATTCAATCATGACTTCGTGATAAAAGATTGAGTGTGAGGTTATAACGCCGAAGCGGT
+SEQ:1:1101:9667:3950#0/1 adapter start: 66	1	66	96	CTTTAGCCATAGCACCAGAAACAAAACTAGGGACGGCCTCATCAGGGTTAGGAACATTAGAGCCTT	GCCTAACTTCTTAGACTGCCTTAAGGACGT	GAATG	adapt
+SEQ:1:1101:9705:3951#0/1 adapter start: 29	1	29	59	ATTGCGTACCCGACGACCAAAATTAGGGT	GCCTAACTTCTTAGACTGCCTTAAGGACGT	CAACGCTACCTGTAGGAAGTGTCCGCATAAAGTGCACCGCAT	adapt
+SEQ:1:1101:9527:3965#0/1	-1	AACATAGTGCCATGCTCAGGAACAAAGAAACGCGGCACAGAATGTTTATAGGTCTGTTGAACACGACCAGAAAACTGGCCTAACGACGTTTGGTCAGTTCC
+SEQ:1:1101:9550:3969#0/1	-1	AGAGTAAACATAGTGCCATGCTCAGGAACAAAGAAACGCGGCACAGAATGTTTATAGGTCTGTTGAACACGACCAGAAAACTGGCCTAACGACGTTTGGTC
+SEQ:1:1101:9636:3973#0/1 adapter start: 9	1	9	39	CAAGCGCAA	GCCTAACTTCTTAGACTGCCTTAAGGACGT	GAGTAAACATAGTGCCATGCTCAGGAACAAAGAAACGCGGCACAGAATGTTTATAGGTCTGT	adapt
+SEQ:1:1101:9726:3981#0/1 adapter start: 66	1	66	96	TTGCTGCCATCTCAAAAACATTTGGACTGCTCCGCTTCCTCCTGAGACTGAGCTTTCTCGCCAAAT	GCCTAACTTCTTAGACTGCCTTAAGGACGT	GACGA	adapt
+SEQ:1:1101:9603:3981#0/1 adapter start: 32	1	32	62	TCTAAGAAGTTTAAGATTGCTGAGGGTCAGTG	GCCTAACTTCTTAGACTGCCTTAAGGACGT	GTATCGTTATGCGCCTTCGTATGTTTCTCCTGCTTATCA	adapt
+SEQ:1:1101:9533:3990#0/1 adapter start: 1	1	1	31	G	GCCTAACTTCTTAGACTGCCTTAAGGACGT	GGGAAGGACGTCAATAGTCACACAGTCCTTGACGGTATAATAACCACCATCATGGCGACCATCCAAAGGA	adapt
+SEQ:1:1101:9583:3992#0/1 adapter start: 20	1	20	50	AAGGTACTGAATCTCTTTAG	GCCTAACTTCTTAGACTGCCTTAAGGACGT	TCGCAGTAGGCGGAAAACGAACAAGCGCAAGAGTAAACATAGTGCCATGCT	adapt
+SEQ:1:1101:9903:3754#0/1	-1	ACCAAAATTAGGGTCAACGCTACCTGTAGGAAGTGTCCGCATAAAGTGCACCGCATGGAAATGAAGACGGCCATCAGCTGTACCATACTCAGGCACACAAA
+SEQ:1:1101:9878:3755#0/1 adapter start: 32	1	32	62	AGAACGTGAAAAAGCGTCCTGCGTGTAGCGAA	GCCTAACTTCTTAGACTGCCTTAAGGACGT	CTGCGATGGGCATACTGTAACCATAAGGCCACGTATTTT	adapt
+SEQ:1:1101:9833:3756#0/1 adapter start: 65	1	65	95	TCATCGTCACGTTTATGGTGAACAGTGGATTAAGTTCATGAAGGATGGTGTTAATGCCACTCCTC	GCCTAACTTCTTAGACTGCCTTAAGGACGT	TCCCGA	adapt
+SEQ:1:1101:9991:3777#0/1	-1	GCTTTGAGTCTTCTTCGGTTCCGACTACCCTCCCGACTGCCTATGATGTTTATCCTTTGGATGGTCGCCATGATGGTGGTTATTATACCGTCAAGGACTGT
diff --git a/tests/cut/illumina5.fastq b/tests/cut/illumina5.fastq
new file mode 100644
index 0000000..1b85887
--- /dev/null
+++ b/tests/cut/illumina5.fastq
@@ -0,0 +1,20 @@
+ at SEQ:1:1101:9010:3891#0/1 adapter start: 51
+ATAACCGGAGTAGTTGAAATGGTAATAAGACGACCAATCTGACCAGCAAGG
++
+FFFFFEDBE at 79@@>@CBCBFDBDFDDDDD<@C>ADD at B;5:978 at CBDDF
+ at SEQ:1:1101:9240:3898#0/1
+CCAGCAAGGAAGCCAAGATGGGAAAGGTCATGCGGCATACGCTCGGCGCCAGTTTGAATATTAGACATAATTTATCCTCAAGTAAGGGGCCGAAGCCCCTG
++
+GHGHGHHHHGGGDHHGDCGFEEFHHGDFGEHHGFHHHHHGHEAFDHHGFHHEEFHGHFHHFHGEHFBHHFHHHH at GGGDGDFEEFC@=D?GBGFGF:FB6D
+ at SEQ:1:1101:9207:3899#0/1 adapter start: 64
+TTAACTTCTCAGTAACAGATACAAACTCATCACGAACGTCAGAAGCAGCCTTATGGCCGTCAAC
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHFHHHHHHCFHHF
+ at SEQ:1:1101:9148:3908#0/1 adapter start: 28
+ACGACGCAATGGAGAAAGACGGAGAGCG
++
+HHHHHHHHHHHHGHHHHGHHHHHHHHHH
+ at SEQ:1:1101:9044:3916#0/1 adapter start: 78
+AACAGAAGGAGTCTACTGCTCGCGTTGCGTCTATTATGGAAAACACCAATCTTTCCAAGCAACAGCAGGTTTCCGAGA
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHGHHHHGHHHHHHHHHHHHFHEBFHFFEFHE
diff --git a/tests/cut/illumina5.info.txt b/tests/cut/illumina5.info.txt
new file mode 100644
index 0000000..eb2e7dc
--- /dev/null
+++ b/tests/cut/illumina5.info.txt
@@ -0,0 +1,8 @@
+SEQ:1:1101:9010:3891#0/1 adapter start: 51	0	64	81	ATAACCGGAGTAGTTGAAATGGTAATAAGACGACCAATCTGACCAGCAAGGGCCTAACTTCTTA	GACTGCCTTAAGGACGT	AAGCCAAGATGGGAAAGGTC	adapt2
+SEQ:1:1101:9010:3891#0/1 adapter start: 51	1	51	64	ATAACCGGAGTAGTTGAAATGGTAATAAGACGACCAATCTGACCAGCAAGG	GCCTAACTTCTTA		adapt
+SEQ:1:1101:9240:3898#0/1	-1	CCAGCAAGGAAGCCAAGATGGGAAAGGTCATGCGGCATACGCTCGGCGCCAGTTTGAATATTAGACATAATTTATCCTCAAGTAAGGGGCCGAAGCCCCTG
+SEQ:1:1101:9207:3899#0/1 adapter start: 64	0	77	94	TTAACTTCTCAGTAACAGATACAAACTCATCACGAACGTCAGAAGCAGCCTTATGGCCGTCAACGCCTAACTTCTTA	GACTGCCTTAAGGACGT	ATACATA	adapt2
+SEQ:1:1101:9207:3899#0/1 adapter start: 64	1	64	77	TTAACTTCTCAGTAACAGATACAAACTCATCACGAACGTCAGAAGCAGCCTTATGGCCGTCAAC	GCCTAACTTCTTA		adapt
+SEQ:1:1101:9148:3908#0/1 adapter start: 28	0	41	58	ACGACGCAATGGAGAAAGACGGAGAGCGGCCTAACTTCTTA	GACTGCCTTAAGGACGT	CCAACGGCGTCCATCTCGAAGGAGTCGCCAGCGATAACCGGAG	adapt2
+SEQ:1:1101:9148:3908#0/1 adapter start: 28	1	28	41	ACGACGCAATGGAGAAAGACGGAGAGCG	GCCTAACTTCTTA		adapt
+SEQ:1:1101:9044:3916#0/1 adapter start: 78	1	78	91	AACAGAAGGAGTCTACTGCTCGCGTTGCGTCTATTATGGAAAACACCAATCTTTCCAAGCAACAGCAGGTTTCCGAGA	GCCTAACTTCTTA	GACTGCCTTA	adapt
diff --git a/tests/cut/illumina64.fastq b/tests/cut/illumina64.fastq
new file mode 100644
index 0000000..bbfce73
--- /dev/null
+++ b/tests/cut/illumina64.fastq
@@ -0,0 +1,80 @@
+ at 14569
+AAGTTTATTCCTGGACGAAGGAAGAAAAGGCCAGATGGGAAACAAGAACAAGCCCCTGTTGAAGACGCAGGGCC
++
+cceeeeceeeee`dedbdbdb_^b`abU_cacadabd`dLMZ[XTcT^a^adaaaddcd`aL^`^_`Y\]^`Y_
+ at 19211
+AGA
++
+^\`
+ at 9180
+GAGGG
++
+b`bLb
+ at 19132
+TGTGATTATCCACTGGTATAT
++
+Z[QZZLZ[]J[SHZNaZ[_Ia
+ at 15868
+CTGCCAAGGCTGCCCCCAAA
++
+`c`cc\`\Lb]bL`[`a]L`
+ at 1424
+GGCCCCAGACTTGCTCCCCCAACAAGGACAATGTCCAAGGAGTGTCCCC
++
+eeeeeeeea`bbdaaadad`Oaaaaccada_aa_d`_X`_^`[`_[_W^
+ at 7855
+GTGGGGGCT
++
+]^\]FW]Z`
+ at 17943
+ACATGGGACCAGAAAACACCACCAGGGGTTTGGGGCTGTCCTGAG
++
+ccc`\^`aba\b^`\FR`OOPYG[[W```[Ra_RR_\]\\P\_H_
+ at 11100
+CGGATAACTGAAAATGCATTTTTAACGCCATGACCGTGTCTCAAGGACCCGCTGTGGAAG
++
+b`b_b_a\bc^Tabadaddcddd``bdaa_^aJ\^_\]\\__O[___L^\_aaa^^^UJ^
+ at 15663
+AGGT
++
+aaKa
+ at 4698
+CCAATTGGCACCCCTCTGCCTTCAGCCATT
++
+cccc\`ccc\caccZccccc]^`LY\bL_b
+ at 20649
+TCTGGACTGGATCTTTAGGATGGTGGAGATGATCTGGATGTAGGACAAAAGAACCAGGCAGAAGGGTG
++
+eeeeeaddadacdddebeccdddadd\^abbT_]bccTac]]b]L^][]Ve[^ZaY_^_^`\\Y]^Y`
+ at 17259
+
++
+
+ at 6003
+CTTCAACTCATCTTGTTATTAATACCATCAATATCCCATGAGGCTCATAAAACGAGTCTTTCTTCTTGGAAACATGACCAAGATTGGGCAAACGT
++
+fffffffffffffffffdffecfcefeffdcfdeeebbbdbccccc\db\`^aa`^Y^^^cbcbaa`bbWY^^^__S_YYR]GWY]\]]XX\_`S
+ at 4118
+TCAAATTGTACTGCAAAGAAGGTCCCAGCTGGTCTCTTCTGGGAGTGATCTAACTAACTTAAG
++
+dc^ddeeeeeedeee`ceceddadadddcbde_dedc_ec_a^^b\b\\]VIPZY^T^^^\L_
+ at 18416
+GTGGGGAAGCCGAAGAAGCAGCGGAGATCGATTGTAAGAACGACG
++
+dddacaabdbea\d^cce\da`dd_^__`a`a`b[_^__^\^^^_
+ at 20115
+TGAAAAAGGAAAACATGGTAGTTTTCTTGTATGAGAGAGCCAGAGCCACCTTGGAGATTTTGTTCTCTCTGTGCG
++
+ed^eeafffaddfecdddabc^_badd`bd_ddadaa^bbcad\d\__^_\aaa_aY____aaN_\cdc\^aaYb
+ at 16139
+TCATCCGAAGAGTTGGCAGGCCCTGTGAATTGTGAAAACAGTATACCCACCCCTTTCCC
++
+cabacacY^c\daaddaadad^\ad_a\Y`[ZQ]Y^^OYQ^X^YT\\]U\^RRX^\YJ^
+ at 14123
+GATTTGGGGAAAGGAAACAATAGTTGAGTTTGGGCCACGGGAAATTCAAGATGCCTGGTATGTC
++
+cccccccac^bYbbT_aa_Yb^^Ta\\^]]aaTaaaaab\b\XL`VZZV]QYYY[aa^^^^_^^
+ at 8766
+ACCTGTAAGGTCCGCTCCTGGTGGACACCCACGAAGTCCAGGGCCTCAGGCAGGAAGTTGTAGCGCAGAGTTTTGAGCAGCTGCTCCATC
++
+fcfffffcffeffeeefdefddeecdccacddfdYd`d^\_^`\_abbc\b[ba^Y^Z_^^H^Z_^Y_Y_OKWPZR]]Z]`Z``Z^UHZ^
diff --git a/tests/cut/issue46.fasta b/tests/cut/issue46.fasta
new file mode 100644
index 0000000..0bc0403
--- /dev/null
+++ b/tests/cut/issue46.fasta
@@ -0,0 +1,2 @@
+>readname
+A
diff --git a/tests/cut/lowercase.fastq b/tests/cut/lowercase.fastq
new file mode 100644
index 0000000..a3437d1
--- /dev/null
+++ b/tests/cut/lowercase.fastq
@@ -0,0 +1,12 @@
+ at prefix:1_13_573/1
+CGTCCGAANTAGCTACCACCCTGA
++
+)3%)&&&&!.1&(6:<'67..*,:
+ at prefix:1_13_1259/1
+AGCCGCTANGACGGGTTGGCCC
++
+;<:&:A;A!9<<<,7:<=3=;:
+ at prefix:1_13_1440/1
+CAAGATCTNCCCTGCCACATTGCCCTAGTTAAAC
++
+<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
diff --git a/tests/cut/lowqual.fastq b/tests/cut/lowqual.fastq
new file mode 100644
index 0000000..58c5a65
--- /dev/null
+++ b/tests/cut/lowqual.fastq
@@ -0,0 +1,8 @@
+ at first_sequence
+
++
+
+ at second_sequence
+
++
+
diff --git a/tests/cut/maxlen.fa b/tests/cut/maxlen.fa
new file mode 100644
index 0000000..8b4729b
--- /dev/null
+++ b/tests/cut/maxlen.fa
@@ -0,0 +1,14 @@
+>read_length0a
+T
+>read_length0b
+T
+>read_length1
+T2
+>read_length2
+T02
+>read_length3
+T302
+>read_length4
+T3302
+>read_length5
+T23302
diff --git a/tests/cut/maxn0.2.fasta b/tests/cut/maxn0.2.fasta
new file mode 100644
index 0000000..0255fc7
--- /dev/null
+++ b/tests/cut/maxn0.2.fasta
@@ -0,0 +1,6 @@
+>r1
+
+>r3
+AAAA
+>r4
+AAAAN
diff --git a/tests/cut/maxn0.4.fasta b/tests/cut/maxn0.4.fasta
new file mode 100644
index 0000000..9c830e5
--- /dev/null
+++ b/tests/cut/maxn0.4.fasta
@@ -0,0 +1,8 @@
+>r1
+
+>r3
+AAAA
+>r4
+AAAAN
+>r5
+AAANN
diff --git a/tests/cut/maxn0.fasta b/tests/cut/maxn0.fasta
new file mode 100644
index 0000000..d448df2
--- /dev/null
+++ b/tests/cut/maxn0.fasta
@@ -0,0 +1,4 @@
+>r1
+
+>r3
+AAAA
diff --git a/tests/cut/maxn1.fasta b/tests/cut/maxn1.fasta
new file mode 100644
index 0000000..4edae80
--- /dev/null
+++ b/tests/cut/maxn1.fasta
@@ -0,0 +1,8 @@
+>r1
+
+>r2
+N
+>r3
+AAAA
+>r4
+AAAAN
diff --git a/tests/cut/maxn2.fasta b/tests/cut/maxn2.fasta
new file mode 100644
index 0000000..3eb7ba2
--- /dev/null
+++ b/tests/cut/maxn2.fasta
@@ -0,0 +1,10 @@
+>r1
+
+>r2
+N
+>r3
+AAAA
+>r4
+AAAAN
+>r5
+AAANN
diff --git a/tests/cut/minlen.fa b/tests/cut/minlen.fa
new file mode 100644
index 0000000..fa9b0fe
--- /dev/null
+++ b/tests/cut/minlen.fa
@@ -0,0 +1,16 @@
+>read_length5
+T23302
+>read_length6
+T023302
+>read_length7
+T1023302
+>read_length8
+T11023302
+>read_length9
+T111023302
+>read_length10
+T2111023302
+>read_length11
+T02111023302
+>read_length12
+T002111023302
diff --git a/tests/cut/minlen.noprimer.fa b/tests/cut/minlen.noprimer.fa
new file mode 100644
index 0000000..1befe6e
--- /dev/null
+++ b/tests/cut/minlen.noprimer.fa
@@ -0,0 +1,14 @@
+>read_length6
+23302
+>read_length7
+023302
+>read_length8
+1023302
+>read_length9
+11023302
+>read_length10
+111023302
+>read_length11
+2111023302
+>read_length12
+02111023302
diff --git a/tests/cut/no-trim.fastq b/tests/cut/no-trim.fastq
new file mode 100644
index 0000000..d3668fd
--- /dev/null
+++ b/tests/cut/no-trim.fastq
@@ -0,0 +1,4 @@
+ at prefix:1_13_1440/1
+CAAGATCTNCCCTGCCACATTGCCCTAGTTAAAC
++
+<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
diff --git a/tests/cut/overlapa.fa b/tests/cut/overlapa.fa
new file mode 100644
index 0000000..a4ad60d
--- /dev/null
+++ b/tests/cut/overlapa.fa
@@ -0,0 +1,40 @@
+>read1
+T0021110233021
+>read2
+T0021110233021
+>read3
+T0021110233021
+>read4
+T0021110233021
+>read5
+T0021110233021
+>read6
+T0021110233021
+>read7
+T0021110233021
+>read8
+T0021110233021
+>read9
+T0021110233021
+>read10
+T0021110233021330201030
+>read11
+T002111023302133020103
+>read12
+T00211102330213302010
+>read13
+T0021110233021330201
+>read14
+T002111023302133020
+>read15
+T00211102330213302
+>read16
+T0021110233021330
+>read17
+T002111023302133
+>read18
+T00211102330213
+>read19
+T0021110233021
+>read20
+T002111023302
diff --git a/tests/cut/overlapb.fa b/tests/cut/overlapb.fa
new file mode 100644
index 0000000..decf1d3
--- /dev/null
+++ b/tests/cut/overlapb.fa
@@ -0,0 +1,38 @@
+>adaptlen18
+ATACTTACCCGTA
+>adaptlen17
+ATACTTACCCGTA
+>adaptlen16
+ATACTTACCCGTA
+>adaptlen15
+ATACTTACCCGTA
+>adaptlen14
+ATACTTACCCGTA
+>adaptlen13
+ATACTTACCCGTA
+>adaptlen12
+ATACTTACCCGTA
+>adaptlen11
+ATACTTACCCGTA
+>adaptlen10
+ATACTTACCCGTA
+>adaptlen9
+TCTCCGTCGATACTTACCCGTA
+>adaptlen8
+CTCCGTCGATACTTACCCGTA
+>adaptlen7
+TCCGTCGATACTTACCCGTA
+>adaptlen6
+CCGTCGATACTTACCCGTA
+>adaptlen5
+CGTCGATACTTACCCGTA
+>adaptlen4
+GTCGATACTTACCCGTA
+>adaptlen3
+TCGATACTTACCCGTA
+>adaptlen2
+CGATACTTACCCGTA
+>adaptlen1
+GATACTTACCCGTA
+>adaptlen0
+ATACTTACCCGTA
diff --git a/tests/cut/paired-m27.1.fastq b/tests/cut/paired-m27.1.fastq
new file mode 100644
index 0000000..3f2d733
--- /dev/null
+++ b/tests/cut/paired-m27.1.fastq
@@ -0,0 +1,16 @@
+ at read1/1 some text
+TTATTTGTCTCCAGCTTAGACATATCGCCT
++
+##HHHHHHHHHHHHHHHHHHHHHHHHHHHH
+ at read2/1
+CAACAGGCCACATTAGACATATCGGATGGT
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
+ at read3/1
+CCAACTTGATATTAATAACATTAGACA
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHH
+ at read4/1
+GACAGGCCGTTTGAATGTTGACGGGATGTT
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
diff --git a/tests/cut/paired-m27.2.fastq b/tests/cut/paired-m27.2.fastq
new file mode 100644
index 0000000..808df31
--- /dev/null
+++ b/tests/cut/paired-m27.2.fastq
@@ -0,0 +1,16 @@
+ at read1/2 other text
+GCTGGAGACAAATAACAGTGGAGTAGTTTT
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
+ at read2/2
+TGTGGCCTGTTGCAGTGGAGTAACTCCAGC
++
+###HHHHHHHHHHHHHHHHHHHHHHHHHHH
+ at read3/2
+TGTTATTAATATCAAGTTGGCAGTG
++
+#HHHHHHHHHHHHHHHHHHHHHHHH
+ at read4/2
+CATCCCGTCAACATTCAAACGGCCTGTCCA
++
+HH############################
diff --git a/tests/cut/paired-onlyA.1.fastq b/tests/cut/paired-onlyA.1.fastq
new file mode 100644
index 0000000..3f2d733
--- /dev/null
+++ b/tests/cut/paired-onlyA.1.fastq
@@ -0,0 +1,16 @@
+ at read1/1 some text
+TTATTTGTCTCCAGCTTAGACATATCGCCT
++
+##HHHHHHHHHHHHHHHHHHHHHHHHHHHH
+ at read2/1
+CAACAGGCCACATTAGACATATCGGATGGT
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
+ at read3/1
+CCAACTTGATATTAATAACATTAGACA
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHH
+ at read4/1
+GACAGGCCGTTTGAATGTTGACGGGATGTT
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
diff --git a/tests/cut/paired-onlyA.2.fastq b/tests/cut/paired-onlyA.2.fastq
new file mode 100644
index 0000000..15354e0
--- /dev/null
+++ b/tests/cut/paired-onlyA.2.fastq
@@ -0,0 +1,16 @@
+ at read1/2 other text
+GCTGGAGACAAATAA
++
+HHHHHHHHHHHHHHH
+ at read2/2
+TGTGGCCTGTTG
++
+###HHHHHHHHH
+ at read3/2
+TGTTATTAATATCAAGTTGG
++
+#HHHHHHHHHHHHHHHHHHH
+ at read4/2
+CATCCCGTCAACATTCAAACGGCCTGTCCA
++
+HH############################
diff --git a/tests/cut/paired-separate.1.fastq b/tests/cut/paired-separate.1.fastq
new file mode 100644
index 0000000..a8b2b28
--- /dev/null
+++ b/tests/cut/paired-separate.1.fastq
@@ -0,0 +1,16 @@
+ at read1/1 some text
+TTATTTGTCTCCAGC
++
+##HHHHHHHHHHHHH
+ at read2/1
+CAACAGGCCACA
++
+HHHHHHHHHHHH
+ at read3/1
+CCAACTTGATATTAATAACA
++
+HHHHHHHHHHHHHHHHHHHH
+ at read4/1
+GACAGGCCGTTTGAATGTTGACGGGATGTT
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
diff --git a/tests/cut/paired-separate.2.fastq b/tests/cut/paired-separate.2.fastq
new file mode 100644
index 0000000..15354e0
--- /dev/null
+++ b/tests/cut/paired-separate.2.fastq
@@ -0,0 +1,16 @@
+ at read1/2 other text
+GCTGGAGACAAATAA
++
+HHHHHHHHHHHHHHH
+ at read2/2
+TGTGGCCTGTTG
++
+###HHHHHHHHH
+ at read3/2
+TGTTATTAATATCAAGTTGG
++
+#HHHHHHHHHHHHHHHHHHH
+ at read4/2
+CATCCCGTCAACATTCAAACGGCCTGTCCA
++
+HH############################
diff --git a/tests/cut/paired-trimmed.1.fastq b/tests/cut/paired-trimmed.1.fastq
new file mode 100644
index 0000000..fb3f459
--- /dev/null
+++ b/tests/cut/paired-trimmed.1.fastq
@@ -0,0 +1,12 @@
+ at read1/1 some text
+TTATTTGTCTCCAGC
++
+##HHHHHHHHHHHHH
+ at read2/1
+CAACAGGCCACA
++
+HHHHHHHHHHHH
+ at read3/1
+CCAACTTGATATTAATAACA
++
+HHHHHHHHHHHHHHHHHHHH
diff --git a/tests/cut/paired-trimmed.2.fastq b/tests/cut/paired-trimmed.2.fastq
new file mode 100644
index 0000000..1feef27
--- /dev/null
+++ b/tests/cut/paired-trimmed.2.fastq
@@ -0,0 +1,12 @@
+ at read1/2 other text
+GCTGGAGACAAATAACAGTGGAGTAGTTTT
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
+ at read2/2
+TGTGGCCTGTTGCAGTGGAGTAACTCCAGC
++
+###HHHHHHHHHHHHHHHHHHHHHHHHHHH
+ at read3/2
+TGTTATTAATATCAAGTTGGCAGTG
++
+#HHHHHHHHHHHHHHHHHHHHHHHH
diff --git a/tests/cut/paired-untrimmed.1.fastq b/tests/cut/paired-untrimmed.1.fastq
new file mode 100644
index 0000000..8ab53bd
--- /dev/null
+++ b/tests/cut/paired-untrimmed.1.fastq
@@ -0,0 +1,4 @@
+ at read4/1
+GACAGGCCGTTTGAATGTTGACGGGATGTT
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
diff --git a/tests/cut/paired-untrimmed.2.fastq b/tests/cut/paired-untrimmed.2.fastq
new file mode 100644
index 0000000..ca52d30
--- /dev/null
+++ b/tests/cut/paired-untrimmed.2.fastq
@@ -0,0 +1,4 @@
+ at read4/2
+CATCCCGTCAACATTCAAACGGCCTGTCCA
++
+HH############################
diff --git a/tests/cut/paired.1.fastq b/tests/cut/paired.1.fastq
new file mode 100644
index 0000000..d6f246d
--- /dev/null
+++ b/tests/cut/paired.1.fastq
@@ -0,0 +1,12 @@
+ at read1/1 some text
+TTATTTGTCTCCAGC
++
+##HHHHHHHHHHHHH
+ at read3/1
+CCAACTTGATATTAATAACA
++
+HHHHHHHHHHHHHHHHHHHH
+ at read4/1
+GACAGGCCGTTTGAATGTTGACGGGATGTT
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
diff --git a/tests/cut/paired.2.fastq b/tests/cut/paired.2.fastq
new file mode 100644
index 0000000..eb4df03
--- /dev/null
+++ b/tests/cut/paired.2.fastq
@@ -0,0 +1,12 @@
+ at read1/2 other text
+GCTGGAGACAAATAA
++
+HHHHHHHHHHHHHHH
+ at read3/2
+TGTTATTAATATCAAGTTGG
++
+#HHHHHHHHHHHHHHHHHHH
+ at read4/2
+CATCCCGTCAACATTCAAACGGCCTGTCCA
++
+HH############################
diff --git a/tests/cut/paired.m14.1.fastq b/tests/cut/paired.m14.1.fastq
new file mode 100644
index 0000000..d6f246d
--- /dev/null
+++ b/tests/cut/paired.m14.1.fastq
@@ -0,0 +1,12 @@
+ at read1/1 some text
+TTATTTGTCTCCAGC
++
+##HHHHHHHHHHHHH
+ at read3/1
+CCAACTTGATATTAATAACA
++
+HHHHHHHHHHHHHHHHHHHH
+ at read4/1
+GACAGGCCGTTTGAATGTTGACGGGATGTT
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
diff --git a/tests/cut/paired.m14.2.fastq b/tests/cut/paired.m14.2.fastq
new file mode 100644
index 0000000..3cb5248
--- /dev/null
+++ b/tests/cut/paired.m14.2.fastq
@@ -0,0 +1,12 @@
+ at read1/2 other text
+GCTGGAGACAAATAACAGTGGAGTAGTTTT
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
+ at read3/2
+TGTTATTAATATCAAGTTGGCAGTG
++
+#HHHHHHHHHHHHHHHHHHHHHHHH
+ at read4/2
+CATCCCGTCAACATTCAAACGGCCTGTCCA
++
+HH############################
diff --git a/tests/cut/pairedq.1.fastq b/tests/cut/pairedq.1.fastq
new file mode 100644
index 0000000..e248176
--- /dev/null
+++ b/tests/cut/pairedq.1.fastq
@@ -0,0 +1,8 @@
+ at read1/1 some text
+TTATTTGTCTCCAGC
++
+##HHHHHHHHHHHHH
+ at read3/1
+CCAACTTGATATTAATAACA
++
+HHHHHHHHHHHHHHHHHHHH
diff --git a/tests/cut/pairedq.2.fastq b/tests/cut/pairedq.2.fastq
new file mode 100644
index 0000000..306314e
--- /dev/null
+++ b/tests/cut/pairedq.2.fastq
@@ -0,0 +1,8 @@
+ at read1/2 other text
+GCTGGAGACAAATAA
++
+HHHHHHHHHHHHHHH
+ at read3/2
+TGTTATTAATATCAAGTTGG
++
+#HHHHHHHHHHHHHHHHHHH
diff --git a/tests/cut/pairedu.1.fastq b/tests/cut/pairedu.1.fastq
new file mode 100644
index 0000000..7688970
--- /dev/null
+++ b/tests/cut/pairedu.1.fastq
@@ -0,0 +1,16 @@
+ at read1/1 some text
+TTTGTCTCCAGCTTAGACATATCGCC
++
+HHHHHHHHHHHHHHHHHHHHHHHHHH
+ at read2/1
+CAGGCCACATTAGACATATCGGATGG
++
+HHHHHHHHHHHHHHHHHHHHHHHHHH
+ at read3/1
+ACTTGATATTAATAACATTAGAC
++
+HHHHHHHHHHHHHHHHHHHHHHH
+ at read4/1
+AGGCCGTTTGAATGTTGACGGGATGT
++
+HHHHHHHHHHHHHHHHHHHHHHHHHH
diff --git a/tests/cut/pairedu.2.fastq b/tests/cut/pairedu.2.fastq
new file mode 100644
index 0000000..dbd88d7
--- /dev/null
+++ b/tests/cut/pairedu.2.fastq
@@ -0,0 +1,16 @@
+ at read1/2 other text
+GAGACAAATAACAGTGGAGTAGTT
++
+HHHHHHHHHHHHHHHHHHHHHHHH
+ at read2/2
+GCCTGTTGCAGTGGAGTAACTCCA
++
+HHHHHHHHHHHHHHHHHHHHHHHH
+ at read3/2
+ATTAATATCAAGTTGGCAG
++
+HHHHHHHHHHHHHHHHHHH
+ at read4/2
+CCGTCAACATTCAAACGGCCTGTC
++
+########################
diff --git a/tests/cut/plus.fastq b/tests/cut/plus.fastq
new file mode 100644
index 0000000..35849f8
--- /dev/null
+++ b/tests/cut/plus.fastq
@@ -0,0 +1,8 @@
+ at first_sequence some other text
+SEQUENCE1
++first_sequence some other text
+:6;;8<=:<
+ at second_sequence and more text
+SEQUENCE2
++second_sequence and more text
+83<??:(61
diff --git a/tests/cut/polya.fasta b/tests/cut/polya.fasta
new file mode 100644
index 0000000..9b12d5c
--- /dev/null
+++ b/tests/cut/polya.fasta
@@ -0,0 +1,2 @@
+>polyAlong
+CTTAGTTCAATWTTAACCAAACTTCAGAACAG
diff --git a/tests/cut/rest.fa b/tests/cut/rest.fa
new file mode 100644
index 0000000..79c64cd
--- /dev/null
+++ b/tests/cut/rest.fa
@@ -0,0 +1,18 @@
+>read1
+TESTING
+>read2
+TESTING
+>read3
+TESTING
+>read4
+TESTING
+>read5
+TESTING
+>read6
+SOMETHING
+>read7
+SOMETHING
+>read8
+REST
+>read9
+NOREST
diff --git a/tests/cut/restfront.fa b/tests/cut/restfront.fa
new file mode 100644
index 0000000..8b51e6c
--- /dev/null
+++ b/tests/cut/restfront.fa
@@ -0,0 +1,18 @@
+>read1
+REST1
+>read2
+RESTING
+>read3
+
+>read4
+RESTLESS
+>read5
+RESTORE
+>read6
+SOMETHING
+>read7
+SOMETHING
+>read8
+SOMETHING
+>read9
+NOREST
diff --git a/tests/cut/s_1_sequence.txt b/tests/cut/s_1_sequence.txt
new file mode 100644
index 0000000..f728223
--- /dev/null
+++ b/tests/cut/s_1_sequence.txt
@@ -0,0 +1,8 @@
+ at first_sequence
+SEQUENCE1
++
+:6;;8<=:<
+ at second_sequence
+SEQUENCE2
++
+83<??:(61
diff --git a/tests/cut/small.fastq b/tests/cut/small.fastq
new file mode 100644
index 0000000..a3437d1
--- /dev/null
+++ b/tests/cut/small.fastq
@@ -0,0 +1,12 @@
+ at prefix:1_13_573/1
+CGTCCGAANTAGCTACCACCCTGA
++
+)3%)&&&&!.1&(6:<'67..*,:
+ at prefix:1_13_1259/1
+AGCCGCTANGACGGGTTGGCCC
++
+;<:&:A;A!9<<<,7:<=3=;:
+ at prefix:1_13_1440/1
+CAAGATCTNCCCTGCCACATTGCCCTAGTTAAAC
++
+<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
diff --git a/tests/cut/small.trimmed.fastq b/tests/cut/small.trimmed.fastq
new file mode 100644
index 0000000..ecb1729
--- /dev/null
+++ b/tests/cut/small.trimmed.fastq
@@ -0,0 +1,8 @@
+ at prefix:1_13_573/1
+CGTCCGAANTAGCTACCACCCTGA
++
+)3%)&&&&!.1&(6:<'67..*,:
+ at prefix:1_13_1259/1
+AGCCGCTANGACGGGTTGGCCC
++
+;<:&:A;A!9<<<,7:<=3=;:
diff --git a/tests/cut/small.untrimmed.fastq b/tests/cut/small.untrimmed.fastq
new file mode 100644
index 0000000..d3668fd
--- /dev/null
+++ b/tests/cut/small.untrimmed.fastq
@@ -0,0 +1,4 @@
+ at prefix:1_13_1440/1
+CAAGATCTNCCCTGCCACATTGCCCTAGTTAAAC
++
+<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
diff --git a/tests/cut/solid-no-zerocap.fastq b/tests/cut/solid-no-zerocap.fastq
new file mode 100644
index 0000000..c666d5c
--- /dev/null
+++ b/tests/cut/solid-no-zerocap.fastq
@@ -0,0 +1,120 @@
+ at 1_13_85_F3
+T110020300.0113010210002110102330021
++
+7&9<&77)& <7))%4'657-1+9;9,.<8);.;8
+ at 1_13_573_F3
+T312311200.30213011011132
++
+6)3%)&&&& .1&(6:<'67..*,
+ at 1_13_1259_F3
+T002112130.201222332211
++
+=;<:&:A;A 9<<<,7:<=3=;
+ at 1_13_1440_F3
+T110020313.1113211010332111302330001
++
+=<=A:A=57 7<';<6?5;;6:+:=)71>70<,=:
+ at 1_14_177_F3
+T31330222020233321121323302013303311
++
+:8957;;54)'98924905;;)6:7;1:3<88(9:
+ at 1_14_238_F3
+T0133103120031002212223
++
+?><5=;<<<12>=<;1;;=5);
+ at 1_15_1098_F3
+T32333033222233020223032312232220332
++
+#,##(#5##*#($$'#.##)$&#%)$1##-$&##%
+ at 1_16_404_F3
+T03310320002130202331112
++
+78;:;;><>9=9;<<2=><<1;5
+ at 1_16_904_F3
+T21230102331022312232132021122111212
++
+9>=::6;;99=+/'$+#.#&%$&'(($1*$($.#.
+ at 1_16_1315_F3
+T032312311122103330103103
++
+<9<8A?>?::;6&,%;6/)8<<#/
+ at 1_16_1595_F3
+T22323211312111230022210011213302012
++
+>,<=<>@6<;?<=>:/=.>&;;8;)17:=&,>1=+
+ at 1_17_1379_F3
+T32011212111223230232132311321200123
++
+/-1179<1;>>8:':7-%/::0&+=<29,7<8(,2
+ at 1_18_1692_F3
+T12322233031100211233323300112200210
++
+.#(###5%)%2)',2&:+#+&5,($/1#&4&))$6
+ at 1_19_171_F3
+T10101101220213201111011320201230032
++
+)6:65/=3*:(8%)%2>&8&%;%0&#;$3$&:$#&
+ at 1_22_72_F3
+T13303032323221212301322233320210233
++
+3/#678<:.=9::6:(<538295;9+;&*;)+',&
+ at 1_22_1377_F3
+T22221333311222312201132312022322300
++
+)##0%.$.1*%,)95+%%14%$#8-###9-()#9+
+ at 1_23_585_F3
+T300103103101303121221
++
+>55;8><96/18?)<3<58<5
+ at 1_23_809_F3
+T13130101101021211013220302223302112
++
+:7<59@;<<5;/9;=<;7::.)&&&827(+221%(
+ at 1_24_138_F3
+T33211130100120323002
++
+6)68/;906#,25/&;<$0+
+ at 1_24_206_F3
+T33330332002223002020303331321221000
++
+))4(&)9592)#)694(,)292:(=7$.18,()65
+ at 1_25_143_F3
+T23202003031200220301303302012203132
++
+:4;/#&<9;&*;95-7;85&;587#16>%&,9<2&
+ at 1_25_1866_F3
+T03201321022131101112012330221130311
++
+=<>9;<@7?(=6,<&?=6=(=<641:?'<1=;':4
+ at 1_27_584_F3
+T10010330110103213112323303012103101
++
+82'('*.-8+%#2)(-&3.,.2,),+.':&,'(&/
+ at 1_27_1227_F3
+T02003022123001003201002031303302011
++
+492:;>A:<;34<<=);:<<;9=7<3::<::3=>'
+ at 1_27_1350_F3
+T13130101101021211013220222221301231
++
+95,)<(4./;<938=64=+2/,.4),3':97#33&
+ at 1_29_477_F3
+T13130101101021211013300302223003030
++
+94=55:75=+:/7><968;;#&+$#3&6,#1#4#'
+ at 1_30_882_F3
+T20102033000233
++
+2(+-:-3<;5##/;
+ at 1_31_221_F3
+T03301311201100030300100233220102031
++
+89>9>5<139/,&:7969972.274&%:78&&746
+ at 1_31_1313_F3
+T0133113130033012232100010101
++
+;3<7=7::)5*4=&;<7>4;795065;9
+ at 1_529_129_F3
+T132222301020322102101322221322302.3302.3.3..221..3
++
+>>%/((B6-&5A0:6)>;'1)B*38/?(5=%B+ &<-9 % @  )%)  (
diff --git a/tests/cut/solid.fasta b/tests/cut/solid.fasta
new file mode 100644
index 0000000..5428e58
--- /dev/null
+++ b/tests/cut/solid.fasta
@@ -0,0 +1,4 @@
+>problem1
+T0112021202222201123121023103020
+>problem2
+T20201030313112322220210
diff --git a/tests/cut/solid.fastq b/tests/cut/solid.fastq
new file mode 100644
index 0000000..ab2927a
--- /dev/null
+++ b/tests/cut/solid.fastq
@@ -0,0 +1,120 @@
+ at 1_13_85_F3
+T110020300.0113010210002110102330021
++
+7&9<&77)&!<7))%4'657-1+9;9,.<8);.;8
+ at 1_13_573_F3
+T312311200.30213011011132
++
+6)3%)&&&&!.1&(6:<'67..*,
+ at 1_13_1259_F3
+T002112130.201222332211
++
+=;<:&:A;A!9<<<,7:<=3=;
+ at 1_13_1440_F3
+T110020313.1113211010332111302330001
++
+=<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
+ at 1_14_177_F3
+T31330222020233321121323302013303311
++
+:8957;;54)'98924905;;)6:7;1:3<88(9:
+ at 1_14_238_F3
+T0133103120031002212223
++
+?><5=;<<<12>=<;1;;=5);
+ at 1_15_1098_F3
+T32333033222233020223032312232220332
++
+#,##(#5##*#($$'#.##)$&#%)$1##-$&##%
+ at 1_16_404_F3
+T03310320002130202331112
++
+78;:;;><>9=9;<<2=><<1;5
+ at 1_16_904_F3
+T21230102331022312232132021122111212
++
+9>=::6;;99=+/'$+#.#&%$&'(($1*$($.#.
+ at 1_16_1315_F3
+T032312311122103330103103
++
+<9<8A?>?::;6&,%;6/)8<<#/
+ at 1_16_1595_F3
+T22323211312111230022210011213302012
++
+>,<=<>@6<;?<=>:/=.>&;;8;)17:=&,>1=+
+ at 1_17_1379_F3
+T32011212111223230232132311321200123
++
+/-1179<1;>>8:':7-%/::0&+=<29,7<8(,2
+ at 1_18_1692_F3
+T12322233031100211233323300112200210
++
+.#(###5%)%2)',2&:+#+&5,($/1#&4&))$6
+ at 1_19_171_F3
+T10101101220213201111011320201230032
++
+)6:65/=3*:(8%)%2>&8&%;%0&#;$3$&:$#&
+ at 1_22_72_F3
+T13303032323221212301322233320210233
++
+3/#678<:.=9::6:(<538295;9+;&*;)+',&
+ at 1_22_1377_F3
+T22221333311222312201132312022322300
++
+)##0%.$.1*%,)95+%%14%$#8-###9-()#9+
+ at 1_23_585_F3
+T300103103101303121221
++
+>55;8><96/18?)<3<58<5
+ at 1_23_809_F3
+T13130101101021211013220302223302112
++
+:7<59@;<<5;/9;=<;7::.)&&&827(+221%(
+ at 1_24_138_F3
+T33211130100120323002
++
+6)68/;906#,25/&;<$0+
+ at 1_24_206_F3
+T33330332002223002020303331321221000
++
+))4(&)9592)#)694(,)292:(=7$.18,()65
+ at 1_25_143_F3
+T23202003031200220301303302012203132
++
+:4;/#&<9;&*;95-7;85&;587#16>%&,9<2&
+ at 1_25_1866_F3
+T03201321022131101112012330221130311
++
+=<>9;<@7?(=6,<&?=6=(=<641:?'<1=;':4
+ at 1_27_584_F3
+T10010330110103213112323303012103101
++
+82'('*.-8+%#2)(-&3.,.2,),+.':&,'(&/
+ at 1_27_1227_F3
+T02003022123001003201002031303302011
++
+492:;>A:<;34<<=);:<<;9=7<3::<::3=>'
+ at 1_27_1350_F3
+T13130101101021211013220222221301231
++
+95,)<(4./;<938=64=+2/,.4),3':97#33&
+ at 1_29_477_F3
+T13130101101021211013300302223003030
++
+94=55:75=+:/7><968;;#&+$#3&6,#1#4#'
+ at 1_30_882_F3
+T20102033000233
++
+2(+-:-3<;5##/;
+ at 1_31_221_F3
+T03301311201100030300100233220102031
++
+89>9>5<139/,&:7969972.274&%:78&&746
+ at 1_31_1313_F3
+T0133113130033012232100010101
++
+;3<7=7::)5*4=&;<7>4;795065;9
+ at 1_529_129_F3
+T132222301020322102101322221322302.3302.3.3..221..3
++
+>>%/((B6-&5A0:6)>;'1)B*38/?(5=%B+!&<-9!%!@!!)%)!!(
diff --git a/tests/cut/solid5p-anchored.fasta b/tests/cut/solid5p-anchored.fasta
new file mode 100644
index 0000000..a779451
--- /dev/null
+++ b/tests/cut/solid5p-anchored.fasta
@@ -0,0 +1,32 @@
+>read1
+212322332333012001112122203233202221000211
+>read2
+01212322332333200121311212133113001311002032
+>read3
+2201212322332333211133003002232323010012320300
+>read4
+02010102312033021011121312131
+>read5
+21313210102120020302022233110
+>read6
+31203203013323021010020301321
+>read7
+1301020302201212322332333203020130202120211322010013211
+>read8
+310321030130120302201212322332333232202123123111113113003200330
+>read9
+002132103320302201212322332333020123133023120320131020333011
+>read10
+0322031320033220302201212322332333201130233321321011303133231200
+>read11
+02010102312033021011121312131
+>read12
+1
+>read13
+
+>read14
+
+>read15
+
+>read16
+
diff --git a/tests/cut/solid5p-anchored.fastq b/tests/cut/solid5p-anchored.fastq
new file mode 100644
index 0000000..c1da73d
--- /dev/null
+++ b/tests/cut/solid5p-anchored.fastq
@@ -0,0 +1,64 @@
+ at read1
+212322332333012001112122203233202221000211
++
+58)2";%4A,8>0;9C\'?276>#)49"<,>?/\'!A4$.%+
+ at read2
+01212322332333200121311212133113001311002032
++
+4<@;(<3.37/''=:-9AA<&C2%$$;?A&5!C69:?-;&;65.
+ at read3
+2201212322332333211133003002232323010012320300
++
+!<A-BB&A/)'103&2$!00>#97*B.0A-@(*","B3><4&16(:
+ at read4
+02010102312033021011121312131
++
+&-81+%)7;<)6?83!&CB9"9B6307=&
+ at read5
+21313210102120020302022233110
++
+9)27,(-*=,#4:;"/4++5<, at -784*'
+ at read6
+31203203013323021010020301321
++
+!.;:C%97@>75-";';*)A67CCC")$*
+ at read7
+1301020302201212322332333203020130202120211322010013211
++
+;0B at A"98!<=!*;5;650;';79!+8,4(2=+98:B at C@:+3*>2+6+2++C0.
+ at read8
+310321030130120302201212322332333232202123123111113113003200330
++
+/$-"=6+1.8?AB!?'#.585 at 6:47@?>.315A-'9<%">6,+)*,)1-;:(691>?C)4A;
+ at read9
+002132103320302201212322332333020123133023120320131020333011
++
+&?527&:=;6 at 6@03%95(-0#$:B8::B*4?@&)6>79C>)6C'5-#<!B:>0:A8+2*
+ at read10
+0322031320033220302201212322332333201130233321321011303133231200
++
+53)>2.+9?7%=&21;8!820961%3#0'5C.28347,2(55*1.,>%:(1A'A5=@7&&5?4'
+ at read11
+02010102312033021011121312131
++
+8B"195'@,@&:5=7;!&-9:%<!)>((>
+ at read12
+1
++
+C
+ at read13
+
++
+
+ at read14
+
++
+
+ at read15
+
++
+
+ at read16
+
++
+
diff --git a/tests/cut/solid5p-anchored.notrim.fasta b/tests/cut/solid5p-anchored.notrim.fasta
new file mode 100644
index 0000000..bdfe76d
--- /dev/null
+++ b/tests/cut/solid5p-anchored.notrim.fasta
@@ -0,0 +1,32 @@
+>read1
+T1212322332333012001112122203233202221000211
+>read2
+T201212322332333200121311212133113001311002032
+>read3
+T02201212322332333211133003002232323010012320300
+>read4
+T302010102312033021011121312131
+>read5
+T121313210102120020302022233110
+>read6
+T331203203013323021010020301321
+>read7
+T21301020302201212322332333203020130202120211322010013211
+>read8
+T2310321030130120302201212322332333232202123123111113113003200330
+>read9
+T0002132103320302201212322332333020123133023120320131020333011
+>read10
+T00322031320033220302201212322332333201130233321321011303133231200
+>read11
+T402010102312033021011121312131
+>read12
+T11
+>read13
+T1
+>read14
+T
+>read15
+T
+>read16
+T
diff --git a/tests/cut/solid5p-anchored.notrim.fastq b/tests/cut/solid5p-anchored.notrim.fastq
new file mode 100644
index 0000000..946aa9c
--- /dev/null
+++ b/tests/cut/solid5p-anchored.notrim.fastq
@@ -0,0 +1,64 @@
+ at read1
+T1212322332333012001112122203233202221000211
++
+:58)2";%4A,8>0;9C\'?276>#)49"<,>?/\'!A4$.%+
+ at read2
+T201212322332333200121311212133113001311002032
++
+44<@;(<3.37/''=:-9AA<&C2%$$;?A&5!C69:?-;&;65.
+ at read3
+T02201212322332333211133003002232323010012320300
++
+2!<A-BB&A/)'103&2$!00>#97*B.0A-@(*","B3><4&16(:
+ at read4
+T302010102312033021011121312131
++
+<&-81+%)7;<)6?83!&CB9"9B6307=&
+ at read5
+T121313210102120020302022233110
++
+$9)27,(-*=,#4:;"/4++5<, at -784*'
+ at read6
+T331203203013323021010020301321
++
+4!.;:C%97@>75-";';*)A67CCC")$*
+ at read7
+T21301020302201212322332333203020130202120211322010013211
++
+,;0B at A"98!<=!*;5;650;';79!+8,4(2=+98:B at C@:+3*>2+6+2++C0.
+ at read8
+T2310321030130120302201212322332333232202123123111113113003200330
++
+C/$-"=6+1.8?AB!?'#.585 at 6:47@?>.315A-'9<%">6,+)*,)1-;:(691>?C)4A;
+ at read9
+T0002132103320302201212322332333020123133023120320131020333011
++
+(&?527&:=;6 at 6@03%95(-0#$:B8::B*4?@&)6>79C>)6C'5-#<!B:>0:A8+2*
+ at read10
+T00322031320033220302201212322332333201130233321321011303133231200
++
+&53)>2.+9?7%=&21;8!820961%3#0'5C.28347,2(55*1.,>%:(1A'A5=@7&&5?4'
+ at read11
+T402010102312033021011121312131
++
+&8B"195'@,@&:5=7;!&-9:%<!)>((>
+ at read12
+T11
++
+?C
+ at read13
+T1
++
+C
+ at read14
+T
++
+
+ at read15
+T
++
+
+ at read16
+T
++
+
diff --git a/tests/cut/solid5p.fasta b/tests/cut/solid5p.fasta
new file mode 100644
index 0000000..29c26a6
--- /dev/null
+++ b/tests/cut/solid5p.fasta
@@ -0,0 +1,32 @@
+>read1
+12001112122203233202221000211
+>read2
+00121311212133113001311002032
+>read3
+11133003002232323010012320300
+>read4
+02010102312033021011121312131
+>read5
+21313210102120020302022233110
+>read6
+31203203013323021010020301321
+>read7
+03020130202120211322010013211
+>read8
+32202123123111113113003200330
+>read9
+20123133023120320131020333011
+>read10
+01130233321321011303133231200
+>read11
+02010102312033021011121312131
+>read12
+1
+>read13
+
+>read14
+
+>read15
+
+>read16
+
diff --git a/tests/cut/solid5p.fastq b/tests/cut/solid5p.fastq
new file mode 100644
index 0000000..5849d87
--- /dev/null
+++ b/tests/cut/solid5p.fastq
@@ -0,0 +1,64 @@
+ at read1
+12001112122203233202221000211
++
+;9C\'?276>#)49"<,>?/\'!A4$.%+
+ at read2
+00121311212133113001311002032
++
+-9AA<&C2%$$;?A&5!C69:?-;&;65.
+ at read3
+11133003002232323010012320300
++
+!00>#97*B.0A-@(*","B3><4&16(:
+ at read4
+02010102312033021011121312131
++
+&-81+%)7;<)6?83!&CB9"9B6307=&
+ at read5
+21313210102120020302022233110
++
+9)27,(-*=,#4:;"/4++5<, at -784*'
+ at read6
+31203203013323021010020301321
++
+!.;:C%97@>75-";';*)A67CCC")$*
+ at read7
+03020130202120211322010013211
++
+8,4(2=+98:B at C@:+3*>2+6+2++C0.
+ at read8
+32202123123111113113003200330
++
+-'9<%">6,+)*,)1-;:(691>?C)4A;
+ at read9
+20123133023120320131020333011
++
+?@&)6>79C>)6C'5-#<!B:>0:A8+2*
+ at read10
+01130233321321011303133231200
++
+47,2(55*1.,>%:(1A'A5=@7&&5?4'
+ at read11
+02010102312033021011121312131
++
+8B"195'@,@&:5=7;!&-9:%<!)>((>
+ at read12
+1
++
+C
+ at read13
+
++
+
+ at read14
+
++
+
+ at read15
+
++
+
+ at read16
+
++
+
diff --git a/tests/cut/solidbfast.fastq b/tests/cut/solidbfast.fastq
new file mode 100644
index 0000000..c9117c4
--- /dev/null
+++ b/tests/cut/solidbfast.fastq
@@ -0,0 +1,120 @@
+ at abc:1_13_85
+T110020300.0113010210002110102330021
++
+7&9<&77)&!<7))%4'657-1+9;9,.<8);.;8
+ at abc:1_13_573
+T312311200.30213011011132
++
+6)3%)&&&&!.1&(6:<'67..*,
+ at abc:1_13_1259
+T002112130.201222332211
++
+=;<:&:A;A!9<<<,7:<=3=;
+ at abc:1_13_1440
+T110020313.1113211010332111302330001
++
+=<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
+ at abc:1_14_177
+T31330222020233321121323302013303311
++
+:8957;;54)'98924905;;)6:7;1:3<88(9:
+ at abc:1_14_238
+T0133103120031002212223
++
+?><5=;<<<12>=<;1;;=5);
+ at abc:1_15_1098
+T32333033222233020223032312232220332
++
+#,##(#5##*#($$'#.##)$&#%)$1##-$&##%
+ at abc:1_16_404
+T03310320002130202331112
++
+78;:;;><>9=9;<<2=><<1;5
+ at abc:1_16_904
+T21230102331022312232132021122111212
++
+9>=::6;;99=+/'$+#.#&%$&'(($1*$($.#.
+ at abc:1_16_1315
+T032312311122103330103103
++
+<9<8A?>?::;6&,%;6/)8<<#/
+ at abc:1_16_1595
+T22323211312111230022210011213302012
++
+>,<=<>@6<;?<=>:/=.>&;;8;)17:=&,>1=+
+ at abc:1_17_1379
+T32011212111223230232132311321200123
++
+/-1179<1;>>8:':7-%/::0&+=<29,7<8(,2
+ at abc:1_18_1692
+T12322233031100211233323300112200210
++
+.#(###5%)%2)',2&:+#+&5,($/1#&4&))$6
+ at abc:1_19_171
+T10101101220213201111011320201230032
++
+)6:65/=3*:(8%)%2>&8&%;%0&#;$3$&:$#&
+ at abc:1_22_72
+T13303032323221212301322233320210233
++
+3/#678<:.=9::6:(<538295;9+;&*;)+',&
+ at abc:1_22_1377
+T22221333311222312201132312022322300
++
+)##0%.$.1*%,)95+%%14%$#8-###9-()#9+
+ at abc:1_23_585
+T300103103101303121221
++
+>55;8><96/18?)<3<58<5
+ at abc:1_23_809
+T13130101101021211013220302223302112
++
+:7<59@;<<5;/9;=<;7::.)&&&827(+221%(
+ at abc:1_24_138
+T33211130100120323002
++
+6)68/;906#,25/&;<$0+
+ at abc:1_24_206
+T33330332002223002020303331321221000
++
+))4(&)9592)#)694(,)292:(=7$.18,()65
+ at abc:1_25_143
+T23202003031200220301303302012203132
++
+:4;/#&<9;&*;95-7;85&;587#16>%&,9<2&
+ at abc:1_25_1866
+T03201321022131101112012330221130311
++
+=<>9;<@7?(=6,<&?=6=(=<641:?'<1=;':4
+ at abc:1_27_584
+T10010330110103213112323303012103101
++
+82'('*.-8+%#2)(-&3.,.2,),+.':&,'(&/
+ at abc:1_27_1227
+T02003022123001003201002031303302011
++
+492:;>A:<;34<<=);:<<;9=7<3::<::3=>'
+ at abc:1_27_1350
+T13130101101021211013220222221301231
++
+95,)<(4./;<938=64=+2/,.4),3':97#33&
+ at abc:1_29_477
+T13130101101021211013300302223003030
++
+94=55:75=+:/7><968;;#&+$#3&6,#1#4#'
+ at abc:1_30_882
+T20102033000233
++
+2(+-:-3<;5##/;
+ at abc:1_31_221
+T03301311201100030300100233220102031
++
+89>9>5<139/,&:7969972.274&%:78&&746
+ at abc:1_31_1313
+T0133113130033012232100010101
++
+;3<7=7::)5*4=&;<7>4;795065;9
+ at abc:1_529_129
+T132222301020322102101322221322302.3302.3.3..221..3
++
+>>%/((B6-&5A0:6)>;'1)B*38/?(5=%B+!&<-9!%!@!!)%)!!(
diff --git a/tests/cut/solidmaq.fastq b/tests/cut/solidmaq.fastq
new file mode 100644
index 0000000..195be3d
--- /dev/null
+++ b/tests/cut/solidmaq.fastq
@@ -0,0 +1,120 @@
+ at 552:1_13_85/1
+CAAGATAANACCTACAGCAAAGCCACAGTTAAGC
++
+&9<&77)&!<7))%4'657-1+9;9,.<8);.;8
+ at 552:1_13_573/1
+CGTCCGAANTAGCTACCACCCTG
++
+)3%)&&&&!.1&(6:<'67..*,
+ at 552:1_13_1259/1
+AGCCGCTANGACGGGTTGGCC
++
+;<:&:A;A!9<<<,7:<=3=;
+ at 552:1_13_1440/1
+CAAGATCTNCCCTGCCACATTGCCCTAGTTAAAC
++
+<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
+ at 552:1_14_177/1
+CTTAGGGAGAGTTTGCCGCTGTTAGACTTATTCC
++
+8957;;54)'98924905;;)6:7;1:3<88(9:
+ at 552:1_14_238/1
+CTTCATCGAATCAAGGCGGGT
++
+><5=;<<<12>=<;1;;=5);
+ at 552:1_15_1098/1
+GTTTATTGGGGTTAGAGGTATGTCGGTGGGATTG
++
+,##(#5##*#($$'#.##)$&#%)$1##-$&##%
+ at 552:1_16_404/1
+TTCATGAAAGCTAGAGTTCCCG
++
+8;:;;><>9=9;<<2=><<1;5
+ at 552:1_16_904/1
+CGTACAGTTCAGGTCGGTGCTGAGCCGGCCCGCG
++
+>=::6;;99=+/'$+#.#&%$&'(($1*$($.#.
+ at 552:1_16_1315/1
+TGTCGTCCCGGCATTTACATCAT
++
+9<8A?>?::;6&,%;6/)8<<#/
+ at 552:1_16_1595/1
+GTGTGCCTCGCCCGTAAGGGCAACCGCTTAGACG
++
+,<=<>@6<;?<=>:/=.>&;;8;)17:=&,>1=+
+ at 552:1_17_1379/1
+GACCGCGCCCGGTGTAGTGCTGTCCTGCGAACGT
++
+-1179<1;>>8:':7-%/::0&+=<29,7<8(,2
+ at 552:1_18_1692/1
+GTGGGTTATCCAAGCCGTTTGTTAACCGGAAGCA
++
+#(###5%)%2)',2&:+#+&5,($/1#&4&))$6
+ at 552:1_19_171/1
+ACACCACGGAGCTGACCCCACCTGAGACGTAATG
++
+6:65/=3*:(8%)%2>&8&%;%0&#;$3$&:$#&
+ at 552:1_22_72/1
+TTATATGTGTGGCGCGTACTGGGTTTGAGCAGTT
++
+/#678<:.=9::6:(<538295;9+;&*;)+',&
+ at 552:1_22_1377/1
+GGGCTTTTCCGGGTCGGACCTGTCGAGGTGGTAA
++
+##0%.$.1*%,)95+%%14%$#8-###9-()#9+
+ at 552:1_23_585/1
+AACATCATCACTATCGCGGC
++
+55;8><96/18?)<3<58<5
+ at 552:1_23_809/1
+TCTACACCACAGCGCCACTGGATAGGGTTAGCCG
++
+7<59@;<<5;/9;=<;7::.)&&&827(+221%(
+ at 552:1_24_138/1
+TGCCCTACAACGATGTAAG
++
+)68/;906#,25/&;<$0+
+ at 552:1_24_206/1
+TTTATTGAAGGGTAAGAGATATTTCTGCGGCAAA
++
+)4(&)9592)#)694(,)292:(=7$.18,()65
+ at 552:1_25_143/1
+TGAGAATATCGAAGGATACTATTAGACGGATCTG
++
+4;/#&<9;&*;95-7;85&;587#16>%&,9<2&
+ at 552:1_25_1866/1
+TGACTGCAGGCTCCACCCGACGTTAGGCCTATCC
++
+<>9;<@7?(=6,<&?=6=(=<641:?'<1=;':4
+ at 552:1_27_584/1
+AACATTACCACATGCTCCGTGTTATACGCATCAC
++
+2'('*.-8+%#2)(-&3.,.2,),+.':&,'(&/
+ at 552:1_27_1227/1
+GAATAGGCGTAACAATGACAAGATCTATTAGACC
++
+92:;>A:<;34<<=);:<<;9=7<3::<::3=>'
+ at 552:1_27_1350/1
+TCTACACCACAGCGCCACTGGAGGGGGCTACGTC
++
+5,)<(4./;<938=64=+2/,.4),3':97#33&
+ at 552:1_29_477/1
+TCTACACCACAGCGCCACTTAATAGGGTAATATA
++
+4=55:75=+:/7><968;;#&+$#3&6,#1#4#'
+ at 552:1_30_882/1
+ACAGATTAAAGTT
++
+(+-:-3<;5##/;
+ at 552:1_31_221/1
+TTACTCCGACCAAATATAACAAGTTGGACAGATC
++
+9>9>5<139/,&:7969972.274&%:78&&746
+ at 552:1_31_1313/1
+CTTCCTCTAATTACGGTGCAAACACAC
++
+3<7=7::)5*4=&;<7>4;795065;9
+ at 552:1_529_129/1
+TGGGGTACAGATGGCAGCACTGGGGCTGGTAGNTTAGNTNTNNGGCNNT
++
+>%/((B6-&5A0:6)>;'1)B*38/?(5=%B+!&<-9!%!@!!)%)!!(
diff --git a/tests/cut/solidqual.fastq b/tests/cut/solidqual.fastq
new file mode 100644
index 0000000..80f4714
--- /dev/null
+++ b/tests/cut/solidqual.fastq
@@ -0,0 +1,120 @@
+ at 1_13_85_F3
+T110020300.0113010210002110102330021
++
+7&9<&77)&!<7))%4'657-1+9;9,.<8);.;8
+ at 1_13_573_F3
+T312311200.3021301101113203302010003
++
+6)3%)&&&&!.1&(6:<'67..*,:75)'77&&&5
+ at 1_13_1259_F3
+T002112130.201222332211133020123031
++
+=;<:&:A;A!9<<<,7:<=3=;:<&<?<?8<;=<
+ at 1_13_1440_F3
+T110020313.1113211010332111302330001
++
+=<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
+ at 1_14_177_F3
+T31330222020233321121323302013303311
++
+:8957;;54)'98924905;;)6:7;1:3<88(9:
+ at 1_14_238_F3
+T01331031200310022122230330201030313
++
+?><5=;<<<12>=<;1;;=5);.;14:0>2;:3;7
+ at 1_15_1098_F3
+T
++
+
+ at 1_16_404_F3
+T03310320002130202331112133020103031
++
+78;:;;><>9=9;<<2=><<1;58;9<<;>(<;<;
+ at 1_16_904_F3
+T21230102331022312232132021122111212
++
+9>=::6;;99=+/'$+#.#&%$&'(($1*$($.#.
+ at 1_16_1315_F3
+T0323123111221033301031032330201000
++
+<9<8A?>?::;6&,%;6/)8<<#/;79(448&*.
+ at 1_16_1595_F3
+T22323211312111230022210011213302012
++
+>,<=<>@6<;?<=>:/=.>&;;8;)17:=&,>1=+
+ at 1_17_1379_F3
+T32011212111223230232132311321200123
++
+/-1179<1;>>8:':7-%/::0&+=<29,7<8(,2
+ at 1_18_1692_F3
+T12322233031100211233323300112200210
++
+.#(###5%)%2)',2&:+#+&5,($/1#&4&))$6
+ at 1_19_171_F3
+T10101101220213201111011320201230
++
+)6:65/=3*:(8%)%2>&8&%;%0&#;$3$&:
+ at 1_22_72_F3
+T133030323232212123013222333202
++
+3/#678<:.=9::6:(<538295;9+;&*;
+ at 1_22_1377_F3
+T22221333311222312201132312022322300
++
+)##0%.$.1*%,)95+%%14%$#8-###9-()#9+
+ at 1_23_585_F3
+T30010310310130312122123302013303131
++
+>55;8><96/18?)<3<58<5:;96=7:1=8=:-<
+ at 1_23_809_F3
+T131301011010212110132203022233021
++
+:7<59@;<<5;/9;=<;7::.)&&&827(+221
+ at 1_24_138_F3
+T3321113010012032300203302012303131
++
+6)68/;906#,25/&;<$0+250#2,<)5,9/+7
+ at 1_24_206_F3
+T33330332002223002020303331321221000
++
+))4(&)9592)#)694(,)292:(=7$.18,()65
+ at 1_25_143_F3
+T2320200303120022030130330201220313
++
+:4;/#&<9;&*;95-7;85&;587#16>%&,9<2
+ at 1_25_1866_F3
+T03201321022131101112012330221130311
++
+=<>9;<@7?(=6,<&?=6=(=<641:?'<1=;':4
+ at 1_27_584_F3
+T10010330110103213112323303012103101
++
+82'('*.-8+%#2)(-&3.,.2,),+.':&,'(&/
+ at 1_27_1227_F3
+T0200302212300100320100203130330201
++
+492:;>A:<;34<<=);:<<;9=7<3::<::3=>
+ at 1_27_1350_F3
+T1313010110102121101322022222130123
++
+95,)<(4./;<938=64=+2/,.4),3':97#33
+ at 1_29_477_F3
+T13130101101021211013300302223
++
+94=55:75=+:/7><968;;#&+$#3&6,
+ at 1_30_882_F3
+T20102033000233133320103031311233200
++
+2(+-:-3<;5##/;:(%&84'#:,?3&&8>-();5
+ at 1_31_221_F3
+T03301311201100030300100233220102031
++
+89>9>5<139/,&:7969972.274&%:78&&746
+ at 1_31_1313_F3
+T01331131300330122321000101010330201
++
+;3<7=7::)5*4=&;<7>4;795065;9';896'=
+ at 1_529_129_F3
+T132222301020322102101322221322302.3302
++
+>>%/((B6-&5A0:6)>;'1)B*38/?(5=%B+!&<-9
diff --git a/tests/cut/sra.fastq b/tests/cut/sra.fastq
new file mode 100644
index 0000000..ea95638
--- /dev/null
+++ b/tests/cut/sra.fastq
@@ -0,0 +1,24 @@
+ at 1_13_85_F3
+T110020300.0113010210002110102330021
++
+7&9<&77)&!<7))%4'657-1+9;9,.<8);.;8
+ at 1_13_573_F3
+T312311200.30213011011132
++
+6)3%)&&&&!.1&(6:<'67..*,
+ at 1_13_1259_F3
+T002112130.201222332211
++
+=;<:&:A;A!9<<<,7:<=3=;
+ at 1_13_1440_F3
+T110020313.1113211010332111302330001
++
+=<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
+ at 1_14_177_F3
+T31330222020233321121323302013303311
++
+:8957;;54)'98924905;;)6:7;1:3<88(9:
+ at 1_14_238_F3
+T0133103120031002212223
++
+?><5=;<<<12>=<;1;;=5);
diff --git a/tests/cut/stripped.fasta b/tests/cut/stripped.fasta
new file mode 100644
index 0000000..2ca63a2
--- /dev/null
+++ b/tests/cut/stripped.fasta
@@ -0,0 +1,4 @@
+>first
+SEQUENCE1
+>second
+SEQUENCE2
diff --git a/tests/cut/suffix.fastq b/tests/cut/suffix.fastq
new file mode 100644
index 0000000..dd1ad1b
--- /dev/null
+++ b/tests/cut/suffix.fastq
@@ -0,0 +1,120 @@
+ at 1_13_85_my_suffix
+T110020300.0113010210002110102330021
++
+7&9<&77)&!<7))%4'657-1+9;9,.<8);.;8
+ at 1_13_573_my_suffix
+T312311200.30213011011132
++
+6)3%)&&&&!.1&(6:<'67..*,
+ at 1_13_1259_my_suffix
+T002112130.201222332211
++
+=;<:&:A;A!9<<<,7:<=3=;
+ at 1_13_1440_my_suffix
+T110020313.1113211010332111302330001
++
+=<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
+ at 1_14_177_my_suffix
+T31330222020233321121323302013303311
++
+:8957;;54)'98924905;;)6:7;1:3<88(9:
+ at 1_14_238_my_suffix
+T0133103120031002212223
++
+?><5=;<<<12>=<;1;;=5);
+ at 1_15_1098_my_suffix
+T32333033222233020223032312232220332
++
+#,##(#5##*#($$'#.##)$&#%)$1##-$&##%
+ at 1_16_404_my_suffix
+T03310320002130202331112
++
+78;:;;><>9=9;<<2=><<1;5
+ at 1_16_904_my_suffix
+T21230102331022312232132021122111212
++
+9>=::6;;99=+/'$+#.#&%$&'(($1*$($.#.
+ at 1_16_1315_my_suffix
+T032312311122103330103103
++
+<9<8A?>?::;6&,%;6/)8<<#/
+ at 1_16_1595_my_suffix
+T22323211312111230022210011213302012
++
+>,<=<>@6<;?<=>:/=.>&;;8;)17:=&,>1=+
+ at 1_17_1379_my_suffix
+T32011212111223230232132311321200123
++
+/-1179<1;>>8:':7-%/::0&+=<29,7<8(,2
+ at 1_18_1692_my_suffix
+T12322233031100211233323300112200210
++
+.#(###5%)%2)',2&:+#+&5,($/1#&4&))$6
+ at 1_19_171_my_suffix
+T10101101220213201111011320201230032
++
+)6:65/=3*:(8%)%2>&8&%;%0&#;$3$&:$#&
+ at 1_22_72_my_suffix
+T13303032323221212301322233320210233
++
+3/#678<:.=9::6:(<538295;9+;&*;)+',&
+ at 1_22_1377_my_suffix
+T22221333311222312201132312022322300
++
+)##0%.$.1*%,)95+%%14%$#8-###9-()#9+
+ at 1_23_585_my_suffix
+T300103103101303121221
++
+>55;8><96/18?)<3<58<5
+ at 1_23_809_my_suffix
+T13130101101021211013220302223302112
++
+:7<59@;<<5;/9;=<;7::.)&&&827(+221%(
+ at 1_24_138_my_suffix
+T33211130100120323002
++
+6)68/;906#,25/&;<$0+
+ at 1_24_206_my_suffix
+T33330332002223002020303331321221000
++
+))4(&)9592)#)694(,)292:(=7$.18,()65
+ at 1_25_143_my_suffix
+T23202003031200220301303302012203132
++
+:4;/#&<9;&*;95-7;85&;587#16>%&,9<2&
+ at 1_25_1866_my_suffix
+T03201321022131101112012330221130311
++
+=<>9;<@7?(=6,<&?=6=(=<641:?'<1=;':4
+ at 1_27_584_my_suffix
+T10010330110103213112323303012103101
++
+82'('*.-8+%#2)(-&3.,.2,),+.':&,'(&/
+ at 1_27_1227_my_suffix
+T02003022123001003201002031303302011
++
+492:;>A:<;34<<=);:<<;9=7<3::<::3=>'
+ at 1_27_1350_my_suffix
+T13130101101021211013220222221301231
++
+95,)<(4./;<938=64=+2/,.4),3':97#33&
+ at 1_29_477_my_suffix
+T13130101101021211013300302223003030
++
+94=55:75=+:/7><968;;#&+$#3&6,#1#4#'
+ at 1_30_882_my_suffix
+T20102033000233
++
+2(+-:-3<;5##/;
+ at 1_31_221_my_suffix
+T03301311201100030300100233220102031
++
+89>9>5<139/,&:7969972.274&%:78&&746
+ at 1_31_1313_my_suffix
+T0133113130033012232100010101
++
+;3<7=7::)5*4=&;<7>4;795065;9
+ at 1_529_129_my_suffix
+T132222301020322102101322221322302.3302.3.3..221..3
++
+>>%/((B6-&5A0:6)>;'1)B*38/?(5=%B+!&<-9!%!@!!)%)!!(
diff --git a/tests/cut/trimN3.fasta b/tests/cut/trimN3.fasta
new file mode 100644
index 0000000..c05f5ed
--- /dev/null
+++ b/tests/cut/trimN3.fasta
@@ -0,0 +1,2 @@
+>read1
+CAGTCGGTCCTGAGAGATGGGCGAGCGCTGG
diff --git a/tests/cut/trimN5.fasta b/tests/cut/trimN5.fasta
new file mode 100644
index 0000000..b1faa5f
--- /dev/null
+++ b/tests/cut/trimN5.fasta
@@ -0,0 +1,2 @@
+>read1
+GGCCTGGAATTCTCGGGTGCCAAGGAACTCCAGTCACCAG
diff --git a/tests/cut/twoadapters.fasta b/tests/cut/twoadapters.fasta
new file mode 100644
index 0000000..c03a129
--- /dev/null
+++ b/tests/cut/twoadapters.fasta
@@ -0,0 +1,6 @@
+>read1
+GATCCTCCTGGAGCTGGCTGATACCAGTATACCAGTGCTGATTGTTG
+>read2
+CTCGAGAATTCTGGATCCTCTCTTCTGCTACCTTTGGGATTTGCTTGCTCTTG
+>read3 (no adapter)
+AATGAAGGTTGTAACCATAACAGGAAGTCATGCGCATTTAGTCGAGCACGTAAGTTCATACGGAAATGGGTAAG
diff --git a/tests/cut/twoadapters.first.fasta b/tests/cut/twoadapters.first.fasta
new file mode 100644
index 0000000..aab7419
--- /dev/null
+++ b/tests/cut/twoadapters.first.fasta
@@ -0,0 +1,2 @@
+>read1
+GATCCTCCTGGAGCTGGCTGATACCAGTATACCAGTGCTGATTGTTG
diff --git a/tests/cut/twoadapters.second.fasta b/tests/cut/twoadapters.second.fasta
new file mode 100644
index 0000000..2c491d3
--- /dev/null
+++ b/tests/cut/twoadapters.second.fasta
@@ -0,0 +1,2 @@
+>read2
+CTCGAGAATTCTGGATCCTCTCTTCTGCTACCTTTGGGATTTGCTTGCTCTTG
diff --git a/tests/cut/twoadapters.unknown.fasta b/tests/cut/twoadapters.unknown.fasta
new file mode 100644
index 0000000..88f7875
--- /dev/null
+++ b/tests/cut/twoadapters.unknown.fasta
@@ -0,0 +1,2 @@
+>read3 (no adapter)
+AATGAAGGTTGTAACCATAACAGGAAGTCATGCGCATTTAGTCGAGCACGTAAGTTCATACGGAAATGGGTAAG
diff --git a/tests/cut/unconditional-back.fastq b/tests/cut/unconditional-back.fastq
new file mode 100644
index 0000000..d03f33e
--- /dev/null
+++ b/tests/cut/unconditional-back.fastq
@@ -0,0 +1,12 @@
+ at prefix:1_13_573/1
+CGTCCGAANTAGCTACCACCCTGATTAGA
++
+)3%)&&&&!.1&(6:<'67..*,:75)'7
+ at prefix:1_13_1259/1
+AGCCGCTANGACGGGTTGGCCCTTAGACG
++
+;<:&:A;A!9<<<,7:<=3=;:<&<?<?8
+ at prefix:1_13_1440/1
+CAAGATCTNCCCTGCCACATTGCCCTAGT
++
+<=A:A=57!7<';<6?5;;6:+:=)71>7
diff --git a/tests/cut/unconditional-both.fastq b/tests/cut/unconditional-both.fastq
new file mode 100644
index 0000000..303b042
--- /dev/null
+++ b/tests/cut/unconditional-both.fastq
@@ -0,0 +1,12 @@
+ at prefix:1_13_573/1
+GAANTAGCTACCACCCTGATTAGA
++
+&&&!.1&(6:<'67..*,:75)'7
+ at prefix:1_13_1259/1
+CTANGACGGGTTGGCCCTTAGACG
++
+A;A!9<<<,7:<=3=;:<&<?<?8
+ at prefix:1_13_1440/1
+TCTNCCCTGCCACATTGCCCTAGT
++
+=57!7<';<6?5;;6:+:=)71>7
diff --git a/tests/cut/unconditional-front.fastq b/tests/cut/unconditional-front.fastq
new file mode 100644
index 0000000..383b3db
--- /dev/null
+++ b/tests/cut/unconditional-front.fastq
@@ -0,0 +1,12 @@
+ at prefix:1_13_573/1
+GAANTAGCTACCACCCTGATTAGACAAAT
++
+&&&!.1&(6:<'67..*,:75)'77&&&5
+ at prefix:1_13_1259/1
+CTANGACGGGTTGGCCCTTAGACGTATCT
++
+A;A!9<<<,7:<=3=;:<&<?<?8<;=<&
+ at prefix:1_13_1440/1
+TCTNCCCTGCCACATTGCCCTAGTTAAAC
++
+=57!7<';<6?5;;6:+:=)71>70<,=:
diff --git a/tests/cut/wildcard.fa b/tests/cut/wildcard.fa
new file mode 100644
index 0000000..2dae07a
--- /dev/null
+++ b/tests/cut/wildcard.fa
@@ -0,0 +1,4 @@
+>1
+TGCATGCA
+>2
+TGCATGCA
diff --git a/tests/cut/wildcardN.fa b/tests/cut/wildcardN.fa
new file mode 100644
index 0000000..ef44dbc
--- /dev/null
+++ b/tests/cut/wildcardN.fa
@@ -0,0 +1,6 @@
+>perfect
+TTT
+>withN
+TTT
+>1mism
+TTTGGGGCGG
diff --git a/tests/cut/wildcard_adapter.fa b/tests/cut/wildcard_adapter.fa
new file mode 100644
index 0000000..27d5dab
--- /dev/null
+++ b/tests/cut/wildcard_adapter.fa
@@ -0,0 +1,8 @@
+>1
+
+>2
+
+>3b
+TGGCTGGCC
+>4b
+TGGCTGGCC
diff --git a/tests/cut/wildcard_adapter_anywhere.fa b/tests/cut/wildcard_adapter_anywhere.fa
new file mode 100644
index 0000000..8ba6688
--- /dev/null
+++ b/tests/cut/wildcard_adapter_anywhere.fa
@@ -0,0 +1,8 @@
+>1
+TGCATGCA
+>2
+TGCATGCA
+>3b
+TGGCTGGCC
+>4b
+TGGCTGGCC
diff --git a/tests/data/454.fa b/tests/data/454.fa
new file mode 100644
index 0000000..92caddf
--- /dev/null
+++ b/tests/data/454.fa
@@ -0,0 +1,118 @@
+>000163_1255_2627 length=52 uaccno=E0R4ISW01DCIQD
+CCATCTCATCCCTGCGTGTCCCATCTGTTCCCTTCCTTGTCTCAGTGTGGTG
+>000652_1085_0667 length=122 uaccno=E0R4ISW01CXJXP
+ATTGAAGAGGTTGGTAAGTTTTAAGTTGGTAGGTGGTTGGGGAGTGGTTGGAGAGGAGTTGTTGGGAGTTTGTGTCCTGCTGAGACACGCAACGGGGATAGGCAAGGCACACAGGGGATAGG
+>000653_1285_1649 length=135 uaccno=E0R4ISW01DE4SJ
+AATTAGTCGAGCGTTGTGGTGGGTATTTGTAATTTTAGCTACTCTGAAGGCTGAGGCAGGAGAACTGCTTGAACCCGGGAGGCGGAGGTTGCTGAGACACGCAACAGGAGATAGGCAAGGCACACAGGGGATAGG
+>000902_0715_2005 length=92 uaccno=E0R4ISW01B03K3
+GGGTGTTGAATTTAATATGTAGTATATTGATTTGTGATGATTATTTTGCCTGAGACACGCAACAGGGGTAGGCAAGGCACACAGGGGATAGG
+>001146_1255_0340 length=92 uaccno=E0R4ISW01DCGYU
+GGGTGTTGAATTTAATATGTAGTATATTGATTTGTGATGATTATTTTGCCTGAGACACGCAACAGGGGTAGGCAAGGCACACAGGGGATAGG
+>001210_1147_1026 length=171 uaccno=E0R4ISW01C2Z5W
+TAGGGAGGTGGTGAGTGTTGTGTGTTTAGATTGTGTGTGGTGGTTGGGAGTGGGAGTTGTATTTTAGGGTGTGGGTTGGGAGAGTGAAAGTTGTGGGTGTTTTGGATGGTGGGTTAGGTGGTTGTGCCTGAGACACGCAACAGGGGAAAGGCAAGGCACACAGGGGATAGG
+>001278_1608_2022 length=109 uaccno=E0R4ISW01D7HW4
+CACACACACTCTTCCCCATACCTACTCACACACACACACACACACACAAACATACACAAATAATTCTGAGACACGCAACAGGAGATAGGCAAGGCACACAGGGGATAGG
+>001333_1518_1176 length=142 uaccno=E0R4ISW01DZKTM
+AATTGTCGTTTGATTGTTGGAAAGTAGAGGGTCGGGTTGGGGTAGATTCGAAAGGGGAATTTTGAGAAAAGAAATGGAGGGAGGTAGGAAAATTTTTTGCTGAGACACGCAACAGGGGTAGGCAAGGCACACAGGGGATAGG
+>001398_1584_1549 length=154 uaccno=E0R4ISW01D5DPB
+TAATGAAATGGAATGGAATGGAATGGAATGAAATGGAATGGAATGGAATGGAATGGAATGGAATGGAATGGAATGGAATGAAATGGAATGGAGTATAAAGGAATGGAATTACTGAGACACGCAACAGGGGAAGGCAAGGCACACAGGGGATAGG
+>001455_1136_2179 length=92 uaccno=E0R4ISW01C12AD
+GGGTGTTGAATTTAATATGTAGTATATTGATTTGTGATGATTATTTTGCCTGAGACACGCAACAGGGGTAGGCAAGGCACACAGGGGATAGG
+>001481_1165_0549 length=92 uaccno=E0R4ISW01C4KON
+GGGTGTTGAATTTAATATGTAGTATATTGATTTGTGATGATTATTTTGCCTGAGACACGCAACAGGGGTAGGCAAGGCACACAGGGGATAGG
+>001744_1376_3512 length=144 uaccno=E0R4ISW01DM5T2
+TAAGTAGGGAAGGTTTGAGGTTGTTGGTGTTGGTAGTAGGGGTGTTTTAGTTAGGGGTTGTAGTTTGTTAAGGGAATTTTATTTGAGTTTAGAATTGAGGCTGAGACACGCAAAAGGGGATAGGCAAGGCACACAGGGGATAGG
+>001893_1084_1137 length=162 uaccno=E0R4ISW01CXG4Z
+TGTATATTTTGTTGGGTTTGTATATATTGTTAGGTGTGGTTGGTGAGTTGTATTGGTGGTGGTGTAAGGTGAGTGGAAATGGGAATGGATTGTAGATATGTTGGATTTGTGGTTTTTGGTTGAGACACGAACAGGGGATAGGCAAGGCACACAGGGGATAGG
+>001927_0254_0706 length=182 uaccno=E0R4ISW01AWLLG
+TGGAATCATCTAAGGGACACAAATAGAATCATCATTGAATGGAATCGAATGGAATCATCTAATGTACTCGAATGGAATTATTATTGAATAGAATAGAATGGAATTATCGAATGGAATCAAATGGAATGTAATGGAATGCTGAGACACGCAACAGGGGAAAGGCAAGGCACACAGGGGATAGG
+>002007_1338_1037 length=139 uaccno=E0R4ISW01DJRTR
+GGGTTGTGTATTTGGATAGTATGTGGAAAATGGTATTAAAAAGAATTTGTAGTTGGATTGTTGGTGGTTATTTAGTTTTTGGGTAATGGGTAGATTCCTGAGACACGCAAAGGGATAGGCAAGGCACACAGGGGATAGG
+>002186_1130_0654 length=92 uaccno=E0R4ISW01C1H5C
+GGGTGTTGAATTTAATATGTAGTATATTGATTTGTGATGATTATTTTGCCTGAGACACGCAACAGGGGTAGGCAAGGCACACAGGGGATAGG
+>002282_1237_2702 length=134 uaccno=E0R4ISW01DAXWG
+AATTAGCCGGGCGTGATGGCGGGCGTTTGTAGTTTTAGTTATTCGGGAGGTTGAGGTAGGAGAATGGCGTGAATTCGGGAAGCGGAGTTTGCTGAGACACGCAACAGGGGTAGGCAAGGCACACAGGGGATAGG
+>002382_1259_0997 length=107 uaccno=E0R4ISW01DCT37
+TAAGGGTTGAAGCGAGGTAGGTAGTTTGTTTGTGGTTTTGTTTCGTATTTTTGTTTCGTATCCCTGAGACACGCAACAGAGGATAGGCAAGGCACACAGGGGATAGG
+>002477_0657_0655 length=174 uaccno=E0R4ISW01BVY8H
+TTTTTGGAAAGTTGGGTGGGTATAGTTTTGAGTAGTTAGAGGTATTATAATAGTATTAGGAAGTTGAATGTGAGGGTATAAGAGTTAATTTGATTTTTCGTTGATATGTTTGTTGTTTGAAGTTAGAGTGCTGAGACACGCAACAGGAGATAGGCAAGGCACACAGGGGATAGG
+>003149_1553_2333 length=170 uaccno=E0R4ISW01D2OBZ
+TATTTAGTTTTAGTTTGTTTAGGTGGTTATAGAATACGGAGTTTATGAAGTTGATTAGGAATATTATTAGTTGAATTAAGAATTGGGAAGAGAGGGGAACGGGAAGGGACGTGAGTGATTATTATTGCTGAGACACGCAAAGGGGATAGGCAAGGCACACAGGGGATAGG
+>003194_1475_2845 length=101 uaccno=E0R4ISW01DVT7J
+TATTTTGGGTTAAGTCGGGTTTAGTTGTTAGGGCGAGAAGTTAGTTGTTGACCCCTGCTGAGACACGCAAAAGGGGATAGGCAAGGCACACAGGGGATAGG
+>003206_1315_0479 length=95 uaccno=E0R4ISW01DHQPD
+GGGTTGGATAATATGATGGTGTTGGGGAATATTTAGGTATGTGGTTTGTGGCTGAGACACGCAACAGAGGATAGGCAAGGCACACAGGGGATAGG
+>003271_0173_0314 length=125 uaccno=E0R4ISW01APHAK
+GTTTATTTGTTATTTATTTTTAGGTTTAGAAGAGTGTTTGGTATTTATTGAGGATTTAGTATTTGTTAGAAGGATTGGATTCTGAGACACGCAACAGGGGGTAGGCAAGGCACACAGGGGATAGG
+>003443_1737_2250 length=67 uaccno=E0R4ISW01EITSS
+TGTAGGTTGTGTTGTAGGTTGTCCTGAGACACGCAACAGGGGAAAGGCAAGGCACACAGGGGATAGG
+>002633_1776_1582 length=81 uaccno=E0R4ISW01EL8JK
+CAGGGTGGATTGGGGAACACACAGTGTGGCCGCGTGATTCTGAGACACGCAACAGGGAAGGCAAGGCACACAGGGGATAGG
+>002663_0725_3154 length=126 uaccno=E0R4ISW01B1Z2S
+GCGTTTTATATTATAATTTAATATTTTGGAGGTTGGGTGCGGTGGTTTACGTTTGTAGTTTAGTATTTGGGAGGTTAAGGTAGCTGAGACACGCAACGGGGATAGGCAAGGCACACAGGGGATAGG
+>002761_1056_4055 length=121 uaccno=E0R4ISW01CU2V9
+AATTTTATTCGATTTATGTGATGATTTATTTATTTTATTTGAAGATGATTTTATTCGAGATTATTCGATGATTCCATTCCTGAGACACGCAAGGGGATAGGCAAGGCACACAGGGGATAGG
+>002843_0289_2275 length=122 uaccno=E0R4ISW01AZPE9
+ATTGAAGAGGTTGGTAAGTTTTAAGTTGGTAGGTGGTTGGGGAGTGGTTGGAGAGGAGTTGTTGGGAGTTTGTGTCCTGCTGAGACACGCAACGGGGATAGGCAAGGCACACAGGGGATAGG
+>002934_1762_2177 length=92 uaccno=E0R4ISW01EK0Q7
+GGGTGTTGAATTTAATATGTAGTATATTGATTTGTGATGATTATTTTGCCTGAGACACGCAACAGGGGTAGGCAAGGCACACAGGGGATAGG
+>003515_1711_1058 length=122 uaccno=E0R4ISW01EGIPG
+AATTGAATGGAATTATTATTGAATGGATTCGAATGGAATTATTATTGAATGGAATCATCGAGTGGAATCGAATGGAATCTGAGACACGCAACAGGGGAAAGGCAAGGCACACAGGGGATAGG
+>003541_1276_1589 length=112 uaccno=E0R4ISW01DECAV
+TAGTTTAGGGTGGTAGTTTGGATAAGGTAGTTTTACGGTTTAGTAGTAGTAGGTTAAGTAGGAAAACTGCTGAGACACGCAAAGGGGATAGGCAAGGCACACAGGGGATAGG
+>003587_1522_1804 length=152 uaccno=E0R4ISW01DZXX6
+AATTTATGTAGTGGAAGTAGGATATAAAGAATAGGTTAATGGATTTTGAGATATTAAAAAGAGTAGGAAATTAGTTGAGAGGTTAAGTAGTAGTTTATTTTAGCCACCCTGAGACACGCAACAGGAGATAGGCAAGGCACACAGGGGATAGG
+>003592_0076_0430 length=134 uaccno=E0R4ISW01AGYTC
+AATTAGTTAGGCGTGGTGGCGGGTGTTTGTAGTTTTAGTTATTCGGGAGGTTGAGGTAGGAGAATGTTGTGAATTTAGGAGGTGGAGTTTGCTGAGACACGCAACAGGGGAAGGCAAGGCACACAGGGGATAGG
+>003957_0595_0965 length=173 uaccno=E0R4ISW01BQJIV
+TAATATTAGGTGTCAATTTGACTGGATCGAGGGATGTGTGTCGGTGAGAGTCTCACTAGAGGTTGATATTTGAGTCGTTAGACTGGGAGAGGAAGACCGAACTGTCAAGTGTATGGGCGCCATCCAATTCTGAGACACGCAACAGGGGAAAGGCAAGGCACACAGGGGATAGG
+>003986_1127_2937 length=103 uaccno=E0R4ISW01C1AFF
+TAATGGAATGGAATTTTCGGAATGGAATGGAATGGAATGGAATGGAATGGAATGGAATTACTGAGACACGCAACAGGGGAAGGCAAGGCACACAGGGGATAGG
+>004012_1559_1491 length=111 uaccno=E0R4ISW01D26M9
+TAGTGGATATAAATGGAATGGATTGGAATGGAATGGATACGAATGGAATGGATTGGAGTGGAATGGATTGACTGAGACACGCAACAGGGGGCAAGGCACACAGGGGATAGG
+>004030_1508_2061 length=166 uaccno=E0R4ISW01DYPWF
+TACGTATATACGCGTACGCGTATACGTATATACGCGTATACGTATACGCGTACGTATATATACGCGTATACGTTTACGTACGTACGCGTATATACGTACGTATACACACACGCATATGCATACTGAGACACGCAACAGGGGAAAGGCAAGGCACACAGGGGATAGG
+>004038_1061_2047 length=152 uaccno=E0R4ISW01CVG5D
+AATTGATTCGAATGGAATGGATTGGAATGGAACGGATTTGAATGGAATGGATTGGAATGGAATGGATTGAATGGAATGGATTGGAGAGGATTGGATTTGAATGGAATTCTGAGACACGCAACAGGGGAAAGGCAAGGCACACAGGGGATAGG
+>004105_1121_0391 length=135 uaccno=E0R4ISW01C0PH1
+AATTAGTTGGGCGTGGTGGCGAGTGTTTGTAATTTTAGTTATTTAGGAGGTTGAGGTAGGAGAATTATTTGAACCCGGTAGACGGAAGTTGCTGAGACACGCAACAGGGGAAAGGCAAGGCACACAGGGGATAGG
+>004129_1618_3423 length=122 uaccno=E0R4ISW01D8ELT
+AATTGAATGGTATTGAAAGGTATTAATTTAGTGGAATGGAATGGAATGTATTGGAATGGAAAATAATGGAATGGAGTGCTGAGACACGCAACAGGGGAAAGGCAAGGCACACAGGGGATAGG
+>004203_0451_0902 length=115 uaccno=E0R4ISW01BDWC4
+TAGTTGGTGTGTTGTAATCGAGACGTAGTTGGTTGGTACGGGTTAGGGTTTTGATTGGGTTGTTGTGTTTGCTGAGACACGCAACATGGGATAGGCAAGGCACACAGGGGATAGG
+>004626_1937_0919 length=223 uaccno=E0R4ISW01E0CVD
+TAGAGTAGATAGTAGGGTTAGAGAAGGTAGGGTACGTTTAGTTTGTTAGTAAGGTTTAAGTTTTGGGTGGGAAAGGTTAGTGGCGGGAAGGGACGAAGGTGGTAATCGAGAGTAGATTTAGAGAAGTTTTTGAAGTGGGCGTTGGGAGTTTTCGAAGTATTGAGAGAGAGGAGCTTGTGCTGAGACATGCAACAGAGGATAGGCAAGGCACACAGGGGATAGG
+>004913_0641_2071 length=135 uaccno=E0R4ISW01BULRD
+AATTAGTCGAGCGTTGTGGTGGGTATTTGTAATTTTAGCTACTCTGAAGGCTGAGGCAGGAGAACTGCTTGAACCCGGGAGGCGGAGGTTGCTGAGACACGCAACAGGAGATAGGCAAGGCACACAGGGGATAGG
+>005063_0599_1983 length=127 uaccno=E0R4ISW01BQWX9
+ATGTGGTGAAGATTGGTTTTAGGTGTTTTAATGTGGATTTTCAGGGGTTTTAAAAGGGTTGGGAGAGTGAAATATATATAAGGCTGAGACACGCAAAAGGGGATAGGCAAGGCACACAGGGGATAGG
+>005140_0759_3209 length=116 uaccno=E0R4ISW01B4ZKR
+TAGTATAGAGGGTTTGTGGTCGTGAGGGTGTTGATGGCGGGAGGGTTTTGATGGTAGGAGGGCCCGTGCTGTGCTGAGACACGCAACAGGGGAAGGCAAGGCACACAGGGGATAGG
+>005351_0883_3221 length=137 uaccno=E0R4ISW01CFVHJ
+TTAGGTGTTATAGTTGAGTGAGATGTTAGTGTTTAATGGTTTTATTTAGGTTGATGGGTTAATGAGGGGGTATTTGATAGTTTTGAAGATTTGACTGAGACACGCAACGGGGATAGGCAAGGCACACAGGGGATAGG
+>005380_1702_1187 length=207 uaccno=E0R4ISW01EFQC1
+TAGGGTTTTTCGAGTATATATTTAGTAGTACGCTCGACTTCTCTTATATAAAGGTTTTGGTTTTTATAGGTTTTTCCATTGTGTCTGCCTGGGGGAGGGCCCTTCTCCTTCAGGATACTGTAGCTTCTCTGCGTGATAAGCCAGCATTCACGGCTTTCAGGTGCTGAGACATGCAACAGGGGAAAGGCAAGGCACACAGGGGATAGG
+>005568_1060_1943 length=63 uaccno=E0R4ISW01CVDWP
+ATAGCGTATTTCTCACCTGCTGAGACACGCAACAGGGGAAAGGCAAGGCACACAGGGGATAGG
+>005740_1536_2697 length=159 uaccno=E0R4ISW01D06VV
+TAAAGAGGTGTTATTATTAGTTAGGAGAGGAGGTGGTTAGATAGTAGTGGGATTATAGGGGAATATAGAGTTGTTAGTTTAGGGATAAGGGATTGATCGATGGGTTAGGTCTCTGCTGAGACACGCAAAAGGGGATAGGCAAGGCACACAGGGGATAGG
+>005753_1884_3877 length=95 uaccno=E0R4ISW01EVRNB
+AAACTGAGTTGTGATGTTTGCATTCAACTCACAGAGTTCAACATTCCTTTAACTGAGACACGCAACAGGGTTAGGCAAGGCACACAGGGTATAGG
+>read_equals_adapter 1a
+TGAGACACGCAACAGGGGAAAGGCAAGGCACACAGGGGATAGG
+>read_equals_start_of_adapter 1b
+TGAGACACGCAACAGGGGAAAG
+>read_equals_end_of_adapter 1c
+GAAAGGCAAGGCACACAGGGGATAGG
+>read_equals_middle_of_adapter 1d
+GCAACAGGGGAAAGGCAAGGCACACAGG
+>read_ends_with_adapter 2a
+GCTACTCTGAAGGCTGAGGCAGGAGAACTGCTTGAACCCGGGAGGCGTGAGACACGCAACAGGGGAAAGGCAAGGCACACAGGGGATAGG
+>read_ends_with_start_of_adapter 2b
+GCTACTCTGAAGGCTGAGGCAGGAGAACTGCTTGAACCCGGGAGGCGTGAGACACGCAACAGGGGAAAGGCAAGG
+>read_contains_adapter_in_the_middle 3
+CGTAGTTGGTTGGTACGTGAGACACGCAACAGGGGAAAGGCAAGGCACACAGGGGATAGGGGTTAGGGTTTTGATTGGGTTGT
+>read_starts_with_adapter 4a
+TGAGACACGCAACAGGGGAAAGGCAAGGCACACAGGGGATAGGAAAGGTTTTGGTTTTTATAGGTTTTT
+>read_starts_with_end_of_adapter 4b
+AACAGGGGAAAGGCAAGGCACACAGGGGATAGGAAAGGTTTTGGTTTTTATAGGTTTTT
diff --git a/tests/data/E3M.fasta b/tests/data/E3M.fasta
new file mode 100644
index 0000000..daa7686
--- /dev/null
+++ b/tests/data/E3M.fasta
@@ -0,0 +1,59 @@
+>E3MFGYR02JWQ7T length=260 xy=3946_2103 region=2 run=R_2008_01_09_16_16_00_
+tcagGGTCTACATGTTGGTTAACCCGTACTGATTTGAATTGGCTCTTTGTCTTTCCAAAG
+GGAATTCATCTTCTTATGGCACACATAAAGGATAAATACAAGAATCTTCCTATTTACATC
+ACTGAAAATGGCATGGCTGAATCAAGGAATGACTCAATACCAGTCAATGAAGCCCGCAAG
+GATAGTATAAGGATTAGATACCATGATGGCCATCTTAAATTCCTTCTTCAAGCGATCAAG
+GAAGGTGTTAATTTGAAGGGGCTTa
+>E3MFGYR02JA6IL length=265 xy=3700_3115 region=2 run=R_2008_01_09_16_16_00_
+tcagTTTTTTTTGGAAAGGAAAACGGACGTACTCATAGATGGATCATACTGACGTTAGGA
+AAATAATTCATAAGACAATAAGGAAACAAAGTGTAAAAAAAAAACCTAAATGCTCAAGGA
+AAATACATAGCCATCTGAACAGATTTCTGCTGGAAGCCACATTTCTCGTAGAACGCCTTG
+TTCTCGACGCTGCAATCAAGAATCACCTTGTAGCATCCCATTGAACGCGCATGCTCCGTG
+AGGAACTTGATGATTCTCTTTCCCAAATGcc
+>E3MFGYR02JHD4H length=292 xy=3771_2095 region=2 run=R_2008_01_09_16_16_00_
+tcagAAAGACAAGTGGTATCAACGCAGAGTGGCCATTACGCCGGGGACTAGGTCATGTTA
+AGAGTGTAGCTTTGTGATGCTCTGCATCCGTCTTATGATAAAATTGAGGTTATCCTGAAA
+TAAAGTGTCTCAAACGATTTATTTTCCATTTATTGTATTTAATTTGAGTCCAAACTAGAT
+TAGAGATCTCTGTAATAAAACATGTTTGTTAGTTTAATTTCAATAACATTTAGTATTGTG
+TCGTAAAAAAAAAAAAAACGAAAAAAAAAAAAACAAAAAAAAAAACAAATGTACGGccgg
+ctagagaacg
+>E3MFGYR02GFKUC length=295 xy=2520_2738 region=2 run=R_2008_01_09_16_16_00_
+tcagCGGCCGGGCCTCTCATCGGTGGTGGAATCACTGGCCTTGTTTACGAGGTTGTCTTT
+ATCAGCCACACCCACGAGCAGCTTCCCACCACTGACTACTAGAGGGGGGGAAATGAAAAA
+TAAAAAAAAAAAATTGTGTATTATTGAATTTCTCTGGAATCTTCTTCTGTGTATGGTTTT
+CCTTCCTTGTGTTTTCTTCCTAATTCACTTTCGAGGGTTGTACTTGTTCCTTTCGTCTTA
+AATCCTTGGATGGTTGATGATCATGAAGTTCTCTTTAAAGTTAAATTATTATCATTTTG
+>E3MFGYR02FTGED length=277 xy=2268_2739 region=2 run=R_2008_01_09_16_16_00_
+tcagTGGTAATGGGGGGAAATTTAATTTTCTGATTTTATTATATATAGTTAATTGATGCT
+TTCGACGGTTTATATTTATGCGATTTGGTTTAGGTTTCAATGGAATTTTGTTGGTAGTTT
+ATATGATTGTATATAGTTATCAGCAACCTTATATTGTTTGCTTGCCTTTCTAGAGCACTC
+AGTGGAGATTTGAAACTTTGTTAGTGGAAAATTTGCAATTGTATGTTAATTGGAGATGGA
+GACAAAAAAGGAGGCAGATATTAATATTTATTTGGATATCA
+>E3MFGYR02FR9G7 length=256 xy=2255_0361 region=2 run=R_2008_01_09_16_16_00_
+tcagCTCCGTAAGAAGGTGCTGCCCGCCGTCATCGTCCGCCAGCGCAAGCCTTGGCGCCG
+AAAGGACGGTGTTTACATGTACTTCGAAGATAATGCTGGTGTTATCGTGAATCCCAAGGG
+TGAAATGAAAGGTTCTGCTATCACTGGTCCAATTGGGAAGGAGTGTGCTGATCTGTGGCC
+CAGGATTGCAAGTGCTGCCAATGCTATTGTTTAAGCTAGGATTTTAGTTTTTGTAATGTT
+TCAGCTTCTTGAAGTTGTTTc
+>E3MFGYR02GAZMS length=271 xy=2468_1618 region=2 run=R_2008_01_09_16_16_00_
+tcagAAAGAAGTAAGGTAAATAACAAACGACAGAGTGGCACATACTCCGGCAGTTCATGG
+GCAGTGACCCAGTTCAGAGAACCAAAGAACCTGAATAAGAATCTATGTCTACTGTGAATT
+TTGTGGCTTTCGTTGGAACGAAGGTAGCTTCGAAACAATAAAGTTATCTACTTCGCAATA
+TGAAGTGTTTCTGTTAGTTCTATGGTTCCTACTCCTAGCACCTCTTTTTCTTATAGAAAT
+GGACCACCGTGATTGGTACAAAAGNTGTACCTAGAtga
+>E3MFGYR02HHZ8O length=150 xy=2958_1574 region=2 run=R_2008_01_09_16_16_00_
+tcagACTTTCTTCTTTACCGTAACGTTGTTAAATTATCTGAGTATATGAAGGACCCTATT
+TGGGTTCTATAACTACAGAACATATCTCAGTCCAATAGTGACGGAATAACAATATTATAA
+ACTAGTTTAACGCTTTATGAAAAAAAAAAAAAAAgaaaaaaaaacatgtcggccgctgag
+acacgcaacaggggataggcaaggcacacaggggataggnn
+>E3MFGYR02GPGB1 length=221 xy=2633_0607 region=2 run=R_2008_01_09_16_16_00_
+tcagAAGCAGTGGTATCAACGCAGAGTGGCCATTACGGCCGGGTCTGATGAGTATGTGTC
+GAAGATCCCAAATAACAAGGTTGGTCTTGTAATTGGTAAAGGTGGAGAAACAATAAAGAA
+TATGCAAGCTTCAACTGGAGCAAGAATTCAGGTGATTCCTCTTCATCTTCCACCTGGTGA
+CACATCTACCAAAAAAAAAAAAAAAAAAAAACCAAATGTCGGCCGctgagacacgcaaca
+gggataggcaaggcacacaggggataggn
+>E3MFGYR02F7Z7G length=130 xy=2434_1658 region=2 run=R_2008_01_09_16_16_00_
+tcagAATCATCCACTTTTTAACGTTTTGTTTTGTTCATCTCTTAACAACAATTCTAGGGC
+GACAGAGAGAGTAAGTACCCACTAACCAGTCCCCAAGTACCAAAATAACAATTTAAACAA
+CAAAACACAAACAGatcttatcaacaaaactcaaagttcctaactgagacacgcaacagg
+ggataagacaaggcacacaggggataggnnnnnnnnnnn
diff --git a/tests/data/E3M.qual b/tests/data/E3M.qual
new file mode 100644
index 0000000..908e628
--- /dev/null
+++ b/tests/data/E3M.qual
@@ -0,0 +1,59 @@
+>E3MFGYR02JWQ7T length=260 xy=3946_2103 region=2 run=R_2008_01_09_16_16_00_
+23 24 26 38 31 11 27 28 25 28 22 25 27 28 36 27 32 22 33 23 27 16 40 33 18 28 28 24 25 20 26 26 37 31 10 21 27 16 36 28 32 22 27 26 28 37 30 9 28 27 26 36 29 8 33 23 37 30 9 37
+30 9 34 26 32 22 28 28 28 22 33 23 28 31 21 28 26 33 23 28 27 28 28 28 21 25 37 33 16 34 28 25 28 37 33 17 28 28 27 34 27 25 30 25 26 24 34 27 34 27 23 28 36 32 14 24 28 27 27 23
+26 25 27 25 36 32 18 1 27 29 21 26 24 27 31 22 27 26 26 34 26 28 27 33 26 34 26 33 26 28 26 27 27 27 27 28 19 25 25 31 23 28 28 28 27 33 26 26 26 27 18 21 35 31 12 21 28 34 28 32
+26 27 27 23 25 27 28 26 34 28 34 28 27 34 28 28 26 28 26 19 32 27 28 25 27 27 26 33 25 34 28 24 28 21 30 21 37 33 16 23 12 27 18 27 18 25 34 28 24 30 22 22 23 28 27 25 26 34 28 33
+26 19 6 34 28 25 25 32 27 34 28 37 33 17 25 34 28 36 32 18 2 17 24 14 17
+>E3MFGYR02JA6IL length=265 xy=3700_3115 region=2 run=R_2008_01_09_16_16_00_
+24 24 26 28 45 32 22 17 12 9 5 1 36 28 40 34 15 36 27 42 35 21 6 28 34 24 27 28 28 21 28 28 28 28 25 27 28 28 28 27 36 28 27 28 28 24 28 28 28 28 28 24 28 28 36 27 28 36 28 43
+36 22 10 28 19 5 36 28 28 25 28 37 28 28 12 28 33 26 28 24 11 35 26 41 34 15 27 40 33 18 28 28 24 24 44 26 17 13 10 7 6 4 2 1 22 9 27 36 33 17 27 26 26 27 28 30 22 33 26 36
+33 19 4 25 18 27 24 22 24 26 31 23 27 24 28 25 25 31 23 27 27 28 26 32 28 7 27 23 24 25 26 33 25 32 24 24 34 26 25 23 27 33 29 8 25 25 26 25 26 25 27 29 20 28 26 32 24 33 25 25
+29 20 24 26 28 23 25 26 26 27 25 27 27 27 18 27 28 31 23 27 31 23 27 23 27 33 27 34 27 27 26 28 26 27 28 27 37 33 15 24 33 26 27 27 18 26 25 27 27 27 25 28 26 27 25 34 28 27 24 27
+25 34 28 31 23 22 34 28 26 27 27 28 27 34 28 25 25 23 36 32 14 37 33 17 37 33 17 23 25 25 15
+>E3MFGYR02JHD4H length=292 xy=3771_2095 region=2 run=R_2008_01_09_16_16_00_
+19 23 27 28 41 34 16 27 27 27 27 16 28 22 33 23 23 28 27 27 36 28 28 28 28 22 26 26 28 26 34 24 36 27 26 37 28 28 27 28 36 28 43 36 22 9 24 21 26 28 36 27 27 28 28 28 27 37 28 36
+27 28 24 28 27 27 28 24 28 28 40 33 14 26 21 28 27 28 27 28 23 27 27 28 27 27 26 33 25 27 26 25 34 27 28 28 27 28 28 38 34 22 10 34 28 27 27 34 27 34 28 27 27 33 27 27 28 35 30 11
+28 37 33 17 27 28 26 27 27 23 25 36 32 14 27 27 24 32 28 7 28 36 32 19 3 30 21 22 37 33 15 21 34 27 28 22 26 36 33 17 34 28 37 33 17 26 21 26 24 34 27 35 31 12 20 27 27 28 25 34
+28 27 25 27 27 25 27 28 27 28 23 28 27 28 20 28 38 34 22 9 23 24 28 28 36 32 13 27 19 7 20 26 37 33 17 21 9 37 33 17 23 32 25 22 29 21 27 24 34 30 10 28 26 25 28 33 26 23 21 27
+28 27 26 23 32 20 11 7 5 3 2 1 1 1 1 1 1 1 20 25 33 21 13 8 6 4 3 2 2 1 1 1 1 23 34 25 16 11 9 7 5 4 3 1 1 21 37 33 17 21 27 25 28 28 34 27 32 27 21 9
+17 25 20 27 18 17 32 24 17 16
+>E3MFGYR02GFKUC length=295 xy=2520_2738 region=2 run=R_2008_01_09_16_16_00_
+24 23 24 27 28 36 28 37 28 39 32 13 34 25 22 28 27 28 26 28 28 37 28 28 36 28 26 36 28 36 28 27 28 27 28 26 36 28 36 28 35 26 28 41 34 17 28 28 28 27 36 28 37 28 28 27 28 41 34 16
+25 28 28 26 27 36 28 28 27 28 41 34 17 28 25 28 28 27 28 27 26 27 34 27 37 33 17 25 33 27 26 27 27 28 25 28 28 27 27 25 27 26 28 38 32 23 17 12 8 2 37 33 17 28 26 38 34 23 12 1
+28 34 23 15 10 8 6 4 3 2 1 1 1 31 23 28 26 26 28 26 34 27 24 34 27 28 34 27 37 33 16 27 24 25 28 34 27 34 27 28 28 34 26 26 34 28 27 27 28 27 28 27 28 28 34 28 38 34 23 11
+34 28 34 27 34 26 34 28 28 27 26 38 35 22 9 27 30 22 33 26 28 34 28 34 28 28 27 28 37 33 15 25 27 23 32 27 6 32 25 28 22 26 26 32 24 27 33 26 26 17 34 30 11 28 26 27 22 33 26 34
+30 10 26 30 22 34 28 33 25 26 27 34 28 31 26 24 28 28 28 28 26 28 28 27 28 32 24 26 34 26 27 28 26 34 30 10 32 28 7 27 33 25 35 31 12 34 27 25 30 22 23 28 27 23 38 34 23 11 26
+>E3MFGYR02FTGED length=277 xy=2268_2739 region=2 run=R_2008_01_09_16_16_00_
+21 24 28 24 28 35 27 28 35 28 28 44 35 24 16 9 2 41 34 17 40 34 15 34 26 43 36 22 9 28 25 26 26 41 34 20 5 26 37 28 27 27 28 28 28 28 28 28 37 28 36 28 37 28 28 28 27 26 26 38
+31 11 28 24 28 28 36 27 36 29 8 26 27 28 36 29 8 27 28 27 28 28 24 34 27 5 32 22 40 33 14 28 37 28 41 34 16 28 32 24 23 34 28 34 27 38 34 22 9 27 34 28 34 27 27 26 26 36 32 13
+28 27 26 28 28 25 34 26 27 28 28 27 28 23 27 28 34 26 27 25 27 26 28 23 32 24 34 28 33 26 28 26 27 27 18 25 36 32 13 27 27 32 24 27 32 25 35 31 12 27 28 26 27 21 27 27 27 26 28 28
+27 26 28 33 25 22 28 28 37 33 17 26 37 33 17 20 36 32 14 28 34 27 26 27 28 34 28 38 34 22 8 37 33 15 27 28 34 27 33 26 27 26 27 28 28 33 25 34 28 34 28 34 26 24 24 28 25 34 28 28
+27 25 23 38 33 24 17 11 5 34 28 25 31 26 22 27 27 27 26 22 34 26 34 27 26 24 34 30 11 19 37 33 15 34 28 27 25 28 25 27 27
+>E3MFGYR02FR9G7 length=256 xy=2255_0361 region=2 run=R_2008_01_09_16_16_00_
+21 22 26 28 28 24 35 26 27 28 36 28 28 37 28 36 27 28 28 26 25 24 37 30 9 28 36 28 28 21 28 26 28 28 28 28 36 28 28 35 26 27 25 25 28 28 36 28 23 31 20 32 22 29 18 27 27 34 25 28
+39 33 13 36 27 28 28 35 25 28 28 40 34 15 27 28 28 27 27 28 28 28 34 28 27 27 34 28 27 27 27 34 27 28 28 28 27 34 27 27 28 34 26 28 27 27 27 27 28 34 27 27 35 31 11 34 27 34 30 10
+28 27 34 30 10 27 28 37 33 15 33 25 33 26 26 28 26 27 27 27 28 26 26 28 27 34 27 26 31 23 34 28 34 28 37 33 15 34 28 34 28 27 23 27 28 27 27 28 23 28 27 25 27 24 27 22 34 28 37 33
+16 26 33 26 25 34 26 25 28 33 25 27 27 23 27 28 28 32 24 34 27 27 27 27 28 27 29 20 27 33 28 8 32 27 23 28 25 24 34 28 26 38 34 22 9 27 26 38 34 23 13 3 27 26 34 28 26 28 36 32
+14 23 28 27 20 33 25 28 30 22 26 33 25 23 34 28 23 34 30 10 27
+>E3MFGYR02GAZMS length=271 xy=2468_1618 region=2 run=R_2008_01_09_16_16_00_
+18 25 28 28 40 34 17 19 33 26 21 17 34 24 31 21 28 41 34 17 28 37 28 28 41 34 17 27 27 21 28 18 24 23 26 25 31 20 28 26 27 28 23 25 27 25 33 23 30 20 28 28 26 31 21 27 28 23 38 31
+11 28 28 28 28 28 26 39 33 13 28 28 35 25 28 26 28 27 28 35 26 36 27 35 31 11 28 32 24 34 28 26 25 34 28 28 34 28 24 33 25 27 27 28 26 27 27 26 27 27 27 27 27 26 27 28 34 27 38 34
+22 10 25 23 32 25 28 37 33 16 26 26 29 20 33 26 27 18 27 25 23 13 32 24 27 22 24 27 34 28 27 27 36 32 14 27 27 18 26 33 29 8 28 34 27 23 26 28 27 28 27 32 24 28 27 23 34 26 25 27
+27 24 34 28 26 25 27 36 32 17 25 25 27 33 27 27 27 34 28 28 28 27 25 34 28 33 27 34 28 28 27 23 25 34 28 27 27 27 28 27 34 27 20 23 38 34 24 15 7 26 22 11 28 27 23 26 36 32 14 22
+34 28 28 33 27 27 30 22 25 22 24 27 34 28 34 28 26 26 27 37 33 20 6 28 0 25 28 27 24 34 28 25 28 28 27 25 26 26
+>E3MFGYR02HHZ8O length=150 xy=2958_1574 region=2 run=R_2008_01_09_16_16_00_
+22 22 25 23 25 28 41 34 17 28 37 28 28 35 28 6 24 30 19 28 25 32 22 27 25 37 28 28 27 15 38 31 11 36 28 27 24 28 28 27 20 28 23 26 25 22 19 28 35 26 34 25 26 41 34 17 26 28 36 29
+7 36 29 8 35 26 28 28 28 24 33 23 28 24 27 27 23 25 34 24 26 24 28 27 22 28 26 28 24 27 28 34 27 34 27 26 27 28 26 27 28 28 34 28 31 23 25 30 22 27 29 21 26 27 34 27 28 26 37 33
+17 17 26 18 28 34 30 11 19 6 27 24 27 35 30 11 27 22 28 32 19 11 6 4 3 2 1 1 1 1 1 1 1 1 27 36 28 19 14 11 8 6 4 2 19 19 27 27 28 27 33 26 33 26 25 27 25 28 26 22
+28 25 27 27 28 25 34 28 28 24 38 34 21 7 28 25 17 33 26 26 31 26 34 27 27 27 27 26 26 28 38 34 23 12 27 28 25 33 27 0 0
+>E3MFGYR02GPGB1 length=221 xy=2633_0607 region=2 run=R_2008_01_09_16_16_00_
+21 24 27 28 36 28 28 28 26 28 28 36 28 28 27 24 28 36 27 28 28 28 23 27 27 28 28 37 28 36 27 27 37 28 28 28 37 28 36 27 41 34 17 28 28 28 28 27 28 28 28 26 28 28 28 28 28 28 28 28
+28 37 28 28 27 28 39 32 13 41 34 16 28 37 28 28 34 28 34 28 34 28 34 27 27 26 34 28 27 27 34 28 34 28 34 28 27 37 33 15 34 27 28 34 28 28 28 37 33 16 28 34 26 27 37 33 16 27 34 27
+26 27 27 27 28 34 28 26 23 34 27 25 34 27 28 26 34 28 27 25 28 34 27 27 33 26 34 28 27 28 34 27 27 27 27 34 28 34 27 25 26 34 27 26 24 27 28 34 27 32 24 27 31 23 28 34 27 27 25 28
+27 25 27 27 27 28 27 17 32 24 35 16 8 4 2 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 1 21 9 36 31 13 24 27 26 28 34 28 34 27 19 22 23 19 28 28 26 26 20 23 22 26 34 27 25 25
+36 32 17 27 27 24 24 14 21 34 27 31 23 23 28 22 27 27 28 36 32 18 2 27 27 22 25 15 0
+>E3MFGYR02F7Z7G length=130 xy=2434_1658 region=2 run=R_2008_01_09_16_16_00_
+22 21 23 28 26 15 12 21 28 21 36 28 27 27 43 35 23 12 1 36 28 27 27 41 34 20 5 28 43 36 22 9 27 35 26 28 26 27 26 28 22 33 26 37 28 26 36 27 28 35 27 31 20 26 28 13 38 32 12 26
+23 24 27 28 27 22 25 28 19 27 28 20 36 27 25 20 26 41 34 17 28 28 17 36 28 35 27 20 28 28 43 36 22 8 33 26 25 27 27 31 26 38 34 22 10 25 34 28 26 34 27 32 27 5 37 33 17 20 23 13
+27 37 33 19 4 27 28 20 37 33 17 24 26 23 27 21 26 33 26 26 27 28 34 27 21 38 34 21 7 28 25 24 37 33 17 28 34 28 32 24 27 33 27 27 20 28 27 27 22 28 19 25 22 28 32 26 27 23 37 33
+20 5 24 24 34 28 28 11 26 30 25 33 26 28 25 22 26 27 27 38 34 23 11 28 26 28 34 26 0 0 0 0 0 0 0 0 0 0 0
diff --git a/tests/data/adapter.fasta b/tests/data/adapter.fasta
new file mode 100644
index 0000000..3519ebc
--- /dev/null
+++ b/tests/data/adapter.fasta
@@ -0,0 +1,4 @@
+>adapter1
+GCCGAACTTCTTAGACTGCCTTAAGGACGT
+>adapter2
+CAGGTATATCGA
diff --git a/tests/data/anchored-back.fasta b/tests/data/anchored-back.fasta
new file mode 100644
index 0000000..651f3fb
--- /dev/null
+++ b/tests/data/anchored-back.fasta
@@ -0,0 +1,8 @@
+>read1
+sequenceBACKADAPTER
+>read2
+sequenceBACKADAPTERblabla
+>read3
+sequenceBACKADA
+>read4
+sequenceBECKADAPTER
diff --git a/tests/data/anchored.fasta b/tests/data/anchored.fasta
new file mode 100644
index 0000000..2af20a4
--- /dev/null
+++ b/tests/data/anchored.fasta
@@ -0,0 +1,8 @@
+>read1
+FRONTADAPTsequence
+>read2
+blablaFRONTADAPTsequence
+>read3
+NTADAPTsequence
+>read4
+FRINTADAPTsequence
diff --git a/tests/data/anchored_no_indels.fasta b/tests/data/anchored_no_indels.fasta
new file mode 100644
index 0000000..dcf626a
--- /dev/null
+++ b/tests/data/anchored_no_indels.fasta
@@ -0,0 +1,12 @@
+>no_mismatch (adapter: TTAGACATAT)
+TTAGACATATGAGGTCAG
+>one_mismatch
+TAAGACATATGAGGTCAG
+>two_mismatches
+TAAGACGTATGAGGTCAG
+>insertion
+ATTAGACATATGAGGTCAG
+>deletion
+TAGACATATGAGGTCAG
+>mismatch_plus_wildcard
+TNAGACGTATGAGGTCAG
diff --git a/tests/data/anywhere_repeat.fastq b/tests/data/anywhere_repeat.fastq
new file mode 100644
index 0000000..120d100
--- /dev/null
+++ b/tests/data/anywhere_repeat.fastq
@@ -0,0 +1,28 @@
+ at prefix:1_13_1400/1
+CGTCCGAANTAGCTACCACCCTGATTAGACAAAT
++
+)3%)&&&&!.1&(6:<'67..*,:75)'77&&&5
+ at prefix:1_13_1500/1
+CAAGACAAGACCTGCCACATTGCCCTAGTATTAA
++
+<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
+ at prefix:1_13_1550/1
+CAAGACAAGACCTGCCACATTGCCCTAGTCAAGA
++
+<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
+ at prefix:1_13_1600/1
+CAAGATGTCCCCTGCCACATTGCCCTAGTCAAGA
++
+<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
+ at prefix:1_13_1700/1
+CAAGATGTCCCCTGCCACATTGCCCTAGTTTATT
++
+<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
+ at prefix:1_13_1800/1
+GTTCATGTCCCCTGCCACATTGCCCTAGTTTATT
++
+<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
+ at prefix:1_13_1900/1
+ATGGCTGTCCCCTGCCACATTGCCCTAGTCAAGA
++
+<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
\ No newline at end of file
diff --git a/tests/data/dos.fastq b/tests/data/dos.fastq
new file mode 100644
index 0000000..6b1ecec
--- /dev/null
+++ b/tests/data/dos.fastq
@@ -0,0 +1,12 @@
+ at prefix:1_13_573/1
+CGTCCGAANTAGCTACCACCCTGATTAGACAAAT
++
+)3%)&&&&!.1&(6:<'67..*,:75)'77&&&5
+ at prefix:1_13_1259/1
+AGCCGCTANGACGGGTTGGCCCTTAGACGTATCT
++
+;<:&:A;A!9<<<,7:<=3=;:<&<?<?8<;=<&
+ at prefix:1_13_1440/1
+CAAGATCTNCCCTGCCACATTGCCCTAGTTAAAC
++
+<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
diff --git a/tests/data/empty.fastq b/tests/data/empty.fastq
new file mode 100644
index 0000000..e69de29
diff --git a/tests/data/example.fa b/tests/data/example.fa
new file mode 100644
index 0000000..b1fc713
--- /dev/null
+++ b/tests/data/example.fa
@@ -0,0 +1,18 @@
+>read1
+MYSEQUENCEADAPTER
+>read2
+MYSEQUENCEADAP
+>read3
+MYSEQUENCEADAPTERSOMETHINGELSE
+>read4
+MYSEQUENCEADABTER
+>read5
+MYSEQUENCEADAPTR
+>read6
+MYSEQUENCEADAPPTER
+>read7
+ADAPTERMYSEQUENCE
+>read8
+PTERMYSEQUENCE
+>read9
+SOMETHINGADAPTERMYSEQUENCE
diff --git a/tests/data/illumina.fastq.gz b/tests/data/illumina.fastq.gz
new file mode 100644
index 0000000..23f9a93
Binary files /dev/null and b/tests/data/illumina.fastq.gz differ
diff --git a/tests/data/illumina5.fastq b/tests/data/illumina5.fastq
new file mode 100644
index 0000000..c915c8d
--- /dev/null
+++ b/tests/data/illumina5.fastq
@@ -0,0 +1,20 @@
+ at SEQ:1:1101:9010:3891#0/1 adapter start: 51
+ATAACCGGAGTAGTTGAAATGGTAATAAGACGACCAATCTGACCAGCAAGGGCCTAACTTCTTAGACTGCCTTAAGGACGTAAGCCAAGATGGGAAAGGTC
++
+FFFFFEDBE at 79@@>@CBCBFDBDFDDDDD<@C>ADD at B;5:978 at CBDDFFDB4B?DB21;84?DDBC9DEBAB;=@<@@B@@@@B>CCBBDE98>>0 at 7
+ at SEQ:1:1101:9240:3898#0/1
+CCAGCAAGGAAGCCAAGATGGGAAAGGTCATGCGGCATACGCTCGGCGCCAGTTTGAATATTAGACATAATTTATCCTCAAGTAAGGGGCCGAAGCCCCTG
++
+GHGHGHHHHGGGDHHGDCGFEEFHHGDFGEHHGFHHHHHGHEAFDHHGFHHEEFHGHFHHFHGEHFBHHFHHHH at GGGDGDFEEFC@=D?GBGFGF:FB6D
+ at SEQ:1:1101:9207:3899#0/1 adapter start: 64
+TTAACTTCTCAGTAACAGATACAAACTCATCACGAACGTCAGAAGCAGCCTTATGGCCGTCAACGCCTAACTTCTTAGACTGCCTTAAGGACGTATACATA
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHFHHHHHHCFHHFHHFHFFFFFBHHGHHHFFHHFHGGHHDEBFG<FGGDG
+ at SEQ:1:1101:9148:3908#0/1 adapter start: 28
+ACGACGCAATGGAGAAAGACGGAGAGCGGCCTAACTTCTTAGACTGCCTTAAGGACGTCCAACGGCGTCCATCTCGAAGGAGTCGCCAGCGATAACCGGAG
++
+HHHHHHHHHHHHGHHHHGHHHHHHHHHHHHHHHHHHHHHHHHHHHGHHHHDHDHHFHHHHHFFFFFHHHEFBEGEGGFFFHHHFHHHHHHFHHEHHGHEHD
+ at SEQ:1:1101:9044:3916#0/1 adapter start: 78
+AACAGAAGGAGTCTACTGCTCGCGTTGCGTCTATTATGGAAAACACCAATCTTTCCAAGCAACAGCAGGTTTCCGAGAGCCTAACTTCTTAGACTGCCTTA
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHGHHHHGHHHHHHHHHHHHFHEBFHFFEFHEFHHGHFHHHHGGHGHHFHGGGHG
diff --git a/tests/data/illumina64.fastq b/tests/data/illumina64.fastq
new file mode 100644
index 0000000..bc5b102
--- /dev/null
+++ b/tests/data/illumina64.fastq
@@ -0,0 +1,80 @@
+ at 14569
+AAGTTTATTCCTGGACGAAGGAAGAAAAGGCCAGATGGGAAACAAGAACAAGCCCCTGTTGAAGACGCAGGGCCAACAGGGGCCAACGAAGCTGC
++
+cceeeeceeeee`dedbdbdb_^b`abU_cacadabd`dLMZ[XTcT^a^adaaaddcd`aL^`^_`Y\]^`Y_BBBBBBBBBBBBBBBBBBBBB
+ at 19211
+AGAGGGCGTGTGATTGCTGGATGTGGGCGGGGGGCCGGGGGAGCCCCATGGGCAGGAGACCTGAGAGCCAGGCGGTGAGGCACTATGAACGCGAG
++
+^\`BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
+ at 9180
+GAGGGGCAGCGACTAGTCACCGGACCTGTCAGGCAAGCATAAGCCGTGCGTCAGCACCACGCTGACGGTGCTCCCGCACTCGCGGGACGCGCCAC
++
+b`bLbBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
+ at 19132
+TGTGATTATCCACTGGTATATCGGCGTGCCGTCCGCACGAGGAAAAAAGGCATTATTGTTGTGGATCTGTACCATCGTTTGTCCCGTTACCCTTC
++
+Z[QZZLZ[]J[SHZNaZ[_IaBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
+ at 15868
+CTGCCAAGGCTGCCCCCAAACCTGGCCCTCCGCGCACCCCACCACGGATCCTGACGTCCTGTCCCCCGCGGCTATGACAGCCAAGTCCCGTCAGC
++
+`c`cc\`\Lb]bL`[`a]L`BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
+ at 1424
+GGCCCCAGACTTGCTCCCCCAACAAGGACAATGTCCAAGGAGTGTCCCCTGGGAAGGGTGGGCCTCCCCAGGTGCGGGCGGTGGGCACTGCCCCC
++
+eeeeeeeea`bbdaaadad`Oaaaaccada_aa_d`_X`_^`[`_[_W^BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
+ at 7855
+GTGGGGGCTACAATGTGGCTCCAAGTTTTTTCCCGGGAGGTAAGGCCGGGAGCCCCCGCCCTGAGGGGGCGGGAAAGAGGAAGCCCGACGCGGAC
++
+]^\]FW]Z`BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
+ at 17943
+ACATGGGACCAGAAAACACCACCAGGGGTTTGGGGCTGTCCTGAGGCTCGGGTAGCAAGCAGCGGGGCTCCGTGTCCAAGCACGCCGGTGTCACC
++
+ccc`\^`aba\b^`\FR`OOPYG[[W```[Ra_RR_\]\\P\_H_BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
+ at 11100
+CGGATAACTGAAAATGCATTTTTAACGCCATGACCGTGTCTCAAGGACCCGCTGTGGAAGGGGCGCCGCAGCCAGAAGCTGGCCATGTCAGCGCG
++
+b`b_b_a\bc^Tabadaddcddd``bdaa_^aJ\^_\]\\__O[___L^\_aaa^^^UJ^BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
+ at 15663
+AGGTGAAGTGGCAGGAGGACCGCCGGAAGAAGCTCTTCAGAACTCAGGGGGAGGGGGAAAGCAGAAACCAGAAGTCCAGTGAGCAGGGGGCTGAG
++
+aaKaBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
+ at 4698
+CCAATTGGCACCCCTCTGCCTTCAGCCATTCCCTCTGGCTACTGCTCTCTGGTCGGGGCGCCTGGGCGACAGACTCTCTCCCCCCACCCCCCCGC
++
+cccc\`ccc\caccZccccc]^`LY\bL_bBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
+ at 20649
+TCTGGACTGGATCTTTAGGATGGTGGAGATGATCTGGATGTAGGACAAAAGAACCAGGCAGAAGGGTGTCATCAGAAGAACACTGCTAGACACCA
++
+eeeeeaddadacdddebeccdddadd\^abbT_]bccTac]]b]L^][]Ve[^ZaY_^_^`\\Y]^Y`BBBBBBBBBBBBBBBBBBBBBBBBBBB
+ at 17259
+GCCTTGTGTTGTTCCTGGCATCACCGCAGGGAGCCCTGGGGGGCCAGGCGGGCGCTGACCCTGGGCACTGCCGCGCCTGGAGGGGCTGAGCACCG
++
+BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
+ at 6003
+CTTCAACTCATCTTGTTATTAATACCATCAATATCCCATGAGGCTCATAAAACGAGTCTTTCTTCTTGGAAACATGACCAAGATTGGGCAAACGT
++
+fffffffffffffffffdffecfcefeffdcfdeeebbbdbccccc\db\`^aa`^Y^^^cbcbaa`bbWY^^^__S_YYR]GWY]\]]XX\_`S
+ at 4118
+TCAAATTGTACTGCAAAGAAGGTCCCAGCTGGTCTCTTCTGGGAGTGATCTAACTAACTTAAGCTGACCCTGTGACTGGCTGAGGATAATCCCTT
++
+dc^ddeeeeeedeee`ceceddadadddcbde_dedc_ec_a^^b\b\\]VIPZY^T^^^\L_BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
+ at 18416
+GTGGGGAAGCCGAAGAAGCAGCGGAGATCGATTGTAAGAACGACGTCCATGACCAGGGTTGGTGGAGACTGCTTCTCTGCATGCGGGGGAAGGCG
++
+dddacaabdbea\d^cce\da`dd_^__`a`a`b[_^__^\^^^_BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
+ at 20115
+TGAAAAAGGAAAACATGGTAGTTTTCTTGTATGAGAGAGCCAGAGCCACCTTGGAGATTTTGTTCTCTCTGTGCGCACCAGTGATGACACAGGGG
++
+ed^eeafffaddfecdddabc^_badd`bd_ddadaa^bbcad\d\__^_\aaa_aY____aaN_\cdc\^aaYbBBBBBBBBBBBBBBBBBBBB
+ at 16139
+TCATCCGAAGAGTTGGCAGGCCCTGTGAATTGTGAAAACAGTATACCCACCCCTTTCCCGGAGCAGGACGCTGAATGTCCAGAGGATGCCAGACC
++
+cabacacY^c\daaddaadad^\ad_a\Y`[ZQ]Y^^OYQ^X^YT\\]U\^RRX^\YJ^BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
+ at 14123
+GATTTGGGGAAAGGAAACAATAGTTGAGTTTGGGCCACGGGAAATTCAAGATGCCTGGTATGTCAAGTCTGGCAGTTGAAGCAGCAGGGCTGGCG
++
+cccccccac^bYbbT_aa_Yb^^Ta\\^]]aaTaaaaab\b\XL`VZZV]QYYY[aa^^^^_^^BBBBBBBBBBBBBBBBBBBBBBBBBBBBBBB
+ at 8766
+ACCTGTAAGGTCCGCTCCTGGTGGACACCCACGAAGTCCAGGGCCTCAGGCAGGAAGTTGTAGCGCAGAGTTTTGAGCAGCTGCTCCATCAGGGA
++
+fcfffffcffeffeeefdefddeecdccacddfdYd`d^\_^`\_abbc\b[ba^Y^Z_^^H^Z_^Y_Y_OKWPZR]]Z]`Z``Z^UHZ^BBBBB
diff --git a/tests/data/issue46.fasta b/tests/data/issue46.fasta
new file mode 100644
index 0000000..50c9ce5
--- /dev/null
+++ b/tests/data/issue46.fasta
@@ -0,0 +1,2 @@
+>readname
+CGTGA
diff --git a/tests/data/lengths.fa b/tests/data/lengths.fa
new file mode 100644
index 0000000..c03f249
--- /dev/null
+++ b/tests/data/lengths.fa
@@ -0,0 +1,28 @@
+>read_length0a
+T330201030313112312
+>read_length0b
+T1330201030313112312
+>read_length1
+T21330201030313112312
+>read_length2
+T021330201030313112312
+>read_length3
+T3021330201030313112312
+>read_length4
+T33021330201030313112312
+>read_length5
+T233021330201030313112312
+>read_length6
+T0233021330201030313112312
+>read_length7
+T10233021330201030313112312
+>read_length8
+T110233021330201030313112312
+>read_length9
+T1110233021330201030313112312
+>read_length10
+T21110233021330201030313112312
+>read_length11
+T021110233021330201030313112312
+>read_length12
+T0021110233021330201030313112312
diff --git a/tests/data/lowqual.fastq b/tests/data/lowqual.fastq
new file mode 100644
index 0000000..7d7d92b
--- /dev/null
+++ b/tests/data/lowqual.fastq
@@ -0,0 +1,8 @@
+ at first_sequence
+SEQUENCE1
++
+#########
+ at second_sequence
+SEQUENCE2
++
+#########
diff --git a/tests/data/maxn.fasta b/tests/data/maxn.fasta
new file mode 100644
index 0000000..1110d12
--- /dev/null
+++ b/tests/data/maxn.fasta
@@ -0,0 +1,12 @@
+>r1
+
+>r2
+N
+>r3
+AAAA
+>r4
+AAAAN
+>r5
+AAANN
+>r6
+AANNN
diff --git a/tests/data/multiblock.fastq.gz b/tests/data/multiblock.fastq.gz
new file mode 100644
index 0000000..8c38897
Binary files /dev/null and b/tests/data/multiblock.fastq.gz differ
diff --git a/tests/data/overlapa.fa b/tests/data/overlapa.fa
new file mode 100644
index 0000000..3a4fac7
--- /dev/null
+++ b/tests/data/overlapa.fa
@@ -0,0 +1,40 @@
+>read1
+T0021110233021330201030313112312
+>read2
+T002111023302133020103031311231
+>read3
+T00211102330213302010303131123
+>read4
+T0021110233021330201030313112
+>read5
+T002111023302133020103031311
+>read6
+T00211102330213302010303131
+>read7
+T0021110233021330201030313
+>read8
+T002111023302133020103031
+>read9
+T00211102330213302010303
+>read10
+T0021110233021330201030
+>read11
+T002111023302133020103
+>read12
+T00211102330213302010
+>read13
+T0021110233021330201
+>read14
+T002111023302133020
+>read15
+T00211102330213302
+>read16
+T0021110233021330
+>read17
+T002111023302133
+>read18
+T00211102330213
+>read19
+T0021110233021
+>read20
+T002111023302
diff --git a/tests/data/overlapb.fa b/tests/data/overlapb.fa
new file mode 100644
index 0000000..c268fc3
--- /dev/null
+++ b/tests/data/overlapb.fa
@@ -0,0 +1,38 @@
+>adaptlen18
+TTAGACATATCTCCGTCGATACTTACCCGTA
+>adaptlen17
+TAGACATATCTCCGTCGATACTTACCCGTA
+>adaptlen16
+AGACATATCTCCGTCGATACTTACCCGTA
+>adaptlen15
+GACATATCTCCGTCGATACTTACCCGTA
+>adaptlen14
+ACATATCTCCGTCGATACTTACCCGTA
+>adaptlen13
+CATATCTCCGTCGATACTTACCCGTA
+>adaptlen12
+ATATCTCCGTCGATACTTACCCGTA
+>adaptlen11
+TATCTCCGTCGATACTTACCCGTA
+>adaptlen10
+ATCTCCGTCGATACTTACCCGTA
+>adaptlen9
+TCTCCGTCGATACTTACCCGTA
+>adaptlen8
+CTCCGTCGATACTTACCCGTA
+>adaptlen7
+TCCGTCGATACTTACCCGTA
+>adaptlen6
+CCGTCGATACTTACCCGTA
+>adaptlen5
+CGTCGATACTTACCCGTA
+>adaptlen4
+GTCGATACTTACCCGTA
+>adaptlen3
+TCGATACTTACCCGTA
+>adaptlen2
+CGATACTTACCCGTA
+>adaptlen1
+GATACTTACCCGTA
+>adaptlen0
+ATACTTACCCGTA
diff --git a/tests/data/paired.1.fastq b/tests/data/paired.1.fastq
new file mode 100644
index 0000000..3f2d733
--- /dev/null
+++ b/tests/data/paired.1.fastq
@@ -0,0 +1,16 @@
+ at read1/1 some text
+TTATTTGTCTCCAGCTTAGACATATCGCCT
++
+##HHHHHHHHHHHHHHHHHHHHHHHHHHHH
+ at read2/1
+CAACAGGCCACATTAGACATATCGGATGGT
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
+ at read3/1
+CCAACTTGATATTAATAACATTAGACA
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHH
+ at read4/1
+GACAGGCCGTTTGAATGTTGACGGGATGTT
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
diff --git a/tests/data/paired.2.fastq b/tests/data/paired.2.fastq
new file mode 100644
index 0000000..808df31
--- /dev/null
+++ b/tests/data/paired.2.fastq
@@ -0,0 +1,16 @@
+ at read1/2 other text
+GCTGGAGACAAATAACAGTGGAGTAGTTTT
++
+HHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
+ at read2/2
+TGTGGCCTGTTGCAGTGGAGTAACTCCAGC
++
+###HHHHHHHHHHHHHHHHHHHHHHHHHHH
+ at read3/2
+TGTTATTAATATCAAGTTGGCAGTG
++
+#HHHHHHHHHHHHHHHHHHHHHHHH
+ at read4/2
+CATCCCGTCAACATTCAAACGGCCTGTCCA
++
+HH############################
diff --git a/tests/data/plus.fastq b/tests/data/plus.fastq
new file mode 100644
index 0000000..35849f8
--- /dev/null
+++ b/tests/data/plus.fastq
@@ -0,0 +1,8 @@
+ at first_sequence some other text
+SEQUENCE1
++first_sequence some other text
+:6;;8<=:<
+ at second_sequence and more text
+SEQUENCE2
++second_sequence and more text
+83<??:(61
diff --git a/tests/data/polya.fasta b/tests/data/polya.fasta
new file mode 100644
index 0000000..4f02229
--- /dev/null
+++ b/tests/data/polya.fasta
@@ -0,0 +1,6 @@
+>polyA
+AAACTTCAGAACAGAAAAAAAAAAAAAAAAAAAAA
+>polyAlong
+CTTAGTTCAATWTTAACCAAACTTCAGAACAGAAAAAAAAAAAAAAAAAAAAAGAAAAAAAAAAAAAAAAAAAA
+>polyA2
+AAACTTAACAAGAACAAGAAAAAAAAAAAAAAAAAAAAA
diff --git a/tests/data/prefix-adapter.fasta b/tests/data/prefix-adapter.fasta
new file mode 100644
index 0000000..b56e57b
--- /dev/null
+++ b/tests/data/prefix-adapter.fasta
@@ -0,0 +1,2 @@
+>prefixadapter
+^FRONTADAPT
diff --git a/tests/data/rest.fa b/tests/data/rest.fa
new file mode 100644
index 0000000..31277ed
--- /dev/null
+++ b/tests/data/rest.fa
@@ -0,0 +1,18 @@
+>read1
+TESTINGADAPTERREST1
+>read2
+TESTINGADAPTERRESTING
+>read3
+TESTINGADAPTER
+>read4
+TESTINGADAPTERRESTLESS
+>read5
+TESTINGADAPTERRESTORE
+>read6
+ADAPTERSOMETHING
+>read7
+DAPTERSOMETHING
+>read8
+RESTADAPTERSOMETHING
+>read9
+NOREST
diff --git a/tests/data/rest.txt b/tests/data/rest.txt
new file mode 100644
index 0000000..31b1941
--- /dev/null
+++ b/tests/data/rest.txt
@@ -0,0 +1,5 @@
+REST1 read1
+RESTING read2
+RESTLESS read4
+RESTORE read5
+SOMETHING read8
diff --git a/tests/data/restfront.txt b/tests/data/restfront.txt
new file mode 100644
index 0000000..3cdba2f
--- /dev/null
+++ b/tests/data/restfront.txt
@@ -0,0 +1,6 @@
+TESTING read1
+TESTING read2
+TESTING read3
+TESTING read4
+TESTING read5
+REST read8
diff --git a/tests/data/s_1_sequence.txt.gz b/tests/data/s_1_sequence.txt.gz
new file mode 100644
index 0000000..3967383
Binary files /dev/null and b/tests/data/s_1_sequence.txt.gz differ
diff --git a/tests/data/simple.fasta b/tests/data/simple.fasta
new file mode 100644
index 0000000..e5c1d4c
--- /dev/null
+++ b/tests/data/simple.fasta
@@ -0,0 +1,7 @@
+# a comment
+# another one
+>first_sequence
+SEQUENCE1
+>second_sequence
+SEQUEN
+CE2
diff --git a/tests/data/simple.fasta~ b/tests/data/simple.fasta~
new file mode 100644
index 0000000..ba68078
--- /dev/null
+++ b/tests/data/simple.fasta~
@@ -0,0 +1,6 @@
+# a comment
+# another one
+>first_sequence
+SEQUENCE1
+>second_sequence
+SEQUENCE2
diff --git a/tests/data/simple.fastq b/tests/data/simple.fastq
new file mode 100644
index 0000000..f728223
--- /dev/null
+++ b/tests/data/simple.fastq
@@ -0,0 +1,8 @@
+ at first_sequence
+SEQUENCE1
++
+:6;;8<=:<
+ at second_sequence
+SEQUENCE2
++
+83<??:(61
diff --git a/tests/data/small.fastq b/tests/data/small.fastq
new file mode 100644
index 0000000..767ca22
--- /dev/null
+++ b/tests/data/small.fastq
@@ -0,0 +1,12 @@
+ at prefix:1_13_573/1
+CGTCCGAANTAGCTACCACCCTGATTAGACAAAT
++
+)3%)&&&&!.1&(6:<'67..*,:75)'77&&&5
+ at prefix:1_13_1259/1
+AGCCGCTANGACGGGTTGGCCCTTAGACGTATCT
++
+;<:&:A;A!9<<<,7:<=3=;:<&<?<?8<;=<&
+ at prefix:1_13_1440/1
+CAAGATCTNCCCTGCCACATTGCCCTAGTTAAAC
++
+<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
diff --git a/tests/data/small.fastq.bz2 b/tests/data/small.fastq.bz2
new file mode 100644
index 0000000..d71a53a
Binary files /dev/null and b/tests/data/small.fastq.bz2 differ
diff --git a/tests/data/small.fastq.gz b/tests/data/small.fastq.gz
new file mode 100644
index 0000000..f843389
Binary files /dev/null and b/tests/data/small.fastq.gz differ
diff --git a/tests/data/small.fastq.xz b/tests/data/small.fastq.xz
new file mode 100644
index 0000000..a7f38cb
Binary files /dev/null and b/tests/data/small.fastq.xz differ
diff --git a/tests/data/small.myownextension b/tests/data/small.myownextension
new file mode 100644
index 0000000..767ca22
--- /dev/null
+++ b/tests/data/small.myownextension
@@ -0,0 +1,12 @@
+ at prefix:1_13_573/1
+CGTCCGAANTAGCTACCACCCTGATTAGACAAAT
++
+)3%)&&&&!.1&(6:<'67..*,:75)'77&&&5
+ at prefix:1_13_1259/1
+AGCCGCTANGACGGGTTGGCCCTTAGACGTATCT
++
+;<:&:A;A!9<<<,7:<=3=;:<&<?<?8<;=<&
+ at prefix:1_13_1440/1
+CAAGATCTNCCCTGCCACATTGCCCTAGTTAAAC
++
+<=A:A=57!7<';<6?5;;6:+:=)71>70<,=:
diff --git a/tests/data/solid.csfasta b/tests/data/solid.csfasta
new file mode 100644
index 0000000..1045429
--- /dev/null
+++ b/tests/data/solid.csfasta
@@ -0,0 +1,63 @@
+# Tue May  5 13:57:32 2009 /share/apps/corona/bin/filter_fasta.pl --output=/data/results/s0103/s0103_20090430_552to561_2_2/552to561/results.01/primary.20090505091459275 --name=s0103_20090430_552to561_2_2_552to561 --tag=F3 --minlength=35 --mincalls=25 --prefix=T /data/results/s0103/s0103_20090430_552to561_2_2/552to561/jobs/postPrimerSetPrimary.197/rawseq
+# Cwd: /state/partition1/home/pipeline
+# Title: s0103_20090430_552to561_2_2_552to561
+>1_13_85_F3
+T110020300.0113010210002110102330021
+>1_13_573_F3
+T312311200.3021301101113203302010003
+>1_13_1259_F3
+T002112130.2012223322111330201230313
+>1_13_1440_F3
+T110020313.1113211010332111302330001
+>1_14_177_F3
+T31330222020233321121323302013303311
+>1_14_238_F3
+T01331031200310022122230330201030313
+>1_15_1098_F3
+T32333033222233020223032312232220332
+>1_16_404_F3
+T03310320002130202331112133020103031
+>1_16_904_F3
+T21230102331022312232132021122111212
+>1_16_1315_F3
+T03231231112210333010310323302010003
+>1_16_1595_F3
+T22323211312111230022210011213302012
+>1_17_1379_F3
+T32011212111223230232132311321200123
+>1_18_1692_F3
+T12322233031100211233323300112200210
+>1_19_171_F3
+T10101101220213201111011320201230032
+>1_22_72_F3
+T13303032323221212301322233320210233
+>1_22_1377_F3
+T22221333311222312201132312022322300
+>1_23_585_F3
+T30010310310130312122123302013303131
+>1_23_809_F3
+T13130101101021211013220302223302112
+>1_24_138_F3
+T33211130100120323002033020123031311
+>1_24_206_F3
+T33330332002223002020303331321221000
+>1_25_143_F3
+T23202003031200220301303302012203132
+>1_25_1866_F3
+T03201321022131101112012330221130311
+>1_27_584_F3
+T10010330110103213112323303012103101
+>1_27_1227_F3
+T02003022123001003201002031303302011
+>1_27_1350_F3
+T13130101101021211013220222221301231
+>1_29_477_F3
+T13130101101021211013300302223003030
+>1_30_882_F3
+T20102033000233133320103031311233200
+>1_31_221_F3
+T03301311201100030300100233220102031
+>1_31_1313_F3
+T01331131300330122321000101010330201
+>1_529_129_F3
+T132222301020322102101322221322302.3302.3.3..221..3
diff --git a/tests/data/solid.fasta b/tests/data/solid.fasta
new file mode 100644
index 0000000..f9f1777
--- /dev/null
+++ b/tests/data/solid.fasta
@@ -0,0 +1,4 @@
+>problem1
+T01120212022222011231210231030201330
+>problem2
+T20201030313112322220210033020133031
diff --git a/tests/data/solid.fastq b/tests/data/solid.fastq
new file mode 100644
index 0000000..82c7b7a
--- /dev/null
+++ b/tests/data/solid.fastq
@@ -0,0 +1,120 @@
+ at 1_13_85_F3
+T110020300.0113010210002110102330021
++
+7&9<&77)& <7))%4'657-1+9;9,.<8);.;8
+ at 1_13_573_F3
+T312311200.3021301101113203302010003
++
+6)3%)&&&& .1&(6:<'67..*,:75)'77&&&5
+ at 1_13_1259_F3
+T002112130.2012223322111330201230313
++
+=;<:&:A;A 9<<<,7:<=3=;:<&<?<?8<;=<&
+ at 1_13_1440_F3
+T110020313.1113211010332111302330001
++
+=<=A:A=57 7<';<6?5;;6:+:=)71>70<,=:
+ at 1_14_177_F3
+T31330222020233321121323302013303311
++
+:8957;;54)'98924905;;)6:7;1:3<88(9:
+ at 1_14_238_F3
+T01331031200310022122230330201030313
++
+?><5=;<<<12>=<;1;;=5);.;14:0>2;:3;7
+ at 1_15_1098_F3
+T32333033222233020223032312232220332
++
+#,##(#5##*#($$'#.##)$&#%)$1##-$&##%
+ at 1_16_404_F3
+T03310320002130202331112133020103031
++
+78;:;;><>9=9;<<2=><<1;58;9<<;>(<;<;
+ at 1_16_904_F3
+T21230102331022312232132021122111212
++
+9>=::6;;99=+/'$+#.#&%$&'(($1*$($.#.
+ at 1_16_1315_F3
+T03231231112210333010310323302010003
++
+<9<8A?>?::;6&,%;6/)8<<#/;79(448&*.)
+ at 1_16_1595_F3
+T22323211312111230022210011213302012
++
+>,<=<>@6<;?<=>:/=.>&;;8;)17:=&,>1=+
+ at 1_17_1379_F3
+T32011212111223230232132311321200123
++
+/-1179<1;>>8:':7-%/::0&+=<29,7<8(,2
+ at 1_18_1692_F3
+T12322233031100211233323300112200210
++
+.#(###5%)%2)',2&:+#+&5,($/1#&4&))$6
+ at 1_19_171_F3
+T10101101220213201111011320201230032
++
+)6:65/=3*:(8%)%2>&8&%;%0&#;$3$&:$#&
+ at 1_22_72_F3
+T13303032323221212301322233320210233
++
+3/#678<:.=9::6:(<538295;9+;&*;)+',&
+ at 1_22_1377_F3
+T22221333311222312201132312022322300
++
+)##0%.$.1*%,)95+%%14%$#8-###9-()#9+
+ at 1_23_585_F3
+T30010310310130312122123302013303131
++
+>55;8><96/18?)<3<58<5:;96=7:1=8=:-<
+ at 1_23_809_F3
+T13130101101021211013220302223302112
++
+:7<59@;<<5;/9;=<;7::.)&&&827(+221%(
+ at 1_24_138_F3
+T33211130100120323002033020123031311
++
+6)68/;906#,25/&;<$0+250#2,<)5,9/+7)
+ at 1_24_206_F3
+T33330332002223002020303331321221000
++
+))4(&)9592)#)694(,)292:(=7$.18,()65
+ at 1_25_143_F3
+T23202003031200220301303302012203132
++
+:4;/#&<9;&*;95-7;85&;587#16>%&,9<2&
+ at 1_25_1866_F3
+T03201321022131101112012330221130311
++
+=<>9;<@7?(=6,<&?=6=(=<641:?'<1=;':4
+ at 1_27_584_F3
+T10010330110103213112323303012103101
++
+82'('*.-8+%#2)(-&3.,.2,),+.':&,'(&/
+ at 1_27_1227_F3
+T02003022123001003201002031303302011
++
+492:;>A:<;34<<=);:<<;9=7<3::<::3=>'
+ at 1_27_1350_F3
+T13130101101021211013220222221301231
++
+95,)<(4./;<938=64=+2/,.4),3':97#33&
+ at 1_29_477_F3
+T13130101101021211013300302223003030
++
+94=55:75=+:/7><968;;#&+$#3&6,#1#4#'
+ at 1_30_882_F3
+T20102033000233133320103031311233200
++
+2(+-:-3<;5##/;:(%&84'#:,?3&&8>-();5
+ at 1_31_221_F3
+T03301311201100030300100233220102031
++
+89>9>5<139/,&:7969972.274&%:78&&746
+ at 1_31_1313_F3
+T01331131300330122321000101010330201
++
+;3<7=7::)5*4=&;<7>4;795065;9';896'=
+ at 1_529_129_F3
+T132222301020322102101322221322302.3302.3.3..221..3
++
+>>%/((B6-&5A0:6)>;'1)B*38/?(5=%B+ &<-9 % @  )%)  (
diff --git a/tests/data/solid.qual b/tests/data/solid.qual
new file mode 100644
index 0000000..f7c5c43
--- /dev/null
+++ b/tests/data/solid.qual
@@ -0,0 +1,63 @@
+# Tue May  5 13:57:32 2009 /share/apps/corona/bin/filter_fasta.pl --output=/data/results/s0103/s0103_20090430_552to561_2_2/552to561/results.01/primary.20090505091459275 --name=s0103_20090430_552to561_2_2_552to561 --tag=F3 --minlength=35 --mincalls=25 --prefix=T /data/results/s0103/s0103_20090430_552to561_2_2/552to561/jobs/postPrimerSetPrimary.197/rawseq
+# Cwd: /state/partition1/home/pipeline
+# Title: s0103_20090430_552to561_2_2_552to561
+>1_13_85_F3
+22 5 24 27 5 22 22 8 5 -1 27 22 8 8 4 19 6 21 20 22 12 16 10 24 26 24 11 13 27 23 8 26 13 26 23
+>1_13_573_F3
+21 8 18 4 8 5 5 5 5 -1 13 16 5 7 21 25 27 6 21 22 13 13 9 11 25 22 20 8 6 22 22 5 5 5 20
+>1_13_1259_F3
+28 26 27 25 5 25 32 26 32 -1 24 27 27 27 11 22 25 27 28 18 28 26 25 27 5 27 30 27 30 23 27 26 28 27 5
+>1_13_1440_F3
+28 27 28 32 25 32 28 20 22 -1 22 27 6 26 27 21 30 20 26 26 21 25 10 25 28 8 22 16 29 22 15 27 11 28 25
+>1_14_177_F3
+25 23 24 20 22 26 26 20 19 8 6 24 23 24 17 19 24 15 20 26 26 8 21 25 22 26 16 25 18 27 23 23 7 24 25
+>1_14_238_F3
+30 29 27 20 28 26 27 27 27 16 17 29 28 27 26 16 26 26 28 20 8 26 13 26 16 19 25 15 29 17 26 25 18 26 22
+>1_15_1098_F3
+2 11 2 2 7 2 20 2 2 9 2 7 3 3 6 2 13 2 2 8 3 5 2 4 8 3 16 2 2 12 3 5 2 2 4
+>1_16_404_F3
+22 23 26 25 26 26 29 27 29 24 28 24 26 27 27 17 28 29 27 27 16 26 20 23 26 24 27 27 26 29 7 27 26 27 26
+>1_16_904_F3
+24 29 28 25 25 21 26 26 24 24 28 10 14 6 3 10 2 13 2 5 4 3 5 6 7 7 3 16 9 3 7 3 13 2 13
+>1_16_1315_F3
+27 24 27 23 32 30 29 30 25 25 26 21 5 11 4 26 21 14 8 23 27 27 2 14 26 22 24 7 19 19 23 5 9 13 8
+>1_16_1595_F3
+29 11 27 28 27 29 31 21 27 26 30 27 28 29 25 14 28 13 29 5 26 26 23 26 8 16 22 25 28 5 11 29 16 28 10
+>1_17_1379_F3
+14 12 16 16 22 24 27 16 26 29 29 23 25 6 25 22 12 4 14 25 25 15 5 10 28 27 17 24 11 22 27 23 7 11 17
+>1_18_1692_F3
+13 2 7 2 2 2 20 4 8 4 17 8 6 11 17 5 25 10 2 10 5 20 11 7 3 14 16 2 5 19 5 8 8 3 21
+>1_19_171_F3
+8 21 25 21 20 14 28 18 9 25 7 23 4 8 4 17 29 5 23 5 4 26 4 15 5 2 26 3 18 3 5 25 3 2 5
+>1_22_72_F3
+18 14 2 21 22 23 27 25 13 28 24 25 25 21 25 7 27 20 18 23 17 24 20 26 24 10 26 5 9 26 8 10 6 11 5
+>1_22_1377_F3
+8 2 2 15 4 13 3 13 16 9 4 11 8 24 20 10 4 4 16 19 4 3 2 23 12 2 2 2 24 12 7 8 2 24 10
+>1_23_585_F3
+29 20 20 26 23 29 27 24 21 14 16 23 30 8 27 18 27 20 23 27 20 25 26 24 21 28 22 25 16 28 23 28 25 12 27
+>1_23_809_F3
+25 22 27 20 24 31 26 27 27 20 26 14 24 26 28 27 26 22 25 25 13 8 5 5 5 23 17 22 7 10 17 17 16 4 7
+>1_24_138_F3
+21 8 21 23 14 26 24 15 21 2 11 17 20 14 5 26 27 3 15 10 17 20 15 2 17 11 27 8 20 11 24 14 10 22 8
+>1_24_206_F3
+8 8 19 7 5 8 24 20 24 17 8 2 8 21 24 19 7 11 8 17 24 17 25 7 28 22 3 13 16 23 11 7 8 21 20
+>1_25_143_F3
+25 19 26 14 2 5 27 24 26 5 9 26 24 20 12 22 26 23 20 5 26 20 23 22 2 16 21 29 4 5 11 24 27 17 5
+>1_25_1866_F3
+28 27 29 24 26 27 31 22 30 7 28 21 11 27 5 30 28 21 28 7 28 27 21 19 16 25 30 6 27 16 28 26 6 25 19
+>1_27_584_F3
+23 17 6 7 6 9 13 12 23 10 4 2 17 8 7 12 5 18 13 11 13 17 11 8 11 10 13 6 25 5 11 6 7 5 14
+>1_27_1227_F3
+19 24 17 25 26 29 32 25 27 26 18 19 27 27 28 8 26 25 27 27 26 24 28 22 27 18 25 25 27 25 25 18 28 29 6
+>1_27_1350_F3
+24 20 11 8 27 7 19 13 14 26 27 24 18 23 28 21 19 28 10 17 14 11 13 19 8 11 18 6 25 24 22 2 18 18 5
+>1_29_477_F3
+24 19 28 20 20 25 22 20 28 10 25 14 22 29 27 24 21 23 26 26 2 5 10 3 2 18 5 21 11 2 16 2 19 2 6
+>1_30_882_F3
+17 7 10 12 25 12 18 27 26 20 2 2 14 26 25 7 4 5 23 19 6 2 25 11 30 18 5 5 23 29 12 7 8 26 20
+>1_31_221_F3
+23 24 29 24 29 20 27 16 18 24 14 11 5 25 22 24 21 24 24 22 17 13 17 22 19 5 4 25 22 23 5 5 22 19 21
+>1_31_1313_F3
+26 18 27 22 28 22 25 25 8 20 9 19 28 5 26 27 22 29 19 26 22 24 20 15 21 20 26 24 6 26 23 24 21 6 28
+>1_529_129_F3
+29 29 4 14 7 7 33 21 12 5 20 32 15 25 21 8 29 26 6 16 8 33 9 18 23 14 30 7 20 28 4 33 10 -1 5 27 12 24 -1 4 -1 31 -1 -1 8 4 8 -1 -1 7 
diff --git a/tests/data/solid5p.fasta b/tests/data/solid5p.fasta
new file mode 100644
index 0000000..6b6d2cb
--- /dev/null
+++ b/tests/data/solid5p.fasta
@@ -0,0 +1,34 @@
+#  used adapter: CCGGAGGTCAGCTCGCTATA
+# in colorspace: C0302201212322332333
+>read1
+T1212322332333012001112122203233202221000211
+>read2
+T201212322332333200121311212133113001311002032
+>read3
+T02201212322332333211133003002232323010012320300
+>read4
+T0302201212322332333002010102312033021011121312131
+>read5
+T20302201212322332333221313210102120020302022233110
+>read6
+T20302211212322332333031203203013323021010020301321
+>read7
+T21301020302201212322332333203020130202120211322010013211
+>read8
+T2310321030130120302201212322332333232202123123111113113003200330
+>read9
+T0002132103320302201212322332333020123133023120320131020333011
+>read10
+T00322031320033220302201212322332333201130233321321011303133231200
+>read11
+T0302201212322332333.02010102312033021011121312131
+>read12
+T030220121232233233321
+>read13
+T03022012123223323332
+>read14
+T0302201212322332333
+>read15
+T030220121232233233
+>read16
+T030220121232233233
diff --git a/tests/data/solid5p.fastq b/tests/data/solid5p.fastq
new file mode 100644
index 0000000..1efba0a
--- /dev/null
+++ b/tests/data/solid5p.fastq
@@ -0,0 +1,64 @@
+ at read1
+T1212322332333012001112122203233202221000211
++
+:58)2";%4A,8>0;9C\'?276>#)49"<,>?/\'!A4$.%+
+ at read2
+T201212322332333200121311212133113001311002032
++
+44<@;(<3.37/''=:-9AA<&C2%$$;?A&5!C69:?-;&;65.
+ at read3
+T02201212322332333211133003002232323010012320300
++
+2!<A-BB&A/)'103&2$!00>#97*B.0A-@(*","B3><4&16(:
+ at read4
+T0302201212322332333002010102312033021011121312131
++
+74-:$-;&@>@0581-82'<&-81+%)7;<)6?83!&CB9"9B6307=&
+ at read5
+T20302201212322332333221313210102120020302022233110
++
+';4!-6?0$45.C#B+$(4+$9)27,(-*=,#4:;"/4++5<, at -784*'
+ at read6
+T20302211212322332333031203203013323021010020301321
++
++3"85:2=3<")$66*#4".4!.;:C%97@>75-";';*)A67CCC")$*
+ at read7
+T21301020302201212322332333203020130202120211322010013211
++
+,;0B at A"98!<=!*;5;650;';79!+8,4(2=+98:B at C@:+3*>2+6+2++C0.
+ at read8
+T2310321030130120302201212322332333232202123123111113113003200330
++
+C/$-"=6+1.8?AB!?'#.585 at 6:47@?>.315A-'9<%">6,+)*,)1-;:(691>?C)4A;
+ at read9
+T0002132103320302201212322332333020123133023120320131020333011
++
+(&?527&:=;6 at 6@03%95(-0#$:B8::B*4?@&)6>79C>)6C'5-#<!B:>0:A8+2*
+ at read10
+T00322031320033220302201212322332333201130233321321011303133231200
++
+&53)>2.+9?7%=&21;8!820961%3#0'5C.28347,2(55*1.,>%:(1A'A5=@7&&5?4'
+ at read11
+T0302201212322332333.02010102312033021011121312131
++
+6=@!85+6<A(&#@7"'C:&8B"195'@,@&:5=7;!&-9:%<!)>((>
+ at read12
+T030220121232233233321
++
+4&1.?+<-0(!(;://+0@?C
+ at read13
+T03022012123223323332
++
+!&,>"772,,/2/2A1C%5C
+ at read14
+T0302201212322332333
++
+@%$#B$A0B0&((<C*+.A
+ at read15
+T030220121232233233
++
+?B=,A#5"*?7268++:2
+ at read16
+T030220121232233233
++
+C=C=C:=+ at 77@723!C5
diff --git a/tests/data/sra.fastq b/tests/data/sra.fastq
new file mode 100644
index 0000000..a92a89c
--- /dev/null
+++ b/tests/data/sra.fastq
@@ -0,0 +1,24 @@
+ at 1_13_85_F3
+T110020300.0113010210002110102330021
++
+!7&9<&77)& <7))%4'657-1+9;9,.<8);.;8
+ at 1_13_573_F3
+T312311200.3021301101113203302010003
++
+!6)3%)&&&& .1&(6:<'67..*,:75)'77&&&5
+ at 1_13_1259_F3
+T002112130.2012223322111330201230313
++
+!=;<:&:A;A 9<<<,7:<=3=;:<&<?<?8<;=<&
+ at 1_13_1440_F3
+T110020313.1113211010332111302330001
++
+!=<=A:A=57 7<';<6?5;;6:+:=)71>70<,=:
+ at 1_14_177_F3
+T31330222020233321121323302013303311
++
+!:8957;;54)'98924905;;)6:7;1:3<88(9:
+ at 1_14_238_F3
+T01331031200310022122230330201030313
++
+!?><5=;<<<12>=<;1;;=5);.;14:0>2;:3;7
diff --git a/tests/data/suffix-adapter.fasta b/tests/data/suffix-adapter.fasta
new file mode 100644
index 0000000..65c68c3
--- /dev/null
+++ b/tests/data/suffix-adapter.fasta
@@ -0,0 +1,2 @@
+>suffixadapter
+BACKADAPTER$
diff --git a/tests/data/toolong.fa b/tests/data/toolong.fa
new file mode 100644
index 0000000..79a9a79
--- /dev/null
+++ b/tests/data/toolong.fa
@@ -0,0 +1,14 @@
+>read_length6
+T023302
+>read_length7
+T1023302
+>read_length8
+T11023302
+>read_length9
+T111023302
+>read_length10
+T2111023302
+>read_length11
+T02111023302
+>read_length12
+T002111023302
diff --git a/tests/data/tooshort.fa b/tests/data/tooshort.fa
new file mode 100644
index 0000000..a5e4711
--- /dev/null
+++ b/tests/data/tooshort.fa
@@ -0,0 +1,12 @@
+>read_length0a
+T
+>read_length0b
+T
+>read_length1
+T2
+>read_length2
+T02
+>read_length3
+T302
+>read_length4
+T3302
diff --git a/tests/data/tooshort.noprimer.fa b/tests/data/tooshort.noprimer.fa
new file mode 100644
index 0000000..e5e22b4
--- /dev/null
+++ b/tests/data/tooshort.noprimer.fa
@@ -0,0 +1,14 @@
+>read_length0a
+
+>read_length0b
+
+>read_length1
+
+>read_length2
+2
+>read_length3
+02
+>read_length4
+302
+>read_length5
+3302
diff --git a/tests/data/trimN3.fasta b/tests/data/trimN3.fasta
new file mode 100644
index 0000000..d936bad
--- /dev/null
+++ b/tests/data/trimN3.fasta
@@ -0,0 +1,2 @@
+>read1
+CAGTCGGTCCTGAGAGATGGGCGAGCGCTGGNANNNNNNNG
diff --git a/tests/data/trimN5.fasta b/tests/data/trimN5.fasta
new file mode 100644
index 0000000..ce681fe
--- /dev/null
+++ b/tests/data/trimN5.fasta
@@ -0,0 +1,2 @@
+>read1
+NGGCCTGGAATTCTCGGGTGCCAAGGAACTCCAGTCACCAG
diff --git a/tests/data/twoadapters.fasta b/tests/data/twoadapters.fasta
new file mode 100644
index 0000000..68d59a1
--- /dev/null
+++ b/tests/data/twoadapters.fasta
@@ -0,0 +1,6 @@
+>read1
+GATCCTCCTGGAGCTGGCTGATACCAGTATACCAGTGCTGATTGTTGAATTTCAGGAATTTCTCAAGCTCGGTAGC
+>read2
+CTCGAGAATTCTGGATCCTCTCTTCTGCTACCTTTGGGATTTGCTTGCTCTTGGTTCTCTAGTTCTTGTAGTGGTG
+>read3 (no adapter)
+AATGAAGGTTGTAACCATAACAGGAAGTCATGCGCATTTAGTCGAGCACGTAAGTTCATACGGAAATGGGTAAG
diff --git a/tests/data/wildcard.fa b/tests/data/wildcard.fa
new file mode 100644
index 0000000..f482927
--- /dev/null
+++ b/tests/data/wildcard.fa
@@ -0,0 +1,4 @@
+>1
+ANGTACGTTGCATGCA
+>2
+ACGTANGTTGCATGCA
diff --git a/tests/data/wildcardN.fa b/tests/data/wildcardN.fa
new file mode 100644
index 0000000..5c15266
--- /dev/null
+++ b/tests/data/wildcardN.fa
@@ -0,0 +1,6 @@
+>perfect
+TTTGGGGGGG
+>withN
+TTTGGNGGGG
+>1mism
+TTTGGGGCGG
diff --git a/tests/data/wildcard_adapter.fa b/tests/data/wildcard_adapter.fa
new file mode 100644
index 0000000..a62b84c
--- /dev/null
+++ b/tests/data/wildcard_adapter.fa
@@ -0,0 +1,8 @@
+>1
+ACGTAAAACGTTGCATGCA
+>2
+ACGTGGGACGTTGCATGCA
+>3b
+TGGCTGGCCACGTCCCACGTAA
+>4b
+TGGCTGGCCACGTTTTACGTCC
diff --git a/tests/data/withplus.fastq b/tests/data/withplus.fastq
new file mode 100644
index 0000000..b71fc07
--- /dev/null
+++ b/tests/data/withplus.fastq
@@ -0,0 +1,8 @@
+ at first_sequence
+SEQUENCE1
++this is different
+:6;;8<=:<
+ at second_sequence
+SEQUENCE2
++also different
+83<??:(61
diff --git a/tests/testadapters.py b/tests/testadapters.py
new file mode 100644
index 0000000..c86dc6a
--- /dev/null
+++ b/tests/testadapters.py
@@ -0,0 +1,92 @@
+# coding: utf-8
+from __future__ import print_function, division, absolute_import
+from nose.tools import raises, assert_raises
+
+from cutadapt.seqio import Sequence
+from cutadapt.adapters import Adapter, AdapterMatch, ColorspaceAdapter, FRONT, BACK
+
+def test_issue_52():
+	adapter = Adapter(
+		sequence='GAACTCCAGTCACNNNNN',
+		where=BACK,
+		max_error_rate=0.1,
+		min_overlap=5,
+		read_wildcards=False,
+		adapter_wildcards=True)
+	read = Sequence(name="abc", sequence='CCCCAGAACTACAGTCCCGGC')
+	am = AdapterMatch(astart=0, astop=17, rstart=5, rstop=21, matches=15, errors=2, front=None, adapter=adapter, read=read)
+	assert am.wildcards() == 'GGC'
+	"""
+	The result above should actually be 'CGGC' since the correct
+	alignment is this one:
+
+	adapter         GAACTCCAGTCACNNNNN
+	mismatches           X     X
+	read       CCCCAGAACTACAGTC-CCGGC
+
+	Since we do not keep the alignment, guessing 'GGC' is the best we
+	can currently do.
+	"""
+
+
+def test_issue_80():
+	# This issue turned out to not be an actual issue with the alignment
+	# algorithm. The following alignment is found because it has more matches
+	# than the 'obvious' one:
+	#
+	# TCGTATGCCGTCTTC
+	# =========X==XX=
+	# TCGTATGCCCTC--C
+	#
+	# This is correct, albeit a little surprising, since an alignment without
+	# indels would have only two errors.
+
+	adapter = Adapter(
+		sequence="TCGTATGCCGTCTTC",
+		where=BACK,
+		max_error_rate=0.2,
+		min_overlap=3,
+		read_wildcards=False,
+		adapter_wildcards=False)
+	read = Sequence(name="seq2", sequence="TCGTATGCCCTCC")
+	result = adapter.match_to(read)
+	assert result.errors == 3, result
+	assert result.astart == 0, result
+	assert result.astop == 15, result
+
+
+def test_str():
+	a = Adapter('ACGT', where=BACK, max_error_rate=0.1)
+	str(a)
+	str(a.match_to(Sequence(name='seq', sequence='TTACGT')))
+	ca = ColorspaceAdapter('0123', where=BACK, max_error_rate=0.1)
+	str(ca)
+
+
+ at raises(ValueError)
+def test_color():
+	ColorspaceAdapter('0123', where=FRONT, max_error_rate=0.1)
+
+
+def test_parse_braces():
+	assert Adapter.parse_braces('') == ''
+	assert Adapter.parse_braces('A') == 'A'
+	assert Adapter.parse_braces('A{0}') == ''
+	assert Adapter.parse_braces('A{1}') == 'A'
+	assert Adapter.parse_braces('A{2}') == 'AA'
+	assert Adapter.parse_braces('A{2}C') == 'AAC'
+	assert Adapter.parse_braces('ACGTN{3}TGACCC') == 'ACGTNNNTGACCC'
+	assert Adapter.parse_braces('ACGTN{10}TGACCC') == 'ACGTNNNNNNNNNNTGACCC'
+	assert Adapter.parse_braces('ACGTN{3}TGA{4}CCC') == 'ACGTNNNTGAAAACCC'
+	assert Adapter.parse_braces('ACGTN{0}TGA{4}CCC') == 'ACGTTGAAAACCC'
+
+
+def test_parse_braces_fail():
+	for expression in ['{', '}', '{}', '{5', '{1}', 'A{-7}', 'A{', 'A{1', 'N{7', 'AN{7', 'A{4{}',
+			'A{4}{3}', 'A{b}', 'A{6X}', 'A{X6}']:
+		print(expression)
+		try:
+			Adapter.parse_braces(expression)
+		except ValueError as e:
+			print(e)
+		assert_raises(ValueError, lambda: Adapter.parse_braces(expression))
diff --git a/tests/testalign.py b/tests/testalign.py
new file mode 100644
index 0000000..e5cc27b
--- /dev/null
+++ b/tests/testalign.py
@@ -0,0 +1,109 @@
+# coding: utf-8
+from __future__ import print_function, division, absolute_import
+
+from cutadapt.align import (locate, compare_prefixes, compare_suffixes,
+	ALLOW_WILDCARD_SEQ1, ALLOW_WILDCARD_SEQ2)
+from cutadapt.adapters import BACK
+
+def test_polya():
+	s = 'AAAAAAAAAAAAAAAAA'
+	t = 'ACAGAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA'
+	result = locate(s, t, 0.0, BACK)
+	#start_s, stop_s, start_t, stop_t, matches, cost = result
+	assert result == (0, len(s), 4, 4 + len(s), len(s), 0)
+
+
+# Sequences with IUPAC wildcards
+# R=A|G, Y=C|T, S=G|C, W=A|T, K=G|T, M=A|C, B=C|G|T, D=A|G|T, H=A|C|T, V=A|C|G,
+# N=A|C|G|T, X={}
+WILDCARD_SEQUENCES = [
+	'CCCATTGATC',  # original sequence without wildcards
+	'CCCRTTRATC',  # R=A|G
+	'YCCATYGATC',  # Y=C|T
+	'CSSATTSATC',  # S=G|C
+	'CCCWWWGATC',  # W=A|T
+	'CCCATKKATC',  # K=G|T
+	'CCMATTGMTC',  # M=A|C
+	'BCCATTBABC',  # B=C|G|T
+	'BCCATTBABC',  # B
+	'CCCDTTDADC',  # D=A|G|T
+	'CHCATHGATC',  # H=A|C|T
+	'CVCVTTVATC',  # V=A|C|G
+	'CCNATNGATC',  # N=A|C|G|T
+	'CCCNTTNATC',  # N
+#   'CCCXTTXATC',  # X
+]
+
+
+def test_compare_prefixes():
+	assert compare_prefixes('AAXAA', 'AAAAATTTTTTTTT') == (0, 5, 0, 5, 4, 1)
+	assert compare_prefixes('AANAA', 'AACAATTTTTTTTT', ALLOW_WILDCARD_SEQ1) == (0, 5, 0, 5, 5, 0)
+	assert compare_prefixes('AANAA', 'AACAATTTTTTTTT', ALLOW_WILDCARD_SEQ1) == (0, 5, 0, 5, 5, 0)
+	assert compare_prefixes('XAAAAA', 'AAAAATTTTTTTTT') == (0, 6, 0, 6, 4, 2)
+
+	a = WILDCARD_SEQUENCES[0]
+	for s in WILDCARD_SEQUENCES:
+		r = s + 'GCCAGGGTTGATTCGGCTGATCTGGCCG'
+		result = compare_prefixes(a, r, degenerate=ALLOW_WILDCARD_SEQ2)
+		assert result == (0, 10, 0, 10, 10, 0), result
+
+		result = compare_prefixes(r, a, degenerate=ALLOW_WILDCARD_SEQ1)
+		assert result == (0, 10, 0, 10, 10, 0)
+
+	for s in WILDCARD_SEQUENCES:
+		for t in WILDCARD_SEQUENCES:
+			r = s + 'GCCAGGG'
+			result = compare_prefixes(s, r, degenerate=ALLOW_WILDCARD_SEQ1|ALLOW_WILDCARD_SEQ2)
+			assert result == (0, 10, 0, 10, 10, 0)
+
+			result = compare_prefixes(r, s, degenerate=ALLOW_WILDCARD_SEQ1|ALLOW_WILDCARD_SEQ2)
+			assert result == (0, 10, 0, 10, 10, 0)
+
+	r = WILDCARD_SEQUENCES[0] + 'GCCAGG'
+	for deg in 0, ALLOW_WILDCARD_SEQ1, ALLOW_WILDCARD_SEQ2, ALLOW_WILDCARD_SEQ1|ALLOW_WILDCARD_SEQ2:
+		result = compare_prefixes('CCCXTTXATC', r, degenerate=deg)
+		assert result == (0, 10, 0, 10, 8, 2)
+
+
+def test_compare_suffixes():
+	assert compare_suffixes('AAXAA', 'TTTTTTTAAAAA') == (0, 5, 7, 12, 4, 1)
+	assert compare_suffixes('AANAA', 'TTTTTTTAACAA', ALLOW_WILDCARD_SEQ1) == (0, 5, 7, 12, 5, 0)
+	assert compare_suffixes('AANAA', 'TTTTTTTAACAA', ALLOW_WILDCARD_SEQ1) == (0, 5, 7, 12, 5, 0)
+	assert compare_suffixes('AAAAAX', 'TTTTTTTAAAAA') == (0, 6, 6, 12, 4, 2)
+
+
+def test_wildcards_in_adapter():
+	r = 'CATCTGTCC' + WILDCARD_SEQUENCES[0] + 'GCCAGGGTTGATTCGGCTGATCTGGCCG'
+	for a in WILDCARD_SEQUENCES:
+		result = locate(a, r, 0.0, BACK, degenerate=ALLOW_WILDCARD_SEQ1)
+		assert result == (0, 10, 9, 19, 10, 0), result
+
+	a = 'CCCXTTXATC'
+	result = locate(a, r, 0.0, BACK, degenerate=ALLOW_WILDCARD_SEQ1)
+	assert result is None
+
+
+def test_wildcards_in_read():
+	a = WILDCARD_SEQUENCES[0]
+	for s in WILDCARD_SEQUENCES:
+		r = 'CATCTGTCC' + s + 'GCCAGGGTTGATTCGGCTGATCTGGCCG'
+		result = locate(a, r, 0.0, BACK, degenerate=ALLOW_WILDCARD_SEQ2)
+		if 'X' in s:
+			assert result is None
+		else:
+			assert result == (0, 10, 9, 19, 10, 0), result
+
+
+def test_wildcards_in_both():
+	for a in WILDCARD_SEQUENCES:
+		for s in WILDCARD_SEQUENCES:
+			if 'X' in s or 'X' in a:
+				continue
+			r = 'CATCTGTCC' + s + 'GCCAGGGTTGATTCGGCTGATCTGGCCG'
+			result = locate(a, r, 0.0, BACK, degenerate=ALLOW_WILDCARD_SEQ1|ALLOW_WILDCARD_SEQ2)
+			assert result == (0, 10, 9, 19, 10, 0), result
+
+
+def test_no_match():
+	a = locate('CTGATCTGGCCG', 'AAAAGGG', 0.1, BACK)
+	assert a is None, a
diff --git a/tests/testcolorspace.py b/tests/testcolorspace.py
new file mode 100644
index 0000000..16a9d88
--- /dev/null
+++ b/tests/testcolorspace.py
@@ -0,0 +1,140 @@
+# coding: utf-8
+from __future__ import print_function, division, absolute_import
+
+from cutadapt.colorspace import encode, decode
+from cutadapt.scripts.cutadapt import main
+from .utils import run, datapath
+
+# If there are any unknown characters in the test sequence,
+# round tripping will only work if all characters after the
+# first unknown character are also unknown:
+# encode("TNGN") == "T444", but
+# decode("T444") == "TNNN".
+
+sequences = [
+	"",
+	"C",
+	"ACGGTC",
+	"TN",
+	"TN.",
+	"TNN.N",
+	"CCGGCAGCATTCATTACGACAACGTGGCACCGTGTTTTCTCGGTGGTA",
+	"TGCAGTTGATGATCGAAGAAAACGACATCATCAGCCAGCAAGTGC",
+	"CAGGGTTTGATGAGTGGCTGTGGGTGCTGGCGTATCCGGG"
+	]
+
+
+def test_encode():
+	assert encode("AA") == "A0"
+	assert encode("AC") == "A1"
+	assert encode("AG") == "A2"
+	assert encode("AT") == "A3"
+	assert encode("CA") == "C1"
+	assert encode("CC") == "C0"
+	assert encode("CG") == "C3"
+	assert encode("CT") == "C2"
+	assert encode("GA") == "G2"
+	assert encode("GC") == "G3"
+	assert encode("GG") == "G0"
+	assert encode("GT") == "G1"
+	assert encode("TA") == "T3"
+	assert encode("TC") == "T2"
+	assert encode("TG") == "T1"
+	assert encode("TT") == "T0"
+
+	assert encode("TN") == "T4"
+	assert encode("NT") == "N4"
+	assert encode("NN") == "N4"
+
+	assert encode("ACGGTC") == "A13012"
+	assert encode("TTT.N") == "T0044"
+	assert encode("TTNT.N") == "T04444"
+
+
+def test_decode():
+	for s in sequences:
+		expected = s.replace('.', 'N')
+		encoded = encode(s)
+		assert decode(encoded) == expected
+	assert decode('A.') == 'AN'
+	assert decode('C.') == 'CN'
+	assert decode('G.') == 'GN'
+	assert decode('T.') == 'TN'
+
+
+def test_qualtrim_csfastaqual():
+	'''-q with csfasta/qual files'''
+	run("-c -q 10", "solidqual.fastq", "solid.csfasta", 'solid.qual')
+
+
+def test_E3M():
+	'''Read the E3M dataset'''
+	# not really colorspace, but a fasta/qual file pair
+	main(['-o', '/dev/null', datapath("E3M.fasta"), datapath("E3M.qual")])
+
+
+def test_bwa():
+	'''MAQ-/BWA-compatible output'''
+	run("-c -e 0.12 -a 330201030313112312 -x 552: --maq", "solidmaq.fastq", "solid.csfasta", 'solid.qual')
+
+
+def test_bfast():
+	'''BFAST-compatible output'''
+	run("-c -e 0.12 -a 330201030313112312 -x abc: --strip-f3", "solidbfast.fastq", "solid.csfasta", 'solid.qual')
+
+
+def test_trim_095():
+	'''some reads properly trimmed since cutadapt 0.9.5'''
+	run("-c -e 0.122 -a 330201030313112312", "solid.fasta", "solid.fasta")
+
+
+def test_solid():
+	run("-c -e 0.122 -a 330201030313112312", "solid.fastq", "solid.fastq")
+
+
+def test_solid_basespace_adapter():
+	'''colorspace adapter given in basespace'''
+	run("-c -e 0.122 -a CGCCTTGGCCGTACAGCAG", "solid.fastq", "solid.fastq")
+
+
+def test_solid5p():
+	'''test 5' colorspace adapter'''
+	# this is not a real adapter, just a random string
+	# in colorspace: C0302201212322332333
+	run("-c -e 0.1 --trim-primer -g CCGGAGGTCAGCTCGCTATA", "solid5p.fasta", "solid5p.fasta")
+
+
+def test_solid5p_prefix_notrim():
+	'''test anchored 5' colorspace adapter, no primer trimming'''
+	run("-c -e 0.1 -g ^CCGGAGGTCAGCTCGCTATA", "solid5p-anchored.notrim.fasta", "solid5p.fasta")
+
+
+def test_solid5p_prefix():
+	'''test anchored 5' colorspace adapter'''
+	run("-c -e 0.1 --trim-primer -g ^CCGGAGGTCAGCTCGCTATA", "solid5p-anchored.fasta", "solid5p.fasta")
+
+
+def test_solid5p_fastq():
+	'''test 5' colorspace adapter'''
+	# this is not a real adapter, just a random string
+	# in colorspace: C0302201212322332333
+	run("-c -e 0.1 --trim-primer -g CCGGAGGTCAGCTCGCTATA", "solid5p.fastq", "solid5p.fastq")
+
+
+def test_solid5p_prefix_notrim_fastq():
+	'''test anchored 5' colorspace adapter, no primer trimming'''
+	run("-c -e 0.1 -g ^CCGGAGGTCAGCTCGCTATA", "solid5p-anchored.notrim.fastq", "solid5p.fastq")
+
+
+def test_solid5p_prefix_fastq():
+	'''test anchored 5' colorspace adapter'''
+	run("-c -e 0.1 --trim-primer -g ^CCGGAGGTCAGCTCGCTATA", "solid5p-anchored.fastq", "solid5p.fastq")
+
+
+def test_sra_fastq():
+	'''test SRA-formatted colorspace FASTQ'''
+	run("-c -e 0.1 --format sra-fastq -a CGCCTTGGCCGTACAGCAG", "sra.fastq", "sra.fastq")
+
+
+def test_no_zero_cap():
+	run("--no-zero-cap -c -e 0.122 -a CGCCTTGGCCGTACAGCAG", "solid-no-zerocap.fastq", "solid.fastq")
diff --git a/tests/testfilters.py b/tests/testfilters.py
new file mode 100644
index 0000000..abd85a1
--- /dev/null
+++ b/tests/testfilters.py
@@ -0,0 +1,41 @@
+# coding: utf-8
+"""
+Tests write output (should it return True or False or write)
+"""
+from __future__ import print_function, division, absolute_import
+
+from cutadapt.filters import NContentFilter, DISCARD, KEEP
+from cutadapt.seqio import Sequence
+
+def test_ncontentfilter():
+	# third parameter is True if read should be discarded
+	params = [
+		('AAA', 0, KEEP),
+		('AAA', 1, KEEP),
+		('AAACCTTGGN', 1, KEEP),
+		('AAACNNNCTTGGN', 0.5, KEEP),
+		('NNNNNN', 1, DISCARD),
+		('ANAAAA', 1/6, KEEP),
+		('ANAAAA', 0, DISCARD)
+	]
+	for seq, count, expected in params:
+		filter = NContentFilter(count=count)
+		_seq = Sequence('read1', seq, qualities='#'*len(seq))
+		assert filter(_seq) == expected
+
+
+def test_ncontentfilter_paired():
+	params = [
+		('AAA', 'AAA', 0, KEEP),
+		('AAAN', 'AAA', 0, DISCARD),
+		('AAA', 'AANA', 0, DISCARD),
+		('ANAA', 'AANA', 1, KEEP),
+	]
+	for seq1, seq2, count, expected in params:
+		filter = NContentFilter(count=count, check_second=False)
+		filter_cs = NContentFilter(count=count, check_second=True)
+		read1 = Sequence('read1', seq1, qualities='#'*len(seq1))
+		read2 = Sequence('read1', seq2, qualities='#'*len(seq2))
+		assert filter(read1, read2) == filter(read1)
+		# discard entire pair if one of the reads fulfills criteria
+		assert filter_cs(read1, read2) == expected
diff --git a/tests/testmodifiers.py b/tests/testmodifiers.py
new file mode 100644
index 0000000..5101755
--- /dev/null
+++ b/tests/testmodifiers.py
@@ -0,0 +1,36 @@
+# coding: utf-8
+from __future__ import print_function, division, absolute_import
+
+from cutadapt.seqio import Sequence
+from cutadapt.modifiers import UnconditionalCutter, NEndTrimmer, QualityTrimmer
+
+def test_unconditional_cutter():
+	uc = UnconditionalCutter(length=5)
+	s = 'abcdefg'
+	assert UnconditionalCutter(length=2)(s) == 'cdefg'
+	assert UnconditionalCutter(length=-2)(s) == 'abcde'
+	assert UnconditionalCutter(length=100)(s) == ''
+	assert UnconditionalCutter(length=-100)(s) == ''
+
+
+def test_nend_trimmer():
+	trimmer = NEndTrimmer()
+	seqs = ['NNNNAAACCTTGGNNN', 'NNNNAAACNNNCTTGGNNN', 'NNNNNN']
+	trims = ['AAACCTTGG', 'AAACNNNCTTGG', '']
+	for seq, trimmed in zip(seqs, trims):
+		_seq = Sequence('read1', seq, qualities='#'*len(seq))
+		_trimmed = Sequence('read1', trimmed, qualities='#'*len(trimmed))
+		assert trimmer(_seq) == _trimmed
+
+
+def test_quality_trimmer():
+	read = Sequence('read1', 'ACGTTTACGTA', '##456789###')
+
+	qt = QualityTrimmer(10, 10, 33)
+	assert qt(read) == Sequence('read1', 'GTTTAC', '456789')
+
+	qt = QualityTrimmer(0, 10, 33)
+	assert qt(read) == Sequence('read1', 'ACGTTTAC', '##456789')
+
+	qt = QualityTrimmer(10, 0, 33)
+	assert qt(read) == Sequence('read1', 'GTTTACGTA', '456789###')
diff --git a/tests/testpaired.py b/tests/testpaired.py
new file mode 100644
index 0000000..6084bb5
--- /dev/null
+++ b/tests/testpaired.py
@@ -0,0 +1,169 @@
+# coding: utf-8
+from __future__ import print_function, division, absolute_import
+
+import shutil
+from nose.tools import raises
+from cutadapt.scripts import cutadapt
+from .utils import run, files_equal, datapath, cutpath, redirect_stderr, temporary_path
+
+def run_paired(params, in1, in2, expected1, expected2):
+	if type(params) is str:
+		params = params.split()
+	with temporary_path("temp-paired.1.fastq") as p1:
+		with temporary_path("temp-paired.2.fastq") as p2:
+			params += ['-o', p1, '-p', p2]
+			params += [datapath(in1), datapath(in2)]
+			assert cutadapt.main(params) is None
+			assert files_equal(cutpath(expected1), p1)
+			assert files_equal(cutpath(expected2), p2)
+
+
+def test_paired_separate():
+	'''test separate trimming of paired-end reads'''
+	run('-a TTAGACATAT', 'paired-separate.1.fastq', 'paired.1.fastq')
+	run('-a CAGTGGAGTA', 'paired-separate.2.fastq', 'paired.2.fastq')
+
+
+def test_paired_end_legacy():
+	'''--paired-output, not using -A/-B/-G'''
+	# the -m 14 filters out one read, which should then also be filtered out in the second output file
+	# -q 10 should not change anything: qualities in file 1 are high enough,
+	# qualities in file 2 should not be inspected.
+	run_paired('-a TTAGACATAT -m 14 -q 10',
+		in1='paired.1.fastq', in2='paired.2.fastq',
+		expected1='paired.m14.1.fastq', expected2='paired.m14.2.fastq'
+	)
+
+
+def test_untrimmed_paired_output():
+	with temporary_path("tmp-untrimmed.1.fastq") as untrimmed1:
+		with temporary_path("tmp-untrimmed.2.fastq") as untrimmed2:
+			run_paired(['-a', 'TTAGACATAT',
+				'--untrimmed-output', untrimmed1,
+				'--untrimmed-paired-output', untrimmed2],
+				in1='paired.1.fastq', in2='paired.2.fastq',
+				expected1='paired-trimmed.1.fastq', expected2='paired-trimmed.2.fastq'
+			)
+			assert files_equal(cutpath('paired-untrimmed.1.fastq'), untrimmed1)
+			assert files_equal(cutpath('paired-untrimmed.2.fastq'), untrimmed2)
+
+
+def test_explicit_format_with_paired():
+	# Use --format=fastq with input files whose extension is .txt
+	with temporary_path("paired.1.txt") as txt1:
+		with temporary_path("paired.2.txt") as txt2:
+			shutil.copyfile(datapath("paired.1.fastq"), txt1)
+			shutil.copyfile(datapath("paired.2.fastq"), txt2)
+			run_paired('--format=fastq -a TTAGACATAT -m 14',
+				in1=txt1, in2=txt2,
+				expected1='paired.m14.1.fastq',
+				expected2='paired.m14.2.fastq'
+			)
+
+
+def test_no_trimming_legacy():
+	# make sure that this doesn't divide by zero
+	cutadapt.main(['-a', 'XXXXX', '-o', '/dev/null', '-p', '/dev/null', datapath('paired.1.fastq'), datapath('paired.2.fastq')])
+
+
+def test_no_trimming():
+	# make sure that this doesn't divide by zero
+	cutadapt.main(['-a', 'XXXXX', '-A', 'XXXXX', '-o', '/dev/null', '-p', '/dev/null', datapath('paired.1.fastq'), datapath('paired.2.fastq')])
+
+
+ at raises(SystemExit)
+def test_missing_file():
+	with redirect_stderr():
+		cutadapt.main(['-a', 'XX', '--paired-output', 'out.fastq', datapath('paired.1.fastq')])
+
+
+ at raises(SystemExit)
+def test_first_too_short():
+	with temporary_path("truncated.1.fastq") as trunc1:
+		# Create a truncated file in which the last read is missing
+		with open(datapath('paired.1.fastq')) as f:
+			lines = f.readlines()
+			lines = lines[:-4]
+		with open(trunc1, 'w') as f:
+			f.writelines(lines)
+		with redirect_stderr():
+			cutadapt.main('-a XX --paired-output out.fastq'.split() + [trunc1, datapath('paired.2.fastq')])
+
+
+ at raises(SystemExit)
+def test_second_too_short():
+	with temporary_path("truncated.2.fastq") as trunc2:
+		# Create a truncated file in which the last read is missing
+		with open(datapath('paired.2.fastq')) as f:
+			lines = f.readlines()
+			lines = lines[:-4]
+		with open(trunc2, 'w') as f:
+			f.writelines(lines)
+		with redirect_stderr():
+			cutadapt.main('-a XX --paired-output out.fastq'.split() + [datapath('paired.1.fastq'), trunc2])
+
+
+ at raises(SystemExit)
+def test_unmatched_read_names():
+	with temporary_path("swapped.1.fastq") as swapped:
+		# Create a file in which reads 2 and are swapped
+		with open(datapath('paired.1.fastq')) as f:
+			lines = f.readlines()
+			lines = lines[0:4] + lines[8:12] + lines[4:8] + lines[12:]
+		with open(swapped, 'w') as f:
+			f.writelines(lines)
+		with redirect_stderr():
+			cutadapt.main('-a XX --paired-output out.fastq'.split() + [swapped, datapath('paired.2.fastq')])
+
+
+def test_legacy_minlength():
+	'''Ensure -m is not applied to second read in a pair in legacy mode'''
+	run_paired('-a XXX -m 27',
+		in1='paired.1.fastq', in2='paired.2.fastq',
+		expected1='paired-m27.1.fastq', expected2='paired-m27.2.fastq'
+	)
+
+
+def test_paired_end():
+	'''single-pass paired-end with -m'''
+	run_paired('-a TTAGACATAT -A CAGTGGAGTA -m 14',
+		in1='paired.1.fastq', in2='paired.2.fastq',
+		expected1='paired.1.fastq', expected2='paired.2.fastq'
+	)
+
+
+def test_paired_anchored_back_no_indels():
+	run_paired("-a BACKADAPTER$ -A BACKADAPTER$ -N --no-indels",
+		in1='anchored-back.fasta', in2='anchored-back.fasta',
+		expected1='anchored-back.fasta', expected2="anchored-back.fasta"
+	)
+
+
+def test_paired_end_qualtrim():
+	'''single-pass paired-end with -q and -m'''
+	run_paired('-q 20 -a TTAGACATAT -A CAGTGGAGTA -m 14 -M 90',
+		in1='paired.1.fastq', in2='paired.2.fastq',
+		expected1='pairedq.1.fastq', expected2='pairedq.2.fastq'
+	)
+
+
+def test_paired_end_qualtrim_swapped():
+	'''single-pass paired-end with -q and -m, but files swapped'''
+	run_paired('-q 20 -a CAGTGGAGTA -A TTAGACATAT -m 14',
+		in1='paired.2.fastq', in2='paired.1.fastq',
+		expected1='pairedq.2.fastq', expected2='pairedq.1.fastq'
+	)
+
+
+def test_paired_end_cut():
+	run_paired('-u 3 -u -1 -U 4 -U -2',
+		in1='paired.1.fastq', in2='paired.2.fastq',
+		expected1='pairedu.1.fastq', expected2='pairedu.2.fastq'
+	)
+
+
+def test_paired_end_A_only():
+	run_paired('-A CAGTGGAGTA',
+		in1='paired.1.fastq', in2='paired.2.fastq',
+		expected1='paired-onlyA.1.fastq', expected2='paired-onlyA.2.fastq'
+	)
diff --git a/tests/tests.py b/tests/tests.py
new file mode 100644
index 0000000..c61d0ec
--- /dev/null
+++ b/tests/tests.py
@@ -0,0 +1,342 @@
+# coding: utf-8
+# TODO
+# test with the --output option
+# test reading from standard input
+from __future__ import print_function, division, absolute_import
+
+import os
+import sys
+from nose.tools import raises
+from cutadapt.scripts import cutadapt
+from .utils import run, files_equal, datapath, cutpath, redirect_stderr, temporary_path
+
+
+def test_example():
+	run('-N -b ADAPTER', 'example.fa', 'example.fa')
+
+def test_small():
+	run('-b TTAGACATATCTCCGTCG', 'small.fastq', 'small.fastq')
+
+def test_empty():
+	'''empty input'''
+	run('-a TTAGACATATCTCCGTCG', 'empty.fastq', 'empty.fastq')
+
+def test_newlines():
+	'''DOS/Windows newlines'''
+	run('-e 0.12 -b TTAGACATATCTCCGTCG', 'dos.fastq', 'dos.fastq')
+
+def test_lowercase():
+	'''lowercase adapter'''
+	run('-b ttagacatatctccgtcg', 'lowercase.fastq', 'small.fastq')
+
+
+def test_rest():
+	'''-r/--rest-file'''
+	with temporary_path('rest.tmp') as rest_tmp:
+		run(['-b', 'ADAPTER', '-N', '-r', rest_tmp], "rest.fa", "rest.fa")
+		assert files_equal(datapath('rest.txt'), rest_tmp)
+
+
+def test_restfront():
+	with temporary_path("rest.txt") as path:
+		run(['-g', 'ADAPTER', '-N', '-r', path], "restfront.fa", "rest.fa")
+		assert files_equal(datapath('restfront.txt'), path)
+
+
+def test_discard():
+	'''--discard'''
+	run("-b TTAGACATATCTCCGTCG --discard", "discard.fastq", "small.fastq")
+
+
+def test_discard_untrimmed():
+	'''--discard-untrimmed'''
+	run('-b CAAGAT --discard-untrimmed', 'discard-untrimmed.fastq', 'small.fastq')
+
+
+def test_plus():
+	'''test if sequence name after the "+" is retained'''
+	run("-e 0.12 -b TTAGACATATCTCCGTCG", "plus.fastq", "plus.fastq")
+
+
+def test_extensiontxtgz():
+	'''automatic recognition of "_sequence.txt.gz" extension'''
+	run("-b TTAGACATATCTCCGTCG", "s_1_sequence.txt", "s_1_sequence.txt.gz")
+
+
+def test_format():
+	'''the -f/--format parameter'''
+	run("-f fastq -b TTAGACATATCTCCGTCG", "small.fastq", "small.myownextension")
+
+
+def test_minimum_length():
+	'''-m/--minimum-length'''
+	run("-c -m 5 -a 330201030313112312", "minlen.fa", "lengths.fa")
+
+
+def test_too_short():
+	'''--too-short-output'''
+	run("-c -m 5 -a 330201030313112312 --too-short-output tooshort.tmp.fa", "minlen.fa", "lengths.fa")
+	assert files_equal(datapath('tooshort.fa'), "tooshort.tmp.fa")
+	os.remove('tooshort.tmp.fa')
+
+
+def test_too_short_no_primer():
+	'''--too-short-output and --trim-primer'''
+	run("-c -m 5 -a 330201030313112312 --trim-primer --too-short-output tooshort.tmp.fa", "minlen.noprimer.fa", "lengths.fa")
+	assert files_equal(datapath('tooshort.noprimer.fa'), "tooshort.tmp.fa")
+	os.remove('tooshort.tmp.fa')
+
+
+def test_maximum_length():
+	'''-M/--maximum-length'''
+	run("-c -M 5 -a 330201030313112312", "maxlen.fa", "lengths.fa")
+
+
+def test_too_long():
+	'''--too-long-output'''
+	run("-c -M 5 --too-long-output toolong.tmp.fa -a 330201030313112312", "maxlen.fa", "lengths.fa")
+	assert files_equal(datapath('toolong.fa'), "toolong.tmp.fa")
+	os.remove('toolong.tmp.fa')
+
+
+def test_length_tag():
+	'''454 data; -n and --length-tag'''
+	run("-n 3 -e 0.1 --length-tag length= " \
+		"-b TGAGACACGCAACAGGGGAAAGGCAAGGCACACAGGGGATAGG "\
+		"-b TCCATCTCATCCCTGCGTGTCCCATCTGTTCCCTCCCTGTCTCA", '454.fa', '454.fa')
+
+def test_overlap_a():
+	'''-O/--overlap with -a (-c omitted on purpose)'''
+	run("-O 10 -a 330201030313112312 -e 0.0 -N", "overlapa.fa", "overlapa.fa")
+
+def test_overlap_b():
+	'''-O/--overlap with -b'''
+	run("-O 10 -b TTAGACATATCTCCGTCG -N", "overlapb.fa", "overlapb.fa")
+
+def test_qualtrim():
+	'''-q with low qualities'''
+	run("-q 10 -a XXXXXX", "lowqual.fastq", "lowqual.fastq")
+
+def test_qualbase():
+	'''-q with low qualities, using ascii(quality+64) encoding'''
+	run("-q 10 --quality-base 64 -a XXXXXX", "illumina64.fastq", "illumina64.fastq")
+
+def test_quality_trim_only():
+	'''only trim qualities, do not remove adapters'''
+	run("-q 10 --quality-base 64", "illumina64.fastq", "illumina64.fastq")
+
+def test_twoadapters():
+	'''two adapters'''
+	run("-a AATTTCAGGAATT -a GTTCTCTAGTTCT", "twoadapters.fasta", "twoadapters.fasta")
+
+def test_polya():
+	'''poly-A tails'''
+	run("-m 24 -O 10 -a AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA", "polya.fasta", "polya.fasta")
+
+def test_polya_brace_notation():
+	'''poly-A tails'''
+	run("-m 24 -O 10 -a A{35}", "polya.fasta", "polya.fasta")
+
+def test_mask_adapter():
+	'''mask adapter with N (reads maintain the same length)'''
+	run("-b CAAG -n 3 --mask-adapter", "anywhere_repeat.fastq", "anywhere_repeat.fastq")
+
+def test_gz_multiblock():
+	'''compressed gz file with multiple blocks (created by concatenating two .gz files)'''
+	run("-b TTAGACATATCTCCGTCG", "small.fastq", "multiblock.fastq.gz")
+
+def test_suffix():
+	'''-y/--suffix parameter, combined with _F3'''
+	run("-c -e 0.12 -a 330201030313112312 -y _my_suffix --strip-f3", "suffix.fastq", "solid.csfasta", 'solid.qual')
+
+def test_read_wildcard():
+	'''test wildcards in reads'''
+	run("--match-read-wildcards -b ACGTACGT", "wildcard.fa", "wildcard.fa")
+
+def test_adapter_wildcard():
+	'''wildcards in adapter'''
+	for adapter_type, expected in (
+			("-a", "wildcard_adapter.fa"),
+			("-b", "wildcard_adapter_anywhere.fa")):
+		with temporary_path("wildcardtmp.txt") as wildcardtmp:
+			run("--wildcard-file {0} {1} ACGTNNNACGT".format(wildcardtmp, adapter_type),
+				expected, "wildcard_adapter.fa")
+			with open(wildcardtmp) as wct:
+				lines = wct.readlines()
+			lines = [ line.strip() for line in lines ]
+			assert lines == ['AAA 1', 'GGG 2', 'CCC 3b', 'TTT 4b']
+
+def test_wildcard_N():
+	'''test 'N' wildcard matching with no allowed errors'''
+	run("-e 0 -a GGGGGGG --match-read-wildcards", "wildcardN.fa", "wildcardN.fa")
+
+def test_illumina_adapter_wildcard():
+	run("-a VCCGAMCYUCKHRKDCUBBCNUWNSGHCGU", "illumina.fastq", "illumina.fastq.gz")
+
+def test_adapter_front():
+	'''test adapter in front'''
+	run("--front ADAPTER -N", "examplefront.fa", "example.fa")
+
+def test_literal_N():
+	'''test matching literal 'N's'''
+	run("-N -e 0.2 -a NNNNNNNNNNNNNN", "trimN3.fasta", "trimN3.fasta")
+
+def test_literal_N2():
+	run("-N -O 1 -g NNNNNNNNNNNNNN", "trimN5.fasta", "trimN5.fasta")
+
+def test_literal_N_brace_notation():
+	'''test matching literal 'N's'''
+	run("-N -e 0.2 -a N{14}", "trimN3.fasta", "trimN3.fasta")
+
+def test_literal_N2_brace_notation():
+	run("-N -O 1 -g N{14}", "trimN5.fasta", "trimN5.fasta")
+
+def test_anchored_front():
+	run("-g ^FRONTADAPT -N", "anchored.fasta", "anchored.fasta")
+
+def test_anchored_back():
+	run("-a BACKADAPTER$ -N", "anchored-back.fasta", "anchored-back.fasta")
+
+def test_anchored_back_no_indels():
+	run("-a BACKADAPTER$ -N --no-indels", "anchored-back.fasta", "anchored-back.fasta")
+
+
+def test_issue_46():
+	'''issue 46 - IndexError with --wildcard-file'''
+	with temporary_path("wildcardtmp.txt") as wildcardtmp:
+		run("--anywhere=AACGTN --wildcard-file={0}".format(wildcardtmp), "issue46.fasta", "issue46.fasta")
+
+def test_strip_suffix():
+	run("--strip-suffix _sequence -a XXXXXXX", "stripped.fasta", "simple.fasta")
+
+
+def test_info_file():
+	# The true adapter sequence in the illumina.fastq.gz data set is
+	# GCCTAACTTCTTAGACTGCCTTAAGGACGT (fourth base is different)
+	#
+	with temporary_path("infotmp.txt") as infotmp:
+		run(["--info-file", infotmp, '-a', 'adapt=GCCGAACTTCTTAGACTGCCTTAAGGACGT'], "illumina.fastq", "illumina.fastq.gz")
+		assert files_equal(cutpath('illumina.info.txt'), infotmp)
+
+
+def test_info_file_times():
+	with temporary_path("infotmp.txt") as infotmp:
+		run(["--info-file", infotmp, '--times', '2', '-a', 'adapt=GCCGAACTTCTTA', '-a', 'adapt2=GACTGCCTTAAGGACGT'], "illumina5.fastq", "illumina5.fastq")
+		assert files_equal(cutpath('illumina5.info.txt'), infotmp)
+
+
+def test_named_adapter():
+	run("-a MY_ADAPTER=GCCGAACTTCTTAGACTGCCTTAAGGACGT", "illumina.fastq", "illumina.fastq.gz")
+
+
+def test_adapter_with_U():
+	run("-a GCCGAACUUCUUAGACUGCCUUAAGGACGU", "illumina.fastq", "illumina.fastq.gz")
+
+
+def test_no_trim():
+	''' --no-trim '''
+	run("--no-trim --discard-untrimmed -a CCCTAGTTAAAC", 'no-trim.fastq', 'small.fastq')
+
+
+def test_bzip2():
+	'''test bzip2 support'''
+	run('-b TTAGACATATCTCCGTCG', 'small.fastq', 'small.fastq.bz2')
+
+
+try:
+	import lzma
+
+	def test_xz():
+		'''test xz support'''
+		run('-b TTAGACATATCTCCGTCG', 'small.fastq', 'small.fastq.xz')
+except ImportError:
+	pass
+
+
+ at raises(SystemExit)
+def test_qualfile_only():
+	with redirect_stderr():
+		cutadapt.main(['file.qual'])
+
+
+ at raises(SystemExit)
+def test_no_args():
+	with redirect_stderr():
+		cutadapt.main([])
+
+
+ at raises(SystemExit)
+def test_two_fastqs():
+	with redirect_stderr():
+		cutadapt.main([datapath('paired.1.fastq'), datapath('paired.2.fastq')])
+
+
+def test_anchored_no_indels():
+	'''anchored 5' adapter, mismatches only (no indels)'''
+	run('-g ^TTAGACATAT --no-indels -e 0.1', 'anchored_no_indels.fasta', 'anchored_no_indels.fasta')
+
+
+def test_anchored_no_indels_wildcard_read():
+	'''anchored 5' adapter, mismatches only (no indels), but wildcards in the read count as matches'''
+	run('-g ^TTAGACATAT --match-read-wildcards --no-indels -e 0.1', 'anchored_no_indels_wildcard.fasta', 'anchored_no_indels.fasta')
+
+
+def test_anchored_no_indels_wildcard_adapt():
+	'''anchored 5' adapter, mismatches only (no indels), but wildcards in the adapter count as matches'''
+	run('-g ^TTAGACANAT --no-indels -e 0.1', 'anchored_no_indels.fasta', 'anchored_no_indels.fasta')
+
+
+def test_unconditional_cut_front():
+	run('-u 5', 'unconditional-front.fastq', 'small.fastq')
+
+
+def test_unconditional_cut_back():
+	run('-u -5', 'unconditional-back.fastq', 'small.fastq')
+
+
+def test_unconditional_cut_both():
+	run('-u -5 -u 5', 'unconditional-both.fastq', 'small.fastq')
+
+
+def test_untrimmed_output():
+	with temporary_path('untrimmed.tmp.fastq') as tmp:
+		run(['-a', 'TTAGACATATCTCCGTCG', '--untrimmed-output', tmp], 'small.trimmed.fastq', 'small.fastq')
+		assert files_equal(cutpath('small.untrimmed.fastq'), tmp)
+
+
+def test_adapter_file():
+	run('-a file:' + datapath('adapter.fasta'), 'illumina.fastq', 'illumina.fastq.gz')
+
+def test_adapter_file_5p_anchored():
+	run('-N -g file:' + datapath('prefix-adapter.fasta'), 'anchored.fasta', 'anchored.fasta')
+
+def test_adapter_file_3p_anchored():
+	run('-N -a file:' + datapath('suffix-adapter.fasta'), 'anchored-back.fasta', 'anchored-back.fasta')
+
+
+def test_adapter_file_5p_anchored_no_indels():
+	run('-N --no-indels -g file:' + datapath('prefix-adapter.fasta'), 'anchored.fasta', 'anchored.fasta')
+
+
+def test_adapter_file_3p_anchored_no_indels():
+	run('-N --no-indels -a file:' + datapath('suffix-adapter.fasta'), 'anchored-back.fasta', 'anchored-back.fasta')
+
+
+def test_demultiplex():
+	multiout = os.path.join(os.path.dirname(__file__), 'data', 'tmp-demulti.{name}.fasta')
+	params = ['-a', 'first=AATTTCAGGAATT', '-a', 'second=GTTCTCTAGTTCT', '-o', multiout, datapath('twoadapters.fasta')]
+	assert cutadapt.main(params) is None
+	assert files_equal(cutpath('twoadapters.first.fasta'), multiout.format(name='first'))
+	assert files_equal(cutpath('twoadapters.second.fasta'), multiout.format(name='second'))
+	assert files_equal(cutpath('twoadapters.unknown.fasta'), multiout.format(name='unknown'))
+	os.remove(multiout.format(name='first'))
+	os.remove(multiout.format(name='second'))
+	os.remove(multiout.format(name='unknown'))
+
+
+def test_max_n():
+	run('--max-n 0', 'maxn0.fasta', 'maxn.fasta')
+	run('--max-n 1', 'maxn1.fasta', 'maxn.fasta')
+	run('--max-n 2', 'maxn2.fasta', 'maxn.fasta')
+	run('--max-n 0.2', 'maxn0.2.fasta', 'maxn.fasta')
+	run('--max-n 0.4', 'maxn0.4.fasta', 'maxn.fasta')
diff --git a/tests/testseqio.py b/tests/testseqio.py
new file mode 100644
index 0000000..27fbf13
--- /dev/null
+++ b/tests/testseqio.py
@@ -0,0 +1,175 @@
+# coding: utf-8
+from __future__ import print_function, division, absolute_import
+
+import sys
+from textwrap import dedent
+from nose.tools import raises
+from cutadapt import seqio
+from cutadapt.compat import StringIO
+
+
+# files tests/data/simple.fast{q,a}
+simple_fastq = [
+	seqio.Sequence("first_sequence", "SEQUENCE1", ":6;;8<=:<"),
+	seqio.Sequence("second_sequence", "SEQUENCE2", "83<??:(61")
+	]
+
+simple_fasta = [ seqio.Sequence(x.name, x.sequence, None) for x in simple_fastq ]
+
+
+def test_fastareader():
+	with seqio.FastaReader("tests/data/simple.fasta") as f:
+		reads = list(f)
+	assert reads == simple_fasta
+
+	fasta = StringIO(">first_sequence\nSEQUENCE1\n>second_sequence\nSEQUENCE2\n")
+	reads = list(seqio.FastaReader(fasta))
+	assert reads == simple_fasta
+
+
+def test_fastareader_with_comments():
+	fasta = StringIO(dedent(
+		"""
+		# a comment
+		# another one
+		>first_sequence
+		SEQUENCE1
+		>second_sequence
+		SEQUENCE2
+		"""))
+	reads = list(seqio.FastaReader(fasta))
+	assert reads == simple_fasta
+
+
+ at raises(seqio.FormatError)
+def test_wrong_fasta_format():
+	fasta = StringIO(dedent(
+		"""
+		# a comment
+		# another one
+		unexpected
+		>first_sequence
+		SEQUENCE1
+		>second_sequence
+		SEQUENCE2
+		"""))
+	reads = list(seqio.FastaReader(fasta))
+
+
+def test_fastqreader():
+	with seqio.FastqReader("tests/data/simple.fastq") as f:
+		reads = list(f)
+	assert reads == simple_fastq
+
+
+def test_fastqreader_dos():
+	with seqio.FastqReader("tests/data/dos.fastq") as f:
+		dos_reads = list(f)
+	with seqio.FastqReader("tests/data/small.fastq") as f:
+		unix_reads = list(f)
+	assert dos_reads == unix_reads
+
+
+def test_fastareader_keeplinebreaks():
+	with seqio.FastaReader("tests/data/simple.fasta", keep_linebreaks=True) as f:
+		reads = list(f)
+	assert reads[0] == simple_fasta[0]
+	assert reads[1].sequence == 'SEQUEN\nCE2'
+
+
+ at raises(seqio.FormatError)
+def test_fastq_wrongformat():
+	with seqio.FastqReader("tests/data/withplus.fastq") as f:
+		reads = list(f)
+
+
+ at raises(seqio.FormatError)
+def test_fastq_incomplete():
+	fastq = StringIO("@name\nACGT+\n")
+	with seqio.FastqReader(fastq) as fq:
+		list(fq)
+
+
+ at raises(seqio.FormatError)
+def test_too_many_qualities():
+	seqio.Sequence(name="name", sequence="ACGT", qualities="#####")
+
+
+ at raises(seqio.FormatError)
+def test_too_many_qualities_colorspace():
+	seqio.ColorspaceSequence(name="name", sequence="T0123", qualities="#####")
+
+
+ at raises(seqio.FormatError)
+def test_invalid_primer():
+	seqio.ColorspaceSequence(name="name", sequence="K0123", qualities="####")
+
+
+ at raises(seqio.FormatError)
+def test_mismatching_read_names():
+	fasta = StringIO(">name\nACG")
+	qual = StringIO(">nome\n3 5 7")
+	list(seqio.FastaQualReader(fasta, qual))
+
+
+ at raises(seqio.FormatError)
+def test_invalid_quality_value():
+	fasta = StringIO(">name\nACG")
+	qual = StringIO(">name\n3 xx 7")
+	list(seqio.FastaQualReader(fasta, qual))
+
+
+def test_sequence_reader():
+	# test the autodetection
+	with seqio.open("tests/data/simple.fastq") as f:
+		reads = list(f)
+	assert reads == simple_fastq
+
+	with seqio.open("tests/data/simple.fasta") as f:
+		reads = list(f)
+	assert reads == simple_fasta
+
+	with open("tests/data/simple.fastq") as f:
+		reads = list(seqio.open(f))
+	assert reads == simple_fastq
+
+	# make the name attribute unavailable
+	f = StringIO(open("tests/data/simple.fastq").read())
+	reads = list(seqio.open(f))
+	assert reads == simple_fastq
+
+	f = StringIO(open("tests/data/simple.fasta").read())
+	reads = list(seqio.open(f))
+	assert reads == simple_fasta
+
+
+def test_fasta_context_manager():
+	filename = "tests/data/simple.fasta"
+	with open(filename) as f:
+		assert not f.closed
+		reads = list(seqio.open(f))
+		assert not f.closed
+	assert f.closed
+
+	with seqio.FastaReader(filename) as sr:
+		tmp_sr = sr
+		assert not sr.fp.closed
+		reads = list(sr)
+		assert not sr.fp.closed
+	assert tmp_sr.fp is None
+
+
+def test_fastq_context_manager():
+	filename = "tests/data/simple.fastq"
+	with open(filename) as f:
+		assert not f.closed
+		reads = list(seqio.open(f))
+		assert not f.closed
+	assert f.closed
+
+	with seqio.FastqReader(filename) as sr:
+		tmp_sr = sr
+		assert not sr.fp.closed
+		reads = list(sr)
+		assert not sr.fp.closed
+	assert tmp_sr.fp is None
diff --git a/tests/testtrim.py b/tests/testtrim.py
new file mode 100644
index 0000000..09c3102
--- /dev/null
+++ b/tests/testtrim.py
@@ -0,0 +1,27 @@
+# coding: utf-8
+from __future__ import print_function, division, absolute_import
+
+from cutadapt.seqio import ColorspaceSequence, Sequence
+from cutadapt.adapters import Adapter, ColorspaceAdapter, PREFIX, BACK
+from cutadapt.scripts.cutadapt import AdapterCutter
+
+def test_cs_5p():
+	read = ColorspaceSequence("name", "0123", "DEFG", "T")
+	adapter = ColorspaceAdapter("CG", PREFIX, 0.1)
+	cutter = AdapterCutter([adapter])
+	trimmed_read = cutter(read)
+	# no assertion here, just make sure the above code runs without
+	# an exception
+
+
+def test_statistics():
+	read = Sequence('name', 'AAAACCCCAAAA')
+	adapters = [Adapter('CCCC', BACK, 0.1)]
+	cutter = AdapterCutter(adapters, times=3)
+	trimmed_read = cutter(read)
+	# TODO make this a lot simpler
+	trimmed_bp = 0
+	for adapter in adapters:
+		for d in (adapter.lengths_front, adapter.lengths_back):
+			trimmed_bp += sum(seqlen * count for (seqlen, count) in d.items())
+	assert trimmed_bp <= len(read), trimmed_bp
diff --git a/tests/testxopen.py b/tests/testxopen.py
new file mode 100644
index 0000000..2d714c4
--- /dev/null
+++ b/tests/testxopen.py
@@ -0,0 +1,101 @@
+# coding: utf-8
+from __future__ import print_function, division, absolute_import
+import gzip
+import os
+import random
+import sys
+from nose.tools import raises
+from cutadapt.xopen import xopen, lzma
+from .utils import temporary_path
+
+base = "tests/data/small.fastq"
+files = [ base + ext for ext in ['', '.gz', '.bz2' ] ]
+if lzma is not None:
+	files.append(base + '.xz')
+
+def test_context_manager():
+	major, minor = sys.version_info[0:2]
+	for name in files:
+		if major == 2 and minor == 6:
+			continue  # Py26 compression libraries do not support context manager protocol.
+		with xopen(name, 'rt') as f:
+			lines = list(f)
+			assert len(lines) == 12
+			assert lines[5] == 'AGCCGCTANGACGGGTTGGCCCTTAGACGTATCT\n', name
+			f.close()
+
+def test_append():
+	for ext in ["", ".gz"]:  # BZ2 does NOT support append
+		text = "AB"
+		if ext != "":
+			text = text.encode("utf-8")  # On Py3, need to send BYTES, not unicode
+		reference = text + text
+		print("Trying ext=%s" % ext)
+		with temporary_path('truncated.fastq' + ext) as path:
+			try:
+				os.unlink(path)
+			except OSError:
+				pass
+			with xopen(path, 'a') as f:
+				f.write(text)
+			with xopen(path, 'a') as f:
+				f.write(text)
+			with xopen(path, 'r') as f:
+				for appended in f:
+					pass
+				try:
+					reference = reference.decode("utf-8")
+				except AttributeError:
+					pass
+				print(appended)
+				print(reference)
+				assert appended == reference
+
+def test_xopen_text():
+	for name in files:
+		f = xopen(name, 'rt')
+		lines = list(f)
+		assert len(lines) == 12
+		assert lines[5] == 'AGCCGCTANGACGGGTTGGCCCTTAGACGTATCT\n', name
+		f.close()
+
+
+def test_xopen_binary():
+	for name in files:
+		f = xopen(name, 'rb')
+		lines = list(f)
+		assert len(lines) == 12
+		assert lines[5] == b'AGCCGCTANGACGGGTTGGCCCTTAGACGTATCT\n', name
+		f.close()
+
+
+def create_truncated_file(path):
+	# Random text
+	text = ''.join(random.choice('ABCDEFGHIJKLMNOPQRSTUVWXYZ') for _ in range(200))
+	f = xopen(path, 'w')
+	f.write(text)
+	f.close()
+	f = open(path, 'a')
+	f.truncate(os.stat(path).st_size - 10)
+	f.close()
+
+
+# Disable these tests in Python 3.2 and 3.3
+if not ((3, 2) <= sys.version_info[:2] <= (3, 3)):
+	@raises(EOFError)
+	def test_truncated_gz():
+		with temporary_path('truncated.gz') as path:
+			create_truncated_file(path)
+			f = xopen(path, 'r')
+			f.read()
+			f.close()
+
+
+	@raises(EOFError)
+	def test_truncated_gz_iter():
+		with temporary_path('truncated.gz') as path:
+			create_truncated_file(path)
+			f = xopen(path, 'r')
+			for line in f:
+				pass
+			f.close()
diff --git a/tests/utils.py b/tests/utils.py
new file mode 100644
index 0000000..c4828a2
--- /dev/null
+++ b/tests/utils.py
@@ -0,0 +1,50 @@
+# coding: utf-8
+from __future__ import print_function, division, absolute_import
+
+import sys, os
+from contextlib import contextmanager
+from cutadapt.scripts import cutadapt
+
+ at contextmanager
+def redirect_stderr():
+	"Send stderr to stdout. Nose doesn't capture stderr, yet."
+	old_stderr = sys.stderr
+	sys.stderr = sys.stdout
+	yield
+	sys.stderr = old_stderr
+
+
+ at contextmanager
+def temporary_path(name):
+	directory = os.path.join(os.path.dirname(__file__), 'testtmp')
+	if not os.path.isdir(directory):
+		os.mkdir(directory)
+	path = os.path.join(directory, name)
+	yield path
+	os.remove(path)
+
+
+def datapath(path):
+	return os.path.join(os.path.dirname(__file__), 'data', path)
+
+
+def cutpath(path):
+	return os.path.join(os.path.dirname(__file__), 'cut', path)
+
+
+def files_equal(path1, path2):
+	return os.system("diff -u {0} {1}".format(path1, path2)) == 0
+
+
+def run(params, expected, inpath, inpath2=None):
+	if type(params) is str:
+		params = params.split()
+	with temporary_path('tmp.fastaq') as tmp_fastaq:
+		params += ['-o', tmp_fastaq ] # TODO not parallelizable
+		params += [ datapath(inpath) ]
+		if inpath2:
+			params += [ datapath(inpath2) ]
+		assert cutadapt.main(params) is None
+		# TODO redirect standard output
+		assert files_equal(cutpath(expected), tmp_fastaq)
+	# TODO diff log files

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/debian-med/python-cutadapt.git



More information about the debian-med-commit mailing list