view tools/ncbi_blast_plus/ncbi_makeblastdb.xml @ 34:b6893f57f8d8 draft

planemo upload for repository https://github.com/peterjc/galaxy_blast/tree/master/tools/ncbi_blast_plus commit 028e3e806ba6df913403a2a083a354dfa713755f
author peterjc
date Thu, 22 Feb 2024 14:47:01 +0000
parents a52d2d93e595
children
line wrap: on
line source

<tool id="ncbi_makeblastdb" name="NCBI BLAST+ makeblastdb" version="@TOOL_VERSION@+galaxy@VERSION_SUFFIX@" profile="@PROFILE@">
    <description>Make BLAST database</description>
    <macros>
        <token name="@BINARY@">makeblastdb</token>
        <import>ncbi_macros.xml</import>
    </macros>
    <expand macro="preamble">
        <requirement type="package" version="3.9">python</requirement>
    </expand>
    <command detect_errors="aggressive" strict="true"><![CDATA[
#set $inputs = []
#set $input_compression = []
#for r in $input.selection:
    #if $input.type == "protein":
        #silent $inputs.append($r.input_file)
        #silent $input_compression.append($r.input_file.is_of_type('fasta.gz'))
    #elif $r.nuc_choice.source == "history":
        #silent $inputs.append($r.nuc_choice.input_file)
        #silent $input_compression.append($r.nuc_choice.input_file.is_of_type('fasta.gz'))
    #else:
        #silent $inputs.append($r.nuc_choice.input_file.fields.path)
        #silent $input_compression.append(False)
    #end if
#end for

python $__tool_directory__/check_no_duplicates.py
##First check for duplicates (since BLAST+ 2.2.28 fails to do so)
##and abort (via the ampersand ampersand trick) if any are found.
#for i in $inputs#'$i' #end for#
&&
##makeblastdb does not like input redirects of the sort
##makeblastdb -in <(gunzip -c gzipped_fasta_file)
##therefore we're cramming everything
##into a single cat command below
cat
#for i, is_gzipped in zip($inputs, $input_compression):
    #if $is_gzipped:
        <(gunzip -c '$i')
    #else:
        '$i'
    #end if
#end for
| makeblastdb -out '${os.path.join($outfile.files_path, "blastdb")}'
-blastdb_version 4
$parse_seqids
$hash_index
-in -
#if $title:
-title '${title}'
#else:
##Would default to being based on the cryptic Galaxy filenames, which is unhelpful
-title 'BLAST Database'
#end if
-dbtype
#if $input.type == "protein":
    prot
#else:
    nucl
#end if
## --------------------------------------------------------------------
## Masking
## --------------------------------------------------------------------
## HACK: If no mask files, evaluates as a list with just None in it:
## See Trello issue https://trello.com/c/lp5YmA1O
#if ' '.join( map(str, $mask_data_file) ) != 'None':
#for i in $mask_data_file:
-mask_data '${i}'
#end for
#end if
## --------------------------------------------------------------------
## Taxonomy
## --------------------------------------------------------------------
#if $tax.taxselect == 'id':
-taxid $tax.taxid
## #else if $tax.taxselect == 'map':
## -taxid_map $tax.taxmap
#end if
## --------------------------------------------------------------------
## Capture the stdout log information to the primary file (plain text):
> '$outfile'
    ]]></command>
    <inputs>
        <conditional name="input">
            <param argument="-dbtype" name="type" type="select" label="Molecule type of input">
                <option value="protein">protein</option>
                <option value="nucleotide">nucleotide</option>
            </param>
            <!-- TODO Allow merging of existing BLAST databases (conditional on the database type)?
                 NOTE Double check the new database would be self contained first
            -->
            <when value="protein">
                <repeat name="selection" title="Select input" min="1" default="1">
                    <!-- Note this is a mandatory parameter - default should be most recent FASTA file -->
                    <param name="input_file" argument="-in" type="data" format="fasta,fasta.gz" label="FASTA input" help="FASTA file with one or more sequences to add to the database" />
                </repeat>
            </when>
            <when value="nucleotide">
                <repeat name="selection" title="Select input" min="1" default="1">
                    <conditional name="nuc_choice">
                        <param name="source" type="select" label="Input is a">
                            <option value="history">Dataset in history</option>
                            <option value="cached">Genome on server</option>
                        </param>
                        <when value="history">
                            <param name="input_file" argument="-in" type="data" format="fasta,fasta.gz" label="FASTA input" help="FASTA file with one or more sequences to add to the database" />
                        </when>
                        <when value="cached">
                            <param name="input_file" type="select" label="Installed genome">
                                <options from_data_table="all_fasta"/>
                            </param>
                        </when>
                    </conditional>
                </repeat>
            </when>
        </conditional>        
        <param argument="-title" type="text" value="" label="Title for BLAST database" help="This is the database name shown in BLAST search output" />
        <param argument="-parse_seqids" type="boolean" truevalue="-parse_seqids" falsevalue="" checked="false" label="Parse the sequence identifiers" help="This is only advised if your FASTA file follows the NCBI naming conventions using pipe '|' symbols" />
        <param argument="-hash_index" type="boolean" truevalue="-hash_index" falsevalue="" checked="true" label="Enable the creation of sequence hash values" help="These hash values can then be used to quickly determine if a given sequence data exists in this BLAST database." />
        <!-- SEQUENCE MASKING OPTIONS -->
        <!-- Note this is an optional parameter - default should be NO files -->
        <param name="mask_data_file" argument="-mask_data" type="data" multiple="true" optional="true" value="" format="maskinfo-asn1,maskinfo-asn1-binary" label="Optional ASN.1 file(s) containing masking data" help="As produced by NCBI masking applications (e.g. dustmasker, segmasker, windowmasker)" />
        <!-- TODO - Option to create GI indexed masking data? via -gi_mask and -gi_mask_name? -->
        <!-- TAXONOMY OPTIONS -->
        <conditional name="tax">
            <param name="taxselect" type="select" label="Taxonomy options">
                <option value="">Do not assign a Taxonomy ID to the sequences</option>
                <option value="id">Assign the same Taxonomy ID to all the sequences</option>
                <!--
                <option value="map">Supply text file mapping sequence IDs to taxnomy IDs</option>
                TODO - Can we use a tabular file for the taxonomy mapping?
                -->
            </param>
            <when value="">
            </when>
            <when value="id">
                <param argument="-taxid" type="integer" min="0" value="" label="NCBI taxonomy ID" help="Integer &gt;=0, e.g. 9606 for Homo sapiens" />
            </when>
            <!-- TODO: File format?
            <when value="map">
                <param name="taxmap" argument="-taxid_map" type="data" format="txt" label="Seq ID : Tax ID mapping file" help="Format: SequenceId TaxonomyId" />
            </when>

            -->
        </conditional>
    </inputs>
    <outputs>
        <!-- If we only accepted one FASTA file, we could use its human name here... -->
        <data name="outfile" format="data" label="${input.type} BLAST database from ${on_string}">
            <change_format>
                <when input="input.type" value="nucleotide" format="blastdbn" />
                <when input="input.type" value="protein" format="blastdbp" />
            </change_format>
        </data>
    </outputs>
    <tests>
        <!-- Note the (two line) PIN file is not reproducible run to run.
             The same applies to the NIN file for nucleotide database.
             Likewise there is a datestamp in the log file as well, so use contains comparison
             With and without the masking makes no difference.
             With and without the taxid the only real difference is in the *.phr file.
        -->
        <test>
            <conditional name="input">
                <param name="type" value="protein"/>
                <repeat name="selection">
                    <param name="input_file" value="four_human_proteins.fasta" ftype="fasta" />
                </repeat>
            </conditional>    
            <param name="title" value="Just 4 human proteins" />
            <param name="parse_seqids" value="" />
            <param name="hash_index" value="true" />
            <output name="outfile" compare="contains" file="four_human_proteins.fasta.log.txt" ftype="blastdbp">
                <extra_files type="file" value="four_human_proteins.fasta.phr" name="blastdb.phr" />
                <extra_files type="file" value="four_human_proteins.fasta.pin" name="blastdb.pin" compare="sim_size" delta="0" />
                <extra_files type="file" value="four_human_proteins.fasta.psq" name="blastdb.psq" />
                <extra_files type="file" value="four_human_proteins.fasta.pog" name="blastdb.pog" />
                <extra_files type="file" value="four_human_proteins.fasta.phd" name="blastdb.phd" />
                <extra_files type="file" value="four_human_proteins.fasta.phi" name="blastdb.phi" />
                <extra_files type="file" value="four_human_proteins.fasta.psd" name="blastdb.psd" />
                <extra_files type="file" value="four_human_proteins.fasta.psi" name="blastdb.psi" />
            </output>
        </test>
        <test>
            <conditional name="input">
                <param name="type" value="protein"/>
                <repeat name="selection">
                    <param name="input_file" value="four_human_proteins.fasta" ftype="fasta" />
                </repeat>
            </conditional>    
            <param name="title" value="Just 4 human proteins" />
            <param name="parse_seqids" value="" />
            <param name="hash_index" value="true" />
            <param name="taxselect" value="id" />
            <param name="taxid" value="9606" />
            <output name="outfile" compare="contains" file="four_human_proteins_taxid.fasta.log.txt" ftype="blastdbp">
                <extra_files type="file" value="four_human_proteins_taxid.fasta.phr" name="blastdb.phr" />
                <extra_files type="file" value="four_human_proteins_taxid.fasta.pin" name="blastdb.pin" compare="sim_size" delta="0" />
                <extra_files type="file" value="four_human_proteins_taxid.fasta.psq" name="blastdb.psq" />
                <extra_files type="file" value="four_human_proteins_taxid.fasta.pog" name="blastdb.pog" />
                <extra_files type="file" value="four_human_proteins_taxid.fasta.phd" name="blastdb.phd" />
                <extra_files type="file" value="four_human_proteins_taxid.fasta.phi" name="blastdb.phi" />
                <extra_files type="file" value="four_human_proteins_taxid.fasta.psd" name="blastdb.psd" />
                <extra_files type="file" value="four_human_proteins_taxid.fasta.psi" name="blastdb.psi" />
            </output>
        </test>
        <test>
            <conditional name="input">
                <param name="type" value="protein"/>
                <repeat name="selection">
                    <param name="input_file" value="four_human_proteins.fasta" ftype="fasta" />
                </repeat>
            </conditional>                
            <param name="title" value="Just 4 human proteins" />
            <param name="parse_seqids" value="" />
            <param name="hash_index" value="true" />
            <param name="mask_data_file" value="segmasker_four_human.maskinfo-asn1" ftype="maskinfo-asn1" />
            <output name="outfile" compare="contains" file="four_human_proteins.fasta.log.txt" ftype="blastdbp">
                <extra_files type="file" value="four_human_proteins.fasta.phr" name="blastdb.phr" />
                <extra_files type="file" value="four_human_proteins.fasta.pin" name="blastdb.pin" compare="sim_size" delta="0" />
                <extra_files type="file" value="four_human_proteins.fasta.psq" name="blastdb.psq" />
                <extra_files type="file" value="four_human_proteins.fasta.pog" name="blastdb.pog" />
                <extra_files type="file" value="four_human_proteins.fasta.phd" name="blastdb.phd" />
                <extra_files type="file" value="four_human_proteins.fasta.phi" name="blastdb.phi" />
                <extra_files type="file" value="four_human_proteins.fasta.psd" name="blastdb.psd" />
                <extra_files type="file" value="four_human_proteins.fasta.psi" name="blastdb.psi" />
            </output>
        </test>
        <test>
            <conditional name="input">
                <param name="type" value="nucleotide"/>
                <repeat name="selection">
                    <conditional name="nuc_choice">
                        <param name="source" value="history"/>
                        <param name="input_file" value="three_human_mRNA.fasta.gz" ftype="fasta.gz" />
                    </conditional> 
                </repeat>
            </conditional> 
            <param name="title" value="Just 3 human mRNA sequences" />
            <param name="parse_seqids" value="" />
            <param name="hash_index" value="true" />
            <param name="taxselect" value="id" />
            <param name="taxid" value="9606" />
            <output name="outfile" compare="contains" file="three_human_mRNA.fasta.log.txt" ftype="blastdbn">
                <extra_files type="file" value="three_human_mRNA.fasta.nhr" name="blastdb.nhr" />
                <extra_files type="file" value="three_human_mRNA.fasta.nin" name="blastdb.nin" compare="sim_size" delta="8" />
                <extra_files type="file" value="three_human_mRNA.fasta.nsq" name="blastdb.nsq" />
                <extra_files type="file" value="three_human_mRNA.fasta.nog" name="blastdb.nog" />
                <extra_files type="file" value="three_human_mRNA.fasta.nhd" name="blastdb.nhd" />
                <extra_files type="file" value="three_human_mRNA.fasta.nhi" name="blastdb.nhi" />
                <extra_files type="file" value="three_human_mRNA.fasta.nsd" name="blastdb.nsd" />
                <extra_files type="file" value="three_human_mRNA.fasta.nsi" name="blastdb.nsi" />
            </output>
        </test>
        <test>
            <conditional name="input">
                <param name="type" value="nucleotide"/>
                <repeat name="selection">
                    <conditional name="nuc_choice">
                        <param name="source" value="cached"/>
                        <param name="input_file" value="three_human_mRNA" />
                    </conditional> 
                </repeat>
            </conditional> 
            <param name="title" value="Just 3 human mRNA sequences" />
            <param name="parse_seqids" value="" />
            <param name="hash_index" value="true" />
            <param name="taxselect" value="id" />
            <param name="taxid" value="9606" />
            <output name="outfile" compare="contains" file="three_human_mRNA.fasta.log.txt" ftype="blastdbn">
                <extra_files type="file" value="three_human_mRNA.fasta.nhr" name="blastdb.nhr" />
                <extra_files type="file" value="three_human_mRNA.fasta.nin" name="blastdb.nin" compare="sim_size" delta="8" />
                <extra_files type="file" value="three_human_mRNA.fasta.nsq" name="blastdb.nsq" />
                <extra_files type="file" value="three_human_mRNA.fasta.nog" name="blastdb.nog" />
                <extra_files type="file" value="three_human_mRNA.fasta.nhd" name="blastdb.nhd" />
                <extra_files type="file" value="three_human_mRNA.fasta.nhi" name="blastdb.nhi" />
                <extra_files type="file" value="three_human_mRNA.fasta.nsd" name="blastdb.nsd" />
                <extra_files type="file" value="three_human_mRNA.fasta.nsi" name="blastdb.nsi" />
            </output>
        </test>
    </tests>
    <help>
**What it does**

Make BLAST database from one or more FASTA files and/or BLAST databases.

This is a wrapper for the NCBI BLAST+ tool 'makeblastdb', which is the
replacement for the 'formatdb' tool in the NCBI 'legacy' BLAST suite.

More information about makeblastdb can be found in the `BLAST Command Line Applications User Manual`_.

.. _BLAST Command Line Applications User Manual: https://www.ncbi.nlm.nih.gov/books/NBK279690/


<!--
Applying masks to an existing BLAST database will not change the original database; a new database will be created.
For this reason, it's best to apply all masks at once to minimize the number of unnecessary intermediate databases.
-->

**References**

If you use this Galaxy tool in work leading to a scientific publication please
cite the following papers:

@REFERENCES@
    </help>
    <expand macro="blast_citations" />
</tool>