changeset 0:b4db4eaf8fff draft default tip

Uploaded
author jorrit
date Tue, 12 Feb 2013 14:41:25 -0500
parents
children
files annotation.py datatypes_conf.xml ontology.py termenrichment.py
diffstat 4 files changed, 199 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/annotation.py	Tue Feb 12 14:41:25 2013 -0500
@@ -0,0 +1,42 @@
+"""
+Annotation 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 Gaf( Tabular ):
+    """Tab delimited data in Gene Ontology Association File (GAF) format"""
+    file_ext = "gaf"
+
+    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 GAF format
+        """
+        headers = get_headers( filename, '\t' )
+        try:
+            for hdr in headers:
+                if hdr and hdr[0].startswith( '!gaf-version:' ) :
+                    return True
+            return False
+        except:
+            return False
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/datatypes_conf.xml	Tue Feb 12 14:41:25 2013 -0500
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<!-- see http://wiki.galaxyproject.org/ToolShedDatatypesFeatures for more info -->
+<datatypes>
+    <datatype_files>
+        <datatype_file name="annotation.py"/>
+        <datatype_file name="ontology.py"/>
+        <datatype_file name="termenrichment.py"/>
+    </datatype_files>
+    <registration> 
+        <datatype extension="ontology" type="galaxy.datatypes.ontology:Ontology" display_in_upload="true"/>
+        <datatype extension="obo" type="galaxy.datatypes.ontology:Obo" display_in_upload="true"/>
+        <datatype extension="owl" type="galaxy.datatypes.ontology:Owl" display_in_upload="true"/>
+        <datatype extension="gaf" type="galaxy.datatypes.annotation:Gaf" display_in_upload="true"/>
+        <datatype extension="terf" type="galaxy.datatypes.termenrichment:TerfTab" display_in_upload="true"/>
+    </registration>
+</datatypes>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ontology.py	Tue Feb 12 14:41:25 2013 -0500
@@ -0,0 +1,90 @@
+"""
+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
+
+
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/termenrichment.py	Tue Feb 12 14:41:25 2013 -0500
@@ -0,0 +1,51 @@
+"""
+Term enrichment 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 TermEnrichmentResult( data.Text ):
+    """Any term enrichment format"""
+    file_ext = "enrichment"
+
+    def init_meta( self, dataset, copy_from=None ):
+        data.Text.init_meta( self, dataset, copy_from=copy_from )
+
+
+class TerfTab( TermEnrichmentResult ):
+    """TERF TSV Format"""
+    file_ext = "terf"
+
+    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 TERF format
+        """
+        headers = get_headers( filename, '\n' )
+        try:
+            for hdr in headers:
+                if hdr and hdr[0].startswith( '##terf-version' ) :
+                    return True
+            return False
+        except:
+            return False
+
+
+