Repository revision
repository tip
Select a revision to inspect and download versions of Galaxy utilities from this repository.

Repository seq_filter_by_id
Owner: peterjc
Synopsis: Filter sequences by ID
Divide a FASTA, FASTQ or SFF file in two, those sequences with or without an ID present
in the specified column(s) of a tabular file.

Example uses include filtering based on search results from a tool like NCBI BLAST,
TMHMM, SignalP, or a read mapper. i.e. Split your sequences according to whether
or not they have a BLAST match, transmembrane domain, signal peptide, or map to
the reference sequence.

This tool is a short Python script (using Biopython and Galaxy library functions).
It requires Biopython to be installed.

Note this tool replaces my three previously separate tools for FASTA, FASTA and
SFF filtering by ID.
Type: unrestricted
Revision: 12:85ef5f5a0562
This revision can be installed: True
Times cloned / installed: 4474

Repository README files - may contain important installation or license information

Galaxy tool to filter FASTA, FASTQ or SFF sequences by ID

This tool is copyright 2010-2023 by Peter Cock, The James Hutton Institute (formerly SCRI, Scottish Crop Research Institute), UK. All rights reserved. See the licence text below.

This tool is a short Python script (using both Biopython library functions) which divides a FASTA, FASTQ, or SFF file in two, those sequences with or without an ID present in the specified column(s) of a tabular file. Example uses include filtering based on search results from a tool like NCBI BLAST before assembly.

This tool is available from the Galaxy Tool Shed at:

See also sister tools:

Automated Installation

This should be straightforward using the Galaxy Tool Shed, which should be able to automatically install the dependency on Biopython, and then install this tool and run its unit tests.

Manual Installation

There are just two files to install to use this tool from within Galaxy:

  • seq_filter_by_id.py (the Python script)
  • seq_filter_by_id.xml (the Galaxy tool definition)

The suggested location is a dedicated tools/seq_filter_by_id folder.

You will also need to modify the tools_conf.xml file to tell Galaxy to offer the tool. One suggested location is in the filters section. Simply add the line:

<tool file="seq_filter_by_id/seq_filter_by_id.xml" />

If you wish to run the unit tests, also move/copy the test-data/ files under Galaxy's test-data/ folder. Then:

$ ./run_tests.sh -id seq_filter_by_id

You will also need to install Biopython 1.54 or later. That's it.

History

Version Changes
v0.0.1
  • Initial version, combining three separate scripts for each file format.
v0.0.4
  • Record script version when run from Galaxy.
  • Faster FASTA code which preserves the original line wrapping.
  • Basic unit test included.
v0.0.5
  • Check for errors using Python script's return code.
  • Cope with malformed FASTA entries without an identifier.
v0.0.6
  • Link to Tool Shed added to help text and this documentation.
  • Automated installation of the Biopython dependency.
  • Use reStructuredText for this README file.
  • Adopt standard MIT License.
  • Updated citation information (Cock et al. 2013).
  • Development moved to GitHub, https://github.com/peterjc/pico_galaxy
  • Renamed folder and adopted README.rst naming.
v0.0.7
  • Correct automated dependency definition.
v0.0.8
  • Simplified XML to apply input format to output data.
v0.2.0
  • Can supply ID list as a text parameter (instead of in a file)
  • Using optparse for the Python command line API.
  • Advanced option to ignore paired read suffixes.
  • Updated dependencies to use Biopython 1.64.
v0.2.1
  • Use Biopython instead of Galaxy for FASTQ handling.
  • Tool definition now embeds citation information.
  • Include input dataset name in output dataset names.
  • If white space is found in the requested tabular field then only the first word is used as the identifier (with a warning to stderr).
v0.2.2
  • Use the format_source=... tag.
  • Reorder XML elements (internal change only).
  • Planemo for Tool Shed upload (.shed.yml, internal change only).
v0.2.3
  • Ignore blank lines in ID file (contributed by Gildas Le CorguillĂ©).
  • Defensive quoting of filenames etc in the command definition (internal change only).
v0.2.4
  • Corrected error message wording.
v0.2.5
  • Ignore empty names, common in R output (Gildas Le CorguillĂ©).
v0.2.6
  • Depends on Biopython 1.67 via legacy Tool Shed package or bioconda.
v0.2.7
  • Python 3 compatible print function.
  • Use <command detect_errors="aggressive"> (internal change only).
  • Single quote command line arguments (internal change only).
v0.2.8
  • Bumped Biopython dependency version for Python 3 fixes.
v0.2.9
  • Fixed file open mode for Python 3.11 onwards.

Developers

This script and related tools were initially developed on the following hg branches: http://bitbucket.org/peterjc/galaxy-central/src/fasta_filter http://bitbucket.org/peterjc/galaxy-central/src/tools

Development has now moved to a dedicated GitHub repository: https://github.com/peterjc/pico_galaxy/tree/master/tools

For pushing a release to the test or main "Galaxy Tool Shed", use the following Planemo commands (which requires you have set your Tool Shed access details in ~/.planemo.yml and that you have access rights on the Tool Shed):

$ planemo shed_update -t testtoolshed --check_diff tools/seq_filter_by_id/ -m "New release"
...

or:

$ planemo shed_update -t toolshed --check_diff tools/seq_filter_by_id/ -m "New release"
...

To just build and check the tar ball, use:

$ planemo shed_upload --tar_only tools/seq_filter_by_id/
...
$ tar -tzf shed_upload.tar.gz
test-data/empty_file.dat
test-data/k12_hypothetical.fasta
test-data/k12_hypothetical.tabular
test-data/k12_hypothetical_alt.tabular
test-data/k12_ten_proteins.fasta
test-data/sanger-pairs-mixed.fastq
test-data/sanger-pairs-names.tabular
test-data/sanger-sample.fastq
tools/seq_filter_by_id/README.rst
tools/seq_filter_by_id/seq_filter_by_id.py
tools/seq_filter_by_id/seq_filter_by_id.xml
tools/seq_filter_by_id/tool_dependencies.xml

Licence (MIT)

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

Contents of this repository

Name Description Version Minimum Galaxy Version
from a tabular file 0.2.9 16.01

Categories
Fasta Manipulation - Tools for manipulating fasta data
Sequence Analysis - Tools for performing Protein and DNA/RNA analysis
Text Manipulation - Tools for manipulating data