Skip to content
Open
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
2 changes: 1 addition & 1 deletion tools/multiqc/macros.xml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<macros>
<token name="@TOOL_VERSION@">1.35</token>
<token name="@VERSION_SUFFIX@">1</token>
<token name="@VERSION_SUFFIX@">2</token>
<token name="@PROFILE@">25.0</token>
<xml name="bio_tools">
<xrefs>
Expand Down
8 changes: 8 additions & 0 deletions tools/multiqc/multiqc.xml
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
<import>image_content_plugin.xml</import>
<import>nanostat_plugin.xml</import>
<import>sequali_plugin.xml</import>
<import>sourmash_plugin.xml</import>
</macros>
<expand macro="bio_tools"/>
<expand macro="requirements"/>
Expand Down Expand Up @@ -221,6 +222,8 @@ mkdir multiqc_WDir &&
@NANOSTAT_COMMAND@
#elif str($repeat.software_cond.software) == "sequali"
@SEQUALI_COMMAND@
#elif str($repeat.software_cond.software) == "sourmash"
@SOURMASH_COMMAND@
#else if str($repeat.software_cond.software) == "custom_content":
#set file_paths = []
#if str($repeat.software_cond.input) != "None"
Expand Down Expand Up @@ -370,6 +373,7 @@ cp ./report_data/*plot*.txt ./plots/ | true ## don't fail if no plot files are g
<!--<option value="verifybamid">VerifyBAMID</option>-->
<option value="nanostat">NanoStat / NanoPlot</option>
<option value="sequali">Sequali</option>
<option value="sourmash">Sourmash</option>
<!--Custom-->
<option value="custom_content">Custom Content</option>
</param>
Expand Down Expand Up @@ -535,6 +539,9 @@ cp ./report_data/*plot*.txt ./plots/ | true ## don't fail if no plot files are g
<when value="sequali">
<expand macro="sequali_form"/>
</when>
<when value="sourmash">
<expand macro="sourmash_form"/>
</when>
<when value="custom_content">
<param argument="plot_type" label="The plot type to visualise the data with" type="select">
<option value="linegraph">linegraph</option>
Expand Down Expand Up @@ -641,6 +648,7 @@ cp ./report_data/*plot*.txt ./plots/ | true ## don't fail if no plot files are g
<expand macro="sexdeterrmine_test"/>
<expand macro="nanostat_test"/>
<expand macro="sequali_test"/>
<expand macro="sourmash_test"/>
<!--expand macro="vcftools_test"/> Does not work, did it ever worked? -->

</tests>
Expand Down
80 changes: 80 additions & 0 deletions tools/multiqc/sourmash_plugin.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,80 @@
<macros>
<token name="@SOURMASH_COMMAND@"><![CDATA[
#for $j, $repeat2 in enumerate( $repeat.software_cond.output )
#if str($repeat2.type.type_selector) == "compare"
## The MultiQC sourmash module (search pattern "*.labels.txt") finds the
## labels file, then loads the matrix from the same path minus ".labels.txt".
## So the matrix and its labels MUST share a basename in the same directory:
## <base> <- numpy matrix from `sourmash compare -o <base>`
## <base>.labels.txt <- the accompanying labels
#set $base = os.path.join($software_dir, 'compare_' + str($i) + '_' + str($j))
#set $at_least_one_input = "T"
ln -s '$repeat2.type.matrix' '$base' &&
ln -s '$repeat2.type.labels' '${base}.labels.txt' &&
#elif str($repeat2.type.type_selector) == "gather"
#if str($repeat2.type.input) != "None"
#set $at_least_one_input = "T"
#for $k, $file in enumerate($repeat2.type.input)
#set $identifier = re.sub('[^\s\w\-]', '_', str($file.element_identifier))
ln -s '$file' '$software_dir/gather_${i}_${j}_${k}_${identifier}.csv' &&
#end for
#end if
#end if
#end for
]]></token>
<xml name="sourmash_form">
<repeat name="output" title="sourmash output" min="1">

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we have repeat here with min=1?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is one enough but wyou can provide 2 different one? What happens if you provide two gathers?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This <repeat name="output" min="1"> mirrors the established pattern used by the other MultiQC plugins in this tool (bismark, deeptools, fastqc, gatk, picard, rseqc, samtools, star, vcftools all use the identical <repeat name="output" ... min="1">). min="1" just requires that a sourmash result block contributes at least one output — otherwise nothing would be staged for that block.

The repeat is there precisely so you can provide more than one output and/or mix types: e.g. one compare plus one gather, or several gathers. Each repeat entry is uniquely indexed in the staged filename, so there are no collisions:

  • compare: compare_<i>_<j> + compare_<i>_<j>.labels.txt
  • gather: gather_<i>_<j>_<k>_<identifier>.csv

I verified two gather entries end-to-end: they stage as gather_0_0_0_*.csv and gather_0_1_0_*.csv, and MultiQC reports Found 2 gather results and renders both. So providing two gathers (or two compares, or any mix) works as expected.

Note also that within a single gather entry the input param already has multiple="true", so a user can either add multiple files to one entry or add multiple repeat entries — both are handled.

<conditional name="type">
<param name="type_selector" type="select" label="Type of sourmash output">
<option value="compare">compare (similarity matrix + labels)</option>
<option value="gather">gather (CSV)</option>
</param>
<when value="compare">
<param name="matrix" type="data" format="data" label="compare similarity matrix"
help="The numpy matrix written by 'sourmash compare -o NAME' (the binary file, not the --csv output)."/>
<param name="labels" type="data" format="txt" label="compare labels"
help="The matching 'NAME.labels.txt' written alongside the matrix by 'sourmash compare' / 'sourmash plot --labels'."/>
</when>
<when value="gather">
<param name="input" type="data" format="csv" multiple="true" label="Output of sourmash gather"
help="CSV produced by 'sourmash gather -o'. It must contain the columns 'f_match', 'f_unique_weighted', 'name' and 'query_name'." optional="true"/>
</when>
</conditional>
</repeat>
</xml>
<!-- add here your test files and tests, the more stringent the better -->
<xml name="sourmash_test">
<test expect_num_outputs="3">
<repeat name="results">
<conditional name="software_cond">
<param name="software" value="sourmash"/>
<repeat name="output">
<conditional name="type">
<param name="type_selector" value="compare"/>
<param name="matrix" value="sourmash_compare_matrix" ftype="data"/>
<param name="labels" value="sourmash_compare.labels.txt" ftype="txt"/>
</conditional>
</repeat>
<repeat name="output">
<conditional name="type">
<param name="type_selector" value="gather"/>
<param name="input" value="sourmash_gather.csv" ftype="csv"/>
</conditional>
</repeat>
</conditional>
</repeat>
<param name="title" value="Title of the report"/>
<param name="comment" value="Commment for the report"/>
<param name="flat" value="true"/>
<param name="export" value="true"/>
<output name="html_report">
<assert_contents>
<has_text text="Title of the report"/>
<has_text text="Commment for the report"/>
<has_text text="sourmash-compare-heatmap"/>
<has_text text="Sample similarity"/>
</assert_contents>
</output>
</test>
</xml>
</macros>
3 changes: 3 additions & 0 deletions tools/multiqc/test-data/sourmash_compare.labels.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
strainA
strainB
strainC
Binary file added tools/multiqc/test-data/sourmash_compare_matrix
Binary file not shown.
3 changes: 3 additions & 0 deletions tools/multiqc/test-data/sourmash_gather.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
intersect_bp,f_orig_query,f_match,f_unique_to_query,f_unique_weighted,average_abund,median_abund,std_abund,name,filename,md5,f_match_orig,unique_intersect_bp,gather_result_rank,remaining_bp,query_filename,query_name,query_md5,query_bp
442000,0.0890,0.0908,0.0890,0.0949,1.5,1.0,0.5,"CP001509.3 Escherichia coli str. K-12 substr. MG1655",db.sbt.zip,abc123,0.0908,442000,0,4525000,query.sig,sampleA,def456,4967000
210000,0.0423,0.0451,0.0423,0.0388,1.2,1.0,0.4,"NC_000913.3 Salmonella enterica",db.sbt.zip,ghi789,0.0451,210000,1,4315000,query.sig,sampleA,def456,4967000
Loading