[med-svn] [Git][med-team/pychopper][upstream] New upstream version 2.7.9
Ananthu C V (@weepingclown)
gitlab at salsa.debian.org
Tue Dec 5 18:36:38 GMT 2023
Ananthu C V pushed to branch upstream at Debian Med / pychopper
Commits:
077c3621 by Ananthu C V at 2023-12-05T22:02:29+05:30
New upstream version 2.7.9
- - - - -
12 changed files:
- .gitlab-ci.yml
- CHANGELOG.md
- LICENSE.md
- README.md
- conda/meta.yaml
- pychopper/__init__.py
- pychopper/chopper.py
- pychopper/edlib_backend.py
- + pychopper/primer_data/LSK114_primers.fas
- pychopper/scripts/pychopper.py
- pychopper/seq_utils.py
- requirements.txt
Changes:
=====================================
.gitlab-ci.yml
=====================================
@@ -3,6 +3,8 @@ include:
file: "push-github.yaml"
- project: "epi2melabs/ci-templates"
file: "push-conda.yaml"
+ - project: "epi2melabs/ci-templates"
+ file: "snippets.yaml"
image: ${UBUNTUIMAGE}:20.04
@@ -19,29 +21,13 @@ stages:
- release
- postrelease
-# Insist that the version in __init__.py matches the git tag
-.check-versions: &check-versions |
- PYVER="v"$(grep "__version__ = " ${CI_PROJECT_NAME}/__init__.py | awk '{gsub("\"","",$3); print $3}')
- TAGVER=${CI_COMMIT_TAG}
- if [[ "${PYVER}" != "${TAGVER}" ]]; then
- echo "Mismatching TAG and PACKAGE versions:"
- echo " - TAG:'$TAGVER'"
- echo " - PACKAGE:'$TAGVER'"
- exit 1
- else
- echo "TAG and PACKAGE versions agree: '${PYVER}'"
- fi
-
-# Insist a CHANGELOG entry has been made for tags
-.check-changelog: &check-changelog |
- TAGVER=${CI_COMMIT_TAG}
- MATCHES=$(grep -c "## \[${TAGVER}\]" CHANGELOG.md || exit 0)
- if [[ "${MATCHES}" != "1" ]]; then
- echo "Expected one match to '${CI_COMMIT_TAG}' in CHANGELOG, found ${MATCHES}"
- exit 1
- else
- echo "Found CHANGELOG.md entry for tag"
- fi
+deploy-checks:
+ stage: prerelease
+ script:
+ - !reference [.check, python-version]
+ - !reference [.check, changelog]
+ rules:
+ - if: '$CI_COMMIT_TAG =~ /^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$/'
test:
stage: test
@@ -54,15 +40,9 @@ test:
paths:
- dist/*.tar.gz
-deploy-checks:
- stage: prerelease
- script:
- - *check-versions
- - *check-changelog
- rules:
- - if: '$CI_COMMIT_TAG =~ /^v[[:digit:]]+\.[[:digit:]]+\.[[:digit:]]+$/'
-
conda:
+ variables:
+ PACKAGE_ARCH: "noarch"
tags:
- large_ram
extends:
=====================================
CHANGELOG.md
=====================================
@@ -4,6 +4,30 @@ All notable changes to this project will be documented in this file.
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
+## [v2.7.9]
+### Added
+- Support for LSK114 direct cDNA sequencing kit
+## [v2.7.8]
+### Fixed
+- Error when reading primers for edlib backend
+
+## [v2.7.7]
+### Fixed
+- UMIs in short reads containing 'N'
+- Incorrect mean quality score calculation
+- Allow length filtering without requirement to supply output file
+
+## [v2.7.6]
+### Fix
+- Literal None appended to sequence names when sequence comment is blank
+
+## [v2.7.5]
+### Fixed
+- CI conda release issue
+### Changed
+- License
+- Use pysam for fastx reading
+
## [v2.7.3]
### Changed
- Fixes for pandas v2 concat api changes
=====================================
LICENSE.md
=====================================
@@ -1,202 +1,173 @@
-This Source Code Form is subject to the terms of the Mozilla Public
-License, v. 2.0. If a copy of the MPL was not distributed with this
-file, You can obtain one at http://mozilla.org/MPL/2.0/.
+Oxford Nanopore Technologies PLC. Public License Version 1.0
+=============================================================
-(c) 2018 Oxford Nanopore Technologies Ltd.
+1. Definitions
+--------------
-
-Mozilla Public License Version 2.0
-==================================
-
-### 1. Definitions
-
-**1.1. “Contributor”**
+1.1. "Contributor"
means each individual or legal entity that creates, contributes to
the creation of, or owns Covered Software.
-**1.2. “Contributor Version”**
+1.2. "Contributor Version"
means the combination of the Contributions of others (if any) used
- by a Contributor and that particular Contributor's Contribution.
+ by a Contributor and that particular Contributor’s Contribution.
-**1.3. “Contribution”**
+1.3. "Contribution"
means Covered Software of a particular Contributor.
-**1.4. “Covered Software”**
+1.4. "Covered Software"
means Source Code Form to which the initial Contributor has attached
the notice in Exhibit A, the Executable Form of such Source Code
Form, and Modifications of such Source Code Form, in each case
including portions thereof.
-**1.5. “Incompatible With Secondary Licenses”**
- means
-
-* **(a)** that the initial Contributor has attached the notice described
- in Exhibit B to the Covered Software; or
-* **(b)** that the Covered Software was made available under the terms of
- version 1.1 or earlier of the License, but not also under the
- terms of a Secondary License.
-
-**1.6. “Executable Form”**
+1.5. "Executable Form"
means any form of the work other than Source Code Form.
-**1.7. “Larger Work”**
- means a work that combines Covered Software with other material, in
+1.6. "Larger Work"
+ means a work that combines Covered Software with other material, in
a separate file or files, that is not Covered Software.
-**1.8. “License”**
+1.7. "License"
means this document.
-**1.9. “Licensable”**
+1.8. "Licensable"
means having the right to grant, to the maximum extent possible,
whether at the time of the initial grant or subsequently, any and
all of the rights conveyed by this License.
-**1.10. “Modifications”**
+1.9. "Modifications"
means any of the following:
-* **(a)** any file in Source Code Form that results from an addition to,
- deletion from, or modification of the contents of Covered
- Software; or
-* **(b)** any new file in Source Code Form that contains any Covered
- Software.
-
-**1.11. “Patent Claims” of a Contributor**
- means any patent claim(s), including without limitation, method,
- process, and apparatus claims, in any patent Licensable by such
- Contributor that would be infringed, but for the grant of the
- License, by the making, using, selling, offering for sale, having
- made, import, or transfer of either its Contributions or its
- Contributor Version.
-
-**1.12. “Secondary License”**
+ (a) any file in Source Code Form that results from an addition to,
+ deletion from, or modification of the contents of Covered
+ Software; or
+ (b) any new file in Source Code Form that contains any Covered
+ Software.
+
+1.10. "Research Purposes"
+ means use for internal research and not intended for or directed
+ towards commercial advantages or monetary compensation; provided,
+ however, that monetary compensation does not include sponsored
+ research of research funded by grants.
+
+1.11 "Secondary License"
means either the GNU General Public License, Version 2.0, the GNU
Lesser General Public License, Version 2.1, the GNU Affero General
Public License, Version 3.0, or any later versions of those
licenses.
-**1.13. “Source Code Form”**
+1.12. "Source Code Form"
means the form of the work preferred for making modifications.
-**1.14. “You” (or “Your”)**
+1.13. "You" (or "Your")
means an individual or a legal entity exercising rights under this
- License. For legal entities, “You” includes any entity that
+ License. For legal entities, "You" includes any entity that
controls, is controlled by, or is under common control with You. For
- purposes of this definition, “control” means **(a)** the power, direct
+ purposes of this definition, "control" means (a) the power, direct
or indirect, to cause the direction or management of such entity,
- whether by contract or otherwise, or **(b)** ownership of more than
+ whether by contract or otherwise, or (b) ownership of more than
fifty percent (50%) of the outstanding shares or beneficial
ownership of such entity.
+2. License Grants and Conditions
+--------------------------------
-### 2. License Grants and Conditions
-
-#### 2.1. Grants
+2.1. Grants
Each Contributor hereby grants You a world-wide, royalty-free,
-non-exclusive license:
-
-* **(a)** under intellectual property rights (other than patent or trademark)
- Licensable by such Contributor to use, reproduce, make available,
- modify, display, perform, distribute, and otherwise exploit its
- Contributions, either on an unmodified basis, with Modifications, or
- as part of a Larger Work; and
-* **(b)** under Patent Claims of such Contributor to make, use, sell, offer
- for sale, have made, import, and otherwise transfer either its
- Contributions or its Contributor Version.
+non-exclusive license under Contributor copyrights Licensable by such
+Contributor to use, reproduce, make available, modify, display,
+perform, distribute, and otherwise exploit solely for Research Purposes
+its Contributions, either on an unmodified basis, with Modifications,
+or as part of a Larger Work.
-#### 2.2. Effective Date
+2.2. Effective Date
The licenses granted in Section 2.1 with respect to any Contribution
-become effective for each Contribution on the date the Contributor first
-distributes such Contribution.
+become effective for each Contribution on the date the Contributor
+first distributes such Contribution.
-#### 2.3. Limitations on Grant Scope
+2.3. Limitations on Grant Scope
The licenses granted in this Section 2 are the only rights granted under
this License. No additional rights or licenses will be implied from the
-distribution or licensing of Covered Software under this License.
-Notwithstanding Section 2.1(b) above, no patent license is granted by a
-Contributor:
+distribution or licensing of Covered Software under this License. The
+License is incompatible with Secondary Licenses. Notwithstanding
+Section 2.1 above, no copyright license is granted:
-* **(a)** for any code that a Contributor has removed from Covered Software;
+(a) for any code that a Contributor has removed from Covered Software;
or
-* **(b)** for infringements caused by: **(i)** Your and any other third party's
- modifications of Covered Software, or **(ii)** the combination of its
- Contributions with other software (except as part of its Contributor
- Version); or
-* **(c)** under Patent Claims infringed by Covered Software in the absence of
- its Contributions.
-This License does not grant any rights in the trademarks, service marks,
-or logos of any Contributor (except as may be necessary to comply with
-the notice requirements in Section 3.4).
+(b) use of the Contributions or its Contributor Version other than for
+Research Purposes only; or
-#### 2.4. Subsequent Licenses
+(c) for infringements caused by: (i) Your and any other third party’s
+modifications of Covered Software, or (ii) the combination of its
+Contributions with other software (except as part of its Contributor
+Version).
+
+This License does not grant any rights in the patents, trademarks,
+service marks, or logos of any Contributor (except as may be necessary
+to comply with the notice requirements in Section 3.4).
+
+2.4. Subsequent Licenses
No Contributor makes additional grants as a result of Your choice to
distribute the Covered Software under a subsequent version of this
-License (see Section 10.2) or under the terms of a Secondary License (if
-permitted under the terms of Section 3.3).
+License (see Section 10.2) or under the terms of a Secondary License
+(if permitted under the terms of Section 3.3).
-#### 2.5. Representation
+2.5. Representation
Each Contributor represents that the Contributor believes its
Contributions are its original creation(s) or it has sufficient rights
to grant the rights to its Contributions conveyed by this License.
-#### 2.6. Fair Use
+2.6. Fair Use
This License is not intended to limit any rights You have under
applicable copyright doctrines of fair use, fair dealing, or other
equivalents.
-#### 2.7. Conditions
+2.7. Conditions
Sections 3.1, 3.2, 3.3, and 3.4 are conditions of the licenses granted
in Section 2.1.
+3. Responsibilities
+-------------------
-### 3. Responsibilities
-
-#### 3.1. Distribution of Source Form
+3.1. Distribution of Source Form
All distribution of Covered Software in Source Code Form, including any
Modifications that You create or to which You contribute, must be under
the terms of this License. You must inform recipients that the Source
Code Form of the Covered Software is governed by the terms of this
License, and how they can obtain a copy of this License. You may not
-attempt to alter or restrict the recipients' rights in the Source Code
-Form.
+attempt to alter or restrict the recipients’ rights in the Source Code Form.
-#### 3.2. Distribution of Executable Form
+3.2. Distribution of Executable Form
If You distribute Covered Software in Executable Form then:
-* **(a)** such Covered Software must also be made available in Source Code
+(a) such Covered Software must also be made available in Source Code
Form, as described in Section 3.1, and You must inform recipients of
the Executable Form how they can obtain a copy of such Source Code
Form by reasonable means in a timely manner, at a charge no more
than the cost of distribution to the recipient; and
-* **(b)** You may distribute such Executable Form under the terms of this
- License, or sublicense it under different terms, provided that the
- license for the Executable Form does not attempt to limit or alter
- the recipients' rights in the Source Code Form under this License.
+(b) You may distribute such Executable Form under the terms of this
+ License.
-#### 3.3. Distribution of a Larger Work
+3.3. Distribution of a Larger Work
You may create and distribute a Larger Work under terms of Your choice,
provided that You also comply with the requirements of this License for
-the Covered Software. If the Larger Work is a combination of Covered
-Software with a work governed by one or more Secondary Licenses, and the
-Covered Software is not Incompatible With Secondary Licenses, this
-License permits You to additionally distribute such Covered Software
-under the terms of such Secondary License(s), so that the recipient of
-the Larger Work may, at their option, further distribute the Covered
-Software under the terms of either this License or such Secondary
-License(s).
+the Covered Software. The Larger Work may not be a combination of Covered
+Software with a work governed by one or more Secondary Licenses.
-#### 3.4. Notices
+3.4. Notices
You may not remove or alter the substance of any license notices
(including copyright notices, patent notices, disclaimers of warranty,
@@ -204,106 +175,105 @@ or limitations of liability) contained within the Source Code Form of
the Covered Software, except that You may alter any license notices to
the extent required to remedy known factual inaccuracies.
-#### 3.5. Application of Additional Terms
+3.5. Application of Additional Terms
-You may choose to offer, and to charge a fee for, warranty, support,
-indemnity or liability obligations to one or more recipients of Covered
-Software. However, You may do so only on Your own behalf, and not on
-behalf of any Contributor. You must make it absolutely clear that any
-such warranty, support, indemnity, or liability obligation is offered by
-You alone, and You hereby agree to indemnify every Contributor for any
-liability incurred by such Contributor as a result of warranty, support,
-indemnity or liability terms You offer. You may include additional
-disclaimers of warranty and limitations of liability specific to any
-jurisdiction.
+You may not choose to offer, or charge a fee for use of the Covered
+Software or a fee for, warranty, support, indemnity or liability
+obligations to one or more recipients of Covered Software. You must
+make it absolutely clear that any such warranty, support, indemnity, or
+liability obligation is offered by You alone, and You hereby agree to
+indemnify every Contributor for any liability incurred by such
+Contributor as a result of warranty, support, indemnity or liability
+terms You offer. You may include additional disclaimers of warranty and
+limitations of liability specific to any jurisdiction.
-
-### 4. Inability to Comply Due to Statute or Regulation
+4. Inability to Comply Due to Statute or Regulation
+---------------------------------------------------
If it is impossible for You to comply with any of the terms of this
License with respect to some or all of the Covered Software due to
-statute, judicial order, or regulation then You must: **(a)** comply with
-the terms of this License to the maximum extent possible; and **(b)**
+statute, judicial order, or regulation then You must: (a) comply with
+the terms of this License to the maximum extent possible; and (b)
describe the limitations and the code they affect. Such description must
be placed in a text file included with all distributions of the Covered
Software under this License. Except to the extent prohibited by statute
or regulation, such description must be sufficiently detailed for a
recipient of ordinary skill to be able to understand it.
+5. Termination
+--------------
-### 5. Termination
-
-**5.1.** The rights granted under this License will terminate automatically
-if You fail to comply with any of its terms. However, if You become
-compliant, then the rights granted under this License from a particular
-Contributor are reinstated **(a)** provisionally, unless and until such
-Contributor explicitly and finally terminates Your grants, and **(b)** on an
-ongoing basis, if such Contributor fails to notify You of the
-non-compliance by some reasonable means prior to 60 days after You have
-come back into compliance. Moreover, Your grants from a particular
-Contributor are reinstated on an ongoing basis if such Contributor
-notifies You of the non-compliance by some reasonable means, this is the
-first time You have received notice of non-compliance with this License
-from such Contributor, and You become compliant prior to 30 days after
-Your receipt of the notice.
+5.1. The rights granted under this License will terminate automatically
+if You fail to comply with any of its terms.
-**5.2.** If You initiate litigation against any entity by asserting a patent
+5.2. If You initiate litigation against any entity by asserting an
infringement claim (excluding declaratory judgment actions,
counter-claims, and cross-claims) alleging that a Contributor Version
-directly or indirectly infringes any patent, then the rights granted to
+directly or indirectly infringes, then the rights granted to
You by any and all Contributors for the Covered Software under Section
2.1 of this License shall terminate.
-**5.3.** In the event of termination under Sections 5.1 or 5.2 above, all
+5.3. In the event of termination under Sections 5.1 or 5.2 above, all
end user license agreements (excluding distributors and resellers) which
have been validly granted by You or Your distributors under this License
prior to termination shall survive termination.
-
-### 6. Disclaimer of Warranty
-
-> Covered Software is provided under this License on an “as is”
-> basis, without warranty of any kind, either expressed, implied, or
-> statutory, including, without limitation, warranties that the
-> Covered Software is free of defects, merchantable, fit for a
-> particular purpose or non-infringing. The entire risk as to the
-> quality and performance of the Covered Software is with You.
-> Should any Covered Software prove defective in any respect, You
-> (not any Contributor) assume the cost of any necessary servicing,
-> repair, or correction. This disclaimer of warranty constitutes an
-> essential part of this License. No use of any Covered Software is
-> authorized under this License except under this disclaimer.
-
-### 7. Limitation of Liability
-
-> Under no circumstances and under no legal theory, whether tort
-> (including negligence), contract, or otherwise, shall any
-> Contributor, or anyone who distributes Covered Software as
-> permitted above, be liable to You for any direct, indirect,
-> special, incidental, or consequential damages of any character
-> including, without limitation, damages for lost profits, loss of
-> goodwill, work stoppage, computer failure or malfunction, or any
-> and all other commercial damages or losses, even if such party
-> shall have been informed of the possibility of such damages. This
-> limitation of liability shall not apply to liability for death or
-> personal injury resulting from such party's negligence to the
-> extent applicable law prohibits such limitation. Some
-> jurisdictions do not allow the exclusion or limitation of
-> incidental or consequential damages, so this exclusion and
-> limitation may not apply to You.
-
-
-### 8. Litigation
+************************************************************************
+* *
+* 6. Disclaimer of Warranty *
+* ------------------------- *
+* *
+* Covered Software is provided under this License on an "as is" *
+* basis, without warranty of any kind, either expressed, implied, or *
+* statutory, including, without limitation, warranties that the *
+* Covered Software is free of defects, merchantable, fit for a *
+* particular purpose or non-infringing. The entire risk as to the *
+* quality and performance of the Covered Software is with You. *
+* Should any Covered Software prove defective in any respect, You *
+* (not any Contributor) assume the cost of any necessary servicing, *
+* repair, or correction. This disclaimer of warranty constitutes an *
+* essential part of this License. No use of any Covered Software is *
+* authorized under this License except under this disclaimer. *
+* *
+************************************************************************
+
+************************************************************************
+* *
+* 7. Limitation of Liability *
+* -------------------------- *
+* *
+* Under no circumstances and under no legal theory, whether tort *
+* (including negligence), contract, or otherwise, shall any *
+* Contributor, or anyone who distributes Covered Software as *
+* permitted above, be liable to You for any direct, indirect, *
+* special, incidental, or consequential damages of any character *
+* including, without limitation, damages for lost profits, loss of *
+* goodwill, work stoppage, computer failure or malfunction, or any *
+* and all other commercial damages or losses, even if such party *
+* shall have been informed of the possibility of such damages. This *
+* limitation of liability shall not apply to liability for death or *
+* personal injury resulting from such party’s negligence to the *
+* extent applicable law prohibits such limitation, but in such event, *
+* and to the greatest extent permissible, damages will be limited to *
+* direct damages not to exceed one hundred dollars. Some *
+* jurisdictions do not allow the exclusion or limitation of *
+* incidental or consequential damages, so this exclusion and *
+* limitation may not apply to You. *
+* *
+************************************************************************
+
+8. Litigation
+-------------
Any litigation relating to this License may be brought only in the
courts of a jurisdiction where the defendant maintains its principal
place of business and such litigation shall be governed by laws of that
jurisdiction, without reference to its conflict-of-law provisions.
-Nothing in this Section shall prevent a party's ability to bring
+Nothing in this Section shall prevent a party’s ability to bring
cross-claims or counter-claims.
-
-### 9. Miscellaneous
+9. Miscellaneous
+----------------
This License represents the complete agreement concerning the subject
matter hereof. If any provision of this License is held to be
@@ -312,24 +282,24 @@ necessary to make it enforceable. Any law or regulation which provides
that the language of a contract shall be construed against the drafter
shall not be used to construe this License against a Contributor.
+10. Versions of the License
+---------------------------
-### 10. Versions of the License
-
-#### 10.1. New Versions
+10.1. New Versions
-Mozilla Foundation is the license steward. Except as provided in Section
-10.3, no one other than the license steward has the right to modify or
-publish new versions of this License. Each version will be given a
-distinguishing version number.
+Oxford Nanopore Technologies PLC. is the license steward. Except as
+provided in Section 10.3, no one other than the license steward has the
+right to modify or publish new versions of this License. Each version
+will be given a distinguishing version number.
-#### 10.2. Effect of New Versions
+10.2. Effect of New Versions
You may distribute the Covered Software under the terms of the version
of the License under which You originally received the Covered Software,
or under the terms of any subsequent version published by the license
steward.
-#### 10.3. Modified Versions
+10.3. Modified Versions
If you create software not governed by this License, and you want to
create a new license for such software, you may create and use a
@@ -337,17 +307,12 @@ modified version of this License if you rename the license and remove
any references to the name of the license steward (except to note that
such modified license differs from this License).
-#### 10.4. Distributing Source Code Form that is Incompatible With Secondary Licenses
-
-If You choose to distribute Source Code Form that is Incompatible With
-Secondary Licenses under the terms of this version of the License, the
-notice described in Exhibit B of this License must be attached.
+Exhibit A - Source Code Form License Notice
+-------------------------------------------
-## Exhibit A - Source Code Form License Notice
-
- This Source Code Form is subject to the terms of the Mozilla Public
- License, v. 2.0. If a copy of the MPL was not distributed with this
- file, You can obtain one at http://mozilla.org/MPL/2.0/.
+ This Source Code Form is subject to the terms of the Oxford Nanopore
+ Technologies PLC. Public License, v. 1.0. Full licence can be found
+ obtained from support at nanoporetech.com
If it is not possible or desirable to put the notice in a particular
file, then You may include the notice in a location (such as a LICENSE
@@ -355,10 +320,3 @@ file in a relevant directory) where a recipient would be likely to look
for such a notice.
You may add additional accurate notices of copyright ownership.
-
-## Exhibit B - “Incompatible With Secondary Licenses” Notice
-
- This Source Code Form is "Incompatible With Secondary Licenses", as
- defined by the Mozilla Public License, v. 2.0.
-
-
=====================================
README.md
=====================================
@@ -27,7 +27,7 @@ Getting Started
Install using conda :
```bash
-conda install -c epi2melabs -c conda-forge -c bioconda "epi2melabs::pychopper"
+conda install -c nanoporetech -c conda-forge -c bioconda "nanoporetech::pychopper"
```
## Usage
@@ -55,7 +55,8 @@ optional arguments:
-g phmm_file File with custom profile HMMs (None).
-c config_file File to specify primer configurations for each
direction (None).
- -k kit Use primer sequences from this kit (PCS109).
+ -k kit{PCS109,PCS110,PCS111,LSK114}
+ Use primer sequences from this kit (PCS109).
-q cutoff Cutoff parameter (autotuned).
-Q min_qual Minimum mean base quality (7.0).
-z min_len Minimum segment length (50).
@@ -91,6 +92,8 @@ Example usage with default PCS109/DCS109 primers using the default pHMM backend:
pychopper -r report.pdf -u unclassified.fq -w rescued.fq input.fq full_length_output.fq
```
+
+
Example usage with default PCS109/DCS109 primers using the edlib/parasail backend:
```bash
@@ -141,14 +144,6 @@ RX:Z:TTTGCCATTGAAATTAGCGTTCGCCTT
Help
====
-## Licence and Copyright
-
-(c) 2019 Oxford Nanopore Technologies Ltd.
-
-This Source Code Form is subject to the terms of the Mozilla Public
-License, v. 2.0. If a copy of the MPL was not distributed with this
-file, You can obtain one at http://mozilla.org/MPL/2.0/.
-
## FAQs and tips
## References and Supporting Information
=====================================
conda/meta.yaml
=====================================
@@ -29,6 +29,7 @@ requirements:
- six
- pandas
- numpy
+ - pysam
test:
commands:
=====================================
pychopper/__init__.py
=====================================
@@ -1,5 +1,3 @@
# -*- coding: utf-8 -*-
-__author__ = 'ONT Applications Group'
-__email__ = 'Apps at nanoporetech.com'
-__version__ = "2.7.3"
+__version__ = "2.7.9"
=====================================
pychopper/chopper.py
=====================================
@@ -13,14 +13,14 @@ def _build_segments(hits, config):
segments = []
if len(hits) == 0:
return tuple(segments)
- for s in zip(hits, hits[1:]):
+ for s0,s1 in zip(hits, hits[1:]):
strand = None
seg_len = 0
- c = (s[0].Query, s[1].Query)
+ c = (s0.Query, s1.Query)
if c in config:
strand = config[c]
- seg_len = s[1].RefStart - s[0].RefEnd
- segments.append(Segment(s[0].RefStart, s[0].RefEnd, s[1].RefStart, s[1].RefEnd, strand, seg_len))
+ seg_len = s1.RefStart - s0.RefEnd
+ segments.append(Segment(s0.RefStart, s0.RefEnd, s1.RefStart, s1.RefEnd, strand, seg_len))
return tuple(segments)
@@ -45,19 +45,16 @@ def analyse_hits(hits, config):
# Fill in DP matrix:
for j in range(1, nr):
- for i in range(2):
- if i == 0:
- # First row holds excluded segments.
- # The can transition from eiter exluded or included segments:
- M[i, j] = M[0, j - 1]
- B[i, j] = (0, j - 1)
- if M[1, j - 1] > M[0, j - 1]:
- M[i, j] = M[1, j - 1]
- B[i, j] = (1, j - 1)
- elif i == 1:
- # Included segments can only transition from previosuly excluded segments:
- M[i, j] = M[0, j - 1] + segments[j].Len
- B[i, j] = (0, j - 1)
+ # First row holds excluded segments.
+ # The can transition from eiter exluded or included segments:
+ M[0, j] = M[0, j - 1]
+ B[0, j] = (0, j - 1)
+ if M[1, j - 1] > M[0, j - 1]:
+ M[0, j] = M[1, j - 1]
+ B[0, j] = (1, j - 1)
+ # Included segments can only transition from previously excluded segments:
+ M[1, j] = M[0, j - 1] + segments[j].Len
+ B[1, j] = (0, j - 1)
tlen = np.argmax(M[:, nr - 1])
valid_segments = []
@@ -115,8 +112,18 @@ def segments_to_reads(read, segments, keep_primers, bam_tags, detect_umis):
p2_to = min(len(read.Seq), s.Right + padding)
p_2 = read.Seq[p2_from:p2_to]
+ # Create a single probe containing adapter-surrounding sequences.
+ # to be used in a single UMI search. Separate with 'N' spacer to prevent
+ # overlapping hits
+ umi_scan_seq = p_1 + 'NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN' + p_2
+
+ # If the read is small and the adapter regions + padding overlap,
+ # then use only the whole read for the UMI search
+ if p1_to >= p2_from:
+ umi_scan_seq = read.Seq
+
umi, _ = edlib_backend.find_umi_single(
- [p_1 + 'NNNNNNNNNNNNNNNNNNNNNNNNNNNNNNN' + p_2, max_umi_ed])
+ [umi_scan_seq, max_umi_ed])
if bam_tags:
sr_name += "\tRX:Z:{}".format(umi)
else:
=====================================
pychopper/edlib_backend.py
=====================================
@@ -22,7 +22,6 @@ def find_umi_single(params):
"Find UMI in a single reads using the edlib/parasail backend"
read = params[0]
max_ed = params[1]
- normalise = False
pattern_list = [
(
@@ -59,33 +58,18 @@ def find_umi_single(params):
if best_ed is None:
return None, None
- # Extract and normalise UMI
- umi = ""
+ # Extract UMI
pattern, wildcard, equalities, forward = best_pattern
ed = best_result["editDistance"]
- if not normalise:
- locs = best_result["locations"][0]
- umi = read[locs[0]:locs[1]+1]
- if not forward:
- umi = seu.reverse_complement(umi)
- return umi, ed
-
- align = edlib.getNiceAlignment(best_result, pattern, read)
- for q, t in zip(align['query_aligned'], align['target_aligned']):
- if q != wildcard:
- continue
- if t == '-':
- umi += 'N'
- else:
- umi += t
+ locs = best_result["locations"][0]
+ umi = read[locs[0]:locs[1]+1]
if not forward:
umi = seu.reverse_complement(umi)
-
- if len(umi) != 16:
- raise RuntimeError("UMI length incorrect")
-
- return umi, best_ed
+ # Do not assign UMIs where UMI probe has aligned to the 'N' spacer.
+ if 'N' in umi:
+ return None, None
+ return umi, ed
def _find_locations_single(params):
=====================================
pychopper/primer_data/LSK114_primers.fas
=====================================
@@ -0,0 +1,4 @@
+>VNP
+ACTTGCCTGTCGCTCTATCTTCTTTTT
+>SSP
+TTTCTGTTGGTGCTGATATTGCT
\ No newline at end of file
=====================================
pychopper/scripts/pychopper.py
=====================================
@@ -183,8 +183,7 @@ def _plot_stats(st, pdf, q, q_bak, detect_umi):
_plot_pd_bars(rs.copy(), "Classification of output reads", R, ann=True)
found, rescue, unusable = float(rs.loc[rs.Name == "Primers_found", ].Value), float(rs.loc[rs.Name == "Rescue", ].Value), float(rs.loc[rs.Name == "Unusable", ].Value)
rs_stats = st.loc[st.Category == "ReadStats", ]
- umi_detected = float(rs_stats.loc[rs_stats.Name == "Umi_detected", ].Value)
- umi_detected_final = float(rs_stats.loc[rs_stats.Name == "Umi_detected_final", ].Value)
+ umi_detected_final = float(rs_stats.loc[rs_stats.Name == "Umi_detected_final", 'Value'].iloc[0])
total = found + rescue + unusable
found = found / total * 100
rescue = rescue / total * 100
@@ -236,8 +235,10 @@ def main():
'-c', metavar='config_file', type=str, default=None,
help="File to specify primer configurations for each direction (None).")
parser.add_argument(
- '-k', metavar='kit', type=str, default="PCS109",
- help="Use primer sequences from this kit (PCS109).")
+ '-k', type=str, default="PCS109",
+ help="Use primer sequences from this kit (PCS109).",
+ choices=['PCS109', 'PCS110', 'PCS111', 'LSK114']
+ )
parser.add_argument(
'-q', metavar='cutoff', type=float, default=None,
help="Cutoff parameter (autotuned).")
@@ -333,7 +334,12 @@ def main():
"HMM": os.path.join(
os.path.dirname(phmm_data.__file__), "PCS110_primers.hmm"),
"FAS": os.path.join(
- os.path.dirname(primer_data.__file__), "PCS111_primers.fas")}
+ os.path.dirname(primer_data.__file__), "PCS111_primers.fas")},
+ "LSK114": {
+ "HMM": os.path.join(
+ os.path.dirname(phmm_data.__file__), "cDNA_SSP_VNP.hmm"),
+ "FAS": os.path.join(
+ os.path.dirname(primer_data.__file__), "LSK114_primers.fas")}
}
if args.g is None:
@@ -355,13 +361,9 @@ def main():
CONFIG = "-:VNP,-VNP"
config = utils.parse_config_string(CONFIG)
- sys.stderr.write("Using kit: {}\n".format(args.k))
+ sys.stderr.write("Using kit: {}\n".format(args.b if args.b else args.k))
sys.stderr.write("Configurations to consider: \"{}\"\n".format(CONFIG))
- in_fh = sys.stdin
- if args.input_fastx != '-':
- in_fh = _opener(args.input_fastx, "r")
-
out_fh = sys.stdout
if args.output_fastx != '-':
out_fh = open(args.output_fastx, "w")
@@ -437,8 +439,7 @@ def main():
sys.stderr.write(
"Total fastq records in input file: {}\n".format(nr_records))
read_sample = list(
- seu.readfq(_opener(args.input_fastx, "r"), sample=target_prop,
- min_qual=args.Q))
+ seu.readfq(args.input_fastx, sample=target_prop, min_qual=args.Q))
sys.stderr.write(
"Tuning the cutoff parameter (q) on {} sampled reads ({:.1f}%) passing quality filters (Q >= {}).\n".format(
len(read_sample), target_prop * 100.0, args.Q))
@@ -446,15 +447,10 @@ def main():
for qv in tqdm.tqdm(cutoffs):
clsLen = 0
cls = 0
- with concurrent.futures.ProcessPoolExecutor(
- max_workers=args.t) as executor:
+ with concurrent.futures.ProcessPoolExecutor(max_workers=args.t) as executor:
for batch in utils.batch(read_sample, int((len(read_sample)))):
- for read, (segments, hits, usable_len) in backend(batch,
- executor,
- qv,
- max(1000,
- int((
- len(read_sample)) / args.t))):
+ for read, (segments, hits, usable_len) \
+ in backend(batch, executor, qv, max(1000, int((len(read_sample)) / args.t))):
flt = list([x.Len for x in segments if x.Len > 0])
if len(flt) == 1:
clsLen += sum(flt)
@@ -494,7 +490,7 @@ def main():
with concurrent.futures.ProcessPoolExecutor(
max_workers=args.t) as executor:
for batch in utils.batch(
- seu.readfq(in_fh, min_qual=args.Q, rfq_sup=rfq_sup), args.B):
+ seu.readfq(args.input_fastx, min_qual=args.Q, rfq_sup=rfq_sup), args.B):
for read, (segments, hits, usable_len) in backend(batch, executor,
q=args.q,
mb=min_batch_size):
@@ -508,9 +504,10 @@ def main():
args.p, args.y, args.U):
if trim_read.Umi:
st["Umi_detected"] += 1
- if args.l is not None and len(trim_read.Seq) < args.z:
+ if len(trim_read.Seq) < args.z:
st["LenFail"] += 1
- seu.writefq(trim_read, l_fh)
+ if args.l is not None:
+ seu.writefq(trim_read, l_fh)
continue
if len(segments) == 1:
if trim_read.Umi:
@@ -546,7 +543,7 @@ def main():
if args.S is not None:
stdf.to_csv(args.S, sep="\t", index=False)
- for fh in (in_fh, out_fh, u_fh, l_fh, w_fh, a_fh, d_fh):
+ for fh in (out_fh, u_fh, l_fh, w_fh, a_fh, d_fh):
if fh is None:
continue
fh.flush()
=====================================
pychopper/seq_utils.py
=====================================
@@ -2,6 +2,7 @@
from six.moves import reduce
from numpy.random import random
+from pysam import FastxFile
from math import log
import sys
from pychopper.common_structures import Seq
@@ -49,62 +50,34 @@ def reverse_complement(seq):
return reduce(lambda x, y: x + y, map(base_complement, seq[::-1]))
-def readfq(fp, sample=None, min_qual=None, rfq_sup={}): # this is a generator function
- """
- Below function taken from https://github.com/lh3/readfq/blob/master/readfq.py
- Much faster parsing of large files compared to Biopyhton.
+def readfq(fastq, sample=None, min_qual=0, rfq_sup={}): # this is a generator function
+ """Read fastx files.
+
+ This is a generator function that yields sequtils.Seq objects.
+ Optionally filter by a minimum mean quality (min_qual).
+ Optionally subsample the fastx file using sample (0.0 - 1.0)
"""
sup = ("out_fq" in rfq_sup) and (rfq_sup["out_fq"] is not None)
tsup = "total" in rfq_sup
if sup:
fh = open(rfq_sup["out_fq"], "w")
- last = None # this is a buffer keeping the last unprocessed line
- while True: # mimic closure; is it a bad idea?
- if not last: # the first record or a record following a fastq
- for l in fp: # search for the start of the next record
- if l[0] in '>@': # fasta/q header line
- last = l[:-1] # save this line
- break
- if not last:
- break
- name, seqs, last = last[1:], [], None
- for l in fp: # read the sequence
- if l[0] in '@+>':
- last = l[:-1]
- break
- seqs.append(l[:-1])
- if not last or last[0] != '+': # this is a fasta record
+
+ with FastxFile(fastq) as fqin:
+ for fx in fqin:
if sample is None or (random() < sample):
if tsup:
rfq_sup["total"] += 1
- yield Seq(name.split(" ", 1)[0], name, ''.join(seqs), None, None) # yield a fasta record
- if not last:
- break
- else: # this is a fastq record
- seq, leng, seqs = ''.join(seqs), 0, []
- for l in fp: # read the quality
- seqs.append(l[:-1])
- leng += len(l) - 1
- if leng >= len(seq): # have read enough quality
- last = None
- if sample is None or (random() < sample):
- quals = "".join(seqs)
- oseq = Seq(Id=name.split(" ", 1)[0], Name=name, Seq=seq, Qual=quals, Umi=None)
- if tsup:
- rfq_sup["total"] += 1
- if not (min_qual is not None and min_qual > 0 and mean_qual(quals) < min_qual):
- if tsup:
- rfq_sup["pass"] += 1
- yield oseq
- else:
- if sup:
- writefq(oseq, fh)
- break
- if last: # reach EOF before reading enough quality
- if sample is None or (random() < sample):
- yield Seq(name.split(" ", 1)[0], name, seq, None) # yield a fasta record instead
- break
-
+ probs = [10 ** (q / -10) for q in fx.get_quality_array()]
+ if (-10 * log(sum(probs) / len(probs), 10)) >= min_qual:
+ if tsup:
+ rfq_sup["pass"] += 1
+ yield Seq(
+ Id=fx.name,
+ Name=f"{fx.name} {fx.comment}" if fx.comment else fx.name,
+ Seq=fx.sequence, Qual=fx.quality, Umi=None)
+ else:
+ if sup:
+ fh.write(f"{fx}\n")
if sup:
fh.flush()
fh.close()
@@ -150,14 +123,14 @@ def record_size(read, in_format='fastq'):
def get_primers(primers):
- "Load primers from fasta file"
+ """Load primers from fasta file"""
all_primers = {}
- for primer in readfq(open(primers, 'r')):
- all_primers[primer.Name] = primer.Seq
- all_primers['-' + primer.Name] = reverse_complement(primer.Seq)
+ with FastxFile(primers) as fh:
+ for primer in fh:
+ all_primers[primer.name] = primer.sequence
+ all_primers['-' + primer.name] = reverse_complement(primer.sequence)
return all_primers
-
def errs_tab(n):
"""Generate list of error rates for qualities less than equal than n."""
return [10**(q / -10) for q in range(n + 1)]
=====================================
requirements.txt
=====================================
@@ -6,3 +6,4 @@ tqdm==4.26.0
pandas
numpy
pytest
+pysam
\ No newline at end of file
View it on GitLab: https://salsa.debian.org/med-team/pychopper/-/commit/077c36217b49900c85be25f976ac2ebb63165995
--
View it on GitLab: https://salsa.debian.org/med-team/pychopper/-/commit/077c36217b49900c85be25f976ac2ebb63165995
You're receiving this email because of your account on salsa.debian.org.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20231205/5d3d3e84/attachment-0001.htm>
More information about the debian-med-commit
mailing list