Mercurial > repos > jorrit > obo_datatypes
view ontology.py @ 0:b4db4eaf8fff draft default tip
Uploaded
author | jorrit |
---|---|
date | Tue, 12 Feb 2013 14:41:25 -0500 |
parents | |
children |
line wrap: on
line source
""" Ontology datatypes """ import pkg_resources pkg_resources.require( "bx-python" ) import logging, os, sys, time, tempfile, shutil import data from galaxy import util from galaxy.datatypes.sniff import * from galaxy.web import url_for from cgi import escape import urllib from bx.intervals.io import * from galaxy.datatypes import metadata from galaxy.datatypes.metadata import MetadataElement from galaxy.datatypes.tabular import Tabular import math log = logging.getLogger(__name__) class Ontology( data.Text ): """Any ontology Format""" file_ext = "ontology" def init_meta( self, dataset, copy_from=None ): data.Text.init_meta( self, dataset, copy_from=copy_from ) class Obo( Ontology ): """OBO Format""" file_ext = "obo" def init_meta( self, dataset, copy_from=None ): data.Text.init_meta( self, dataset, copy_from=copy_from ) def sniff( self, filename ): """ Determines whether the file is in OBO format """ headers = get_headers( filename, '\n' ) try: for hdr in headers: if hdr and hdr[0].startswith( 'format-version:' ) : return True return False except: return False class Owl( Ontology ): """OWL""" file_ext = "owl" def init_meta( self, dataset, copy_from=None ): data.Text.init_meta( self, dataset, copy_from=copy_from ) def sniff( self, filename ): """ Determines whether the file is in OWL RDF-XML format """ headers = get_headers( filename, '\n' ) try: for hdr in headers: if hdr and hdr[0].find( '<owl' ) > -1 : return True if hdr and hdr[0].find( 'http://www.w3.org/2002/07/owl' ) > -1 : return True return False except: return False class OwlRdfXML( Owl ): """OWL RDF/XML""" def init_meta( self, dataset, copy_from=None ): data.Text.init_meta( self, dataset, copy_from=copy_from ) def sniff( self, filename ): """ Determines whether the file is in OWL RDF-XML format """ headers = get_headers( filename, '\n' ) try: for hdr in headers: if hdr and hdr[0].find( '<owl:Ontology' ) > -1 : return True return False except: return False