Mercurial > repos > jjohnson > mothur_toolsuite
diff mothur/lib/galaxy/datatypes/metagenomics.py @ 26:5c77423823cb
Updates for Mothur version 1.25.0 (includes changes to datatypes metagenomics.py and uses more efficient means for labels and groups options)
author | Jim Johnson <jj@umn.edu> |
---|---|
date | Wed, 16 May 2012 13:12:05 -0500 |
parents | bfbaf823be4c |
children | 49058b1f8d3f |
line wrap: on
line diff
--- a/mothur/lib/galaxy/datatypes/metagenomics.py Wed May 16 12:28:44 2012 -0500 +++ b/mothur/lib/galaxy/datatypes/metagenomics.py Wed May 16 13:12:05 2012 -0500 @@ -17,6 +17,9 @@ from galaxy.datatypes.sequence import Fasta from galaxy import util from galaxy.datatypes.images import Html +import pkg_resources +pkg_resources.require("simplejson") +import simplejson log = logging.getLogger(__name__) @@ -1260,6 +1263,56 @@ return False +## Biom + +class BiologicalObservationMatrix( Text ): + file_ext = 'biom' + """ + http://biom-format.org/documentation/biom_format.html + The format of the file is JSON: + { + "id":null, + "format": "Biological Observation Matrix 0.9.1-dev", + "format_url": "http://biom-format.org", + "type": "OTU table", + "generated_by": "QIIME revision 1.4.0-dev", + "date": "2011-12-19T19:00:00", + "rows":[ + {"id":"GG_OTU_1", "metadata":null}, + {"id":"GG_OTU_2", "metadata":null}, + {"id":"GG_OTU_3", "metadata":null}, + ], + "columns": [ + {"id":"Sample1", "metadata":null}, + {"id":"Sample2", "metadata":null} + ], + "matrix_type": "sparse", + "matrix_element_type": "int", + "shape": [3, 2], + "data":[[0,1,1], + [1,0,5], + [2,1,4] + ] + } + + """ + + def __init__(self, **kwd): + Text.__init__( self, **kwd ) + + def sniff( self, filename ): + if os.path.getsize(filename) < 50000: + try: + data = simplejson.load(open(filename)) + if data['format'].find('Biological Observation Matrix'): + return True + except: + pass + return False + + + + ## Qiime Classes class QiimeMetadataMapping(Tabular):