pax_global_header00006660000000000000000000000064132425153650014520gustar00rootroot0000000000000052 comment=892f4b940ea681dc98d89307789bdf4146fc2b87 Fastaq-3.17.0/000077500000000000000000000000001324251536500130275ustar00rootroot00000000000000Fastaq-3.17.0/.gitignore000066400000000000000000000004571324251536500150250ustar00rootroot00000000000000*.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 Fastaq-3.17.0/.travis.yml000066400000000000000000000001221324251536500151330ustar00rootroot00000000000000language: python python: - "3.4" sudo: false script: - "python setup.py test" Fastaq-3.17.0/AUTHORS000066400000000000000000000000451324251536500140760ustar00rootroot00000000000000Martin Hunt (path-help@sanger.ac.uk) Fastaq-3.17.0/LICENSE000066400000000000000000001046571324251536500140510ustar00rootroot00000000000000Copyright (c) 2013 - 2017 by Genome Research Ltd. This is free software, licensed under: 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}. Fastaq-3.17.0/MANIFEST.in000066400000000000000000000000651324251536500145660ustar00rootroot00000000000000recursive-include pyfastaq/tests *.txt *.py *_test_* Fastaq-3.17.0/README.md000066400000000000000000000140261324251536500143110ustar00rootroot00000000000000Fastaq ====== Python3 script to manipulate FASTA and FASTQ (and other format) files, plus API for developers Installation ------------ Install with pip3: pip3 install pyfastaq Alternatively, you can download the latest release from this github repository, or clone the repository. Then run the tests: python3 setup.py test If the tests all pass, install: python3 setup.py install Usage ----- The installation will put a single script called `fastaq` in your path. The usage is: fastaq [options] Key points: * To list the available commands and brief descriptions, just run `fastaq` * Use `fastaq command -h` or `fastaq command --help` to get a longer description and the usage of that command. * The type of input file is automatically detected. Currently supported: `FASTA`, `FASTQ`, `GFF3`, `EMBL`, `GBK`, `Phylip`. * `fastaq` only manipulates sequences (and quality scores if present), so annotation is ignored where present in the input. * 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 commands can be piped together. See the example below. 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 Available commands ------------------ | Command | Description | |-----------------------|----------------------------------------------------------------------| | acgtn_only | Replace every non acgtnACGTN with an N | | add_indels | Deletes or inserts bases at given position(s) | | caf_to_fastq | Converts a CAF file to FASTQ format | | capillary_to_pairs | Converts file of capillary reads to paired and unpaired files | | chunker | Splits sequences into equal sized chunks | | count_sequences | Counts the sequences in input file | | deinterleave | Splits interleaved paired file into two separate files | | enumerate_names | Renames sequences in a file, calling them 1,2,3... etc | | expand_nucleotides | Makes every combination of degenerate nucleotides | | fasta_to_fastq | Convert FASTA and .qual to FASTQ | | filter | Filter sequences to get a subset of them | | get_ids | Get the ID of each sequence | | get_seq_flanking_gaps | Gets the sequences flanking gaps | | interleave | Interleaves two files, output is alternating between fwd/rev reads | | make_random_contigs | Make contigs of random sequence | | merge | Converts multi sequence file to a single sequence | | replace_bases | Replaces all occurrences of one letter with another | | reverse_complement | Reverse complement all sequences | | scaffolds_to_contigs | Creates a file of contigs from a file of scaffolds | | search_for_seq | Find all exact matches to a string (and its reverse complement) | | sequence_trim | Trim exact matches to a given string off the start of every sequence | | sort_by_name | Sorts sequences in lexographical (name) order | | sort_by_size | Sorts sequences in length order | | split_by_base_count | Split multi sequence file into separate files | | strip_illumina_suffix | Strips /1 or /2 off the end of every read name | | to_fake_qual | Make fake quality scores file | | to_fasta | Converts a variety of input formats to nicely formatted FASTA format | | to_mira_xml | Create an xml file from a file of reads, for use with Mira assembler | | to_orfs_gff | Writes a GFF file of open reading frames | | to_perfect_reads | Make perfect paired reads from reference | | to_random_subset | Make a random sample of sequences (and optionally mates as well) | | to_tiling_bam | Make a BAM file of reads uniformly spread across the input reference | | to_unique_by_id | Remove duplicate sequences, based on their names. Keep longest seqs | | translate | Translate all sequences in input nucleotide sequences | | trim_Ns_at_end | Trims all Ns at the start/end of all sequences | | trim_contigs | Trims a set number of bases off the end of every contig | | trim_ends | Trim fixed number of bases of start and/or end of every sequence | | version | Print version number and exit | For developers -------------- Here is a template for counting the sequences in a FASTA or FASTQ file: from pyfastaq 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 the input file type and whether gzipped or not is automatic. See help(sequences) for the various methods already defined in the classes Fasta and Fastq. --------------------------------- Build status: [![Build Status](https://travis-ci.org/sanger-pathogens/Fastaq.svg?branch=master)](https://travis-ci.org/sanger-pathogens/Fastaq) Fastaq-3.17.0/pyfastaq/000077500000000000000000000000001324251536500146575ustar00rootroot00000000000000Fastaq-3.17.0/pyfastaq/__init__.py000066400000000000000000000004341324251536500167710ustar00rootroot00000000000000from pkg_resources import get_distribution try: __version__ = get_distribution('pyfastaq').version except: __version__ = 'local' __all__ = [ 'caf', 'genetic_codes', 'utils', 'sequences', 'tasks', 'intervals', 'runners' ] from pyfastaq import * Fastaq-3.17.0/pyfastaq/caf.py000066400000000000000000000040521324251536500157630ustar00rootroot00000000000000from pyfastaq import sequences, utils class Error (Exception): pass def file_reader(fname): f = utils.open_file_read(fname) c = Caf() while c.get_next_from_file(f): yield c utils.close(f) class Caf: def __init__(self): self.id = None self.seq = None self.insert_min = None self.insert_max = None self.ligation = None self.clone = None self.clip_start = None self.clip_end = None def __eq__(self, other): if type(other) is type(self): return self.__dict__ == other.__dict__ return False def get_next_from_file(self, f): self.__init__() line = f.readline() if not line: return None while line == '\n': line = f.readline() if not line.startswith('DNA : '): raise Error("Error reading caf file. Expected line starting with 'DNA : ...'") self.id = line.rstrip().split()[2] line = f.readline() seq = [] while line != '\n': seq.append(line.rstrip()) line = f.readline() self.seq = sequences.Fasta(self.id, ''.join(seq)) line = f.readline() if not line.startswith('BaseQuality : '): raise Error("Error reading caf file. Expected line starting with 'BaseQuality : ...'") quals = [int(x) for x in f.readline().rstrip().split()] self.seq = self.seq.to_Fastq(quals) line = f.readline() assert line == '\n' line = f.readline() while line not in ['', '\n']: a = line.rstrip().split() if a[0] == 'Insert_size': self.insert_min, self.insert_max = int(a[1]), int(a[2]) elif a[0] == 'Ligation_no': self.ligation = a[1] elif a[0] == 'Clone': self.clone = a[1] elif a[0] == 'Clipping' and a[1] == 'QUAL': self.clip_start, self.clip_end = int(a[2]) - 1, int(a[3]) - 1 line = f.readline() return True Fastaq-3.17.0/pyfastaq/genetic_codes.py000066400000000000000000000047621324251536500200350ustar00rootroot00000000000000# see http://www.ncbi.nlm.nih.gov/Taxonomy/Utils/wprintgc.cgi codes = {} starts = {} #standard genetic code codes[1] = { 'TTT': 'F', 'TTC': 'F', 'TTA': 'L', 'TTG': 'L', 'TCT': 'S', 'TCC': 'S', 'TCA': 'S', 'TCG': 'S', 'TAT': 'Y', 'TAC': 'Y', 'TAA': '*', 'TAG': '*', 'TGT': 'C', 'TGC': 'C', 'TGA': '*', 'TGG': 'W', 'CTT': 'L', 'CTC': 'L', 'CTA': 'L', 'CTG': 'L', 'CCT': 'P', 'CCC': 'P', 'CCA': 'P', 'CCG': 'P', 'CAT': 'H', 'CAC': 'H', 'CAA': 'Q', 'CAG': 'Q', 'CGT': 'R', 'CGC': 'R', 'CGA': 'R', 'CGG': 'R', 'ATT': 'I', 'ATC': 'I', 'ATA': 'I', 'ATG': 'M', 'ACT': 'T', 'ACC': 'T', 'ACA': 'T', 'ACG': 'T', 'AAT': 'N', 'AAC': 'N', 'AAA': 'K', 'AAG': 'K', 'AGT': 'S', 'AGC': 'S', 'AGA': 'R', 'AGG': 'R', 'GTT': 'V', 'GTC': 'V', 'GTA': 'V', 'GTG': 'V', 'GCT': 'A', 'GCC': 'A', 'GCA': 'A', 'GCG': 'A', 'GAT': 'D', 'GAC': 'D', 'GAA': 'E', 'GAG': 'E', 'GGT': 'G', 'GGC': 'G', 'GGA': 'G', 'GGG': 'G', } starts[1] = set([ 'TTG', 'CTG', 'ATG', ]) #mycoplasma genetic code codes[4] = { 'TTT': 'F', 'TTC': 'F', 'TTA': 'L', 'TTG': 'L', 'TCT': 'S', 'TCC': 'S', 'TCA': 'S', 'TCG': 'S', 'TAT': 'Y', 'TAC': 'Y', 'TAA': '*', 'TAG': '*', 'TGT': 'C', 'TGC': 'C', 'TGA': 'W', 'TGG': 'W', 'CTT': 'L', 'CTC': 'L', 'CTA': 'L', 'CTG': 'L', 'CCT': 'P', 'CCC': 'P', 'CCA': 'P', 'CCG': 'P', 'CAT': 'H', 'CAC': 'H', 'CAA': 'Q', 'CAG': 'Q', 'CGT': 'R', 'CGC': 'R', 'CGA': 'R', 'CGG': 'R', 'ATT': 'I', 'ATC': 'I', 'ATA': 'I', 'ATG': 'M', 'ACT': 'T', 'ACC': 'T', 'ACA': 'T', 'ACG': 'T', 'AAT': 'N', 'AAC': 'N', 'AAA': 'K', 'AAG': 'K', 'AGT': 'S', 'AGC': 'S', 'AGA': 'R', 'AGG': 'R', 'GTT': 'V', 'GTC': 'V', 'GTA': 'V', 'GTG': 'V', 'GCT': 'A', 'GCC': 'A', 'GCA': 'A', 'GCG': 'A', 'GAT': 'D', 'GAC': 'D', 'GAA': 'E', 'GAG': 'E', 'GGT': 'G', 'GGC': 'G', 'GGA': 'G', 'GGG': 'G' } starts[4] = set([ 'TTA', 'TTG', 'CTG', 'ATT', 'ATC', 'ATA', 'ATG', 'GTG', ]) # Bacterial, Archaeal and Plant Plastid Code codes[11] = codes[1] starts[11] = set([ 'TTG', 'CTG', 'ATT', 'ATC', 'ATA', 'ATG', 'GTG', ]) Fastaq-3.17.0/pyfastaq/intervals.py000066400000000000000000000073161324251536500172470ustar00rootroot00000000000000class 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 distance_to_point(self, p): '''Returns the distance from the point to the interval. Zero if the point lies inside the interval.''' if self.start <= p <= self.end: return 0 else: return min(abs(self.start - p), abs(self.end - p)) 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]) Fastaq-3.17.0/pyfastaq/runners/000077500000000000000000000000001324251536500163535ustar00rootroot00000000000000Fastaq-3.17.0/pyfastaq/runners/__init__.py000066400000000000000000000000001324251536500204520ustar00rootroot00000000000000Fastaq-3.17.0/pyfastaq/runners/acgtn_only.py000066400000000000000000000007171324251536500210670ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = 'Replaces any character that is not one of acgtACGTnN with an N', usage = 'fastaq acgtn_only [options] ') parser.add_argument('infile', help='Name of input file') parser.add_argument('outfile', help='Name of output file') options = parser.parse_args() tasks.acgtn_only(options.infile, options.outfile) Fastaq-3.17.0/pyfastaq/runners/add_indels.py000066400000000000000000000101671324251536500210200ustar00rootroot00000000000000import argparse import sys import random from pyfastaq import sequences, utils, intervals def run(description): parser = argparse.ArgumentParser( description = description, usage = 'fastaq add_indels [options] ') parser.add_argument('infile', help='Name of input file') 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) Fastaq-3.17.0/pyfastaq/runners/caf_to_fastq.py000066400000000000000000000015761324251536500213670ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = 'Converts CAF file to FASTQ format', usage = 'fastaq caf_to_fastq [options] ') parser.add_argument('infile', help='Name of input CAF file.') parser.add_argument('outfile', help='Name of output FASTQ file') parser.add_argument('-c', '--clip', action='store_true', help='Use clipping info to clip reads, if present in the input CAF file (as lines of the form "Clipping QUAL start end"). Default is to not clip') parser.add_argument('-l', '--min_length', type=int, help='Minimum length of sequence to output [%(default)s]', default=1, metavar='INT') options = parser.parse_args() tasks.caf_to_fastq( options.infile, options.outfile, trim=options.clip, min_length=options.min_length ) Fastaq-3.17.0/pyfastaq/runners/capillary_to_pairs.py000066400000000000000000000013121324251536500226020ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = 'Given a 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 = 'fastaq capillary_to_pairs ') 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) Fastaq-3.17.0/pyfastaq/runners/chunker.py000066400000000000000000000030101324251536500203560ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = 'Splits a multi sequence 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 = 'fastaq chunker [options] ') parser.add_argument('infile', help='Name of input file to be split') parser.add_argument('out', help='Prefix of output file. If --onefile used, then name of single output 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('--onefile', action='store_true', help='Output all the sequences in one file') parser.add_argument('--skip_all_Ns', action='store_true', help='Do not output any sequence that consists of all Ns') options = parser.parse_args() if options.onefile: tasks.split_by_fixed_size_onefile( options.infile, options.out, options.chunk_size, options.tolerance, skip_if_all_Ns=options.skip_all_Ns ) else: tasks.split_by_fixed_size( options.infile, options.out, options.chunk_size, options.tolerance, skip_if_all_Ns=options.skip_all_Ns ) Fastaq-3.17.0/pyfastaq/runners/count_sequences.py000066400000000000000000000005731324251536500221350ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = 'Prints the number of sequences in input file to stdout', usage = 'fastaq count_sequences ') parser.add_argument('infile', help='Name of input file') options = parser.parse_args() print(tasks.count_sequences(options.infile)) Fastaq-3.17.0/pyfastaq/runners/deinterleave.py000066400000000000000000000014771324251536500214050ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = 'Deinterleaves sequence file, so that reads are written alternately between two output files', usage = 'fastaq deinterleave [options] ') 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) Fastaq-3.17.0/pyfastaq/runners/enumerate_names.py000066400000000000000000000021011324251536500220670ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = 'Renames sequences in a file, calling them 1,2,3... etc', usage = 'fastaq enumerate_names [options] ') 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('--suffix', help='Add the given string to the end of every name', default=None) 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, suffix=options.suffix) Fastaq-3.17.0/pyfastaq/runners/expand_nucleotides.py000066400000000000000000000011411324251536500225770ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): 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 = 'fastaq expand_nucleotides ') parser.add_argument('infile', help='Name of input file') parser.add_argument('outfile', help='Name of output file') options = parser.parse_args() tasks.expand_nucleotides( options.infile, options.outfile, ) Fastaq-3.17.0/pyfastaq/runners/fasta_to_fastq.py000066400000000000000000000011131324251536500217170ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = description, usage = 'fastaq fasta_to_fastq ') 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) Fastaq-3.17.0/pyfastaq/runners/filter.py000066400000000000000000000040421324251536500202120ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = 'Filters a sequence file by sequence length and/or by name matching a regular expression', usage = 'fastaq filter [options] ') 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.', metavar='FILENAME') parser.add_argument('-v', '--invert', action='store_true', help='Only keep sequences that do not match the filters') mate_group = parser.add_argument_group('Mate file for read pairs options') mate_group.add_argument('--mate_in', help='Name of mates input file. If used, must also provide --mate_out', metavar='FILENAME') mate_group.add_argument('--mate_out', help='Name of mates output file', metavar='FILENAME') mate_group.add_argument('--both_mates_pass', action='store_true', help='By default, if either mate passes filter, then both reads output. Use this flag to require that both reads of a pair pass the filter') parser.add_argument('infile', help='Name of input file to be filtered') parser.add_argument('outfile', help='Name of output 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, mate_in=options.mate_in, mate_out=options.mate_out, both_mates_pass=options.both_mates_pass, ) Fastaq-3.17.0/pyfastaq/runners/get_ids.py000066400000000000000000000006611324251536500203460ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = 'Gets IDs from each sequence in input file', usage = 'fastaq get_ids ') parser.add_argument('infile', help='Name of input file') parser.add_argument('outfile', help='Name of output file') options = parser.parse_args() tasks.get_ids(options.infile, options.outfile) Fastaq-3.17.0/pyfastaq/runners/get_seq_flanking_gaps.py000066400000000000000000000013351324251536500232410ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = description, usage = 'fastaq get_seq_flanking_gaps [options] ') 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 file') parser.add_argument('outfile', help='Name of output file') options = parser.parse_args() tasks.get_seqs_flanking_gaps(options.infile, options.outfile, options.left, options.right) Fastaq-3.17.0/pyfastaq/runners/interleave.py000066400000000000000000000015471324251536500210720ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = description, usage = 'fastaq interleave ') parser.add_argument('--suffix1', help='Suffix to add to all names from infile_1 (if suffix not already present)') parser.add_argument('--suffix2', help='Suffix to add to all names from infile_2 (if suffix not already present)') parser.add_argument('infile_1', help='Name of first input file') parser.add_argument('infile_2', help='Name of second input file') parser.add_argument('outfile', help='Name of output file of interleaved reads') options = parser.parse_args() tasks.interleave( options.infile_1, options.infile_2, options.outfile, suffix1=options.suffix1, suffix2=options.suffix2 ) Fastaq-3.17.0/pyfastaq/runners/make_random_contigs.py000066400000000000000000000025271324251536500227360ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): 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 = 'fastaq make_random_contigs [options] ') 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='Number 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 ) Fastaq-3.17.0/pyfastaq/runners/merge.py000066400000000000000000000011051324251536500200210ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = description, usage = 'fastaq merge [options] ') parser.add_argument('infile', help='Name of input file') 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 ) Fastaq-3.17.0/pyfastaq/runners/replace_bases.py000066400000000000000000000010761324251536500215210ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = description, usage = 'fastaq replace_bases ') parser.add_argument('infile', help='Name of input 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) Fastaq-3.17.0/pyfastaq/runners/reverse_complement.py000066400000000000000000000006471324251536500226320ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = description, usage = 'fastaq reverse_complement ') parser.add_argument('infile', help='Name of input file') parser.add_argument('outfile', help='Name of output file') options = parser.parse_args() tasks.reverse_complement(options.infile, options.outfile) Fastaq-3.17.0/pyfastaq/runners/scaffolds_to_contigs.py000066400000000000000000000013001324251536500231130ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = 'Creates a file of contigs from a file of scaffolds - i.e. breaks at every gap in the input', usage = 'fastaq scaffolds_to_contigs [options] ') 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 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) Fastaq-3.17.0/pyfastaq/runners/search_for_seq.py000066400000000000000000000013651324251536500217150ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = 'Searches for an exact match on a given string and its reverse complement, in every sequence of input sequence file. Case insensitive. Guaranteed to find all hits', usage = 'fastaq search_for_seq [options] ') parser.add_argument('infile', help='Name of input 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) Fastaq-3.17.0/pyfastaq/runners/sequence_trim.py000066400000000000000000000027271324251536500216000ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = 'Trims sequences off the start of all sequences in a pair of sequence 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 = 'fastaq sequence_trim [options] ') parser.add_argument('--min_length', type=int, help='Minimum length of output sequences [%(default)s]', default=50, metavar='INT') parser.add_argument('--revcomp', action='store_true', help='Trim the end of each sequence if it matches the reverse complement. This option is intended for PCR primer trimming') parser.add_argument('infile_1', help='Name of forward fasta/q file to be trimmed') parser.add_argument('infile_2', help='Name of reverse fasta/q file to be trimmed') parser.add_argument('outfile_1', help='Name of output forward fasta/q file') parser.add_argument('outfile_2', help='Name of output reverse fasta/q file') parser.add_argument('trim_seqs', help='Name of file of sequences to search for at the start of each input sequence') 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, check_revcomp=options.revcomp ) Fastaq-3.17.0/pyfastaq/runners/sort_by_name.py000066400000000000000000000006611324251536500214110ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = description, usage = 'fastaq sort_by_name ') parser.add_argument('infile', help='Name of input file') parser.add_argument('outfile', help='Name of output file') options = parser.parse_args() tasks.sort_by_name( options.infile, options.outfile ) Fastaq-3.17.0/pyfastaq/runners/sort_by_size.py000066400000000000000000000011521324251536500214370ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = description, usage = 'fastaq sort_by_size [options] ') parser.add_argument('infile', help='Name of input file') parser.add_argument('outfile', help='Name of output file') parser.add_argument('-r', '--reverse', action='store_true', help='Sort by shortest first instead of the default of longest first') options = parser.parse_args() tasks.sort_by_size( options.infile, options.outfile, smallest_first=options.reverse ) Fastaq-3.17.0/pyfastaq/runners/split_by_base_count.py000066400000000000000000000016531324251536500227610ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = 'Splits a multi sequence 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 = 'fastaq split_by_base_count [options] ') parser.add_argument('infile', help='Name of input file to be split') parser.add_argument('outprefix', help='Name of output 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) Fastaq-3.17.0/pyfastaq/runners/strip_illumina_suffix.py000066400000000000000000000006551324251536500233520ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = description, usage = 'fastaq strip_illumina_suffix ') parser.add_argument('infile', help='Name of input file') parser.add_argument('outfile', help='Name of output file') options = parser.parse_args() tasks.strip_illumina_suffix(options.infile, options.outfile) Fastaq-3.17.0/pyfastaq/runners/to_boulderio.py000066400000000000000000000007431324251536500214170ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = 'Converts input sequence file into "Boulder-IO" format, which is used by primer3', usage = 'fastaq to_boulderio ') parser.add_argument('infile', help='Name of input file') parser.add_argument('outfile', help='Name of output files') options = parser.parse_args() tasks.to_boulderio(options.infile, options.outfile) Fastaq-3.17.0/pyfastaq/runners/to_fake_qual.py000066400000000000000000000011241324251536500213550ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = description, usage = 'fastaq to_fake_qual [options] ') 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 ) Fastaq-3.17.0/pyfastaq/runners/to_fasta.py000066400000000000000000000021321324251536500205230ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = description, usage = 'fastaq to_fasta [options] ') 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. Set to zero for no linebreaks in sequences [%(default)s]', default=60) parser.add_argument('-s', '--strip_after_whitespace', action='store_true', help='Remove everything after first whitespace in every sequence name') parser.add_argument('-u', '--check_unique', action='store_true', help='Die if any of the output sequence names are not unique') options = parser.parse_args() tasks.to_fasta( options.infile, options.outfile, line_length=options.line_length, strip_after_first_whitespace=options.strip_after_whitespace, check_unique=options.check_unique ) Fastaq-3.17.0/pyfastaq/runners/to_mira_xml.py000066400000000000000000000006541324251536500212440ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = description, usage = 'fastaq to_mira_xml ') 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) Fastaq-3.17.0/pyfastaq/runners/to_orfs_gff.py000066400000000000000000000012131324251536500212170ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = 'Writes a GFF file of open reading frames from a sequence file', usage = 'fastaq to_orfs_gff [options] ') 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 file') parser.add_argument('outfile', help='Name of output GFF file') options = parser.parse_args() tasks.fastaq_to_orfs_gff(options.infile, options.outfile, min_length=options.min_length) Fastaq-3.17.0/pyfastaq/runners/to_perfect_reads.py000066400000000000000000000102151324251536500222340ustar00rootroot00000000000000import argparse import random from math import floor, ceil import sys from pyfastaq import sequences, utils def run(description): parser = argparse.ArgumentParser( description = 'Makes perfect paired end fastq reads from a sequence file, with insert sizes sampled from a normal distribution. Read orientation is innies. Output is an interleaved FASTQ file.', usage = 'fastaq to_perfect_reads [options] ') parser.add_argument('infile', help='Name of input file') parser.add_argument('outfile', help='Name of output 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) Fastaq-3.17.0/pyfastaq/runners/to_random_subset.py000066400000000000000000000031061324251536500222740ustar00rootroot00000000000000import argparse import sys import random from pyfastaq import sequences, utils def run(description): parser = argparse.ArgumentParser( description = 'Takes a random subset of reads from a sequence file and optionally the corresponding read ' + 'from a mates file. Output is interleaved if mates file given', usage = 'fastaq to_random_subset [options] ') parser.add_argument('--mate_file', help='Name of mates file') parser.add_argument('--seed', help='Seed for random number generator. If not given, python\'s default is used', metavar='INT') parser.add_argument('infile', help='Name of input file') parser.add_argument('outfile', help='Name of output file') parser.add_argument('percent', type=float, help='Per cent probability of keeping any given read (pair) in [0,100]', metavar='FLOAT') options = parser.parse_args() random.seed(a=options.seed) 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 100 * random.random() <= options.percent: print(seq, file=fout) if options.mate_file: print(mate_seq, file=fout) utils.close(fout) Fastaq-3.17.0/pyfastaq/runners/to_tiling_bam.py000066400000000000000000000062071324251536500215410ustar00rootroot00000000000000import argparse import sys import os from pyfastaq import sequences, utils def run(description): parser = argparse.ArgumentParser( description = 'Takes a sequence file. Makes a BAM file containing perfect (unpaired) reads tiling the whole genome', usage = 'fastaq to_tiling_bam [options] ', 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('--qual_char', help='Character to use for quality score [%(default)s]', default='I') 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], options.qual_char * (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() Fastaq-3.17.0/pyfastaq/runners/to_unique_by_id.py000066400000000000000000000011211324251536500220760ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = 'Removes duplicate sequences from input 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 = 'fastaq to_unique_by_id ') parser.add_argument('infile', help='Name of input file') parser.add_argument('outfile', help='Name of output file') options = parser.parse_args() tasks.to_unique_by_id(options.infile, options.outfile) Fastaq-3.17.0/pyfastaq/runners/translate.py000066400000000000000000000011631324251536500207230ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = 'Translates all sequences in input file. Output is always FASTA format', usage = 'fastaq translate [options] ') 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 file to be translated') parser.add_argument('outfile', help='Name of output FASTA file') options = parser.parse_args() tasks.translate(options.infile, options.outfile, frame=options.frame) Fastaq-3.17.0/pyfastaq/runners/trim_Ns_at_end.py000066400000000000000000000007731324251536500216610ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = 'Trims any Ns off each sequence in input file. Does nothing to gaps in the middle, just trims the ends', usage = 'fastaq trim_Ns_at_end ') parser.add_argument('infile', help='Name of input file') parser.add_argument('outfile', help='Name of output file') options = parser.parse_args() tasks.trim_Ns_at_end(options.infile, options.outfile) Fastaq-3.17.0/pyfastaq/runners/trim_contigs.py000066400000000000000000000013761324251536500214350ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = 'Trims a set number of bases off the end of every contig, so gaps get bigger and contig ends are removed. Bases are replaced with Ns. Any sequence that ends up as all Ns is lost', usage = 'fastaq trim_contigs [options] ') 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 file') parser.add_argument('outfile', help='Name of output file') options = parser.parse_args() tasks.trim_contigs(options.infile, options.outfile, options.trim_number) Fastaq-3.17.0/pyfastaq/runners/trim_ends.py000066400000000000000000000012101324251536500207030ustar00rootroot00000000000000import argparse from pyfastaq import tasks def run(description): parser = argparse.ArgumentParser( description = description, usage = 'fastaq trim_ends ') parser.add_argument('infile', help='Name of input 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 file') options = parser.parse_args() tasks.trim(options.infile, options.outfile, options.start_trim, options.end_trim) Fastaq-3.17.0/pyfastaq/runners/version.py000066400000000000000000000001071324251536500204100ustar00rootroot00000000000000import pyfastaq def run(description): print(pyfastaq.__version__) Fastaq-3.17.0/pyfastaq/sequences.py000066400000000000000000000607771324251536500172450ustar00rootroot00000000000000import copy import re import random import itertools from collections import Counter from pyfastaq import utils, intervals, genetic_codes 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 = {} genetic_code = 1 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 subseq(self, start, end): '''Returns Fasta object with the same name, of the bases from start to end, but not including end''' return Fasta(self.id, self.seq[start:end]) 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 occurrences of 'old' with 'new' ''' self.seq = self.seq.replace(old, new) def replace_non_acgt(self): '''Replace all non acgt characters with an N (case insensitive)''' self.seq = re.sub(r'''[^acgtACGTnN]''', 'N', self.seq) 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): '''Returns a list of ORFs that the sequence has, starting on the given frame. Each returned ORF is an interval.Interval object. If revomp=True, then finds the ORFs of the reverse complement of the sequence.''' 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): '''Finds all open reading frames in the sequence, that are at least as long as min_length. Includes ORFs on the reverse strand. Returns a list of ORFs, where each element is a tuple: (interval.Interval, bool) where bool=True means on the reverse strand''' 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]) def is_complete_orf(self): '''Returns true iff length is >= 6, is a multiple of 3, and there is exactly one stop codon in the sequence and it is at the end''' if len(self) %3 != 0 or len(self) < 6: return False orfs = self.orfs() complete_orf = intervals.Interval(0, len(self) - 1) for orf in orfs: if orf == complete_orf: return True return False def looks_like_gene(self): '''Returns true iff: length >=6, length is a multiple of 3, first codon is start, last codon is a stop and has no other stop codons''' return self.is_complete_orf() \ and len(self) >= 6 \ and len(self) %3 == 0 \ and self.seq[0:3].upper() in genetic_codes.starts[genetic_code] def make_into_gene(self): '''Tries to make into a gene sequence. Tries all three reading frames and both strands. Returns a tuple (new sequence, strand, frame) if it was successful. Otherwise returns None.''' for reverse in [True, False]: for frame in range(3): new_seq = copy.copy(self) if reverse: new_seq.revcomp() new_seq.seq = new_seq[frame:] if len(new_seq) % 3: new_seq.seq = new_seq.seq[:-(len(new_seq) % 3)] new_aa_seq = new_seq.translate() if len(new_aa_seq) >= 2 and new_seq[0:3] in genetic_codes.starts[genetic_code] and new_aa_seq[-1] == '*' and '*' not in new_aa_seq[:-1]: strand = '-' if reverse else '+' return new_seq, strand, frame return None # 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 occurrence (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([genetic_codes.codes[genetic_code].get(self.seq[x:x+3].upper(), 'X') for x in range(frame, len(self)-1-frame, 3)])) def gc_content(self, as_decimal=True): """Returns the GC content for the sequence. Notes: This method ignores N when calculating the length of the sequence. It does not, however ignore other ambiguous bases. It also only includes the ambiguous base S (G or C). In this sense the method is conservative with its calculation. Args: as_decimal (bool): Return the result as a decimal. Setting to False will return as a percentage. i.e for the sequence GCAT it will return 0.5 by default and 50.00 if set to False. Returns: float: GC content calculated as the number of G, C, and S divided by the number of (non-N) bases (length). """ gc_total = 0.0 num_bases = 0.0 n_tuple = tuple('nN') accepted_bases = tuple('cCgGsS') # counter sums all unique characters in sequence. Case insensitive. for base, count in Counter(self.seq).items(): # dont count N in the number of bases if base not in n_tuple: num_bases += count if base in accepted_bases: # S is a G or C gc_total += count gc_content = gc_total / num_bases if not as_decimal: # return as percentage gc_content *= 100 return gc_content 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 subseq(self, start, end): '''Returns Fastq object with the same name, of the bases from start to end, but not including end''' return Fastq(self.id, self.seq[start:end], self.qual[start:end]) 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 make_into_gene(self): got = super().make_into_gene() if got is None: return None seq, strand, frame = got new_seq = copy.copy(self) if strand == '-': new_seq.revcomp() new_seq.seq = new_seq.seq[frame:frame + len(seq)] new_seq.qual = new_seq.qual[frame:frame + len(seq)] return new_seq, strand, frame 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 Fastaq-3.17.0/pyfastaq/tasks.py000066400000000000000000000710751324251536500163700ustar00rootroot00000000000000import re import sys import copy import random from pyfastaq import sequences, utils, caf class Error (Exception): pass def acgtn_only(infile, outfile): '''Replace every non-acgtn (case insensitve) character with an N''' f = utils.open_file_write(outfile) for seq in sequences.file_reader(infile): seq.replace_non_acgt() print(seq, file=f) utils.close(f) def caf_to_fastq(infile, outfile, min_length=0, trim=False): '''Convert a CAF file to fastq. Reads shorter than min_length are not output. If clipping information is in the CAF file (with a line Clipping QUAL ...) and trim=True, then trim the reads''' caf_reader = caf.file_reader(infile) fout = utils.open_file_write(outfile) for c in caf_reader: if trim: if c.clip_start is not None and c.clip_end is not None: c.seq.seq = c.seq.seq[c.clip_start:c.clip_end + 1] c.seq.qual = c.seq.qual[c.clip_start:c.clip_end + 1] else: print('Warning: no clipping info for sequence', c.id, file=sys.stderr) if len(c.seq) >= min_length: print(c.seq, file=fout) utils.close(fout) 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, suffix=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) if suffix is not None: seq.id += suffix 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 trim_contigs(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('', '', sep='\n', file=fout) for seq in seq_reader: print(' ', ' ' + seq.id + '', ' ' + str(len(seq)) + '', ' 1', ' ', sep='\n', file=fout) print('', 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, mate_in=None, mate_out=None, both_mates_pass=True, ): 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) if mate_in: if mate_out is None: raise Error('Error in filter! mate_in provided. Must also provide mate_out') seq_reader_mate = sequences.file_reader(mate_in) f_out_mate = utils.open_file_write(mate_out) seq_reader = sequences.file_reader(infile) f_out = utils.open_file_write(outfile) if regex is not None: r = re.compile(regex) def passes(seq, name_regex): # remove trailing comments from FASTQ readname lines matches = name_regex.match(seq.id) if matches is not None: clean_seq_id = matches.group(1) else: clean_seq_id = seq.id return minlength <= len(seq) <= maxlength \ and (regex is None or r.search(clean_seq_id) is not None) \ and (ids_file is None or clean_seq_id in ids_from_file) name_regex = re.compile(r'^([^\s]+).*?$') for seq in seq_reader: seq_passes = passes(seq, name_regex) if mate_in: try: seq_mate = next(seq_reader_mate) except: utils.close(f_out) raise Error('Error getting mate for sequence', seq.id, ' ... cannot continue') mate_passes = passes(seq_mate, name_regex) want_the_pair = (seq_passes and mate_passes) \ or (( seq_passes or mate_passes) and not both_mates_pass) if want_the_pair != invert: print(seq, file=f_out) print(seq_mate, file=f_out_mate) elif seq_passes != invert: print(seq, file=f_out) utils.close(f_out) if mate_in: utils.close(f_out_mate) 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, suffix1=None, suffix2=None): '''Makes interleaved file from two sequence files. If used, will append suffix1 onto end of every sequence name in infile_1, unless it already ends with suffix1. Similar for sufffix2.''' 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') if suffix1 is not None and not seq_1.id.endswith(suffix1): seq_1.id += suffix1 if suffix2 is not None and not seq_2.id.endswith(suffix2): seq_2.id += suffix2 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 mean_length(infile, limit=None): '''Returns the mean length of the sequences in the input file. By default uses all sequences. To limit to the first N sequences, use limit=N''' total = 0 count = 0 seq_reader = sequences.file_reader(infile) for seq in seq_reader: total += len(seq) count += 1 if limit is not None and count >= limit: break assert count > 0 return total / count 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, check_revcomp=False): to_trim_seqs = {} file_to_dict(to_trim_file, to_trim_seqs) trim_seqs = [x.seq for x in to_trim_seqs.values()] if check_revcomp: for seq in to_trim_seqs.values(): seq.revcomp() trim_seqs_revcomp = [x.seq for x in to_trim_seqs.values()] else: trim_seqs_revcomp = [] 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 for trim_seq in trim_seqs_revcomp: if seq.seq.endswith(trim_seq): seq.trim(0,len(trim_seq)) 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 sort_by_size(infile, outfile, smallest_first=False): '''Sorts input sequence file by biggest sequence first, writes sorted output file. Set smallest_first=True to have smallest first''' seqs = {} file_to_dict(infile, seqs) seqs = list(seqs.values()) seqs.sort(key=lambda x: len(x), reverse=not smallest_first) fout = utils.open_file_write(outfile) for seq in seqs: print(seq, file=fout) utils.close(fout) def sort_by_name(infile, outfile): '''Sorts input sequence file by sort -d -k1,1, writes sorted output file.''' seqs = {} file_to_dict(infile, seqs) #seqs = list(seqs.values()) #seqs.sort() fout = utils.open_file_write(outfile) for name in sorted(seqs): print(seqs[name], file=fout) utils.close(fout) def to_fastg(infile, outfile, circular=None): '''Writes a FASTG file in SPAdes format from input file. Currently only whether or not a sequence is circular is supported. Put circular=set of ids, or circular=filename to make those sequences circular in the output. Puts coverage=1 on all contigs''' if circular is None: to_circularise = set() elif type(circular) is not set: f = utils.open_file_read(circular) to_circularise = set([x.rstrip() for x in f.readlines()]) utils.close(f) else: to_circularise = circular seq_reader = sequences.file_reader(infile) fout = utils.open_file_write(outfile) nodes = 1 for seq in seq_reader: new_id = '_'.join([ 'NODE', str(nodes), 'length', str(len(seq)), 'cov', '1', 'ID', seq.id ]) if seq.id in to_circularise: seq.id = new_id + ':' + new_id + ';' print(seq, file=fout) seq.revcomp() seq.id = new_id + "':" + new_id + "';" print(seq, file=fout) else: seq.id = new_id + ';' print(seq, file=fout) seq.revcomp() seq.id = new_id + "';" print(seq, file=fout) nodes += 1 utils.close(fout) 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 length_offsets_from_fai(fai_file): '''Returns a dictionary of positions of the start of each sequence, as if all the sequences were catted into one sequence. eg if file has three sequences, seq1 10bp, seq2 30bp, seq3 20bp, then the output would be: {'seq1': 0, 'seq2': 10, 'seq3': 40}''' positions = {} total_length = 0 f = utils.open_file_read(fai_file) for line in f: try: (name, length) = line.rstrip().split()[:2] length = int(length) except: raise Error('Error reading the following line of fai file ' + fai_file + '\n' + line) positions[name] = total_length total_length += length utils.close(f) return positions 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 split_by_fixed_size_onefile(infile, outfile, chunk_size, tolerance, skip_if_all_Ns=False): '''Splits each sequence in infile into chunks of fixed size, last chunk can be up to (chunk_size + tolerance) in length''' seq_reader = sequences.file_reader(infile) f_out = utils.open_file_write(outfile) for seq in seq_reader: for i in range(0, len(seq), chunk_size): if i + chunk_size + tolerance >= len(seq): end = len(seq) else: end = i + chunk_size subseq = seq.subseq(i, end) if not (skip_if_all_Ns and subseq.is_all_Ns()): subseq.id += '.' + str(i+1) + '_' + str(end) print(subseq, file=f_out) if end == len(seq): break utils.close(f_out) 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 stats_from_fai(infile): '''Returns dictionary of length stats from an fai file. Keys are: longest, shortest, mean, total_length, N50, number''' f = utils.open_file_read(infile) try: lengths = sorted([int(line.split('\t')[1]) for line in f], reverse=True) except: raise Error('Error getting lengths from fai file ' + infile) utils.close(f) stats = {} if len(lengths) > 0: stats['longest'] = max(lengths) stats['shortest'] = min(lengths) stats['total_length'] = sum(lengths) stats['mean'] = stats['total_length'] / len(lengths) stats['number'] = len(lengths) cumulative_length = 0 for length in lengths: cumulative_length += length if cumulative_length >= 0.5 * stats['total_length']: stats['N50'] = length break else: stats = {x: 0 for x in ('longest', 'shortest', 'mean', 'N50', 'total_length', 'number')} return stats def to_boulderio(infile, outfile): '''Converts input sequence file into a "Boulder-IO format", as used by primer3''' seq_reader = sequences.file_reader(infile) f_out = utils.open_file_write(outfile) for sequence in seq_reader: print("SEQUENCE_ID=" + sequence.id, file=f_out) print("SEQUENCE_TEMPLATE=" + sequence.seq, file=f_out) print("=", file=f_out) utils.close(f_out) def to_fasta(infile, outfile, line_length=60, strip_after_first_whitespace=False, check_unique=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 if check_unique: used_names = {} for seq in seq_reader: if strip_after_first_whitespace: seq.strip_after_first_whitespace() if check_unique: used_names[seq.id] = used_names.get(seq.id, 0) + 1 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 if check_unique: all_unique = True for name, count in used_names.items(): if count > 1: print('Sequence name "' + name + '" not unique. Found', count, 'times', file=sys.stderr) all_unique = False if not all_unique: raise Error('Not all sequence names unique. Cannot continue') 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) Fastaq-3.17.0/pyfastaq/tests/000077500000000000000000000000001324251536500160215ustar00rootroot00000000000000Fastaq-3.17.0/pyfastaq/tests/caf_test.py000066400000000000000000000025051324251536500201650ustar00rootroot00000000000000#!/usr/bin/env python3 import os import unittest from pyfastaq import caf, utils, sequences modules_dir = os.path.dirname(os.path.abspath(caf.__file__)) data_dir = os.path.join(modules_dir, 'tests', 'data') class TestCaf(unittest.TestCase): def test_get_next_from_file(self): '''Test get_next_from_file()''' f_in = utils.open_file_read(os.path.join(data_dir, 'caf_test.caf')) c = caf.Caf() c.get_next_from_file(f_in) read = caf.Caf() read.id = 'read1.p1k' read.seq = sequences.Fasta(read.id, 'NACGTAN') read.seq = read.seq.to_Fastq([4, 24, 42, 43, 40, 30, 8]) read.insert_min = 2000 read.insert_max = 4000 read.ligation = '12345' read.clone = 'clone1' read.clip_start = 1 read.clip_end = 5 self.assertEqual(c, read) c.get_next_from_file(f_in) read = caf.Caf() read.id = 'read2.p1k' read.seq = sequences.Fasta(read.id, 'CGACGTT') read.seq = read.seq.to_Fastq([9, 9, 40, 41, 42, 42, 4]) read.insert_min = 2000 read.insert_max = 4000 read.ligation = '23456' read.clone = 'clone2' read.clip_start = None read.clip_end = None self.assertEqual(c, read) utils.close(f_in) if __name__ == '__main__': unittest.main() Fastaq-3.17.0/pyfastaq/tests/data/000077500000000000000000000000001324251536500167325ustar00rootroot00000000000000Fastaq-3.17.0/pyfastaq/tests/data/caf_test.caf000066400000000000000000000013421324251536500211750ustar00rootroot00000000000000 DNA : read1.p1k NACG TAN BaseQuality : read1.p1k 4 24 42 43 40 30 8 Sequence : read1.p1k Is_read SCF_File read1.p1kSCF Template read1 Insert_size 2000 4000 Ligation_no 12345 Primer Universal_primer Strand Forward Dye Dye_terminator Clone clone1 Seq_vec SVEC 1 15 puc19 Sequencing_vector "puc19" Clipping QUAL 2 6 ProcessStatus PASS Asped 2006-7-5 Unpadded Align_to_SCF 1 1272 1 1272 DNA : read2.p1k CG ACGTT BaseQuality : read2.p1k 9 9 40 41 42 42 4 Sequence : read2.p1k Is_read SCF_File read2.p1kSCF Template read2 Insert_size 2000 4000 Ligation_no 23456 Primer Universal_primer Strand Forward Dye Dye_terminator Clone clone2 Seq_vec SVEC 1 32 puc19 Sequencing_vector "puc19" ProcessStatus PASS Unpadded Align_to_SCF 1 1347 1 1347 Fastaq-3.17.0/pyfastaq/tests/data/caf_test.to_fastq.no_trim.min_length_0.fq000066400000000000000000000000721324251536500267000ustar00rootroot00000000000000@read1.p1k NACGTAN + %9KLI?) @read2.p1k CGACGTT + **IJKK% Fastaq-3.17.0/pyfastaq/tests/data/caf_test.to_fastq.trim.min_length_6.fq000066400000000000000000000000351324251536500262110ustar00rootroot00000000000000@read2.p1k CGACGTT + **IJKK% Fastaq-3.17.0/pyfastaq/tests/data/readnames_with_comments.fastq000066400000000000000000000005661324251536500247000ustar00rootroot00000000000000@A1234::15950:1663 stuff_to_remove TCGTAAGCCTGCTCGAGC + >>3>>44@CFFFGG??EE @A1234::16080:1672 stuff_to_remove CCATCGTCTTCGCCCTGC + 111AA1AAAAF1EAEGAG @A1234::12967:1677 stuff_to_remove CTCCAGCATCGTGCAAAT + 3>>A?@CBDFAAACCBAF @A1234::16114:1681 stuff_to_remove TTGATATAGAGATACTTC + 3>A3A5D55DBFFDFGGG @A1234::16669:1683 stuff_to_remove CTGCGCGACTATACGCAG + 1>1>>>A1>D?FF10E0AFastaq-3.17.0/pyfastaq/tests/data/readnames_with_comments.fastq.filtered000066400000000000000000000001131324251536500264610ustar00rootroot00000000000000@A1234::12967:1677 stuff_to_remove CTCCAGCATCGTGCAAAT + 3>>A?@CBDFAAACCBAF Fastaq-3.17.0/pyfastaq/tests/data/readnames_with_comments.fastq.ids000066400000000000000000000000211324251536500254400ustar00rootroot00000000000000A1234::12967:1677Fastaq-3.17.0/pyfastaq/tests/data/sequences_test.embl000066400000000000000000000247111324251536500226320ustar00rootroot00000000000000ID 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 // Fastaq-3.17.0/pyfastaq/tests/data/sequences_test.embl.bad000066400000000000000000000246151324251536500233620ustar00rootroot00000000000000ID 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 // Fastaq-3.17.0/pyfastaq/tests/data/sequences_test.embl.bad2000066400000000000000000000247061324251536500234450ustar00rootroot00000000000000ID 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 // Fastaq-3.17.0/pyfastaq/tests/data/sequences_test.embl.to_fasta000066400000000000000000000073201324251536500244260ustar00rootroot00000000000000>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 Fastaq-3.17.0/pyfastaq/tests/data/sequences_test.fa000066400000000000000000000000571324251536500222760ustar00rootroot00000000000000>1 ACGTA >2 A C GT A >3 ACGTA >4 ACGTA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test.fa.ids000066400000000000000000000000101324251536500230410ustar00rootroot000000000000001 2 3 4 Fastaq-3.17.0/pyfastaq/tests/data/sequences_test.fa.qual000066400000000000000000000001221324251536500232300ustar00rootroot00000000000000>1 40 40 40 40 40 >2 40 40 40 40 40 >3 40 40 40 40 40 >4 40 40 40 40 40 Fastaq-3.17.0/pyfastaq/tests/data/sequences_test.fa.qual.bad000066400000000000000000000001221324251536500237550ustar00rootroot00000000000000>1 40 40 40 40 40 >3 40 40 40 40 40 >3 40 40 40 40 40 >4 40 40 40 40 40 Fastaq-3.17.0/pyfastaq/tests/data/sequences_test.fasta_to_fastq.fq000066400000000000000000000001041324251536500253040ustar00rootroot00000000000000@1 ACGTA + IIIII @2 ACGTA + IIIII @3 ACGTA + IIIII @4 ACGTA + IIIII Fastaq-3.17.0/pyfastaq/tests/data/sequences_test.gbk000066400000000000000000000213341324251536500224540ustar00rootroot00000000000000LOCUS 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 // Fastaq-3.17.0/pyfastaq/tests/data/sequences_test.gbk.to_fasta000066400000000000000000000007361324251536500242560ustar00rootroot00000000000000>NAME1 gatcctccatatacaacggtatctccacctcaggtttagatctcaacaacggaaccattg ccgacatgagacagttaggtatcgtcgagagttacaagctaaaacgagcagtagtcagct ctgcatctgaagccgctgaagttctactaagggtggataacatcatccgtgcaagaccaa tgccatgactcagattctaattttaagctattcaatttctctttgatc >NAME2 gatcctccatatacaacggtatctccacctcaggtttagatctcaacaacggaaccattg ccgacatgagacagttaggtatcgtcgagagttacaagctaaaacgagcagtagtcagct ctgcatctgaagccgctgaagttctactaagggtggataacatcatccgtgcaagaccaa tgccatgactcagattctaattttaagctattcaatttctctttgaaa Fastaq-3.17.0/pyfastaq/tests/data/sequences_test.line_length3.fa000066400000000000000000000000501324251536500246410ustar00rootroot00000000000000>1 ACG TA >2 ACG TA >3 ACG TA >4 ACG TA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test.to_fasta.strip_after_whitespace_non_unique.in.fa000066400000000000000000000000401324251536500334670ustar00rootroot00000000000000>1 spam ACGT >1 eggs A >2 GTTTG Fastaq-3.17.0/pyfastaq/tests/data/sequences_test.to_fasta.strip_after_whitespace_non_unique.out.fa000066400000000000000000000000261324251536500336740ustar00rootroot00000000000000>1 ACGT >1 A >2 GTTTG Fastaq-3.17.0/pyfastaq/tests/data/sequences_test.to_fasta.strip_after_whitespace_unique.in.fa000066400000000000000000000000511324251536500326170ustar00rootroot00000000000000>1 abcde ACGT >2 abcde G >3 hello GTACCA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test.to_fasta.strip_after_whitespace_unique.out.fa000066400000000000000000000000271324251536500330230ustar00rootroot00000000000000>1 ACGT >2 G >3 GTACCA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_3-per-line.fa000066400000000000000000000001041324251536500242220ustar00rootroot00000000000000>ID A >ID AA >ID AAA >ID AAA A >ID AAA AA >ID AAA AAA >ID AAA AAA A Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_cap_to_read_pairs.fa000066400000000000000000000001511324251536500260070ustar00rootroot00000000000000>one.p1k ACGT >one.q1k CCCC >two.p1k A >two.q1k C >one.p1k TTTTTTTTTT >three.q1k A >four.x T >five.p1k G Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_cap_to_read_pairs.fa.paired.gz000066400000000000000000000001341324251536500276720ustar00rootroot00000000000000‹I0&Rsequences_test_cap_to_read_pairs.fa.pairs³ËÏKÕ7ä .;ˆ—3pÙ•”çe!   ]•’K0Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_cap_to_read_pairs.fa.unpaired.gz000066400000000000000000000001341324251536500302350ustar00rootroot00000000000000‹Ü3&Rsequences_test_cap_to_read_pairs.fa.unpaired³+É(JMÕ7ârä²KË/-â Ò™e©ú†\î\/zÔ0Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_deinterleaved_1.fa000066400000000000000000000000221324251536500254010ustar00rootroot00000000000000>1/1 ACGTA >2/1 A Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_deinterleaved_2.fa000066400000000000000000000000221324251536500254020ustar00rootroot00000000000000>1/2 ACGTA >2/2 C Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_deinterleaved_bad2_1.fa000066400000000000000000000000131324251536500262710ustar00rootroot00000000000000>1/1 ACGTA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_deinterleaved_bad2_2.fa000066400000000000000000000000221324251536500262720ustar00rootroot00000000000000>1/2 ACGTA >2/2 A Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_deinterleaved_bad_1.fa000066400000000000000000000000221324251536500262070ustar00rootroot00000000000000>1/1 ACGTA >2/1 A Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_deinterleaved_bad_2.fa000066400000000000000000000000131324251536500262100ustar00rootroot00000000000000>1/2 ACGTA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_deinterleaved_no_suffixes_1.fa000066400000000000000000000000201324251536500300070ustar00rootroot00000000000000>1/1 ACGTA >2 A Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_deinterleaved_no_suffixes_2.fa000066400000000000000000000000201324251536500300100ustar00rootroot00000000000000>1 ACGTA >2/2 C Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_empty_file000066400000000000000000000000001324251536500241120ustar00rootroot00000000000000Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_enumerate_names.fa000066400000000000000000000000441324251536500255220ustar00rootroot00000000000000>one/1 A >one/2 C >two/1 G >two/2 T Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_enumerate_names.fa.out.add_suffix000066400000000000000000000000601324251536500304410ustar00rootroot00000000000000>1.SUFFIX A >2.SUFFIX C >3.SUFFIX G >4.SUFFIX T Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_enumerate_names.fa.out.keep_suffix000066400000000000000000000000341324251536500306360ustar00rootroot00000000000000>1/1 A >2/2 C >3/1 G >4/2 T Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_enumerate_names.fa.out.start.1000066400000000000000000000000241324251536500276210ustar00rootroot00000000000000>1 A >2 C >3 G >4 T Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_enumerate_names.fa.out.start.1.rename_file000066400000000000000000000000511324251536500320660ustar00rootroot00000000000000#old new one/1 1 one/2 2 two/1 3 two/2 4 Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_enumerate_names.fa.out.start.2000066400000000000000000000000241324251536500276220ustar00rootroot00000000000000>2 A >3 C >4 G >5 T Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_fai_test.fa000066400000000000000000000000321324251536500241450ustar00rootroot00000000000000>1 A >2 AA >3 AAA >4 AAAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_fai_test.fa.fai000066400000000000000000000000521324251536500247050ustar00rootroot000000000000001 1 3 1 2 2 2 8 2 3 3 3 14 3 4 4 4 21 4 5 Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_fail_no_AT.fq000066400000000000000000000000271324251536500243660ustar00rootroot00000000000000@1 A + I NOT_AN_@_LINE Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_fail_no_plus.fq000066400000000000000000000000171324251536500250440ustar00rootroot00000000000000@A A NOT_A_+ I Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_fail_no_qual.fq000066400000000000000000000000071324251536500250220ustar00rootroot00000000000000@A A + Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_fail_no_seq.fq000066400000000000000000000000141324251536500246460ustar00rootroot00000000000000@A A + I @B Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_fastaq_replace_bases.expected.fa000066400000000000000000000000151324251536500302770ustar00rootroot00000000000000>1 ACGXXXAXA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_fastaq_replace_bases.fa000066400000000000000000000000151324251536500264770ustar00rootroot00000000000000>1 ACGTTTATA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_filter_by_ids_file.fa000066400000000000000000000000401324251536500261630ustar00rootroot00000000000000>seq1 A >seq2 C >seq3 G >seq4 T Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_filter_by_ids_file.fa.filtered000066400000000000000000000000201324251536500277560ustar00rootroot00000000000000>seq2 C >seq4 T Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_filter_by_ids_file.fa.filtered.invert000066400000000000000000000000201324251536500312640ustar00rootroot00000000000000>seq1 A >seq3 G Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_filter_by_ids_file.fa.ids000066400000000000000000000000121324251536500267400ustar00rootroot00000000000000seq4 seq2 Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_filter_by_regex.fa000066400000000000000000000000511324251536500255210ustar00rootroot00000000000000>1 AAA >a AAA >a/1 AAA >a/2 AAA >b/1 AAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_filter_by_regex.first-char-a.fa000066400000000000000000000000311324251536500277760ustar00rootroot00000000000000>a AAA >a/1 AAA >a/2 AAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_filter_by_regex.first-of-pair.fa000066400000000000000000000000221324251536500302000ustar00rootroot00000000000000>a/1 AAA >b/1 AAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_filter_by_regex.numeric.fa000066400000000000000000000000071324251536500271630ustar00rootroot00000000000000>1 AAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_get_seqs_flanking_gaps.fa000066400000000000000000000000401324251536500270430ustar00rootroot00000000000000>a ACGTCNGTCNNNGT >b ACGTGTGTTG Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_get_seqs_flanking_gaps.fa.out000066400000000000000000000001121324251536500276510ustar00rootroot00000000000000#id gap_start gap_end left_bases right_bases a 6 6 GTC GTC a 10 12 GTC GT Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_gffv3.gff000066400000000000000000000002131324251536500235370ustar00rootroot00000000000000##gff-version 3 # comment ##sequence-region seq1 1 10 seq1 . gene 3 7 . + . ID=gene1;name=name1 ##FASTA >seq1 ACGTACGTAC >seq2 ACGTACGTAC Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_gffv3.gff.fasta000066400000000000000000000000421324251536500246340ustar00rootroot00000000000000>seq1 ACACGTGACG >seq2 AGTACCGTAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_gffv3.gff.to_fasta000066400000000000000000000000421324251536500253360ustar00rootroot00000000000000>seq1 ACGTACGTAC >seq2 ACGTACGTAC Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_gffv3.no_FASTA_line.gff000066400000000000000000000002031324251536500260760ustar00rootroot00000000000000##gff-version 3 # comment ##sequence-region seq1 1 10 seq1 . gene 3 7 . + . ID=gene1;name=name1 >seq1 ACGTACGTAC >seq2 ACGTACGTAC Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_gffv3.no_FASTA_line.gff.to_fasta000066400000000000000000000000421324251536500276760ustar00rootroot00000000000000>seq1 ACGTACGTAC >seq2 ACGTACGTAC Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_gffv3.no_seq.2.gff000066400000000000000000000001561324251536500251700ustar00rootroot00000000000000##gff-version 3 # comment ##sequence-region seq1 1 10 seq1 . gene 3 7 . + . ID=gene1;name=name1 ##FASTA oops Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_gffv3.no_seq.gff000066400000000000000000000001411324251536500250220ustar00rootroot00000000000000##gff-version 3 # comment ##sequence-region seq1 1 10 seq1 . gene 3 7 . + . ID=gene1;name=name1 Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_good_file.fq000066400000000000000000000000531324251536500243210ustar00rootroot00000000000000@ID ACGTA + IIIII @ID ACGTA +blah IIIII Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_good_file.fq.to_fasta000066400000000000000000000000241324251536500261160ustar00rootroot00000000000000>ID ACGTA >ID ACGTA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_good_file_mira.xml000066400000000000000000000005631324251536500255310ustar00rootroot00000000000000 ID 5 1 ID 5 1 Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_interleaved.fa000066400000000000000000000000441324251536500246540ustar00rootroot00000000000000>1/1 ACGTA >1/2 ACGTA >2/1 A >2/2 C Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_interleaved.fq000066400000000000000000000000741324251536500246770ustar00rootroot00000000000000@1/1 ACGTA + IIIII @1/2 ACGTA + IIIII @2/1 A + I @2/2 C + I Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_interleaved_bad.fa000066400000000000000000000000351324251536500254620ustar00rootroot00000000000000>1/1 ACGTA >1/2 ACGTA >2/1 A Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_interleaved_with_suffixes.fa000066400000000000000000000000441324251536500276230ustar00rootroot00000000000000>1/1 ACGTA >1/2 ACGTA >2/1 A >2/2 C Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_length_filter.fa000066400000000000000000000000301324251536500251730ustar00rootroot00000000000000>3 AAA >4 AAAA >5 AAAAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_length_filter.min-0.max-1.fa000066400000000000000000000000001324251536500270310ustar00rootroot00000000000000Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_length_filter.min-0.max-inf.fa000066400000000000000000000000301324251536500274500ustar00rootroot00000000000000>3 AAA >4 AAAA >5 AAAAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_length_filter.min-4.max-4.fa000066400000000000000000000000101324251536500270410ustar00rootroot00000000000000>4 AAAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_make_random_contigs.default.fa000066400000000000000000000000161324251536500277770ustar00rootroot00000000000000>1 ACG >2 ACG Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_make_random_contigs.first-42.fa000066400000000000000000000000201324251536500277200ustar00rootroot00000000000000>42 ACG >43 ACG Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_make_random_contigs.name-by-letters.fa000066400000000000000000000003041324251536500313630ustar00rootroot00000000000000>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 Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_make_random_contigs.prefix-p.fa000066400000000000000000000000201324251536500301000ustar00rootroot00000000000000>p1 ACG >p2 ACG Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_merge_to_one_seq.fa000066400000000000000000000000241324251536500256620ustar00rootroot00000000000000>1 A >2 G >3 C >4 T Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_merge_to_one_seq.fq000066400000000000000000000000221324251536500257000ustar00rootroot00000000000000@1 A + I @2 G + H Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_merge_to_one_seq.merged.fa000066400000000000000000000000141324251536500271230ustar00rootroot00000000000000>union AGCT Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_merge_to_one_seq.merged.fq000066400000000000000000000000171324251536500271460ustar00rootroot00000000000000@union AG + IH Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_not_a_fastaq_file000066400000000000000000000000371324251536500254250ustar00rootroot00000000000000i am not a fasta or fastq file Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_one-per-line.fa000066400000000000000000000000771324251536500246520ustar00rootroot00000000000000>ID A >ID AA >ID AAA >ID AAAA >ID AAAAA >ID AAAAAA >ID AAAAAAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_orfs.fa000066400000000000000000000017741324251536500233360ustar00rootroot00000000000000>1 GTATGACGACTTCTCGGTCAAAGGTAAGGTGAACAAGGGATTGAATGCTTAAATCCCGTG CCTACACTCAGTACCGGTGCTTGGCTGAAGCGTTCCTATGCAAGAATGAGAACTGGCAAC ACGTCGCGGCCAGCCCGGGACCATCAGGACCCGAACGTGTACCGCGAATGTTTACATTTC ACCCAGTTACCCGGATTCGGGCCAAAGCAGGAGAGCCTCTGAATTAGATGGTGCCACGTA AGTCTATTTTCGCACGTTTTATTGATTCAAGTGAGTGTCAACGTAGATTTATTGGTGCTT GGCTAAAGACGTATGGATCACGGGATGGAACATCTGGATCCCCCATGTACGTAAGTGTGT CGTCAAACAAAATTCTGTATCCCGTCGCTCCTGCCAGGGCAATCGCGGAGCTACGGACAT AGTCCTTAGTGAACTAATGATGATGAACATCTCGAACCAGGTTAACACGATACGATGAAG CGGGTTACTGAACACACTTAACAGGAGCCTGAGCAAATGTCATTTACAAAAGGTTTCTAG ACCCCCTTGGTAAGTCACTTGACACGTCTCATGCGGGGCCTACGGTAAACCAGATGCTAG AGTAGCGAACGGTGGGTGCGCAGGCATGTCCGGTCTCTCGATGGTGCACTTACGGACATC TCCCTATACAGATCTATTCAGTCACGAAGGTCAGCGAACATAACCCACGGGAGTTATCTC AACGAGTACGGGAGCGAACGGTGCACGGATCTGTCTTAGCTCAGAGGCGTCACGCGGTCC TATCTAACGCAAGAGCATGTGCCATTCCGGCCCTCTGATGTGCCTATGTACATAGAGCCG ACCCCGGCGGATTGGAGTCCCTAGCTACCGTCGACAGAGACGCAAAGACTCAATTGCTAT GTATATTGTTACTCTTCAACCACTGGAAAGACAAATAATTGCGGGCAAGTGCGTTACCCA TCACTCTGTTCTGTACACGAAAGGCTGAATAGCAAGTGGC Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_orfs.gff000066400000000000000000000006221324251536500235010ustar00rootroot000000000000001 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 . + . Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_phylip.interleaved000066400000000000000000000002661324251536500256010ustar00rootroot00000000000000 3 42 Turkey AA-CTNGGGC ATTTCAGGGT Salmo_gairAAGCCTTGGC AGTGCAGGGT H. SapiensACCGGTTGGC CGTTCAGGGT GAGCCCGGGC AATACAGGGT AT GAGCCGTGGC CGGGCACGGT AT ACAGGTTGGC CGTTCAGGGT AA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_phylip.interleaved.to_fasta000066400000000000000000000002401324251536500273700ustar00rootroot00000000000000>Turkey AACTNGGGCATTTCAGGGTGAGCCCGGGCAATACAGGGTAT >Salmo_gair AAGCCTTGGCAGTGCAGGGTGAGCCGTGGCCGGGCACGGTAT >H. Sapiens ACCGGTTGGCCGTTCAGGGTACAGGTTGGCCGTTCAGGGTAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_phylip.interleaved2000066400000000000000000000002651324251536500256620ustar00rootroot00000000000000 3 42 Turkey AA-CTNGGGC ATTTCAGGGT Salmo_gairAAGCCTTGGC AGTGCAGGGT H. SapiensACCGGTTGGC CGTTCAGGGT GAGCCCGGGC AATACAGGGT AT GAGCCGTGGC CGGGCACGGT AT ACAGGTTGGC CGTTCAGGGT AA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_phylip.interleaved2.to_fasta000066400000000000000000000002401324251536500274520ustar00rootroot00000000000000>Turkey AACTNGGGCATTTCAGGGTGAGCCCGGGCAATACAGGGTAT >Salmo_gair AAGCCTTGGCAGTGCAGGGTGAGCCGTGGCCGGGCACGGTAT >H. Sapiens ACCGGTTGGCCGTTCAGGGTACAGGTTGGCCGTTCAGGGTAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_phylip.made_by_seaview000066400000000000000000000004161324251536500264170ustar00rootroot000000000000002 97 seq1 GGGGGGGGGG GGGGGGGGGG GGGGGGGGGG GGGGGGGGGG GGGGGGGGGG GGGGGGGGGG seq2 AAAAAAAAAA AAAAAAAAAA AAAAAAAAAA AAAAAAAAAA AAAAAAAAAA AAAAAAAAAA GGGGGGGGGG GGGGGGGGGG GGGGGGGGGG GGGGGGT AAAAAAAAAA AAAAAAAAAA AAAAAAAAA- -AAAAAG Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_phylip.made_by_seaview.to_fasta000066400000000000000000000003201324251536500302100ustar00rootroot00000000000000>seq1 GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGG GGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGGT >seq2 AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAG Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_phylip.sequential000066400000000000000000000002651324251536500254500ustar00rootroot00000000000000 3 42 Turkey AA-CTNGGGC ATTTCAGGGT GAGCCCGGGC AATACAGGGT AT Salmo_gairAAGCCTTGGC AGTGCAGGGT GAGCCGTGGC CGGGCACGGT AT H. SapiensACCGGTTGGC CGTTCAGGGT ACAGGTTGGC CGTTCAGGGT AA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_phylip.sequential.to_fasta000066400000000000000000000002401324251536500272400ustar00rootroot00000000000000>Turkey AACTNGGGCATTTCAGGGTGAGCCCGGGCAATACAGGGTAT >Salmo_gair AAGCCTTGGCAGTGCAGGGTGAGCCGTGGCCGGGCACGGTAT >H. Sapiens ACCGGTTGGCCGTTCAGGGTACAGGTTGGCCGTTCAGGGTAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_revcomp.fa000066400000000000000000000000441324251536500240250ustar00rootroot00000000000000>1 TACGT >2 TACGT >3 TACGT >4 TACGT Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_search_string.fa000066400000000000000000000000241324251536500252030ustar00rootroot00000000000000>seq AAGATCTAGAGATC Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_search_string.fa.hits000066400000000000000000000000411324251536500261500ustar00rootroot00000000000000seq 2 + seq 8 + seq 10 + seq 5 - Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_fixed_size.fa000066400000000000000000000001021324251536500257110ustar00rootroot00000000000000>seq1 ACGTNNNNN >seq2 ACGTA >seq3 NNNN >seq4 AC >seq5 ACG >seq6 A Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_fixed_size.fa.split.1000066400000000000000000000000171324251536500272070ustar00rootroot00000000000000>seq1:1-4 ACGT Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_fixed_size.fa.split.2000066400000000000000000000000201324251536500272020ustar00rootroot00000000000000>seq1:5-9 NNNNN Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_fixed_size.fa.split.3000066400000000000000000000000141324251536500272060ustar00rootroot00000000000000>seq2 ACGTA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_fixed_size.fa.split.4000066400000000000000000000000131324251536500272060ustar00rootroot00000000000000>seq3 NNNN Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_fixed_size.fa.split.5000066400000000000000000000000231324251536500272100ustar00rootroot00000000000000>seq4 AC >seq5 ACG Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_fixed_size.fa.split.6000066400000000000000000000000101324251536500272050ustar00rootroot00000000000000>seq6 A Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_fixed_size.fa.split.coords000066400000000000000000000000401324251536500303340ustar00rootroot00000000000000seq1:1-4 seq1 0 seq1:5-9 seq1 4 Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_fixed_size.fa.split.skip_if_all_Ns.1000066400000000000000000000000171324251536500321220ustar00rootroot00000000000000>seq1:1-4 ACGT Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_fixed_size.fa.split.skip_if_all_Ns.2000066400000000000000000000000141324251536500321200ustar00rootroot00000000000000>seq2 ACGTA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_fixed_size.fa.split.skip_if_all_Ns.3000066400000000000000000000000231324251536500321210ustar00rootroot00000000000000>seq4 AC >seq5 ACG Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_fixed_size.fa.split.skip_if_all_Ns.4000066400000000000000000000000101324251536500321160ustar00rootroot00000000000000>seq6 A Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_fixed_size.fa.split.skip_if_all_Ns.coords000066400000000000000000000000201324251536500332450ustar00rootroot00000000000000seq1:1-4 seq1 0 Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_fixed_size_onefile.fa000066400000000000000000000001541324251536500274210ustar00rootroot00000000000000>seq1 A >seq2 NC >seq3 ACG >seq4 ACGT >seq5 NNNTA >seq6 ACGTAC >seq7 ACGTACG >seq8 ACGTACGT >seq9 ACGTACGTA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_fixed_size_onefile.out.fa000066400000000000000000000003351324251536500302300ustar00rootroot00000000000000>seq1.1_1 A >seq2.1_2 NC >seq3.1_3 ACG >seq4.1_4 ACGT >seq5.1_3 NNN >seq5.4_5 TA >seq6.1_3 ACG >seq6.4_6 TAC >seq7.1_3 ACG >seq7.4_7 TACG >seq8.1_3 ACG >seq8.4_6 TAC >seq8.7_8 GT >seq9.1_3 ACG >seq9.4_6 TAC >seq9.7_9 GTA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_fixed_size_onefile.skip_Ns.out.fa000066400000000000000000000003171324251536500316350ustar00rootroot00000000000000>seq1.1_1 A >seq2.1_2 NC >seq3.1_3 ACG >seq4.1_4 ACGT >seq5.4_5 TA >seq6.1_3 ACG >seq6.4_6 TAC >seq7.1_3 ACG >seq7.4_7 TACG >seq8.1_3 ACG >seq8.4_6 TAC >seq8.7_8 GT >seq9.1_3 ACG >seq9.4_6 TAC >seq9.7_9 GTA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_test.fa000066400000000000000000000000321324251536500245410ustar00rootroot00000000000000>1 A >2 AA >3 AAA >4 AAAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_test.fa.2.1000066400000000000000000000000051324251536500250400ustar00rootroot00000000000000>1 A Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_test.fa.2.2000066400000000000000000000000061324251536500250420ustar00rootroot00000000000000>2 AA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_test.fa.2.3000066400000000000000000000000071324251536500250440ustar00rootroot00000000000000>3 AAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_test.fa.2.4000066400000000000000000000000101324251536500250370ustar00rootroot00000000000000>4 AAAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_test.fa.3.1000066400000000000000000000000131324251536500250400ustar00rootroot00000000000000>1 A >2 AA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_test.fa.3.2000066400000000000000000000000071324251536500250440ustar00rootroot00000000000000>3 AAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_test.fa.3.3000066400000000000000000000000101324251536500250370ustar00rootroot00000000000000>4 AAAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_test.fa.4.1000066400000000000000000000000131324251536500250410ustar00rootroot00000000000000>1 A >2 AA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_test.fa.4.2000066400000000000000000000000071324251536500250450ustar00rootroot00000000000000>3 AAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_test.fa.4.3000066400000000000000000000000101324251536500250400ustar00rootroot00000000000000>4 AAAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_test.fa.6.1000066400000000000000000000000221324251536500250430ustar00rootroot00000000000000>1 A >2 AA >3 AAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_test.fa.6.2000066400000000000000000000000101324251536500250410ustar00rootroot00000000000000>4 AAAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_test.fa.6.limit2.1000066400000000000000000000000131324251536500262420ustar00rootroot00000000000000>1 A >2 AA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_test.fa.6.limit2.2000066400000000000000000000000071324251536500262460ustar00rootroot00000000000000>3 AAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_test.fa.6.limit2.3000066400000000000000000000000101324251536500262410ustar00rootroot00000000000000>4 AAAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_test.long.fa000066400000000000000000000000301324251536500254750ustar00rootroot00000000000000>1 AAAAAAAA >2 AAAAAAAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_test.long.fa.2.1000066400000000000000000000000141324251536500257760ustar00rootroot00000000000000>1 AAAAAAAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_split_test.long.fa.2.2000066400000000000000000000000141324251536500257770ustar00rootroot00000000000000>2 AAAAAAAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_strip_after_whitespace.fa000066400000000000000000000000441324251536500271100ustar00rootroot00000000000000>seq 1 ACGT >seq 1 2 ACGT >seq ACGT Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_strip_after_whitespace.fa.to_fasta000066400000000000000000000000361324251536500307100ustar00rootroot00000000000000>seq ACGT >seq ACGT >seq ACGT Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_strip_illumina_suffix.fq000066400000000000000000000000471324251536500270140ustar00rootroot00000000000000@one/1 A + I @one/2 A + I @two/3 A + I Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_strip_illumina_suffix.fq.stripped000066400000000000000000000000431324251536500306410ustar00rootroot00000000000000@one A + I @one A + I @two/3 A + I Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_to_fasta_union.in.fa000066400000000000000000000000261324251536500257670ustar00rootroot00000000000000>1 AA A >2 GGG >3 TTT Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_to_fasta_union.out.fa000066400000000000000000000000241324251536500261660ustar00rootroot00000000000000>testname AAAGGGTTT Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_to_unique_by_id.fa000066400000000000000000000000611324251536500255270ustar00rootroot00000000000000>seq1 AA >seq2 A >seq3 A >seq1 A >seq4 >seq1 AAA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_to_unique_by_id.fa.out000066400000000000000000000000321324251536500263330ustar00rootroot00000000000000>seq1 AAA >seq2 A >seq3 A Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_translate.fa000066400000000000000000000003061324251536500243500ustar00rootroot00000000000000>seq GCAGCCGCGGCTAGAAGGCGACGCCGGCGTAACAATGACGATTGCTGTGAAGAGCAACAGGGAGGCGGGGGTCACCATATAATCATTTTATTGCTACTCCTGCTTAAAAAGATGTTCTTTCCACCCCCGCCTAGCAGTTCATCCTCGTCTACAACCACGACTTGGTACTATGTAGTCGTGGTTTAATAGTGA Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_translate.fa.frame0000066400000000000000000000001071324251536500255200ustar00rootroot00000000000000>seq AAAARRRRRRNNDDCCEEQQGGGGHHIIILLLLLLKKMFFPPPPSSSSSSTTTTWYYVVV V*** Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_translate.fa.frame1000066400000000000000000000001061324251536500255200ustar00rootroot00000000000000>seq QPRLEGDAGVTMTIAVKSNREAGVTI*SFYCYSCLKRCSFHPRLAVHPRLQPRLGTM*SW FNS Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_translate.fa.frame2000066400000000000000000000001061324251536500255210ustar00rootroot00000000000000>seq SRG*KATPA*Q*RLL*RATGRRGSPYNHFIATPA*KDVLSTPA*QFILVYNHDLVLCSRG LIV Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_trim_Ns_at_end.fa000066400000000000000000000000671324251536500253040ustar00rootroot00000000000000>1 A >2 nNNNNNNCNNNANNNN >3 NNnA >4 AnnnNn >5 NNnnnNNn Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_trim_Ns_at_end.fa.trimmed000066400000000000000000000000301324251536500267320ustar00rootroot00000000000000>1 A >2 CNNNA >3 A >4 A Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_trim_contigs.fa000066400000000000000000000000641324251536500250550ustar00rootroot00000000000000>1 AC >2 ACGTACGT >3 ACGTNACGT >4 ACGTACGTNACGTACGT Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_trim_contigs.fa.out000066400000000000000000000000311324251536500256550ustar00rootroot00000000000000>2 GTAC >4 GTACNNNNNGTAC Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_trimmed.fq000066400000000000000000000000301324251536500240260ustar00rootroot00000000000000@ID GT + II @ID GT + II Fastaq-3.17.0/pyfastaq/tests/data/sequences_test_untrimmed.fq000066400000000000000000000000741324251536500244010ustar00rootroot00000000000000@ID ACGTA + IIIII @ID ACGTA +blah IIIII @ NNN + III @ N + I Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_expend_nucleotides.in.fa000066400000000000000000000000141324251536500257670ustar00rootroot00000000000000>1 A >2 ART Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_expend_nucleotides.in.fq000066400000000000000000000000261324251536500260120ustar00rootroot00000000000000@1 A + I @2 ART + HIG Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_expend_nucleotides.out.fa000066400000000000000000000000271324251536500261740ustar00rootroot00000000000000>1 A >2.1 AAT >2.2 AGT Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_expend_nucleotides.out.fq000066400000000000000000000000471324251536500262160ustar00rootroot00000000000000@1 A + I @2.1 AAT + HIG @2.2 AGT + HIG Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_fasta_to_fake_qual.in.fa000066400000000000000000000001141324251536500257170ustar00rootroot00000000000000>1 CATTCATGATGCAGTCATCGATGCATGATGCATGCATGCATGCTGCAGTCAGTCATGCAA TC >2 CATGT Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_fasta_to_fake_qual.out.default.qual000066400000000000000000000003171324251536500301240ustar00rootroot00000000000000>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 Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_fasta_to_fake_qual.out.q42.qual000066400000000000000000000003171324251536500271060ustar00rootroot00000000000000>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 Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_filter_paired_both_pass.in_1.fa000066400000000000000000000001041324251536500272010ustar00rootroot00000000000000>both_fail/1 A >read1_pass/1 ACGT >read2_pass/1 A >both_pass/1 ACGT Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_filter_paired_both_pass.in_2.fa000066400000000000000000000001041324251536500272020ustar00rootroot00000000000000>both_fail/2 A >read1_pass/2 A >read2_pass/2 ACGT >both_pass/2 ACGT Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_filter_paired_both_pass.out_1.fa000066400000000000000000000000221324251536500274010ustar00rootroot00000000000000>both_pass/1 ACGT Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_filter_paired_both_pass.out_2.fa000066400000000000000000000000221324251536500274020ustar00rootroot00000000000000>both_pass/2 ACGT Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_filter_paired_one_pass.in_1.fa000066400000000000000000000001041324251536500270260ustar00rootroot00000000000000>both_fail/1 A >read1_pass/1 ACGT >read2_pass/1 A >both_pass/1 ACGT Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_filter_paired_one_pass.in_2.fa000066400000000000000000000001041324251536500270270ustar00rootroot00000000000000>both_fail/2 A >read1_pass/2 A >read2_pass/2 ACGT >both_pass/2 ACGT Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_filter_paired_one_pass.out_1.fa000066400000000000000000000000651324251536500272350ustar00rootroot00000000000000>read1_pass/1 ACGT >read2_pass/1 A >both_pass/1 ACGT Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_filter_paired_one_pass.out_2.fa000066400000000000000000000000651324251536500272360ustar00rootroot00000000000000>read1_pass/2 A >read2_pass/2 ACGT >both_pass/2 ACGT Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_length_offsets_from_fai.fa000066400000000000000000000001071324251536500263600ustar00rootroot00000000000000>seq1 ACGCTCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGCGA >seq2 A >seq3 ACGTGTT Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_length_offsets_from_fai.fa.fai000066400000000000000000000000541324251536500271170ustar00rootroot00000000000000seq1 42 6 42 43 seq2 1 55 1 2 seq3 7 63 7 8 Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_make_long_reads.input.fa000066400000000000000000000000371324251536500257560ustar00rootroot00000000000000>1 ACGCTCTCGAGCGCGAGCGCGAGCGAC Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_make_long_reads.output.fa000066400000000000000000000001371324251536500261600ustar00rootroot00000000000000>1_1_10 ACGCTCTCGA >1_6_15 CTCGAGCGCG >1_11_20 GCGCGAGCGC >1_16_25 AGCGCGAGCG >1_21_27 GAGCGAC Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_mean_length.fa000066400000000000000000000000401324251536500237610ustar00rootroot00000000000000>1 AGT >2 A >3 AGACG >4 AAGTAGT Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_sequence_trim_1.fa000066400000000000000000000003531324251536500245720ustar00rootroot00000000000000>1/1 1234567890 >2/1 AACG123456789 >3/1 1234567890 >4/1 AACG1234567890 >5/1 1234567890 >6/1 AACG1234567890 >7/1 123456789AGGC >8/1 123456789 >9/1 1234567890AGGC >10/1 AACG123456789CGTT >11/1 AACG1234567890CGTT >12/1 AACG1234567890CGTT Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_sequence_trim_1.trimmed.fa000066400000000000000000000001411324251536500262250ustar00rootroot00000000000000>1/1 1234567890 >4/1 1234567890 >5/1 1234567890 >6/1 1234567890 >9/1 1234567890 >12/1 1234567890 Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_sequence_trim_2.fa000066400000000000000000000003541324251536500245740ustar00rootroot00000000000000>1/2 1234567890 >2/2 1234567890 >3/2 AACG123456789 >4/2 1234567890 >5/2 AACG1234567890 >6/2 GCCT1234567890 >7/2 1234567890 >8/2 123456789AGGC >9/2 1234567890CGTT >10/2 AACG1234567890CGTT >11/2 AACG123456789CGTT >12/2 AACG1234567890CGTT Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_sequence_trim_2.trimmed.fa000066400000000000000000000001411324251536500262260ustar00rootroot00000000000000>1/2 1234567890 >4/2 1234567890 >5/2 1234567890 >6/2 1234567890 >9/2 1234567890 >12/2 1234567890 Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_sequences_to_trim.fa000066400000000000000000000000201324251536500252260ustar00rootroot00000000000000>1 AACG >2 GCCT Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_sort_by_name.in.fa000066400000000000000000000001711324251536500245730ustar00rootroot00000000000000>scaffold1 AGTCA >scaffold2 ACGTTT >scaffold10 A >scaffold12 ACG >contig1 AGTCA >contig2 ACGTTT >contig10 A >contig12 ACGFastaq-3.17.0/pyfastaq/tests/data/tasks_test_sort_by_name.out.fa000066400000000000000000000001721324251536500247750ustar00rootroot00000000000000>contig1 AGTCA >contig10 A >contig12 ACG >contig2 ACGTTT >scaffold1 AGTCA >scaffold10 A >scaffold12 ACG >scaffold2 ACGTTT Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_sort_by_size.in.fa000066400000000000000000000000371324251536500246260ustar00rootroot00000000000000>1 AGTCA >2 ACGTTT >3 A >4 ACG Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_sort_by_size.out.fa000066400000000000000000000000371324251536500250270ustar00rootroot00000000000000>2 ACGTTT >1 AGTCA >4 ACG >3 A Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_sort_by_size.out.rev.fa000066400000000000000000000000371324251536500256220ustar00rootroot00000000000000>3 A >4 ACG >1 AGTCA >2 ACGTTT Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_stats_from_fai.in.empty.fai000066400000000000000000000000001324251536500264070ustar00rootroot00000000000000Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_stats_from_fai.in.fai000066400000000000000000000001101324251536500252540ustar00rootroot00000000000000seq1 3 6 3 4 seq2 4 16 4 5 seq3 10 27 10 11 seq4 3 44 3 4 seq5 1 54 1 2 Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_to_boulderio.in.fa000066400000000000000000000001461324251536500246020ustar00rootroot00000000000000>one ACGTCAGCTCTGATCGACTGATGCACTAATCATATCTCGATCGATCGATCTGACTGACT CAGACCTCATACTACTTGCTGATAAT >two TGCA Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_to_boulderio.out.boulder000066400000000000000000000002431324251536500260470ustar00rootroot00000000000000SEQUENCE_ID=one SEQUENCE_TEMPLATE=ACGTCAGCTCTGATCGACTGATGCACTAATCATATCTCGATCGATCGATCTGACTGACTCAGACCTCATACTACTTGCTGATAAT = SEQUENCE_ID=two SEQUENCE_TEMPLATE=TGCA = Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_to_fastg.fasta000066400000000000000000000000271324251536500240230ustar00rootroot00000000000000>seq1 ATTTG >seq2 ACCG Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_to_fastg.fastg000066400000000000000000000003251324251536500240320ustar00rootroot00000000000000>NODE_1_length_5_cov_1_ID_seq1; ATTTG >NODE_1_length_5_cov_1_ID_seq1'; CAAAT >NODE_2_length_4_cov_1_ID_seq2:NODE_2_length_4_cov_1_ID_seq2; ACCG >NODE_2_length_4_cov_1_ID_seq2':NODE_2_length_4_cov_1_ID_seq2'; CGGT Fastaq-3.17.0/pyfastaq/tests/data/tasks_test_to_fastg.ids_to_circularise000066400000000000000000000000051324251536500265670ustar00rootroot00000000000000seq2 Fastaq-3.17.0/pyfastaq/tests/data/test_acgtn_only.expected.fa000066400000000000000000000000401324251536500242300ustar00rootroot00000000000000>seq1 acgtACGTnN >seq2 aNcNgNNT Fastaq-3.17.0/pyfastaq/tests/data/test_acgtn_only.in.fa000066400000000000000000000000401324251536500230350ustar00rootroot00000000000000>seq1 acgtACGTnN >seq2 aXcRg.?T Fastaq-3.17.0/pyfastaq/tests/data/utils_test_file_transpose.txt000066400000000000000000000000521324251536500247640ustar00rootroot0000000000000011 12 13 21 22 23 31 32 33 41 42 51 52 53 Fastaq-3.17.0/pyfastaq/tests/data/utils_test_file_transposed.txt000066400000000000000000000000541324251536500251320ustar00rootroot0000000000000011 21 31 41 51 12 22 32 42 52 13 23 33 . 53 Fastaq-3.17.0/pyfastaq/tests/data/utils_test_not_really_zipped.gz000066400000000000000000000000031324251536500252670ustar00rootroot0000000000000042 Fastaq-3.17.0/pyfastaq/tests/data/utils_test_scaffolds.fa000066400000000000000000000000751324251536500234670ustar00rootroot00000000000000>scaf1 ACGT >scaf2 ACNNNGTNA >scaf3 NNAAAANNN >scaf4 NNNNNNN Fastaq-3.17.0/pyfastaq/tests/data/utils_test_scaffolds.fa.to_contigs.fa000066400000000000000000000001111324251536500262120ustar00rootroot00000000000000>scaf1.1.4 ACGT >scaf2.1.2 AC >scaf2.6.7 GT >scaf2.9.9 A >scaf3.3.6 AAAA Fastaq-3.17.0/pyfastaq/tests/data/utils_test_scaffolds.fa.to_contigs.number_contigs.fa000066400000000000000000000000771324251536500312420ustar00rootroot00000000000000>scaf1.1 ACGT >scaf2.1 AC >scaf2.2 GT >scaf2.3 A >scaf3.1 AAAA Fastaq-3.17.0/pyfastaq/tests/data/utils_test_system_call.txt000066400000000000000000000000561324251536500242720ustar00rootroot00000000000000this is the contents of system call test file Fastaq-3.17.0/pyfastaq/tests/intervals_test.py000066400000000000000000000221731324251536500214460ustar00rootroot00000000000000#!/usr/bin/env python3 import unittest from pyfastaq import intervals class TestIntervals(unittest.TestCase): def test_init(self): '''Throw error if try to construct genome_interval from a non-int, or endX'), '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_subseq(self): '''Test subseq''' fa = sequences.Fasta('name', 'ACGTA') self.assertEqual(fa.subseq(1,4), sequences.Fasta('name', 'CGT')) self.assertEqual(fa.subseq(None,4), sequences.Fasta('name', 'ACGT')) self.assertEqual(fa.subseq(1,None), sequences.Fasta('name', 'CGTA')) 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_complete_orf(self): '''Test is_complete_orf''' tests = [ (sequences.Fasta('ID', 'TTT'), False), (sequences.Fasta('ID', 'TTTTAA'), True), (sequences.Fasta('ID', 'TTTTAATAA'), False), (sequences.Fasta('ID', 'TTGTAA'), True), (sequences.Fasta('ID', 'TTTAAC'), True), (sequences.Fasta('ID', 'TGA'), False), (sequences.Fasta('ID', 'TGAA'), False), ] for t in tests: self.assertEqual(t[0].is_complete_orf(), t[1]) def test_looks_like_gene(self): '''Test looks_like_gene''' tests = [ (sequences.Fasta('ID', 'TTT'), False), (sequences.Fasta('ID', 'TTGTAA'), True), (sequences.Fasta('ID', 'ttgTAA'), True), (sequences.Fasta('ID', 'TTGTTTTAA'), True), (sequences.Fasta('ID', 'TTGTAATTTTAA'), False), (sequences.Fasta('ID', 'TTGTTTTGAA'), False), ] for t in tests: self.assertEqual(t[0].looks_like_gene(), t[1]) sequences.genetic_code = 1 self.assertFalse(sequences.Fasta('ID', 'ATTCAGTAA').looks_like_gene()) sequences.genetic_code = 11 self.assertTrue(sequences.Fasta('ID', 'ATTCAGTAA').looks_like_gene()) sequences.genetic_code = 1 def test_make_into_gene_fasta(self): '''Test make_into_gene fasta''' print('sequences.genetic_code', sequences.genetic_code) tests = [ (sequences.Fasta('ID', 'T'), None), (sequences.Fasta('ID', 'TT'), None), (sequences.Fasta('ID', 'TTT'), None), (sequences.Fasta('ID', 'TTG'), None), (sequences.Fasta('ID', 'TAA'), None), (sequences.Fasta('ID', 'TTGAAATAA'), (sequences.Fasta('ID', 'TTGAAATAA'), '+', 0)), (sequences.Fasta('ID', 'TTGAAATAT'), None), (sequences.Fasta('ID', 'TTGTAA'), (sequences.Fasta('ID', 'TTGTAA'), '+', 0)), (sequences.Fasta('ID', 'TTGTAAA'), (sequences.Fasta('ID', 'TTGTAA'), '+', 0)), (sequences.Fasta('ID', 'TTGTAAAA'), (sequences.Fasta('ID', 'TTGTAA'), '+', 0)), (sequences.Fasta('ID', 'TTGTAAAAA'), None), (sequences.Fasta('ID', 'ATTGTAA'), (sequences.Fasta('ID', 'TTGTAA'), '+', 1)), (sequences.Fasta('ID', 'ATTGTAAA'), (sequences.Fasta('ID', 'TTGTAA'), '+', 1)), (sequences.Fasta('ID', 'ATTGTAAAA'), (sequences.Fasta('ID', 'TTGTAA'), '+', 1)), (sequences.Fasta('ID', 'ATTGTAAAAA'), None), (sequences.Fasta('ID', 'AATTGTAA'), (sequences.Fasta('ID', 'TTGTAA'), '+', 2)), (sequences.Fasta('ID', 'AATTGTAAA'), (sequences.Fasta('ID', 'TTGTAA'), '+', 2)), (sequences.Fasta('ID', 'AATTGTAAAA'), (sequences.Fasta('ID', 'TTGTAA'), '+', 2)), (sequences.Fasta('ID', 'AATTGTAAAAA'), None), (sequences.Fasta('ID', 'TTACAA'), (sequences.Fasta('ID', 'TTGTAA'), '-', 0)), (sequences.Fasta('ID', 'ATTACAA'), (sequences.Fasta('ID', 'TTGTAA'), '-', 0)), (sequences.Fasta('ID', 'AATTACAA'), (sequences.Fasta('ID', 'TTGTAA'), '-', 0)), (sequences.Fasta('ID', 'AAATTACAA'), None), (sequences.Fasta('ID', 'TTACAAA'), (sequences.Fasta('ID', 'TTGTAA'), '-', 1)), (sequences.Fasta('ID', 'ATTACAAA'), (sequences.Fasta('ID', 'TTGTAA'), '-', 1)), (sequences.Fasta('ID', 'AATTACAAA'), (sequences.Fasta('ID', 'TTGTAA'), '-', 1)), (sequences.Fasta('ID', 'AAATTACAAA'), None), (sequences.Fasta('ID', 'TTACAAAA'), (sequences.Fasta('ID', 'TTGTAA'), '-', 2)), (sequences.Fasta('ID', 'ATTACAAAA'), (sequences.Fasta('ID', 'TTGTAA'), '-', 2)), (sequences.Fasta('ID', 'AATTACAAAA'), (sequences.Fasta('ID', 'TTGTAA'), '-', 2)), (sequences.Fasta('ID', 'AAATTACAAAA'), None), ] for seq, expected in tests: self.assertEqual(seq.make_into_gene(), expected) def test_make_into_gene_fastq(self): '''Test make_into_gene fastq''' print('sequences.genetic_code', sequences.genetic_code) tests = [ (sequences.Fastq('ID', 'T', '1'), None), (sequences.Fastq('ID', 'TT', '12'), None), (sequences.Fastq('ID', 'TTT', '123'), None), (sequences.Fastq('ID', 'TTG', '123'), None), (sequences.Fastq('ID', 'TAA', '123'), None), (sequences.Fastq('ID', 'TTGAAATAA', '123456789'), (sequences.Fastq('ID', 'TTGAAATAA', '123456789'), '+', 0)), (sequences.Fastq('ID', 'TTGAAATAT', '123456789'), None), (sequences.Fastq('ID', 'TTGTAA', '123456'), (sequences.Fastq('ID', 'TTGTAA', '123456'), '+', 0)), (sequences.Fastq('ID', 'TTGTAAA', '1234567'), (sequences.Fastq('ID', 'TTGTAA', '123456'), '+', 0)), (sequences.Fastq('ID', 'TTGTAAAA', '12345678'), (sequences.Fastq('ID', 'TTGTAA', '123456'), '+', 0)), (sequences.Fastq('ID', 'TTGTAAAAA', '123456789'), None), (sequences.Fastq('ID', 'ATTGTAA', '1234567'), (sequences.Fastq('ID', 'TTGTAA', '234567'), '+', 1)), (sequences.Fastq('ID', 'ATTGTAAA', '12345678'), (sequences.Fastq('ID', 'TTGTAA', '234567'), '+', 1)), (sequences.Fastq('ID', 'ATTGTAAAA', '123456789'), (sequences.Fastq('ID', 'TTGTAA', '234567'), '+', 1)), (sequences.Fastq('ID', 'ATTGTAAAAA', '123456789A'), None), (sequences.Fastq('ID', 'AATTGTAA', '12345678'), (sequences.Fastq('ID', 'TTGTAA', '345678'), '+', 2)), (sequences.Fastq('ID', 'AATTGTAAA', '123456789'), (sequences.Fastq('ID', 'TTGTAA', '345678'), '+', 2)), (sequences.Fastq('ID', 'AATTGTAAAA', '123456789A'), (sequences.Fastq('ID', 'TTGTAA', '345678'), '+', 2)), (sequences.Fastq('ID', 'AATTGTAAAAA', '123456789AB'), None), (sequences.Fastq('ID', 'TTACAA', '123456'), (sequences.Fastq('ID', 'TTGTAA', '654321'), '-', 0)), (sequences.Fastq('ID', 'ATTACAA', '1234567'), (sequences.Fastq('ID', 'TTGTAA', '765432'), '-', 0)), (sequences.Fastq('ID', 'AATTACAA', '12345678'), (sequences.Fastq('ID', 'TTGTAA', '876543'), '-', 0)), (sequences.Fastq('ID', 'AAATTACAA', '123456789'), None), (sequences.Fastq('ID', 'TTACAAA', '1234567'), (sequences.Fastq('ID', 'TTGTAA', '654321'), '-', 1)), (sequences.Fastq('ID', 'ATTACAAA', '12345678'), (sequences.Fastq('ID', 'TTGTAA', '765432'), '-', 1)), (sequences.Fastq('ID', 'AATTACAAA', '123456789'), (sequences.Fastq('ID', 'TTGTAA', '876543'), '-', 1)), (sequences.Fastq('ID', 'AAATTACAAA', '123456789A'), None), (sequences.Fastq('ID', 'TTACAAAA', '12345678'), (sequences.Fastq('ID', 'TTGTAA', '654321'), '-', 2)), (sequences.Fastq('ID', 'ATTACAAAA', '123456789'), (sequences.Fastq('ID', 'TTGTAA', '765432'), '-', 2)), (sequences.Fastq('ID', 'AATTACAAAA', '123456789A'), (sequences.Fastq('ID', 'TTGTAA', '876543'), '-', 2)), (sequences.Fastq('ID', 'AAATTACAAAA', '123456789AB'), None), ] for seq, expected in tests: self.assertEqual(seq.make_into_gene(), expected) 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_non_acgt(self): '''test replace_non_acgt''' tests = [ ('acgtACGTnN', 'acgtACGTnN'), ('abc.g-T?aRC1T', 'aNcNgNTNaNCNT') ] for seq, expected in tests: fa = sequences.Fasta('id', seq) fa.replace_non_acgt() self.assertEqual(expected, fa.seq) 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() def test_gc_content(self): """Test GC content calculation works as expected""" tests = [ (sequences.Fasta('ID', 'cgCG'), 1.0), (sequences.Fasta('ID', 'tTaA'), 0.0), (sequences.Fasta('ID', 'GCAT'), 0.5), (sequences.Fasta('ID', 'GCATNN'), 0.5), (sequences.Fasta('ID', 'GCATNNS'), 0.6), (sequences.Fasta('ID', 'GCATNNSK'), 0.5) ] for test, answer in tests: self.assertAlmostEqual(test.gc_content(), answer) self.assertAlmostEqual(test.gc_content(as_decimal=False), answer * 100) 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_subseq(self): '''Test subseq''' fq = sequences.Fastq('name', 'ACGTA', 'FGHIJ') self.assertEqual(fq.subseq(1,4), sequences.Fastq('name', 'CGT', 'GHI')) self.assertEqual(fq.subseq(None,4), sequences.Fastq('name', 'ACGT', 'FGHI')) self.assertEqual(fq.subseq(1,None), sequences.Fastq('name', 'CGTA', 'GHIJ')) 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() Fastaq-3.17.0/pyfastaq/tests/tasks_test.py000066400000000000000000001045761324251536500205740ustar00rootroot00000000000000#!/usr/bin/env python3 import sys import filecmp import os import unittest from pyfastaq 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 TestACGTN_only(unittest.TestCase): def test_acgtn_only(self): '''Test acgtn_only''' tmpfile = 'tmp.test_acgtn_only.fa' infile = os.path.join(data_dir, 'test_acgtn_only.in.fa') expected = os.path.join(data_dir, 'test_acgtn_only.expected.fa') tasks.acgtn_only(infile, tmpfile) self.assertTrue(filecmp.cmp(expected, tmpfile, shallow=False)) os.unlink(tmpfile) class TestCafToFastq(unittest.TestCase): def test_caf_to_fastq_default(self): '''Test caf_to_fastq with no filtering''' tmpfile = 'tmp.fq' tasks.caf_to_fastq(os.path.join(data_dir, 'caf_test.caf'), tmpfile) self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'caf_test.to_fastq.no_trim.min_length_0.fq'), tmpfile, shallow=False)) os.unlink(tmpfile) def test_caf_to_fastq_trim_and_min_length(self): '''Test caf_to_fastq with trimming and min_length''' tmpfile = 'tmp.fq' tasks.caf_to_fastq(os.path.join(data_dir, 'caf_test.caf'), tmpfile, trim=True, min_length=6) self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'caf_test.to_fastq.trim.min_length_6.fq'), tmpfile, shallow=False)) os.unlink(tmpfile) 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)) tasks.enumerate_names(os.path.join(data_dir, 'sequences_test_enumerate_names.fa'), outfile, suffix='.SUFFIX') self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_enumerate_names.fa.out.add_suffix'), outfile, shallow=False)) 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_trim_contigs(self): '''Test that gap extension works''' outfile = 'tmp.gap_extend.fa' tasks.trim_contigs(os.path.join(data_dir, 'sequences_test_trim_contigs.fa'), outfile, trim=2) self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_trim_contigs.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_ids_with_comments_from_file_filter(self): '''Test that can extract reads from a file of read names where the read names have extra data after space''' infile = os.path.join(data_dir, 'readnames_with_comments.fastq') outfile = 'tmp.ids_file_filter.fastq' 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) def test_paired_both_pass(self): '''Test filter with paired file both pass''' infile1 = os.path.join(data_dir, 'tasks_test_filter_paired_both_pass.in_1.fa') infile2 = os.path.join(data_dir, 'tasks_test_filter_paired_both_pass.in_2.fa') outfile1 = 'tmp.filter_both_pass_1.fa' outfile2 = 'tmp.filter_both_pass_2.fa' expected1 = os.path.join(data_dir, 'tasks_test_filter_paired_both_pass.out_1.fa') expected2 = os.path.join(data_dir, 'tasks_test_filter_paired_both_pass.out_2.fa') tasks.filter(infile1, outfile1, mate_in=infile2, mate_out=outfile2, minlength=3) self.assertTrue(filecmp.cmp(outfile1, expected1, shallow=False)) self.assertTrue(filecmp.cmp(outfile2, expected2, shallow=False)) os.unlink(outfile1) os.unlink(outfile2) def test_paired_one_pass(self): '''Test filter with paired file one pass''' infile1 = os.path.join(data_dir, 'tasks_test_filter_paired_one_pass.in_1.fa') infile2 = os.path.join(data_dir, 'tasks_test_filter_paired_one_pass.in_2.fa') outfile1 = 'tmp.filter_one_pass_1.fa' outfile2 = 'tmp.filter_one_pass_2.fa' expected1 = os.path.join(data_dir, 'tasks_test_filter_paired_one_pass.out_1.fa') expected2 = os.path.join(data_dir, 'tasks_test_filter_paired_one_pass.out_2.fa') tasks.filter(infile1, outfile1, mate_in=infile2, mate_out=outfile2, both_mates_pass=False, minlength=3) self.assertTrue(filecmp.cmp(outfile1, expected1, shallow=False)) self.assertTrue(filecmp.cmp(outfile2, expected2, shallow=False)) os.unlink(outfile1) os.unlink(outfile2) 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)) tasks.interleave(os.path.join(data_dir, 'sequences_test_deinterleaved_no_suffixes_1.fa'), os.path.join(data_dir, 'sequences_test_deinterleaved_no_suffixes_2.fa'), tmp, suffix1='/1', suffix2='/2') self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'sequences_test_interleaved_with_suffixes.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 TestMeanLength(unittest.TestCase): def test_mean_length(self): '''Test mean_length''' expected = [3, 2, 3, 4, 4] limits = [1, 2, 3, 4, None] assert len(expected) == len(limits) for i in range(len(expected)): mean = tasks.mean_length(os.path.join(data_dir, 'tasks_test_mean_length.fa'), limit=limits[i]) self.assertEqual(expected[i], mean) 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, check_revcomp=True) self.assertTrue(filecmp.cmp(expected1, tmp1)) self.assertTrue(filecmp.cmp(expected2, tmp2)) os.unlink(tmp1) os.unlink(tmp2) class ToFastg(unittest.TestCase): def test_to_fastg_ids_set(self): '''Test to_fastg when ids are a set''' infile = os.path.join(data_dir, 'tasks_test_to_fastg.fasta') tmpfile = 'tmp.to_fastg.fastg' expected = os.path.join(data_dir, 'tasks_test_to_fastg.fastg') ids = {'seq2'} tasks.to_fastg(infile, tmpfile, circular=ids) self.assertTrue(filecmp.cmp(expected, tmpfile, shallow=False)) os.unlink(tmpfile) def test_to_fastg_ids_file(self): '''Test to_fastg when ids in a file''' infile = os.path.join(data_dir, 'tasks_test_to_fastg.fasta') tmpfile = 'tmp.to_fastg.fastg' expected = os.path.join(data_dir, 'tasks_test_to_fastg.fastg') ids_file = os.path.join(data_dir, 'tasks_test_to_fastg.ids_to_circularise') tasks.to_fastg(infile, tmpfile, circular=ids_file) self.assertTrue(filecmp.cmp(expected, tmpfile, shallow=False)) os.unlink(tmpfile) 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 TestLengthOffsetsFromFai(unittest.TestCase): def test_length_offsets_from_fai(self): '''Test length_offsets_from_fai''' got = tasks.length_offsets_from_fai(os.path.join(data_dir, 'tasks_test_length_offsets_from_fai.fa.fai')) expected = {'seq1': 0, 'seq2': 42, 'seq3': 43} self.assertEqual(expected, got) 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) def test_split_by_fixed_size_onefile(self): infile = os.path.join(data_dir, 'sequences_test_split_fixed_size_onefile.fa') tmp_out = 'tmp.sequences_test_split_fixed_size_onefile.fa' expected = os.path.join(data_dir, 'sequences_test_split_fixed_size_onefile.out.fa') tasks.split_by_fixed_size_onefile(infile, tmp_out, chunk_size=3, tolerance=1) self.assertTrue(filecmp.cmp(expected, tmp_out)) os.unlink(tmp_out) def test_split_by_fixed_size_onefile_exclude_Ns(self): infile = os.path.join(data_dir, 'sequences_test_split_fixed_size_onefile.fa') tmp_out = 'tmp.sequences_test_split_fixed_size_onefile.skip_Ns.fa' expected = os.path.join(data_dir, 'sequences_test_split_fixed_size_onefile.skip_Ns.out.fa') tasks.split_by_fixed_size_onefile(infile, tmp_out, chunk_size=3, tolerance=1, skip_if_all_Ns=True) self.assertTrue(filecmp.cmp(expected, tmp_out)) os.unlink(tmp_out) 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 TestSortBySize(unittest.TestCase): def test_sort_by_size(self): '''Test sort_by_size''' infile = os.path.join(data_dir, 'tasks_test_sort_by_size.in.fa') tmpfile = 'tmp.sorted.fa' tasks.sort_by_size(infile, tmpfile) self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'tasks_test_sort_by_size.out.fa'), tmpfile, shallow=False)) tasks.sort_by_size(infile, tmpfile, smallest_first=True) self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'tasks_test_sort_by_size.out.rev.fa'), tmpfile, shallow=False)) os.unlink(tmpfile) class TestSortByName(unittest.TestCase): def test_sort_by_name(self): '''Test sort_by_name''' infile = os.path.join(data_dir, 'tasks_test_sort_by_name.in.fa') tmpfile = 'tmp.sort_by_name.fa' tasks.sort_by_name(infile, tmpfile) self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'tasks_test_sort_by_name.out.fa'), tmpfile, shallow=False)) 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 TestStatsFromFai(unittest.TestCase): def test_stats_from_fai_nonempty(self): '''Test task stats_from_fai non-empty file''' infile = os.path.join(data_dir, 'tasks_test_stats_from_fai.in.fai') got = tasks.stats_from_fai(infile) expected = { 'longest': 10, 'shortest': 1, 'N50': 4, 'mean': 4.2, 'number': 5, 'total_length': 21 } self.assertEqual(expected, got) def test_stats_from_fai_empty(self): '''Test task stats_from_fai empty file''' infile = os.path.join(data_dir, 'tasks_test_stats_from_fai.in.empty.fai') got = tasks.stats_from_fai(infile) expected = { 'longest': 0, 'shortest': 0, 'N50': 0, 'mean': 0, 'number': 0, 'total_length': 0 } self.assertEqual(expected, got) class TestToBoulderio(unittest.TestCase): def test_to_boulderio(self): '''Test task to_boulderio''' tmpfile = 'tmp.boulder' tasks.to_boulderio(os.path.join(data_dir, 'tasks_test_to_boulderio.in.fa'), tmpfile) self.assertTrue(filecmp.cmp(os.path.join(data_dir, 'tasks_test_to_boulderio.out.boulder'), tmpfile, shallow=False)) 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) def test_to_fasta_strip_after_whitespace_non_unique(self): '''Test strip_after_whitespace with non-unique names''' tmpfile = 'tmp.strip_after_whitespace.fa' infile = os.path.join(data_dir, 'sequences_test.to_fasta.strip_after_whitespace_non_unique.in.fa') expected = os.path.join(data_dir, 'sequences_test.to_fasta.strip_after_whitespace_non_unique.out.fa') with self.assertRaises(tasks.Error): tasks.to_fasta(infile, tmpfile, strip_after_first_whitespace=True, check_unique=True) tasks.to_fasta(infile, tmpfile, strip_after_first_whitespace=True, check_unique=False) self.assertTrue(filecmp.cmp(tmpfile, expected, shallow=False)) os.unlink(tmpfile) def test_to_fasta_strip_after_whitespace_unique(self): '''Test strip_after_whitespace with unique names''' tmpfile = 'tmp.strip_after_whitespace.fa' infile = os.path.join(data_dir, 'sequences_test.to_fasta.strip_after_whitespace_unique.in.fa') expected = os.path.join(data_dir, 'sequences_test.to_fasta.strip_after_whitespace_unique.out.fa') tasks.to_fasta(infile, tmpfile, strip_after_first_whitespace=True, check_unique=True) self.assertTrue(filecmp.cmp(tmpfile, expected, shallow=False)) 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() Fastaq-3.17.0/pyfastaq/tests/utils_test.py000066400000000000000000000062131324251536500205740ustar00rootroot00000000000000#!/usr/bin/env python3 import sys import os import filecmp import unittest from pyfastaq 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() Fastaq-3.17.0/pyfastaq/utils.py000066400000000000000000000043451324251536500163770ustar00rootroot00000000000000import 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)) Fastaq-3.17.0/scripts/000077500000000000000000000000001324251536500145165ustar00rootroot00000000000000Fastaq-3.17.0/scripts/fastaq000077500000000000000000000101261324251536500157230ustar00rootroot00000000000000#!/usr/bin/env python3 import argparse import sys tasks = { 'acgtn_only': 'Replace every non acgtnACGTN with an N', 'add_indels': 'Deletes or inserts bases at given position(s)', 'caf_to_fastq': 'Converts a CAF file to FASTQ format', 'capillary_to_pairs': 'Converts file of capillary reads to paired and unpaired files', 'chunker': 'Splits sequences into equal sized chunks', 'count_sequences': 'Counts the sequences in input file', 'deinterleave': 'Splits interleaved paired file into two separate files', 'enumerate_names': 'Renames sequences in a file, calling them 1,2,3... etc', 'expand_nucleotides': 'Makes every combination of degenerate nucleotides', 'fasta_to_fastq': 'Convert FASTA and .qual to FASTQ', 'filter': 'Filter sequences to get a subset of them', 'get_ids': 'Get the ID of each sequence', 'get_seq_flanking_gaps': 'Gets the sequences flanking gaps', 'interleave': 'Interleaves two files, output is alternating between fwd/rev reads', 'make_random_contigs': 'Make contigs of random sequence', 'merge': 'Converts multi sequence file to a single sequence', 'replace_bases': 'Replaces all occurrences of one letter with another', 'reverse_complement': 'Reverse complement all sequences', 'scaffolds_to_contigs': 'Creates a file of contigs from a file of scaffolds', 'search_for_seq': 'Find all exact matches to a string (and its reverse complement)', 'sequence_trim': 'Trim exact matches to a given string off the start of every sequence', 'sort_by_name': 'Sorts sequences in lexographical (name) order', 'sort_by_size': 'Sorts sequences in length order', 'split_by_base_count': 'Split multi sequence file into separate files', 'strip_illumina_suffix': 'Strips /1 or /2 off the end of every read name', 'to_boulderio': 'Converts to Boulder-IO format, used by primer3', 'to_fasta': 'Converts a variety of input formats to nicely formatted FASTA format', 'to_fake_qual': 'Make fake quality scores file', 'to_mira_xml': 'Create an xml file from a file of reads, for use with Mira assembler', 'to_orfs_gff': 'Writes a GFF file of open reading frames', 'to_perfect_reads': 'Make perfect paired reads from reference', 'to_random_subset': 'Make a random sample of sequences (and optionally mates as well)', 'to_tiling_bam': 'Make a BAM file of reads uniformly spread across the input reference', 'to_unique_by_id': 'Remove duplicate sequences, based on their names. Keep longest seqs', 'translate': 'Translate all sequences in input nucleotide sequences', 'trim_contigs': 'Trims a set number of bases off the end of every contig', 'trim_ends': 'Trim fixed number of bases of start and/or end of every sequence', 'trim_Ns_at_end': 'Trims all Ns at the start/end of all sequences', 'version': 'Print version number and exit', } def print_usage_and_exit(): print('Usage: fastaq [options]', file=sys.stderr) print('\nTo get minimal usage for a command use:\nfastaq command', file=sys.stderr) print('\nTo get full help for a command use one of:\nfastaq command -h\nfastaq command --help\n', file=sys.stderr) print('\nAvailable commands:\n', file=sys.stderr) max_task_length = max([len(x) for x in list(tasks.keys())]) for task in sorted(tasks): print('{{0: <{}}}'.format(max_task_length).format(task), tasks[task], sep=' ', file=sys.stderr) sys.exit(1) if len(sys.argv) == 1 or sys.argv[1] in ['-h', '-help', '--help']: print_usage_and_exit() task = sys.argv.pop(1) if task not in tasks: print('Task "' + task + '" not recognised. Cannot continue.\n', file=sys.stderr) print_usage_and_exit() exec('import pyfastaq.runners.' + task) exec('pyfastaq.runners.' + task + '.run("' + tasks[task] + '")') Fastaq-3.17.0/setup.py000066400000000000000000000013411324251536500145400ustar00rootroot00000000000000import glob from setuptools import setup, find_packages setup( name='pyfastaq', version='3.17.0', description='Script to manipulate FASTA and FASTQ files, plus API for developers', packages = find_packages(), author='Martin Hunt', author_email='path-help@sanger.ac.uk', url='https://github.com/sanger-pathogens/Fastaq', scripts=glob.glob('scripts/*'), test_suite='nose.collector', tests_require=['nose >= 1.3'], license='GPLv3', classifiers=[ 'Development Status :: 4 - Beta', 'Topic :: Scientific/Engineering :: Bio-Informatics', 'Programming Language :: Python :: 3 :: Only', 'License :: OSI Approved :: GNU General Public License v3 (GPLv3)', ], )