Skip to content
Draft
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
8 changes: 8 additions & 0 deletions tools/isa2w4m/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
.*.swp
planemo-venv
tool_test_output.*
dist
*-venv
tests/output
.python-version
.Rproj.user
11 changes: 11 additions & 0 deletions tools/isa2w4m/.travis.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
dist: bionic

notifications:
email:
recipients:
- [email protected]

script:
- make test
- make plint
- make ptest
108 changes: 108 additions & 0 deletions tools/isa2w4m/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
SCRIPT_NAME=isa2w4m.py
REPOS_NAME=isa2w4m
TOOL_XML=isa2w4m.xml
PYVER37=3.7.13
PYVER38=3.8.12
PYVER39=3.9.9
PYVER=$(PYVER38) $(PYVER39)
PYENV:=$(shell command -v pyenv)
ifeq (,$(PYENV))
PYTHON=python3 -s
else
PYTHON=$(PYENV) exec python3 -s
endif
VM = isa2w4m-archlinux
CONDA_DIR=$(HOME)/plnmconda
export TMPDIR=$(HOME)/plnmtmp
PLANEMO_DIR=$(HOME)/plnmws

all:

test: $(addprefix test,37 38 39)

testvm:
teston -rD -f Makefile -f isa2w4m.py -f isa2w4m.xml -f requirements.txt -f tests/test-isa2w4m -f test-data -c gnumake -c pyenv -c unzip -c git -t test39 archlinux/archlinux

pyver:
ifneq (,$(PYENV))
for ver in $(PYVER) ; do pyenv install -s $$ver ; done
pyenv local $(PYVER)
endif
echo "Using $$($(PYTHON) --version)."

define test_on_pyver
test$(1): export PYENV_VERSION=$$(PYVER$(1))
test$(1): pyver requirements.txt
$(PYTHON) -m venv test$(1)-venv
. test$(1)-venv/bin/activate && test "Python $$(PYENV_VERSION)" = "$$$$(python3 --version)"
. test$(1)-venv/bin/activate && python3 -s -m pip install --no-cache-dir --upgrade pip
. test$(1)-venv/bin/activate && python3 -s -m pip install --no-cache-dir -r requirements.txt
. test$(1)-venv/bin/activate && python3 -s -c 'import isatools'
. test$(1)-venv/bin/activate && tests/test-isa2w4m
endef

$(foreach ver,37 38 39,$(eval $(call test_on_pyver,$(ver))))

$(TMPDIR):
mkdir -p "$@"

# TODO Check for presence of ~/.local/lib/python* folders before running planemo.
define ptest_on_pyver
planemo$(1)-venv: export PYENV_VERSION=$$(PYVER$(1))
planemo$(1)-venv: pyver
$(PYTHON) -m venv $$@
. planemo$(1)-venv/bin/activate && test "Python $$(PYENV_VERSION)" = "$$$$(python3 --version)"

planemo$(1)-venv/bin/planemo: planemo$(1)-venv
. planemo$(1)-venv/bin/activate && python3 -s -m pip install planemo

plint$(1): planemo-venv/bin/planemo
. planemo$(1)-venv/bin/activate && planemo --directory $(PLANEMO_DIR)$(1) lint $(TOOL_XML)

ptest$(1): planemo$(1)-venv/bin/planemo $(TMPDIR)
. planemo$(1)-venv/bin/activate && planemo --directory $(PLANEMO_DIR)$(1) test --conda_prefix "$(CONDA_DIR)$(1)" --conda_dependency_resolution --galaxy_python_version $(subst 3,3.,$(1)) $(TOOL_XML)

pttsdiff$(1): dist/$(REPOS_NAME)/ planemo$(1)-venv/bin/planemo $(HOME)/.planemo.yml
@echo "Check difference with testtoolshed version."
. planemo$(1)-venv/bin/activate && cd $$< && planemo shed_diff --shed_target testtoolshed

pttsupdate$(1): dist/$(REPOS_NAME)/ planemo$(1)-venv/bin/planemo $(HOME)/.planemo.yml
@echo "Push new version to testtoolshed."
. planemo$(1)-venv/bin/activate && cd $$< && planemo shed_update --check_diff --skip_metadata --shed_target testtoolshed

ptsdiff$(1): dist/$(REPOS_NAME)/ planemo$(1)-venv/bin/planemo $(HOME)/.planemo.yml
@echo "Check difference with toolshed version."
. planemo$(1)-venv/bin/activate && cd $$< && planemo shed_diff --shed_target toolshed

ptsupdate$(1): dist/$(REPOS_NAME)/ planemo$(1)-venv/bin/planemo $(HOME)/.planemo.yml
@echo "Push new version to toolshed."
. planemo$(1)-venv/bin/activate && cd $$< && planemo shed_update --check_diff --skip_metadata --shed_target toolshed
endef

$(foreach ver,37 38 39,$(eval $(call ptest_on_pyver,$(ver))))

plint: plint39

ptest: ptest39

dist/$(REPOS_NAME)/:
mkdir -p $@
cp -Lr README.md $(SCRIPT_NAME) $(TOOL_XML) test-data $@

pttsdiff: pttsdiff39

ptsdiff: ptsdiff39

pttsupdate: pttsupdate39

ptsupdate: ptsupdate39

clean:
$(RM) -r *-venv $(HOME)/plnm*
$(RM) tool_test_output.*
$(RM) -r dist
$(RM) -r tests/output
$(RM) .python-version
$(RM) -r $(TMPDIR)

.PHONY: all clean test plint ptest ptesttoolshed_diff ptesttoolshed_update ptoolshed_diff ptoolshed_update
17 changes: 17 additions & 0 deletions tools/isa2w4m/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# ISA2W4M

[![Build Status](https://travis-ci.org/workflow4metabolomics/isa2w4m.svg?branch=master)](https://travis-ci.org/workflow4metabolomics/isa2w4m)

Convert an ISA study into the 3 TSV files format of W4M.

## Updates

### 1.1.2

* Changed double quotes in single quotes inside XML Command tag.

### 1.1.1

* Correct planemo test.
* Run tests in Travis-CI.

18 changes: 18 additions & 0 deletions tools/isa2w4m/isa2w4m.Rproj
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
Version: 1.0

RestoreWorkspace: Default
SaveWorkspace: Default
AlwaysSaveHistory: Default

EnableCodeIndexing: Yes
UseSpacesForTab: Yes
NumSpacesForTab: 2
Encoding: UTF-8

RnwWeave: Sweave
LaTeX: pdfLaTeX

AutoAppendNewline: Yes
StripTrailingWhitespace: Yes

BuildType: Makefile
8 changes: 8 additions & 0 deletions tools/isa2w4m/isa2w4m.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#!/usr/bin/env python3

from isatools.convert import isatab2w4m
import warnings

with warnings.catch_warnings():
warnings.simplefilter("ignore")
isatab2w4m.main()
141 changes: 141 additions & 0 deletions tools/isa2w4m/isa2w4m.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
<!-- vi: se fdm=marker : -->
<tool id="isa2w4m" name="ISA to W4M" version="1.1.3">

<description>Convert ISA data type into W4M format</description>

<requirements>
<requirement type="package" version="1.2.5">pandas</requirement>
<requirement type="package" version="0.12.2">isatools</requirement>
</requirements>

<!-- Command {{{1 -->

<command><![CDATA[
## @@@BEGIN_CHEETAH@@@

$__tool_directory__/isa2w4m.py
-i '$isa.extra_files_path'
-s '$w4m_sample_metadata'
-v '$w4m_variable_metadata'
-m '$w4m_data_matrix'

## Choose study to output
#if $study:
-n '$study'
#end if

## Choose assay to output
#if $assay:
-f '$assay'
#end if

## Filtering
#if $sample_na_filtering:
-S '$sample_na_filtering'
#end if
#if $variable_na_filtering:
-V '$variable_na_filtering'
#end if

## Redirect stderr to stdout otherwise Galaxy thinks the tool fails if
## it sees just one character on stderr.
2>&1

## @@@END_CHEETAH@@@
]]></command>

<!-- Inputs {{{1 -->

<inputs>
<param name="isa" label="ISA" type="data" format="isa-tab"/>
<param name="study" type="text" size="256" value="" help="Type here the name of the assay file you want to extract from the ISA archive. If unset, the first listed study will be used."/>
<param name="assay" type="text" size="256" value="" help="Type here the name of the study file you want to extract from the ISA archive. If unset, the first listed assay in the study will be used"/>
<param name="sample_na_filtering" type="text" label="Sample metadata columns NA filtering" help="The rows that contain NA value in the specified columns will be filtered out. Column names must be separated by commas."/>
<param name="variable_na_filtering" type="text" label="Variable metadata columns NA filtering" help="The rows that contain NA value in the specified columns will be filtered out. Column names must be separated by commas."/>
</inputs>

<!-- Outputs {{{1 -->

<outputs>
<data name="w4m_variable_metadata" label="${isa.name} W4M var" format="tabular"/>
<data name="w4m_sample_metadata" label="${isa.name} W4M samp" format="tabular"/>
<data name="w4m_data_matrix" label="${isa.name} W4M data" format="tabular"/>
</outputs>

<!-- Tests {{{1 -->
<tests>
<test>
<param name="isa" value="MTBLS30.zip" ftype="isa-tab"/>
<output name="w4m_variable_metadata" file="MTBLS30-w4m-variable-metadata.tsv"/>
<output name="w4m_sample_metadata" file="MTBLS30-w4m-sample-metadata.tsv"/>
<output name="w4m_data_matrix" file="MTBLS30-w4m-sample-variable-matrix.tsv"/>
</test>
<test>
<param name="isa" value="MTBLS174.zip" ftype="isa-tab"/>
<output name="w4m_variable_metadata" file="MTBLS174-w4m-variable-metadata.tsv"/>
<output name="w4m_sample_metadata" file="MTBLS174-w4m-sample-metadata.tsv"/>
<output name="w4m_data_matrix" file="MTBLS174-w4m-sample-variable-matrix.tsv"/>
</test>
</tests>

<!-- Help {{{1 -->
<help>
<!-- @@@BEGIN_RST@@@ -->

====================
ISA to W4M converter
====================

Converts an ISA-Tab dataset into W4M 3 files format.

------
Inputs
------

ISA dataset
===========

The ISA-Tab dataset to convert to W4M format.

Study to extract
================

The file name of the study to extract from the ISA dataset.

Assay to extract
================

The file name of the assay to extract from the ISA dataset chosen study.

Sample NA filtering
===================

This is a comma separated list of column names from the sample metadata dataset.
Rows containg NA values in one or more of the listed columns will be removed from the dataset.

Variable NA filtering
=====================

This is a comma separated list of column names from the variable metadata dataset.
Rows containg NA values in one or more of the listed columns will be removed from the dataset.

-------
Outputs
-------

The output is a set of 3 datasets:

- Samples metadata.
- Variables metadata.
- Samples x variables matrix.

<!-- @@@END_RST@@@ -->
</help>

<!-- Citations {{{1 -->
<citations>
<citation type="doi">10.1038/ng.1054</citation> <!-- ISA -->
<citation type="doi">10.1093/bioinformatics/btu813</citation> <!-- W4M -->
</citations>

</tool>
4 changes: 4 additions & 0 deletions tools/isa2w4m/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
markupsafe==2.0.1
toml>=0.9.4
isatools==0.12.2
planemo
Loading
Loading