Skip to content

Commit

Permalink
Remove forward slash in m/z for txt outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
RJMW committed Feb 19, 2018
1 parent 24b3ff9 commit cde30e3
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 7 deletions.
2 changes: 1 addition & 1 deletion dimspy/models/peak_matrix.py
Original file line number Diff line number Diff line change
Expand Up @@ -757,7 +757,7 @@ def to_str(self, attr_name='intensity', delimiter='\t', samples_in_rows=True, co
self.remove_empty_peaks()

mz = self.attr_matrix('mz', flagged_only = not comprehensive)
hd = ['m/z'] + map(str, np.average(mz, axis = 0, weights = mz.astype(bool)))
hd = ['mz'] + map(str, np.average(mz, axis = 0, weights = mz.astype(bool)))
dm = [map(str, self.peaklist_ids)] + \
[map(str, ln) for ln in self.attr_matrix(attr_name, flagged_only = not comprehensive).T]

Expand Down
2 changes: 1 addition & 1 deletion tests/data/MTBLS79_subset/pm_mzml_triplicates.txt

Large diffs are not rendered by default.

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
m/z present occurrence purity rsd_QC rsd_all flags batch04_B02_rep01_301.mzML batch04_B02_rep02_302.mzML batch04_B02_rep03_303.mzML batch04_QC17_rep01_262.mzML batch04_QC17_rep02_263.mzML batch04_QC17_rep03_264.mzML batch04_S01_rep01_247.mzML batch04_S01_rep02_248.mzML batch04_S01_rep03_249.mzML
mz present occurrence purity rsd_QC rsd_all flags batch04_B02_rep01_301.mzML batch04_B02_rep02_302.mzML batch04_B02_rep03_303.mzML batch04_QC17_rep01_262.mzML batch04_QC17_rep02_263.mzML batch04_QC17_rep03_264.mzML batch04_S01_rep01_247.mzML batch04_S01_rep02_248.mzML batch04_S01_rep03_249.mzML
missing values 2548 2454 2474 2839 2832 2829 2865 2859 2884
tags_class_label blank blank blank QC QC QC sample sample sample
tags_untyped
Expand Down
6 changes: 3 additions & 3 deletions tests/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,14 +218,14 @@ def test_hdf5_peak_matrix_to_txt(self):
attr_name="intensity", rsd_tags=(), delimiter="\t", samples_in_rows=True, comprehensive=False)
with open(to_test_result("pm_mzml_triplicates.txt"), "rU") as test_result:
ln = test_result.readline().split("\t")[:5]
self.assertEqual(ln[0], "m/z")
self.assertEqual(ln[0], "mz")
self.assertTrue(np.allclose(map(float,ln[1:]), [74.0166655257, 74.0198337519, 74.0200238089, 74.0202012645], atol = 1e-10))

hdf5_peak_matrix_to_txt(to_test_data("MTBLS79_mzml_peak_matrix.hdf5"), to_test_result("pm_mzml_triplicates_comprehensive.txt"),
attr_name="intensity", rsd_tags=(Tag("QC", "classLabel"),), delimiter="\t", samples_in_rows=True, comprehensive=True)
with open(to_test_result("pm_mzml_triplicates_comprehensive.txt"), "rU") as test_result:
ln = test_result.readline().split("\t")[:8]
self.assertEquals(ln[:-2], ['m/z', 'missing values', 'tags_batch', 'tags_replicate', 'tags_injectionOrder', 'tags_classLabel'])
self.assertEquals(ln[:-2], ['mz', 'missing values', 'tags_batch', 'tags_replicate', 'tags_injectionOrder', 'tags_classLabel'])
self.assertTrue(np.isclose(float(ln[-1]), 74.0166655257))

hdf5_peak_matrix_to_txt(to_test_data("MTBLS79_mzml_peak_matrix.hdf5"), to_test_result("pm_mzml_triplicates_snr.txt"),
Expand All @@ -239,7 +239,7 @@ def test_hdf5_peak_matrix_to_txt(self):
attr_name="intensity", rsd_tags=(Tag("QC", "classLabel"),), delimiter="\t", samples_in_rows=False, comprehensive=True)
with open(to_test_result("pm_mzml_triplicates_comprehensive_T.txt"), "rU") as test_result:
self.assertEquals(test_result.readline().split("\t")[0:5],
['m/z', 'present', 'occurrence', 'purity', 'rsd_QC'])
['mz', 'present', 'occurrence', 'purity', 'rsd_QC'])


def test_create_sample_list(self):
Expand Down

0 comments on commit cde30e3

Please sign in to comment.