view sparse.xml @ 19:c92a4d1252e1 draft

planemo upload for repository https://github.com/bgruening/galaxytools/tree/master/tools/sklearn commit d00173591e4a783a4c1cb2664e4bb192ab5414f7
author bgruening
date Fri, 17 Aug 2018 12:30:35 -0400
parents bf3a5f8a66a2
children f9a2fe161db4
line wrap: on
line source

<tool id="scipy_sparse" name="Sparse Matrix Functions" version="@VERSION@">
    <description>for manipulating 2-D Scipy sparse numeric data</description>
    <macros>
        <import>main_macros.xml</import>
    </macros>
    <expand macro="python_requirements"/>
    <expand macro="macro_stdio"/>
    <version_command>echo "@VERSION@"</version_command>
    <command>
        <![CDATA[
        python "$sparse_script" '$inputs'
        ]]>
    </command>
    <configfiles>
        <inputs name="inputs" />
        <configfile name="sparse_script">
            <![CDATA[
import sys
import json
import pandas
import numpy as np
from scipy import sparse
from scipy.io import mmread
from scipy.io import mmwrite

input_json_path = sys.argv[1]
with open(input_json_path, "r") as param_handler:
    params = json.load(param_handler)

sparse_iter = []
#for $i, $s in enumerate( $sparse_functions.sparse_inputs )
sparse_index=$i
sparse_path="${s.input.file_name}"
sparse_iter.append(mmread(sparse_path))
#end for

my_function = getattr(sparse, params["sparse_functions"]["selected_function"])
my_sparse = my_function(sparse_iter)
with open("$outfile", "w+") as out_handler:
    mmwrite(out_handler, my_sparse)
            ]]>
        </configfile>
    </configfiles>
    <inputs>
        <conditional name="sparse_functions">
            <param name="selected_function" type="select" label="Select a task:">
                <option value="vstack" selected="true">Stack sparse matrices vertically (vstack)</option>
                <option value="hstack">Stack sparse matrices horizontally (hstack)</option>
            </param>
            <when value="vstack">
                <expand macro="multiple_input" name="sparse_inputs"/>
            </when>
            <when value="hstack">
                <expand macro="multiple_input" name="sparse_inputs"/>
            </when>
        </conditional>
    </inputs>
    <outputs>
        <data format="txt" name="outfile"/>
    </outputs>
    <tests>
        <test>
            <param name="selected_function" value="vstack"/>
            <param name="sparse_inputs_0|input" value="csr_sparse1.mtx" ftype="txt"/>
            <param name="sparse_inputs_1|input" value="csr_sparse2.mtx" ftype="txt"/>
            <output name="outfile" file="csr_stack_result01.mtx"/>
        </test>
        <test>
            <param name="selected_function" value="hstack"/>
            <param name="sparse_inputs_0|input" value="csc_sparse1.mtx" ftype="txt"/>
            <param name="sparse_inputs_1|input" value="csc_sparse2.mtx" ftype="txt"/>
            <output name="outfile" file="csc_stack_result01.mtx"/>
        </test>
    </tests>
    <help>
        <![CDATA[
**What it does**

This tool stacks sparse matrices horizontally (column wise) or vertically (row wise).
It can handle two different formats:

 * Compressed Sparse Column matrix (csc_matrix)

 * Compressed Sparse Row matrix (csr_matrix)

Sparse matrices in column format should be stacked horizontally (hstack) , while matrices in row format are stacked vertically (vstack). This tool outputs a single resulting sparse matrix which is compatible with the inputs in format.    

**Parameters:** blocks sequence of sparse matrices with compatible shapes format. 

For more information please refer to  DOI:10.1109/MCSE.2011.37.
        ]]>
    </help>
    <expand macro="scipy_citation"/>
</tool>