view tools/filters/seq_filter_by_id.xml @ 2:abdd608c869b draft

Uploaded v0.0.5, checked script return code for errors X copes with a FASTA entry missing an ID.
author peterjc
date Wed, 24 Apr 2013 11:34:12 -0400
parents 262f08104540
children
line wrap: on
line source

<tool id="seq_filter_by_id" name="Filter sequences by ID" version="0.0.5">
	<description>from a tabular file</description>
	<version_command interpreter="python">seq_filter_by_id.py --version</version_command>
	<command interpreter="python">
seq_filter_by_id.py $input_tabular $columns $input_file $input_file.ext
#if $output_choice_cond.output_choice=="both"
 $output_pos $output_neg
#elif $output_choice_cond.output_choice=="pos"
 $output_pos -
#elif $output_choice_cond.output_choice=="neg"
 - $output_neg
#end if
	</command>
        <stdio>
                <!-- Anything other than zero is an error -->
                <exit_code range="1:" />
                <exit_code range=":-1" />
        </stdio>
	<inputs>
		<param name="input_file" type="data" format="fasta,fastq,sff" label="Sequence file to filter on the identifiers" help="FASTA, FASTQ, or SFF format." />
		<param name="input_tabular" type="data" format="tabular" label="Tabular file containing sequence identifiers"/>
		<param name="columns" type="data_column" data_ref="input_tabular" multiple="True" numerical="False" label="Column(s) containing sequence identifiers" help="Multi-select list - hold the appropriate key while clicking to select multiple columns">
			<validator type="no_options" message="Pick at least one column"/>
		</param>
		<conditional name="output_choice_cond">
			<param name="output_choice" type="select" label="Output positive matches, negative matches, or both?">
				<option value="both">Both positive matches (ID on list) and negative matches (ID not on list), as two files</option>
				<option value="pos">Just positive matches (ID on list), as a single file</option>
				<option value="neg">Just negative matches (ID not on list), as a single file</option>
			</param>
			<!-- Seems need these dummy entries here, compare this to indels/indel_sam2interval.xml -->
			<when value="both" />
			<when value="pos" />
			<when value="neg" />
		</conditional>
	</inputs>
	<outputs>
		<data name="output_pos" format="fasta" label="With matched ID">
            <!-- TODO - Replace this with format="input:input_fastq" if/when that works -->
            <change_format>
                <when input_dataset="input_file" attribute="extension" value="sff" format="sff" />
                <when input_dataset="input_file" attribute="extension" value="fastq" format="fastq" />
                <when input_dataset="input_file" attribute="extension" value="fastqsanger" format="fastqsanger" />
                <when input_dataset="input_file" attribute="extension" value="fastqsolexa" format="fastqsolexa" />
                <when input_dataset="input_file" attribute="extension" value="fastqillumina" format="fastqillumina" />
                <when input_dataset="input_file" attribute="extension" value="fastqcssanger" format="fastqcssanger" />
            </change_format>
			<filter>output_choice_cond["output_choice"] != "neg"</filter>
		</data>
		<data name="output_neg" format="fasta" label="Without matched ID">
            <!-- TODO - Replace this with format="input:input_fastq" if/when that works -->
            <change_format>
                <when input_dataset="input_file" attribute="extension" value="sff" format="sff" />
                <when input_dataset="input_file" attribute="extension" value="fastq" format="fastq" />
                <when input_dataset="input_file" attribute="extension" value="fastqsanger" format="fastqsanger" />
                <when input_dataset="input_file" attribute="extension" value="fastqsolexa" format="fastqsolexa" />
                <when input_dataset="input_file" attribute="extension" value="fastqillumina" format="fastqillumina" />
                <when input_dataset="input_file" attribute="extension" value="fastqcssanger" format="fastqcssanger" />
            </change_format>
			<filter>output_choice_cond["output_choice"] != "pos"</filter>
		</data>
	</outputs>
	<tests>
		<test>
			<param name="input_file" value="k12_ten_proteins.fasta" ftype="fasta" />
			<param name="input_tabular" value="k12_hypothetical.tabular" ftype="tabular" />
			<param name="columns" value="1" />
			<param name="output_choice" value="pos" />
			<output name="output_pos" file="k12_hypothetical.fasta" ftype="fasta" />
		</test>
	</tests>
	<requirements>
		<requirement type="python-module">Bio</requirement>
	</requirements>
	<help>

**What it does**

By default it divides a FASTA, FASTQ or Standard Flowgram Format (SFF) file in
two, those sequences with or without an ID present in the tabular file column(s)
specified. You can opt to have a single output file of just the matching records,
or just the non-matching ones.

Note that the order of sequences in the original sequence file is preserved, as
is any Roche XML Manifest in an SFF file. Also, if any sequences share an
identifier (which would be very unusual in SFF files), duplicates are not removed.

**Example Usage**

You may have performed some kind of contamination search, for example running
BLASTN against a database of cloning vectors or bacteria, giving you a tabular
file containing read identifiers. You could use this tool to extract only the
reads without BLAST matches (i.e. those which do not match your contaminant
database).

You may have a file of FASTA sequences which has been used with some analysis
tool giving tabular output, which has then been filtered on some criteria.
You can then use this tool to divide the original FASTA file into those entries
matching or not matching your criteria (those with or without their identifier
in the filtered tabular file).

**Citation**

This tool uses Biopython to read and write SFF files. If you use this tool in
scientific work leading to a publication, please cite the Biopython application
note (and Galaxy too of course):

Cock et al 2009. Biopython: freely available Python tools for computational
molecular biology and bioinformatics. Bioinformatics 25(11) 1422-3.
http://dx.doi.org/10.1093/bioinformatics/btp163 pmid:19304878.

	</help>
</tool>