# HG changeset patch
# User galaxyp
# Date 1610745059 0
# Node ID a475c1906e0b70bddcbfa28a1a7e7580a2483a1a
# Parent 84e4b5d4b7adfbddebf45f6b960a1c9a652de8a4
"planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tree/master/tools/pyteomics commit 58fe8232b7f4659b37e8725197d63e81efae0683"
diff -r 84e4b5d4b7ad -r a475c1906e0b mztab2tsv.xml
--- a/mztab2tsv.xml Fri Jan 15 15:58:54 2021 +0000
+++ b/mztab2tsv.xml Fri Jan 15 21:10:59 2021 +0000
@@ -60,13 +60,13 @@
diff -r 84e4b5d4b7ad -r a475c1906e0b mztab_reader.py
--- a/mztab_reader.py Fri Jan 15 15:58:54 2021 +0000
+++ b/mztab_reader.py Fri Jan 15 21:10:59 2021 +0000
@@ -9,43 +9,17 @@
def read_mztab(input_path, output_path):
"""
- Read mztab file
+ Read and process mztab file
"""
mztab = MzTab(input_path)
- if mztab.variant == 'P':
- return read_mztab_p(mztab, output_path)
- elif mztab.variant == 'M':
- return read_mztab_m(mztab, output_path)
-
-
-def read_mztab_p(mztab, output_path):
- """
- Processing mztab "P"
- """
mtd = pd.DataFrame.from_dict(mztab.metadata, orient='index')
mtd.to_csv(os.path.join(output_path, "mtd.tsv"), sep="\t")
- prt = mztab.protein_table
- prt.to_csv(os.path.join(output_path, "prt.tsv"), sep="\t")
- pep = mztab.peptide_table
- pep.to_csv(os.path.join(output_path, "pep.tsv"), sep="\t")
- psm = mztab.spectrum_match_table
- psm.to_csv(os.path.join(output_path, "psm.tsv"), sep="\t")
- sml = mztab.small_molecule_table
- sml.to_csv(os.path.join(output_path, "sml.tsv"), sep="\t")
-
-
-def read_mztab_m(mztab, output_path):
- """
- Processing mztab "M"
- """
- mtd = pd.DataFrame.from_dict(mztab.metadata, orient='index')
- mtd.to_csv(os.path.join(output_path, "mtd.tsv"), sep="\t")
- sml = mztab.small_molecule_table
- sml.to_csv(os.path.join(output_path, "sml.tsv"), sep="\t")
- smf = mztab.small_molecule_feature_table
- smf.to_csv(os.path.join(output_path, "smf.tsv"), sep="\t")
- sme = mztab.small_molecule_evidence_table
- sme.to_csv(os.path.join(output_path, "sme.tsv"), sep="\t")
+ for name, tab in mztab:
+ if not tab.empty:
+ tab.to_csv(os.path.join(output_path, f"{name.lower()}.tsv"), sep="\t")
+ else:
+ with open(os.path.join(output_path, f"{name.lower()}.tsv"), "w"):
+ pass
if __name__ == "__main__":