comparison 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
comparison
equal deleted inserted replaced
25:bfbaf823be4c 26:5c77423823cb
15 from galaxy.datatypes.data import Text 15 from galaxy.datatypes.data import Text
16 from galaxy.datatypes.tabular import Tabular 16 from galaxy.datatypes.tabular import Tabular
17 from galaxy.datatypes.sequence import Fasta 17 from galaxy.datatypes.sequence import Fasta
18 from galaxy import util 18 from galaxy import util
19 from galaxy.datatypes.images import Html 19 from galaxy.datatypes.images import Html
20 import pkg_resources
21 pkg_resources.require("simplejson")
22 import simplejson
20 23
21 24
22 log = logging.getLogger(__name__) 25 log = logging.getLogger(__name__)
23 26
24 27
1258 finally: 1261 finally:
1259 fh.close() 1262 fh.close()
1260 return False 1263 return False
1261 1264
1262 1265
1266 ## Biom
1267
1268 class BiologicalObservationMatrix( Text ):
1269 file_ext = 'biom'
1270 """
1271 http://biom-format.org/documentation/biom_format.html
1272 The format of the file is JSON:
1273 {
1274 "id":null,
1275 "format": "Biological Observation Matrix 0.9.1-dev",
1276 "format_url": "http://biom-format.org",
1277 "type": "OTU table",
1278 "generated_by": "QIIME revision 1.4.0-dev",
1279 "date": "2011-12-19T19:00:00",
1280 "rows":[
1281 {"id":"GG_OTU_1", "metadata":null},
1282 {"id":"GG_OTU_2", "metadata":null},
1283 {"id":"GG_OTU_3", "metadata":null},
1284 ],
1285 "columns": [
1286 {"id":"Sample1", "metadata":null},
1287 {"id":"Sample2", "metadata":null}
1288 ],
1289 "matrix_type": "sparse",
1290 "matrix_element_type": "int",
1291 "shape": [3, 2],
1292 "data":[[0,1,1],
1293 [1,0,5],
1294 [2,1,4]
1295 ]
1296 }
1297
1298 """
1299
1300 def __init__(self, **kwd):
1301 Text.__init__( self, **kwd )
1302
1303 def sniff( self, filename ):
1304 if os.path.getsize(filename) < 50000:
1305 try:
1306 data = simplejson.load(open(filename))
1307 if data['format'].find('Biological Observation Matrix'):
1308 return True
1309 except:
1310 pass
1311 return False
1312
1313
1314
1315
1263 ## Qiime Classes 1316 ## Qiime Classes
1264 1317
1265 class QiimeMetadataMapping(Tabular): 1318 class QiimeMetadataMapping(Tabular):
1266 MetadataElement( name="column_names", default=[], desc="Column Names", readonly=False, visible=True, no_value=[] ) 1319 MetadataElement( name="column_names", default=[], desc="Column Names", readonly=False, visible=True, no_value=[] )
1267 file_ext = 'qiimemapping' 1320 file_ext = 'qiimemapping'