Skip to content

Commit

Permalink
fix import tests
Browse files Browse the repository at this point in the history
  • Loading branch information
pavanvidem committed Jan 16, 2025
1 parent 0eebc8f commit 5318430
Showing 1 changed file with 17 additions and 23 deletions.
40 changes: 17 additions & 23 deletions tools/muon/mudata_import_export.xml
Original file line number Diff line number Diff line change
Expand Up @@ -11,21 +11,21 @@
<configfiles>
<configfile name="script_file"><![CDATA[
@CMD_imports@
#if $method.method == 'import'
#if $operation.mode == 'import'
import anndata as ad
mdata = mu.MuData({
#for $modality in $method.modalities
#for $modality in $operation.modalities
'$modality.name': ad.read_h5ad('$modality.anndata'),
#end for
})
#if $make_unique
mdata.var_names_make_unique()
#end if
@CMD_mudata_write_outputs@
mdata.write_h5mu('mudata.h5mu')
#else if $method.method == 'export'
mdata = mu.read_h5mu('$method.mudata_in')
#else if $operation.mode == 'export'
mdata = mu.read_h5mu('$operation.mudata_in')
for mod in mdata.mod:
mdata[mod].write_h5ad(mod + '.h5ad')
Expand All @@ -34,8 +34,8 @@ for mod in mdata.mod:
]]></configfile>
</configfiles>
<inputs>
<conditional name="method">
<param name="method" type="select" label="Mode of operation">
<conditional name="operation">
<param name="mode" type="select" label="Mode of operation">
<option value="import" selected="true">Import multiple Anndata objects into a MuData object</option>
<option value="export">Export Anndata objects from a MuData objects</option>
</param>
Expand All @@ -58,22 +58,20 @@ for mod in mdata.mod:
<expand macro="inputs_common_advanced" />
</inputs>
<outputs>
<expand macro="muon_outputs">
<filter>method['method'] == 'import' </filter>
</expand>
<data name="mudata_out" format="h5ad" from_work_dir="mudata.h5mu" label="MuData object built from ${on_string}">
<filter>operation['mode'] == 'import' </filter>
</data>
<collection name="collection_anndata" type="list" label="Anndata objects extracted from ${on_string}">
<discover_datasets pattern="(?P&lt;designation&gt;.*).h5ad" format="h5ad"/>
<filter>method['method'] == 'export' </filter>
<filter>operation['mode'] == 'export' </filter>
</collection>
<expand macro="outputs_common_advanced">
<filter>method['method'] == 'export' </filter>
</expand>
<expand macro="outputs_common_advanced"/>
</outputs>
<tests>
<test expect_num_outputs="2">
<!--Import test for RNA and ATAC modalities-->
<conditional name="method">
<param name="method" value="import"/>
<conditional name="operation">
<param name="mode" value="import"/>
<repeat name="modalities">
<param name="name" value="RNA"/>
<param name="anndata" location="https://zenodo.org/records/12570984/files/rna.h5ad"/>
Expand All @@ -95,10 +93,6 @@ for mod in mdata.mod:
<has_text_matching expression="var_names_make_unique()"/>
</assert_contents>
</output>
<assert_stdout>
<has_text_matching expression="20 × 40"/>
<has_text_matching expression="20 x 20"/>
</assert_stdout>
<output name="mudata_out" ftype="h5ad">
<assert_contents>
<has_h5_keys keys="mod/RNA"/>
Expand All @@ -107,10 +101,10 @@ for mod in mdata.mod:
</assert_contents>
</output>
</test>
<test expect_num_outputs="3">
<test expect_num_outputs="2">
<!--Export test for RNA and ATAC modalities-->
<conditional name="method">
<param name="method" value="export"/>
<conditional name="operation">
<param name="mode" value="export"/>
<param name="mudata_in" location="https://zenodo.org/records/12570984/files/rna_atac.h5mu"/>
</conditional>
<section name="advanced_common">
Expand Down

0 comments on commit 5318430

Please sign in to comment.