Mercurial > repos > jjohnson > mothur_toolsuite
changeset 12:2088a8d469c9 draft
Fix datatype defs - metagenomics.py
author | Jim Johnson <jj@umn.edu> |
---|---|
date | Fri, 30 Nov 2012 11:46:37 -0600 |
parents | 2ab2418616af |
children | 729e90f1e874 |
files | mothur/lib/galaxy/datatypes/metagenomics.py |
diffstat | 1 files changed, 5 insertions(+), 61 deletions(-) [+] |
line wrap: on
line diff
--- a/mothur/lib/galaxy/datatypes/metagenomics.py Fri Nov 30 10:51:36 2012 -0600 +++ b/mothur/lib/galaxy/datatypes/metagenomics.py Fri Nov 30 11:46:37 2012 -0600 @@ -6,11 +6,7 @@ import logging, os, os.path, sys, time, tempfile, shutil, string, glob, re import galaxy.model -from galaxy.datatypes import data from galaxy.datatypes.sniff import * -from galaxy.datatypes import metadata -from galaxy.datatypes import tabular -from galaxy.datatypes import sequence from galaxy.datatypes.metadata import MetadataElement from galaxy.datatypes.data import Text from galaxy.datatypes.tabular import Tabular @@ -21,10 +17,8 @@ pkg_resources.require("simplejson") import simplejson - log = logging.getLogger(__name__) - ## Mothur Classes class Otu( Text ): @@ -873,59 +867,9 @@ column_types.append('int') dataset.metadata.column_types = column_types dataset.metadata.comment_lines = 1 - while (line = fh.readline()) - data_lines += 1 - dataset.metadata.data_lines = data_lines - finally: - close(fh) - -class SampleMetadata(Tabular): - MetadataElement( name="groups", default=[], desc="Group Names", readonly=True, visible=True, no_value=[] ) - MetadataElement( name="", default=[], desc="Group Variables", readonly=True, visible=True, no_value=[] ) - file_ext = 'metadata' - - def __init__(self, **kwd): - """ - A table with first column being sample names and following columns are variables - # Example 1: - group dpw description - F003D000 0 "F003D000 description" - F003D002 2 "F003D002 description" - F003D004 4 "F003D004 description" - F003D006 6 "F003D006 description" - F003D008 8 "F003D008 description" - F003D142 142 "F003D142 description" - # Example 2: - group dpw temp - F003D000 0 30.2 - F003D008 8 32.7 - F003D142 142 31.4 - """ - Tabular.__init__( self, **kwd ) - - def set_meta( self, dataset, overwrite = True, skip = 1, max_data_lines = None, **kwd ): - try: - data_lines = 0; - fh = open( dataset.file_name ) - line = fh.readline() - if line: - line = line.strip() - fields = line.split() - if len(fields) > 0: - # check if the first row is column headings, not number values - for colname in colnames[1:]: - f = float(linePieces[1]) - - - dataset.metadata.columns = len( colnames ) - if len(colnames) > 2: - dataset.metadata.groups = colnames[2:] - column_types = ['str'] - for i in range(1,len(colnames)): - column_types.append('int') - dataset.metadata.column_types = column_types - dataset.metadata.comment_lines = 1 - while (line = fh.readline()) + while line: + line = fh.readline() + if not line: break data_lines += 1 dataset.metadata.data_lines = data_lines finally: @@ -1476,7 +1420,7 @@ MetadataElement( name="column_names", default=[], desc="Column Names", readonly=False, visible=True, no_value=[] ) file_ext = 'qiimeotutable' def init_meta( self, dataset, copy_from=None ): - tabular.Tabular.init_meta( self, dataset, copy_from=copy_from ) + Tabular.init_meta( self, dataset, copy_from=copy_from ) def set_meta( self, dataset, overwrite = True, skip = None, **kwd ): self.set_column_names(dataset) def set_column_names(self, dataset): @@ -1498,7 +1442,7 @@ """ file_ext = 'qiimedistmat' def init_meta( self, dataset, copy_from=None ): - tabular.Tabular.init_meta( self, dataset, copy_from=copy_from ) + Tabular.init_meta( self, dataset, copy_from=copy_from ) def set_meta( self, dataset, overwrite = True, skip = None, **kwd ): self.set_column_names(dataset) def set_column_names(self, dataset):