[med-svn] [fastaq] 02/04: Imported Upstream version 1.5.0

Jorge Soares jssoares-guest at moszumanska.debian.org
Tue Oct 21 07:53:06 UTC 2014


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

jssoares-guest pushed a commit to branch master
in repository fastaq.

commit b5501926252378107d6d2ec0a51a7a844c18ce35
Author: js21 <js21 at localhost.localdomain>
Date:   Tue Oct 21 08:51:19 2014 +0100

    Imported Upstream version 1.5.0
---
 .gitignore                                         |  35 +
 AUTHORS                                            |   1 +
 LICENSE                                            | 674 +++++++++++++++++++
 MANIFEST.in                                        |   1 +
 README.md                                          |  50 ++
 fastaq/__init__.py                                 |   2 +
 fastaq/intervals.py                                | 117 ++++
 fastaq/sequences.py                                | 638 ++++++++++++++++++
 fastaq/tasks.py                                    | 727 +++++++++++++++++++++
 fastaq/tests/data/sequences_test.embl              | 203 ++++++
 fastaq/tests/data/sequences_test.embl.bad          | 202 ++++++
 fastaq/tests/data/sequences_test.embl.bad2         | 202 ++++++
 fastaq/tests/data/sequences_test.embl.to_fasta     |  64 ++
 fastaq/tests/data/sequences_test.fa                |  19 +
 fastaq/tests/data/sequences_test.fa.ids            |   4 +
 fastaq/tests/data/sequences_test.fa.qual           |  17 +
 fastaq/tests/data/sequences_test.fa.qual.bad       |  17 +
 fastaq/tests/data/sequences_test.fasta_to_fastq.fq |  16 +
 fastaq/tests/data/sequences_test.gbk               | 170 +++++
 fastaq/tests/data/sequences_test.gbk.to_fasta      |  10 +
 fastaq/tests/data/sequences_test.line_length3.fa   |  12 +
 fastaq/tests/data/sequences_test_3-per-line.fa     |  19 +
 .../tests/data/sequences_test_cap_to_read_pairs.fa |  16 +
 .../sequences_test_cap_to_read_pairs.fa.paired.gz  | Bin 0 -> 92 bytes
 ...sequences_test_cap_to_read_pairs.fa.unpaired.gz | Bin 0 -> 92 bytes
 .../tests/data/sequences_test_deinterleaved_1.fa   |   4 +
 .../tests/data/sequences_test_deinterleaved_2.fa   |   4 +
 .../data/sequences_test_deinterleaved_bad2_1.fa    |   2 +
 .../data/sequences_test_deinterleaved_bad2_2.fa    |   4 +
 .../data/sequences_test_deinterleaved_bad_1.fa     |   4 +
 .../data/sequences_test_deinterleaved_bad_2.fa     |   2 +
 fastaq/tests/data/sequences_test_empty_file        |   0
 .../tests/data/sequences_test_enumerate_names.fa   |   8 +
 ...quences_test_enumerate_names.fa.out.keep_suffix |   8 +
 .../sequences_test_enumerate_names.fa.out.start.1  |   8 +
 ...test_enumerate_names.fa.out.start.1.rename_file |   5 +
 .../sequences_test_enumerate_names.fa.out.start.2  |   8 +
 fastaq/tests/data/sequences_test_extend_gaps.fa    |   8 +
 .../tests/data/sequences_test_extend_gaps.fa.out   |   4 +
 fastaq/tests/data/sequences_test_fai_test.fa       |   8 +
 fastaq/tests/data/sequences_test_fai_test.fa.fai   |   4 +
 fastaq/tests/data/sequences_test_fail_no_AT.fq     |   5 +
 fastaq/tests/data/sequences_test_fail_no_plus.fq   |   4 +
 fastaq/tests/data/sequences_test_fail_no_qual.fq   |   3 +
 fastaq/tests/data/sequences_test_fail_no_seq.fq    |   5 +
 ...sequences_test_fastaq_replace_bases.expected.fa |   2 +
 .../data/sequences_test_fastaq_replace_bases.fa    |   2 +
 ...sequences_test_fastaq_to_quasr_primers.expected |   2 +
 .../data/sequences_test_fastaq_to_quasr_primers.fa |   4 +
 .../data/sequences_test_filter_by_ids_file.fa      |   8 +
 .../sequences_test_filter_by_ids_file.fa.filtered  |   4 +
 ...nces_test_filter_by_ids_file.fa.filtered.invert |   4 +
 .../data/sequences_test_filter_by_ids_file.fa.ids  |   2 +
 .../tests/data/sequences_test_filter_by_regex.fa   |  10 +
 .../sequences_test_filter_by_regex.first-char-a.fa |   6 +
 ...sequences_test_filter_by_regex.first-of-pair.fa |   4 +
 .../data/sequences_test_filter_by_regex.numeric.fa |   2 +
 .../data/sequences_test_get_seqs_flanking_gaps.fa  |   4 +
 .../sequences_test_get_seqs_flanking_gaps.fa.out   |   3 +
 fastaq/tests/data/sequences_test_gffv3.gff         |   9 +
 fastaq/tests/data/sequences_test_gffv3.gff.fasta   |   4 +
 .../tests/data/sequences_test_gffv3.gff.to_fasta   |   4 +
 .../data/sequences_test_gffv3.no_FASTA_line.gff    |   8 +
 ...sequences_test_gffv3.no_FASTA_line.gff.to_fasta |   4 +
 .../tests/data/sequences_test_gffv3.no_seq.2.gff   |   6 +
 fastaq/tests/data/sequences_test_gffv3.no_seq.gff  |   4 +
 fastaq/tests/data/sequences_test_good_file.fq      |  11 +
 .../data/sequences_test_good_file.fq.to_fasta      |   4 +
 .../tests/data/sequences_test_good_file_mira.xml   |  13 +
 fastaq/tests/data/sequences_test_interleaved.fa    |   8 +
 fastaq/tests/data/sequences_test_interleaved.fq    |  16 +
 .../tests/data/sequences_test_interleaved_bad.fa   |   6 +
 fastaq/tests/data/sequences_test_length_filter.fa  |   6 +
 .../sequences_test_length_filter.min-0.max-1.fa    |   0
 .../sequences_test_length_filter.min-0.max-inf.fa  |   6 +
 .../sequences_test_length_filter.min-4.max-4.fa    |   2 +
 .../sequences_test_make_random_contigs.default.fa  |   4 +
 .../sequences_test_make_random_contigs.first-42.fa |   4 +
 ...ces_test_make_random_contigs.name-by-letters.fa |  56 ++
 .../sequences_test_make_random_contigs.prefix-p.fa |   4 +
 .../tests/data/sequences_test_merge_to_one_seq.fa  |   8 +
 .../tests/data/sequences_test_merge_to_one_seq.fq  |   8 +
 .../data/sequences_test_merge_to_one_seq.merged.fa |   2 +
 .../data/sequences_test_merge_to_one_seq.merged.fq |   4 +
 fastaq/tests/data/sequences_test_not_a_fastaq_file |   1 +
 fastaq/tests/data/sequences_test_one-per-line.fa   |  14 +
 fastaq/tests/data/sequences_test_orfs.fa           |  18 +
 fastaq/tests/data/sequences_test_orfs.gff          |  15 +
 .../tests/data/sequences_test_phylip.interleaved   |   8 +
 .../sequences_test_phylip.interleaved.to_fasta     |   6 +
 .../tests/data/sequences_test_phylip.interleaved2  |   7 +
 .../sequences_test_phylip.interleaved2.to_fasta    |   6 +
 .../data/sequences_test_phylip.made_by_seaview     |   6 +
 .../sequences_test_phylip.made_by_seaview.to_fasta |   6 +
 fastaq/tests/data/sequences_test_phylip.sequential |   7 +
 .../data/sequences_test_phylip.sequential.to_fasta |   6 +
 fastaq/tests/data/sequences_test_revcomp.fa        |   8 +
 fastaq/tests/data/sequences_test_search_string.fa  |   2 +
 .../data/sequences_test_search_string.fa.hits      |   4 +
 .../tests/data/sequences_test_split_fixed_size.fa  |  12 +
 .../sequences_test_split_fixed_size.fa.split.1     |   2 +
 .../sequences_test_split_fixed_size.fa.split.2     |   2 +
 .../sequences_test_split_fixed_size.fa.split.3     |   2 +
 .../sequences_test_split_fixed_size.fa.split.4     |   2 +
 .../sequences_test_split_fixed_size.fa.split.5     |   4 +
 .../sequences_test_split_fixed_size.fa.split.6     |   2 +
 ...sequences_test_split_fixed_size.fa.split.coords |   2 +
 ...test_split_fixed_size.fa.split.skip_if_all_Ns.1 |   2 +
 ...test_split_fixed_size.fa.split.skip_if_all_Ns.2 |   2 +
 ...test_split_fixed_size.fa.split.skip_if_all_Ns.3 |   4 +
 ...test_split_fixed_size.fa.split.skip_if_all_Ns.4 |   2 +
 ...split_fixed_size.fa.split.skip_if_all_Ns.coords |   1 +
 fastaq/tests/data/sequences_test_split_test.fa     |   8 +
 fastaq/tests/data/sequences_test_split_test.fa.2.1 |   2 +
 fastaq/tests/data/sequences_test_split_test.fa.2.2 |   2 +
 fastaq/tests/data/sequences_test_split_test.fa.2.3 |   2 +
 fastaq/tests/data/sequences_test_split_test.fa.2.4 |   2 +
 fastaq/tests/data/sequences_test_split_test.fa.3.1 |   4 +
 fastaq/tests/data/sequences_test_split_test.fa.3.2 |   2 +
 fastaq/tests/data/sequences_test_split_test.fa.3.3 |   2 +
 fastaq/tests/data/sequences_test_split_test.fa.4.1 |   4 +
 fastaq/tests/data/sequences_test_split_test.fa.4.2 |   2 +
 fastaq/tests/data/sequences_test_split_test.fa.4.3 |   2 +
 fastaq/tests/data/sequences_test_split_test.fa.6.1 |   6 +
 fastaq/tests/data/sequences_test_split_test.fa.6.2 |   2 +
 .../data/sequences_test_split_test.fa.6.limit2.1   |   4 +
 .../data/sequences_test_split_test.fa.6.limit2.2   |   2 +
 .../data/sequences_test_split_test.fa.6.limit2.3   |   2 +
 .../tests/data/sequences_test_split_test.long.fa   |   4 +
 .../data/sequences_test_split_test.long.fa.2.1     |   2 +
 .../data/sequences_test_split_test.long.fa.2.2     |   2 +
 .../data/sequences_test_strip_after_whitespace.fa  |   6 +
 ...quences_test_strip_after_whitespace.fa.to_fasta |   6 +
 .../data/sequences_test_strip_illumina_suffix.fq   |  12 +
 ...equences_test_strip_illumina_suffix.fq.stripped |  12 +
 .../tests/data/sequences_test_to_fasta_union.in.fa |   7 +
 .../data/sequences_test_to_fasta_union.out.fa      |   2 +
 .../tests/data/sequences_test_to_unique_by_id.fa   |  11 +
 .../data/sequences_test_to_unique_by_id.fa.out     |   6 +
 fastaq/tests/data/sequences_test_translate.fa      |   2 +
 .../tests/data/sequences_test_translate.fa.frame0  |   3 +
 .../tests/data/sequences_test_translate.fa.frame1  |   3 +
 .../tests/data/sequences_test_translate.fa.frame2  |   3 +
 fastaq/tests/data/sequences_test_trim_Ns_at_end.fa |  10 +
 .../data/sequences_test_trim_Ns_at_end.fa.trimmed  |   8 +
 fastaq/tests/data/sequences_test_trimmed.fq        |   8 +
 fastaq/tests/data/sequences_test_untrimmed.fq      |  16 +
 .../tests/data/tasks_test_expend_nucleotides.in.fa |   4 +
 .../tests/data/tasks_test_expend_nucleotides.in.fq |   8 +
 .../data/tasks_test_expend_nucleotides.out.fa      |   6 +
 .../data/tasks_test_expend_nucleotides.out.fq      |  12 +
 .../tests/data/tasks_test_fasta_to_fake_qual.in.fa |   5 +
 .../tasks_test_fasta_to_fake_qual.out.default.qual |   5 +
 .../tasks_test_fasta_to_fake_qual.out.q42.qual     |   5 +
 .../tests/data/tasks_test_make_long_reads.input.fa |   2 +
 .../data/tasks_test_make_long_reads.output.fa      |  10 +
 fastaq/tests/data/tasks_test_sequence_trim_1.fa    |  12 +
 .../data/tasks_test_sequence_trim_1.trimmed.fa     |   8 +
 fastaq/tests/data/tasks_test_sequence_trim_2.fa    |  12 +
 .../data/tasks_test_sequence_trim_2.trimmed.fa     |   8 +
 fastaq/tests/data/tasks_test_sequences_to_trim.fa  |   8 +
 fastaq/tests/data/utils_test_file_transpose.txt    |   5 +
 fastaq/tests/data/utils_test_file_transposed.txt   |   3 +
 fastaq/tests/data/utils_test_not_really_zipped.gz  |   1 +
 fastaq/tests/data/utils_test_scaffolds.fa          |   8 +
 .../data/utils_test_scaffolds.fa.to_contigs.fa     |  10 +
 ..._test_scaffolds.fa.to_contigs.number_contigs.fa |  10 +
 fastaq/tests/data/utils_test_system_call.txt       |   1 +
 fastaq/tests/intervals_test.py                     | 212 ++++++
 fastaq/tests/sequences_test.py                     | 656 +++++++++++++++++++
 fastaq/tests/tasks_test.py                         | 538 +++++++++++++++
 fastaq/tests/utils_test.py                         |  80 +++
 fastaq/utils.py                                    |  86 +++
 scripts/fastaq_capillary_to_pairs                  |  12 +
 scripts/fastaq_chunker                             |  21 +
 scripts/fastaq_count_sequences                     |  11 +
 scripts/fastaq_deinterleave                        |  14 +
 scripts/fastaq_enumerate_names                     |  19 +
 scripts/fastaq_expand_nucleotides                  |  15 +
 scripts/fastaq_extend_gaps                         |  13 +
 scripts/fastaq_fasta_to_fastq                      |  13 +
 scripts/fastaq_filter                              |  24 +
 scripts/fastaq_get_ids                             |  12 +
 scripts/fastaq_get_seq_flanking_gaps               |  14 +
 scripts/fastaq_insert_or_delete_bases              |  94 +++
 scripts/fastaq_interleave                          |  13 +
 scripts/fastaq_long_read_simulate                  |  50 ++
 scripts/fastaq_make_random_contigs                 |  25 +
 scripts/fastaq_merge                               |  18 +
 scripts/fastaq_replace_bases                       |  14 +
 scripts/fastaq_reverse_complement                  |  12 +
 scripts/fastaq_scaffolds_to_contigs                |  13 +
 scripts/fastaq_search_for_seq                      |  13 +
 scripts/fastaq_sequence_trim                       |  23 +
 scripts/fastaq_split_by_base_count                 |  15 +
 scripts/fastaq_strip_illumina_suffix               |  12 +
 scripts/fastaq_to_fake_qual                        |  18 +
 scripts/fastaq_to_fasta                            |  19 +
 scripts/fastaq_to_mira_xml                         |  12 +
 scripts/fastaq_to_orfs_gff                         |  13 +
 scripts/fastaq_to_perfect_reads                    |  86 +++
 scripts/fastaq_to_quasr_primers_file               |  12 +
 scripts/fastaq_to_random_subset                    |  36 +
 scripts/fastaq_to_tiling_bam                       |  79 +++
 scripts/fastaq_to_unique_by_id                     |  12 +
 scripts/fastaq_translate                           |  13 +
 scripts/fastaq_trim_Ns_at_end                      |  12 +
 scripts/fastaq_trim_ends                           |  14 +
 setup.py                                           |  21 +
 209 files changed, 6428 insertions(+)

diff --git a/.gitignore b/.gitignore
new file mode 100644
index 0000000..d2d6f36
--- /dev/null
+++ b/.gitignore
@@ -0,0 +1,35 @@
+*.py[cod]
+
+# C extensions
+*.so
+
+# Packages
+*.egg
+*.egg-info
+dist
+build
+eggs
+parts
+bin
+var
+sdist
+develop-eggs
+.installed.cfg
+lib
+lib64
+
+# Installer logs
+pip-log.txt
+
+# Unit test / coverage reports
+.coverage
+.tox
+nosetests.xml
+
+# Translations
+*.mo
+
+# Mr Developer
+.mr.developer.cfg
+.project
+.pydevproject
diff --git a/AUTHORS b/AUTHORS
new file mode 100644
index 0000000..711ae85
--- /dev/null
+++ b/AUTHORS
@@ -0,0 +1 @@
+Martin Hunt (mh12 at sanger.ac.uk)
diff --git a/LICENSE b/LICENSE
new file mode 100644
index 0000000..1a0079f
--- /dev/null
+++ b/LICENSE
@@ -0,0 +1,674 @@
+GNU GENERAL PUBLIC LICENSE
+                       Version 3, 29 June 2007
+
+ Copyright (C) 2007 Free Software Foundation, Inc. {http://fsf.org/}
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+                            Preamble
+
+  The GNU General Public License is a free, copyleft license for
+software and other kinds of works.
+
+  The licenses for most software and other practical works are designed
+to take away your freedom to share and change the works.  By contrast,
+the GNU General Public License is intended to guarantee your freedom to
+share and change all versions of a program--to make sure it remains free
+software for all its users.  We, the Free Software Foundation, use the
+GNU General Public License for most of our software; it applies also to
+any other work released this way by its authors.  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+them if you wish), that you receive source code or can get it if you
+want it, that you can change the software or use pieces of it in new
+free programs, and that you know you can do these things.
+
+  To protect your rights, we need to prevent others from denying you
+these rights or asking you to surrender the rights.  Therefore, you have
+certain responsibilities if you distribute copies of the software, or if
+you modify it: responsibilities to respect the freedom of others.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must pass on to the recipients the same
+freedoms that you received.  You must make sure that they, too, receive
+or can get the source code.  And you must show them these terms so they
+know their rights.
+
+  Developers that use the GNU GPL protect your rights with two steps:
+(1) assert copyright on the software, and (2) offer you this License
+giving you legal permission to copy, distribute and/or modify it.
+
+  For the developers' and authors' protection, the GPL clearly explains
+that there is no warranty for this free software.  For both users' and
+authors' sake, the GPL requires that modified versions be marked as
+changed, so that their problems will not be attributed erroneously to
+authors of previous versions.
+
+  Some devices are designed to deny users access to install or run
+modified versions of the software inside them, although the manufacturer
+can do so.  This is fundamentally incompatible with the aim of
+protecting users' freedom to change the software.  The systematic
+pattern of such abuse occurs in the area of products for individuals to
+use, which is precisely where it is most unacceptable.  Therefore, we
+have designed this version of the GPL to prohibit the practice for those
+products.  If such problems arise substantially in other domains, we
+stand ready to extend this provision to those domains in future versions
+of the GPL, as needed to protect the freedom of users.
+
+  Finally, every program is threatened constantly by software patents.
+States should not allow patents to restrict development and use of
+software on general-purpose computers, but in those that do, we wish to
+avoid the special danger that patents applied to a free program could
+make it effectively proprietary.  To prevent this, the GPL assures that
+patents cannot be used to render the program non-free.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+                       TERMS AND CONDITIONS
+
+  0. Definitions.
+
+  "This License" refers to version 3 of the GNU General Public License.
+
+  "Copyright" also means copyright-like laws that apply to other kinds of
+works, such as semiconductor masks.
+
+  "The Program" refers to any copyrightable work licensed under this
+License.  Each licensee is addressed as "you".  "Licensees" and
+"recipients" may be individuals or organizations.
+
+  To "modify" a work means to copy from or adapt all or part of the work
+in a fashion requiring copyright permission, other than the making of an
+exact copy.  The resulting work is called a "modified version" of the
+earlier work or a work "based on" the earlier work.
+
+  A "covered work" means either the unmodified Program or a work based
+on the Program.
+
+  To "propagate" a work means to do anything with it that, without
+permission, would make you directly or secondarily liable for
+infringement under applicable copyright law, except executing it on a
+computer or modifying a private copy.  Propagation includes copying,
+distribution (with or without modification), making available to the
+public, and in some countries other activities as well.
+
+  To "convey" a work means any kind of propagation that enables other
+parties to make or receive copies.  Mere interaction with a user through
+a computer network, with no transfer of a copy, is not conveying.
+
+  An interactive user interface displays "Appropriate Legal Notices"
+to the extent that it includes a convenient and prominently visible
+feature that (1) displays an appropriate copyright notice, and (2)
+tells the user that there is no warranty for the work (except to the
+extent that warranties are provided), that licensees may convey the
+work under this License, and how to view a copy of this License.  If
+the interface presents a list of user commands or options, such as a
+menu, a prominent item in the list meets this criterion.
+
+  1. Source Code.
+
+  The "source code" for a work means the preferred form of the work
+for making modifications to it.  "Object code" means any non-source
+form of a work.
+
+  A "Standard Interface" means an interface that either is an official
+standard defined by a recognized standards body, or, in the case of
+interfaces specified for a particular programming language, one that
+is widely used among developers working in that language.
+
+  The "System Libraries" of an executable work include anything, other
+than the work as a whole, that (a) is included in the normal form of
+packaging a Major Component, but which is not part of that Major
+Component, and (b) serves only to enable use of the work with that
+Major Component, or to implement a Standard Interface for which an
+implementation is available to the public in source code form.  A
+"Major Component", in this context, means a major essential component
+(kernel, window system, and so on) of the specific operating system
+(if any) on which the executable work runs, or a compiler used to
+produce the work, or an object code interpreter used to run it.
+
+  The "Corresponding Source" for a work in object code form means all
+the source code needed to generate, install, and (for an executable
+work) run the object code and to modify the work, including scripts to
+control those activities.  However, it does not include the work's
+System Libraries, or general-purpose tools or generally available free
+programs which are used unmodified in performing those activities but
+which are not part of the work.  For example, Corresponding Source
+includes interface definition files associated with source files for
+the work, and the source code for shared libraries and dynamically
+linked subprograms that the work is specifically designed to require,
+such as by intimate data communication or control flow between those
+subprograms and other parts of the work.
+
+  The Corresponding Source need not include anything that users
+can regenerate automatically from other parts of the Corresponding
+Source.
+
+  The Corresponding Source for a work in source code form is that
+same work.
+
+  2. Basic Permissions.
+
+  All rights granted under this License are granted for the term of
+copyright on the Program, and are irrevocable provided the stated
+conditions are met.  This License explicitly affirms your unlimited
+permission to run the unmodified Program.  The output from running a
+covered work is covered by this License only if the output, given its
+content, constitutes a covered work.  This License acknowledges your
+rights of fair use or other equivalent, as provided by copyright law.
+
+  You may make, run and propagate covered works that you do not
+convey, without conditions so long as your license otherwise remains
+in force.  You may convey covered works to others for the sole purpose
+of having them make modifications exclusively for you, or provide you
+with facilities for running those works, provided that you comply with
+the terms of this License in conveying all material for which you do
+not control copyright.  Those thus making or running the covered works
+for you must do so exclusively on your behalf, under your direction
+and control, on terms that prohibit them from making any copies of
+your copyrighted material outside their relationship with you.
+
+  Conveying under any other circumstances is permitted solely under
+the conditions stated below.  Sublicensing is not allowed; section 10
+makes it unnecessary.
+
+  3. Protecting Users' Legal Rights From Anti-Circumvention Law.
+
+  No covered work shall be deemed part of an effective technological
+measure under any applicable law fulfilling obligations under article
+11 of the WIPO copyright treaty adopted on 20 December 1996, or
+similar laws prohibiting or restricting circumvention of such
+measures.
+
+  When you convey a covered work, you waive any legal power to forbid
+circumvention of technological measures to the extent such circumvention
+is effected by exercising rights under this License with respect to
+the covered work, and you disclaim any intention to limit operation or
+modification of the work as a means of enforcing, against the work's
+users, your or third parties' legal rights to forbid circumvention of
+technological measures.
+
+  4. Conveying Verbatim Copies.
+
+  You may convey verbatim copies of the Program's source code as you
+receive it, in any medium, provided that you conspicuously and
+appropriately publish on each copy an appropriate copyright notice;
+keep intact all notices stating that this License and any
+non-permissive terms added in accord with section 7 apply to the code;
+keep intact all notices of the absence of any warranty; and give all
+recipients a copy of this License along with the Program.
+
+  You may charge any price or no price for each copy that you convey,
+and you may offer support or warranty protection for a fee.
+
+  5. Conveying Modified Source Versions.
+
+  You may convey a work based on the Program, or the modifications to
+produce it from the Program, in the form of source code under the
+terms of section 4, provided that you also meet all of these conditions:
+
+    a) The work must carry prominent notices stating that you modified
+    it, and giving a relevant date.
+
+    b) The work must carry prominent notices stating that it is
+    released under this License and any conditions added under section
+    7.  This requirement modifies the requirement in section 4 to
+    "keep intact all notices".
+
+    c) You must license the entire work, as a whole, under this
+    License to anyone who comes into possession of a copy.  This
+    License will therefore apply, along with any applicable section 7
+    additional terms, to the whole of the work, and all its parts,
+    regardless of how they are packaged.  This License gives no
+    permission to license the work in any other way, but it does not
+    invalidate such permission if you have separately received it.
+
+    d) If the work has interactive user interfaces, each must display
+    Appropriate Legal Notices; however, if the Program has interactive
+    interfaces that do not display Appropriate Legal Notices, your
+    work need not make them do so.
+
+  A compilation of a covered work with other separate and independent
+works, which are not by their nature extensions of the covered work,
+and which are not combined with it such as to form a larger program,
+in or on a volume of a storage or distribution medium, is called an
+"aggregate" if the compilation and its resulting copyright are not
+used to limit the access or legal rights of the compilation's users
+beyond what the individual works permit.  Inclusion of a covered work
+in an aggregate does not cause this License to apply to the other
+parts of the aggregate.
+
+  6. Conveying Non-Source Forms.
+
+  You may convey a covered work in object code form under the terms
+of sections 4 and 5, provided that you also convey the
+machine-readable Corresponding Source under the terms of this License,
+in one of these ways:
+
+    a) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by the
+    Corresponding Source fixed on a durable physical medium
+    customarily used for software interchange.
+
+    b) Convey the object code in, or embodied in, a physical product
+    (including a physical distribution medium), accompanied by a
+    written offer, valid for at least three years and valid for as
+    long as you offer spare parts or customer support for that product
+    model, to give anyone who possesses the object code either (1) a
+    copy of the Corresponding Source for all the software in the
+    product that is covered by this License, on a durable physical
+    medium customarily used for software interchange, for a price no
+    more than your reasonable cost of physically performing this
+    conveying of source, or (2) access to copy the
+    Corresponding Source from a network server at no charge.
+
+    c) Convey individual copies of the object code with a copy of the
+    written offer to provide the Corresponding Source.  This
+    alternative is allowed only occasionally and noncommercially, and
+    only if you received the object code with such an offer, in accord
+    with subsection 6b.
+
+    d) Convey the object code by offering access from a designated
+    place (gratis or for a charge), and offer equivalent access to the
+    Corresponding Source in the same way through the same place at no
+    further charge.  You need not require recipients to copy the
+    Corresponding Source along with the object code.  If the place to
+    copy the object code is a network server, the Corresponding Source
+    may be on a different server (operated by you or a third party)
+    that supports equivalent copying facilities, provided you maintain
+    clear directions next to the object code saying where to find the
+    Corresponding Source.  Regardless of what server hosts the
+    Corresponding Source, you remain obligated to ensure that it is
+    available for as long as needed to satisfy these requirements.
+
+    e) Convey the object code using peer-to-peer transmission, provided
+    you inform other peers where the object code and Corresponding
+    Source of the work are being offered to the general public at no
+    charge under subsection 6d.
+
+  A separable portion of the object code, whose source code is excluded
+from the Corresponding Source as a System Library, need not be
+included in conveying the object code work.
+
+  A "User Product" is either (1) a "consumer product", which means any
+tangible personal property which is normally used for personal, family,
+or household purposes, or (2) anything designed or sold for incorporation
+into a dwelling.  In determining whether a product is a consumer product,
+doubtful cases shall be resolved in favor of coverage.  For a particular
+product received by a particular user, "normally used" refers to a
+typical or common use of that class of product, regardless of the status
+of the particular user or of the way in which the particular user
+actually uses, or expects or is expected to use, the product.  A product
+is a consumer product regardless of whether the product has substantial
+commercial, industrial or non-consumer uses, unless such uses represent
+the only significant mode of use of the product.
+
+  "Installation Information" for a User Product means any methods,
+procedures, authorization keys, or other information required to install
+and execute modified versions of a covered work in that User Product from
+a modified version of its Corresponding Source.  The information must
+suffice to ensure that the continued functioning of the modified object
+code is in no case prevented or interfered with solely because
+modification has been made.
+
+  If you convey an object code work under this section in, or with, or
+specifically for use in, a User Product, and the conveying occurs as
+part of a transaction in which the right of possession and use of the
+User Product is transferred to the recipient in perpetuity or for a
+fixed term (regardless of how the transaction is characterized), the
+Corresponding Source conveyed under this section must be accompanied
+by the Installation Information.  But this requirement does not apply
+if neither you nor any third party retains the ability to install
+modified object code on the User Product (for example, the work has
+been installed in ROM).
+
+  The requirement to provide Installation Information does not include a
+requirement to continue to provide support service, warranty, or updates
+for a work that has been modified or installed by the recipient, or for
+the User Product in which it has been modified or installed.  Access to a
+network may be denied when the modification itself materially and
+adversely affects the operation of the network or violates the rules and
+protocols for communication across the network.
+
+  Corresponding Source conveyed, and Installation Information provided,
+in accord with this section must be in a format that is publicly
+documented (and with an implementation available to the public in
+source code form), and must require no special password or key for
+unpacking, reading or copying.
+
+  7. Additional Terms.
+
+  "Additional permissions" are terms that supplement the terms of this
+License by making exceptions from one or more of its conditions.
+Additional permissions that are applicable to the entire Program shall
+be treated as though they were included in this License, to the extent
+that they are valid under applicable law.  If additional permissions
+apply only to part of the Program, that part may be used separately
+under those permissions, but the entire Program remains governed by
+this License without regard to the additional permissions.
+
+  When you convey a copy of a covered work, you may at your option
+remove any additional permissions from that copy, or from any part of
+it.  (Additional permissions may be written to require their own
+removal in certain cases when you modify the work.)  You may place
+additional permissions on material, added by you to a covered work,
+for which you have or can give appropriate copyright permission.
+
+  Notwithstanding any other provision of this License, for material you
+add to a covered work, you may (if authorized by the copyright holders of
+that material) supplement the terms of this License with terms:
+
+    a) Disclaiming warranty or limiting liability differently from the
+    terms of sections 15 and 16 of this License; or
+
+    b) Requiring preservation of specified reasonable legal notices or
+    author attributions in that material or in the Appropriate Legal
+    Notices displayed by works containing it; or
+
+    c) Prohibiting misrepresentation of the origin of that material, or
+    requiring that modified versions of such material be marked in
+    reasonable ways as different from the original version; or
+
+    d) Limiting the use for publicity purposes of names of licensors or
+    authors of the material; or
+
+    e) Declining to grant rights under trademark law for use of some
+    trade names, trademarks, or service marks; or
+
+    f) Requiring indemnification of licensors and authors of that
+    material by anyone who conveys the material (or modified versions of
+    it) with contractual assumptions of liability to the recipient, for
+    any liability that these contractual assumptions directly impose on
+    those licensors and authors.
+
+  All other non-permissive additional terms are considered "further
+restrictions" within the meaning of section 10.  If the Program as you
+received it, or any part of it, contains a notice stating that it is
+governed by this License along with a term that is a further
+restriction, you may remove that term.  If a license document contains
+a further restriction but permits relicensing or conveying under this
+License, you may add to a covered work material governed by the terms
+of that license document, provided that the further restriction does
+not survive such relicensing or conveying.
+
+  If you add terms to a covered work in accord with this section, you
+must place, in the relevant source files, a statement of the
+additional terms that apply to those files, or a notice indicating
+where to find the applicable terms.
+
+  Additional terms, permissive or non-permissive, may be stated in the
+form of a separately written license, or stated as exceptions;
+the above requirements apply either way.
+
+  8. Termination.
+
+  You may not propagate or modify a covered work except as expressly
+provided under this License.  Any attempt otherwise to propagate or
+modify it is void, and will automatically terminate your rights under
+this License (including any patent licenses granted under the third
+paragraph of section 11).
+
+  However, if you cease all violation of this License, then your
+license from a particular copyright holder is reinstated (a)
+provisionally, unless and until the copyright holder explicitly and
+finally terminates your license, and (b) permanently, if the copyright
+holder fails to notify you of the violation by some reasonable means
+prior to 60 days after the cessation.
+
+  Moreover, your license from a particular copyright holder is
+reinstated permanently if the copyright holder notifies you of the
+violation by some reasonable means, this is the first time you have
+received notice of violation of this License (for any work) from that
+copyright holder, and you cure the violation prior to 30 days after
+your receipt of the notice.
+
+  Termination of your rights under this section does not terminate the
+licenses of parties who have received copies or rights from you under
+this License.  If your rights have been terminated and not permanently
+reinstated, you do not qualify to receive new licenses for the same
+material under section 10.
+
+  9. Acceptance Not Required for Having Copies.
+
+  You are not required to accept this License in order to receive or
+run a copy of the Program.  Ancillary propagation of a covered work
+occurring solely as a consequence of using peer-to-peer transmission
+to receive a copy likewise does not require acceptance.  However,
+nothing other than this License grants you permission to propagate or
+modify any covered work.  These actions infringe copyright if you do
+not accept this License.  Therefore, by modifying or propagating a
+covered work, you indicate your acceptance of this License to do so.
+
+  10. Automatic Licensing of Downstream Recipients.
+
+  Each time you convey a covered work, the recipient automatically
+receives a license from the original licensors, to run, modify and
+propagate that work, subject to this License.  You are not responsible
+for enforcing compliance by third parties with this License.
+
+  An "entity transaction" is a transaction transferring control of an
+organization, or substantially all assets of one, or subdividing an
+organization, or merging organizations.  If propagation of a covered
+work results from an entity transaction, each party to that
+transaction who receives a copy of the work also receives whatever
+licenses to the work the party's predecessor in interest had or could
+give under the previous paragraph, plus a right to possession of the
+Corresponding Source of the work from the predecessor in interest, if
+the predecessor has it or can get it with reasonable efforts.
+
+  You may not impose any further restrictions on the exercise of the
+rights granted or affirmed under this License.  For example, you may
+not impose a license fee, royalty, or other charge for exercise of
+rights granted under this License, and you may not initiate litigation
+(including a cross-claim or counterclaim in a lawsuit) alleging that
+any patent claim is infringed by making, using, selling, offering for
+sale, or importing the Program or any portion of it.
+
+  11. Patents.
+
+  A "contributor" is a copyright holder who authorizes use under this
+License of the Program or a work on which the Program is based.  The
+work thus licensed is called the contributor's "contributor version".
+
+  A contributor's "essential patent claims" are all patent claims
+owned or controlled by the contributor, whether already acquired or
+hereafter acquired, that would be infringed by some manner, permitted
+by this License, of making, using, or selling its contributor version,
+but do not include claims that would be infringed only as a
+consequence of further modification of the contributor version.  For
+purposes of this definition, "control" includes the right to grant
+patent sublicenses in a manner consistent with the requirements of
+this License.
+
+  Each contributor grants you a non-exclusive, worldwide, royalty-free
+patent license under the contributor's essential patent claims, to
+make, use, sell, offer for sale, import and otherwise run, modify and
+propagate the contents of its contributor version.
+
+  In the following three paragraphs, a "patent license" is any express
+agreement or commitment, however denominated, not to enforce a patent
+(such as an express permission to practice a patent or covenant not to
+sue for patent infringement).  To "grant" such a patent license to a
+party means to make such an agreement or commitment not to enforce a
+patent against the party.
+
+  If you convey a covered work, knowingly relying on a patent license,
+and the Corresponding Source of the work is not available for anyone
+to copy, free of charge and under the terms of this License, through a
+publicly available network server or other readily accessible means,
+then you must either (1) cause the Corresponding Source to be so
+available, or (2) arrange to deprive yourself of the benefit of the
+patent license for this particular work, or (3) arrange, in a manner
+consistent with the requirements of this License, to extend the patent
+license to downstream recipients.  "Knowingly relying" means you have
+actual knowledge that, but for the patent license, your conveying the
+covered work in a country, or your recipient's use of the covered work
+in a country, would infringe one or more identifiable patents in that
+country that you have reason to believe are valid.
+
+  If, pursuant to or in connection with a single transaction or
+arrangement, you convey, or propagate by procuring conveyance of, a
+covered work, and grant a patent license to some of the parties
+receiving the covered work authorizing them to use, propagate, modify
+or convey a specific copy of the covered work, then the patent license
+you grant is automatically extended to all recipients of the covered
+work and works based on it.
+
+  A patent license is "discriminatory" if it does not include within
+the scope of its coverage, prohibits the exercise of, or is
+conditioned on the non-exercise of one or more of the rights that are
+specifically granted under this License.  You may not convey a covered
+work if you are a party to an arrangement with a third party that is
+in the business of distributing software, under which you make payment
+to the third party based on the extent of your activity of conveying
+the work, and under which the third party grants, to any of the
+parties who would receive the covered work from you, a discriminatory
+patent license (a) in connection with copies of the covered work
+conveyed by you (or copies made from those copies), or (b) primarily
+for and in connection with specific products or compilations that
+contain the covered work, unless you entered into that arrangement,
+or that patent license was granted, prior to 28 March 2007.
+
+  Nothing in this License shall be construed as excluding or limiting
+any implied license or other defenses to infringement that may
+otherwise be available to you under applicable patent law.
+
+  12. No Surrender of Others' Freedom.
+
+  If conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot convey a
+covered work so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you may
+not convey it at all.  For example, if you agree to terms that obligate you
+to collect a royalty for further conveying from those to whom you convey
+the Program, the only way you could satisfy both those terms and this
+License would be to refrain entirely from conveying the Program.
+
+  13. Use with the GNU Affero General Public License.
+
+  Notwithstanding any other provision of this License, you have
+permission to link or combine any covered work with a work licensed
+under version 3 of the GNU Affero General Public License into a single
+combined work, and to convey the resulting work.  The terms of this
+License will continue to apply to the part which is the covered work,
+but the special requirements of the GNU Affero General Public License,
+section 13, concerning interaction through a network will apply to the
+combination as such.
+
+  14. Revised Versions of this License.
+
+  The Free Software Foundation may publish revised and/or new versions of
+the GNU General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+  Each version is given a distinguishing version number.  If the
+Program specifies that a certain numbered version of the GNU General
+Public License "or any later version" applies to it, you have the
+option of following the terms and conditions either of that numbered
+version or of any later version published by the Free Software
+Foundation.  If the Program does not specify a version number of the
+GNU General Public License, you may choose any version ever published
+by the Free Software Foundation.
+
+  If the Program specifies that a proxy can decide which future
+versions of the GNU General Public License can be used, that proxy's
+public statement of acceptance of a version permanently authorizes you
+to choose that version for the Program.
+
+  Later license versions may give you additional or different
+permissions.  However, no additional obligations are imposed on any
+author or copyright holder as a result of your choosing to follow a
+later version.
+
+  15. Disclaimer of Warranty.
+
+  THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
+APPLICABLE LAW.  EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
+HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
+OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
+THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+PURPOSE.  THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
+IS WITH YOU.  SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
+ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
+
+  16. Limitation of Liability.
+
+  IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
+THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
+GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
+USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
+DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
+PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
+EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
+SUCH DAMAGES.
+
+  17. Interpretation of Sections 15 and 16.
+
+  If the disclaimer of warranty and limitation of liability provided
+above cannot be given local legal effect according to their terms,
+reviewing courts shall apply local law that most closely approximates
+an absolute waiver of all civil liability in connection with the
+Program, unless a warranty or assumption of liability accompanies a
+copy of the Program in return for a fee.
+
+                     END OF TERMS AND CONDITIONS
+
+            How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+state the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    {one line to give the program's name and a brief idea of what it does.}
+    Copyright (C) {year}  {name of author}
+
+    This program is free software: you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation, either version 3 of the License, or
+    (at your option) any later version.
+
+    This program is distributed in the hope that it will be useful,
+    but WITHOUT ANY WARRANTY; without even the implied warranty of
+    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+    GNU General Public License for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program.  If not, see {http://www.gnu.org/licenses/}.
+
+Also add information on how to contact you by electronic and paper mail.
+
+  If the program does terminal interaction, make it output a short
+notice like this when it starts in an interactive mode:
+
+    Fastaq  Copyright (C) 2013  Pathogen Genomics, Wellcome Trust Sanger Institute
+    This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, your program's commands
+might be different; for a GUI interface, you would use an "about box".
+
+  You should also get your employer (if you work as a programmer) or school,
+if any, to sign a "copyright disclaimer" for the program, if necessary.
+For more information on this, and how to apply and follow the GNU GPL, see
+{http://www.gnu.org/licenses/}.
+
+  The GNU General Public License does not permit incorporating your program
+into proprietary programs.  If your program is a subroutine library, you
+may consider it more useful to permit linking proprietary applications with
+the library.  If this is what you want to do, use the GNU Lesser General
+Public License instead of this License.  But first, please read
+{http://www.gnu.org/philosophy/why-not-lgpl.html}.
diff --git a/MANIFEST.in b/MANIFEST.in
new file mode 100644
index 0000000..f5282c0
--- /dev/null
+++ b/MANIFEST.in
@@ -0,0 +1 @@
+recursive-include fastaq/tests *.txt *.sh *.py *_test_*
diff --git a/README.md b/README.md
new file mode 100644
index 0000000..a5c3464
--- /dev/null
+++ b/README.md
@@ -0,0 +1,50 @@
+Fastaq
+======
+
+Python3 scripts to manipulate FASTA and FASTQ files, plus API for developers
+
+Installation
+------------
+
+Run the tests:
+
+    python3 setup.py test
+
+Install:
+
+    python3 setup.py install
+
+Notes:
+ * A few scripts assume that samtools is installed and in your path. This is NOT tested in the tests, because most scripts don't need it.
+ * The installation will put all scripts in your path and are named fastaq_*.
+
+Scripts
+-------
+
+Key points:
+ * Use -h or --help with a script to get its usage.
+ * All scripts automatically detect whether the input is a FASTA or FASTQ file.
+ * Input and output files can be gzipped. An input file is assumed to be gzipped if its name ends with .gz. To gzip an output file, just name it with .gz at the end.
+ * You can use a minus sign for a filename to use stdin or stdout, so scripts can be piped together. See the following examples.
+
+Reverse complement all sequences in a file:
+
+    fastaq_reverse_complement in.fastq out.fastq
+
+Reverse complement all sequences in a gzipped file, then translate each sequence
+
+    fastaq_reverse_complement in.fastq.gz - | fastaq_translate - out.fasta
+
+For developers
+--------------
+
+Here is a template for counting the sequences in a FASTA or FASTQ file:
+
+    from fastaq import sequences
+    seq_reader = sequences.file_reader(infile)
+    count = 0
+    for seq in seq_reader:
+        count += 1
+    print(count)
+
+Hopefully you get the idea and there are plenty of examples in tasks.py. Detection of FASTA or FASTQ and gzipped or not input file 'infile' is automatic. See help(sequences) for the various methods already defined in the classes Fasta and Fastq.
diff --git a/fastaq/__init__.py b/fastaq/__init__.py
new file mode 100644
index 0000000..52ded75
--- /dev/null
+++ b/fastaq/__init__.py
@@ -0,0 +1,2 @@
+__all__ = ['utils', 'sequences', 'tasks', 'intervals']
+from fastaq import *
diff --git a/fastaq/intervals.py b/fastaq/intervals.py
new file mode 100644
index 0000000..b320c63
--- /dev/null
+++ b/fastaq/intervals.py
@@ -0,0 +1,117 @@
+class Error (Exception): pass
+
+
+class Interval:
+    '''A class to deal with intervals in a genome. Can do things like intersections, unions etc'''
+    def __init__(self, start, end):
+        try:
+            self.start = int(start)
+            self.end = int(end)
+        except ValueError:
+            raise Error('Error making interval from :"' + str(start) + '" and "' + str(end) + '"')
+
+        if self.end < self.start:
+            raise Error('Error making interval ' + str(self) + '.  end < start.')
+
+    def __len__(self):
+        return self.end - self.start + 1
+
+    def __eq__(self, other):
+        return type(other) is type(self) and self.__dict__ == other.__dict__
+
+    def __ne__(self, other):
+        return not self.__eq__(other)
+
+    def __str__(self):
+        return '(' + str(self.start) + ',' + str(self.end) + ')'
+
+    def __lt__(self, i):
+        return self.start < i.start or (self.start == i.start and self.end < i.end)
+
+    def __le__(self, i):
+        return self.start < i.start or (self.start == i.start and self.end <= i.end)
+
+    def intersects(self, i):
+        '''Returns true iff this interval intersects the interval i'''
+        return self.start <= i.end and i.start <= self.end
+
+    def contains(self, i):
+        '''Returns true iff this interval contains the interval i'''
+        return self.start <= i.start and i.end <= self.end
+
+    def union(self, i):
+        '''If intervals intersect, returns their union, otherwise returns None'''
+        if self.intersects(i) or self.end + 1 == i.start or i.end + 1 == self.start:
+            return Interval(min(self.start, i.start), max(self.end, i.end))
+        else:
+            return None
+
+    def union_fill_gap(self, i):
+        '''Like union, but ignores whether the two intervals intersect or not'''
+        return Interval(min(self.start, i.start), max(self.end, i.end))
+
+    def intersection(self, i):
+        '''If intervals intersect, returns their intersection, otherwise returns None'''
+        if self.intersects(i):
+            return Interval(max(self.start, i.start), min(self.end, i.end))
+        else:
+            return None
+
+
+def intersection(l1, l2):
+    '''Returns intersection of two lists.  Assumes the lists are sorted by start positions'''
+    if len(l1) == 0 or len(l2) == 0:
+        return []
+
+    out = []
+    l2_pos = 0
+
+    for l in l1:
+        while l2_pos < len(l2) and l2[l2_pos].end < l.start:
+            l2_pos += 1
+
+        if l2_pos == len(l2):
+            break
+
+        while l2_pos < len(l2) and l.intersects(l2[l2_pos]):
+            out.append(l.intersection(l2[l2_pos]))
+            l2_pos += 1
+
+        l2_pos = max(0, l2_pos - 1)
+
+    return out
+
+
+def merge_overlapping_in_list(l):
+    '''Sorts list, merges any overlapping intervals, and also adjacent intervals. e.g.
+       [0,1], [1,2] would be merge to [0,.2].'''
+    i = 0
+    l.sort()
+
+    while i < len(l) - 1:
+        u = l[i].union(l[i+1])
+        if u is not None:
+            l[i] = u
+            l.pop(i+1)
+        else:
+            i += 1
+
+
+def remove_contained_in_list(l):
+    '''Sorts list in place, then removes any intervals that are completely
+       contained inside another interval'''
+    i = 0
+    l.sort()
+
+    while i < len(l) - 1:
+       if l[i+1].contains(l[i]):
+           l.pop(i)
+       elif l[i].contains(l[i+1]):
+           l.pop(i+1)
+       else:
+           i += 1
+
+
+def length_sum_from_list(l):
+    '''Returns total length of intervals from a list'''
+    return sum([len(x) for x in l])
diff --git a/fastaq/sequences.py b/fastaq/sequences.py
new file mode 100644
index 0000000..f7efb1a
--- /dev/null
+++ b/fastaq/sequences.py
@@ -0,0 +1,638 @@
+import re
+import string
+import random
+import itertools
+
+from fastaq import utils, intervals
+
+class Error (Exception): pass
+
+
+# python 3's seek is glacially slow. When we read a fasta file, we know
+# we've reached the end of a sequence when we get a new line starting with
+# '>'. Instead of using seek and tell, we just remember the previous line
+# of the file, for any given filehandle
+previous_lines = {}
+
+
+codon2aa = {
+'GCA': 'A',
+'GCC': 'A',
+'GCG': 'A',
+'GCT': 'A',
+'AGA': 'R',
+'AGG': 'R',
+'CGA': 'R',
+'CGC': 'R',
+'CGG': 'R',
+'CGT': 'R',
+'AAC': 'N',
+'AAT': 'N',
+'GAC': 'D',
+'GAT': 'D',
+'TGC': 'C',
+'TGT': 'C',
+'GAA': 'E',
+'GAG': 'E',
+'CAA': 'Q',
+'CAG': 'Q',
+'GGA': 'G',
+'GGC': 'G',
+'GGG': 'G',
+'GGT': 'G',
+'CAC': 'H',
+'CAT': 'H',
+'ATA': 'I',
+'ATC': 'I',
+'ATT': 'I',
+'TTA': 'L',
+'TTG': 'L',
+'CTA': 'L',
+'CTC': 'L',
+'CTG': 'L',
+'CTT': 'L',
+'AAA': 'K',
+'AAG': 'K',
+'ATG': 'M',
+'TTC': 'F',
+'TTT': 'F',
+'CCA': 'P',
+'CCC': 'P',
+'CCG': 'P',
+'CCT': 'P',
+'AGC': 'S',
+'AGT': 'S',
+'TCA': 'S',
+'TCC': 'S',
+'TCG': 'S',
+'TCT': 'S',
+'ACA': 'T',
+'ACC': 'T',
+'ACG': 'T',
+'ACT': 'T',
+'TGG': 'W',
+'TAC': 'Y',
+'TAT': 'Y',
+'GTA': 'V',
+'GTC': 'V',
+'GTG': 'V',
+'GTT': 'V',
+'TAA': '*',
+'TAG': '*',
+'TGA': '*'}
+
+
+redundant_nts = {
+    'R': ('A', 'G'),
+    'Y': ('C', 'T'),
+    'S': ('C', 'G'),
+    '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')
+}
+
+def file_reader(fname, read_quals=False):
+    '''Iterates over a FASTA or FASTQ file, yielding the next sequence in the file until there are no more sequences'''
+    f = utils.open_file_read(fname)
+    line = f.readline()
+    phylip_regex = re.compile('^\s*[0-9]+\s+[0-9]+$')
+    gbk_regex = re.compile('^LOCUS\s+\S')
+
+    if line.startswith('>'):
+        seq = Fasta()
+        previous_lines[f] = line
+    elif line.startswith('##gff-version 3'):
+        seq = Fasta()
+        # if a GFF file, need to skip past all the annotation
+        # and get to the fasta sequences at the end of the file
+        while not line.startswith('>'):
+            line = f.readline()
+            if not line:
+                utils.close(f)
+                raise Error('No sequences found in GFF file "' + fname + '"')
+
+        seq = Fasta()
+        previous_lines[f] = line
+    elif line.startswith('ID   ') and line[5] != ' ':
+        seq = Embl()
+        previous_lines[f] = line
+    elif gbk_regex.search(line):
+        seq = Embl()
+        previous_lines[f] = line
+    elif line.startswith('@'):
+        seq = Fastq()
+        previous_lines[f] = line
+    elif phylip_regex.search(line):
+        # phylip format could be interleaved or not, need to look at next
+        # couple of lines to figure that out. Don't expect these files to
+        # be too huge, so just store all the sequences in memory
+        number_of_seqs, bases_per_seq = line.strip().split()
+        number_of_seqs = int(number_of_seqs)
+        bases_per_seq = int(bases_per_seq)
+        got_blank_line = False
+
+        first_line = line
+        seq_lines = []
+        while 1:
+            line = f.readline()
+            if line == '':
+                break
+            elif line == '\n':
+                got_blank_line = True
+            else:
+                seq_lines.append(line.rstrip())
+        utils.close(f)
+
+        if len(seq_lines) == 1 or len(seq_lines) == number_of_seqs:
+            sequential = True
+        elif seq_lines[0][10] != ' ' and seq_lines[1][10] == ' ':
+            sequential = True
+        else:
+            sequential = False
+
+        # if the 11th char of second sequence line is a space,  then the file is sequential, e.g.:
+        # GAGCCCGGGC AATACAGGGT AT
+        # as opposed to:
+        # Salmo gairAAGCCTTGGC AGTGCAGGGT
+        if sequential:
+            current_id = None
+            current_seq = ''
+            for line in seq_lines:
+                if len(current_seq) == bases_per_seq or len(current_seq) == 0:
+                    if current_id is not None:
+                        yield Fasta(current_id, current_seq.replace('-', ''))
+                    current_seq = ''
+                    current_id, new_bases = line[0:10].rstrip(), line.rstrip()[10:]
+                else:
+                    new_bases = line.rstrip()
+
+                current_seq += new_bases.replace(' ','')
+
+            yield Fasta(current_id, current_seq.replace('-', ''))
+        else:
+            # seaview files start all seqs at pos >=12. Other files start
+            # their sequence at the start of the line
+            if seq_lines[number_of_seqs + 1][0] == ' ':
+                first_gap_pos = seq_lines[0].find(' ')
+                end_of_gap = first_gap_pos
+                while seq_lines[0][end_of_gap] == ' ':
+                    end_of_gap += 1
+                first_seq_base = end_of_gap
+            else:
+                first_seq_base = 10
+
+            seqs = []
+            for i in range(number_of_seqs):
+                name, bases = seq_lines[i][0:first_seq_base].rstrip(), seq_lines[i][first_seq_base:]
+                seqs.append(Fasta(name, bases))
+
+            for i in range(number_of_seqs, len(seq_lines)):
+                seqs[i%number_of_seqs].seq += seq_lines[i]
+
+            for fa in seqs:
+                fa.seq = fa.seq.replace(' ','').replace('-','')
+                yield fa
+
+        return
+    elif line == '':
+        utils.close(f)
+        return
+    else:
+        utils.close(f)
+        raise Error('Error determining file type from file "' + fname + '". First line is:\n' + line.rstrip())
+
+    try:
+        while seq.get_next_from_file(f, read_quals):
+            yield seq
+    finally:
+        utils.close(f)
+
+
+class Fasta:
+    '''Class to store and manipulate FASTA sequences. They have two things: a name and a sequence'''
+    # this defines the line length when printing sequences
+    line_length = 60
+
+    def _get_id_from_header_line(self, line):
+        if line.startswith('>'):
+            return line.rstrip()[1:]
+        else:
+            raise Error('Error! expected line starting with ">", but got this:\n', line)
+
+
+    def __init__(self, id_in=None, seq_in=None):
+        self.id = id_in
+        self.seq = seq_in
+
+    def __eq__(self, other):
+        return type(other) is type(self) and self.__dict__ == other.__dict__
+
+    def __ne__(self, other):
+        return not self.__eq__(other)
+
+    def __len__(self):
+        return len(self.seq)
+
+    def split_capillary_id(self):
+        '''Gets the prefix and suffix of an name of a capillary read, e.g. xxxxx.p1k or xxxx.q1k. Returns a tuple (prefix, suffx)'''
+        try:
+            a = self.id.rsplit('.', 1)
+            if a[1].startswith('p'):
+                dir = 'fwd'
+            elif a[1].startswith('q'):
+                dir = 'rev'
+            else:
+                dir = 'unk'
+
+            return {'prefix': a[0], 'dir': dir, 'suffix':a[1]}
+        except:
+            raise Error('Error in split_capillary_id() on ID', self.id)
+
+    def expand_nucleotides(self):
+        '''Assumes sequence is nucleotides. Returns list of all combinations of redundant nucleotides. e.g. R is A or G, so CRT would have combinations CAT and CGT'''
+        s = list(self.seq)
+        for i in range(len(s)):
+            if s[i] in redundant_nts:
+                s[i] = ''.join(redundant_nts[s[i]])
+
+        seqs = []
+        for x in itertools.product(*s):
+            seqs.append(Fasta(self.id + '.' + str(len(seqs) + 1), ''.join(x)))
+        return seqs
+
+    def strip_after_first_whitespace(self):
+        '''Removes everything in the name after the first whitespace character'''
+        self.id = self.id.split()[0]
+
+    def strip_illumina_suffix(self):
+        '''Removes any trailing /1 or /2 off the end of the name'''
+        if self.id.endswith('/1') or self.id.endswith('/2'):
+            self.id = self.id[:-2]
+
+    def revcomp(self):
+        '''Reverse complements the sequence'''
+        self.seq = self.seq.translate(str.maketrans("ATCGatcg", "TAGCtagc"))[::-1]
+
+    def is_all_Ns(self, start=0, end=None):
+        '''Returns true if the sequence is all Ns (upper or lower case)'''
+        if end is not None:
+            if start > end:
+                raise Error('Error in is_all_Ns. Start coord must be <= end coord')
+            end += 1
+        else:
+            end = len(self)
+
+        if len(self) == 0:
+            return False
+        else:
+            return re.search('[^Nn]', self.seq[start:end]) is None
+
+    def trim_Ns(self):
+        '''Removes any leading or trailing N or n characters from the sequence'''
+        self.seq = self.seq.strip('Nn')
+
+    def add_insertions(self, skip=10, window=1, test=False):
+        '''Adds a random base within window bases around every skip bases. e.g. skip=10, window=1 means a random base added somwhere in theintervals [9,11], [19,21] ... '''
+        assert 2 * window < skip
+        new_seq = list(self.seq)
+        for i in range(len(self) - skip, 0, -skip):
+            pos = random.randrange(i - window, i + window + 1)
+            base = random.choice(['A', 'C', 'G', 'T'])
+            if test:
+                base = 'N'
+            new_seq.insert(pos, base)
+
+        self.seq = ''.join(new_seq)
+
+    def replace_bases(self, old, new):
+        '''Replaces all occurences of 'old' with 'new' '''
+        self.seq = self.seq.replace(old, new)
+
+    def replace_interval(self, start, end, new):
+        '''Replaces the sequence from start to end with the sequence "new"'''
+        if start > end or start > len(self) - 1 or end > len(self) - 1:
+            raise Error('Error replacing bases ' + str(start) + '-' + str(end) + ' in sequence ' + self.id)
+
+        self.seq = self.seq[0:start] + new + self.seq[end + 1:]
+
+    def gaps(self, min_length = 1):
+        '''Finds the positions of all gaps in the sequence that are at least min_length long. Returns a list of Intervals. Coords are zero-based'''
+        gaps = []
+        regex = re.compile('N+', re.IGNORECASE)
+        for m in regex.finditer(self.seq):
+             if m.span()[1] - m.span()[0] + 1 >= min_length:
+                 gaps.append(intervals.Interval(m.span()[0], m.span()[1] - 1))
+        return gaps
+
+    def contig_coords(self):
+        '''Finds coords of contigs, i.e. everything that's not a gap (N or n). Returns a list of Intervals. Coords are zero-based'''
+        # contigs are the opposite of gaps, so work out the coords from the gap coords
+        gaps = self.gaps()
+
+        if len(gaps) == 0:
+            return [intervals.Interval(0, len(self) - 1)]
+
+        coords = [0]
+        for g in gaps:
+            if g.start == 0:
+                coords = [g.end + 1]
+            else:
+                coords += [g.start - 1, g.end + 1]
+
+        if coords[-1] < len(self):
+            coords.append(len(self) - 1)
+
+        return [intervals.Interval(coords[i], coords[i+1]) for i in range(0, len(coords)-1,2)]
+
+
+
+
+    def orfs(self, frame=0, revcomp=False):
+        assert frame in [0,1,2]
+        if revcomp:
+            self.revcomp()
+
+        aa_seq = self.translate(frame=frame).seq.rstrip('X')
+        if revcomp:
+            self.revcomp()
+
+        orfs = _orfs_from_aa_seq(aa_seq)
+        for i in range(len(orfs)):
+            if revcomp:
+                start = len(self) - (orfs[i].end * 3 + 3) - frame
+                end = len(self) - (orfs[i].start * 3) - 1 - frame
+            else:
+                start = orfs[i].start * 3 + frame
+                end = orfs[i].end * 3 + 2 + frame
+
+            orfs[i] = intervals.Interval(start, end)
+
+        return orfs
+
+
+    def all_orfs(self, min_length=300):
+        orfs = []
+        for frame in [0,1,2]:
+            for revcomp in [False, True]:
+                orfs.extend([(t, revcomp) for t in self.orfs(frame=frame, revcomp=revcomp) if len(t)>=min_length])
+
+        return sorted(orfs, key=lambda t:t[0])
+
+    # Fills the object with the next sequence in the file. Returns
+    # True if this was successful, False if no more sequences in the file.
+    # If reading a file of quality scores, set read_quals = True
+    def get_next_from_file(self, f, read_quals=False):
+        if f in previous_lines:
+            if previous_lines[f] == None:
+                self.id = self.seq = None
+                return False
+            else:
+                self.id = self._get_id_from_header_line(previous_lines[f])
+        else:
+            line = '\n'
+            while line == '\n':
+                line = f.readline()
+            self.id = self._get_id_from_header_line(line)
+
+        self.seq = ''
+        seq_lines = [] # much faster to store the seq lines in an array,
+                       # then join at the end
+
+        while 1:
+            line = f.readline()
+
+            if line.startswith('>'):
+                previous_lines[f] = line.rstrip()
+                break
+            elif line == '':
+                previous_lines[f] = None
+                break
+            else:
+                 seq_lines.append(line.rstrip())
+
+        if read_quals:
+            self.seq = ' '.join(seq_lines)
+        else:
+            self.seq = ''.join(seq_lines)
+        return True
+
+    def __str__(self):
+        if Fasta.line_length == 0:
+            return '>' + self.id + '\n' + self.seq
+        else:
+            return '>' + self.id + '\n' + '\n'.join(self.seq[i:i+Fasta.line_length] for i in range(0, len(self), Fasta.line_length))
+
+    def __getitem__(self, index):
+        return self.seq[index]
+
+    def trim(self, start, end):
+        '''Removes first 'start'/'end' bases off the start/end of the sequence'''
+        self.seq = self.seq[start:len(self.seq) - end]
+
+    # qual_scores should be a list of quality scores
+    def to_Fastq(self, qual_scores):
+        '''Returns a Fastq object. qual_scores expected to be a list of numbers, like you would get in a .qual file'''
+        if len(self) != len(qual_scores):
+            raise Error('Error making Fastq from Fasta, lengths differ.', self.id)
+        return Fastq(self.id, self.seq, ''.join([chr(max(0, min(x, 93)) + 33) for x in qual_scores]))
+
+    def search(self, search_string):
+        '''Finds every occurence (including overlapping ones) of the search_string, including on the reverse strand. Returns a list where each element is a tuple (position, strand) where strand is in ['-', '+']. Positions are zero-based'''
+        seq = self.seq.upper()
+        search_string = search_string.upper()
+        pos = 0
+        found = seq.find(search_string, pos)
+        hits = []
+
+        while found != -1:
+            hits.append((found, '+'))
+            pos = found + 1
+            found = seq.find(search_string, pos)
+
+
+        pos = 0
+        search_string = Fasta('x', search_string)
+        search_string.revcomp()
+        search_string = search_string.seq
+        found = seq.find(search_string, pos)
+
+        while found != -1:
+            hits.append((found, '-'))
+            pos = found + 1
+            found = seq.find(search_string, pos)
+
+        return hits
+
+    def translate(self, frame=0):
+        '''Returns a Fasta sequence, translated into amino acids. Starts translating from 'frame', where frame expected to be 0,1 or 2'''
+        return Fasta(self.id, ''.join([codon2aa.get(self.seq[x:x+3].upper(), 'X') for x in range(frame, len(self)-1-frame, 3)]))
+
+
+class Embl(Fasta):
+    '''Exactly the same as Fasta, but reading seqs from a file works differently'''
+    def __eq__(self, other):
+        return type(other) in [Fasta, Embl] and  type(self) in [Fasta, Embl] and self.__dict__ == other.__dict__
+
+    def _get_id_from_header_line(self, line):
+        if line.startswith('ID   ') and line[5] != ' ':
+            return line.split()[1].rstrip(';')
+        elif line.startswith('LOCUS'):
+            return line.split()[1]
+        else:
+            raise Error('Error! expected line starting with "ID" or "LOCUS", but got this:\n', line)
+
+    def get_next_from_file(self, f, read_quals=False):
+        if f in previous_lines:
+            line = ''
+            if previous_lines[f] == None:
+                self.id = self.seq = None
+                return False
+            else:
+                self.id = self._get_id_from_header_line(previous_lines[f])
+        else:
+            line = '\n'
+            while line == '\n':
+                line = f.readline()
+            self.id = self._get_id_from_header_line(line)
+
+        self.seq = ''
+        seq_lines = []
+
+        while not (line.startswith('SQ') or line.rstrip() == 'ORIGIN'):
+            line = f.readline()
+            if line == '':
+                raise Error('Error! No SQ or ORIGIN line found for sequence ' + self.id)
+
+        line = f.readline()
+
+        while not line.startswith('//'):
+            if line == '' or line[0] != ' ':
+                raise Error('Error! Did not find end of sequence ' + self.id)
+            seq_lines.append(''.join(line.rstrip().strip(' 0123456789').split()))
+            line = f.readline()
+
+
+        while 1:
+            if line.startswith('ID') or line.startswith('LOCUS'):
+                previous_lines[f] = line.rstrip()
+                break
+            elif line == '':
+                previous_lines[f] = None
+                break
+
+            line = f.readline()
+
+        self.seq = ''.join(seq_lines)
+        return True
+
+class Fastq(Fasta):
+    '''Class to store and manipulate FASTQ sequences. They have three things: a name, sequence and string of quality scores'''
+    def __init__(self, id_in=None, seq_in=None, qual_in=None):
+        super().__init__(id_in, seq_in)
+        self.qual = qual_in
+        if (not self.seq == self.qual == None) and len(self.qual) != len(self.seq):
+            raise Error('Error constructing Fastq. Mismatch in sequence and quality length\n' + str(self))
+
+    def __str__(self):
+        return '@' + self.id + '\n' + self.seq + '\n+\n' + self.qual
+
+    def __eq__(self, other):
+        return type(other) is type(self) and self.__dict__ == other.__dict__
+
+    def get_next_from_file(self, f, read_quals=False):
+        if f in previous_lines:
+            line = previous_lines[f]
+            del previous_lines[f]
+        else:
+            line = f.readline()
+
+        while line == '\n':
+            line = f.readline()
+
+        if not line:
+            self = Fastq('', '', '')
+            return False
+
+        if not line.startswith('@'):
+            raise Error('Error getting next sequence from fastq file. Got line:\n' + line)
+
+        self.id = line.rstrip()[1:]
+        line = f.readline()
+        if not line:
+            raise Error('Error getting next sequence from fastq file, sequence has ID ' + self.id)
+
+        self.seq = line.strip()
+
+        line = f.readline()
+        if not (line and line.startswith('+')):
+            raise Error('Error getting next sequence from fastq file, no line starting with +,  sequence has ID ' + self.id)
+
+        line = f.readline()
+        if not line:
+            raise Error('Error getting next sequence from fastq file, sequence has ID ' + self.id)
+
+        self.qual = line.rstrip()
+        return True
+
+    def revcomp(self):
+        '''Reverse complements the sequence'''
+        super().revcomp()
+        self.qual = self.qual[::-1]
+
+    def trim(self, start, end):
+        '''Removes first 'start'/'end' bases off the start/end of the sequence'''
+        super().trim(start, end)
+        self.qual = self.qual[start:len(self.qual) - end]
+
+    def to_Fasta_and_qual(self):
+        quals = [ord(x) - 33 for x in self.qual]
+        return (Fasta(self.id, self.seq), quals)
+
+    def expand_nucleotides(self):
+        return [Fastq(x.id, x.seq, self.qual) for x in super().expand_nucleotides()]
+
+    def trim_Ns(self):
+        '''Removes any leading or trailing N or n characters from the sequence'''
+        # get index of first base that is not an N
+        i = 0
+        while i < len(self) and self.seq[i] in 'nN':
+            i += 1
+
+        # strip off start of sequence and quality
+        self.seq = self.seq[i:]
+        self.qual = self.qual[i:]
+
+        # strip the ends
+        self.seq = self.seq.rstrip('Nn')
+        self.qual = self.qual[:len(self.seq)]
+
+    def replace_interval(self, start, end, new, qual_string):
+        '''Replaces the sequence from start to end with the sequence "new"'''
+        if len(new) != len(qual_string):
+            raise Error('Length of new seq and qual string in replace_interval() must be equal. Cannot continue')
+        super().replace_interval(start, end, new)
+        self.qual = self.qual[0:start] + qual_string + self.qual[end + 1:]
+
+    def translate(self):
+        '''Returns a Fasta sequence, translated into amino acids. Starts translating from 'frame', where frame expected to be 0,1 or 2'''
+        fa = super().translate()
+        return Fastq(fa.id, fa.seq, 'I'*len(fa.seq))
+
+
+def _orfs_from_aa_seq(seq):
+    orfs = []
+    pos = 0
+    while pos < len(seq):
+        next_stop = seq.find('*', pos)
+        if next_stop == -1:
+            orfs.append(intervals.Interval(pos, len(seq)-1))
+            break
+        elif next_stop > pos:
+            orfs.append(intervals.Interval(pos, next_stop))
+        pos = next_stop + 1
+    return orfs
diff --git a/fastaq/tasks.py b/fastaq/tasks.py
new file mode 100644
index 0000000..068a640
--- /dev/null
+++ b/fastaq/tasks.py
@@ -0,0 +1,727 @@
+import re
+import sys
+import copy
+import random
+import numpy
+from fastaq import sequences, utils
+
+class Error (Exception): pass
+
+def capillary_to_pairs(infile, outprefix):
+    # hash the sequences, only taking longest where an end has been sequenced more than once
+    seq_reader = sequences.file_reader(infile)
+    fwd_seqs = {}
+    rev_seqs = {}
+    unpaired_seqs = {}
+
+    for seq in seq_reader:
+        id_info = seq.split_capillary_id()
+        if id_info['dir'] == 'fwd':
+            seq.id = id_info['prefix'] + '/1'
+            h = fwd_seqs
+        elif id_info['dir'] == 'rev':
+            seq.id = id_info['prefix'] + '/2'
+            h = rev_seqs
+        else:
+            seq.id = id_info['prefix']
+            h = unpaired_seqs
+
+        key = id_info['prefix']
+
+        if key not in h or len(h[key]) < len(seq):
+            h[key] = copy.copy(seq)
+
+    # write the output files
+    f_pe = utils.open_file_write(outprefix + '.paired.gz')
+    f_up = utils.open_file_write(outprefix + '.unpaired.gz')
+
+    for id in fwd_seqs:
+        if id in rev_seqs:
+            print(fwd_seqs[id], file=f_pe)
+            print(rev_seqs[id], file=f_pe)
+            del rev_seqs[id]
+        else:
+            print(fwd_seqs[id], file=f_up)
+
+    for seq in rev_seqs.values():
+        print(seq, file=f_up)
+
+    for seq in unpaired_seqs.values():
+        print(seq, file=f_up)
+
+    utils.close(f_pe)
+    utils.close(f_up)
+
+
+def count_sequences(infile):
+    '''Returns the number of sequences in a file'''
+    seq_reader = sequences.file_reader(infile)
+    n = 0
+    for seq in seq_reader:
+        n += 1
+    return n
+
+
+def deinterleave(infile, outfile_1, outfile_2, fasta_out=False):
+    seq_reader = sequences.file_reader(infile)
+    f_1 = utils.open_file_write(outfile_1)
+    f_2 = utils.open_file_write(outfile_2)
+    for seq in seq_reader:
+        if fasta_out:
+            print(sequences.Fasta(seq.id, seq.seq), file=f_1)
+        else:
+            print(seq, file=f_1)
+        try:
+            next(seq_reader)
+        except StopIteration:
+            utils.close(f_1)
+            utils.close(f_2)
+            raise Error('Error getting mate for sequence. Cannot continue')
+        if fasta_out:
+            print(sequences.Fasta(seq.id, seq.seq), file=f_2)
+        else:
+            print(seq, file=f_2)
+
+    utils.close(f_1)
+    utils.close(f_2)
+
+
+def enumerate_names(infile, outfile, start_index=1, keep_illumina_suffix=False, rename_file=None):
+    seq_reader = sequences.file_reader(infile)
+    fout_seqs = utils.open_file_write(outfile)
+    counter = start_index
+
+    if keep_illumina_suffix:
+        sequence_suffixes = ['/1', '/2']
+    else:
+        sequence_suffixes = []
+
+
+    if rename_file is not None:
+        fout_rename = utils.open_file_write(rename_file)
+        print('#old\tnew', file=fout_rename)
+
+    for seq in seq_reader:
+        old_id = seq.id
+        seq.id = str(counter)
+
+        for suff in sequence_suffixes:
+            if old_id.endswith(suff):
+                seq.id += suff
+                break
+
+        if rename_file is not None:
+            print(old_id, seq.id, sep='\t', file=fout_rename)
+
+        print(seq, file=fout_seqs)
+        counter += 1
+
+    utils.close(fout_seqs)
+
+    if rename_file is not None:
+        utils.close(fout_rename)
+
+
+def expand_nucleotides(infile, outfile):
+    seq_reader = sequences.file_reader(infile)
+    fout = utils.open_file_write(outfile)
+
+    for seq in seq_reader:
+        seqs = seq.expand_nucleotides()
+        if len(seqs) > 1:
+            for s in seqs:
+                print(s, file=fout)
+        else:
+            print(seq, file=fout)
+
+
+def extend_gaps(infile, outfile, trim):
+    seq_reader = sequences.file_reader(infile)
+    fout = utils.open_file_write(outfile)
+
+    for seq in seq_reader:
+        if len(seq) < 2 * trim:
+            continue
+
+        gaps = seq.gaps()
+        bases = list(seq.seq)
+
+        # extend the length of each gap
+        for gap in gaps:
+            left_start = max(gap.start - trim, 0)
+            right_end = min(gap.end + trim + 1, len(seq))
+
+            for i in range(left_start, gap.start):
+                bases[i] = 'N'
+
+            for i in range(gap.end, right_end):
+                bases[i] = 'N'
+
+        seq.seq = ''.join(bases)
+
+        # trim start/end bases and tidy up any resulting Ns at either end of the trimmed seq
+        seq.trim(trim, trim)
+        seq.trim_Ns()
+
+        # check that there is some non-N sequence left over
+        regex = re.compile('[^nN]')
+        if regex.search(seq.seq) is not None:
+            print(seq, file=fout)
+
+    utils.close(fout)
+
+
+def fastaq_to_fake_qual(infile, outfile, q=40):
+    seq_reader = sequences.file_reader(infile)
+    fout = utils.open_file_write(outfile)
+
+    for seq in seq_reader:
+        print('>' + seq.id, file=fout)
+        if sequences.Fasta.line_length == 0:
+            print(' '.join([str(q)] * len(seq)), file=fout)
+        else:
+            for i in range(0, len(seq), sequences.Fasta.line_length):
+                print(' '.join([str(q)] * min(sequences.Fasta.line_length, len(seq) - i)), file=fout)
+
+    utils.close(fout)
+
+
+def fasta_to_fastq(fasta_in, qual_in, outfile):
+    fa_reader = sequences.file_reader(fasta_in)
+    qual_reader = sequences.file_reader(qual_in, read_quals=True)
+    f_out = utils.open_file_write(outfile)
+
+    for seq in fa_reader:
+        qual = next(qual_reader)
+        if seq.id != qual.id:
+            utils.close(f_out)
+            raise Error('Mismatch in names from fasta and qual file', seq.id, qual.id)
+
+        qual.seq = [int(x) for x in qual.seq.split()]
+        print(seq.to_Fastq(qual.seq), file=f_out)
+
+    utils.close(f_out)
+
+
+def fastaq_to_mira_xml(infile, outfile):
+    seq_reader = sequences.file_reader(infile)
+    fout = utils.open_file_write(outfile)
+    print('<?xml version="1.0"?>', '<trace_volume>', sep='\n', file=fout)
+
+    for seq in seq_reader:
+        print('    <trace>',
+              '        <trace_name>' + seq.id + '</trace_name>',
+              '        <clip_quality_right>' + str(len(seq)) + '</clip_quality_right>',
+              '        <clip_vector_left>1</clip_vector_left>',
+              '    </trace>', sep='\n', file=fout)
+
+
+    print('</trace_volume>', file=fout)
+    utils.close(fout)
+
+
+def fastaq_to_orfs_gff(infile, outfile, min_length=300, tool_name='fastaq'):
+    seq_reader = sequences.file_reader(infile)
+    fout = utils.open_file_write(outfile)
+    for seq in seq_reader:
+        orfs = seq.all_orfs(min_length=min_length)
+        for coords, revcomp in orfs:
+            if revcomp:
+                strand = '-'
+            else:
+                strand = '+'
+
+            print(seq.id, tool_name, 'CDS', coords.start+1, coords.end+1, '.', strand, '.', sep='\t', file=fout)
+
+    utils.close(fout)
+
+
+def file_to_dict(infile, d):
+    seq_reader = sequences.file_reader(infile)
+    for seq in seq_reader:
+        d[seq.id] = copy.copy(seq)
+
+
+def filter(infile, outfile, minlength=0, maxlength=float('inf'), regex=None, ids_file=None, invert=False):
+    ids_from_file = set()
+    if ids_file is not None:
+        f = utils.open_file_read(ids_file)
+        for line in f:
+            ids_from_file.add(line.rstrip())
+        utils.close(f)
+
+    seq_reader = sequences.file_reader(infile)
+    f_out = utils.open_file_write(outfile)
+    if regex is not None:
+        r = re.compile(regex)
+
+    for seq in seq_reader:
+        hit = minlength <= len(seq) <= maxlength \
+              and (regex is None or r.search(seq.id) is not None) \
+              and (ids_file is None or seq.id in ids_from_file)
+
+        if hit != invert:
+            print(seq, file=f_out)
+    utils.close(f_out)
+
+
+def get_ids(infile, outfile):
+    seq_reader = sequences.file_reader(infile)
+    f_out = utils.open_file_write(outfile)
+    for seq in seq_reader:
+        print(seq.id, file=f_out)
+    utils.close(f_out)
+
+
+def get_seqs_flanking_gaps(infile, outfile, left, right):
+    seq_reader = sequences.file_reader(infile)
+    fout = utils.open_file_write(outfile)
+
+    print('#id', 'gap_start', 'gap_end', 'left_bases', 'right_bases', sep='\t', file=fout)
+
+    for seq in seq_reader:
+        gaps = seq.gaps()
+
+        for gap in gaps:
+            left_start = max(gap.start - left, 0)
+            right_end = min(gap.end + right + 1, len(seq))
+            print(seq.id,
+                  gap.start + 1,
+                  gap.end + 1,
+                  seq.seq[left_start:gap.start],
+                  seq.seq[gap.end + 1:right_end],
+                  sep='\t', file=fout)
+
+    utils.close(fout)
+
+
+def interleave(infile_1, infile_2, outfile):
+    seq_reader_1 = sequences.file_reader(infile_1)
+    seq_reader_2 = sequences.file_reader(infile_2)
+    f_out = utils.open_file_write(outfile)
+
+    for seq_1 in seq_reader_1:
+        try:
+            seq_2 = next(seq_reader_2)
+        except:
+            utils.close(f_out)
+            raise Error('Error getting mate for sequence', seq_1.id, ' ... cannot continue')
+
+        print(seq_1, file=f_out)
+        print(seq_2, file=f_out)
+
+    try:
+        seq_2 = next(seq_reader_2)
+    except:
+        seq_2 = None
+
+    if seq_2 is not None:
+        utils.close(f_out)
+        raise Error('Error getting mate for sequence', seq_2.id, ' ... cannot continue')
+
+    utils.close(f_out)
+
+
+def make_random_contigs(contigs, length, outfile, name_by_letters=False, prefix='', seed=None, first_number=1):
+    '''Makes a multi fasta file of random sequences, all the same length'''
+    random.seed(a=seed)
+    fout = utils.open_file_write(outfile)
+    letters = list('ABCDEFGHIJKLMNOPQRSTUVWXYZ')
+    letters_index = 0
+
+    for i in range(contigs):
+        if name_by_letters:
+            name = letters[letters_index]
+            letters_index += 1
+            if letters_index == len(letters):
+                letters_index = 0
+        else:
+            name = str(i + first_number)
+
+        fa = sequences.Fasta(prefix + name, ''.join([random.choice('ACGT') for x in range(length)]))
+        print(fa, file=fout)
+
+    utils.close(fout)
+
+
+def make_long_reads(infile, outfile, method='tiling', fixed_read_length=20000, tile_step=10000, gamma_shape=1.2,  gamma_scale=6000, coverage=10, gamma_min_length=20000, seed=None, ins_skip=None, ins_window=None,):
+    assert method in ['tiling', 'gamma', 'uniform']
+    assert ins_skip == ins_window == None or None not in [ins_skip, ins_window]
+    if seed is not None:
+        random.seed(a=seed)
+    seq_reader = sequences.file_reader(infile)
+    f = utils.open_file_write(outfile)
+
+    for seq in seq_reader:
+        if method == 'tiling':
+            if len(seq) < fixed_read_length:
+                print('Skipping sequence', seq.id, 'because it is too short at', len(seq), 'bases', file=sys.stderr)
+                continue
+            for i in range(0, len(seq), tile_step):
+                end = min(len(seq), i + fixed_read_length)
+                fa = sequences.Fasta('_'.join([seq.id, str(i + 1), str(end)]), seq[i:end])
+                if ins_skip:
+                    fa.add_insertions(skip=ins_skip, window=ins_window)
+                print(fa, file=f)
+                if end >= len(seq):
+                    break
+        elif method == 'gamma':
+            if len(seq) < gamma_min_length:
+                print('Skipping sequence', seq.id, 'because it is too short at', len(seq), 'bases', file=sys.stderr)
+                continue
+            total_read_length = 0
+            while total_read_length < coverage * len(seq) - 0.5 * gamma_min_length:
+                read_length = int(numpy.random.gamma(gamma_shape, scale=gamma_scale))
+                while read_length < gamma_min_length or read_length > len(seq):
+                    read_length = int(numpy.random.gamma(gamma_shape, scale=gamma_scale))
+
+                start = random.randint(0, len(seq) - read_length)
+                end = start + read_length - 1
+                fa = sequences.Fasta('_'.join([seq.id, str(start + 1), str(end + 1)]), seq[start:end+1])
+                total_read_length += len(fa)
+                if ins_skip:
+                    fa.add_insertions(skip=ins_skip, window=ins_window)
+                print(fa, file=f)
+        elif method == 'uniform':
+            if len(seq) < fixed_read_length:
+                print('Skipping sequence', seq.id, 'because it is too short at', len(seq), 'bases', file=sys.stderr)
+                continue
+            total_read_length = 0
+            while total_read_length < coverage * len(seq) - 0.5 * fixed_read_length:
+                start = random.randint(0, len(seq) - fixed_read_length)
+                end = start + fixed_read_length - 1
+                fa = sequences.Fasta('_'.join([seq.id, str(start + 1), str(end + 1)]), seq[start:end+1])
+                total_read_length += len(fa)
+                if ins_skip:
+                    fa.add_insertions(skip=ins_skip, window=ins_window)
+                print(fa, file=f)
+
+
+    utils.close(f)
+
+
+def merge_to_one_seq(infile, outfile, seqname='union'):
+    '''Takes a multi fasta or fastq file and writes a new file that contains just one sequence, with the original sequences catted together, preserving their order'''
+    seq_reader = sequences.file_reader(infile)
+    seqs = []
+
+    for seq in seq_reader:
+        seqs.append(copy.copy(seq))
+
+    new_seq = ''.join([seq.seq for seq in seqs])
+
+    if type(seqs[0]) == sequences.Fastq:
+        new_qual = ''.join([seq.qual for seq in seqs])
+        seqs[:] = []
+        merged = sequences.Fastq(seqname, new_seq, new_qual)
+    else:
+        merged = sequences.Fasta(seqname, new_seq)
+        seqs[:] = []
+
+    f = utils.open_file_write(outfile)
+    print(merged, file=f)
+    utils.close(f)
+
+
+def reverse_complement(infile, outfile):
+    seq_reader = sequences.file_reader(infile)
+    fout = utils.open_file_write(outfile)
+
+    for seq in seq_reader:
+        seq.revcomp()
+        print(seq, file=fout)
+
+    utils.close(fout)
+
+
+def scaffolds_to_contigs(infile, outfile, number_contigs=False):
+    '''Makes a file of contigs from scaffolds by splitting at every N.
+       Use number_contigs=True to add .1, .2, etc onto end of each
+       contig, instead of default to append coordinates.'''
+    seq_reader = sequences.file_reader(infile)
+    fout = utils.open_file_write(outfile)
+
+    for seq in seq_reader:
+        contigs = seq.contig_coords()
+        counter = 1
+        for contig in contigs:
+            if number_contigs:
+                name = seq.id + '.' + str(counter)
+                counter += 1
+            else:
+                name = '.'.join([seq.id, str(contig.start + 1), str(contig.end + 1)])
+            print(sequences.Fasta(name, seq[contig.start:contig.end+1]), file=fout)
+
+    utils.close(fout)
+
+
+def search_for_seq(infile, outfile, search_string):
+    seq_reader = sequences.file_reader(infile)
+    fout = utils.open_file_write(outfile)
+
+    for seq in seq_reader:
+        hits = seq.search(search_string)
+        for hit in hits:
+            print(seq.id, hit[0]+1, hit[1], sep='\t', file=fout)
+
+    utils.close(fout)
+
+
+def sequence_trim(infile_1, infile_2, outfile_1, outfile_2, to_trim_file, min_length=50):
+    trim_seqs = {}
+    file_to_dict(to_trim_file, trim_seqs)
+    trim_seqs = [x.seq for x in trim_seqs.values()]
+
+    seq_reader_1 = sequences.file_reader(infile_1)
+    seq_reader_2 = sequences.file_reader(infile_2)
+    f_out_1 = utils.open_file_write(outfile_1)
+    f_out_2 = utils.open_file_write(outfile_2)
+
+    for seq_1 in seq_reader_1:
+        try:
+            seq_2 = next(seq_reader_2)
+        except:
+            utils.close(f_out)
+            raise Error('Error getting mate for sequence', seq_1.id, ' ... cannot continue')
+
+        for seq in seq_1, seq_2:
+            for trim_seq in trim_seqs:
+                if seq.seq.startswith(trim_seq):
+                    seq.trim(len(trim_seq),0)
+                    break
+
+        if len(seq_1) >= min_length and len(seq_2) >= min_length:
+            print(seq_1, file=f_out_1)
+            print(seq_2, file=f_out_2)
+
+
+    utils.close(f_out_1)
+    utils.close(f_out_2)
+
+
+
+def translate(infile, outfile, frame=0):
+    seq_reader = sequences.file_reader(infile)
+    fout = utils.open_file_write(outfile)
+
+    for seq in seq_reader:
+        print(seq.translate(frame=frame), file=fout)
+
+    utils.close(fout)
+
+
+def trim(infile, outfile, start, end):
+    seq_reader = sequences.file_reader(infile)
+    fout = utils.open_file_write(outfile)
+
+    for seq in seq_reader:
+        seq.trim(start, end)
+        if len(seq):
+            print(seq, file=fout)
+
+    utils.close(fout)
+
+
+def trim_Ns_at_end(infile, outfile):
+    seq_reader = sequences.file_reader(infile)
+    fout = utils.open_file_write(outfile)
+
+    for seq in seq_reader:
+        seq.trim_Ns()
+        if len(seq):
+            print(seq, file=fout)
+
+    utils.close(fout)
+
+
+def lengths_from_fai(fai_file, d):
+    f = utils.open_file_read(fai_file)
+    for line in f:
+        (id, length) = line.rstrip().split()[:2]
+        d[id] = int(length)
+    utils.close(f)
+
+
+def split_by_base_count(infile, outfiles_prefix, max_bases, max_seqs=None):
+    '''Splits a fasta/q file into separate files, file size determined by number of bases.
+
+    Puts <= max_bases in each split file The exception is a single sequence >=max_bases
+    is put in its own file.  This does not split sequences.
+    '''
+    seq_reader = sequences.file_reader(infile)
+    base_count = 0
+    file_count = 1
+    seq_count = 0
+    fout = None
+    if max_seqs is None:
+        max_seqs = float('inf')
+
+    for seq in seq_reader:
+        if base_count == 0:
+            fout = utils.open_file_write(outfiles_prefix + '.' + str(file_count))
+            file_count += 1
+
+        if base_count + len(seq) > max_bases or seq_count >= max_seqs:
+            if base_count == 0:
+                print(seq, file=fout)
+                utils.close(fout)
+            else:
+                utils.close(fout)
+                fout = utils.open_file_write(outfiles_prefix + '.' + str(file_count))
+                print(seq, file=fout)
+                base_count = len(seq)
+                file_count += 1
+                seq_count = 1
+        else:
+            base_count += len(seq)
+            seq_count += 1
+            print(seq, file=fout)
+
+    utils.close(fout)
+
+
+def split_by_fixed_size(infile, outfiles_prefix, chunk_size, tolerance, skip_if_all_Ns=False):
+    '''Splits  fasta/q file into separate files, with up to (chunk_size + tolerance) bases in each file'''
+    file_count = 1
+    coords = []
+    small_sequences = []  # sequences shorter than chunk_size
+    seq_reader = sequences.file_reader(infile)
+    f_coords = utils.open_file_write(outfiles_prefix + '.coords')
+
+    for seq in seq_reader:
+        if skip_if_all_Ns and seq.is_all_Ns():
+             continue
+        if len(seq) < chunk_size:
+            small_sequences.append(copy.copy(seq))
+        elif len(seq) <= chunk_size + tolerance:
+            f = utils.open_file_write(outfiles_prefix + '.' + str(file_count))
+            print(seq, file=f)
+            utils.close(f)
+            file_count += 1
+        else:
+            # make list of chunk coords
+            chunks = [(x,x+chunk_size) for x in range(0, len(seq), chunk_size)]
+            if chunks[-1][1] - 1 > len(seq):
+                chunks[-1] = (chunks[-1][0], len(seq))
+            if len(chunks) > 1 and (chunks[-1][1] - chunks[-1][0]) <= tolerance:
+                chunks[-2] = (chunks[-2][0], chunks[-1][1])
+                chunks.pop()
+
+            # write one output file per chunk
+            offset = 0
+            for chunk in chunks:
+                if not(skip_if_all_Ns and seq.is_all_Ns(start=chunk[0], end=chunk[1]-1)):
+                    f = utils.open_file_write(outfiles_prefix + '.' + str(file_count))
+                    chunk_id = seq.id + ':' + str(chunk[0]+1) + '-' + str(chunk[1])
+                    print(sequences.Fasta(chunk_id, seq[chunk[0]:chunk[1]]), file=f)
+                    print(chunk_id, seq.id, offset, sep='\t', file=f_coords)
+                    utils.close(f)
+                    file_count += 1
+
+                offset += chunk[1] - chunk[0]
+
+    # write files of small sequences
+    if len(small_sequences):
+        f = utils.open_file_write(outfiles_prefix + '.' + str(file_count))
+        file_count += 1
+        base_count = 0
+        for seq in small_sequences:
+            if base_count > 0 and base_count + len(seq) > chunk_size + tolerance:
+                utils.close(f)
+                f = utils.open_file_write(outfiles_prefix + '.' + str(file_count))
+                file_count += 1
+                base_count = 0
+
+            print(seq, file=f)
+            base_count += len(seq)
+
+        utils.close(f)
+
+
+def replace_bases(infile, outfile, old, new):
+    seq_reader = sequences.file_reader(infile)
+    f_out = utils.open_file_write(outfile)
+
+    for seq in seq_reader:
+        seq.replace_bases(old, new)
+        print(seq, file=f_out)
+
+    utils.close(f_out)
+
+
+def strip_illumina_suffix(infile, outfile):
+    seq_reader = sequences.file_reader(infile)
+    f_out = utils.open_file_write(outfile)
+
+    for seq in seq_reader:
+        seq.strip_illumina_suffix()
+        print(seq, file=f_out)
+
+    utils.close(f_out)
+
+
+def to_fasta(infile, outfile, line_length=60, strip_after_first_whitespace=False):
+    seq_reader = sequences.file_reader(infile)
+    f_out = utils.open_file_write(outfile)
+    original_line_length = sequences.Fasta.line_length
+    sequences.Fasta.line_length = line_length
+
+    for seq in seq_reader:
+        if strip_after_first_whitespace:
+            seq.strip_after_first_whitespace()
+
+        if type(seq) == sequences.Fastq:
+            print(sequences.Fasta(seq.id, seq.seq), file=f_out)
+        else:
+            print(seq, file=f_out)
+
+    utils.close(f_out)
+    sequences.Fasta.line_length = original_line_length
+
+
+def to_quasr_primers(infile, outfile):
+    seq_reader = sequences.file_reader(infile)
+    f_out = utils.open_file_write(outfile)
+
+    for seq in seq_reader:
+        seq2 = copy.copy(seq)
+        seq2.revcomp()
+        print(seq.seq, seq2.seq, sep='\t', file=f_out)
+
+    utils.close(f_out)
+
+
+def to_fasta_union(infile, outfile, seqname='union'):
+    seq_reader = sequences.file_reader(infile)
+    new_seq = []
+
+    for seq in seq_reader:
+        new_seq.append(seq.seq)
+
+    f_out = utils.open_file_write(outfile)
+    print(sequences.Fasta(seqname, ''.join(new_seq)), file=f_out)
+    utils.close(f_out)
+
+
+
+def to_unique_by_id(infile, outfile):
+    seq_reader = sequences.file_reader(infile)
+    seqs = {}
+    ids_in_order = []
+
+    # has the reads, keeping the longest one when we get the same
+    # name more than once
+    for seq in seq_reader:
+        if len(seq) == 0:
+           continue
+        if seq.id not in seqs:
+            seqs[seq.id] = copy.copy(seq)
+            ids_in_order.append(seq.id)
+        elif len(seqs[seq.id]) < len(seq):
+            seqs[seq.id] = copy.copy(seq)
+
+    # write the output
+    f_out = utils.open_file_write(outfile)
+    for id in ids_in_order:
+        print(seqs[id], file=f_out)
+    utils.close(f_out)
diff --git a/fastaq/tests/data/sequences_test.embl b/fastaq/tests/data/sequences_test.embl
new file mode 100644
index 0000000..b40c185
--- /dev/null
+++ b/fastaq/tests/data/sequences_test.embl
@@ -0,0 +1,203 @@
+ID   seq1; SV 1; linear; mRNA; STD; PLN; 1859 BP.
+XX
+AC   X56734; S46826;
+XX
+DT   12-SEP-1991 (Rel. 29, Created)
+DT   25-NOV-2005 (Rel. 85, Last updated, Version 11)
+XX
+DE   Trifolium repens mRNA for non-cyanogenic beta-glucosidase
+XX
+KW   beta-glucosidase.
+XX
+OS   Trifolium repens (white clover)
+OC   Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta;
+OC   Spermatophyta; Magnoliophyta; eudicotyledons; core eudicotyledons; rosids;
+OC   fabids; Fabales; Fabaceae; Papilionoideae; Trifolieae; Trifolium.
+XX
+RN   [5]
+RP   1-1859
+RX   DOI; 10.1007/BF00039495.
+RX   PUBMED; 1907511.
+RA   Oxtoby E., Dunn M.A., Pancoro A., Hughes M.A.;
+RT   "Nucleotide and derived amino acid sequence of the cyanogenic
+RT   beta-glucosidase (linamarase) from white clover (Trifolium repens L.)";
+RL   Plant Mol. Biol. 17(2):209-219(1991).
+XX
+RN   [6]
+RP   1-1859
+RA   Hughes M.A.;
+RT   ;
+RL   Submitted (19-NOV-1990) to the INSDC.
+RL   Hughes M.A., University of Newcastle Upon Tyne, Medical School, Newcastle
+RL   Upon Tyne, NE2 4HH, UK
+XX
+DR   EuropePMC; PMC99098; 11752244.
+XX
+FH   Key             Location/Qualifiers
+FH
+FT   source          1..1859
+FT                   /organism="Trifolium repens"
+FT                   /mol_type="mRNA"
+FT                   /clone_lib="lambda gt10"
+FT                   /clone="TRE361"
+FT                   /tissue_type="leaves"
+FT                   /db_xref="taxon:3899"
+FT   mRNA            1..1859
+FT                   /experiment="experimental evidence, no additional details
+FT                   recorded"
+FT   CDS             14..1495
+FT                   /product="beta-glucosidase"
+FT                   /EC_number="3.2.1.21"
+FT                   /note="non-cyanogenic"
+FT                   /db_xref="GOA:P26204"
+FT                   /db_xref="InterPro:IPR001360"
+FT                   /db_xref="InterPro:IPR013781"
+FT                   /db_xref="InterPro:IPR017853"
+FT                   /db_xref="InterPro:IPR018120"
+FT                   /db_xref="UniProtKB/Swiss-Prot:P26204"
+FT                   /protein_id="CAA40058.1"
+FT                   /translation="MDFIVAIFALFVISSFTITSTNAVEASTLLDIGNLSRSSFPRGFI
+FT                   FGAGSSAYQFEGAVNEGGRGPSIWDTFTHKYPEKIRDGSNADITVDQYHRYKEDVGIMK
+FT                   DQNMDSYRFSISWPRILPKGKLSGGINHEGIKYYNNLINELLANGIQPFVTLFHWDLPQ
+FT                   VLEDEYGGFLNSGVINDFRDYTDLCFKEFGDRVRYWSTLNEPWVFSNSGYALGTNAPGR
+FT                   CSASNVAKPGDSGTGPYIVTHNQILAHAEAVHVYKTKYQAYQKGKIGITLVSNWLMPLD
+FT                   DNSIPDIKAAERSLDFQFGLFMEQLTTGDYSKSMRRIVKNRLPKFSKFESSLVNGSFDF
+FT                   IGINYYSSSYISNAPSHGNAKPSYSTNPMTNISFEKHGIPLGPRAASIWIYVYPYMFIQ
+FT                   EDFEIFCYILKINITILQFSITENGMNEFNDATLPVEEALLNTYRIDYYYRHLYYIRSA
+FT                   IRAGSNVKGFYAWSFLDCNEWFAGFTVRFGLNFVD"
+XX
+SQ   Sequence 1859 BP; 609 A; 314 C; 355 G; 581 T; 0 other;
+     aaacaaacca aatatggatt ttattgtagc catatttgct ctgtttgtta ttagctcatt        60
+     cacaattact tccacaaatg cagttgaagc ttctactctt cttgacatag gtaacctgag       120
+     tcggagcagt tttcctcgtg gcttcatctt tggtgctgga tcttcagcat accaatttga       180
+     aggtgcagta aacgaaggcg gtagaggacc aagtatttgg gataccttca cccataaata       240
+     tccagaaaaa ataagggatg gaagcaatgc agacatcacg gttgaccaat atcaccgcta       300
+     caaggaagat gttgggatta tgaaggatca aaatatggat tcgtatagat tctcaatctc       360
+     ttggccaaga atactcccaa agggaaagtt gagcggaggc ataaatcacg aaggaatcaa       420
+     atattacaac aaccttatca acgaactatt ggctaacggt atacaaccat ttgtaactct       480
+     ttttcattgg gatcttcccc aagtcttaga agatgagtat ggtggtttct taaactccgg       540
+     tgtaataaat gattttcgag actatacgga tctttgcttc aaggaatttg gagatagagt       600
+     gaggtattgg agtactctaa atgagccatg ggtgtttagc aattctggat atgcactagg       660
+     aacaaatgca ccaggtcgat gttcggcctc caacgtggcc aagcctggtg attctggaac       720
+     aggaccttat atagttacac acaatcaaat tcttgctcat gcagaagctg tacatgtgta       780
+     taagactaaa taccaggcat atcaaaaggg aaagataggc ataacgttgg tatctaactg       840
+     gttaatgcca cttgatgata atagcatacc agatataaag gctgccgaga gatcacttga       900
+     cttccaattt ggattgttta tggaacaatt aacaacagga gattattcta agagcatgcg       960
+     gcgtatagtt aaaaaccgat tacctaagtt ctcaaaattc gaatcaagcc tagtgaatgg      1020
+     ttcatttgat tttattggta taaactatta ctcttctagt tatattagca atgccccttc      1080
+     acatggcaat gccaaaccca gttactcaac aaatcctatg accaatattt catttgaaaa      1140
+     acatgggata cccttaggtc caagggctgc ttcaatttgg atatatgttt atccatatat      1200
+     gtttatccaa gaggacttcg agatcttttg ttacatatta aaaataaata taacaatcct      1260
+     gcaattttca atcactgaaa atggtatgaa tgaattcaac gatgcaacac ttccagtaga      1320
+     agaagctctt ttgaatactt acagaattga ttactattac cgtcacttat actacattcg      1380
+     ttctgcaatc agggctggct caaatgtgaa gggtttttac gcatggtcat ttttggactg      1440
+     taatgaatgg tttgcaggct ttactgttcg ttttggatta aactttgtag attagaaaga      1500
+     tggattaaaa aggtacccta agctttctgc ccaatggtac aagaactttc tcaaaagaaa      1560
+     ctagctagta ttattaaaag aactttgtag tagattacag tacatcgttt gaagttgagt      1620
+     tggtgcacct aattaaataa aagaggttac tcttaacata tttttaggcc attcgttgtg      1680
+     aagttgttag gctgttattt ctattatact atgttgtagt aataagtgca ttgttgtacc      1740
+     agaagctatg atcataacta taggttgatc cttcatgtat cagtttgatg ttgagaatac      1800
+     tttgaattaa aagtcttttt ttattttttt aaaaaaaaaa aaaaaaaaaa aaaaaaaaa       1859
+//
+ID   seq2; SV 1; linear; mRNA; STD; PLN; 1859 BP.
+XX
+AC   X56734; S46826;
+XX
+DT   12-SEP-1991 (Rel. 29, Created)
+DT   25-NOV-2005 (Rel. 85, Last updated, Version 11)
+XX
+DE   Trifolium repens mRNA for non-cyanogenic beta-glucosidase
+XX
+KW   beta-glucosidase.
+XX
+OS   Trifolium repens (white clover)
+OC   Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta;
+OC   Spermatophyta; Magnoliophyta; eudicotyledons; core eudicotyledons; rosids;
+OC   fabids; Fabales; Fabaceae; Papilionoideae; Trifolieae; Trifolium.
+XX
+RN   [5]
+RP   1-1859
+RX   DOI; 10.1007/BF00039495.
+RX   PUBMED; 1907511.
+RA   Oxtoby E., Dunn M.A., Pancoro A., Hughes M.A.;
+RT   "Nucleotide and derived amino acid sequence of the cyanogenic
+RT   beta-glucosidase (linamarase) from white clover (Trifolium repens L.)";
+RL   Plant Mol. Biol. 17(2):209-219(1991).
+XX
+RN   [6]
+RP   1-1859
+RA   Hughes M.A.;
+RT   ;
+RL   Submitted (19-NOV-1990) to the INSDC.
+RL   Hughes M.A., University of Newcastle Upon Tyne, Medical School, Newcastle
+RL   Upon Tyne, NE2 4HH, UK
+XX
+DR   EuropePMC; PMC99098; 11752244.
+XX
+FH   Key             Location/Qualifiers
+FH
+FT   source          1..1859
+FT                   /organism="Trifolium repens"
+FT                   /mol_type="mRNA"
+FT                   /clone_lib="lambda gt10"
+FT                   /clone="TRE361"
+FT                   /tissue_type="leaves"
+FT                   /db_xref="taxon:3899"
+FT   mRNA            1..1859
+FT                   /experiment="experimental evidence, no additional details
+FT                   recorded"
+FT   CDS             14..1495
+FT                   /product="beta-glucosidase"
+FT                   /EC_number="3.2.1.21"
+FT                   /note="non-cyanogenic"
+FT                   /db_xref="GOA:P26204"
+FT                   /db_xref="InterPro:IPR001360"
+FT                   /db_xref="InterPro:IPR013781"
+FT                   /db_xref="InterPro:IPR017853"
+FT                   /db_xref="InterPro:IPR018120"
+FT                   /db_xref="UniProtKB/Swiss-Prot:P26204"
+FT                   /protein_id="CAA40058.1"
+FT                   /translation="MDFIVAIFALFVISSFTITSTNAVEASTLLDIGNLSRSSFPRGFI
+FT                   FGAGSSAYQFEGAVNEGGRGPSIWDTFTHKYPEKIRDGSNADITVDQYHRYKEDVGIMK
+FT                   DQNMDSYRFSISWPRILPKGKLSGGINHEGIKYYNNLINELLANGIQPFVTLFHWDLPQ
+FT                   VLEDEYGGFLNSGVINDFRDYTDLCFKEFGDRVRYWSTLNEPWVFSNSGYALGTNAPGR
+FT                   CSASNVAKPGDSGTGPYIVTHNQILAHAEAVHVYKTKYQAYQKGKIGITLVSNWLMPLD
+FT                   DNSIPDIKAAERSLDFQFGLFMEQLTTGDYSKSMRRIVKNRLPKFSKFESSLVNGSFDF
+FT                   IGINYYSSSYISNAPSHGNAKPSYSTNPMTNISFEKHGIPLGPRAASIWIYVYPYMFIQ
+FT                   EDFEIFCYILKINITILQFSITENGMNEFNDATLPVEEALLNTYRIDYYYRHLYYIRSA
+FT                   IRAGSNVKGFYAWSFLDCNEWFAGFTVRFGLNFVD"
+XX
+SQ   Sequence 1859 BP; 609 A; 314 C; 355 G; 581 T; 0 other;
+     aaacaaacca aatatggatt ttattgtagc catatttgct ctgtttgtta ttagctcatt        60
+     cacaattact tccacaaatg cagttgaagc ttctactctt cttgacatag gtaacctgag       120
+     tcggagcagt tttcctcgtg gcttcatctt tggtgctgga tcttcagcat accaatttga       180
+     aggtgcagta aacgaaggcg gtagaggacc aagtatttgg gataccttca cccataaata       240
+     tccagaaaaa ataagggatg gaagcaatgc agacatcacg gttgaccaat atcaccgcta       300
+     caaggaagat gttgggatta tgaaggatca aaatatggat tcgtatagat tctcaatctc       360
+     ttggccaaga atactcccaa agggaaagtt gagcggaggc ataaatcacg aaggaatcaa       420
+     atattacaac aaccttatca acgaactatt ggctaacggt atacaaccat ttgtaactct       480
+     ttttcattgg gatcttcccc aagtcttaga agatgagtat ggtggtttct taaactccgg       540
+     tgtaataaat gattttcgag actatacgga tctttgcttc aaggaatttg gagatagagt       600
+     gaggtattgg agtactctaa atgagccatg ggtgtttagc aattctggat atgcactagg       660
+     aacaaatgca ccaggtcgat gttcggcctc caacgtggcc aagcctggtg attctggaac       720
+     aggaccttat atagttacac acaatcaaat tcttgctcat gcagaagctg tacatgtgta       780
+     taagactaaa taccaggcat atcaaaaggg aaagataggc ataacgttgg tatctaactg       840
+     gttaatgcca cttgatgata atagcatacc agatataaag gctgccgaga gatcacttga       900
+     cttccaattt ggattgttta tggaacaatt aacaacagga gattattcta agagcatgcg       960
+     gcgtatagtt aaaaaccgat tacctaagtt ctcaaaattc gaatcaagcc tagtgaatgg      1020
+     ttcatttgat tttattggta taaactatta ctcttctagt tatattagca atgccccttc      1080
+     acatggcaat gccaaaccca gttactcaac aaatcctatg accaatattt catttgaaaa      1140
+     acatgggata cccttaggtc caagggctgc ttcaatttgg atatatgttt atccatatat      1200
+     gtttatccaa gaggacttcg agatcttttg ttacatatta aaaataaata taacaatcct      1260
+     gcaattttca atcactgaaa atggtatgaa tgaattcaac gatgcaacac ttccagtaga      1320
+     agaagctctt ttgaatactt acagaattga ttactattac cgtcacttat actacattcg      1380
+     ttctgcaatc agggctggct caaatgtgaa gggtttttac gcatggtcat ttttggactg      1440
+     taatgaatgg tttgcaggct ttactgttcg ttttggatta aactttgtag attagaaaga      1500
+     tggattaaaa aggtacccta agctttctgc ccaatggtac aagaactttc tcaaaagaaa      1560
+     ctagctagta ttattaaaag aactttgtag tagattacag tacatcgttt gaagttgagt      1620
+     tggtgcacct aattaaataa aagaggttac tcttaacata tttttaggcc attcgttgtg      1680
+     aagttgttag gctgttattt ctattatact atgttgtagt aataagtgca ttgttgtacc      1740
+     agaagctatg atcataacta taggttgatc cttcatgtat cagtttgatg ttgagaatac      1800
+     tttgaattaa aagtcttttt ttattttttt aaaaaaaaaa aaaaaaaaaa ccccccccc       1859
+//
+
diff --git a/fastaq/tests/data/sequences_test.embl.bad b/fastaq/tests/data/sequences_test.embl.bad
new file mode 100644
index 0000000..10ca1ab
--- /dev/null
+++ b/fastaq/tests/data/sequences_test.embl.bad
@@ -0,0 +1,202 @@
+ID   seq1; SV 1; linear; mRNA; STD; PLN; 1859 BP.
+XX
+AC   X56734; S46826;
+XX
+DT   12-SEP-1991 (Rel. 29, Created)
+DT   25-NOV-2005 (Rel. 85, Last updated, Version 11)
+XX
+DE   Trifolium repens mRNA for non-cyanogenic beta-glucosidase
+XX
+KW   beta-glucosidase.
+XX
+OS   Trifolium repens (white clover)
+OC   Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta;
+OC   Spermatophyta; Magnoliophyta; eudicotyledons; core eudicotyledons; rosids;
+OC   fabids; Fabales; Fabaceae; Papilionoideae; Trifolieae; Trifolium.
+XX
+RN   [5]
+RP   1-1859
+RX   DOI; 10.1007/BF00039495.
+RX   PUBMED; 1907511.
+RA   Oxtoby E., Dunn M.A., Pancoro A., Hughes M.A.;
+RT   "Nucleotide and derived amino acid sequence of the cyanogenic
+RT   beta-glucosidase (linamarase) from white clover (Trifolium repens L.)";
+RL   Plant Mol. Biol. 17(2):209-219(1991).
+XX
+RN   [6]
+RP   1-1859
+RA   Hughes M.A.;
+RT   ;
+RL   Submitted (19-NOV-1990) to the INSDC.
+RL   Hughes M.A., University of Newcastle Upon Tyne, Medical School, Newcastle
+RL   Upon Tyne, NE2 4HH, UK
+XX
+DR   EuropePMC; PMC99098; 11752244.
+XX
+FH   Key             Location/Qualifiers
+FH
+FT   source          1..1859
+FT                   /organism="Trifolium repens"
+FT                   /mol_type="mRNA"
+FT                   /clone_lib="lambda gt10"
+FT                   /clone="TRE361"
+FT                   /tissue_type="leaves"
+FT                   /db_xref="taxon:3899"
+FT   mRNA            1..1859
+FT                   /experiment="experimental evidence, no additional details
+FT                   recorded"
+FT   CDS             14..1495
+FT                   /product="beta-glucosidase"
+FT                   /EC_number="3.2.1.21"
+FT                   /note="non-cyanogenic"
+FT                   /db_xref="GOA:P26204"
+FT                   /db_xref="InterPro:IPR001360"
+FT                   /db_xref="InterPro:IPR013781"
+FT                   /db_xref="InterPro:IPR017853"
+FT                   /db_xref="InterPro:IPR018120"
+FT                   /db_xref="UniProtKB/Swiss-Prot:P26204"
+FT                   /protein_id="CAA40058.1"
+FT                   /translation="MDFIVAIFALFVISSFTITSTNAVEASTLLDIGNLSRSSFPRGFI
+FT                   FGAGSSAYQFEGAVNEGGRGPSIWDTFTHKYPEKIRDGSNADITVDQYHRYKEDVGIMK
+FT                   DQNMDSYRFSISWPRILPKGKLSGGINHEGIKYYNNLINELLANGIQPFVTLFHWDLPQ
+FT                   VLEDEYGGFLNSGVINDFRDYTDLCFKEFGDRVRYWSTLNEPWVFSNSGYALGTNAPGR
+FT                   CSASNVAKPGDSGTGPYIVTHNQILAHAEAVHVYKTKYQAYQKGKIGITLVSNWLMPLD
+FT                   DNSIPDIKAAERSLDFQFGLFMEQLTTGDYSKSMRRIVKNRLPKFSKFESSLVNGSFDF
+FT                   IGINYYSSSYISNAPSHGNAKPSYSTNPMTNISFEKHGIPLGPRAASIWIYVYPYMFIQ
+FT                   EDFEIFCYILKINITILQFSITENGMNEFNDATLPVEEALLNTYRIDYYYRHLYYIRSA
+FT                   IRAGSNVKGFYAWSFLDCNEWFAGFTVRFGLNFVD"
+XX
+SQ   Sequence 1859 BP; 609 A; 314 C; 355 G; 581 T; 0 other;
+     aaacaaacca aatatggatt ttattgtagc catatttgct ctgtttgtta ttagctcatt        60
+     cacaattact tccacaaatg cagttgaagc ttctactctt cttgacatag gtaacctgag       120
+     tcggagcagt tttcctcgtg gcttcatctt tggtgctgga tcttcagcat accaatttga       180
+     aggtgcagta aacgaaggcg gtagaggacc aagtatttgg gataccttca cccataaata       240
+     tccagaaaaa ataagggatg gaagcaatgc agacatcacg gttgaccaat atcaccgcta       300
+     caaggaagat gttgggatta tgaaggatca aaatatggat tcgtatagat tctcaatctc       360
+     ttggccaaga atactcccaa agggaaagtt gagcggaggc ataaatcacg aaggaatcaa       420
+     atattacaac aaccttatca acgaactatt ggctaacggt atacaaccat ttgtaactct       480
+     ttttcattgg gatcttcccc aagtcttaga agatgagtat ggtggtttct taaactccgg       540
+     tgtaataaat gattttcgag actatacgga tctttgcttc aaggaatttg gagatagagt       600
+     gaggtattgg agtactctaa atgagccatg ggtgtttagc aattctggat atgcactagg       660
+     aacaaatgca ccaggtcgat gttcggcctc caacgtggcc aagcctggtg attctggaac       720
+     aggaccttat atagttacac acaatcaaat tcttgctcat gcagaagctg tacatgtgta       780
+     taagactaaa taccaggcat atcaaaaggg aaagataggc ataacgttgg tatctaactg       840
+     gttaatgcca cttgatgata atagcatacc agatataaag gctgccgaga gatcacttga       900
+     cttccaattt ggattgttta tggaacaatt aacaacagga gattattcta agagcatgcg       960
+     gcgtatagtt aaaaaccgat tacctaagtt ctcaaaattc gaatcaagcc tagtgaatgg      1020
+     ttcatttgat tttattggta taaactatta ctcttctagt tatattagca atgccccttc      1080
+     acatggcaat gccaaaccca gttactcaac aaatcctatg accaatattt catttgaaaa      1140
+     acatgggata cccttaggtc caagggctgc ttcaatttgg atatatgttt atccatatat      1200
+     gtttatccaa gaggacttcg agatcttttg ttacatatta aaaataaata taacaatcct      1260
+     gcaattttca atcactgaaa atggtatgaa tgaattcaac gatgcaacac ttccagtaga      1320
+     agaagctctt ttgaatactt acagaattga ttactattac cgtcacttat actacattcg      1380
+     ttctgcaatc agggctggct caaatgtgaa gggtttttac gcatggtcat ttttggactg      1440
+     taatgaatgg tttgcaggct ttactgttcg ttttggatta aactttgtag attagaaaga      1500
+     tggattaaaa aggtacccta agctttctgc ccaatggtac aagaactttc tcaaaagaaa      1560
+     ctagctagta ttattaaaag aactttgtag tagattacag tacatcgttt gaagttgagt      1620
+     tggtgcacct aattaaataa aagaggttac tcttaacata tttttaggcc attcgttgtg      1680
+     aagttgttag gctgttattt ctattatact atgttgtagt aataagtgca ttgttgtacc      1740
+     agaagctatg atcataacta taggttgatc cttcatgtat cagtttgatg ttgagaatac      1800
+     tttgaattaa aagtcttttt ttattttttt aaaaaaaaaa aaaaaaaaaa aaaaaaaaa       1859
+//
+ID   seq2; SV 1; linear; mRNA; STD; PLN; 1859 BP.
+XX
+AC   X56734; S46826;
+XX
+DT   12-SEP-1991 (Rel. 29, Created)
+DT   25-NOV-2005 (Rel. 85, Last updated, Version 11)
+XX
+DE   Trifolium repens mRNA for non-cyanogenic beta-glucosidase
+XX
+KW   beta-glucosidase.
+XX
+OS   Trifolium repens (white clover)
+OC   Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta;
+OC   Spermatophyta; Magnoliophyta; eudicotyledons; core eudicotyledons; rosids;
+OC   fabids; Fabales; Fabaceae; Papilionoideae; Trifolieae; Trifolium.
+XX
+RN   [5]
+RP   1-1859
+RX   DOI; 10.1007/BF00039495.
+RX   PUBMED; 1907511.
+RA   Oxtoby E., Dunn M.A., Pancoro A., Hughes M.A.;
+RT   "Nucleotide and derived amino acid sequence of the cyanogenic
+RT   beta-glucosidase (linamarase) from white clover (Trifolium repens L.)";
+RL   Plant Mol. Biol. 17(2):209-219(1991).
+XX
+RN   [6]
+RP   1-1859
+RA   Hughes M.A.;
+RT   ;
+RL   Submitted (19-NOV-1990) to the INSDC.
+RL   Hughes M.A., University of Newcastle Upon Tyne, Medical School, Newcastle
+RL   Upon Tyne, NE2 4HH, UK
+XX
+DR   EuropePMC; PMC99098; 11752244.
+XX
+FH   Key             Location/Qualifiers
+FH
+FT   source          1..1859
+FT                   /organism="Trifolium repens"
+FT                   /mol_type="mRNA"
+FT                   /clone_lib="lambda gt10"
+FT                   /clone="TRE361"
+FT                   /tissue_type="leaves"
+FT                   /db_xref="taxon:3899"
+FT   mRNA            1..1859
+FT                   /experiment="experimental evidence, no additional details
+FT                   recorded"
+FT   CDS             14..1495
+FT                   /product="beta-glucosidase"
+FT                   /EC_number="3.2.1.21"
+FT                   /note="non-cyanogenic"
+FT                   /db_xref="GOA:P26204"
+FT                   /db_xref="InterPro:IPR001360"
+FT                   /db_xref="InterPro:IPR013781"
+FT                   /db_xref="InterPro:IPR017853"
+FT                   /db_xref="InterPro:IPR018120"
+FT                   /db_xref="UniProtKB/Swiss-Prot:P26204"
+FT                   /protein_id="CAA40058.1"
+FT                   /translation="MDFIVAIFALFVISSFTITSTNAVEASTLLDIGNLSRSSFPRGFI
+FT                   FGAGSSAYQFEGAVNEGGRGPSIWDTFTHKYPEKIRDGSNADITVDQYHRYKEDVGIMK
+FT                   DQNMDSYRFSISWPRILPKGKLSGGINHEGIKYYNNLINELLANGIQPFVTLFHWDLPQ
+FT                   VLEDEYGGFLNSGVINDFRDYTDLCFKEFGDRVRYWSTLNEPWVFSNSGYALGTNAPGR
+FT                   CSASNVAKPGDSGTGPYIVTHNQILAHAEAVHVYKTKYQAYQKGKIGITLVSNWLMPLD
+FT                   DNSIPDIKAAERSLDFQFGLFMEQLTTGDYSKSMRRIVKNRLPKFSKFESSLVNGSFDF
+FT                   IGINYYSSSYISNAPSHGNAKPSYSTNPMTNISFEKHGIPLGPRAASIWIYVYPYMFIQ
+FT                   EDFEIFCYILKINITILQFSITENGMNEFNDATLPVEEALLNTYRIDYYYRHLYYIRSA
+FT                   IRAGSNVKGFYAWSFLDCNEWFAGFTVRFGLNFVD"
+XX
+     aaacaaacca aatatggatt ttattgtagc catatttgct ctgtttgtta ttagctcatt        60
+     cacaattact tccacaaatg cagttgaagc ttctactctt cttgacatag gtaacctgag       120
+     tcggagcagt tttcctcgtg gcttcatctt tggtgctgga tcttcagcat accaatttga       180
+     aggtgcagta aacgaaggcg gtagaggacc aagtatttgg gataccttca cccataaata       240
+     tccagaaaaa ataagggatg gaagcaatgc agacatcacg gttgaccaat atcaccgcta       300
+     caaggaagat gttgggatta tgaaggatca aaatatggat tcgtatagat tctcaatctc       360
+     ttggccaaga atactcccaa agggaaagtt gagcggaggc ataaatcacg aaggaatcaa       420
+     atattacaac aaccttatca acgaactatt ggctaacggt atacaaccat ttgtaactct       480
+     ttttcattgg gatcttcccc aagtcttaga agatgagtat ggtggtttct taaactccgg       540
+     tgtaataaat gattttcgag actatacgga tctttgcttc aaggaatttg gagatagagt       600
+     gaggtattgg agtactctaa atgagccatg ggtgtttagc aattctggat atgcactagg       660
+     aacaaatgca ccaggtcgat gttcggcctc caacgtggcc aagcctggtg attctggaac       720
+     aggaccttat atagttacac acaatcaaat tcttgctcat gcagaagctg tacatgtgta       780
+     taagactaaa taccaggcat atcaaaaggg aaagataggc ataacgttgg tatctaactg       840
+     gttaatgcca cttgatgata atagcatacc agatataaag gctgccgaga gatcacttga       900
+     cttccaattt ggattgttta tggaacaatt aacaacagga gattattcta agagcatgcg       960
+     gcgtatagtt aaaaaccgat tacctaagtt ctcaaaattc gaatcaagcc tagtgaatgg      1020
+     ttcatttgat tttattggta taaactatta ctcttctagt tatattagca atgccccttc      1080
+     acatggcaat gccaaaccca gttactcaac aaatcctatg accaatattt catttgaaaa      1140
+     acatgggata cccttaggtc caagggctgc ttcaatttgg atatatgttt atccatatat      1200
+     gtttatccaa gaggacttcg agatcttttg ttacatatta aaaataaata taacaatcct      1260
+     gcaattttca atcactgaaa atggtatgaa tgaattcaac gatgcaacac ttccagtaga      1320
+     agaagctctt ttgaatactt acagaattga ttactattac cgtcacttat actacattcg      1380
+     ttctgcaatc agggctggct caaatgtgaa gggtttttac gcatggtcat ttttggactg      1440
+     taatgaatgg tttgcaggct ttactgttcg ttttggatta aactttgtag attagaaaga      1500
+     tggattaaaa aggtacccta agctttctgc ccaatggtac aagaactttc tcaaaagaaa      1560
+     ctagctagta ttattaaaag aactttgtag tagattacag tacatcgttt gaagttgagt      1620
+     tggtgcacct aattaaataa aagaggttac tcttaacata tttttaggcc attcgttgtg      1680
+     aagttgttag gctgttattt ctattatact atgttgtagt aataagtgca ttgttgtacc      1740
+     agaagctatg atcataacta taggttgatc cttcatgtat cagtttgatg ttgagaatac      1800
+     tttgaattaa aagtcttttt ttattttttt aaaaaaaaaa aaaaaaaaaa ccccccccc       1859
+//
+
diff --git a/fastaq/tests/data/sequences_test.embl.bad2 b/fastaq/tests/data/sequences_test.embl.bad2
new file mode 100644
index 0000000..1dd59b1
--- /dev/null
+++ b/fastaq/tests/data/sequences_test.embl.bad2
@@ -0,0 +1,202 @@
+ID   seq1; SV 1; linear; mRNA; STD; PLN; 1859 BP.
+XX
+AC   X56734; S46826;
+XX
+DT   12-SEP-1991 (Rel. 29, Created)
+DT   25-NOV-2005 (Rel. 85, Last updated, Version 11)
+XX
+DE   Trifolium repens mRNA for non-cyanogenic beta-glucosidase
+XX
+KW   beta-glucosidase.
+XX
+OS   Trifolium repens (white clover)
+OC   Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta;
+OC   Spermatophyta; Magnoliophyta; eudicotyledons; core eudicotyledons; rosids;
+OC   fabids; Fabales; Fabaceae; Papilionoideae; Trifolieae; Trifolium.
+XX
+RN   [5]
+RP   1-1859
+RX   DOI; 10.1007/BF00039495.
+RX   PUBMED; 1907511.
+RA   Oxtoby E., Dunn M.A., Pancoro A., Hughes M.A.;
+RT   "Nucleotide and derived amino acid sequence of the cyanogenic
+RT   beta-glucosidase (linamarase) from white clover (Trifolium repens L.)";
+RL   Plant Mol. Biol. 17(2):209-219(1991).
+XX
+RN   [6]
+RP   1-1859
+RA   Hughes M.A.;
+RT   ;
+RL   Submitted (19-NOV-1990) to the INSDC.
+RL   Hughes M.A., University of Newcastle Upon Tyne, Medical School, Newcastle
+RL   Upon Tyne, NE2 4HH, UK
+XX
+DR   EuropePMC; PMC99098; 11752244.
+XX
+FH   Key             Location/Qualifiers
+FH
+FT   source          1..1859
+FT                   /organism="Trifolium repens"
+FT                   /mol_type="mRNA"
+FT                   /clone_lib="lambda gt10"
+FT                   /clone="TRE361"
+FT                   /tissue_type="leaves"
+FT                   /db_xref="taxon:3899"
+FT   mRNA            1..1859
+FT                   /experiment="experimental evidence, no additional details
+FT                   recorded"
+FT   CDS             14..1495
+FT                   /product="beta-glucosidase"
+FT                   /EC_number="3.2.1.21"
+FT                   /note="non-cyanogenic"
+FT                   /db_xref="GOA:P26204"
+FT                   /db_xref="InterPro:IPR001360"
+FT                   /db_xref="InterPro:IPR013781"
+FT                   /db_xref="InterPro:IPR017853"
+FT                   /db_xref="InterPro:IPR018120"
+FT                   /db_xref="UniProtKB/Swiss-Prot:P26204"
+FT                   /protein_id="CAA40058.1"
+FT                   /translation="MDFIVAIFALFVISSFTITSTNAVEASTLLDIGNLSRSSFPRGFI
+FT                   FGAGSSAYQFEGAVNEGGRGPSIWDTFTHKYPEKIRDGSNADITVDQYHRYKEDVGIMK
+FT                   DQNMDSYRFSISWPRILPKGKLSGGINHEGIKYYNNLINELLANGIQPFVTLFHWDLPQ
+FT                   VLEDEYGGFLNSGVINDFRDYTDLCFKEFGDRVRYWSTLNEPWVFSNSGYALGTNAPGR
+FT                   CSASNVAKPGDSGTGPYIVTHNQILAHAEAVHVYKTKYQAYQKGKIGITLVSNWLMPLD
+FT                   DNSIPDIKAAERSLDFQFGLFMEQLTTGDYSKSMRRIVKNRLPKFSKFESSLVNGSFDF
+FT                   IGINYYSSSYISNAPSHGNAKPSYSTNPMTNISFEKHGIPLGPRAASIWIYVYPYMFIQ
+FT                   EDFEIFCYILKINITILQFSITENGMNEFNDATLPVEEALLNTYRIDYYYRHLYYIRSA
+FT                   IRAGSNVKGFYAWSFLDCNEWFAGFTVRFGLNFVD"
+XX
+SQ   Sequence 1859 BP; 609 A; 314 C; 355 G; 581 T; 0 other;
+     aaacaaacca aatatggatt ttattgtagc catatttgct ctgtttgtta ttagctcatt        60
+     cacaattact tccacaaatg cagttgaagc ttctactctt cttgacatag gtaacctgag       120
+     tcggagcagt tttcctcgtg gcttcatctt tggtgctgga tcttcagcat accaatttga       180
+     aggtgcagta aacgaaggcg gtagaggacc aagtatttgg gataccttca cccataaata       240
+     tccagaaaaa ataagggatg gaagcaatgc agacatcacg gttgaccaat atcaccgcta       300
+     caaggaagat gttgggatta tgaaggatca aaatatggat tcgtatagat tctcaatctc       360
+     ttggccaaga atactcccaa agggaaagtt gagcggaggc ataaatcacg aaggaatcaa       420
+     atattacaac aaccttatca acgaactatt ggctaacggt atacaaccat ttgtaactct       480
+     ttttcattgg gatcttcccc aagtcttaga agatgagtat ggtggtttct taaactccgg       540
+     tgtaataaat gattttcgag actatacgga tctttgcttc aaggaatttg gagatagagt       600
+     gaggtattgg agtactctaa atgagccatg ggtgtttagc aattctggat atgcactagg       660
+     aacaaatgca ccaggtcgat gttcggcctc caacgtggcc aagcctggtg attctggaac       720
+     aggaccttat atagttacac acaatcaaat tcttgctcat gcagaagctg tacatgtgta       780
+     taagactaaa taccaggcat atcaaaaggg aaagataggc ataacgttgg tatctaactg       840
+     gttaatgcca cttgatgata atagcatacc agatataaag gctgccgaga gatcacttga       900
+     cttccaattt ggattgttta tggaacaatt aacaacagga gattattcta agagcatgcg       960
+     gcgtatagtt aaaaaccgat tacctaagtt ctcaaaattc gaatcaagcc tagtgaatgg      1020
+     ttcatttgat tttattggta taaactatta ctcttctagt tatattagca atgccccttc      1080
+     acatggcaat gccaaaccca gttactcaac aaatcctatg accaatattt catttgaaaa      1140
+     acatgggata cccttaggtc caagggctgc ttcaatttgg atatatgttt atccatatat      1200
+     gtttatccaa gaggacttcg agatcttttg ttacatatta aaaataaata taacaatcct      1260
+     gcaattttca atcactgaaa atggtatgaa tgaattcaac gatgcaacac ttccagtaga      1320
+     agaagctctt ttgaatactt acagaattga ttactattac cgtcacttat actacattcg      1380
+     ttctgcaatc agggctggct caaatgtgaa gggtttttac gcatggtcat ttttggactg      1440
+     taatgaatgg tttgcaggct ttactgttcg ttttggatta aactttgtag attagaaaga      1500
+     tggattaaaa aggtacccta agctttctgc ccaatggtac aagaactttc tcaaaagaaa      1560
+     ctagctagta ttattaaaag aactttgtag tagattacag tacatcgttt gaagttgagt      1620
+     tggtgcacct aattaaataa aagaggttac tcttaacata tttttaggcc attcgttgtg      1680
+     aagttgttag gctgttattt ctattatact atgttgtagt aataagtgca ttgttgtacc      1740
+     agaagctatg atcataacta taggttgatc cttcatgtat cagtttgatg ttgagaatac      1800
+     tttgaattaa aagtcttttt ttattttttt aaaaaaaaaa aaaaaaaaaa aaaaaaaaa       1859
+ID   seq2; SV 1; linear; mRNA; STD; PLN; 1859 BP.
+XX
+AC   X56734; S46826;
+XX
+DT   12-SEP-1991 (Rel. 29, Created)
+DT   25-NOV-2005 (Rel. 85, Last updated, Version 11)
+XX
+DE   Trifolium repens mRNA for non-cyanogenic beta-glucosidase
+XX
+KW   beta-glucosidase.
+XX
+OS   Trifolium repens (white clover)
+OC   Eukaryota; Viridiplantae; Streptophyta; Embryophyta; Tracheophyta;
+OC   Spermatophyta; Magnoliophyta; eudicotyledons; core eudicotyledons; rosids;
+OC   fabids; Fabales; Fabaceae; Papilionoideae; Trifolieae; Trifolium.
+XX
+RN   [5]
+RP   1-1859
+RX   DOI; 10.1007/BF00039495.
+RX   PUBMED; 1907511.
+RA   Oxtoby E., Dunn M.A., Pancoro A., Hughes M.A.;
+RT   "Nucleotide and derived amino acid sequence of the cyanogenic
+RT   beta-glucosidase (linamarase) from white clover (Trifolium repens L.)";
+RL   Plant Mol. Biol. 17(2):209-219(1991).
+XX
+RN   [6]
+RP   1-1859
+RA   Hughes M.A.;
+RT   ;
+RL   Submitted (19-NOV-1990) to the INSDC.
+RL   Hughes M.A., University of Newcastle Upon Tyne, Medical School, Newcastle
+RL   Upon Tyne, NE2 4HH, UK
+XX
+DR   EuropePMC; PMC99098; 11752244.
+XX
+FH   Key             Location/Qualifiers
+FH
+FT   source          1..1859
+FT                   /organism="Trifolium repens"
+FT                   /mol_type="mRNA"
+FT                   /clone_lib="lambda gt10"
+FT                   /clone="TRE361"
+FT                   /tissue_type="leaves"
+FT                   /db_xref="taxon:3899"
+FT   mRNA            1..1859
+FT                   /experiment="experimental evidence, no additional details
+FT                   recorded"
+FT   CDS             14..1495
+FT                   /product="beta-glucosidase"
+FT                   /EC_number="3.2.1.21"
+FT                   /note="non-cyanogenic"
+FT                   /db_xref="GOA:P26204"
+FT                   /db_xref="InterPro:IPR001360"
+FT                   /db_xref="InterPro:IPR013781"
+FT                   /db_xref="InterPro:IPR017853"
+FT                   /db_xref="InterPro:IPR018120"
+FT                   /db_xref="UniProtKB/Swiss-Prot:P26204"
+FT                   /protein_id="CAA40058.1"
+FT                   /translation="MDFIVAIFALFVISSFTITSTNAVEASTLLDIGNLSRSSFPRGFI
+FT                   FGAGSSAYQFEGAVNEGGRGPSIWDTFTHKYPEKIRDGSNADITVDQYHRYKEDVGIMK
+FT                   DQNMDSYRFSISWPRILPKGKLSGGINHEGIKYYNNLINELLANGIQPFVTLFHWDLPQ
+FT                   VLEDEYGGFLNSGVINDFRDYTDLCFKEFGDRVRYWSTLNEPWVFSNSGYALGTNAPGR
+FT                   CSASNVAKPGDSGTGPYIVTHNQILAHAEAVHVYKTKYQAYQKGKIGITLVSNWLMPLD
+FT                   DNSIPDIKAAERSLDFQFGLFMEQLTTGDYSKSMRRIVKNRLPKFSKFESSLVNGSFDF
+FT                   IGINYYSSSYISNAPSHGNAKPSYSTNPMTNISFEKHGIPLGPRAASIWIYVYPYMFIQ
+FT                   EDFEIFCYILKINITILQFSITENGMNEFNDATLPVEEALLNTYRIDYYYRHLYYIRSA
+FT                   IRAGSNVKGFYAWSFLDCNEWFAGFTVRFGLNFVD"
+XX
+SQ   Sequence 1859 BP; 609 A; 314 C; 355 G; 581 T; 0 other;
+     aaacaaacca aatatggatt ttattgtagc catatttgct ctgtttgtta ttagctcatt        60
+     cacaattact tccacaaatg cagttgaagc ttctactctt cttgacatag gtaacctgag       120
+     tcggagcagt tttcctcgtg gcttcatctt tggtgctgga tcttcagcat accaatttga       180
+     aggtgcagta aacgaaggcg gtagaggacc aagtatttgg gataccttca cccataaata       240
+     tccagaaaaa ataagggatg gaagcaatgc agacatcacg gttgaccaat atcaccgcta       300
+     caaggaagat gttgggatta tgaaggatca aaatatggat tcgtatagat tctcaatctc       360
+     ttggccaaga atactcccaa agggaaagtt gagcggaggc ataaatcacg aaggaatcaa       420
+     atattacaac aaccttatca acgaactatt ggctaacggt atacaaccat ttgtaactct       480
+     ttttcattgg gatcttcccc aagtcttaga agatgagtat ggtggtttct taaactccgg       540
+     tgtaataaat gattttcgag actatacgga tctttgcttc aaggaatttg gagatagagt       600
+     gaggtattgg agtactctaa atgagccatg ggtgtttagc aattctggat atgcactagg       660
+     aacaaatgca ccaggtcgat gttcggcctc caacgtggcc aagcctggtg attctggaac       720
+     aggaccttat atagttacac acaatcaaat tcttgctcat gcagaagctg tacatgtgta       780
+     taagactaaa taccaggcat atcaaaaggg aaagataggc ataacgttgg tatctaactg       840
+     gttaatgcca cttgatgata atagcatacc agatataaag gctgccgaga gatcacttga       900
+     cttccaattt ggattgttta tggaacaatt aacaacagga gattattcta agagcatgcg       960
+     gcgtatagtt aaaaaccgat tacctaagtt ctcaaaattc gaatcaagcc tagtgaatgg      1020
+     ttcatttgat tttattggta taaactatta ctcttctagt tatattagca atgccccttc      1080
+     acatggcaat gccaaaccca gttactcaac aaatcctatg accaatattt catttgaaaa      1140
+     acatgggata cccttaggtc caagggctgc ttcaatttgg atatatgttt atccatatat      1200
+     gtttatccaa gaggacttcg agatcttttg ttacatatta aaaataaata taacaatcct      1260
+     gcaattttca atcactgaaa atggtatgaa tgaattcaac gatgcaacac ttccagtaga      1320
+     agaagctctt ttgaatactt acagaattga ttactattac cgtcacttat actacattcg      1380
+     ttctgcaatc agggctggct caaatgtgaa gggtttttac gcatggtcat ttttggactg      1440
+     taatgaatgg tttgcaggct ttactgttcg ttttggatta aactttgtag attagaaaga      1500
+     tggattaaaa aggtacccta agctttctgc ccaatggtac aagaactttc tcaaaagaaa      1560
+     ctagctagta ttattaaaag aactttgtag tagattacag tacatcgttt gaagttgagt      1620
+     tggtgcacct aattaaataa aagaggttac tcttaacata tttttaggcc attcgttgtg      1680
+     aagttgttag gctgttattt ctattatact atgttgtagt aataagtgca ttgttgtacc      1740
+     agaagctatg atcataacta taggttgatc cttcatgtat cagtttgatg ttgagaatac      1800
+     tttgaattaa aagtcttttt ttattttttt aaaaaaaaaa aaaaaaaaaa ccccccccc       1859
+//
+
diff --git a/fastaq/tests/data/sequences_test.embl.to_fasta b/fastaq/tests/data/sequences_test.embl.to_fasta
new file mode 100644
index 0000000..89e2230
--- /dev/null
+++ b/fastaq/tests/data/sequences_test.embl.to_fasta
@@ -0,0 +1,64 @@
+>seq1
+aaacaaaccaaatatggattttattgtagccatatttgctctgtttgttattagctcatt
+cacaattacttccacaaatgcagttgaagcttctactcttcttgacataggtaacctgag
+tcggagcagttttcctcgtggcttcatctttggtgctggatcttcagcataccaatttga
+aggtgcagtaaacgaaggcggtagaggaccaagtatttgggataccttcacccataaata
+tccagaaaaaataagggatggaagcaatgcagacatcacggttgaccaatatcaccgcta
+caaggaagatgttgggattatgaaggatcaaaatatggattcgtatagattctcaatctc
+ttggccaagaatactcccaaagggaaagttgagcggaggcataaatcacgaaggaatcaa
+atattacaacaaccttatcaacgaactattggctaacggtatacaaccatttgtaactct
+ttttcattgggatcttccccaagtcttagaagatgagtatggtggtttcttaaactccgg
+tgtaataaatgattttcgagactatacggatctttgcttcaaggaatttggagatagagt
+gaggtattggagtactctaaatgagccatgggtgtttagcaattctggatatgcactagg
+aacaaatgcaccaggtcgatgttcggcctccaacgtggccaagcctggtgattctggaac
+aggaccttatatagttacacacaatcaaattcttgctcatgcagaagctgtacatgtgta
+taagactaaataccaggcatatcaaaagggaaagataggcataacgttggtatctaactg
+gttaatgccacttgatgataatagcataccagatataaaggctgccgagagatcacttga
+cttccaatttggattgtttatggaacaattaacaacaggagattattctaagagcatgcg
+gcgtatagttaaaaaccgattacctaagttctcaaaattcgaatcaagcctagtgaatgg
+ttcatttgattttattggtataaactattactcttctagttatattagcaatgccccttc
+acatggcaatgccaaacccagttactcaacaaatcctatgaccaatatttcatttgaaaa
+acatgggatacccttaggtccaagggctgcttcaatttggatatatgtttatccatatat
+gtttatccaagaggacttcgagatcttttgttacatattaaaaataaatataacaatcct
+gcaattttcaatcactgaaaatggtatgaatgaattcaacgatgcaacacttccagtaga
+agaagctcttttgaatacttacagaattgattactattaccgtcacttatactacattcg
+ttctgcaatcagggctggctcaaatgtgaagggtttttacgcatggtcatttttggactg
+taatgaatggtttgcaggctttactgttcgttttggattaaactttgtagattagaaaga
+tggattaaaaaggtaccctaagctttctgcccaatggtacaagaactttctcaaaagaaa
+ctagctagtattattaaaagaactttgtagtagattacagtacatcgtttgaagttgagt
+tggtgcacctaattaaataaaagaggttactcttaacatatttttaggccattcgttgtg
+aagttgttaggctgttatttctattatactatgttgtagtaataagtgcattgttgtacc
+agaagctatgatcataactataggttgatccttcatgtatcagtttgatgttgagaatac
+tttgaattaaaagtctttttttatttttttaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
+>seq2
+aaacaaaccaaatatggattttattgtagccatatttgctctgtttgttattagctcatt
+cacaattacttccacaaatgcagttgaagcttctactcttcttgacataggtaacctgag
+tcggagcagttttcctcgtggcttcatctttggtgctggatcttcagcataccaatttga
+aggtgcagtaaacgaaggcggtagaggaccaagtatttgggataccttcacccataaata
+tccagaaaaaataagggatggaagcaatgcagacatcacggttgaccaatatcaccgcta
+caaggaagatgttgggattatgaaggatcaaaatatggattcgtatagattctcaatctc
+ttggccaagaatactcccaaagggaaagttgagcggaggcataaatcacgaaggaatcaa
+atattacaacaaccttatcaacgaactattggctaacggtatacaaccatttgtaactct
+ttttcattgggatcttccccaagtcttagaagatgagtatggtggtttcttaaactccgg
+tgtaataaatgattttcgagactatacggatctttgcttcaaggaatttggagatagagt
+gaggtattggagtactctaaatgagccatgggtgtttagcaattctggatatgcactagg
+aacaaatgcaccaggtcgatgttcggcctccaacgtggccaagcctggtgattctggaac
+aggaccttatatagttacacacaatcaaattcttgctcatgcagaagctgtacatgtgta
+taagactaaataccaggcatatcaaaagggaaagataggcataacgttggtatctaactg
+gttaatgccacttgatgataatagcataccagatataaaggctgccgagagatcacttga
+cttccaatttggattgtttatggaacaattaacaacaggagattattctaagagcatgcg
+gcgtatagttaaaaaccgattacctaagttctcaaaattcgaatcaagcctagtgaatgg
+ttcatttgattttattggtataaactattactcttctagttatattagcaatgccccttc
+acatggcaatgccaaacccagttactcaacaaatcctatgaccaatatttcatttgaaaa
+acatgggatacccttaggtccaagggctgcttcaatttggatatatgtttatccatatat
+gtttatccaagaggacttcgagatcttttgttacatattaaaaataaatataacaatcct
+gcaattttcaatcactgaaaatggtatgaatgaattcaacgatgcaacacttccagtaga
+agaagctcttttgaatacttacagaattgattactattaccgtcacttatactacattcg
+ttctgcaatcagggctggctcaaatgtgaagggtttttacgcatggtcatttttggactg
+taatgaatggtttgcaggctttactgttcgttttggattaaactttgtagattagaaaga
+tggattaaaaaggtaccctaagctttctgcccaatggtacaagaactttctcaaaagaaa
+ctagctagtattattaaaagaactttgtagtagattacagtacatcgtttgaagttgagt
+tggtgcacctaattaaataaaagaggttactcttaacatatttttaggccattcgttgtg
+aagttgttaggctgttatttctattatactatgttgtagtaataagtgcattgttgtacc
+agaagctatgatcataactataggttgatccttcatgtatcagtttgatgttgagaatac
+tttgaattaaaagtctttttttatttttttaaaaaaaaaaaaaaaaaaaaccccccccc
diff --git a/fastaq/tests/data/sequences_test.fa b/fastaq/tests/data/sequences_test.fa
new file mode 100644
index 0000000..22da7a3
--- /dev/null
+++ b/fastaq/tests/data/sequences_test.fa
@@ -0,0 +1,19 @@
+>1
+ACGTA
+>2
+A
+
+C
+GT
+
+A
+
+>3
+
+
+ACGTA
+>4
+ACGTA
+
+
+
diff --git a/fastaq/tests/data/sequences_test.fa.ids b/fastaq/tests/data/sequences_test.fa.ids
new file mode 100644
index 0000000..94ebaf9
--- /dev/null
+++ b/fastaq/tests/data/sequences_test.fa.ids
@@ -0,0 +1,4 @@
+1
+2
+3
+4
diff --git a/fastaq/tests/data/sequences_test.fa.qual b/fastaq/tests/data/sequences_test.fa.qual
new file mode 100644
index 0000000..435d562
--- /dev/null
+++ b/fastaq/tests/data/sequences_test.fa.qual
@@ -0,0 +1,17 @@
+>1
+40 40 40
+40 40
+
+>2
+40
+40
+
+40
+40 40
+>3
+
+40 40 40 40 40
+
+>4
+40 40 40      40 40
+
diff --git a/fastaq/tests/data/sequences_test.fa.qual.bad b/fastaq/tests/data/sequences_test.fa.qual.bad
new file mode 100644
index 0000000..92c8d8d
--- /dev/null
+++ b/fastaq/tests/data/sequences_test.fa.qual.bad
@@ -0,0 +1,17 @@
+>1
+40 40 40
+40 40
+
+>3
+40
+40
+
+40
+40 40
+>3
+
+40 40 40 40 40
+
+>4
+40 40 40      40 40
+
diff --git a/fastaq/tests/data/sequences_test.fasta_to_fastq.fq b/fastaq/tests/data/sequences_test.fasta_to_fastq.fq
new file mode 100644
index 0000000..48f7282
--- /dev/null
+++ b/fastaq/tests/data/sequences_test.fasta_to_fastq.fq
@@ -0,0 +1,16 @@
+ at 1
+ACGTA
++
+IIIII
+ at 2
+ACGTA
++
+IIIII
+ at 3
+ACGTA
++
+IIIII
+ at 4
+ACGTA
++
+IIIII
diff --git a/fastaq/tests/data/sequences_test.gbk b/fastaq/tests/data/sequences_test.gbk
new file mode 100644
index 0000000..40f1afb
--- /dev/null
+++ b/fastaq/tests/data/sequences_test.gbk
@@ -0,0 +1,170 @@
+LOCUS       NAME1         5028 bp    DNA             PLN       21-JUN-1999
+DEFINITION  Saccharomyces cerevisiae TCP1-beta gene, partial cds, and Axl2p
+            (AXL2) and Rev7p (REV7) genes, complete cds.
+ACCESSION   U49845
+VERSION     U49845.1  GI:1293613
+KEYWORDS    .
+SOURCE      Saccharomyces cerevisiae (baker's yeast)
+  ORGANISM  Saccharomyces cerevisiae
+            Eukaryota; Fungi; Ascomycota; Saccharomycotina; Saccharomycetes;
+            Saccharomycetales; Saccharomycetaceae; Saccharomyces.
+REFERENCE   1  (bases 1 to 5028)
+  AUTHORS   Torpey,L.E., Gibbs,P.E., Nelson,J. and Lawrence,C.W.
+  TITLE     Cloning and sequence of REV7, a gene whose function is required for
+            DNA damage-induced mutagenesis in Saccharomyces cerevisiae
+  JOURNAL   Yeast 10 (11), 1503-1509 (1994)
+  PUBMED    7871890
+REFERENCE   2  (bases 1 to 5028)
+  AUTHORS   Roemer,T., Madden,K., Chang,J. and Snyder,M.
+  TITLE     Selection of axial growth sites in yeast requires Axl2p, a novel
+            plasma membrane glycoprotein
+  JOURNAL   Genes Dev. 10 (7), 777-793 (1996)
+  PUBMED    8846915
+REFERENCE   3  (bases 1 to 5028)
+  AUTHORS   Roemer,T.
+  TITLE     Direct Submission
+  JOURNAL   Submitted (22-FEB-1996) Terry Roemer, Biology, Yale University, New
+            Haven, CT, USA
+FEATURES             Location/Qualifiers
+     source          1..5028
+                     /organism="Saccharomyces cerevisiae"
+                     /db_xref="taxon:4932"
+                     /chromosome="IX"
+                     /map="9"
+     CDS             <1..206
+                     /codon_start=3
+                     /product="TCP1-beta"
+                     /protein_id="AAA98665.1"
+                     /db_xref="GI:1293614"
+                     /translation="SSIYNGISTSGLDLNNGTIADMRQLGIVESYKLKRAVVSSASEA
+                     AEVLLRVDNIIRARPRTANRQHM"
+     gene            687..3158
+                     /gene="AXL2"
+     CDS             687..3158
+                     /gene="AXL2"
+                     /note="plasma membrane glycoprotein"
+                     /codon_start=1
+                     /function="required for axial budding pattern of S.
+                     cerevisiae"
+                     /product="Axl2p"
+                     /protein_id="AAA98666.1"
+                     /db_xref="GI:1293615"
+                     /translation="MTQLQISLLLTATISLLHLVVATPYEAYPIGKQYPPVARVNESF
+                     TFQISNDTYKSSVDKTAQITYNCFDLPSWLSFDSSSRTFSGEPSSDLLSDANTTLYFN
+                     VILEGTDSADSTSLNNTYQFVVTNRPSISLSSDFNLLALLKNYGYTNGKNALKLDPNE
+                     VFNVTFDRSMFTNEESIVSYYGRSQLYNAPLPNWLFFDSGELKFTGTAPVINSAIAPE
+                     TSYSFVIIATDIEGFSAVEVEFELVIGAHQLTTSIQNSLIINVTDTGNVSYDLPLNYV
+                     YLDDDPISSDKLGSINLLDAPDWVALDNATISGSVPDELLGKNSNPANFSVSIYDTYG
+                     DVIYFNFEVVSTTDLFAISSLPNINATRGEWFSYYFLPSQFTDYVNTNVSLEFTNSSQ
+                     DHDWVKFQSSNLTLAGEVPKNFDKLSLGLKANQGSQSQELYFNIIGMDSKITHSNHSA
+                     NATSTRSSHHSTSTSSYTSSTYTAKISSTSAAATSSAPAALPAANKTSSHNKKAVAIA
+                     CGVAIPLGVILVALICFLIFWRRRRENPDDENLPHAISGPDLNNPANKPNQENATPLN
+                     NPFDDDASSYDDTSIARRLAALNTLKLDNHSATESDISSVDEKRDSLSGMNTYNDQFQ
+                     SQSKEELLAKPPVQPPESPFFDPQNRSSSVYMDSEPAVNKSWRYTGNLSPVSDIVRDS
+                     YGSQKTVDTEKLFDLEAPEKEKRTSRDVTMSSLDPWNSNISPSPVRKSVTPSPYNVTK
+                     HRNRHLQNIQDSQSGKNGITPTTMSTSSSDDFVPVKDGENFCWVHSMEPDRRPSKKRL
+                     VDFSNKSNVNVGQVKDIHGRIPEML"
+     gene            complement(3300..4037)
+                     /gene="REV7"
+     CDS             complement(3300..4037)
+                     /gene="REV7"
+                     /codon_start=1
+                     /product="Rev7p"
+                     /protein_id="AAA98667.1"
+                     /db_xref="GI:1293616"
+                     /translation="MNRWVEKWLRVYLKCYINLILFYRNVYPPQSFDYTTYQSFNLPQ
+                     FVPINRHPALIDYIEELILDVLSKLTHVYRFSICIINKKNDLCIEKYVLDFSELQHVD
+                     KDDQIITETEVFDEFRSSLNSLIMHLEKLPKVNDDTITFEAVINAIELELGHKLDRNR
+                     RVDSLEEKAEIERDSNWVKCQEDENLPDNNGFQPPKIKLTSLVGSDVGPLIIHQFSEK
+                     LISGDDKILNGVYSQYEEGESIFGSLF"
+ORIGIN
+        1 gatcctccat atacaacggt atctccacct caggtttaga tctcaacaac ggaaccattg
+       61 ccgacatgag acagttaggt atcgtcgaga gttacaagct aaaacgagca gtagtcagct
+      121 ctgcatctga agccgctgaa gttctactaa gggtggataa catcatccgt gcaagaccaa
+      181 tgccatgact cagattctaa ttttaagcta ttcaatttct ctttgatc
+//
+LOCUS       NAME2         5028 bp    DNA             PLN       21-JUN-1999
+DEFINITION  Saccharomyces cerevisiae TCP1-beta gene, partial cds, and Axl2p
+            (AXL2) and Rev7p (REV7) genes, complete cds.
+ACCESSION   U49845
+VERSION     U49845.1  GI:1293613
+KEYWORDS    .
+SOURCE      Saccharomyces cerevisiae (baker's yeast)
+  ORGANISM  Saccharomyces cerevisiae
+            Eukaryota; Fungi; Ascomycota; Saccharomycotina; Saccharomycetes;
+            Saccharomycetales; Saccharomycetaceae; Saccharomyces.
+REFERENCE   1  (bases 1 to 5028)
+  AUTHORS   Torpey,L.E., Gibbs,P.E., Nelson,J. and Lawrence,C.W.
+  TITLE     Cloning and sequence of REV7, a gene whose function is required for
+            DNA damage-induced mutagenesis in Saccharomyces cerevisiae
+  JOURNAL   Yeast 10 (11), 1503-1509 (1994)
+  PUBMED    7871890
+REFERENCE   2  (bases 1 to 5028)
+  AUTHORS   Roemer,T., Madden,K., Chang,J. and Snyder,M.
+  TITLE     Selection of axial growth sites in yeast requires Axl2p, a novel
+            plasma membrane glycoprotein
+  JOURNAL   Genes Dev. 10 (7), 777-793 (1996)
+  PUBMED    8846915
+REFERENCE   3  (bases 1 to 5028)
+  AUTHORS   Roemer,T.
+  TITLE     Direct Submission
+  JOURNAL   Submitted (22-FEB-1996) Terry Roemer, Biology, Yale University, New
+            Haven, CT, USA
+FEATURES             Location/Qualifiers
+     source          1..5028
+                     /organism="Saccharomyces cerevisiae"
+                     /db_xref="taxon:4932"
+                     /chromosome="IX"
+                     /map="9"
+     CDS             <1..206
+                     /codon_start=3
+                     /product="TCP1-beta"
+                     /protein_id="AAA98665.1"
+                     /db_xref="GI:1293614"
+                     /translation="SSIYNGISTSGLDLNNGTIADMRQLGIVESYKLKRAVVSSASEA
+                     AEVLLRVDNIIRARPRTANRQHM"
+     gene            687..3158
+                     /gene="AXL2"
+     CDS             687..3158
+                     /gene="AXL2"
+                     /note="plasma membrane glycoprotein"
+                     /codon_start=1
+                     /function="required for axial budding pattern of S.
+                     cerevisiae"
+                     /product="Axl2p"
+                     /protein_id="AAA98666.1"
+                     /db_xref="GI:1293615"
+                     /translation="MTQLQISLLLTATISLLHLVVATPYEAYPIGKQYPPVARVNESF
+                     TFQISNDTYKSSVDKTAQITYNCFDLPSWLSFDSSSRTFSGEPSSDLLSDANTTLYFN
+                     VILEGTDSADSTSLNNTYQFVVTNRPSISLSSDFNLLALLKNYGYTNGKNALKLDPNE
+                     VFNVTFDRSMFTNEESIVSYYGRSQLYNAPLPNWLFFDSGELKFTGTAPVINSAIAPE
+                     TSYSFVIIATDIEGFSAVEVEFELVIGAHQLTTSIQNSLIINVTDTGNVSYDLPLNYV
+                     YLDDDPISSDKLGSINLLDAPDWVALDNATISGSVPDELLGKNSNPANFSVSIYDTYG
+                     DVIYFNFEVVSTTDLFAISSLPNINATRGEWFSYYFLPSQFTDYVNTNVSLEFTNSSQ
+                     DHDWVKFQSSNLTLAGEVPKNFDKLSLGLKANQGSQSQELYFNIIGMDSKITHSNHSA
+                     NATSTRSSHHSTSTSSYTSSTYTAKISSTSAAATSSAPAALPAANKTSSHNKKAVAIA
+                     CGVAIPLGVILVALICFLIFWRRRRENPDDENLPHAISGPDLNNPANKPNQENATPLN
+                     NPFDDDASSYDDTSIARRLAALNTLKLDNHSATESDISSVDEKRDSLSGMNTYNDQFQ
+                     SQSKEELLAKPPVQPPESPFFDPQNRSSSVYMDSEPAVNKSWRYTGNLSPVSDIVRDS
+                     YGSQKTVDTEKLFDLEAPEKEKRTSRDVTMSSLDPWNSNISPSPVRKSVTPSPYNVTK
+                     HRNRHLQNIQDSQSGKNGITPTTMSTSSSDDFVPVKDGENFCWVHSMEPDRRPSKKRL
+                     VDFSNKSNVNVGQVKDIHGRIPEML"
+     gene            complement(3300..4037)
+                     /gene="REV7"
+     CDS             complement(3300..4037)
+                     /gene="REV7"
+                     /codon_start=1
+                     /product="Rev7p"
+                     /protein_id="AAA98667.1"
+                     /db_xref="GI:1293616"
+                     /translation="MNRWVEKWLRVYLKCYINLILFYRNVYPPQSFDYTTYQSFNLPQ
+                     FVPINRHPALIDYIEELILDVLSKLTHVYRFSICIINKKNDLCIEKYVLDFSELQHVD
+                     KDDQIITETEVFDEFRSSLNSLIMHLEKLPKVNDDTITFEAVINAIELELGHKLDRNR
+                     RVDSLEEKAEIERDSNWVKCQEDENLPDNNGFQPPKIKLTSLVGSDVGPLIIHQFSEK
+                     LISGDDKILNGVYSQYEEGESIFGSLF"
+ORIGIN
+        1 gatcctccat atacaacggt atctccacct caggtttaga tctcaacaac ggaaccattg
+       61 ccgacatgag acagttaggt atcgtcgaga gttacaagct aaaacgagca gtagtcagct
+      121 ctgcatctga agccgctgaa gttctactaa gggtggataa catcatccgt gcaagaccaa
+      181 tgccatgact cagattctaa ttttaagcta ttcaatttct ctttgaaa
+//
diff --git a/fastaq/tests/data/sequences_test.gbk.to_fasta b/fastaq/tests/data/sequences_test.gbk.to_fasta
new file mode 100644
index 0000000..270d9ec
--- /dev/null
+++ b/fastaq/tests/data/sequences_test.gbk.to_fasta
@@ -0,0 +1,10 @@
+>NAME1
+gatcctccatatacaacggtatctccacctcaggtttagatctcaacaacggaaccattg
+ccgacatgagacagttaggtatcgtcgagagttacaagctaaaacgagcagtagtcagct
+ctgcatctgaagccgctgaagttctactaagggtggataacatcatccgtgcaagaccaa
+tgccatgactcagattctaattttaagctattcaatttctctttgatc
+>NAME2
+gatcctccatatacaacggtatctccacctcaggtttagatctcaacaacggaaccattg
+ccgacatgagacagttaggtatcgtcgagagttacaagctaaaacgagcagtagtcagct
+ctgcatctgaagccgctgaagttctactaagggtggataacatcatccgtgcaagaccaa
+tgccatgactcagattctaattttaagctattcaatttctctttgaaa
diff --git a/fastaq/tests/data/sequences_test.line_length3.fa b/fastaq/tests/data/sequences_test.line_length3.fa
new file mode 100644
index 0000000..a77df6d
--- /dev/null
+++ b/fastaq/tests/data/sequences_test.line_length3.fa
@@ -0,0 +1,12 @@
+>1
+ACG
+TA
+>2
+ACG
+TA
+>3
+ACG
+TA
+>4
+ACG
+TA
diff --git a/fastaq/tests/data/sequences_test_3-per-line.fa b/fastaq/tests/data/sequences_test_3-per-line.fa
new file mode 100644
index 0000000..01ec932
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_3-per-line.fa
@@ -0,0 +1,19 @@
+>ID
+A
+>ID
+AA
+>ID
+AAA
+>ID
+AAA
+A
+>ID
+AAA
+AA
+>ID
+AAA
+AAA
+>ID
+AAA
+AAA
+A
diff --git a/fastaq/tests/data/sequences_test_cap_to_read_pairs.fa b/fastaq/tests/data/sequences_test_cap_to_read_pairs.fa
new file mode 100644
index 0000000..dffde8b
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_cap_to_read_pairs.fa
@@ -0,0 +1,16 @@
+>one.p1k
+ACGT
+>one.q1k
+CCCC
+>two.p1k
+A
+>two.q1k
+C
+>one.p1k
+TTTTTTTTTT
+>three.q1k
+A
+>four.x
+T
+>five.p1k
+G
diff --git a/fastaq/tests/data/sequences_test_cap_to_read_pairs.fa.paired.gz b/fastaq/tests/data/sequences_test_cap_to_read_pairs.fa.paired.gz
new file mode 100644
index 0000000..5f98494
Binary files /dev/null and b/fastaq/tests/data/sequences_test_cap_to_read_pairs.fa.paired.gz differ
diff --git a/fastaq/tests/data/sequences_test_cap_to_read_pairs.fa.unpaired.gz b/fastaq/tests/data/sequences_test_cap_to_read_pairs.fa.unpaired.gz
new file mode 100644
index 0000000..2e8d705
Binary files /dev/null and b/fastaq/tests/data/sequences_test_cap_to_read_pairs.fa.unpaired.gz differ
diff --git a/fastaq/tests/data/sequences_test_deinterleaved_1.fa b/fastaq/tests/data/sequences_test_deinterleaved_1.fa
new file mode 100644
index 0000000..cb095ce
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_deinterleaved_1.fa
@@ -0,0 +1,4 @@
+>1/1
+ACGTA
+>2/1
+A
diff --git a/fastaq/tests/data/sequences_test_deinterleaved_2.fa b/fastaq/tests/data/sequences_test_deinterleaved_2.fa
new file mode 100644
index 0000000..d0017c9
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_deinterleaved_2.fa
@@ -0,0 +1,4 @@
+>1/2
+ACGTA
+>2/2
+C
diff --git a/fastaq/tests/data/sequences_test_deinterleaved_bad2_1.fa b/fastaq/tests/data/sequences_test_deinterleaved_bad2_1.fa
new file mode 100644
index 0000000..0f656b5
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_deinterleaved_bad2_1.fa
@@ -0,0 +1,2 @@
+>1/1
+ACGTA
diff --git a/fastaq/tests/data/sequences_test_deinterleaved_bad2_2.fa b/fastaq/tests/data/sequences_test_deinterleaved_bad2_2.fa
new file mode 100644
index 0000000..ad68ff1
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_deinterleaved_bad2_2.fa
@@ -0,0 +1,4 @@
+>1/2
+ACGTA
+>2/2
+A
diff --git a/fastaq/tests/data/sequences_test_deinterleaved_bad_1.fa b/fastaq/tests/data/sequences_test_deinterleaved_bad_1.fa
new file mode 100644
index 0000000..cb095ce
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_deinterleaved_bad_1.fa
@@ -0,0 +1,4 @@
+>1/1
+ACGTA
+>2/1
+A
diff --git a/fastaq/tests/data/sequences_test_deinterleaved_bad_2.fa b/fastaq/tests/data/sequences_test_deinterleaved_bad_2.fa
new file mode 100644
index 0000000..baf20b4
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_deinterleaved_bad_2.fa
@@ -0,0 +1,2 @@
+>1/2
+ACGTA
diff --git a/fastaq/tests/data/sequences_test_empty_file b/fastaq/tests/data/sequences_test_empty_file
new file mode 100644
index 0000000..e69de29
diff --git a/fastaq/tests/data/sequences_test_enumerate_names.fa b/fastaq/tests/data/sequences_test_enumerate_names.fa
new file mode 100644
index 0000000..d2dce18
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_enumerate_names.fa
@@ -0,0 +1,8 @@
+>one/1
+A
+>one/2
+C
+>two/1
+G
+>two/2
+T
diff --git a/fastaq/tests/data/sequences_test_enumerate_names.fa.out.keep_suffix b/fastaq/tests/data/sequences_test_enumerate_names.fa.out.keep_suffix
new file mode 100644
index 0000000..dba3ca0
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_enumerate_names.fa.out.keep_suffix
@@ -0,0 +1,8 @@
+>1/1
+A
+>2/2
+C
+>3/1
+G
+>4/2
+T
diff --git a/fastaq/tests/data/sequences_test_enumerate_names.fa.out.start.1 b/fastaq/tests/data/sequences_test_enumerate_names.fa.out.start.1
new file mode 100644
index 0000000..2c8d196
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_enumerate_names.fa.out.start.1
@@ -0,0 +1,8 @@
+>1
+A
+>2
+C
+>3
+G
+>4
+T
diff --git a/fastaq/tests/data/sequences_test_enumerate_names.fa.out.start.1.rename_file b/fastaq/tests/data/sequences_test_enumerate_names.fa.out.start.1.rename_file
new file mode 100644
index 0000000..8de27ac
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_enumerate_names.fa.out.start.1.rename_file
@@ -0,0 +1,5 @@
+#old	new
+one/1	1
+one/2	2
+two/1	3
+two/2	4
diff --git a/fastaq/tests/data/sequences_test_enumerate_names.fa.out.start.2 b/fastaq/tests/data/sequences_test_enumerate_names.fa.out.start.2
new file mode 100644
index 0000000..fdb1d1f
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_enumerate_names.fa.out.start.2
@@ -0,0 +1,8 @@
+>2
+A
+>3
+C
+>4
+G
+>5
+T
diff --git a/fastaq/tests/data/sequences_test_extend_gaps.fa b/fastaq/tests/data/sequences_test_extend_gaps.fa
new file mode 100644
index 0000000..b05b56c
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_extend_gaps.fa
@@ -0,0 +1,8 @@
+>1
+AC
+>2
+ACGTACGT
+>3
+ACGTNACGT
+>4
+ACGTACGTNACGTACGT
diff --git a/fastaq/tests/data/sequences_test_extend_gaps.fa.out b/fastaq/tests/data/sequences_test_extend_gaps.fa.out
new file mode 100644
index 0000000..e1ec718
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_extend_gaps.fa.out
@@ -0,0 +1,4 @@
+>2
+GTAC
+>4
+GTACNNNNNGTAC
diff --git a/fastaq/tests/data/sequences_test_fai_test.fa b/fastaq/tests/data/sequences_test_fai_test.fa
new file mode 100644
index 0000000..7c02b44
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_fai_test.fa
@@ -0,0 +1,8 @@
+>1
+A
+>2
+AA
+>3
+AAA
+>4
+AAAA
diff --git a/fastaq/tests/data/sequences_test_fai_test.fa.fai b/fastaq/tests/data/sequences_test_fai_test.fa.fai
new file mode 100644
index 0000000..154a9d6
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_fai_test.fa.fai
@@ -0,0 +1,4 @@
+1	1	3	1	2
+2	2	8	2	3
+3	3	14	3	4
+4	4	21	4	5
diff --git a/fastaq/tests/data/sequences_test_fail_no_AT.fq b/fastaq/tests/data/sequences_test_fail_no_AT.fq
new file mode 100644
index 0000000..d1472fc
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_fail_no_AT.fq
@@ -0,0 +1,5 @@
+ at 1
+A
++
+I
+NOT_AN_ at _LINE
diff --git a/fastaq/tests/data/sequences_test_fail_no_plus.fq b/fastaq/tests/data/sequences_test_fail_no_plus.fq
new file mode 100644
index 0000000..52b5b7c
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_fail_no_plus.fq
@@ -0,0 +1,4 @@
+ at A
+A
+NOT_A_+
+I
diff --git a/fastaq/tests/data/sequences_test_fail_no_qual.fq b/fastaq/tests/data/sequences_test_fail_no_qual.fq
new file mode 100644
index 0000000..16ca520
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_fail_no_qual.fq
@@ -0,0 +1,3 @@
+ at A
+A
++
diff --git a/fastaq/tests/data/sequences_test_fail_no_seq.fq b/fastaq/tests/data/sequences_test_fail_no_seq.fq
new file mode 100644
index 0000000..de51137
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_fail_no_seq.fq
@@ -0,0 +1,5 @@
+ at A
+A
++
+I
+ at B
diff --git a/fastaq/tests/data/sequences_test_fastaq_replace_bases.expected.fa b/fastaq/tests/data/sequences_test_fastaq_replace_bases.expected.fa
new file mode 100644
index 0000000..98e1577
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_fastaq_replace_bases.expected.fa
@@ -0,0 +1,2 @@
+>1
+ACGXXXAXA
diff --git a/fastaq/tests/data/sequences_test_fastaq_replace_bases.fa b/fastaq/tests/data/sequences_test_fastaq_replace_bases.fa
new file mode 100644
index 0000000..c33edf7
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_fastaq_replace_bases.fa
@@ -0,0 +1,2 @@
+>1
+ACGTTTATA
diff --git a/fastaq/tests/data/sequences_test_fastaq_to_quasr_primers.expected b/fastaq/tests/data/sequences_test_fastaq_to_quasr_primers.expected
new file mode 100644
index 0000000..88ce837
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_fastaq_to_quasr_primers.expected
@@ -0,0 +1,2 @@
+ACGT	ACGT
+AG	CT
diff --git a/fastaq/tests/data/sequences_test_fastaq_to_quasr_primers.fa b/fastaq/tests/data/sequences_test_fastaq_to_quasr_primers.fa
new file mode 100644
index 0000000..be7c130
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_fastaq_to_quasr_primers.fa
@@ -0,0 +1,4 @@
+>1
+ACGT
+>2
+AG
diff --git a/fastaq/tests/data/sequences_test_filter_by_ids_file.fa b/fastaq/tests/data/sequences_test_filter_by_ids_file.fa
new file mode 100644
index 0000000..35845b6
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_filter_by_ids_file.fa
@@ -0,0 +1,8 @@
+>seq1
+A
+>seq2
+C
+>seq3
+G
+>seq4
+T
diff --git a/fastaq/tests/data/sequences_test_filter_by_ids_file.fa.filtered b/fastaq/tests/data/sequences_test_filter_by_ids_file.fa.filtered
new file mode 100644
index 0000000..3519900
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_filter_by_ids_file.fa.filtered
@@ -0,0 +1,4 @@
+>seq2
+C
+>seq4
+T
diff --git a/fastaq/tests/data/sequences_test_filter_by_ids_file.fa.filtered.invert b/fastaq/tests/data/sequences_test_filter_by_ids_file.fa.filtered.invert
new file mode 100644
index 0000000..af15a5f
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_filter_by_ids_file.fa.filtered.invert
@@ -0,0 +1,4 @@
+>seq1
+A
+>seq3
+G
diff --git a/fastaq/tests/data/sequences_test_filter_by_ids_file.fa.ids b/fastaq/tests/data/sequences_test_filter_by_ids_file.fa.ids
new file mode 100644
index 0000000..486529d
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_filter_by_ids_file.fa.ids
@@ -0,0 +1,2 @@
+seq4
+seq2
diff --git a/fastaq/tests/data/sequences_test_filter_by_regex.fa b/fastaq/tests/data/sequences_test_filter_by_regex.fa
new file mode 100644
index 0000000..d2cc8eb
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_filter_by_regex.fa
@@ -0,0 +1,10 @@
+>1
+AAA
+>a
+AAA
+>a/1
+AAA
+>a/2
+AAA
+>b/1
+AAA
diff --git a/fastaq/tests/data/sequences_test_filter_by_regex.first-char-a.fa b/fastaq/tests/data/sequences_test_filter_by_regex.first-char-a.fa
new file mode 100644
index 0000000..e874092
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_filter_by_regex.first-char-a.fa
@@ -0,0 +1,6 @@
+>a
+AAA
+>a/1
+AAA
+>a/2
+AAA
diff --git a/fastaq/tests/data/sequences_test_filter_by_regex.first-of-pair.fa b/fastaq/tests/data/sequences_test_filter_by_regex.first-of-pair.fa
new file mode 100644
index 0000000..6dd5e50
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_filter_by_regex.first-of-pair.fa
@@ -0,0 +1,4 @@
+>a/1
+AAA
+>b/1
+AAA
diff --git a/fastaq/tests/data/sequences_test_filter_by_regex.numeric.fa b/fastaq/tests/data/sequences_test_filter_by_regex.numeric.fa
new file mode 100644
index 0000000..b2d5b58
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_filter_by_regex.numeric.fa
@@ -0,0 +1,2 @@
+>1
+AAA
diff --git a/fastaq/tests/data/sequences_test_get_seqs_flanking_gaps.fa b/fastaq/tests/data/sequences_test_get_seqs_flanking_gaps.fa
new file mode 100644
index 0000000..18a368a
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_get_seqs_flanking_gaps.fa
@@ -0,0 +1,4 @@
+>a
+ACGTCNGTCNNNGT
+>b
+ACGTGTGTTG
diff --git a/fastaq/tests/data/sequences_test_get_seqs_flanking_gaps.fa.out b/fastaq/tests/data/sequences_test_get_seqs_flanking_gaps.fa.out
new file mode 100644
index 0000000..ecd2305
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_get_seqs_flanking_gaps.fa.out
@@ -0,0 +1,3 @@
+#id	gap_start	gap_end	left_bases	right_bases
+a	6	6	GTC	GTC
+a	10	12	GTC	GT
diff --git a/fastaq/tests/data/sequences_test_gffv3.gff b/fastaq/tests/data/sequences_test_gffv3.gff
new file mode 100644
index 0000000..5dab817
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_gffv3.gff
@@ -0,0 +1,9 @@
+##gff-version 3
+# comment
+##sequence-region seq1 1 10
+seq1	. 	gene	3	7	.	+	.	ID=gene1;name=name1
+##FASTA
+>seq1
+ACGTACGTAC
+>seq2
+ACGTACGTAC
diff --git a/fastaq/tests/data/sequences_test_gffv3.gff.fasta b/fastaq/tests/data/sequences_test_gffv3.gff.fasta
new file mode 100644
index 0000000..3b2f48f
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_gffv3.gff.fasta
@@ -0,0 +1,4 @@
+>seq1
+ACACGTGACG
+>seq2
+AGTACCGTAA
diff --git a/fastaq/tests/data/sequences_test_gffv3.gff.to_fasta b/fastaq/tests/data/sequences_test_gffv3.gff.to_fasta
new file mode 100644
index 0000000..89cfed0
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_gffv3.gff.to_fasta
@@ -0,0 +1,4 @@
+>seq1
+ACGTACGTAC
+>seq2
+ACGTACGTAC
diff --git a/fastaq/tests/data/sequences_test_gffv3.no_FASTA_line.gff b/fastaq/tests/data/sequences_test_gffv3.no_FASTA_line.gff
new file mode 100644
index 0000000..8e580fa
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_gffv3.no_FASTA_line.gff
@@ -0,0 +1,8 @@
+##gff-version 3
+# comment
+##sequence-region seq1 1 10
+seq1	. 	gene	3	7	.	+	.	ID=gene1;name=name1
+>seq1
+ACGTACGTAC
+>seq2
+ACGTACGTAC
diff --git a/fastaq/tests/data/sequences_test_gffv3.no_FASTA_line.gff.to_fasta b/fastaq/tests/data/sequences_test_gffv3.no_FASTA_line.gff.to_fasta
new file mode 100644
index 0000000..89cfed0
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_gffv3.no_FASTA_line.gff.to_fasta
@@ -0,0 +1,4 @@
+>seq1
+ACGTACGTAC
+>seq2
+ACGTACGTAC
diff --git a/fastaq/tests/data/sequences_test_gffv3.no_seq.2.gff b/fastaq/tests/data/sequences_test_gffv3.no_seq.2.gff
new file mode 100644
index 0000000..d9fda5c
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_gffv3.no_seq.2.gff
@@ -0,0 +1,6 @@
+##gff-version 3
+# comment
+##sequence-region seq1 1 10
+seq1	. 	gene	3	7	.	+	.	ID=gene1;name=name1
+##FASTA
+oops
diff --git a/fastaq/tests/data/sequences_test_gffv3.no_seq.gff b/fastaq/tests/data/sequences_test_gffv3.no_seq.gff
new file mode 100644
index 0000000..dbe2b52
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_gffv3.no_seq.gff
@@ -0,0 +1,4 @@
+##gff-version 3
+# comment
+##sequence-region seq1 1 10
+seq1	. 	gene	3	7	.	+	.	ID=gene1;name=name1
diff --git a/fastaq/tests/data/sequences_test_good_file.fq b/fastaq/tests/data/sequences_test_good_file.fq
new file mode 100644
index 0000000..12a42bc
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_good_file.fq
@@ -0,0 +1,11 @@
+ at ID
+ACGTA
++
+IIIII
+
+
+
+ at ID
+ACGTA
++blah
+IIIII
diff --git a/fastaq/tests/data/sequences_test_good_file.fq.to_fasta b/fastaq/tests/data/sequences_test_good_file.fq.to_fasta
new file mode 100644
index 0000000..c11bdfd
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_good_file.fq.to_fasta
@@ -0,0 +1,4 @@
+>ID
+ACGTA
+>ID
+ACGTA
diff --git a/fastaq/tests/data/sequences_test_good_file_mira.xml b/fastaq/tests/data/sequences_test_good_file_mira.xml
new file mode 100644
index 0000000..a9fe6a2
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_good_file_mira.xml
@@ -0,0 +1,13 @@
+<?xml version="1.0"?>
+<trace_volume>
+    <trace>
+        <trace_name>ID</trace_name>
+        <clip_quality_right>5</clip_quality_right>
+        <clip_vector_left>1</clip_vector_left>
+    </trace>
+    <trace>
+        <trace_name>ID</trace_name>
+        <clip_quality_right>5</clip_quality_right>
+        <clip_vector_left>1</clip_vector_left>
+    </trace>
+</trace_volume>
diff --git a/fastaq/tests/data/sequences_test_interleaved.fa b/fastaq/tests/data/sequences_test_interleaved.fa
new file mode 100644
index 0000000..3692716
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_interleaved.fa
@@ -0,0 +1,8 @@
+>1/1
+ACGTA
+>1/2
+ACGTA
+>2/1
+A
+>2/2
+C
diff --git a/fastaq/tests/data/sequences_test_interleaved.fq b/fastaq/tests/data/sequences_test_interleaved.fq
new file mode 100644
index 0000000..951d5a5
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_interleaved.fq
@@ -0,0 +1,16 @@
+ at 1/1
+ACGTA
++
+IIIII
+ at 1/2
+ACGTA
++
+IIIII
+ at 2/1
+A
++
+I
+ at 2/2
+C
++
+I
diff --git a/fastaq/tests/data/sequences_test_interleaved_bad.fa b/fastaq/tests/data/sequences_test_interleaved_bad.fa
new file mode 100644
index 0000000..fef6d47
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_interleaved_bad.fa
@@ -0,0 +1,6 @@
+>1/1
+ACGTA
+>1/2
+ACGTA
+>2/1
+A
diff --git a/fastaq/tests/data/sequences_test_length_filter.fa b/fastaq/tests/data/sequences_test_length_filter.fa
new file mode 100644
index 0000000..7507f2e
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_length_filter.fa
@@ -0,0 +1,6 @@
+>3
+AAA
+>4
+AAAA
+>5
+AAAAA
diff --git a/fastaq/tests/data/sequences_test_length_filter.min-0.max-1.fa b/fastaq/tests/data/sequences_test_length_filter.min-0.max-1.fa
new file mode 100644
index 0000000..e69de29
diff --git a/fastaq/tests/data/sequences_test_length_filter.min-0.max-inf.fa b/fastaq/tests/data/sequences_test_length_filter.min-0.max-inf.fa
new file mode 100644
index 0000000..7507f2e
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_length_filter.min-0.max-inf.fa
@@ -0,0 +1,6 @@
+>3
+AAA
+>4
+AAAA
+>5
+AAAAA
diff --git a/fastaq/tests/data/sequences_test_length_filter.min-4.max-4.fa b/fastaq/tests/data/sequences_test_length_filter.min-4.max-4.fa
new file mode 100644
index 0000000..15e79c4
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_length_filter.min-4.max-4.fa
@@ -0,0 +1,2 @@
+>4
+AAAA
diff --git a/fastaq/tests/data/sequences_test_make_random_contigs.default.fa b/fastaq/tests/data/sequences_test_make_random_contigs.default.fa
new file mode 100644
index 0000000..8efafc7
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_make_random_contigs.default.fa
@@ -0,0 +1,4 @@
+>1
+ACG
+>2
+ACG
diff --git a/fastaq/tests/data/sequences_test_make_random_contigs.first-42.fa b/fastaq/tests/data/sequences_test_make_random_contigs.first-42.fa
new file mode 100644
index 0000000..67ee20a
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_make_random_contigs.first-42.fa
@@ -0,0 +1,4 @@
+>42
+ACG
+>43
+ACG
diff --git a/fastaq/tests/data/sequences_test_make_random_contigs.name-by-letters.fa b/fastaq/tests/data/sequences_test_make_random_contigs.name-by-letters.fa
new file mode 100644
index 0000000..447d3e0
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_make_random_contigs.name-by-letters.fa
@@ -0,0 +1,56 @@
+>A
+ACG
+>B
+ACG
+>C
+ACG
+>D
+ACG
+>E
+ACG
+>F
+ACG
+>G
+ACG
+>H
+ACG
+>I
+ACG
+>J
+ACG
+>K
+ACG
+>L
+ACG
+>M
+ACG
+>N
+ACG
+>O
+ACG
+>P
+ACG
+>Q
+ACG
+>R
+ACG
+>S
+ACG
+>T
+ACG
+>U
+ACG
+>V
+ACG
+>W
+ACG
+>X
+ACG
+>Y
+ACG
+>Z
+ACG
+>A
+ACG
+>B
+ACG
diff --git a/fastaq/tests/data/sequences_test_make_random_contigs.prefix-p.fa b/fastaq/tests/data/sequences_test_make_random_contigs.prefix-p.fa
new file mode 100644
index 0000000..dc68695
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_make_random_contigs.prefix-p.fa
@@ -0,0 +1,4 @@
+>p1
+ACG
+>p2
+ACG
diff --git a/fastaq/tests/data/sequences_test_merge_to_one_seq.fa b/fastaq/tests/data/sequences_test_merge_to_one_seq.fa
new file mode 100644
index 0000000..dc12fa4
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_merge_to_one_seq.fa
@@ -0,0 +1,8 @@
+>1
+A
+>2
+G
+>3
+C
+>4
+T
diff --git a/fastaq/tests/data/sequences_test_merge_to_one_seq.fq b/fastaq/tests/data/sequences_test_merge_to_one_seq.fq
new file mode 100644
index 0000000..cd2d877
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_merge_to_one_seq.fq
@@ -0,0 +1,8 @@
+ at 1
+A
++
+I
+ at 2
+G
++
+H
diff --git a/fastaq/tests/data/sequences_test_merge_to_one_seq.merged.fa b/fastaq/tests/data/sequences_test_merge_to_one_seq.merged.fa
new file mode 100644
index 0000000..ee6ca7b
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_merge_to_one_seq.merged.fa
@@ -0,0 +1,2 @@
+>union
+AGCT
diff --git a/fastaq/tests/data/sequences_test_merge_to_one_seq.merged.fq b/fastaq/tests/data/sequences_test_merge_to_one_seq.merged.fq
new file mode 100644
index 0000000..2a93ab6
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_merge_to_one_seq.merged.fq
@@ -0,0 +1,4 @@
+ at union
+AG
++
+IH
diff --git a/fastaq/tests/data/sequences_test_not_a_fastaq_file b/fastaq/tests/data/sequences_test_not_a_fastaq_file
new file mode 100644
index 0000000..da4a76b
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_not_a_fastaq_file
@@ -0,0 +1 @@
+i am not a fasta or fastq file
diff --git a/fastaq/tests/data/sequences_test_one-per-line.fa b/fastaq/tests/data/sequences_test_one-per-line.fa
new file mode 100644
index 0000000..b6e4b2f
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_one-per-line.fa
@@ -0,0 +1,14 @@
+>ID
+A
+>ID
+AA
+>ID
+AAA
+>ID
+AAAA
+>ID
+AAAAA
+>ID
+AAAAAA
+>ID
+AAAAAAA
diff --git a/fastaq/tests/data/sequences_test_orfs.fa b/fastaq/tests/data/sequences_test_orfs.fa
new file mode 100644
index 0000000..71b972a
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_orfs.fa
@@ -0,0 +1,18 @@
+>1
+GTATGACGACTTCTCGGTCAAAGGTAAGGTGAACAAGGGATTGAATGCTTAAATCCCGTG
+CCTACACTCAGTACCGGTGCTTGGCTGAAGCGTTCCTATGCAAGAATGAGAACTGGCAAC
+ACGTCGCGGCCAGCCCGGGACCATCAGGACCCGAACGTGTACCGCGAATGTTTACATTTC
+ACCCAGTTACCCGGATTCGGGCCAAAGCAGGAGAGCCTCTGAATTAGATGGTGCCACGTA
+AGTCTATTTTCGCACGTTTTATTGATTCAAGTGAGTGTCAACGTAGATTTATTGGTGCTT
+GGCTAAAGACGTATGGATCACGGGATGGAACATCTGGATCCCCCATGTACGTAAGTGTGT
+CGTCAAACAAAATTCTGTATCCCGTCGCTCCTGCCAGGGCAATCGCGGAGCTACGGACAT
+AGTCCTTAGTGAACTAATGATGATGAACATCTCGAACCAGGTTAACACGATACGATGAAG
+CGGGTTACTGAACACACTTAACAGGAGCCTGAGCAAATGTCATTTACAAAAGGTTTCTAG
+ACCCCCTTGGTAAGTCACTTGACACGTCTCATGCGGGGCCTACGGTAAACCAGATGCTAG
+AGTAGCGAACGGTGGGTGCGCAGGCATGTCCGGTCTCTCGATGGTGCACTTACGGACATC
+TCCCTATACAGATCTATTCAGTCACGAAGGTCAGCGAACATAACCCACGGGAGTTATCTC
+AACGAGTACGGGAGCGAACGGTGCACGGATCTGTCTTAGCTCAGAGGCGTCACGCGGTCC
+TATCTAACGCAAGAGCATGTGCCATTCCGGCCCTCTGATGTGCCTATGTACATAGAGCCG
+ACCCCGGCGGATTGGAGTCCCTAGCTACCGTCGACAGAGACGCAAAGACTCAATTGCTAT
+GTATATTGTTACTCTTCAACCACTGGAAAGACAAATAATTGCGGGCAAGTGCGTTACCCA
+TCACTCTGTTCTGTACACGAAAGGCTGAATAGCAAGTGGC
diff --git a/fastaq/tests/data/sequences_test_orfs.gff b/fastaq/tests/data/sequences_test_orfs.gff
new file mode 100644
index 0000000..f89b79c
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_orfs.gff
@@ -0,0 +1,15 @@
+1	fastaq	CDS	28	222	.	+	.
+1	fastaq	CDS	45	227	.	+	.
+1	fastaq	CDS	49	171	.	-	.
+1	fastaq	CDS	110	241	.	+	.
+1	fastaq	CDS	144	266	.	-	.
+1	fastaq	CDS	228	422	.	+	.
+1	fastaq	CDS	278	433	.	-	.
+1	fastaq	CDS	287	478	.	+	.
+1	fastaq	CDS	289	519	.	-	.
+1	fastaq	CDS	563	703	.	+	.
+1	fastaq	CDS	601	759	.	+	.
+1	fastaq	CDS	606	818	.	+	.
+1	fastaq	CDS	819	938	.	+	.
+1	fastaq	CDS	836	988	.	+	.
+1	fastaq	CDS	865	999	.	+	.
diff --git a/fastaq/tests/data/sequences_test_phylip.interleaved b/fastaq/tests/data/sequences_test_phylip.interleaved
new file mode 100644
index 0000000..e9a42db
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_phylip.interleaved
@@ -0,0 +1,8 @@
+  3    42
+Turkey    AA-CTNGGGC ATTTCAGGGT
+Salmo_gairAAGCCTTGGC AGTGCAGGGT
+H. SapiensACCGGTTGGC CGTTCAGGGT
+
+GAGCCCGGGC AATACAGGGT AT
+GAGCCGTGGC CGGGCACGGT AT
+ACAGGTTGGC CGTTCAGGGT AA
diff --git a/fastaq/tests/data/sequences_test_phylip.interleaved.to_fasta b/fastaq/tests/data/sequences_test_phylip.interleaved.to_fasta
new file mode 100644
index 0000000..22dfb80
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_phylip.interleaved.to_fasta
@@ -0,0 +1,6 @@
+>Turkey
+AACTNGGGCATTTCAGGGTGAGCCCGGGCAATACAGGGTAT
+>Salmo_gair
+AAGCCTTGGCAGTGCAGGGTGAGCCGTGGCCGGGCACGGTAT
+>H. Sapiens
+ACCGGTTGGCCGTTCAGGGTACAGGTTGGCCGTTCAGGGTAA
diff --git a/fastaq/tests/data/sequences_test_phylip.interleaved2 b/fastaq/tests/data/sequences_test_phylip.interleaved2
new file mode 100644
index 0000000..18e8795
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_phylip.interleaved2
@@ -0,0 +1,7 @@
+  3    42
+Turkey    AA-CTNGGGC ATTTCAGGGT
+Salmo_gairAAGCCTTGGC AGTGCAGGGT
+H. SapiensACCGGTTGGC CGTTCAGGGT
+GAGCCCGGGC AATACAGGGT AT
+GAGCCGTGGC CGGGCACGGT AT
+ACAGGTTGGC CGTTCAGGGT AA
diff --git a/fastaq/tests/data/sequences_test_phylip.interleaved2.to_fasta b/fastaq/tests/data/sequences_test_phylip.interleaved2.to_fasta
new file mode 100644
index 0000000..22dfb80
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_phylip.interleaved2.to_fasta
@@ -0,0 +1,6 @@
+>Turkey
+AACTNGGGCATTTCAGGGTGAGCCCGGGCAATACAGGGTAT
+>Salmo_gair
+AAGCCTTGGCAGTGCAGGGTGAGCCGTGGCCGGGCACGGTAT
+>H. Sapiens
+ACCGGTTGGCCGTTCAGGGTACAGGTTGGCCGTTCAGGGTAA
diff --git a/fastaq/tests/data/sequences_test_phylip.made_by_seaview b/fastaq/tests/data/sequences_test_phylip.made_by_seaview
new file mode 100644
index 0000000..3f7b0cf
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_phylip.made_by_seaview
@@ -0,0 +1,6 @@
+2   97
+seq1        GGGGGGGGGG GGGGGGGGGG GGGGGGGGGG GGGGGGGGGG GGGGGGGGGG GGGGGGGGGG
+seq2        AAAAAAAAAA AAAAAAAAAA AAAAAAAAAA AAAAAAAAAA AAAAAAAAAA AAAAAAAAAA
+
+            GGGGGGGGGG GGGGGGGGGG GGGGGGGGGG GGGGGGT
+            AAAAAAAAAA AAAAAAAAAA AAAAAAAAA- -AAAAAG
diff --git a/fastaq/tests/data/sequences_test_phylip.made_by_seaview.to_fasta b/fastaq/tests/data/sequences_test_phylip.made_by_seaview.to_fasta
new file mode 100644
index 0000000..10d8264
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_phylip.made_by_seaview.to_fasta
@@ -0,0 +1,6 @@
+>seq1
+GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG
+GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGT
+>seq2
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA
+AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAG
diff --git a/fastaq/tests/data/sequences_test_phylip.sequential b/fastaq/tests/data/sequences_test_phylip.sequential
new file mode 100644
index 0000000..e9ce346
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_phylip.sequential
@@ -0,0 +1,7 @@
+  3    42
+Turkey    AA-CTNGGGC ATTTCAGGGT
+GAGCCCGGGC AATACAGGGT AT
+Salmo_gairAAGCCTTGGC AGTGCAGGGT
+GAGCCGTGGC CGGGCACGGT AT
+H. SapiensACCGGTTGGC CGTTCAGGGT
+ACAGGTTGGC CGTTCAGGGT AA
diff --git a/fastaq/tests/data/sequences_test_phylip.sequential.to_fasta b/fastaq/tests/data/sequences_test_phylip.sequential.to_fasta
new file mode 100644
index 0000000..22dfb80
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_phylip.sequential.to_fasta
@@ -0,0 +1,6 @@
+>Turkey
+AACTNGGGCATTTCAGGGTGAGCCCGGGCAATACAGGGTAT
+>Salmo_gair
+AAGCCTTGGCAGTGCAGGGTGAGCCGTGGCCGGGCACGGTAT
+>H. Sapiens
+ACCGGTTGGCCGTTCAGGGTACAGGTTGGCCGTTCAGGGTAA
diff --git a/fastaq/tests/data/sequences_test_revcomp.fa b/fastaq/tests/data/sequences_test_revcomp.fa
new file mode 100644
index 0000000..4d9922f
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_revcomp.fa
@@ -0,0 +1,8 @@
+>1
+TACGT
+>2
+TACGT
+>3
+TACGT
+>4
+TACGT
diff --git a/fastaq/tests/data/sequences_test_search_string.fa b/fastaq/tests/data/sequences_test_search_string.fa
new file mode 100644
index 0000000..5dc3d2c
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_search_string.fa
@@ -0,0 +1,2 @@
+>seq
+AAGATCTAGAGATC
diff --git a/fastaq/tests/data/sequences_test_search_string.fa.hits b/fastaq/tests/data/sequences_test_search_string.fa.hits
new file mode 100644
index 0000000..cde92ef
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_search_string.fa.hits
@@ -0,0 +1,4 @@
+seq	2	+
+seq	8	+
+seq	10	+
+seq	5	-
diff --git a/fastaq/tests/data/sequences_test_split_fixed_size.fa b/fastaq/tests/data/sequences_test_split_fixed_size.fa
new file mode 100644
index 0000000..8b2f4c5
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_fixed_size.fa
@@ -0,0 +1,12 @@
+>seq1
+ACGTNNNNN
+>seq2
+ACGTA
+>seq3
+NNNN
+>seq4
+AC
+>seq5
+ACG
+>seq6
+A
diff --git a/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.1 b/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.1
new file mode 100644
index 0000000..a72c34d
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.1
@@ -0,0 +1,2 @@
+>seq1:1-4
+ACGT
diff --git a/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.2 b/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.2
new file mode 100644
index 0000000..6a1a218
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.2
@@ -0,0 +1,2 @@
+>seq1:5-9
+NNNNN
diff --git a/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.3 b/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.3
new file mode 100644
index 0000000..5ff6016
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.3
@@ -0,0 +1,2 @@
+>seq2
+ACGTA
diff --git a/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.4 b/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.4
new file mode 100644
index 0000000..05a52a9
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.4
@@ -0,0 +1,2 @@
+>seq3
+NNNN
diff --git a/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.5 b/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.5
new file mode 100644
index 0000000..bee7218
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.5
@@ -0,0 +1,4 @@
+>seq4
+AC
+>seq5
+ACG
diff --git a/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.6 b/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.6
new file mode 100644
index 0000000..e17b9b7
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.6
@@ -0,0 +1,2 @@
+>seq6
+A
diff --git a/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.coords b/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.coords
new file mode 100644
index 0000000..3ed2ead
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.coords
@@ -0,0 +1,2 @@
+seq1:1-4	seq1	0
+seq1:5-9	seq1	4
diff --git a/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.skip_if_all_Ns.1 b/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.skip_if_all_Ns.1
new file mode 100644
index 0000000..a72c34d
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.skip_if_all_Ns.1
@@ -0,0 +1,2 @@
+>seq1:1-4
+ACGT
diff --git a/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.skip_if_all_Ns.2 b/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.skip_if_all_Ns.2
new file mode 100644
index 0000000..5ff6016
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.skip_if_all_Ns.2
@@ -0,0 +1,2 @@
+>seq2
+ACGTA
diff --git a/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.skip_if_all_Ns.3 b/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.skip_if_all_Ns.3
new file mode 100644
index 0000000..bee7218
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.skip_if_all_Ns.3
@@ -0,0 +1,4 @@
+>seq4
+AC
+>seq5
+ACG
diff --git a/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.skip_if_all_Ns.4 b/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.skip_if_all_Ns.4
new file mode 100644
index 0000000..e17b9b7
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.skip_if_all_Ns.4
@@ -0,0 +1,2 @@
+>seq6
+A
diff --git a/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.skip_if_all_Ns.coords b/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.skip_if_all_Ns.coords
new file mode 100644
index 0000000..3934ef1
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_fixed_size.fa.split.skip_if_all_Ns.coords
@@ -0,0 +1 @@
+seq1:1-4	seq1	0
diff --git a/fastaq/tests/data/sequences_test_split_test.fa b/fastaq/tests/data/sequences_test_split_test.fa
new file mode 100644
index 0000000..7c02b44
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_test.fa
@@ -0,0 +1,8 @@
+>1
+A
+>2
+AA
+>3
+AAA
+>4
+AAAA
diff --git a/fastaq/tests/data/sequences_test_split_test.fa.2.1 b/fastaq/tests/data/sequences_test_split_test.fa.2.1
new file mode 100644
index 0000000..5e9a7fe
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_test.fa.2.1
@@ -0,0 +1,2 @@
+>1
+A
diff --git a/fastaq/tests/data/sequences_test_split_test.fa.2.2 b/fastaq/tests/data/sequences_test_split_test.fa.2.2
new file mode 100644
index 0000000..7e79b53
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_test.fa.2.2
@@ -0,0 +1,2 @@
+>2
+AA
diff --git a/fastaq/tests/data/sequences_test_split_test.fa.2.3 b/fastaq/tests/data/sequences_test_split_test.fa.2.3
new file mode 100644
index 0000000..22603c9
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_test.fa.2.3
@@ -0,0 +1,2 @@
+>3
+AAA
diff --git a/fastaq/tests/data/sequences_test_split_test.fa.2.4 b/fastaq/tests/data/sequences_test_split_test.fa.2.4
new file mode 100644
index 0000000..15e79c4
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_test.fa.2.4
@@ -0,0 +1,2 @@
+>4
+AAAA
diff --git a/fastaq/tests/data/sequences_test_split_test.fa.3.1 b/fastaq/tests/data/sequences_test_split_test.fa.3.1
new file mode 100644
index 0000000..5a17cab
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_test.fa.3.1
@@ -0,0 +1,4 @@
+>1
+A
+>2
+AA
diff --git a/fastaq/tests/data/sequences_test_split_test.fa.3.2 b/fastaq/tests/data/sequences_test_split_test.fa.3.2
new file mode 100644
index 0000000..22603c9
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_test.fa.3.2
@@ -0,0 +1,2 @@
+>3
+AAA
diff --git a/fastaq/tests/data/sequences_test_split_test.fa.3.3 b/fastaq/tests/data/sequences_test_split_test.fa.3.3
new file mode 100644
index 0000000..15e79c4
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_test.fa.3.3
@@ -0,0 +1,2 @@
+>4
+AAAA
diff --git a/fastaq/tests/data/sequences_test_split_test.fa.4.1 b/fastaq/tests/data/sequences_test_split_test.fa.4.1
new file mode 100644
index 0000000..5a17cab
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_test.fa.4.1
@@ -0,0 +1,4 @@
+>1
+A
+>2
+AA
diff --git a/fastaq/tests/data/sequences_test_split_test.fa.4.2 b/fastaq/tests/data/sequences_test_split_test.fa.4.2
new file mode 100644
index 0000000..22603c9
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_test.fa.4.2
@@ -0,0 +1,2 @@
+>3
+AAA
diff --git a/fastaq/tests/data/sequences_test_split_test.fa.4.3 b/fastaq/tests/data/sequences_test_split_test.fa.4.3
new file mode 100644
index 0000000..15e79c4
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_test.fa.4.3
@@ -0,0 +1,2 @@
+>4
+AAAA
diff --git a/fastaq/tests/data/sequences_test_split_test.fa.6.1 b/fastaq/tests/data/sequences_test_split_test.fa.6.1
new file mode 100644
index 0000000..a7fcecf
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_test.fa.6.1
@@ -0,0 +1,6 @@
+>1
+A
+>2
+AA
+>3
+AAA
diff --git a/fastaq/tests/data/sequences_test_split_test.fa.6.2 b/fastaq/tests/data/sequences_test_split_test.fa.6.2
new file mode 100644
index 0000000..15e79c4
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_test.fa.6.2
@@ -0,0 +1,2 @@
+>4
+AAAA
diff --git a/fastaq/tests/data/sequences_test_split_test.fa.6.limit2.1 b/fastaq/tests/data/sequences_test_split_test.fa.6.limit2.1
new file mode 100644
index 0000000..5a17cab
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_test.fa.6.limit2.1
@@ -0,0 +1,4 @@
+>1
+A
+>2
+AA
diff --git a/fastaq/tests/data/sequences_test_split_test.fa.6.limit2.2 b/fastaq/tests/data/sequences_test_split_test.fa.6.limit2.2
new file mode 100644
index 0000000..22603c9
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_test.fa.6.limit2.2
@@ -0,0 +1,2 @@
+>3
+AAA
diff --git a/fastaq/tests/data/sequences_test_split_test.fa.6.limit2.3 b/fastaq/tests/data/sequences_test_split_test.fa.6.limit2.3
new file mode 100644
index 0000000..15e79c4
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_test.fa.6.limit2.3
@@ -0,0 +1,2 @@
+>4
+AAAA
diff --git a/fastaq/tests/data/sequences_test_split_test.long.fa b/fastaq/tests/data/sequences_test_split_test.long.fa
new file mode 100644
index 0000000..23dad6a
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_test.long.fa
@@ -0,0 +1,4 @@
+>1
+AAAAAAAA
+>2
+AAAAAAAA
diff --git a/fastaq/tests/data/sequences_test_split_test.long.fa.2.1 b/fastaq/tests/data/sequences_test_split_test.long.fa.2.1
new file mode 100644
index 0000000..ecc99e6
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_test.long.fa.2.1
@@ -0,0 +1,2 @@
+>1
+AAAAAAAA
diff --git a/fastaq/tests/data/sequences_test_split_test.long.fa.2.2 b/fastaq/tests/data/sequences_test_split_test.long.fa.2.2
new file mode 100644
index 0000000..2a2c6a7
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_split_test.long.fa.2.2
@@ -0,0 +1,2 @@
+>2
+AAAAAAAA
diff --git a/fastaq/tests/data/sequences_test_strip_after_whitespace.fa b/fastaq/tests/data/sequences_test_strip_after_whitespace.fa
new file mode 100644
index 0000000..d394bf9
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_strip_after_whitespace.fa
@@ -0,0 +1,6 @@
+>seq 1
+ACGT
+>seq 1 2
+ACGT
+>seq
+ACGT
diff --git a/fastaq/tests/data/sequences_test_strip_after_whitespace.fa.to_fasta b/fastaq/tests/data/sequences_test_strip_after_whitespace.fa.to_fasta
new file mode 100644
index 0000000..cde7200
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_strip_after_whitespace.fa.to_fasta
@@ -0,0 +1,6 @@
+>seq
+ACGT
+>seq
+ACGT
+>seq
+ACGT
diff --git a/fastaq/tests/data/sequences_test_strip_illumina_suffix.fq b/fastaq/tests/data/sequences_test_strip_illumina_suffix.fq
new file mode 100644
index 0000000..05a65a4
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_strip_illumina_suffix.fq
@@ -0,0 +1,12 @@
+ at one/1
+A
++
+I
+ at one/2
+A
++
+I
+ at two/3
+A
++
+I
diff --git a/fastaq/tests/data/sequences_test_strip_illumina_suffix.fq.stripped b/fastaq/tests/data/sequences_test_strip_illumina_suffix.fq.stripped
new file mode 100644
index 0000000..4425cc6
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_strip_illumina_suffix.fq.stripped
@@ -0,0 +1,12 @@
+ at one
+A
++
+I
+ at one
+A
++
+I
+ at two/3
+A
++
+I
diff --git a/fastaq/tests/data/sequences_test_to_fasta_union.in.fa b/fastaq/tests/data/sequences_test_to_fasta_union.in.fa
new file mode 100644
index 0000000..922d090
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_to_fasta_union.in.fa
@@ -0,0 +1,7 @@
+>1
+AA
+A
+>2
+GGG
+>3
+TTT
diff --git a/fastaq/tests/data/sequences_test_to_fasta_union.out.fa b/fastaq/tests/data/sequences_test_to_fasta_union.out.fa
new file mode 100644
index 0000000..2f55fb2
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_to_fasta_union.out.fa
@@ -0,0 +1,2 @@
+>testname
+AAAGGGTTT
diff --git a/fastaq/tests/data/sequences_test_to_unique_by_id.fa b/fastaq/tests/data/sequences_test_to_unique_by_id.fa
new file mode 100644
index 0000000..5b486ee
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_to_unique_by_id.fa
@@ -0,0 +1,11 @@
+>seq1
+AA
+>seq2
+A
+>seq3
+A
+>seq1
+A
+>seq4
+>seq1
+AAA
diff --git a/fastaq/tests/data/sequences_test_to_unique_by_id.fa.out b/fastaq/tests/data/sequences_test_to_unique_by_id.fa.out
new file mode 100644
index 0000000..8c40ed1
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_to_unique_by_id.fa.out
@@ -0,0 +1,6 @@
+>seq1
+AAA
+>seq2
+A
+>seq3
+A
diff --git a/fastaq/tests/data/sequences_test_translate.fa b/fastaq/tests/data/sequences_test_translate.fa
new file mode 100644
index 0000000..62c5afc
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_translate.fa
@@ -0,0 +1,2 @@
+>seq
+GCAGCCGCGGCTAGAAGGCGACGCCGGCGTAACAATGACGATTGCTGTGAAGAGCAACAGGGAGGCGGGGGTCACCATATAATCATTTTATTGCTACTCCTGCTTAAAAAGATGTTCTTTCCACCCCCGCCTAGCAGTTCATCCTCGTCTACAACCACGACTTGGTACTATGTAGTCGTGGTTTAATAGTGA
diff --git a/fastaq/tests/data/sequences_test_translate.fa.frame0 b/fastaq/tests/data/sequences_test_translate.fa.frame0
new file mode 100644
index 0000000..0cdd1cf
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_translate.fa.frame0
@@ -0,0 +1,3 @@
+>seq
+AAAARRRRRRNNDDCCEEQQGGGGHHIIILLLLLLKKMFFPPPPSSSSSSTTTTWYYVVV
+V***
diff --git a/fastaq/tests/data/sequences_test_translate.fa.frame1 b/fastaq/tests/data/sequences_test_translate.fa.frame1
new file mode 100644
index 0000000..80a5aaa
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_translate.fa.frame1
@@ -0,0 +1,3 @@
+>seq
+QPRLEGDAGVTMTIAVKSNREAGVTI*SFYCYSCLKRCSFHPRLAVHPRLQPRLGTM*SW
+FNS
diff --git a/fastaq/tests/data/sequences_test_translate.fa.frame2 b/fastaq/tests/data/sequences_test_translate.fa.frame2
new file mode 100644
index 0000000..874a17d
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_translate.fa.frame2
@@ -0,0 +1,3 @@
+>seq
+SRG*KATPA*Q*RLL*RATGRRGSPYNHFIATPA*KDVLSTPA*QFILVYNHDLVLCSRG
+LIV
diff --git a/fastaq/tests/data/sequences_test_trim_Ns_at_end.fa b/fastaq/tests/data/sequences_test_trim_Ns_at_end.fa
new file mode 100644
index 0000000..752e880
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_trim_Ns_at_end.fa
@@ -0,0 +1,10 @@
+>1
+A
+>2
+nNNNNNNCNNNANNNN
+>3
+NNnA
+>4
+AnnnNn
+>5
+NNnnnNNn
diff --git a/fastaq/tests/data/sequences_test_trim_Ns_at_end.fa.trimmed b/fastaq/tests/data/sequences_test_trim_Ns_at_end.fa.trimmed
new file mode 100644
index 0000000..f9ca62c
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_trim_Ns_at_end.fa.trimmed
@@ -0,0 +1,8 @@
+>1
+A
+>2
+CNNNA
+>3
+A
+>4
+A
diff --git a/fastaq/tests/data/sequences_test_trimmed.fq b/fastaq/tests/data/sequences_test_trimmed.fq
new file mode 100644
index 0000000..ba91557
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_trimmed.fq
@@ -0,0 +1,8 @@
+ at ID
+GT
++
+II
+ at ID
+GT
++
+II
diff --git a/fastaq/tests/data/sequences_test_untrimmed.fq b/fastaq/tests/data/sequences_test_untrimmed.fq
new file mode 100644
index 0000000..349de37
--- /dev/null
+++ b/fastaq/tests/data/sequences_test_untrimmed.fq
@@ -0,0 +1,16 @@
+ at ID
+ACGTA
++
+IIIII
+ at ID
+ACGTA
++blah
+IIIII
+@
+NNN
++
+III
+@
+N
++
+I
diff --git a/fastaq/tests/data/tasks_test_expend_nucleotides.in.fa b/fastaq/tests/data/tasks_test_expend_nucleotides.in.fa
new file mode 100644
index 0000000..55d2ad3
--- /dev/null
+++ b/fastaq/tests/data/tasks_test_expend_nucleotides.in.fa
@@ -0,0 +1,4 @@
+>1
+A
+>2
+ART
diff --git a/fastaq/tests/data/tasks_test_expend_nucleotides.in.fq b/fastaq/tests/data/tasks_test_expend_nucleotides.in.fq
new file mode 100644
index 0000000..4aaf860
--- /dev/null
+++ b/fastaq/tests/data/tasks_test_expend_nucleotides.in.fq
@@ -0,0 +1,8 @@
+ at 1
+A
++
+I
+ at 2
+ART
++
+HIG
diff --git a/fastaq/tests/data/tasks_test_expend_nucleotides.out.fa b/fastaq/tests/data/tasks_test_expend_nucleotides.out.fa
new file mode 100644
index 0000000..9d7b593
--- /dev/null
+++ b/fastaq/tests/data/tasks_test_expend_nucleotides.out.fa
@@ -0,0 +1,6 @@
+>1
+A
+>2.1
+AAT
+>2.2
+AGT
diff --git a/fastaq/tests/data/tasks_test_expend_nucleotides.out.fq b/fastaq/tests/data/tasks_test_expend_nucleotides.out.fq
new file mode 100644
index 0000000..97090c1
--- /dev/null
+++ b/fastaq/tests/data/tasks_test_expend_nucleotides.out.fq
@@ -0,0 +1,12 @@
+ at 1
+A
++
+I
+ at 2.1
+AAT
++
+HIG
+ at 2.2
+AGT
++
+HIG
diff --git a/fastaq/tests/data/tasks_test_fasta_to_fake_qual.in.fa b/fastaq/tests/data/tasks_test_fasta_to_fake_qual.in.fa
new file mode 100644
index 0000000..56c943a
--- /dev/null
+++ b/fastaq/tests/data/tasks_test_fasta_to_fake_qual.in.fa
@@ -0,0 +1,5 @@
+>1
+CATTCATGATGCAGTCATCGATGCATGATGCATGCATGCATGCTGCAGTCAGTCATGCAA
+TC
+>2
+CATGT
diff --git a/fastaq/tests/data/tasks_test_fasta_to_fake_qual.out.default.qual b/fastaq/tests/data/tasks_test_fasta_to_fake_qual.out.default.qual
new file mode 100644
index 0000000..0420243
--- /dev/null
+++ b/fastaq/tests/data/tasks_test_fasta_to_fake_qual.out.default.qual
@@ -0,0 +1,5 @@
+>1
+40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40 40
+40 40
+>2
+40 40 40 40 40
diff --git a/fastaq/tests/data/tasks_test_fasta_to_fake_qual.out.q42.qual b/fastaq/tests/data/tasks_test_fasta_to_fake_qual.out.q42.qual
new file mode 100644
index 0000000..196a1d8
--- /dev/null
+++ b/fastaq/tests/data/tasks_test_fasta_to_fake_qual.out.q42.qual
@@ -0,0 +1,5 @@
+>1
+42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42 42
+42 42
+>2
+42 42 42 42 42
diff --git a/fastaq/tests/data/tasks_test_make_long_reads.input.fa b/fastaq/tests/data/tasks_test_make_long_reads.input.fa
new file mode 100644
index 0000000..e4862bc
--- /dev/null
+++ b/fastaq/tests/data/tasks_test_make_long_reads.input.fa
@@ -0,0 +1,2 @@
+>1
+ACGCTCTCGAGCGCGAGCGCGAGCGAC
diff --git a/fastaq/tests/data/tasks_test_make_long_reads.output.fa b/fastaq/tests/data/tasks_test_make_long_reads.output.fa
new file mode 100644
index 0000000..09ab3b0
--- /dev/null
+++ b/fastaq/tests/data/tasks_test_make_long_reads.output.fa
@@ -0,0 +1,10 @@
+>1_1_10
+ACGCTCTCGA
+>1_6_15
+CTCGAGCGCG
+>1_11_20
+GCGCGAGCGC
+>1_16_25
+AGCGCGAGCG
+>1_21_27
+GAGCGAC
diff --git a/fastaq/tests/data/tasks_test_sequence_trim_1.fa b/fastaq/tests/data/tasks_test_sequence_trim_1.fa
new file mode 100644
index 0000000..28f665b
--- /dev/null
+++ b/fastaq/tests/data/tasks_test_sequence_trim_1.fa
@@ -0,0 +1,12 @@
+>1/1
+TRIM1GCTCGAGCT
+>2/1
+TRIM1AGCTAGCTAG
+>3/1
+CGCTAGCTAG
+>4/1
+TRIM2AGCTAGCTAG
+>5/1
+AGCTAGCTAG
+>6/1
+TRIM4AGCTAGCTAG
diff --git a/fastaq/tests/data/tasks_test_sequence_trim_1.trimmed.fa b/fastaq/tests/data/tasks_test_sequence_trim_1.trimmed.fa
new file mode 100644
index 0000000..0bebad8
--- /dev/null
+++ b/fastaq/tests/data/tasks_test_sequence_trim_1.trimmed.fa
@@ -0,0 +1,8 @@
+>3/1
+CGCTAGCTAG
+>4/1
+AGCTAGCTAG
+>5/1
+AGCTAGCTAG
+>6/1
+AGCTAGCTAG
diff --git a/fastaq/tests/data/tasks_test_sequence_trim_2.fa b/fastaq/tests/data/tasks_test_sequence_trim_2.fa
new file mode 100644
index 0000000..7514250
--- /dev/null
+++ b/fastaq/tests/data/tasks_test_sequence_trim_2.fa
@@ -0,0 +1,12 @@
+>1/2
+TRIM1ACGTACGTAC
+>2/2
+TRIM2ACGTAGTGA
+>3/2
+ACGCTGCAGTCAGTCAGTAT
+>4/2
+TRIM3CGATCGATCG
+>5/2
+TRIM3CGATCGATCG
+>6/2
+CGATCGATCG
diff --git a/fastaq/tests/data/tasks_test_sequence_trim_2.trimmed.fa b/fastaq/tests/data/tasks_test_sequence_trim_2.trimmed.fa
new file mode 100644
index 0000000..ec80f40
--- /dev/null
+++ b/fastaq/tests/data/tasks_test_sequence_trim_2.trimmed.fa
@@ -0,0 +1,8 @@
+>3/2
+ACGCTGCAGTCAGTCAGTAT
+>4/2
+CGATCGATCG
+>5/2
+CGATCGATCG
+>6/2
+CGATCGATCG
diff --git a/fastaq/tests/data/tasks_test_sequences_to_trim.fa b/fastaq/tests/data/tasks_test_sequences_to_trim.fa
new file mode 100644
index 0000000..395eaaa
--- /dev/null
+++ b/fastaq/tests/data/tasks_test_sequences_to_trim.fa
@@ -0,0 +1,8 @@
+>1
+TRIM1
+>2
+TRIM2
+>3
+TRIM3
+>4
+TRIM4
diff --git a/fastaq/tests/data/utils_test_file_transpose.txt b/fastaq/tests/data/utils_test_file_transpose.txt
new file mode 100644
index 0000000..1661a3c
--- /dev/null
+++ b/fastaq/tests/data/utils_test_file_transpose.txt
@@ -0,0 +1,5 @@
+11	12	13
+21	22	23
+31	32	33
+41	42
+51	52	53
diff --git a/fastaq/tests/data/utils_test_file_transposed.txt b/fastaq/tests/data/utils_test_file_transposed.txt
new file mode 100644
index 0000000..8af3080
--- /dev/null
+++ b/fastaq/tests/data/utils_test_file_transposed.txt
@@ -0,0 +1,3 @@
+11	21	31	41	51
+12	22	32	42	52
+13	23	33	.	53
diff --git a/fastaq/tests/data/utils_test_not_really_zipped.gz b/fastaq/tests/data/utils_test_not_really_zipped.gz
new file mode 100644
index 0000000..d81cc07
--- /dev/null
+++ b/fastaq/tests/data/utils_test_not_really_zipped.gz
@@ -0,0 +1 @@
+42
diff --git a/fastaq/tests/data/utils_test_scaffolds.fa b/fastaq/tests/data/utils_test_scaffolds.fa
new file mode 100644
index 0000000..5c1b14b
--- /dev/null
+++ b/fastaq/tests/data/utils_test_scaffolds.fa
@@ -0,0 +1,8 @@
+>scaf1
+ACGT
+>scaf2
+ACNNNGTNA
+>scaf3
+NNAAAANNN
+>scaf4
+NNNNNNN
diff --git a/fastaq/tests/data/utils_test_scaffolds.fa.to_contigs.fa b/fastaq/tests/data/utils_test_scaffolds.fa.to_contigs.fa
new file mode 100644
index 0000000..a599ad2
--- /dev/null
+++ b/fastaq/tests/data/utils_test_scaffolds.fa.to_contigs.fa
@@ -0,0 +1,10 @@
+>scaf1.1.4
+ACGT
+>scaf2.1.2
+AC
+>scaf2.6.7
+GT
+>scaf2.9.9
+A
+>scaf3.3.6
+AAAA
diff --git a/fastaq/tests/data/utils_test_scaffolds.fa.to_contigs.number_contigs.fa b/fastaq/tests/data/utils_test_scaffolds.fa.to_contigs.number_contigs.fa
new file mode 100644
index 0000000..412e4bd
--- /dev/null
+++ b/fastaq/tests/data/utils_test_scaffolds.fa.to_contigs.number_contigs.fa
@@ -0,0 +1,10 @@
+>scaf1.1
+ACGT
+>scaf2.1
+AC
+>scaf2.2
+GT
+>scaf2.3
+A
+>scaf3.1
+AAAA
diff --git a/fastaq/tests/data/utils_test_system_call.txt b/fastaq/tests/data/utils_test_system_call.txt
new file mode 100644
index 0000000..f5b2b3b
--- /dev/null
+++ b/fastaq/tests/data/utils_test_system_call.txt
@@ -0,0 +1 @@
+this is the contents of system call test file
diff --git a/fastaq/tests/intervals_test.py b/fastaq/tests/intervals_test.py
new file mode 100644
index 0000000..c6282a0
--- /dev/null
+++ b/fastaq/tests/intervals_test.py
@@ -0,0 +1,212 @@
+#!/usr/bin/env python3
+
+import unittest
+from fastaq import intervals
+
+class TestIntervals(unittest.TestCase):
+    def test_init(self):
+        '''Throw error if try to construct genome_interval from a non-int, or end<start'''
+        with self.assertRaises(intervals.Error):
+            intervals.Interval('a', 1)
+        with self.assertRaises(intervals.Error):
+            intervals.Interval(1, 'a')
+        with self.assertRaises(intervals.Error):
+            intervals.Interval('a', 'a')
+        with self.assertRaises(intervals.Error):
+            intervals.Interval(3, 2)
+
+    def test_comparisons(self):
+        '''<, <=, == should work as expected'''
+        self.assertTrue(intervals.Interval(1,2) < intervals.Interval(2,2))
+        self.assertTrue(intervals.Interval(1,2) <= intervals.Interval(2,2))
+        self.assertFalse(intervals.Interval(2,2) <= intervals.Interval(1,2))
+        self.assertFalse(intervals.Interval(2,2) < intervals.Interval(1,2))
+        self.assertFalse(intervals.Interval(2,2) < intervals.Interval(2,2))
+        self.assertTrue(intervals.Interval(1,2) == intervals.Interval(1,2))
+        self.assertFalse(intervals.Interval(1,2) == intervals.Interval(1,3))
+        self.assertTrue(intervals.Interval(1,2) != intervals.Interval(1,3))
+        self.assertFalse(intervals.Interval(1,2) != intervals.Interval(1,2))
+
+    def test_len(self):
+        self.assertEqual(len(intervals.Interval(1,2)), 2)
+        self.assertEqual(len(intervals.Interval(1,1)), 1)
+        self.assertEqual(len(intervals.Interval(10,20)), 11)
+
+    def test_intersects(self):
+        '''Intersection of two intervals should do the right thing'''
+        a = intervals.Interval(5, 10)
+        no_intersect = [intervals.Interval(3, 4),
+                        intervals.Interval(11,20)]
+        intersect = [intervals.Interval(3,5),
+                     intervals.Interval(3,6),
+                     intervals.Interval(9,12),
+                     intervals.Interval(10,12),
+                     intervals.Interval(6,7),
+                     intervals.Interval(1,20)]
+
+        for i in no_intersect:
+            self.assertFalse(a.intersects(i), 'shouldn\'t intersect: ' + str(a) + ', ' + str(i))
+
+        for i in intersect:
+            self.assertTrue(a.intersects(i), 'should intersect: ' + str(a) + ', ' + str(i))
+
+    def test_contains(self):
+        '''Check that contains() works as expected'''
+        a = intervals.Interval(5, 10)
+        not_contained = [intervals.Interval(1,2),
+                         intervals.Interval(4,5),
+                         intervals.Interval(4,10),
+                         intervals.Interval(4,11),
+                         intervals.Interval(5,11),
+                         intervals.Interval(1,2),
+                         intervals.Interval(9,11),
+                         intervals.Interval(10,11),
+                         intervals.Interval(11,20)]
+
+
+        contained = [intervals.Interval(5,5),
+                     intervals.Interval(5,10),
+                     intervals.Interval(6,7),
+                     intervals.Interval(6,10),
+                     intervals.Interval(10,10)]
+
+        for i in not_contained:
+            self.assertFalse(a.contains(i), 'shouldn\'t contain: ' + str(a) + ', ' + str(i))
+
+        for i in contained:
+            self.assertTrue(a.contains(i), 'should contain: ' + str(a) + ', ' + str(i))
+
+    def test_union(self):
+        '''Union should either return None or the correct union'''
+        a = intervals.Interval(5, 10)
+        b = intervals.Interval(8, 15)
+        c = intervals.Interval(12, 20)
+        d = intervals.Interval(21,22)
+        self.assertEqual(a.union(c), None)
+        self.assertEqual(c.union(a), None)
+        self.assertEqual(a.union(b), intervals.Interval(5,15))
+        self.assertEqual(b.union(a), intervals.Interval(5,15))
+        self.assertEqual(c.union(d), intervals.Interval(12,22))
+        self.assertEqual(d.union(c), intervals.Interval(12,22))
+
+    def test_union_flll_gap(self):
+        '''union_fill_gap() should ignore intersections and return the maximum range of coords'''
+        a = intervals.Interval(5, 10)
+        b = intervals.Interval(8, 15)
+        c = intervals.Interval(12, 20)
+        d = intervals.Interval(21,22)
+        self.assertEqual(a.union_fill_gap(c), intervals.Interval(5,20))
+        self.assertEqual(c.union_fill_gap(a), intervals.Interval(5,20))
+        self.assertEqual(a.union_fill_gap(b), intervals.Interval(5,15))
+        self.assertEqual(b.union_fill_gap(a), intervals.Interval(5,15))
+        self.assertEqual(c.union_fill_gap(d), intervals.Interval(12,22))
+        self.assertEqual(d.union_fill_gap(c), intervals.Interval(12,22))
+
+
+    def test_intersection(self):
+        '''Intersection should either return None or the correct intersection'''
+        a = intervals.Interval(5, 10)
+        b = intervals.Interval(8, 15)
+        c = intervals.Interval(12, 20)
+        self.assertEqual(a.intersection(c), None)
+        self.assertEqual(a.intersection(b), intervals.Interval(8,10))
+
+class Test_intersection(unittest.TestCase):
+    def test_intersection(self):
+        '''intersection() should correctly intersect two lists of intervals'''
+        a = [intervals.Interval(1,2),
+             intervals.Interval(10,20),
+             intervals.Interval(51,52),
+             intervals.Interval(54,55),
+             intervals.Interval(57,58)]
+
+        b = [intervals.Interval(5,6),
+             intervals.Interval(9,11),
+             intervals.Interval(13,14),
+             intervals.Interval(17,18),
+             intervals.Interval(20,25),
+             intervals.Interval(50,60)]
+
+        c = [intervals.Interval(100,200)]
+
+        i = [intervals.Interval(10,11),
+             intervals.Interval(13,14),
+             intervals.Interval(17,18),
+             intervals.Interval(20,20),
+             intervals.Interval(51,52),
+             intervals.Interval(54,55),
+             intervals.Interval(57,58)]
+
+        self.assertSequenceEqual(intervals.intersection(a,b), i)
+        self.assertSequenceEqual(intervals.intersection(b,a), i)
+        self.assertSequenceEqual(intervals.intersection(c,a), [])
+        self.assertEqual(intervals.intersection([],a), [])
+        self.assertEqual(intervals.intersection(a,[]), [])
+
+class Test_merge_overlapping_in_list(unittest.TestCase):
+    def test_merge_overlapping_in_list(self):
+        '''merge_overlapping_in_list() merges correctly'''
+        a = [intervals.Interval(1,2),
+             intervals.Interval(51,60),
+             intervals.Interval(10,20),
+             intervals.Interval(20,30),
+             intervals.Interval(20,30),
+             intervals.Interval(29,50),
+             intervals.Interval(65,70)]
+
+        b = [intervals.Interval(1,2),
+             intervals.Interval(10,60),
+             intervals.Interval(65,70)]
+
+        intervals.merge_overlapping_in_list(a)
+        self.assertSequenceEqual(a, b)
+
+class Test_remove_contained_in_list(unittest.TestCase):
+    def test_remove_contained_in_list(self):
+        '''test_remove_contained_in_list removes the right elements of list'''
+        a = [intervals.Interval(1,2),
+             intervals.Interval(4,4),
+             intervals.Interval(4,5),
+             intervals.Interval(5,6),
+             intervals.Interval(7,9),
+             intervals.Interval(8,10),
+             intervals.Interval(9,11),
+             intervals.Interval(20,25),
+             intervals.Interval(20,24),
+             intervals.Interval(20,26),
+             intervals.Interval(30,38),
+             intervals.Interval(30,37),
+             intervals.Interval(30,36),
+             intervals.Interval(30,35),
+             intervals.Interval(30,35),
+             intervals.Interval(32,33),
+             intervals.Interval(38,50),
+             intervals.Interval(65,70),
+             intervals.Interval(67,70)]
+
+        b = [intervals.Interval(1,2),
+             intervals.Interval(4,5),
+             intervals.Interval(5,6),
+             intervals.Interval(7,9),
+             intervals.Interval(8,10),
+             intervals.Interval(9,11),
+             intervals.Interval(20,26),
+             intervals.Interval(30,38),
+             intervals.Interval(38,50),
+             intervals.Interval(65,70)]
+
+        intervals.remove_contained_in_list(a)
+        self.assertSequenceEqual(a, b)
+
+class Test_length_sum_from_list(unittest.TestCase):
+    def test_length_sum_from_list(self):
+        '''Test that total length of intervals is summed correctly'''
+        a = [intervals.Interval(1,2),
+             intervals.Interval(4,5),
+             intervals.Interval(10,19)]
+
+        self.assertEqual(14, intervals.length_sum_from_list(a))
+
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/fastaq/tests/sequences_test.py b/fastaq/tests/sequences_test.py
new file mode 100644
index 0000000..fad6098
--- /dev/null
+++ b/fastaq/tests/sequences_test.py
@@ -0,0 +1,656 @@
+#!/usr/bin/env python3
+
+import sys
+import filecmp
+import os
+import unittest
+from fastaq import sequences, utils, intervals, tasks
+
+modules_dir = os.path.dirname(os.path.abspath(sequences.__file__))
+data_dir = os.path.join(modules_dir, 'tests', 'data')
+
+class Error (Exception): pass
+
+expected_embl = [
+    'aaacaaaccaaatatggattttattgtagccatatttgctctgtttgttattagctcattcacaattacttccacaaatgcagttgaagcttctactcttcttgacataggtaacctgagtcggagcagttttcctcgtggcttcatctttggtgctggatcttcagcataccaatttgaaggtgcagtaaacgaaggcggtagaggaccaagtatttgggataccttcacccataaatatccagaaaaaataagggatggaagcaatgcagacatcacggttgaccaatatcaccgctacaaggaagatgttgggattatgaaggatcaaaatatggattcgtatagattctcaatctcttggccaagaatactcccaaagggaaagttgagcggaggcataaatcacgaaggaatcaaatattacaacaaccttatcaacgaactattggctaacggtatacaaccatttgtaactctttttcat [...]
+    'aaacaaaccaaatatggattttattgtagccatatttgctctgtttgttattagctcattcacaattacttccacaaatgcagttgaagcttctactcttcttgacataggtaacctgagtcggagcagttttcctcgtggcttcatctttggtgctggatcttcagcataccaatttgaaggtgcagtaaacgaaggcggtagaggaccaagtatttgggataccttcacccataaatatccagaaaaaataagggatggaagcaatgcagacatcacggttgaccaatatcaccgctacaaggaagatgttgggattatgaaggatcaaaatatggattcgtatagattctcaatctcttggccaagaatactcccaaagggaaagttgagcggaggcataaatcacgaaggaatcaaatattacaacaaccttatcaacgaactattggctaacggtatacaaccatttgtaactctttttcat [...]
+]
+class TestFasta(unittest.TestCase):
+    def setUp(self):
+        self.fasta = sequences.Fasta('ID', 'ACGTA')
+
+    def test_equality(self):
+        self.assertTrue(self.fasta == sequences.Fasta('ID', 'ACGTA'))
+        self.assertFalse(self.fasta == sequences.Fasta('I', 'ACGTA'))
+        self.assertFalse(self.fasta == sequences.Fasta('ID', 'ACGT'))
+        self.assertFalse(self.fasta != sequences.Fasta('ID', 'ACGTA'))
+        self.assertTrue(self.fasta != sequences.Fasta('I', 'ACGTA'))
+        self.assertTrue(self.fasta != sequences.Fasta('ID', 'ACGT'))
+
+    def test_init(self):
+        '''__init__ should get the ID and sequence correctly'''
+        self.assertEqual(self.fasta.id, 'ID')
+        self.assertEqual(self.fasta.seq, 'ACGTA')
+
+    def test_get_next_from_file(self):
+        '''get_next_from_file() should read seqs from OK, including weirdness in file'''
+        f_in = utils.open_file_read(os.path.join(data_dir, 'sequences_test.fa'))
+        fa = sequences.Fasta()
+        counter = 1
+
+        while fa.get_next_from_file(f_in):
+            self.assertEqual(fa, sequences.Fasta(str(counter), 'ACGTA'))
+            counter += 1
+
+        utils.close(f_in)
+
+    def test_get_id_from_header_line(self):
+        '''Check that can get ID from header line or die properly'''
+        self.assertEqual(sequences.Fasta._get_id_from_header_line(self.fasta, '>X'), 'X')
+        with self.assertRaises(sequences.Error):
+            self.assertEqual(sequences.Fasta._get_id_from_header_line(self.fasta, 'X'), 'X')
+
+    def test_getitem(self):
+        '''getitem() should return the right subsequence'''
+        seq = 'AACGTGTCA'
+        fa = sequences.Fasta('x', seq)
+        self.assertEqual(seq[1], fa[1])
+        self.assertEqual(seq[0:2], fa[0:2])
+        self.assertEqual(seq[1:], fa[1:])
+
+    def test_len(self):
+        '''len() should return the length of the sequence'''
+        self.assertEqual(5, len(self.fasta))
+
+    def test_print_line_length(self):
+        '''__str__ should be formatted correctly with the right number of chars per line of sequence'''
+        line_lengths = [0, 3]
+        correct_files = [os.path.join(data_dir, x) for x in ['sequences_test_one-per-line.fa', 'sequences_test_3-per-line.fa']]
+
+        for i in range(len(line_lengths)):
+            seq_reader = sequences.file_reader(os.path.join(data_dir, 'sequences_test_one-per-line.fa'))
+            sequences.Fasta.line_length = line_lengths[i]
+            tmp_out = 'tmp.line_length_test.fa'
+            f = utils.open_file_write(tmp_out)
+            for s in seq_reader:
+                print(s, file=f)
+            utils.close(f)
+            self.assertTrue(filecmp.cmp(correct_files[i], tmp_out))
+            os.unlink(tmp_out)
+
+        sequences.Fasta.line_length = 60
+
+    def test_strip_after_first_whitespace(self):
+        '''Test strip_after_first_whitespace()'''
+        seqs = [
+            sequences.Fasta('name', 'A'),
+            sequences.Fasta('name foo', 'A'),
+            sequences.Fasta('name foo bar', 'A'),
+            sequences.Fasta('name\tfoo', 'A'),
+        ]
+
+        for seq in seqs:
+            seq.strip_after_first_whitespace()
+
+        for seq in seqs:
+            self.assertEqual(seq.id, 'name')
+
+    def test_strip_illumina_suffix(self):
+        '''Check that /1 and /2 removed correctly from IDs'''
+        seqs = [sequences.Fasta('name/1', 'A'),
+                sequences.Fasta('name/2', 'A'),
+                sequences.Fasta('name', 'A'),
+                sequences.Fasta('name/1/2', 'A'),
+                sequences.Fasta('name/2/1', 'A'),
+                sequences.Fasta('name/3', 'A')]
+
+        correct_names = ['name', 'name', 'name', 'name/1', 'name/2', 'name/3']
+
+        for seq in seqs:
+            seq.strip_illumina_suffix()
+
+        for i in range(len(seqs)):
+            self.assertEqual(seqs[i].id, correct_names[i])
+
+    def test_revcomp(self):
+        '''revcomp() should correctly reverse complement a sequence'''
+        fa = sequences.Fasta('ID', 'ACGTNacgtn')
+        fa.revcomp()
+        self.assertEqual(fa, sequences.Fasta('ID', 'nacgtNACGT'))
+
+    def test_gaps(self):
+        '''gaps() should find the gaps in a sequence correctly'''
+        test_seqs = [sequences.Fasta('ID', 'ACGT'),
+                     sequences.Fasta('ID', 'NACGT'),
+                     sequences.Fasta('ID', 'NACGTN'),
+                     sequences.Fasta('ID', 'ANNCGT'),
+                     sequences.Fasta('ID', 'NANNCGTNN')]
+
+        correct_gaps = [[],
+                        [intervals.Interval(0, 0)],
+                        [intervals.Interval(0, 0), intervals.Interval(5, 5)],
+                        [intervals.Interval(1, 2)],
+                        [intervals.Interval(0, 0), intervals.Interval(2, 3), intervals.Interval(7, 8)]]
+
+        for i in range(len(test_seqs)):
+            gaps = test_seqs[i].gaps()
+            self.assertListEqual(correct_gaps[i], gaps)
+
+    def test_contig_coords(self):
+        '''contig_coords() should get the coords of all contigs in a sequence correctly'''
+        test_seqs = [sequences.Fasta('ID', 'ACGT'),
+                     sequences.Fasta('ID', 'NACGT'),
+                     sequences.Fasta('ID', 'NNACGT'),
+                     sequences.Fasta('ID', 'ACGTN'),
+                     sequences.Fasta('ID', 'ACGTNN'),
+                     sequences.Fasta('ID', 'NANNCGT'),
+                     sequences.Fasta('ID', 'ACNNNGTNA'),
+                     sequences.Fasta('ID', 'ANNCGTNNAAAAA')]
+
+        correct_coords = [[intervals.Interval(0,3)],
+                         [intervals.Interval(1, 4)],
+                         [intervals.Interval(2, 5)],
+                         [intervals.Interval(0, 3)],
+                         [intervals.Interval(0, 3)],
+                         [intervals.Interval(1, 1), intervals.Interval(4,6)],
+                         [intervals.Interval(0, 1), intervals.Interval(5, 6), intervals.Interval(8, 8)],
+                         [intervals.Interval(0, 0), intervals.Interval(3, 5), intervals.Interval(8, 12)]]
+
+        for i in range(len(test_seqs)):
+            gaps = test_seqs[i].contig_coords()
+            self.assertListEqual(correct_coords[i], gaps)
+
+
+
+
+    def test_orfs(self):
+        '''Test orfs()'''
+        test_seqs = [(sequences.Fasta('ID', 'AAACCCGG'), 0, False, [intervals.Interval(0,5)]),
+                     (sequences.Fasta('ID', 'AAAACCCGG'), 1, False, [intervals.Interval(1,6)]),
+                     (sequences.Fasta('ID', 'AAAAACCCGG'), 2, False, [intervals.Interval(2,7)]),
+                     (sequences.Fasta('ID', 'CCGGGTTT'), 0, True, [intervals.Interval(2,7)]),
+                     (sequences.Fasta('ID', 'CCGGGTTTT'), 1, True, [intervals.Interval(2,7)]),
+                     (sequences.Fasta('ID', 'CCGGGTTTTT'), 2, True, [intervals.Interval(2,7)]),
+                     (sequences.Fasta('ID', 'AAACCCTGA'), 0, False, [intervals.Interval(0,8)]),
+                     (sequences.Fasta('ID', 'AAACCCTGATAG'), 0, False, [intervals.Interval(0,8)]),
+                     (sequences.Fasta('ID', 'AAACCCTGA'), 1, False, [intervals.Interval(1,6)]),
+                     (sequences.Fasta('ID', ''), 0, False, []),
+                     (sequences.Fasta('ID', 'A'), 0, False, []),
+                     (sequences.Fasta('ID', 'AA'), 0, False, []),
+                     (sequences.Fasta('ID', 'AAA'), 0, False, [intervals.Interval(0,2)]),
+                     (sequences.Fasta('ID', 'AAAAAA'), 0, False, [intervals.Interval(0,5)]),
+                     (sequences.Fasta('ID', 'AAA'), 1, False, []),
+                     (sequences.Fasta('ID', 'AAA'), 2, False, []),
+                     (sequences.Fasta('ID', 'AAA'), 0, True, [intervals.Interval(0,2)]),
+                     (sequences.Fasta('ID', 'AAA'), 1, True, []),
+                     (sequences.Fasta('ID', 'AAA'), 2, True, []),
+                     (sequences.Fasta('ID', 'TAA'), 0, False, []),
+                     (sequences.Fasta('ID', 'CTA'), 0, True, [])]
+
+
+        for t in test_seqs:
+            orfs = t[0].orfs(frame=t[1], revcomp=t[2])
+            self.assertListEqual(orfs, t[3])
+
+    def test_all_orfs(self):
+        '''Test all_orfs()'''
+        d = {}
+        tasks.file_to_dict(os.path.join(data_dir, 'sequences_test_orfs.fa'), d)
+        seq = d['1']
+        orfs = seq.all_orfs(min_length=120)
+        expected = [
+            (intervals.Interval(27, 221), False),
+            (intervals.Interval(44, 226), False),
+            (intervals.Interval(48, 170), True),
+            (intervals.Interval(109, 240), False),
+            (intervals.Interval(143, 265), True),
+            (intervals.Interval(227, 421), False),
+            (intervals.Interval(277, 432), True),
+            (intervals.Interval(286, 477), False),
+            (intervals.Interval(288, 518), True),
+            (intervals.Interval(562, 702), False),
+            (intervals.Interval(600, 758), False),
+            (intervals.Interval(605, 817), False),
+            (intervals.Interval(818, 937), False),
+            (intervals.Interval(835, 987), False),
+            (intervals.Interval(864, 998), False)
+        ]
+
+        self.assertEqual(len(orfs), len(expected))
+
+        for i in range(len(orfs)):
+            print(orfs[i][0], expected[i][0])
+            self.assertEqual(orfs[i][0], expected[i][0])
+            self.assertEqual(orfs[i][1], expected[i][1])
+
+
+    def test_is_all_Ns(self):
+        '''Test is_all_Ns()'''
+        self.assertTrue(sequences.Fasta('ID', 'n').is_all_Ns())
+        self.assertTrue(sequences.Fasta('ID', 'N').is_all_Ns())
+        self.assertTrue(sequences.Fasta('ID', 'nNn').is_all_Ns())
+        self.assertFalse(sequences.Fasta('ID', 'a').is_all_Ns())
+        self.assertFalse(sequences.Fasta('ID', '').is_all_Ns())
+        self.assertFalse(sequences.Fasta('ID', 'anNg').is_all_Ns())
+        self.assertFalse(sequences.Fasta('ID', 'naN').is_all_Ns())
+        self.assertFalse(sequences.Fasta('ID', 'anNg').is_all_Ns(start=0, end=0))
+        self.assertFalse(sequences.Fasta('ID', 'anNg').is_all_Ns(start=0, end=1))
+        self.assertTrue(sequences.Fasta('ID', 'anNg').is_all_Ns(start=1, end=1))
+        self.assertTrue(sequences.Fasta('ID', 'anNg').is_all_Ns(start=1, end=2))
+        self.assertFalse(sequences.Fasta('ID', 'anNg').is_all_Ns(start=1))
+        self.assertTrue(sequences.Fasta('ID', 'anN').is_all_Ns(start=1))
+        self.assertFalse(sequences.Fasta('ID', 'anNg').is_all_Ns(end=1))
+        self.assertTrue(sequences.Fasta('ID', 'nNA').is_all_Ns(end=1))
+
+        with self.assertRaises(sequences.Error):
+            sequences.Fasta('ID', 'anNg').is_all_Ns(start=1, end=0)
+
+    def test_trim_Ns(self):
+        '''trim_Ns() should do the right trimming of a sequence'''
+        fa = sequences.Fasta('ID', 'ANNANA')
+        test_seqs = [sequences.Fasta('ID', 'ANNANA'),
+                     sequences.Fasta('ID', 'NANNANA'),
+                     sequences.Fasta('ID', 'NANNANAN'),
+                     sequences.Fasta('ID', 'ANNANAN'),
+                     sequences.Fasta('ID', 'NNNNNNANNANAN'),
+                     sequences.Fasta('ID', 'NNANNANANn')]
+
+        for s in test_seqs:
+            s.trim_Ns()
+            self.assertEqual(fa, s)
+
+    def test_add_insertions(self):
+        '''Test add_insertions'''
+        fa = sequences.Fasta('X', 'acgtacgtacgt')
+        fa.add_insertions(skip=4, window=0, test=True)
+        self.assertEqual(fa, sequences.Fasta('X', 'acgtNacgtNacgt'))
+
+    def test_replace_bases(self):
+        '''Check that bases get replaced correctly'''
+        fa = sequences.Fasta('X', 'AUCGTUUACT')
+        fa.replace_bases('U', 'T')
+        self.assertEqual(fa, sequences.Fasta('X', 'ATCGTTTACT'))
+
+    def test_replace_interval(self):
+        '''Test replace_interval()'''
+        fa = sequences.Fasta('ID', 'ACGTA')
+        fa.replace_interval(0, 0, 'NEW')
+        self.assertEqual(fa, sequences.Fasta('ID', 'NEWCGTA'))
+
+        fa = sequences.Fasta('ID', 'ACGTA')
+        fa.replace_interval(4, 4, 'NEW')
+        self.assertEqual(fa, sequences.Fasta('ID', 'ACGTNEW'))
+
+        fa = sequences.Fasta('ID', 'ACGTA')
+        fa.replace_interval(2, 3, 'NEW')
+        self.assertEqual(fa, sequences.Fasta('ID', 'ACNEWA'))
+
+        fa = sequences.Fasta('ID', 'ACGTA')
+        with self.assertRaises(sequences.Error):
+            fa.replace_interval(3,2,'x')
+        with self.assertRaises(sequences.Error):
+            fa.replace_interval(1,5,'x')
+        with self.assertRaises(sequences.Error):
+            fa.replace_interval(5,10,'x')
+
+        fq = sequences.Fastq('ID', 'ACGTA', 'ABCDE')
+        fq.replace_interval(0, 0, 'NEW', 'III')
+        self.assertEqual(fq, sequences.Fastq('ID', 'NEWCGTA', 'IIIBCDE'))
+
+        fq = sequences.Fastq('ID', 'ACGTA', 'ABCDE')
+        fq.replace_interval(4, 4, 'NEW', 'III')
+        self.assertEqual(fq, sequences.Fastq('ID', 'ACGTNEW', 'ABCDIII'))
+
+        fq = sequences.Fastq('ID', 'ACGTA', 'ABCDE')
+        fq.replace_interval(2, 3, 'NEW', 'III')
+        self.assertEqual(fq, sequences.Fastq('ID', 'ACNEWA', 'ABIIIE'))
+
+        with self.assertRaises(sequences.Error):
+            fq.replace_interval(1,1,'x', 'xx')
+
+    def test_search_string(self):
+        '''Check that search_string() finds all the hits'''
+        fa = sequences.Fasta('X', 'AAA')
+        hits = fa.search('G')
+        self.assertTrue(len(hits) == 0)
+        hits = fa.search('AAA')
+        self.assertListEqual(hits, [(0, '+')])
+        hits = fa.search('AA')
+        self.assertListEqual(hits, [(0, '+'), (1, '+')])
+        hits = fa.search('TTT')
+        self.assertListEqual(hits, [(0, '-')])
+
+    def test_to_Fastq(self):
+        '''Check to_Fastq converts OK, including out of range quality scores'''
+        fa = sequences.Fasta('X', 'AAAAA')
+        quals = [-1, 0, 40, 93, 94]
+        self.assertEqual(sequences.Fastq('X', 'AAAAA', '!!I~~'), fa.to_Fastq(quals))
+        with self.assertRaises(sequences.Error):
+            fa.to_Fastq('AAAAAAAAAAAAA')
+
+
+    def test_translate(self):
+        '''Test nucleotide -> amino acid conversion works on Fasta'''
+        fa = sequences.Fasta('ID', 'GCAGCCGCGGCTAGAAGGCGACGCCGGCGTAACAATGACGATTGCTGTGAAGAGCAACAGGGAGGCGGGGGTCACCATATAATCATTTTATTGCTACTCCTGCTTAAAAAGATGTTCTTTCCACCCCCGCCTAGCAGTTCATCCTCGTCTACAACCACGACTTGGTACTATGTAGTCGTGGTTTAATAGTGA')
+        self.assertEqual(sequences.Fasta('ID', 'AAAARRRRRRNNDDCCEEQQGGGGHHIIILLLLLLKKMFFPPPPSSSSSSTTTTWYYVVVV***'), fa.translate())
+        self.assertEqual(sequences.Fasta('ID', 'QPRLEGDAGVTMTIAVKSNREAGVTI*SFYCYSCLKRCSFHPRLAVHPRLQPRLGTM*SWFNS'), fa.translate(frame=1))
+        print(fa.translate(frame=1))
+        self.assertEqual(sequences.Fasta('ID', 'SRG*KATPA*Q*RLL*RATGRRGSPYNHFIATPA*KDVLSTPA*QFILVYNHDLVLCSRGLIV'), fa.translate(frame=2))
+
+    def test_expand_nucleotides(self):
+        '''Test expand_nucleotides'''
+        tests = [
+            (sequences.Fasta('1', 'A'), [sequences.Fasta('1.1', 'A')]),
+            (sequences.Fasta('2', 'C'), [sequences.Fasta('2.1', 'C')]),
+            (sequences.Fasta('3', 'G'), [sequences.Fasta('3.1', 'G')]),
+            (sequences.Fasta('4', 'T'), [sequences.Fasta('4.1', 'T')]),
+            (sequences.Fasta('6', 'R'), [sequences.Fasta('6.1', 'A'), sequences.Fasta('6.2', 'G')]),
+            (sequences.Fasta('7', 'Y'), [sequences.Fasta('7.1', 'C'), sequences.Fasta('7.2', 'T')]),
+            (sequences.Fasta('8', 'S'), [sequences.Fasta('8.1', 'C'), sequences.Fasta('8.2', 'G')]),
+            (sequences.Fasta('9', 'W'), [sequences.Fasta('9.1', 'A'), sequences.Fasta('9.2', 'T')]),
+            (sequences.Fasta('10', 'K'), [sequences.Fasta('10.1', 'G'), sequences.Fasta('10.2', 'T')]),
+            (sequences.Fasta('11', 'M'), [sequences.Fasta('11.1', 'A'), sequences.Fasta('11.2', 'C')]),
+            (sequences.Fasta('12', 'B'), [sequences.Fasta('12.1', 'C'), sequences.Fasta('12.2', 'G'), sequences.Fasta('12.3', 'T')]),
+            (sequences.Fasta('13', 'D'), [sequences.Fasta('13.1', 'A'), sequences.Fasta('13.2', 'G'), sequences.Fasta('13.3', 'T')]),
+            (sequences.Fasta('14', 'H'), [sequences.Fasta('14.1', 'A'), sequences.Fasta('14.2', 'C'), sequences.Fasta('14.3', 'T')]),
+            (sequences.Fasta('15', 'V'), [sequences.Fasta('15.1', 'A'), sequences.Fasta('15.2', 'C'), sequences.Fasta('15.3', 'G')]),
+            (sequences.Fasta('16', 'N'), [sequences.Fasta('16.1', 'A'), sequences.Fasta('16.2', 'C'), sequences.Fasta('16.3', 'G'), sequences.Fasta('16.4', 'T')]),
+            (sequences.Fasta('17', 'ART'), [sequences.Fasta('17.1', 'AAT'), sequences.Fasta('17.2', 'AGT')]),
+            (sequences.Fasta('18', 'ARRT'), [sequences.Fasta('18.1', 'AAAT'), sequences.Fasta('18.2', 'AAGT'), sequences.Fasta('18.3', 'AGAT'), sequences.Fasta('18.4', 'AGGT')]),
+            (sequences.Fasta('19', 'ARTR'), [sequences.Fasta('19.1', 'AATA'), sequences.Fasta('19.2', 'AATG'), sequences.Fasta('19.3', 'AGTA'), sequences.Fasta('19.4', 'AGTG')]),
+            (sequences.Fastq('20', 'ART', 'GHI'), [sequences.Fastq('20.1', 'AAT', 'GHI'), sequences.Fastq('20.2', 'AGT', 'GHI')]),
+        ]
+
+        for t in tests:
+            self.assertListEqual(t[0].expand_nucleotides(), t[1])
+
+    def test_split_capillary_id(self):
+        '''Tests that we get information from a sanger capillary read name OK'''
+        ids = ['abcde.p1k', 'abcde.x.p1k', 'abcde.p1ka', 'abcde.q1k', 'abcde.w2k']
+        expected = [{'prefix': 'abcde', 'dir': 'fwd', 'suffix': 'p1k'},
+                    {'prefix': 'abcde.x', 'dir': 'fwd', 'suffix': 'p1k'},
+                    {'prefix': 'abcde', 'dir': 'fwd', 'suffix': 'p1ka'},
+                    {'prefix': 'abcde', 'dir': 'rev', 'suffix': 'q1k'},
+                    {'prefix': 'abcde', 'dir': 'unk', 'suffix': 'w2k'}]
+
+        for i in range(len(ids)):
+            fa = sequences.Fasta(ids[i], 'A')
+            self.assertEqual(fa.split_capillary_id(), expected[i])
+
+        with self.assertRaises(sequences.Error):
+            fa = sequences.Fasta('name', 'A')
+            fa.split_capillary_id()
+
+
+class TestEmbl(unittest.TestCase):
+    def test_get_id_from_header_line(self):
+        '''Test get id from header line of EMBL'''
+        embl = sequences.Embl('ID', 'ACGT')
+        self.assertEqual(embl._get_id_from_header_line('ID   X; blah'), 'X')
+        self.assertEqual(embl._get_id_from_header_line('LOCUS   X foo'), 'X')
+        with self.assertRaises(sequences.Error):
+            self.assertEqual(embl._get_id_from_header_line('ID X;'), 'X')
+        with self.assertRaises(sequences.Error):
+            self.assertEqual(embl._get_id_from_header_line('XX   X;'), 'X')
+
+
+    def test_get_next_from_embl_file(self):
+        f_in = utils.open_file_read(os.path.join(data_dir, 'sequences_test.embl'))
+        embl = sequences.Embl()
+        counter = 1
+
+        while embl.get_next_from_file(f_in):
+            self.assertEqual(embl, sequences.Fasta('seq' + str(counter), expected_embl[counter-1]))
+            counter += 1
+
+        utils.close(f_in)
+
+
+    def test_get_next_from_gbk_file(self):
+        f_in = utils.open_file_read(os.path.join(data_dir, 'sequences_test.gbk'))
+        embl = sequences.Embl()
+        counter = 1
+        expected = [
+            'gatcctccatatacaacggtatctccacctcaggtttagatctcaacaacggaaccattgccgacatgagacagttaggtatcgtcgagagttacaagctaaaacgagcagtagtcagctctgcatctgaagccgctgaagttctactaagggtggataacatcatccgtgcaagaccaatgccatgactcagattctaattttaagctattcaatttctctttgatc',
+            'gatcctccatatacaacggtatctccacctcaggtttagatctcaacaacggaaccattgccgacatgagacagttaggtatcgtcgagagttacaagctaaaacgagcagtagtcagctctgcatctgaagccgctgaagttctactaagggtggataacatcatccgtgcaagaccaatgccatgactcagattctaattttaagctattcaatttctctttgaaa']
+
+        while embl.get_next_from_file(f_in):
+            self.assertEqual(embl, sequences.Fasta('NAME' + str(counter), expected[counter-1]))
+            counter += 1
+
+        utils.close(f_in)
+
+
+class TestFastq(unittest.TestCase):
+    def setUp(self):
+        self.fastq = sequences.Fastq('ID', 'ACGTA', 'IIIII')
+
+    def test_init(self):
+        '''__init__ should get the ID, sequence and quality correctly'''
+        self.assertEqual(self.fastq.id, 'ID')
+        self.assertEqual(self.fastq.seq, 'ACGTA')
+        self.assertEqual(self.fastq.qual, 'IIIII')
+
+    def test_init_length_mismatch(self):
+        '''__init__ should raise an error when length of seq and quality not the same'''
+        with self.assertRaises(sequences.Error):
+            sequences.Fastq('X', 'A', 'II')
+
+    def test_get_next_from_file(self):
+        '''get_next_from_file() should read seqs from OK, and raise error at badly formatted file'''
+        bad_files = ['sequences_test_fail_no_AT.fq',
+                     'sequences_test_fail_no_seq.fq',
+                     'sequences_test_fail_no_plus.fq',
+                     'sequences_test_fail_no_qual.fq']
+
+        bad_files = [os.path.join(data_dir, x) for x in bad_files]
+
+        for fname in bad_files:
+            f_in = utils.open_file_read(fname)
+            fq = sequences.Fastq()
+            with self.assertRaises(sequences.Error):
+                while fq.get_next_from_file(f_in):
+                    pass
+
+            utils.close(f_in)
+
+        fname = os.path.join(data_dir, 'sequences_test_good_file.fq')
+        try:
+            f_in = open(fname)
+        except IOError:
+            print("Error opening '" + fname + "'", file=sys.stderr)
+            sys.exit(1)
+
+        fq = sequences.Fastq()
+        while fq.get_next_from_file(f_in):
+            self.assertEqual(fq, sequences.Fastq('ID', 'ACGTA', 'IIIII'))
+        utils.close(f_in)
+
+    def test_revcomp(self):
+        '''revcomp() should correctly reverse complement a sequence'''
+        fq = sequences.Fastq('ID', 'ACGTNacgtn', '1234567890')
+        fq.revcomp()
+        self.assertEqual(fq, sequences.Fastq('ID', 'nacgtNACGT', '0987654321'))
+
+    def test_trim_Ns(self):
+        '''trim_Ns() should do the right trimming of a fastq sequence'''
+        fq = sequences.Fastq('ID', 'ANNANA', '111111')
+        test_seqs = [sequences.Fastq('ID', 'ANNANA', '111111'),
+                     sequences.Fastq('ID', 'NANNANA', '1111111'),
+                     sequences.Fastq('ID', 'NANNANAN', '11111111'),
+                     sequences.Fastq('ID', 'ANNANAN', '1111111'),
+                     sequences.Fastq('ID', 'NNNNNNANNANAN', '1111111111111'),
+                     sequences.Fastq('ID', 'NNANNANANn', '1111111111')]
+
+        for s in test_seqs:
+            s.trim_Ns()
+            self.assertEqual(fq, s)
+
+    def test_trim(self):
+        '''trim() should trim the right number of bases off start and end'''
+        fq = sequences.Fastq('ID', '1234567890', '1234567890')
+        fq.trim(0, 0)
+        self.assertEqual(fq, sequences.Fastq('ID', '1234567890', '1234567890'))
+
+        fq = sequences.Fastq('ID', '1234567890', '1234567890')
+        fq.trim(1, 0)
+        self.assertEqual(fq, sequences.Fastq('ID', '234567890', '234567890'))
+
+        fq = sequences.Fastq('ID', '1234567890', '1234567890')
+        fq.trim(0, 1)
+        self.assertEqual(fq, sequences.Fastq('ID', '123456789', '123456789'))
+
+        fq = sequences.Fastq('ID', '1234567890', '1234567890')
+        fq.trim(2, 2)
+        self.assertEqual(fq, sequences.Fastq('ID', '345678', '345678'))
+
+    def test_to_Fasta_and_qual(self):
+        '''Check to_Fasta_and_qual converts quality scores correctly'''
+        fq = sequences.Fastq('ID', 'ACGT', '>ADI')
+        (fa, qual) = fq.to_Fasta_and_qual()
+        self.assertEqual(fa, sequences.Fasta('ID', 'ACGT'))
+        self.assertListEqual(qual, [29, 32, 35, 40])
+
+
+    def test_translate(self):
+        '''Test nucleatide -> amino acid conversion works on Fasta'''
+        fq = sequences.Fastq('ID', 'GCAGCCGCGGCTAGAAGGCGACGCCGGCGTAACAATGACGATTGCTGTGAAGAGCAACAGGGAGGCGGGGGTCACCATATAATCATTTTATTGCTACTCCTGCTTAAAAAGATGTTCTTTCCACCCCCGCCTAGCAGTTCATCCTCGTCTACAACCACGACTTGGTACTATGTAGTCGTGGTTTAATAGTGA', 'IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII')
+
+        self.assertEqual(sequences.Fastq('ID', 'AAAARRRRRRNNDDCCEEQQGGGGHHIIILLLLLLKKMFFPPPPSSSSSSTTTTWYYVVVV***', 'IIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIIII'), fq.translate())
+
+class TestFileReader(unittest.TestCase):
+    def test_file_reader_fasta(self):
+        '''file_reader should iterate through a fasta file correctly'''
+        reader = sequences.file_reader(os.path.join(data_dir, 'sequences_test.fa'))
+        counter = 1
+        for seq in reader:
+            self.assertEqual(seq, sequences.Fasta(str(counter), 'ACGTA'))
+            counter += 1
+
+    def test_file_reader_fastq(self):
+        '''file_reader should iterate through a fastq file correctly'''
+        reader = sequences.file_reader(os.path.join(data_dir, 'sequences_test_good_file.fq'))
+        for seq in reader:
+            self.assertEqual(seq, sequences.Fastq('ID', 'ACGTA', 'IIIII'))
+
+    def test_file_reader_bad_format(self):
+        '''file_reader should die properly when not given fasta or fastq file'''
+        with self.assertRaises(sequences.Error):
+            reader = sequences.file_reader(os.path.join(data_dir, 'sequences_test_not_a_fastaq_file'))
+            for seq in reader:
+                pass
+
+    def test_file_reader_gff(self):
+        '''Test read gff file'''
+        good_files = [
+            'sequences_test_gffv3.gff',
+            'sequences_test_gffv3.no_FASTA_line.gff'
+        ]
+        good_files = [os.path.join(data_dir, x) for x in good_files]
+
+        for f in good_files:
+            reader = sequences.file_reader(f)
+            counter = 1
+            for seq in reader:
+                self.assertEqual(seq, sequences.Fasta('seq' + str(counter), 'ACGTACGTAC'))
+                counter += 1
+
+        bad_files = [
+            'sequences_test_gffv3.no_seq.gff',
+            'sequences_test_gffv3.no_seq.2.gff'
+        ]
+        bad_files = [os.path.join(data_dir, x) for x in bad_files]
+
+        for filename in bad_files:
+            with self.assertRaises(sequences.Error):
+                reader = sequences.file_reader(filename)
+                for seq in reader:
+                    pass
+
+    def test_file_reader_embl(self):
+        '''Test read embl file'''
+        reader = sequences.file_reader(os.path.join(data_dir, 'sequences_test.embl'))
+
+        counter = 1
+        for seq in reader:
+            self.assertEqual(seq, sequences.Fasta('seq' + str(counter), expected_embl[counter-1]))
+            counter += 1
+
+        bad_files = [
+            'sequences_test.embl.bad',
+            'sequences_test.embl.bad2',
+        ]
+        bad_files = [os.path.join(data_dir, x) for x in bad_files]
+
+        for filename in bad_files:
+            with self.assertRaises(sequences.Error):
+                reader = sequences.file_reader(filename)
+                for seq in reader:
+                    pass
+
+    def test_file_reader_phylip(self):
+        '''Test read phylip file'''
+        test_files = [
+            'sequences_test_phylip.interleaved',
+            'sequences_test_phylip.interleaved2',
+            'sequences_test_phylip.sequential'
+        ]
+
+        test_files = [os.path.join(data_dir, f) for f in test_files]
+
+        expected_seqs = [
+            sequences.Fasta('Turkey', 'AACTNGGGCATTTCAGGGTGAGCCCGGGCAATACAGGGTAT'),
+            sequences.Fasta('Salmo_gair', 'AAGCCTTGGCAGTGCAGGGTGAGCCGTGGCCGGGCACGGTAT'),
+            sequences.Fasta('H. Sapiens', 'ACCGGTTGGCCGTTCAGGGTACAGGTTGGCCGTTCAGGGTAA')
+        ]
+
+        for fname in test_files:
+            reader = sequences.file_reader(fname)
+            i = 0
+            for seq in reader:
+                self.assertEqual(expected_seqs[i], seq)
+                i += 1
+
+        # files made by seaview are a little different in the first line.
+        # Test one of these
+        expected_seqs = [
+            sequences.Fasta('seq1', 96 * 'G' + 'T'),
+            sequences.Fasta('seq2', 94 * 'A' + 'G')
+        ]
+
+        reader = sequences.file_reader(os.path.join(data_dir, 'sequences_test_phylip.made_by_seaview'))
+        i = 0
+        for seq in reader:
+            print(seq)
+            self.assertEqual(expected_seqs[i], seq)
+            i += 1
+
+
+class TestOther(unittest.TestCase):
+    def test_orfs_from_aa_seq(self):
+        '''Test _orfs_from_aa_seq()'''
+        test_seqs = ['',
+                     '*',
+                     '**',
+                     'A',
+                     'A*A*A',
+                     'AB**CDE*AB',
+                     '*ABCDE*',
+                     '**ABCDE**']
+
+        correct_coords = [[],
+                          [],
+                          [],
+                          [intervals.Interval(0, 0)],
+                          [intervals.Interval(0, 1), intervals.Interval(2, 3),intervals.Interval(4, 4)],
+                          [intervals.Interval(0, 2), intervals.Interval(4, 7), intervals.Interval(8, 9)],
+                          [intervals.Interval(1, 6)],
+                          [intervals.Interval(2, 7)]]
+
+        for i in range(len(test_seqs)):
+            orfs = sequences._orfs_from_aa_seq(test_seqs[i])
+            self.assertListEqual(correct_coords[i], orfs)
+
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/fastaq/tests/tasks_test.py b/fastaq/tests/tasks_test.py
new file mode 100644
index 0000000..36ebfba
--- /dev/null
+++ b/fastaq/tests/tasks_test.py
@@ -0,0 +1,538 @@
+#!/usr/bin/env python3
+
+import sys
+import filecmp
+import os
+import unittest
+from fastaq import tasks, sequences
+
+modules_dir = os.path.dirname(os.path.abspath(sequences.__file__))
+data_dir = os.path.join(modules_dir, 'tests', 'data')
+
+class Error (Exception): pass
+
+
+class TestCapillaryToPairs(unittest.TestCase):
+    def test_capillary_to_pairs(self):
+        '''Check that capillary reads file converted to paired and unpaired'''
+        tmp_prefix = 'tmp.cap_to_pairs'
+        tasks.capillary_to_pairs(os.path.join(data_dir, 'sequences_test_cap_to_read_pairs.fa'), tmp_prefix)
+        # sequences have been hashed, so could be in any order in
+        # output files. So need to check contents of files are OK
+        d_correct_paired = {}
+        d_correct_unpaired = {}
+        tasks.file_to_dict(os.path.join(data_dir, 'sequences_test_cap_to_read_pairs.fa.paired.gz'), d_correct_paired)
+        tasks.file_to_dict(os.path.join(data_dir, 'sequences_test_cap_to_read_pairs.fa.unpaired.gz'), d_correct_unpaired)
+        d_test_paired = {}
+        d_test_unpaired = {}
+        tasks.file_to_dict(tmp_prefix + '.paired.gz', d_test_paired)
+        tasks.file_to_dict(tmp_prefix + '.unpaired.gz', d_test_unpaired)
+        self.assertDictEqual(d_test_paired, d_correct_paired)
+        self.assertDictEqual(d_test_unpaired, d_correct_unpaired)
+        os.unlink(tmp_prefix + '.paired.gz')
+        os.unlink(tmp_prefix + '.unpaired.gz')
+
+
+class TestDeinterleave(unittest.TestCase):
+    def test_deinterleave(self):
+        '''deinterleave should deal with an interleaved file correctly'''
+        tmp_1 = 'tmp.deinterleaved_1.fa'
+        tmp_2 = 'tmp.deinterleaved_2.fa'
+        tasks.deinterleave(os.path.join(data_dir, 'sequences_test_interleaved.fa'), tmp_1, tmp_2)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_deinterleaved_1.fa'), tmp_1))
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_deinterleaved_2.fa'), tmp_2))
+
+        tasks.deinterleave(os.path.join(data_dir, 'sequences_test_interleaved.fq'), tmp_1, tmp_2, fasta_out=True)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_deinterleaved_1.fa'), tmp_1))
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_deinterleaved_2.fa'), tmp_2))
+
+        with self.assertRaises(tasks.Error):
+            tasks.deinterleave(os.path.join(data_dir, 'sequences_test_interleaved_bad.fa'), tmp_1, tmp_2)
+        os.unlink(tmp_1)
+        os.unlink(tmp_2)
+
+
+class TestEnumerateNames(unittest.TestCase):
+    def test_enumerate_names(self):
+        '''Test enomereate_names works with all options'''
+        outfile = 'tmp.enumerate_seqs.fa'
+        rename_out = outfile + '.rename'
+        tasks.enumerate_names(os.path.join(data_dir, 'sequences_test_enumerate_names.fa'), outfile)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_enumerate_names.fa.out.start.1'), outfile))
+        tasks.enumerate_names(os.path.join(data_dir, 'sequences_test_enumerate_names.fa'), outfile, rename_file=rename_out)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_enumerate_names.fa.out.start.1'), outfile))
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_enumerate_names.fa.out.start.1.rename_file'), rename_out))
+        tasks.enumerate_names(os.path.join(data_dir, 'sequences_test_enumerate_names.fa'), outfile, start_index=2)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_enumerate_names.fa.out.start.2'), outfile))
+        tasks.enumerate_names(os.path.join(data_dir, 'sequences_test_enumerate_names.fa'), outfile, keep_illumina_suffix=True)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_enumerate_names.fa.out.keep_suffix'), outfile))
+        os.unlink(outfile)
+        os.unlink(rename_out)
+
+
+class TestExpandNucleotides(unittest.TestCase):
+    def test_expand_nucleoties(self):
+        '''Test expand_nucleotides'''
+        tmp = 'tmp.expanded'
+        fq_in = os.path.join(data_dir, 'tasks_test_expend_nucleotides.in.fq')
+        fa_in = os.path.join(data_dir, 'tasks_test_expend_nucleotides.in.fa')
+        fq_expected = os.path.join(data_dir, 'tasks_test_expend_nucleotides.out.fq')
+        fa_expected = os.path.join(data_dir, 'tasks_test_expend_nucleotides.out.fa')
+        tasks.expand_nucleotides(fq_in, tmp)
+        self.assertTrue(filecmp.cmp(fq_expected, tmp, shallow=False))
+        os.unlink(tmp)
+        tasks.expand_nucleotides(fa_in, tmp)
+        self.assertTrue(filecmp.cmp(fa_expected, tmp, shallow=False))
+        os.unlink(tmp)
+
+
+class TestExtendGaps(unittest.TestCase):
+    def test_extend_gaps(self):
+        '''Test that gap extension works'''
+        outfile = 'tmp.gap_extend.fa'
+        tasks.extend_gaps(os.path.join(data_dir, 'sequences_test_extend_gaps.fa'), outfile, trim=2)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_extend_gaps.fa.out'), outfile))
+        os.unlink(outfile)
+
+
+class TestFastqToMiraXml(unittest.TestCase):
+    def test_fastaq_to_mira_xml(self):
+        '''check that fastaq_to_mira_xml makes the correct xml file from a fastq file'''
+        tmp = 'tmp.mira.xml'
+        tasks.fastaq_to_mira_xml(os.path.join(data_dir, 'sequences_test_good_file.fq'), tmp)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_good_file_mira.xml'), tmp))
+        os.unlink(tmp)
+
+
+class TestFastaqToOrfsGFF(unittest.TestCase):
+    def test_fastaq_to_orfs_gff(self):
+        '''Test fastaq_to_orfs_gff'''
+        outfile = 'tmp.orfs.gff'
+        tasks.fastaq_to_orfs_gff(os.path.join(data_dir, 'sequences_test_orfs.fa'), outfile, min_length=120)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_orfs.gff'), outfile, shallow=False))
+        os.unlink(outfile)
+
+
+class TestFilter(unittest.TestCase):
+    def test_length_filter(self):
+        '''Check that filtering by length works as expected'''
+        infile = os.path.join(data_dir, 'sequences_test_length_filter.fa')
+        correct_files = [os.path.join(data_dir, 'sequences_test_length_filter.min-0.max-1.fa'),
+                         os.path.join(data_dir, 'sequences_test_length_filter.min-0.max-inf.fa'),
+                         os.path.join(data_dir, 'sequences_test_length_filter.min-4.max-4.fa')]
+        cutoffs = [(0, 1), (0, float('inf')), (4, 4)]
+
+        for i in range(len(cutoffs)):
+            outfile = 'tmp.length_filter.fa'
+            tasks.filter(infile, outfile, minlength=cutoffs[i][0], maxlength=cutoffs[i][1])
+            self.assertTrue(filecmp.cmp(correct_files[i], outfile))
+            os.unlink(outfile)
+
+    def test_regex_filter(self):
+        '''Check that filtering by name regex works as expected'''
+        infile = os.path.join(data_dir, 'sequences_test_filter_by_regex.fa')
+        correct_files = [os.path.join(data_dir, 'sequences_test_filter_by_regex.numeric.fa'),
+                         os.path.join(data_dir, 'sequences_test_filter_by_regex.first-of-pair.fa'),
+                         os.path.join(data_dir, 'sequences_test_filter_by_regex.first-char-a.fa')]
+        regexes = ['^[0-9]+$', '/1$', '^a']
+
+        for i in range(len(regexes)):
+            outfile = 'tmp.regex_filter.fa'
+            tasks.filter(infile, outfile, regex=regexes[i])
+            self.assertTrue(filecmp.cmp(correct_files[i], outfile))
+            os.unlink(outfile)
+
+    def test_ids_from_file_filter(self):
+        '''Test that can extract reads from a file of read names'''
+        infile = os.path.join(data_dir, 'sequences_test_filter_by_ids_file.fa')
+        outfile = 'tmp.ids_file_filter.fa'
+        tasks.filter(infile, outfile, ids_file=infile + '.ids')
+        self.assertTrue(filecmp.cmp(infile + '.filtered', outfile))
+        os.unlink(outfile)
+
+    def test_invert_filter(self):
+        '''Test that inverting filtering works'''
+        infile = os.path.join(data_dir, 'sequences_test_filter_by_ids_file.fa')
+        outfile = 'tmp.ids_file_filter.fa'
+        tasks.filter(infile, outfile, ids_file=infile + '.ids', invert=True)
+        self.assertTrue(filecmp.cmp(infile + '.filtered.invert', outfile))
+        os.unlink(outfile)
+
+
+class TestGetSeqsFlankingGaps(unittest.TestCase):
+    def test_get_seqs_flanking_gaps(self):
+        outfile = 'tmp.seqs_flanking_gaps'
+        tasks.get_seqs_flanking_gaps(os.path.join(data_dir, 'sequences_test_get_seqs_flanking_gaps.fa'), outfile, 3, 3)
+        self.assertTrue(filecmp.cmp(outfile, os.path.join(data_dir, 'sequences_test_get_seqs_flanking_gaps.fa.out')))
+        os.unlink(outfile)
+
+
+class TestInterleave(unittest.TestCase):
+    def test_interleave(self):
+        '''Check that interleave works as expected'''
+        tmp = 'tmp.interleaved.fa'
+        tasks.interleave(os.path.join(data_dir, 'sequences_test_deinterleaved_1.fa'),
+                         os.path.join(data_dir, 'sequences_test_deinterleaved_2.fa'),
+                         tmp)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_interleaved.fa'), tmp))
+
+        with self.assertRaises(tasks.Error):
+            tasks.interleave(os.path.join(data_dir, 'sequences_test_deinterleaved_bad_1.fa'),
+                             os.path.join(data_dir, 'sequences_test_deinterleaved_bad_2.fa'),
+                             tmp)
+
+        with self.assertRaises(tasks.Error):
+            tasks.interleave(os.path.join(data_dir, 'sequences_test_deinterleaved_bad2_1.fa'),
+                             os.path.join(data_dir, 'sequences_test_deinterleaved_bad2_2.fa'),
+                             tmp)
+        os.unlink(tmp)
+
+
+class TestMakeRandomContigs(unittest.TestCase):
+    def test_make_random_contigs(self):
+        '''Test make_random_contigs()'''
+        # Can't guarantee same results from random (even using same seed), so
+        # just check sequence names and lengths
+        def files_are_equal(file1, file2):
+            seqs1 = {}
+            seqs2 = {}
+            tasks.file_to_dict(file1, seqs1)
+            tasks.file_to_dict(file2, seqs2)
+            if len(seqs1) != len(seqs2):
+                return False
+
+            for name in seqs1:
+                seq1 = seqs1[name]
+                seq2 = seqs2[name]
+                if seq1.id != seq2.id:
+                    return False
+                if len(seq1) != len(seq2):
+                    return False
+
+            return True
+
+        tmp = 'tmp.random_contigs.fa'
+        tasks.make_random_contigs(2, 3, tmp)
+        self.assertTrue(files_are_equal(os.path.join(data_dir, 'sequences_test_make_random_contigs.default.fa'), tmp))
+        tasks.make_random_contigs(2, 3, tmp, prefix='p')
+        self.assertTrue(files_are_equal(os.path.join(data_dir, 'sequences_test_make_random_contigs.prefix-p.fa'), tmp))
+        tasks.make_random_contigs(2, 3, tmp, first_number=42)
+        self.assertTrue(files_are_equal(os.path.join(data_dir, 'sequences_test_make_random_contigs.first-42.fa'), tmp))
+        tasks.make_random_contigs(28, 3, tmp, name_by_letters=True)
+        self.assertTrue(files_are_equal(os.path.join(data_dir, 'sequences_test_make_random_contigs.name-by-letters.fa'), tmp))
+        os.unlink(tmp)
+
+
+class TestMakeLongReads(unittest.TestCase):
+    def test_tiling_reads(self):
+        tmp = 'tmp.out.fa'
+        fa_in = os.path.join(data_dir, 'tasks_test_make_long_reads.input.fa')
+        tasks.make_long_reads(fa_in, tmp, method='tiling', fixed_read_length=10, tile_step=5)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'tasks_test_make_long_reads.output.fa'), tmp, shallow=False))
+        os.unlink(tmp)
+
+
+class TestMergeToOneSeq(unittest.TestCase):
+    def test_merge_to_one_seq_fa(self):
+        '''Test merge_to_one_seq with fasta'''
+        tmp = 'tmp.merged.fa'
+        tasks.merge_to_one_seq(os.path.join(data_dir, 'sequences_test_merge_to_one_seq.fa'), tmp)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_merge_to_one_seq.merged.fa'), tmp, shallow=False))
+        os.unlink(tmp)
+
+    def test_merge_to_one_seq_fq(self):
+        '''Test merge_to_one_seq with fastq'''
+        tmp = 'tmp.merged.fq'
+        tasks.merge_to_one_seq(os.path.join(data_dir, 'sequences_test_merge_to_one_seq.fq'), tmp)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_merge_to_one_seq.merged.fq'), tmp, shallow=False))
+        os.unlink(tmp)
+
+class TestReverseComplement(unittest.TestCase):
+    def test_reverse_complement(self):
+        '''reverse_complement should correctly reverse complement each seq in a file'''
+        tmp = 'tmp.revcomp.fa'
+        tasks.reverse_complement(os.path.join(data_dir, 'sequences_test.fa'), tmp)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_revcomp.fa'), tmp))
+        os.unlink(tmp)
+
+
+class TestScaffoldsToContigs(unittest.TestCase):
+    def test_scaffolds_to_contigs(self):
+        '''Test scaffolds_to_contigs'''
+        tmp = 'tmp.contigs.fa'
+        tasks.scaffolds_to_contigs(os.path.join(data_dir, 'utils_test_scaffolds.fa'), tmp)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'utils_test_scaffolds.fa.to_contigs.fa'), tmp))
+        os.unlink(tmp)
+
+    def test_scaffolds_to_contigs_number_contigs(self):
+        '''Test scaffolds_to_contigs with contig numbering'''
+        tmp = 'tmp.contigs.fa'
+        tasks.scaffolds_to_contigs(os.path.join(data_dir, 'utils_test_scaffolds.fa'), tmp, number_contigs=True)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'utils_test_scaffolds.fa.to_contigs.number_contigs.fa'), tmp))
+        os.unlink(tmp)
+
+
+class TestSearchForSeq(unittest.TestCase):
+    def test_search_for_seq(self):
+        '''Test that sequence search finds all hits'''
+        tmp = 'tmp.search.fa'
+        tasks.search_for_seq(os.path.join(data_dir, 'sequences_test_search_string.fa'), tmp, 'AGA')
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_search_string.fa.hits'), tmp))
+        os.unlink(tmp)
+
+
+class TestSequenceTrim(unittest.TestCase):
+    def test_sequence_trim(self):
+        '''Test sequence_trim'''
+        tmp1 = 'tmp.trimmed_1.fa'
+        tmp2 = 'tmp.trimmed_2.fa'
+        in1 = os.path.join(data_dir, 'tasks_test_sequence_trim_1.fa')
+        in2 = os.path.join(data_dir, 'tasks_test_sequence_trim_2.fa')
+        to_trim = os.path.join(data_dir, 'tasks_test_sequences_to_trim.fa')
+        expected1 = os.path.join(data_dir, 'tasks_test_sequence_trim_1.trimmed.fa')
+        expected2 = os.path.join(data_dir, 'tasks_test_sequence_trim_2.trimmed.fa')
+        tasks.sequence_trim(in1, in2, tmp1, tmp2, to_trim, min_length=10)
+        self.assertTrue(filecmp.cmp(expected1, tmp1))
+        self.assertTrue(filecmp.cmp(expected2, tmp2))
+        os.unlink(tmp1)
+        os.unlink(tmp2)
+
+
+class TestTranslate(unittest.TestCase):
+    def test_translate(self):
+        '''Test translate works in each frame'''
+        tmp = 'tmp.translated.fa'
+        for i in range(3):
+            tasks.translate(os.path.join(data_dir, 'sequences_test_translate.fa'), tmp, frame=i)
+            self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_translate.fa.frame' + str(i)), tmp))
+
+        os.unlink(tmp)
+
+
+class TestTrim(unittest.TestCase):
+    def test_trim(self):
+        '''trim should correctly trim each seq in a file'''
+        tmp = 'tmp.trim.fq'
+        tasks.trim(os.path.join(data_dir, 'sequences_test_untrimmed.fq'), tmp, 2, 1)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_trimmed.fq'), tmp))
+        os.unlink(tmp)
+
+
+    def test_trim_Ns_at_end(self):
+        '''Test Ns at ends of sequences trimmed OK'''
+        tmp = 'tmp.trim.fa'
+        tasks.trim_Ns_at_end(os.path.join(data_dir, 'sequences_test_trim_Ns_at_end.fa'), tmp)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_trim_Ns_at_end.fa.trimmed'), tmp))
+        os.unlink(tmp)
+
+
+class TestFileToDict(unittest.TestCase):
+    def test_file_to_dict(self):
+        '''check file_to_dict fills dictionary correctly'''
+        d_test = {}
+        d = {}
+        tasks.file_to_dict(os.path.join(data_dir, 'sequences_test.fa'), d_test)
+        for i in range(1,5):
+            d[str(i)] = sequences.Fasta(str(i),'ACGTA')
+
+        self.assertSequenceEqual(d_test.keys(),d.keys())
+        for i in range(1,5):
+            key = str(i)
+            self.assertEqual(d_test[key].id, d[key].id)
+            self.assertEqual(d_test[key].seq, d[key].seq)
+
+
+class TestLengthsFromFai(unittest.TestCase):
+    def test_lengths_from_fai(self):
+        '''Check lengths_from_fai gets the length of each seq OK'''
+        d = {}
+        lengths = {str(x):x for x in range(1,5)}
+        tasks.lengths_from_fai(os.path.join(data_dir, 'sequences_test_fai_test.fa.fai'), d)
+        self.assertSequenceEqual(d.keys(), lengths.keys())
+        for i in d:
+            self.assertEqual(int(i), d[i])
+
+
+class TestSplit(unittest.TestCase):
+    def test_split_by_base_count(self):
+        '''Check that fasta/q files get split by base count correctly'''
+        infile = os.path.join(data_dir, 'sequences_test_split_test.fa')
+        outprefix = 'tmp.sequences_test_split_test.fa.test'
+        length2files = {2: ['1','2','3','4'],
+                        3: ['1','2','3'],
+                        4: ['1', '2', '3'],
+                        6: ['1', '2']}
+        for l in length2files:
+            tasks.split_by_base_count(infile, outprefix, l)
+            for x in range(len(length2files[l])):
+                file_index = str(length2files[l][x])
+                fname = outprefix + '.' + file_index
+                self.assertTrue(filecmp.cmp(fname, infile + '.' + str(l) + '.' + file_index))
+                os.unlink(fname)
+
+        # check that limiting the number of files works
+        tasks.split_by_base_count(infile, outprefix, 6, 2)
+        for i in range(1,4):
+            test_file = outprefix + '.' + str(i)
+            self.assertTrue(filecmp.cmp(test_file, os.path.join(data_dir, 'sequences_test_split_test.fa.6.limit2.') + str(i)))
+            os.unlink(test_file)
+
+        # check big sequence not broken
+        tasks.split_by_base_count(os.path.join(data_dir, 'sequences_test_split_test.long.fa'), outprefix, 2)
+        self.assertTrue(filecmp.cmp(outprefix + '.1', os.path.join(data_dir, 'sequences_test_split_test.long.fa.2.1')))
+        self.assertTrue(filecmp.cmp(outprefix + '.2', os.path.join(data_dir, 'sequences_test_split_test.long.fa.2.2')))
+        os.unlink(outprefix + '.1')
+        os.unlink(outprefix + '.2')
+
+    def test_split_by_fixed_size(self):
+        '''Test fasta/q file split by fixed size'''
+        infile = os.path.join(data_dir, 'sequences_test_split_fixed_size.fa')
+        outprefix = 'tmp.sequences_test_split'
+        tasks.split_by_fixed_size(infile, outprefix, 4, 1)
+
+        for i in range(1,7,1):
+            correct = os.path.join(data_dir, 'sequences_test_split_fixed_size.fa.split.' + str(i))
+            test = outprefix + '.' + str(i)
+            self.assertTrue(filecmp.cmp(test, correct))
+            os.unlink(test)
+
+        test_coords = outprefix + '.coords'
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_split_fixed_size.fa.split.coords'), test_coords))
+        os.unlink(test_coords)
+
+    def test_split_by_fixed_size_exclude_Ns(self):
+        infile = os.path.join(data_dir, 'sequences_test_split_fixed_size.fa')
+        outprefix = 'tmp.sequences_test_split'
+        tasks.split_by_fixed_size(infile, outprefix, 4, 1, skip_if_all_Ns=True)
+
+        for i in range(1,5,1):
+            correct = os.path.join(data_dir, 'sequences_test_split_fixed_size.fa.split.skip_if_all_Ns.' + str(i))
+            test = outprefix + '.' + str(i)
+            self.assertTrue(filecmp.cmp(test, correct))
+            os.unlink(test)
+
+        test_coords = outprefix + '.coords'
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_split_fixed_size.fa.split.skip_if_all_Ns.coords'), test_coords))
+        os.unlink(test_coords)
+
+class TestCountSequences(unittest.TestCase):
+    def test_count_sequences(self):
+        '''Check that count_sequences does as expected'''
+        self.assertEqual(2, tasks.count_sequences(os.path.join(data_dir, 'sequences_test_good_file.fq')))
+        self.assertEqual(4, tasks.count_sequences(os.path.join(data_dir, 'sequences_test.fa')))
+        self.assertEqual(0, tasks.count_sequences(os.path.join(data_dir, 'sequences_test_empty_file')))
+
+class TestGetIds(unittest.TestCase):
+    def test_get_ids(self):
+        '''Check that IDs extracted correctly from fasta/q file'''
+        tmpfile = 'tmp.ids'
+        tasks.get_ids(os.path.join(data_dir, 'sequences_test.fa'), tmpfile)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test.fa.ids'), tmpfile))
+        os.unlink(tmpfile)
+
+
+class TestFastaToFakeQual(unittest.TestCase):
+    def test_fasta_to_fake_qual(self):
+        '''Test fasta_to_fake_qual'''
+        tmpfile = 'tmp.qual'
+        infile = os.path.join(data_dir, 'tasks_test_fasta_to_fake_qual.in.fa')
+        tasks.fastaq_to_fake_qual(infile, tmpfile)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'tasks_test_fasta_to_fake_qual.out.default.qual'), tmpfile, shallow=False))
+        os.unlink(tmpfile)
+        tasks.fastaq_to_fake_qual(infile, tmpfile, q=42)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'tasks_test_fasta_to_fake_qual.out.q42.qual'), tmpfile, shallow=False))
+        os.unlink(tmpfile)
+
+
+class TestFastaToFastq(unittest.TestCase):
+    def test_fasta_to_fastq(self):
+        '''Check fasta_to_fastq converts files as expected'''
+        tasks.fasta_to_fastq(os.path.join(data_dir, 'sequences_test.fa'),
+                             os.path.join(data_dir, 'sequences_test.fa.qual'),
+                             'tmp.fq')
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test.fasta_to_fastq.fq'), 'tmp.fq'))
+
+        with self.assertRaises(tasks.Error):
+            tasks.fasta_to_fastq(os.path.join(data_dir, 'sequences_test.fa'),
+                                 os.path.join(data_dir, 'sequences_test.fa.qual.bad'),
+                                 'tmp.fq')
+
+        os.unlink('tmp.fq')
+
+
+class TestReplaceBases(unittest.TestCase):
+    def test_sequences_replace_bases(self):
+        '''Check that fasta file gets all bases replaced OK'''
+        tmpfile = 'tmp.replace_bases.fa'
+        tasks.replace_bases(os.path.join(data_dir, 'sequences_test_fastaq_replace_bases.fa'), tmpfile, 'T', 'X')
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_fastaq_replace_bases.expected.fa'), tmpfile))
+        os.unlink(tmpfile)
+
+
+class TestStripIlluminaSuffix(unittest.TestCase):
+    def test_strip_illumina_suffix(self):
+        '''Check illumina suffixes stripped correctly off read names'''
+        tmpfile = 'tmp.stripped.fa'
+        tasks.strip_illumina_suffix(os.path.join(data_dir, 'sequences_test_strip_illumina_suffix.fq'), tmpfile)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_strip_illumina_suffix.fq.stripped'), tmpfile))
+        os.unlink(tmpfile)
+
+
+class TestToQuasrPrimers(unittest.TestCase):
+    def test_to_quasr_primers(self):
+        '''Check that fasta file gets converted to QUASR sequence file'''
+        tmpfile = 'tmp.primers'
+        tasks.to_quasr_primers(os.path.join(data_dir, 'sequences_test_fastaq_to_quasr_primers.fa'), tmpfile)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_fastaq_to_quasr_primers.expected'), tmpfile))
+        os.unlink(tmpfile)
+
+
+class TestToFasta(unittest.TestCase):
+    def test_to_fasta(self):
+        '''Test to_fasta'''
+        tmpfile = 'tmp.to_fasta'
+        infiles = [
+            'sequences_test_good_file.fq',
+            'sequences_test_gffv3.gff',
+            'sequences_test_gffv3.no_FASTA_line.gff',
+            'sequences_test.embl',
+            'sequences_test.gbk',
+            'sequences_test_phylip.interleaved',
+            'sequences_test_phylip.interleaved2',
+            'sequences_test_phylip.sequential'
+        ]
+        infiles = [os.path.join(data_dir, x) for x in infiles]
+        expected_outfiles = [x + '.to_fasta' for x in infiles]
+
+        for i in range(len(infiles)):
+            tasks.to_fasta(infiles[i], tmpfile)
+            self.assertTrue(filecmp.cmp(expected_outfiles[i], tmpfile))
+
+        tasks.to_fasta(os.path.join(data_dir, 'sequences_test.fa'), tmpfile, line_length=3)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test.line_length3.fa'), tmpfile))
+        tasks.to_fasta(os.path.join(data_dir, 'sequences_test_strip_after_whitespace.fa'), tmpfile, strip_after_first_whitespace=True)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_strip_after_whitespace.fa.to_fasta'), tmpfile))
+        os.unlink(tmpfile)
+
+
+class TestToUniqueByID(unittest.TestCase):
+    def test_to_unique_by_id(self):
+        '''Test to_unique_by_id()'''
+        tmpfile = 'tmp.unique_by_id.fa'
+        tasks.to_unique_by_id(os.path.join(data_dir, 'sequences_test_to_unique_by_id.fa'), tmpfile)
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_to_unique_by_id.fa.out'), tmpfile))
+        os.unlink(tmpfile)
+
+
+class TestToFastaUnion(unittest.TestCase):
+    def test_to_fasta_union(self):
+        '''Test to_fasta_union'''
+        tmpfile = 'tmp.to_fasta_union'
+        tasks.to_fasta_union(os.path.join(data_dir, 'sequences_test_to_fasta_union.in.fa'), tmpfile, seqname='testname')
+        self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_to_fasta_union.out.fa'), tmpfile, shallow=False))
+        os.unlink(tmpfile)
+
+
+if __name__ == '__main__':
+    unittest.main()
+
diff --git a/fastaq/tests/utils_test.py b/fastaq/tests/utils_test.py
new file mode 100644
index 0000000..731c944
--- /dev/null
+++ b/fastaq/tests/utils_test.py
@@ -0,0 +1,80 @@
+#!/usr/bin/env python3
+
+import sys
+import os
+import filecmp
+import unittest
+from fastaq import utils
+
+modules_dir = os.path.dirname(os.path.abspath(utils.__file__))
+data_dir = os.path.join(modules_dir, 'tests', 'data')
+
+class TestUtils(unittest.TestCase):
+    def test_write_and_read(self):
+        '''open_file_write() and open_file_read() should do the right thing depending gzipped or not'''
+        for filename in ['utils.tmp', 'utils.tmp.gz', 'utils.tmp.bgz']:
+            f = utils.open_file_write(filename)
+            for i in range(3):
+                print(i, file=f)
+            utils.close(f)
+
+            counter = 0
+
+            f = utils.open_file_read(filename)
+            for line in f:
+                self.assertEqual(counter, int(line.strip()))
+                counter += 1
+            utils.close(f)
+
+            os.unlink(filename)
+
+        f = utils.open_file_read('-')
+        self.assertEqual(sys.stdin, f)
+        f = utils.open_file_write('-')
+        self.assertEqual(sys.stdout, f)
+
+    def test_raise_exception(self):
+        '''open_file_write() and open_file_read() should raise an exception when can't do the opening'''
+        with self.assertRaises(utils.Error):
+            utils.open_file_read('this_file_is_not_here_so_throw_error')
+        with self.assertRaises(utils.Error):
+            utils.open_file_read('this_file_is_not_here_so_throw_error.gz')
+        with self.assertRaises(utils.Error):
+            utils.open_file_read(os.path.join(data_dir, 'utils_test_not_really_zipped.gz'))
+
+        with self.assertRaises(utils.Error):
+            utils.open_file_write(os.path.join('not_a_directory', 'this_file_is_not_here_so_throw_error'))
+        with self.assertRaises(utils.Error):
+            utils.open_file_write(os.path.join('not_a_directory', 'this_file_is_not_here_so_throw_error.gz'))
+
+    def test_file_transpose(self):
+        '''Test that file_transpose() does what it should'''
+        infile = os.path.join(data_dir, 'utils_test_file_transpose.txt')
+        tmp_out = 'utils_test_file_transpose.tmp'
+        correct_file = os.path.join(data_dir, 'utils_test_file_transposed.txt')
+        utils.file_transpose(infile, tmp_out)
+        self.assertTrue(filecmp.cmp(tmp_out, correct_file))
+        os.unlink(tmp_out)
+
+    def test_system_call(self):
+        '''Test that system call appears to work and die as it should'''
+        test_file = os.path.join(data_dir, 'utils_test_system_call.txt')
+        tmp_out = 'utils_test_syscall.tmp'
+        utils.syscall('cat ' + test_file + ' > ' + tmp_out)
+        self.assertTrue(filecmp.cmp(tmp_out, test_file))
+        os.unlink(tmp_out)
+
+        with self.assertRaises(utils.Error):
+            utils.syscall('thisisveryunlikelytoebarealcommandandshouldthrowerror')
+
+        utils.syscall('echo "this is not the right string" > ' + tmp_out)
+        self.assertFalse(filecmp.cmp(tmp_out, test_file))
+        os.unlink(tmp_out)
+
+        s = utils.syscall_get_stdout('echo bingo')
+        self.assertListEqual(["bingo"], s)
+        with self.assertRaises(utils.Error):
+            utils.syscall_get_stdout('thisisveryunlikelytoebarealcommandandshouldthrowerror')
+
+if __name__ == '__main__':
+    unittest.main()
diff --git a/fastaq/utils.py b/fastaq/utils.py
new file mode 100644
index 0000000..c30273b
--- /dev/null
+++ b/fastaq/utils.py
@@ -0,0 +1,86 @@
+import os
+import sys
+import subprocess
+import shlex
+
+class Error (Exception): pass
+
+def open_file_read(filename):
+    if filename == '-':
+        f = sys.stdin
+    elif filename.endswith('.gz'):
+        # first check that the file is OK according to gunzip
+        retcode = subprocess.call('gunzip -t ' + filename, shell=True)
+        if retcode != 0:
+            raise Error("Error opening for reading gzipped file '" + filename + "'")
+
+        # now open the file
+        f = os.popen('gunzip -c ' + filename)
+    else:
+        try:
+            f = open(filename)
+        except:
+            raise Error("Error opening for reading file '" + filename + "'")
+
+    return f
+
+
+def open_file_write(filename):
+    if filename == '-':
+        f = sys.stdout
+    elif filename.endswith('.gz'):
+        if not os.path.exists(os.path.abspath(os.path.dirname(filename))):
+            raise Error("Error opening for writing gzipped file '" + filename + "'")
+
+        try:
+            f = os.popen('gzip -9 -c > ' + filename, 'w')
+        except:
+            raise Error("Error opening for writing gzipped file '" + filename + "'")
+    else:
+        try:
+            f = open(filename, 'w')
+        except:
+            raise Error("Error opening for writing file '" + filename + "'")
+
+    return f
+
+
+def close(filehandle):
+    if filehandle not in [sys.stdout, sys.stderr]:
+        filehandle.close()
+
+
+def file_transpose(f_in, f_out, sep_in=None, sep_out='\t'):
+    rows = []
+    f = open_file_read(f_in)
+    for line in f:
+        rows.append(line.rstrip().split(sep_in))
+    close(f)
+
+    columns_out = max([len(x) for x in rows])
+
+    for r in rows:
+        r += ['.'] * (columns_out - len(r))
+
+    f = open_file_write(f_out)
+    for i in range(columns_out):
+        print(sep_out.join([str(rows[x][i]) for x in range(len(rows))]), file=f)
+
+    close(f)
+
+
+def syscall(cmd):
+    retcode = subprocess.call(cmd, shell=True)
+
+    if retcode != 0:
+        raise Error("Error in system call. Command was:\n" + cmd)
+
+
+def syscall_get_stdout(cmd):
+    try:
+        out = subprocess.Popen(shlex.split(cmd), stdout=subprocess.PIPE).communicate()[0].decode('utf-8').rstrip()
+        return out.split('\n')
+    except:
+        raise Error('Error in system call. I tried to run:\n' + str(cmd))
+
+
diff --git a/scripts/fastaq_capillary_to_pairs b/scripts/fastaq_capillary_to_pairs
new file mode 100755
index 0000000..0d4a48f
--- /dev/null
+++ b/scripts/fastaq_capillary_to_pairs
@@ -0,0 +1,12 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Given a fasta/q file of capillary reads, makes an interleaved file of read pairs (where more than read from same ligation, takes the longest read) and a file of unpaired reads. Replaces the .p1k/.q1k part of read names to denote fwd/rev reads with /1 and /2',
+    usage = '%(prog)s <infile> <outfiles prefix>')
+parser.add_argument('infile', help='Name of input fasta/q file')
+parser.add_argument('outprefix', help='Prefix of output files', metavar='outfiles prefix')
+options = parser.parse_args()
+tasks.capillary_to_pairs(options.infile, options.outprefix)
diff --git a/scripts/fastaq_chunker b/scripts/fastaq_chunker
new file mode 100755
index 0000000..d1aeb68
--- /dev/null
+++ b/scripts/fastaq_chunker
@@ -0,0 +1,21 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Splits a multi fasta/q file into separate files. Splits sequences into chunks of a fixed size. Aims for chunk_size chunks in each file, but allows a little extra, so chunk can be up to (chunk_size + tolerance), to prevent tiny chunks made from the ends of sequences',
+    usage = '%(prog)s [options] <fasta/q in> <prefix of output files> <chunk size> <tolerance>')
+parser.add_argument('infile', help='Name of input fasta/q file to be split')
+parser.add_argument('outprefix', help='Name of output fasta/q file')
+parser.add_argument('chunk_size', type=int, help='Size of each chunk')
+parser.add_argument('tolerance', type=int, help='Tolerance allowed in chunk size')
+parser.add_argument('--skip_all_Ns', action='store_true', help='Do not output any sequence that consists of all Ns')
+options = parser.parse_args()
+tasks.split_by_fixed_size(
+    options.infile,
+    options.outprefix,
+    options.chunk_size,
+    options.tolerance,
+    skip_if_all_Ns=options.skip_all_Ns
+)
diff --git a/scripts/fastaq_count_sequences b/scripts/fastaq_count_sequences
new file mode 100755
index 0000000..fcb7911
--- /dev/null
+++ b/scripts/fastaq_count_sequences
@@ -0,0 +1,11 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Counts the number of sequences in a fasta/q file',
+    usage = '%(prog)s <fasta/q in>')
+parser.add_argument('infile', help='Name of input fasta/q file')
+options = parser.parse_args()
+print(tasks.count_sequences(options.infile))
diff --git a/scripts/fastaq_deinterleave b/scripts/fastaq_deinterleave
new file mode 100755
index 0000000..a28c505
--- /dev/null
+++ b/scripts/fastaq_deinterleave
@@ -0,0 +1,14 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Deinterleaves fasta/q file, so that reads are written alternately between two output files',
+    usage = '%(prog)s [options] <fasta/q in> <out_fwd> <out_rev>')
+parser.add_argument('--fasta_out', action='store_true', help='Use this to write output as fasta (default is same as input)', default=False)
+parser.add_argument('infile', help='Name of fasta/q file to be deinterleaved')
+parser.add_argument('out_fwd', help='Name of output fasta/q file of forwards reads')
+parser.add_argument('out_rev', help='Name of output fasta/q file of reverse reads')
+options = parser.parse_args()
+tasks.deinterleave(options.infile, options.out_fwd, options.out_rev, fasta_out=options.fasta_out)
diff --git a/scripts/fastaq_enumerate_names b/scripts/fastaq_enumerate_names
new file mode 100755
index 0000000..89831cb
--- /dev/null
+++ b/scripts/fastaq_enumerate_names
@@ -0,0 +1,19 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Renames sequences in a file, calling them 1,2,3... etc',
+    usage = '%(prog)s [options] <fasta/q in> <fasta/q out>')
+parser.add_argument('--start_index', type=int, help='Starting number [%(default)s]', default=1)
+parser.add_argument('--rename_file', help='If used, will write a file of old name to new name')
+parser.add_argument('--keep_suffix', action='store_true', help='Use this to keep a /1 or /2 suffix at the end of each name')
+parser.add_argument('infile', help='Name of fasta/q file to be read')
+parser.add_argument('outfile', help='Name of output fasta/q file')
+options = parser.parse_args()
+tasks.enumerate_names(options.infile,
+                      options.outfile,
+                      start_index=options.start_index,
+                      keep_illumina_suffix=options.keep_suffix,
+                      rename_file=options.rename_file)
diff --git a/scripts/fastaq_expand_nucleotides b/scripts/fastaq_expand_nucleotides
new file mode 100755
index 0000000..2dbde36
--- /dev/null
+++ b/scripts/fastaq_expand_nucleotides
@@ -0,0 +1,15 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Makes all combinations of sequences in input file by using all possibilities of redundant bases. e.g. ART could be AAT or AGT. Assumes input is nucleotides, not amino acids',
+    usage = '%(prog)s <infile> <outfile>')
+parser.add_argument('infile', help='Name of input file. Can be any of FASTA, FASTQ, GFF3, EMBL, GBK, Phylip')
+parser.add_argument('outfile', help='Name of output file')
+options = parser.parse_args()
+tasks.expand_nucleotides(
+    options.infile,
+    options.outfile,
+)
diff --git a/scripts/fastaq_extend_gaps b/scripts/fastaq_extend_gaps
new file mode 100755
index 0000000..e8622c3
--- /dev/null
+++ b/scripts/fastaq_extend_gaps
@@ -0,0 +1,13 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Extends the length of all gaps (and trims the start/end of sequences) in a fasta/q file. Does this by replacing a set number of bases either side of each gap with Ns. Any sequence that ends up as all Ns is lost',
+    usage = '%(prog)s [options] <fasta/q in> <fasta/q out>')
+parser.add_argument('--trim_number', type=int, help='Number of bases to trim around each gap, and off ends of each sequence [%(default)s]', default=100)
+parser.add_argument('infile', help='Name of input fasta/q file')
+parser.add_argument('outfile', help='Name of output fasta/q file')
+options = parser.parse_args()
+tasks.extend_gaps(options.infile, options.outfile, options.trim_number)
diff --git a/scripts/fastaq_fasta_to_fastq b/scripts/fastaq_fasta_to_fastq
new file mode 100755
index 0000000..18b6edb
--- /dev/null
+++ b/scripts/fastaq_fasta_to_fastq
@@ -0,0 +1,13 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Given a fasta and qual file, makes a fastq file',
+    usage = '%(prog)s <fasta in> <qual in> <fastq out>')
+parser.add_argument('fasta', help='Name of input fasta file', metavar='fasta in')
+parser.add_argument('qual', help='Name of input quality scores file', metavar='qual in')
+parser.add_argument('outfile', help='Name of output fastq file', metavar='fastq out')
+options = parser.parse_args()
+tasks.fasta_to_fastq(options.fasta, options.qual, options.outfile)
diff --git a/scripts/fastaq_filter b/scripts/fastaq_filter
new file mode 100755
index 0000000..cb260e6
--- /dev/null
+++ b/scripts/fastaq_filter
@@ -0,0 +1,24 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Filters a fasta/q file by sequence length and/or by name matching a regular expression',
+    usage = '%(prog)s [options] <infile> <outfile>')
+parser.add_argument('--min_length', type=int, help='Minimum length of sequence to keep [%(default)s]', default=0, metavar='INT')
+parser.add_argument('--max_length', type=float, help='Maximum length of sequence to keep [%(default)s]', default=float('inf'), metavar='INT')
+parser.add_argument('--regex', help='If given, only reads with a name matching the regular expression will be kept')
+parser.add_argument('--ids_file', help='If given, only reads whose ID is in th given file will be used. One ID per line of file.')
+parser.add_argument('-v', '--invert', action='store_true', help='Keep sequences that do not match the filters')
+parser.add_argument('infile', help='Name of fasta/q file to be filtered')
+parser.add_argument('outfile', help='Name of output fasta/q file')
+options = parser.parse_args()
+tasks.filter(options.infile,
+             options.outfile,
+             minlength=options.min_length,
+             maxlength=options.max_length,
+             regex=options.regex,
+             ids_file=options.ids_file,
+             invert=options.invert
+)
diff --git a/scripts/fastaq_get_ids b/scripts/fastaq_get_ids
new file mode 100755
index 0000000..59b9e0e
--- /dev/null
+++ b/scripts/fastaq_get_ids
@@ -0,0 +1,12 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Gets IDs from each sequence in a fasta or fastq file',
+    usage = '%(prog)s <infile> <outfile>')
+parser.add_argument('infile', help='Name of input fasta/q file')
+parser.add_argument('outfile', help='Name of output file')
+options = parser.parse_args()
+tasks.get_ids(options.infile, options.outfile)
diff --git a/scripts/fastaq_get_seq_flanking_gaps b/scripts/fastaq_get_seq_flanking_gaps
new file mode 100755
index 0000000..0c54154
--- /dev/null
+++ b/scripts/fastaq_get_seq_flanking_gaps
@@ -0,0 +1,14 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Gets the sequences either side of gaps in a fasta/q file',
+    usage = '%(prog)s [options] <fasta/q in> <fasta/q out>')
+parser.add_argument('--left', type=int, help='Number of bases to get to left of gap [%(default)s]', default=25, metavar='INT')
+parser.add_argument('--right', type=int, help='Number of bases to get to right of gap [%(default)s]', default=25, metavar='INT')
+parser.add_argument('infile', help='Name of input fasta/q file')
+parser.add_argument('outfile', help='Name of output fasta/q file')
+options = parser.parse_args()
+tasks.get_seqs_flanking_gaps(options.infile, options.outfile, options.left, options.right)
diff --git a/scripts/fastaq_insert_or_delete_bases b/scripts/fastaq_insert_or_delete_bases
new file mode 100755
index 0000000..61e1e80
--- /dev/null
+++ b/scripts/fastaq_insert_or_delete_bases
@@ -0,0 +1,94 @@
+#!/usr/bin/env python3
+
+import argparse
+import sys
+import random
+from fastaq import sequences, utils, intervals
+
+parser = argparse.ArgumentParser(
+    description = 'Deletes or inserts bases at given position(s) from a fasta/q file',
+    usage = '%(prog)s <fasta/q in> <outfile>')
+parser.add_argument('infile', help='Name of fasta/q file to be read')
+parser.add_argument('outfile', help='Name of output file')
+parser.add_argument('-d','--delete', action='append', help='Delete the given bases from the given sequence. Format same as samtools view: name:start-end. This option can be used multiple times (once for each region to delete). Overlapping coords will be merged before deleting', metavar='Name:start:bases')
+parser.add_argument('--delete_range', help='Deletes bases starting at position P in each sequence of the input file. Deletes start + (n-1)*step bases from sequence n.', metavar='P,start,step')
+parser.add_argument('-i','--insert', action='append', help='Insert a random string of bases at the given position. Format is name:position:number_to_add. Bases are added after the position. This option can be used multiple times', metavar='Name:start:bases')
+parser.add_argument('--insert_range', help='Inserts random bases starting after position P in each sequence of the input file. Inserts start + (n-1)*step bases into sequence n.', metavar='P,start,step')
+options = parser.parse_args()
+
+test_ops = [int(x is not None) for x in [options.delete, options.insert, options.delete_range, options.insert_range]]
+
+if sum(test_ops) != 1:
+    print('Must use one of --delete, --insert, --delete_range, --insert_range. Cannot continue', file=sys.stderr)
+    sys.exit(1)
+
+
+def range2dic(range_in):
+    if range_in is None:
+        return {}
+    (pos, start, step) = range_in.split(',')
+    d = {}
+    d['pos'] = int(pos) - 1
+    d['bases'] = int(start)
+    d['step'] = int(step)
+    return d
+
+delete_range = range2dic(options.delete_range)
+insert_range = range2dic(options.insert_range)
+
+
+# convert the -d regions into sequence name, start and end coords
+to_delete = {}
+if options.delete:
+    for s in options.delete:
+        id, coords = s.rsplit(':')
+        start, end = [int(x)-1 for x in coords.split('-')]
+        if id not in to_delete:
+            to_delete[id] = []
+        to_delete[id].append(intervals.Interval(start, end))
+
+
+to_insert = {}
+if options.insert:
+    for s in options.insert:
+        id, pos, bases = s.rsplit(':',2)
+        pos = int(pos) - 1
+        bases = int(bases)
+        if id not in to_insert:
+            to_insert[id] = []
+        to_insert[id].append((pos, bases))
+
+
+assert len(to_delete) * len(to_insert) == 0
+
+# merge overlapping regions to be deleted
+for l in to_delete.values():
+    intervals.merge_overlapping_in_list(l)
+
+# sort positions to be inserted
+for l in to_insert.values():
+    l.sort()
+
+# read in the fasta/q file and print outfile with deleted sequences
+seq_reader = sequences.file_reader(options.infile)
+f = utils.open_file_write(options.outfile)
+
+for seq in seq_reader:
+    if seq.id in to_delete:
+        # delete regions for this sequence, but start at the end so the
+        # coords don't get messed up after the first deletion
+        for inter in reversed(to_delete[seq.id]):
+            seq.seq = seq.seq[:inter.start] + seq.seq[inter.end + 1:]
+    elif options.delete_range:
+        seq.seq = seq.seq[:delete_range['pos']] + seq.seq[delete_range['pos'] + delete_range['bases']:]
+        delete_range['bases'] += delete_range['step']
+    elif seq.id in to_insert:
+        for pos, bases in reversed(to_insert[seq.id]):
+            seq.seq = seq.seq[:pos + 1] + ''.join([random.choice('ACGT') for x in range(bases)]) + seq.seq[pos + 1:]
+    elif options.insert_range:
+        seq.seq = seq.seq[:insert_range['pos'] + 1] + ''.join([random.choice('ACGT') for x in range(insert_range['bases'])]) +  seq.seq[insert_range['pos'] + 1:]
+        insert_range['bases'] += insert_range['step']
+
+    print(seq, file=f)
+
+utils.close(f)
diff --git a/scripts/fastaq_interleave b/scripts/fastaq_interleave
new file mode 100755
index 0000000..4b39a3e
--- /dev/null
+++ b/scripts/fastaq_interleave
@@ -0,0 +1,13 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Interleaves two fasta/q files, so that reads are written alternately first/second in output file',
+    usage = '%(prog)s [options] <fasta/q 1> <fasta/q 2> <outfile>')
+parser.add_argument('infile_1', help='Name of first input fasta/q file')
+parser.add_argument('infile_2', help='Name of second input fasta/q file')
+parser.add_argument('outfile', help='Name of output fasta/q file of interleaved reads')
+options = parser.parse_args()
+tasks.interleave(options.infile_1, options.infile_2, options.outfile)
diff --git a/scripts/fastaq_long_read_simulate b/scripts/fastaq_long_read_simulate
new file mode 100755
index 0000000..23106f3
--- /dev/null
+++ b/scripts/fastaq_long_read_simulate
@@ -0,0 +1,50 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Simulates long reads from a fasta/q file. Can optionally make insertions into the reads, like pacbio does. If insertions made, coverage calculation is done before the insertions (so total read length may appear longer then expected).',
+    usage = '%(prog)s [options] <infile> <outfile>')
+
+parser.add_argument('infile', help='Name of input fasta/q file')
+parser.add_argument('outfile', help='Name of output fasta file')
+
+parser.add_argument('--method', help='How to sample the read positions and lengths. Choose from 1) "tiling", where reads of fixed length are taken at equal intervals from the reference. 2) "unfiform", where reads of fixed length taken at positions sampled uniformly. 3) "gamma", where reads lengths are taken from a gamma distribution, and positions sampled uniformly. [%(default)s]', default='tiling', choices=['tiling', 'uniform', 'gamma'], metavar='tiling|uniform|gamma')
+parser.add_argument('--seed', type=int, help='Seed for random number generator [default: use python\'s default]', metavar='INT')
+parser.add_argument('--qual', help='Write a file of fake quality scores called outfile.qual, all bases same quality [%(default)s]', metavar='INT')
+parser.add_argument('--fixed_read_length', type=int, help='Length of each read. Only applies if method is tile or uniform. [%(default)s]', default=20000, metavar='INT')
+parser.add_argument('--coverage', type=float, help='Read coverage. Only applies if method is gamma or uniform. [%(default)s]', default=2, metavar='FLOAT')
+
+
+tiling_group = parser.add_argument_group('tiling options')
+tiling_group.add_argument('--tile_step', type=int, help='Distance between start of each read [%(default)s]', default=10000, metavar='INT')
+
+gamma_group = parser.add_argument_group('gamma options')
+gamma_group.add_argument('--gamma_shape', type=float, help='Shape parameter of gamma distribution [%(default)s]', default=1.2, metavar='FLOAT')
+gamma_group.add_argument('--gamma_scale', type=float, help='Scale parameter of gamma distribution [%(default)s]', default=6000, metavar='FLOAT')
+gamma_group.add_argument('--gamma_min_length', type=int, help='Minimum read length [%(default)s]', default=20000, metavar='INT')
+
+ins_group = parser.add_argument_group('options to add insertions to reads')
+ins_group.add_argument('--ins_skip', type=int, help='Insert a random base every --skip bases plus or minus --ins_window. If this option is used, must also use --ins_window.', metavar='INT')
+ins_group.add_argument('--ins_window', type=int, help='See --ins_skip. If this option is used, must also use --ins_skip.', metavar='INT')
+
+
+options = parser.parse_args()
+tasks.make_long_reads(
+    options.infile,
+    options.outfile,
+    method=options.method,
+    fixed_read_length=options.fixed_read_length,
+    coverage=options.coverage,
+    tile_step=options.tile_step,
+    gamma_shape=options.gamma_shape,
+    gamma_scale=options.gamma_scale,
+    gamma_min_length=options.gamma_min_length,
+    seed=options.seed,
+    ins_skip=options.ins_skip,
+    ins_window=options.ins_window
+)
+
+if options.qual:
+    tasks.fastaq_to_fake_qual(options.outfile, options.outfile + '.qual', q=options.qual)
diff --git a/scripts/fastaq_make_random_contigs b/scripts/fastaq_make_random_contigs
new file mode 100755
index 0000000..c6774fe
--- /dev/null
+++ b/scripts/fastaq_make_random_contigs
@@ -0,0 +1,25 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Makes a multi-fasta file of random sequences, all of the same length. Each base has equal chance of being A,C,G or T',
+    usage = '%(prog)s [options] <number of sequences> <length of each sequence> <fasta out>')
+parser.add_argument('--first_number', type=int, help='If numbering the sequences, the first sequence gets this number [%(default)s]', default=1)
+parser.add_argument('--name_by_letters', action='store_true', help='Name the contigs A,B,C,... will start at A again if you get to Z')
+parser.add_argument('--prefix', help='Prefix to add to start of every sequence name', default='')
+parser.add_argument('--seed', type=int, help='Seed for random number generator. Default is to use python\'s default', default=None)
+parser.add_argument('contigs', type=int, help='Nunber of contigs to make')
+parser.add_argument('length', type=int, help='Length of each contig')
+parser.add_argument('outfile', help='Name of output file')
+options = parser.parse_args()
+tasks.make_random_contigs(
+    options.contigs,
+    options.length,
+    options.outfile,
+    name_by_letters=options.name_by_letters,
+    prefix=options.prefix,
+    seed=options.seed,
+    first_number=options.first_number
+)
diff --git a/scripts/fastaq_merge b/scripts/fastaq_merge
new file mode 100755
index 0000000..d919323
--- /dev/null
+++ b/scripts/fastaq_merge
@@ -0,0 +1,18 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Converts multi fasta/q file to single sequence file, preserving original order of sequences',
+    usage = '%(prog)s <infile> <outfile>')
+parser.add_argument('infile', help='Name of input file. Can be any of FASTA, FASTQ, GFF3, EMBL, GBK, Phylip')
+parser.add_argument('outfile', help='Name of output file')
+parser.add_argument('-n', '--name', help='Name of sequence in output file [%(default)s]', default='union')
+options = parser.parse_args()
+tasks.merge_to_one_seq(
+    options.infile,
+    options.outfile,
+    seqname=options.name
+)
+
diff --git a/scripts/fastaq_replace_bases b/scripts/fastaq_replace_bases
new file mode 100755
index 0000000..6ce2fc0
--- /dev/null
+++ b/scripts/fastaq_replace_bases
@@ -0,0 +1,14 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Replaces all occurences of one letter with another in a fasta/q file',
+    usage = '%(prog)s <fasta/q in> <outfile> <old> <new>')
+parser.add_argument('infile', help='Name of input fasta/q file')
+parser.add_argument('outfile', help='Name of output file')
+parser.add_argument('old', help='Base to be replaced')
+parser.add_argument('new', help='Replace with this letter')
+options = parser.parse_args()
+tasks.replace_bases(options.infile, options.outfile, options.old, options.new)
diff --git a/scripts/fastaq_reverse_complement b/scripts/fastaq_reverse_complement
new file mode 100755
index 0000000..147e01f
--- /dev/null
+++ b/scripts/fastaq_reverse_complement
@@ -0,0 +1,12 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Reverse complements all sequences in a fasta/q file',
+    usage = '%(prog)s [options] <fasta/q in> <fasta/q out>')
+parser.add_argument('infile', help='Name of input fasta/q file')
+parser.add_argument('outfile', help='Name of output fasta/q file')
+options = parser.parse_args()
+tasks.reverse_complement(options.infile, options.outfile)
diff --git a/scripts/fastaq_scaffolds_to_contigs b/scripts/fastaq_scaffolds_to_contigs
new file mode 100755
index 0000000..46d4861
--- /dev/null
+++ b/scripts/fastaq_scaffolds_to_contigs
@@ -0,0 +1,13 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Creates a file of contigs from a file of scaffolds - i.e. breaks at every gap in the input',
+    usage = '%(prog)s [options] <infile> <outfile>')
+parser.add_argument('--number_contigs', action='store_true', help='Use this to enumerate contig names 1,2,3,... within each scaffold')
+parser.add_argument('infile', help='Name of input fasta/q file')
+parser.add_argument('outfile', help='Name of output contigs file')
+options = parser.parse_args()
+tasks.scaffolds_to_contigs(options.infile, options.outfile, number_contigs=options.number_contigs)
diff --git a/scripts/fastaq_search_for_seq b/scripts/fastaq_search_for_seq
new file mode 100755
index 0000000..c00ed7a
--- /dev/null
+++ b/scripts/fastaq_search_for_seq
@@ -0,0 +1,13 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Searches for an exact match on a given string and its reverese complement, in every sequences of a fasta/q file. Case insensitive. Guaranteed to find all hits',
+    usage = '%(prog)s [options] <fasta/q in> <outfile> <search_string>')
+parser.add_argument('infile', help='Name of input fasta/q file')
+parser.add_argument('outfile', help='Name of outputfile. Tab-delimited output: sequence name, position, strand')
+parser.add_argument('search_string', help='String to search for in the sequences')
+options = parser.parse_args()
+tasks.search_for_seq(options.infile, options.outfile, options.search_string)
diff --git a/scripts/fastaq_sequence_trim b/scripts/fastaq_sequence_trim
new file mode 100755
index 0000000..50a4f34
--- /dev/null
+++ b/scripts/fastaq_sequence_trim
@@ -0,0 +1,23 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Trims sequences off the start of all sequences in a pair of fasta/q files, whenever there is a perfect match. Only keeps a read pair if both reads of the pair are at least a minimum length after any trimming',
+    usage = '%(prog)s [options] <fasta/q 1 in> <fastaq/2 in> <out 1> <out 2> <trim_seqs>')
+parser.add_argument('--min_length', type=int, help='Minimum length of output sequences [%(default)s]', default=50, metavar='INT')
+parser.add_argument('infile_1', help='Name of forward fasta/q file to be trimmed', metavar='fasta/q 1 in')
+parser.add_argument('infile_2', help='Name of reverse fasta/q file to be trimmed', metavar='fasta/q 2 in')
+parser.add_argument('outfile_1', help='Name of output forward fasta/q file', metavar='out_1')
+parser.add_argument('outfile_2', help='Name of output reverse fasta/q file', metavar='out_2')
+parser.add_argument('trim_seqs', help='Name of fasta/q file of sequences to search for at the start of each input sequence', metavar='trim_seqs')
+options = parser.parse_args()
+tasks.sequence_trim(
+    options.infile_1,
+    options.infile_2,
+    options.outfile_1,
+    options.outfile_2,
+    options.trim_seqs,
+    min_length=options.min_length
+)
diff --git a/scripts/fastaq_split_by_base_count b/scripts/fastaq_split_by_base_count
new file mode 100755
index 0000000..dd7b43d
--- /dev/null
+++ b/scripts/fastaq_split_by_base_count
@@ -0,0 +1,15 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Splits a multi fasta/q file into separate files. Does not split sequences. Puts up to max_bases into each split file. The exception is that any sequence longer than max_bases is put into its own file.',
+    usage = '%(prog)s [options] <fasta/q in> <prefix of output files> <max_bases>')
+parser.add_argument('infile', help='Name of input fasta/q file to be split')
+parser.add_argument('outprefix', help='Name of output fasta/q file')
+parser.add_argument('max_bases', type=int, help='Max bases in each output split file', metavar='max_bases')
+parser.add_argument('--max_seqs', type=int, help='Max number of sequences in each output split file [no limit]', metavar='INT')
+
+options = parser.parse_args()
+tasks.split_by_base_count(options.infile, options.outprefix, options.max_bases, options.max_seqs)
diff --git a/scripts/fastaq_strip_illumina_suffix b/scripts/fastaq_strip_illumina_suffix
new file mode 100755
index 0000000..6a29a42
--- /dev/null
+++ b/scripts/fastaq_strip_illumina_suffix
@@ -0,0 +1,12 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Strips /1 or /2 off the end of every read name in a fasta/q file',
+    usage = '%(prog)s [options] <fasta/q in> <fasta/q out>')
+parser.add_argument('infile', help='Name of input fasta/q file')
+parser.add_argument('outfile', help='Name of output fasta/q file')
+options = parser.parse_args()
+tasks.strip_illumina_suffix(options.infile, options.outfile)
diff --git a/scripts/fastaq_to_fake_qual b/scripts/fastaq_to_fake_qual
new file mode 100755
index 0000000..272f7a3
--- /dev/null
+++ b/scripts/fastaq_to_fake_qual
@@ -0,0 +1,18 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Makes fake quality scores file from a fasta/q file',
+    usage = '%(prog)s <infile> <outfile>')
+parser.add_argument('infile', help='Name of input file')
+parser.add_argument('outfile', help='Name of output file')
+parser.add_argument('-q', '--qual', type=int, help='Quality score to assign to all bases [%(default)s]', default=40)
+options = parser.parse_args()
+tasks.fastaq_to_fake_qual(
+    options.infile,
+    options.outfile,
+    q=options.qual
+)
+
diff --git a/scripts/fastaq_to_fasta b/scripts/fastaq_to_fasta
new file mode 100755
index 0000000..742e95f
--- /dev/null
+++ b/scripts/fastaq_to_fasta
@@ -0,0 +1,19 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Converts sequence file to FASTA format',
+    usage = '%(prog)s <infile> <outfile>')
+parser.add_argument('infile', help='Name of input file. Can be any of FASTA, FASTQ, GFF3, EMBL, GBK, Phylip')
+parser.add_argument('outfile', help='Name of output file')
+parser.add_argument('-l', '--line_length', type=int, help='Number of bases on each sequence line of output file [%(default)s]', default=60)
+parser.add_argument('-s', '--strip_after_whitespace', action='store_true', help='Remove everything after first whitesapce in every sequence name')
+options = parser.parse_args()
+tasks.to_fasta(
+    options.infile,
+    options.outfile,
+    line_length=options.line_length,
+    strip_after_first_whitespace=options.strip_after_whitespace
+)
diff --git a/scripts/fastaq_to_mira_xml b/scripts/fastaq_to_mira_xml
new file mode 100755
index 0000000..582d669
--- /dev/null
+++ b/scripts/fastaq_to_mira_xml
@@ -0,0 +1,12 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Creates an xml file from a fasta/q file of reads, for use with Mira assembler',
+    usage = '%(prog)s [options] <fastq_in> <xml_out>')
+parser.add_argument('infile', help='Name of input fasta/q file')
+parser.add_argument('xml_out', help='Name of output xml file')
+options = parser.parse_args()
+tasks.fastaq_to_mira_xml(options.infile, options.xml_out)
diff --git a/scripts/fastaq_to_orfs_gff b/scripts/fastaq_to_orfs_gff
new file mode 100755
index 0000000..0098023
--- /dev/null
+++ b/scripts/fastaq_to_orfs_gff
@@ -0,0 +1,13 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Writes a GFF file of open reading frames from a fasta/q file',
+    usage = '%(prog)s [options] <fasta/q in> <gff_out>')
+parser.add_argument('--min_length', type=int, help='Minimum length of ORF, in nucleotides [%(default)s]', default=300, metavar='INT')
+parser.add_argument('infile', help='Name of input fasta/q file')
+parser.add_argument('gff_out', help='Name of output gff file')
+options = parser.parse_args()
+tasks.fastaq_to_orfs_gff(options.infile, options.gff_out, min_length=options.min_length)
diff --git a/scripts/fastaq_to_perfect_reads b/scripts/fastaq_to_perfect_reads
new file mode 100755
index 0000000..6f3ca10
--- /dev/null
+++ b/scripts/fastaq_to_perfect_reads
@@ -0,0 +1,86 @@
+#!/usr/bin/env python3
+
+import argparse
+import random
+from math import floor, ceil
+from fastaq import sequences, utils
+import sys
+
+parser = argparse.ArgumentParser(
+    description = 'Makes perfect paired end fastq reads from a fasta/q file, with insert sizes sampled from a normal distribution. Read orientation is innies. Output is an interleaved fastq file.',
+    usage = '%(prog)s <fasta/q in> <out.fastq> <mean insert size> <insert std deviation> <mean coverage> <read length>')
+parser.add_argument('infile', help='Name of input fasta/q file')
+parser.add_argument('outfile', help='Name of output fastq file')
+parser.add_argument('mean_insert', type=int, help='Mean insert size of read pairs', metavar='mean insert size')
+parser.add_argument('insert_std', type=float, help='Standard devation of insert size', metavar='insert std deviation')
+parser.add_argument('coverage', type=float, help='Mean coverage of the reads', metavar='mean coverage')
+parser.add_argument('readlength', type=int, help='Length of each read', metavar='read length')
+parser.add_argument('--fragments', help='Write FASTA sequences of fragments (i.e. read pairs plus sequences in between them) to the given filename', metavar='FILENAME')
+parser.add_argument('--no_n', action='store_true', help='Don\'t allow any N or n characters in the reads')
+parser.add_argument('--seed', type=int, help='Seed for random number generator. Default is to use python\'s default', default=None, metavar='INT')
+options = parser.parse_args()
+
+random.seed(a=options.seed)
+
+seq_reader = sequences.file_reader(options.infile)
+fout = utils.open_file_write(options.outfile)
+pair_counter = 1
+
+if options.fragments:
+    fout_frags = utils.open_file_write(options.fragments)
+
+for ref in seq_reader:
+    # check if current seq is long enough
+    if len(ref) < options.mean_insert + 4 * options.insert_std:
+        print('Warning, sequence ', ref.id, ' too short.  Skipping it...', file=sys.stderr)
+        continue
+
+    # work out how many reads to simulate
+    read_pairs = int(0.5 * options.coverage * len(ref) / options.readlength)
+
+    # it's possible that we pick the same fragment twice, in which case the
+    # reads would get the same name. So remember the frag coords
+    used_fragments = {}  # (middle_position, length) => count
+
+    # do the simulation:  pick insert size from normal distribution, and
+    # position in genome from uniform distribution
+    x = 0
+    while x < read_pairs:
+        isize = int(random.normalvariate(options.mean_insert, options.insert_std))
+        while isize > len(ref) or isize < options.readlength:
+            isize = int(random.normalvariate(options.mean_insert, options.insert_std))
+        middle_pos = random.randint(ceil(0.5 *isize), floor(len(ref) - 0.5 * isize))
+        read_start1 = int(middle_pos - ceil(0.5 * isize))
+        read_start2 = read_start1 + isize - options.readlength
+
+        readname = ':'.join([ref.id, str(pair_counter), str(read_start1+1), str(read_start2+1)])
+
+        fragment = (middle_pos, isize)
+        if fragment in used_fragments:
+            used_fragments[fragment] += 1
+            readname += '.dup.' + str(used_fragments[fragment])
+        else:
+            used_fragments[fragment] = 1
+
+        read1 = sequences.Fastq(readname + '/1', ref.seq[read_start1:read_start1 + options.readlength], 'I' * options.readlength)
+        read2 = sequences.Fastq(readname + '/2', ref.seq[read_start2:read_start2 + options.readlength], 'I' * options.readlength)
+
+
+        if options.no_n and ('n' in read1.seq or 'N' in read1.seq or 'n' in read2.seq or 'N' in read2.seq):
+            continue
+
+        read2.revcomp()
+
+        print(read1, file=fout)
+        print(read2, file=fout)
+
+        if options.fragments:
+            frag = sequences.Fasta(readname, ref.seq[read_start1:read_start2 + options.readlength])
+            print(frag, file=fout_frags)
+
+        pair_counter += 1
+        x += 1
+
+utils.close(fout)
+if options.fragments:
+    utils.close(fout_frags)
diff --git a/scripts/fastaq_to_quasr_primers_file b/scripts/fastaq_to_quasr_primers_file
new file mode 100755
index 0000000..8e5bf7c
--- /dev/null
+++ b/scripts/fastaq_to_quasr_primers_file
@@ -0,0 +1,12 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Converts a fasta/q file to QUASR primers format: just the sequence on each line and its reverse complement, tab separated',
+    usage = '%(prog)s <fasta/q in> <outfile>')
+parser.add_argument('infile', help='Name of input fasta/q file')
+parser.add_argument('outfile', help='Name of output file')
+options = parser.parse_args()
+tasks.to_quasr_primers(options.infile, options.outfile)
diff --git a/scripts/fastaq_to_random_subset b/scripts/fastaq_to_random_subset
new file mode 100755
index 0000000..b4f11c5
--- /dev/null
+++ b/scripts/fastaq_to_random_subset
@@ -0,0 +1,36 @@
+#!/usr/bin/env python3
+
+import sys
+import argparse
+import random
+from fastaq import sequences, utils
+
+parser = argparse.ArgumentParser(
+    description = 'Takes a random subset of reads from a fasta/q file and optionally the corresponding read ' +
+                  'from a mates file.  Ouptut is interleaved if mates file given',
+    usage = '%(prog)s [options] <fasta/q in> <outfile> <probablilty of keeping read (pair) in [0,100]>')
+parser.add_argument('--mate_file', help='Name of fasta/q mates file')
+parser.add_argument('infile', help='Name of input fasta/q file')
+parser.add_argument('outfile', help='Name of fasta/q output file')
+parser.add_argument('probability', type=int, help='Probability of keeping any given read (pair) in [0,100]', metavar='INT')
+options = parser.parse_args()
+
+seq_reader = sequences.file_reader(options.infile)
+fout = utils.open_file_write(options.outfile)
+
+if options.mate_file:
+    mate_seq_reader = sequences.file_reader(options.mate_file)
+
+for seq in seq_reader:
+    if options.mate_file:
+        try:
+            mate_seq = next(mate_seq_reader)
+        except StopIteration:
+            print('Error! Didn\'t get mate for read', seq.id, file=sys.stderr)
+            sys.exit(1)
+    if random.randint(0, 100) <= options.probability:
+        print(seq, file=fout)
+        if options.mate_file:
+            print(mate_seq, file=fout)
+
+utils.close(fout)
diff --git a/scripts/fastaq_to_tiling_bam b/scripts/fastaq_to_tiling_bam
new file mode 100755
index 0000000..9b9738d
--- /dev/null
+++ b/scripts/fastaq_to_tiling_bam
@@ -0,0 +1,79 @@
+#!/usr/bin/env python3
+
+import argparse
+import sys
+import os
+from fastaq import sequences, utils
+
+parser = argparse.ArgumentParser(
+    description = 'Takes a fasta/q file. Makes a BAM file containing perfect (unpaired) reads tiling the whole genome',
+    usage = '%(prog)s [options] <fasta/q in> <read length> <read step> <read prefix> <out.bam>',
+    epilog = 'Important: assumes that samtools is in your path')
+parser.add_argument('infile', help='Name of input fasta/q file')
+parser.add_argument('read_length', type=int, help='Length of reads')
+parser.add_argument('read_step', type=int, help='Distance between start of each read')
+parser.add_argument('read_prefix', help='Prefix of read names')
+parser.add_argument('outfile', help='Name of output BAM file')
+parser.add_argument('--read_group', help='Add the given read group ID to all reads [%(default)s]' ,default='42')
+options = parser.parse_args()
+
+# make a header first  - we need to add the @RG line to the default header made by samtools
+tmp_empty_file = options.outfile + '.tmp.empty'
+f = utils.open_file_write(tmp_empty_file)
+utils.close(f)
+try:
+    f = os.popen('samtools view -H -T ' + options.infile + ' ' + tmp_empty_file)
+except IOError:
+    print('Error making tmp header file', file=sys.stderr)
+    sys.exit(1)
+
+header_lines = f.readlines()
+header_lines.append('@RG\tID:' + options.read_group + '\tSM:FAKE')
+f.close()
+os.unlink(tmp_empty_file)
+
+seq_reader = sequences.file_reader(options.infile)
+try:
+    f = os.popen('samtools view -hbS - > ' + options.outfile, 'w')
+except IOError:
+    print("Error opening for writing BAM file '" + options.outfile + "'", file=sys.stderr)
+    sys.exit(1)
+
+print(''.join(header_lines), file=f)
+
+for seq in seq_reader:
+    end_range = len(seq)
+    if len(seq) < options.read_length:
+        end_range = 1
+    for i in range(0, end_range, options.read_step):
+        if len(seq) <= options.read_length:
+            start = 0
+            end = len(seq) - 1
+        else:
+            start = i
+            end = start + options.read_length - 1
+
+            if end > len(seq) - 1:
+                end  = len(seq) - 1
+                start = end - options.read_length + 1
+
+        read = sequences.Fastq(options.read_prefix + ':' + seq.id + ':' + str(start + 1) + ':' + str(end + 1), seq[start:end+1], 'I' * (end - start + 1))
+
+        print ('\t'.join([read.id,
+                         '0',
+                         seq.id,
+                         str(start + 1),
+                         '60',
+                         str(len(read)) + 'M',
+                         '*',
+                         '*',
+                         '*',
+                         read.seq,
+                         read.qual,
+                         'RG:Z:' + options.read_group]), file=f)
+
+        if end == len(seq) - 1:
+            break
+
+f.close()
+
diff --git a/scripts/fastaq_to_unique_by_id b/scripts/fastaq_to_unique_by_id
new file mode 100755
index 0000000..e743a92
--- /dev/null
+++ b/scripts/fastaq_to_unique_by_id
@@ -0,0 +1,12 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Removes duplicate sequences from a fasta/q file, based on their names. If the same name is found more than once, then the longest sequence is kept. Order of sequences is preserved in output',
+    usage = '%(prog)s <infile> <outfile>')
+parser.add_argument('infile', help='Name of input fasta/q file')
+parser.add_argument('outfile', help='Name of output fasta/q file')
+options = parser.parse_args()
+tasks.to_unique_by_id(options.infile, options.outfile)
diff --git a/scripts/fastaq_translate b/scripts/fastaq_translate
new file mode 100755
index 0000000..9ec04c7
--- /dev/null
+++ b/scripts/fastaq_translate
@@ -0,0 +1,13 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Translates all sequences in a fasta or fastq file. Output is always fasta format',
+    usage = '%(prog)s <in.fasta/q> <out.fasta>')
+parser.add_argument('--frame', type=int, choices=[0,1,2], help='Frame to translate [%(default)s]', default=0)
+parser.add_argument('infile', help='Name of fasta/q file to be translated', metavar='in.fasta/q')
+parser.add_argument('outfile', help='Name of output fasta file', metavar='out.fasta')
+options = parser.parse_args()
+tasks.translate(options.infile, options.outfile, frame=options.frame)
diff --git a/scripts/fastaq_trim_Ns_at_end b/scripts/fastaq_trim_Ns_at_end
new file mode 100755
index 0000000..200d71f
--- /dev/null
+++ b/scripts/fastaq_trim_Ns_at_end
@@ -0,0 +1,12 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Trims any Ns off each sequence in a fasta/q file. Does nothing to gaps in the middle, just trims the ends',
+    usage = '%(prog)s [options] <fasta/q in> <fasta/q out>')
+parser.add_argument('infile', help='Name of input fasta/q file')
+parser.add_argument('outfile', help='Name of output fasta/q file')
+options = parser.parse_args()
+tasks.trim_Ns_at_end(options.infile, options.outfile)
diff --git a/scripts/fastaq_trim_ends b/scripts/fastaq_trim_ends
new file mode 100755
index 0000000..ffc662d
--- /dev/null
+++ b/scripts/fastaq_trim_ends
@@ -0,0 +1,14 @@
+#!/usr/bin/env python3
+
+import argparse
+from fastaq import tasks
+
+parser = argparse.ArgumentParser(
+    description = 'Trims set number of bases off each sequence in a fasta/q file',
+    usage = '%(prog)s [options] <fasta/q in> <bases off start> <bases off end> <fasta/q out>')
+parser.add_argument('infile', help='Name of input fasta/q file')
+parser.add_argument('start_trim', type=int, help='Number of bases to trim off start')
+parser.add_argument('end_trim', type=int, help='Number of bases to trim off end')
+parser.add_argument('outfile', help='Name of output fasta/q file')
+options = parser.parse_args()
+tasks.trim(options.infile, options.outfile, options.start_trim, options.end_trim)
diff --git a/setup.py b/setup.py
new file mode 100644
index 0000000..3064862
--- /dev/null
+++ b/setup.py
@@ -0,0 +1,21 @@
+import os
+import glob
+from setuptools import setup, find_packages
+
+def read(fname):
+    return open(os.path.join(os.path.dirname(__file__), fname)).read()
+
+setup(
+    name='Fastaq',
+    version='1.5.0',
+    description='Scripts to manipulate FASTA and FASTQ files, plus API for developers',
+    long_description=read('README.md'),
+    packages = find_packages(),
+    author='Martin Hunt',
+    author_email='mh12 at sanger.ac.uk',
+    url='https://github.com/sanger-pathogens/Fastaq',
+    scripts=glob.glob('scripts/*'),
+    test_suite='nose.collector',
+    install_requires=['nose >= 1.3'],
+    license='GPLv3',
+)

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



More information about the debian-med-commit mailing list