From adfb623224810a0f383dc4ddf88be4ce51d3aa71 Mon Sep 17 00:00:00 2001 From: mvdbeek Date: Fri, 24 Nov 2017 20:52:47 +0100 Subject: [PATCH] Fix metadata setting for Otu datatypes I broke this in https://github.com/galaxyproject/galaxy/pull/4388. I went through the other changes in that PR, and I believe this should be the only error. Figured out through the great detective work of @abernard. --- lib/galaxy/datatypes/mothur.py | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/lib/galaxy/datatypes/mothur.py b/lib/galaxy/datatypes/mothur.py index d1e016a729c..292c296eed5 100644 --- a/lib/galaxy/datatypes/mothur.py +++ b/lib/galaxy/datatypes/mothur.py @@ -26,6 +26,24 @@ class Otu(Text): super(Otu, self).__init__(**kwd) def set_meta(self, dataset, overwrite=True, **kwd): + """ + Set metadata for Otu files. + + >>> from galaxy.datatypes.sniff import get_test_fname + >>> from galaxy.util.bunch import Bunch + >>> dataset = Bunch() + >>> dataset.metadata = Bunch + >>> otu = Otu() + >>> dataset.file_name = get_test_fname( 'mothur_datatypetest_true.mothur.otu' ) + >>> dataset.has_data = lambda: True + >>> otu.set_meta(dataset) + >>> dataset.metadata.columns + 100 + >>> len(dataset.metadata.labels) == 37 + True + >>> len(dataset.metadata.otulabels) == 98 + True + """ super(Otu, self).set_meta(dataset, overwrite=overwrite, **kwd) if dataset.has_data(): @@ -37,6 +55,8 @@ class Otu(Text): headers = iter_headers(dataset.file_name, sep='\t', count=-1) first_line = get_headers(dataset.file_name, sep='\t', count=1) + if first_line: + first_line = first_line[0] # set otulabels if len(first_line) > 2: otulabel_names = first_line[2:]