Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add unit tests #2

Merged
merged 1 commit into from
Jul 15, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
41 changes: 41 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
language: python
python:
- "2.7"

install:
- sudo apt-get update
- if [[ "$TRAVIS_PYTHON_VERSION" == "2.7" ]]; then
wget https://repo.continuum.io/miniconda/Miniconda2-latest-Linux-x86_64.sh -O miniconda.sh;
else
wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh;
fi
- bash miniconda.sh -b -p $HOME/miniconda
- export PATH="$HOME/miniconda/bin:$PATH"
- hash -r
- conda config --set always_yes yes --set changeps1 no
- conda update -q conda
- conda info -a

- conda create -q -n test-environment python=$TRAVIS_PYTHON_VERSION
- source activate test-environment
- conda config --add channels conda-forge
- conda config --add channels bioconda
- conda config --add channels anaconda
- conda config --add channels workflowconversion

- git clone https://github.com/WorkflowConversion/CTDopts $HOME/CTDopts
- cd $HOME/CTDopts
- python setup.py install
- conda install -c conda-forge lxml
- conda install -c conda-forge ruamel.yaml
- conda install libxml2
- cd $TRAVIS_BUILD_DIR
- python setup.py install

- conda install coverage green codecov

script:
- python setup.py test

after_script:
- python -m codecov
Empty file added tests/__init__.py
Empty file.
44 changes: 44 additions & 0 deletions tests/test-data/AccurateMassSearch.ctd
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
<?xml version="1.0" encoding="UTF-8"?>
<tool ctdVersion="1.7" version="2.4.0-HEAD-2018-10-26" name="AccurateMassSearch" docurl="http://ftp.mi.fu-berlin.de/OpenMS/release-documentation/html/UTILS_AccurateMassSearch.html" category="Utilities" >
<description><![CDATA[Match MS signals to molecules from a database by mass.]]></description>
<manual><![CDATA[Match MS signals to molecules from a database by mass.]]></manual>
<citations>
<citation doi="10.1038/nmeth.3959" url="" />
</citations>
<PARAMETERS version="1.6.2" xsi:noNamespaceSchemaLocation="https://raw.githubusercontent.com/OpenMS/OpenMS/develop/share/OpenMS/SCHEMAS/Param_1_6_2.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<NODE name="AccurateMassSearch" description="Match MS signals to molecules from a database by mass.">
<ITEM name="version" value="2.4.0-HEAD-2018-10-26" type="string" description="Version of the tool that generated this parameters file." required="false" advanced="true" />
<NODE name="1" description="Instance &apos;1&apos; section for &apos;AccurateMassSearch&apos;">
<ITEM name="in" value="" type="input-file" description="featureXML or consensusXML file" required="true" advanced="false" supported_formats="*.featureXML,*.consensusXML" />
<ITEM name="out" value="" type="output-file" description="mzTab file" required="true" advanced="false" supported_formats="*.mzTab" />
<ITEM name="out_annotation" value="" type="output-file" description="A copy of the input file, annotated with matching hits from the database." required="false" advanced="false" supported_formats="*.featureXML,*.consensusXML" />
<ITEM name="positive_adducts" value="CHEMISTRY/PositiveAdducts.tsv" type="input-file" description="This file contains the list of potential positive adducts that will be looked for in the database. Edit the list if you wish to exclude/include adducts. By default CHEMISTRY/PositiveAdducts.tsv in OpenMS/share is used! If empty, the default will be used." required="true" advanced="false" supported_formats="*.tsv" />
<ITEM name="negative_adducts" value="CHEMISTRY/NegativeAdducts.tsv" type="input-file" description="This file contains the list of potential negative adducts that will be looked for in the database. Edit the list if you wish to exclude/include adducts. By default CHEMISTRY/NegativeAdducts.tsv in OpenMS/share is used! If empty, the default will be used." required="true" advanced="false" supported_formats="*.tsv" />
<ITEM name="log" value="" type="string" description="Name of log file (created only when specified)" required="false" advanced="true" />
<ITEM name="debug" value="0" type="int" description="Sets the debug level" required="false" advanced="true" />
<ITEM name="threads" value="1" type="int" description="Sets the number of threads allowed to be used by the TOPP tool" required="false" advanced="false" />
<ITEM name="no_progress" value="false" type="string" description="Disables progress logging to command line" required="false" advanced="true" restrictions="true,false" />
<ITEM name="force" value="false" type="string" description="Overwrite tool specific checks." required="false" advanced="true" restrictions="true,false" />
<ITEM name="test" value="false" type="string" description="Enables the test mode (needed for internal use only)" required="false" advanced="true" restrictions="true,false" />
<NODE name="db" description="Database files which contain the identifications">
<ITEMLIST name="mapping" type="input-file" description="Database input file(s), containing three tab-separated columns of mass, formula, identifier. If &apos;mass&apos; is 0, it is re-computed from the molecular sum formula. By default CHEMISTRY/HMDBMappingFile.tsv in OpenMS/share is used! If empty, the default will be used." required="true" advanced="false" supported_formats="*.tsv">
<LISTITEM value="CHEMISTRY/HMDBMappingFile.tsv"/>
</ITEMLIST>
<ITEMLIST name="struct" type="input-file" description="Database input file(s), containing four tab-separated columns of identifier, name, SMILES, INCHI.The identifier should match with mapping file. SMILES and INCHI are reported in the output, but not used otherwise. By default CHEMISTRY/HMDB2StructMapping.tsv in OpenMS/share is used! If empty, the default will be used." required="true" advanced="false" supported_formats="*.tsv">
<LISTITEM value="CHEMISTRY/HMDB2StructMapping.tsv"/>
</ITEMLIST>
</NODE>
<NODE name="algorithm" description="Algorithm parameters section">
<ITEM name="mass_error_value" value="5" type="double" description="Tolerance allowed for accurate mass search." required="false" advanced="false" />
<ITEM name="mass_error_unit" value="ppm" type="string" description="Unit of mass error (ppm or Da)" required="false" advanced="false" restrictions="ppm,Da" />
<ITEM name="ionization_mode" value="positive" type="string" description="Positive or negative ionization mode? If &apos;auto&apos; is used, the first feature of the input map must contain the meta-value &apos;scan_polarity&apos;. If its missing, the tool will exit with error." required="false" advanced="false" restrictions="positive,negative,auto" />
<ITEM name="isotopic_similarity" value="false" type="string" description="Computes a similarity score for each hit (only if the feature exhibits at least two isotopic mass traces)." required="false" advanced="false" restrictions="false,true" />
<ITEM name="keep_unidentified_masses" value="false" type="string" description="Keep features that did not yield any DB hit." required="false" advanced="false" restrictions="false,true" />
<NODE name="mzTab" description="">
<ITEM name="exportIsotopeIntensities" value="0" type="int" description="[featureXML input only] Number of extra columns in mzTab output, which provide intensities up to the x&apos;th isotope. &apos;0&apos; to deactivate, &apos;1&apos; for monoisotopic peak, etc. If a feature does not have a certain isotope, &apos;null&apos; will be reported." required="false" advanced="false" restrictions="0:" />
</NODE>
</NODE>
</NODE>
</NODE>
</PARAMETERS>
</tool>
144 changes: 144 additions & 0 deletions tests/test-data/AccurateMassSearch.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,144 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--This is a configuration file for the integration of a tools into Galaxy (https://galaxyproject.org/). This file was automatically generated using CTDConverter.-->
<!--Proposed Tool Section: [Utilities]-->
<tool id="AccurateMassSearch" name="AccurateMassSearch" version="2.4.0-HEAD-2018-10-26">
<description>Match MS signals to molecules from a database by mass.</description>
<macros>
<token name="@EXECUTABLE@">AccurateMassSearch</token>
<import>macros.xml</import>
</macros>
<expand macro="requirements"/>
<expand macro="stdio"/>
<expand macro="references"/>
<command>AccurateMassSearch

#if str($param_in):
-in $param_in
#end if
#if str($param_out):
-out $param_out
#end if
#if str($param_out_annotation):
-out_annotation $param_out_annotation
#end if
#if str($param_positive_adducts):
-positive_adducts $param_positive_adducts
#end if
#if str($param_negative_adducts):
-negative_adducts $param_negative_adducts
#end if
#if str($param_threads):
-threads $param_threads
#end if
-db:mapping
#for token in $param_db_mapping:
$token
#end for
-db:struct
#for token in $param_db_struct:
$token
#end for
#if str($param_algorithm_mass_error_value):
-algorithm:mass_error_value $param_algorithm_mass_error_value
#end if
#if $param_algorithm_mass_error_unit:
-algorithm:mass_error_unit
#if " " in str($param_algorithm_mass_error_unit):
"$param_algorithm_mass_error_unit"
#else
$param_algorithm_mass_error_unit
#end if
#end if
#if $param_algorithm_ionization_mode:
-algorithm:ionization_mode
#if " " in str($param_algorithm_ionization_mode):
"$param_algorithm_ionization_mode"
#else
$param_algorithm_ionization_mode
#end if
#end if
#if $param_algorithm_isotopic_similarity:
-algorithm:isotopic_similarity
#end if
#if $param_algorithm_keep_unidentified_masses:
-algorithm:keep_unidentified_masses
#end if
#if str($param_algorithm_mzTab_exportIsotopeIntensities):
-algorithm:mzTab:exportIsotopeIntensities $param_algorithm_mzTab_exportIsotopeIntensities
#end if
#if $adv_opts.adv_opts_selector=='advanced':
#if str($adv_opts.param_log):
-log "$adv_opts.param_log"
#end if
#if str($adv_opts.param_debug):
-debug $adv_opts.param_debug
#end if
#if $adv_opts.param_no_progress:
-no_progress
#end if
#if $adv_opts.param_force:
-force
#end if
#if $adv_opts.param_test:
-test
#end if
#end if
</command>
<inputs>
<param name="param_in" type="data" format="featureXML,consensusXML" optional="False" label="featureXML or consensusXML file" help="(-in) "/>
<param name="param_positive_adducts" type="data" format="tsv" optional="False" value="CHEMISTRY/PositiveAdducts.tsv" label="This file contains the list of potential positive adducts that will be looked for in the database" help="(-positive_adducts) Edit the list if you wish to exclude/include adducts. By default CHEMISTRY/PositiveAdducts.tsv in OpenMS/share is used! If empty, the default will be used"/>
<param name="param_negative_adducts" type="data" format="tsv" optional="False" value="CHEMISTRY/NegativeAdducts.tsv" label="This file contains the list of potential negative adducts that will be looked for in the database" help="(-negative_adducts) Edit the list if you wish to exclude/include adducts. By default CHEMISTRY/NegativeAdducts.tsv in OpenMS/share is used! If empty, the default will be used"/>
<param name="param_threads" type="integer" value="1" label="Sets the number of threads allowed to be used by the TOPP tool" help="(-threads) "/>
<param name="param_db_mapping" type="data" format="tsv" multiple="true" optional="False" size="30" value="CHEMISTRY/HMDBMappingFile.tsv" label="Database input file(s), containing three tab-separated columns of mass, formula, identifie" help="(-mapping) If 'mass' is 0, it is re-computed from the molecular sum formula. By default CHEMISTRY/HMDBMappingFile.tsv in OpenMS/share is used! If empty, the default will be used">
<sanitizer>
<valid initial="string.printable">
<remove value="'"/>
<remove value="&quot;"/>
</valid>
</sanitizer>
</param>
<param name="param_db_struct" type="data" format="tsv" multiple="true" optional="False" size="30" value="CHEMISTRY/HMDB2StructMapping.tsv" label="Database input file(s), containing four tab-separated columns of identifier, name, SMILES, INCHI.The identifier should match with mapping file" help="(-struct) SMILES and INCHI are reported in the output, but not used otherwise. By default CHEMISTRY/HMDB2StructMapping.tsv in OpenMS/share is used! If empty, the default will be used">
<sanitizer>
<valid initial="string.printable">
<remove value="'"/>
<remove value="&quot;"/>
</valid>
</sanitizer>
</param>
<param name="param_algorithm_mass_error_value" type="float" value="5.0" label="Tolerance allowed for accurate mass search" help="(-mass_error_value) "/>
<param name="param_algorithm_mass_error_unit" display="radio" type="select" optional="False" value="ppm" label="Unit of mass error (ppm or Da)" help="(-mass_error_unit) ">
<option value="ppm" selected="true">ppm</option>
<option value="Da">Da</option>
</param>
<param name="param_algorithm_ionization_mode" display="radio" type="select" optional="False" value="positive" label="Positive or negative ionization mode?" help="(-ionization_mode) If 'auto' is used, the first feature of the input map must contain the meta-value 'scan_polarity'. If its missing, the tool will exit with error">
<option value="positive" selected="true">positive</option>
<option value="negative">negative</option>
<option value="auto">auto</option>
</param>
<param name="param_algorithm_isotopic_similarity" display="radio" type="boolean" truevalue="-algorithm:isotopic_similarity" falsevalue="" checked="false" optional="True" label="Computes a similarity score for each hit (only if the feature exhibits at least two isotopic mass traces)" help="(-isotopic_similarity) "/>
<param name="param_algorithm_keep_unidentified_masses" display="radio" type="boolean" truevalue="-algorithm:keep_unidentified_masses" falsevalue="" checked="false" optional="True" label="Keep features that did not yield any DB hit" help="(-keep_unidentified_masses) "/>
<param name="param_algorithm_mzTab_exportIsotopeIntensities" type="integer" min="0" optional="True" value="0" label="[featureXML input only] Number of extra columns in mzTab output, which provide intensities up to the x'th isotope" help="(-exportIsotopeIntensities) '0' to deactivate, '1' for monoisotopic peak, etc. If a feature does not have a certain isotope, 'null' will be reported"/>
<expand macro="advanced_options">
<param name="param_log" type="text" size="30" label="Name of log file (created only when specified)" help="(-log) ">
<sanitizer>
<valid initial="string.printable">
<remove value="'"/>
<remove value="&quot;"/>
</valid>
</sanitizer>
</param>
<param name="param_debug" type="integer" value="0" label="Sets the debug level" help="(-debug) "/>
<param name="param_no_progress" display="radio" type="boolean" truevalue="-no_progress" falsevalue="" checked="false" optional="True" label="Disables progress logging to command line" help="(-no_progress) "/>
<param name="param_force" display="radio" type="boolean" truevalue="-force" falsevalue="" checked="false" optional="True" label="Overwrite tool specific checks" help="(-force) "/>
<param name="param_test" display="radio" type="boolean" truevalue="-test" falsevalue="" checked="false" optional="True" label="Enables the test mode (needed for internal use only)" help="(-test) "/>
</expand>
</inputs>
<outputs>
<data name="param_out" format="mzTab"/>
<data name="param_out_annotation" label="${tool.name} on ${on_string}: annotation" format="featureXML,consensusXML"/>
</outputs>
<help>Match MS signals to molecules from a database by mass.


For more information, visit http://ftp.mi.fu-berlin.de/OpenMS/release-documentation/html/UTILS_AccurateMassSearch.html</help>
</tool>
12 changes: 12 additions & 0 deletions tests/test-data/empty.ctd
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
<?xml version="1.0" encoding="UTF-8"?>
<tool ctdVersion="1.7" version="2.3.0" name="echo StringTest" docurl="http://docs.are/unavailable.html" category="String Test" >
<description><![CDATA[String parameter tests]]></description>
<manual><![CDATA[String parameter tests.]]></manual>
<PARAMETERS version="1.6.2" xsi:noNamespaceSchemaLocation="http://open-ms.sourceforge.net/schemas/Param_1_6_2.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<NODE name="StringTest" description="String test.">
<ITEM name="version" value="2.3.0" type="string" description="Version of the tool that generated this parameters file." required="false" advanced="true" />
<NODE name="1" description="Instance &apos;1&apos; section for &apos;StringTest&apos;">
</NODE>
</NODE>
</PARAMETERS>
</tool>
25 changes: 25 additions & 0 deletions tests/test-data/empty.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
<?xml version='1.0' encoding='UTF-8'?>
<!--This is a configuration file for the integration of a tools into Galaxy (https://galaxyproject.org/). This file was automatically generated using CTDConverter.-->
<!--Proposed Tool Section: [String Test]-->
<tool id="echo StringTest" name="echo StringTest" version="2.3.0">
<description>String parameter tests</description>
<macros>
<token name="@EXECUTABLE@">echo StringTest</token>
<import>macros.xml</import>
</macros>
<expand macro="requirements"/>
<expand macro="stdio"/>
<expand macro="references"/>
<command>&lt;![CDATA[echo StringTest

&gt; $param_stdout
]]&gt;</command>
<inputs/>
<outputs>
<data name="param_stdout" format="txt" label="Output from stdout"/>
</outputs>
<help>&lt;![CDATA[String parameter tests.


For more information, visit http://docs.are/unavailable.html]]&gt;</help>
</tool>
Loading