Skip to content

Commit

Permalink
Merge pull request #504 from zargham-ahmad/issue439
Browse files Browse the repository at this point in the history
Change output csv types to tsv
  • Loading branch information
hechth authored Apr 16, 2024
2 parents 79e9939 + 8d0a3d3 commit 4b8a43b
Show file tree
Hide file tree
Showing 30 changed files with 464 additions and 411 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,7 +183,7 @@ jobs:
# This job runs on Linux
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
path: artifacts
- uses: actions/setup-python@v5
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -345,7 +345,7 @@ jobs:
matrix:
python-version: ['3.7']
steps:
- uses: actions/download-artifact@v3
- uses: actions/download-artifact@v4
with:
path: artifacts
- uses: actions/setup-python@v5
Expand Down
13 changes: 9 additions & 4 deletions tools/matchms/matchms_metadata_export.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tool id="matchms_metadata_export" name="matchms metadata export" version="@TOOL_VERSION@+galaxy1" profile="21.09">
<tool id="matchms_metadata_export" name="matchms metadata export" version="@TOOL_VERSION@+galaxy2" profile="21.09">
<description>extract all metadata from mass spectra file to tabular format</description>
<macros>
<import>macros.xml</import>
Expand All @@ -18,6 +18,7 @@
<configfiles>
<configfile name="matchms_python_cli">
import matchms
import pandas as pd
from matchms.importing import load_from_msp, load_from_mgf
from matchms.exporting.metadata_export import export_metadata_as_csv

Expand All @@ -28,6 +29,10 @@ if "$harmonize_metadata" == "False":
spectra_list = list(load_from_${input_file.ext}("${input_file}", $harmonize_metadata))

export_metadata_as_csv(spectra_list, "${output_file}")

data = pd.read_csv("${output_file}")

data.to_csv("${output_file}", sep='\t', index=False)
</configfile>
</configfiles>

Expand All @@ -38,19 +43,19 @@ export_metadata_as_csv(spectra_list, "${output_file}")
</inputs>

<outputs>
<data label="matchms extract metadata on ${on_string}" name="output_file" format="csv"/>
<data label="matchms extract metadata on ${on_string}" name="output_file" format="tsv"/>
</outputs>

<tests>
<test>
<param name="input_file" value="convert/mgf_out.mgf" ftype="mgf"/>
<param name="harmonize_metadata" value="True"/>
<output name="output_file" file="convert/metadata.csv" ftype="csv" compare="sim_size" delta="0"/>
<output name="output_file" file="convert/metadata.tsv" ftype="tsv" compare="sim_size" delta="0"/>
</test>
<test>
<param name="input_file" value="similarity/RECETOX_Exposome_pesticides_HR_MS_20220323.msp" ftype="msp"/>
<param name="harmonize_metadata" value="True"/>
<output name="output_file" file="convert/metadata.csv" ftype="csv" compare="sim_size" delta="0"/>
<output name="output_file" file="convert/metadata.tsv" ftype="tsv" compare="sim_size" delta="0"/>
</test>
</tests>

Expand Down
171 changes: 0 additions & 171 deletions tools/matchms/test-data/convert/metadata.csv

This file was deleted.

171 changes: 171 additions & 0 deletions tools/matchms/test-data/convert/metadata.tsv

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions tools/msmetaenhancer/msmetaenhancer.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tool id="msmetaenhancer" name="MSMetaEnhancer" version="@TOOL_VERSION@+galaxy3">
<tool id="msmetaenhancer" name="MSMetaEnhancer" version="@TOOL_VERSION@+galaxy4" profile="21.09">
<description>annotate MS data</description>

<macros>
Expand Down Expand Up @@ -84,7 +84,7 @@
<change_format>
<when input="input_file.ext" value="mgf" format="mgf" />
<when input="input_file.ext" value="json" format="json" />
<when input="input_file.ext" value="csv" format="csv" />
<when input="input_file.ext" value="csv" format="tsv" />
<when input="input_file.ext" value="tsv" format="tsv" />
<when input="input_file.ext" value="xlsx" format="xlsx" />
</change_format>
Expand Down
5 changes: 4 additions & 1 deletion tools/msmetaenhancer/msmetaenhancer_wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,10 @@ def main(argv):
if args.file_format == 'xlsx':
handle_xlsx_file(app, args.output_file)
else:
app.save_data(args.output_file, file_format=args.file_format)
if args.file_format == 'csv':
app.save_data(args.output_file, file_format="tsv")
else:
app.save_data(args.output_file, file_format=args.file_format)
return 0


Expand Down
10 changes: 5 additions & 5 deletions tools/ramclustr/ramclustr.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<tool id="ramclustr" name="RAMClustR" version="@TOOL_VERSION@+galaxy3" profile="21.09">
<tool id="ramclustr" name="RAMClustR" version="@TOOL_VERSION@+galaxy4" profile="21.09">
<description>A feature clustering algorithm for non-targeted mass spectrometric metabolomics data.</description>
<macros>
<import>macros.xml</import>
Expand Down Expand Up @@ -153,7 +153,7 @@
</inputs>

<outputs>
<data label="Spec Abundance of ${on_string}" name="spec_abundance" format="csv" />
<data label="Spec Abundance of ${on_string}" name="spec_abundance" format="tsv" />
<expand macro="output_msp"/>
</outputs>

Expand All @@ -175,7 +175,7 @@
<param name="ExpDes" value="lc-ramclustr-define-experiment.csv" ftype="csv"/>
</section>
<output name="mass_spectra_merged" file="test1_fill_xcms_1.msp" ftype="msp"/>
<output name="spec_abundance" file="test1_spec_abundance_xcms_1.csv" ftype="csv" compare="sim_size" delta="100"/>
<output name="spec_abundance" file="test1_spec_abundance_xcms_1.tsv" ftype="tsv" compare="sim_size" delta="100"/>
</test>
<test expect_num_outputs="2"><!-- TEST 2 -->
<section name="filetype">
Expand All @@ -196,7 +196,7 @@
</section>
</section>
<output name="mass_spectra_merged" file="test2_fill_xcms_2.msp" ftype="msp" compare="sim_size" delta="100"/>
<output name="spec_abundance" file="test2_spec_abundance_xcms_2.csv" ftype="csv" compare="sim_size" delta="100"/>
<output name="spec_abundance" file="test2_spec_abundance_xcms_2.tsv" ftype="tsv" compare="sim_size" delta="100"/>
</test>
<test expect_num_outputs="2"><!-- TEST 3 -->
<section name="filetype">
Expand All @@ -214,7 +214,7 @@
<param name="mult" value="1"/>
</section>
<output name="mass_spectra_merged" file="test3_spectra_csv_1.msp" ftype="msp"/>
<output name="spec_abundance" file="test3_spec_abundance_csv_1.csv" ftype="csv"/>
<output name="spec_abundance" file="test3_spec_abundance_csv_1.tsv" ftype="tsv"/>
</test>
<test expect_num_outputs="2"><!-- TEST 4 -->
<section name="filetype">
Expand Down
4 changes: 2 additions & 2 deletions tools/ramclustr/ramclustr_wrapper.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@ store_output <- function(ramclustr_obj,
output_spec_abundance,
msp_file) {
RAMClustR::write.msp(ramclustr_obj, one.file = output_merge_msp)
write.csv(ramclustr_obj$SpecAbund,
write.table(ramclustr_obj$SpecAbund,
file = output_spec_abundance,
row.names = TRUE, quote = FALSE
row.names = TRUE, quote = FALSE, col.names = NA, sep = "\t"
)

if (!is.null(msp_file)) {
Expand Down
Loading

0 comments on commit 4b8a43b

Please sign in to comment.