4 new commits in galaxy-central: https://bitbucket.org/galaxy/galaxy-central/commits/0be206ac31c2/ Changeset: 0be206ac31c2 Branch: obo-owl-datatype User: BjoernGruening Date: 2014-10-27 15:13:14+00:00 Summary: Add OWL & OBO datatype. Affected #: 3 files diff -r 32929a1f9bf4b2150f99655c266223cd05d9a2bd -r 0be206ac31c2005f009e37af9d665cc9b4b955db config/datatypes_conf.xml.sample --- a/config/datatypes_conf.xml.sample +++ b/config/datatypes_conf.xml.sample @@ -160,6 +160,8 @@ <converter file="interval_to_bgzip_converter.xml" target_datatype="bgzip"/><converter file="interval_to_tabix_converter.xml" target_datatype="tabix" depends_on="bgzip"/></datatype> + <datatype extension="obo" type="galaxy.datatypes.text:Obo" mimetype="text/html" display_in_upload="True" /> + <datatype extension="owl" type="galaxy.datatypes.xml:Owl" mimetype="text/html" display_in_upload="True" /><datatype extension="png" type="galaxy.datatypes.images:Png" mimetype="image/png"/><datatype extension="qual" type="galaxy.datatypes.qualityscore:QualityScore" /><datatype extension="qualsolexa" type="galaxy.datatypes.qualityscore:QualityScoreSolexa" display_in_upload="true"/> @@ -272,6 +274,7 @@ <sniffer type="galaxy.datatypes.binary:Bam"/><sniffer type="galaxy.datatypes.binary:Sff"/><sniffer type="galaxy.datatypes.xml:Phyloxml"/> + <sniffer type="galaxy.datatypes.xml:Owl"/><sniffer type="galaxy.datatypes.xml:GenericXml"/><sniffer type="galaxy.datatypes.sequence:Maf"/><sniffer type="galaxy.datatypes.sequence:Lav"/> @@ -294,6 +297,7 @@ <sniffer type="galaxy.datatypes.tabular:Sam"/><sniffer type="galaxy.datatypes.data:Newick"/><sniffer type="galaxy.datatypes.data:Nexus"/> + <sniffer type="galaxy.datatypes.text:Obo"/><sniffer type="galaxy.datatypes.text:Ipynb"/><sniffer type="galaxy.datatypes.text:Json"/><sniffer type="galaxy.datatypes.images:Jpg"/> diff -r 32929a1f9bf4b2150f99655c266223cd05d9a2bd -r 0be206ac31c2005f009e37af9d665cc9b4b955db lib/galaxy/datatypes/text.py --- a/lib/galaxy/datatypes/text.py +++ b/lib/galaxy/datatypes/text.py @@ -12,6 +12,7 @@ import subprocess import json import os +import re import logging log = logging.getLogger(__name__) @@ -119,3 +120,45 @@ Set the number of models in dataset. """ pass + + +class Obo( Text ): + """ + OBO file format description + http://www.geneontology.org/GO.format.obo-1_2.shtml + """ + file_ext = "obo" + + def set_peek( self, dataset, is_multi_byte=False ): + if not dataset.dataset.purged: + dataset.peek = get_file_peek( dataset.file_name, is_multi_byte=is_multi_byte ) + dataset.blurb = "Open Biomedical Ontology (OBO)" + else: + dataset.peek = 'file does not exist' + dataset.blurb = 'file purged from disc' + + def sniff( self, filename ): + """ + Try to load the string with the json module. If successful it's a json file. + """ + stanza = re.compile(r'^\[.*\]$') + with open( filename ) as handle: + first_line = handle.readline() + if not first_line.startswith('format-version:'): + return False + + for line in handle: + if stanza.match(line.strip()): + # a stanza needs to begin with an ID tag + if handle.next().startswith('id:'): + return True + return False + + + + def set_meta( self, dataset, **kwd ): + """ + Set metadata for OBO files. + """ + pass + diff -r 32929a1f9bf4b2150f99655c266223cd05d9a2bd -r 0be206ac31c2005f009e37af9d665cc9b4b955db lib/galaxy/datatypes/xml.py --- a/lib/galaxy/datatypes/xml.py +++ b/lib/galaxy/datatypes/xml.py @@ -1,6 +1,7 @@ """ XML format classes """ +import re import data import logging from galaxy.datatypes.sniff import * @@ -116,3 +117,39 @@ """ return [ 'phyloviz' ] + + +class Owl( GenericXml ): + """ + Web Ontology Language OWL format description + http://www.w3.org/TR/owl-ref/ + """ + file_ext = "owl" + + def set_peek( self, dataset, is_multi_byte=False ): + if not dataset.dataset.purged: + dataset.peek = data.get_file_peek( dataset.file_name, is_multi_byte=is_multi_byte ) + dataset.blurb = "Web Ontology Language OWL" + else: + dataset.peek = 'file does not exist' + dataset.blurb = 'file purged from disc' + + def sniff( self, filename ): + """ + Try to load the string with the json module. If successful it's a json file. + """ + owl_marker = re.compile(r'\<owl:') + with open( filename ) as handle: + # Check first 200 lines for the string "<owl:" + first_lines = handle.readlines(200) + for line in first_lines: + if owl_marker.search( line ): + return True + return False + + def set_meta( self, dataset, **kwd ): + """ + Set metadata for OBO files. + """ + pass + https://bitbucket.org/galaxy/galaxy-central/commits/58b8aa9edad1/ Changeset: 58b8aa9edad1 Branch: obo-owl-datatype User: BjoernGruening Date: 2014-11-04 10:01:52+00:00 Summary: Remove set_meta() function. It's not used. Affected #: 1 file diff -r 0be206ac31c2005f009e37af9d665cc9b4b955db -r 58b8aa9edad12df296cde8a18b8d33c904e2e059 lib/galaxy/datatypes/text.py --- a/lib/galaxy/datatypes/text.py +++ b/lib/galaxy/datatypes/text.py @@ -154,11 +154,3 @@ return True return False - - - def set_meta( self, dataset, **kwd ): - """ - Set metadata for OBO files. - """ - pass - https://bitbucket.org/galaxy/galaxy-central/commits/b581932bb2ea/ Changeset: b581932bb2ea Branch: obo-owl-datatype User: BjoernGruening Date: 2014-11-04 11:01:42+00:00 Summary: Remove set_meta() function. It's not used. Affected #: 1 file diff -r 58b8aa9edad12df296cde8a18b8d33c904e2e059 -r b581932bb2ea861c50efce69fde9e508d937d739 lib/galaxy/datatypes/xml.py --- a/lib/galaxy/datatypes/xml.py +++ b/lib/galaxy/datatypes/xml.py @@ -146,10 +146,3 @@ if owl_marker.search( line ): return True return False - - def set_meta( self, dataset, **kwd ): - """ - Set metadata for OBO files. - """ - pass - https://bitbucket.org/galaxy/galaxy-central/commits/25f0318f232f/ Changeset: 25f0318f232f User: dannon Date: 2014-11-10 16:14:49+00:00 Summary: Merged in BjoernGruening/galaxy-central-1/obo-owl-datatype (pull request #542) Add OWL & OBO datatype. Affected #: 3 files diff -r a3ebaac5d31258a02bc7f037721f898c2c1e80e3 -r 25f0318f232ff783972c1e3e26fa853c0b9f085b config/datatypes_conf.xml.sample --- a/config/datatypes_conf.xml.sample +++ b/config/datatypes_conf.xml.sample @@ -160,6 +160,8 @@ <converter file="interval_to_bgzip_converter.xml" target_datatype="bgzip"/><converter file="interval_to_tabix_converter.xml" target_datatype="tabix" depends_on="bgzip"/></datatype> + <datatype extension="obo" type="galaxy.datatypes.text:Obo" mimetype="text/html" display_in_upload="True" /> + <datatype extension="owl" type="galaxy.datatypes.xml:Owl" mimetype="text/html" display_in_upload="True" /><datatype extension="png" type="galaxy.datatypes.images:Png" mimetype="image/png"/><datatype extension="qual" type="galaxy.datatypes.qualityscore:QualityScore" /><datatype extension="qualsolexa" type="galaxy.datatypes.qualityscore:QualityScoreSolexa" display_in_upload="true"/> @@ -272,6 +274,7 @@ <sniffer type="galaxy.datatypes.binary:Bam"/><sniffer type="galaxy.datatypes.binary:Sff"/><sniffer type="galaxy.datatypes.xml:Phyloxml"/> + <sniffer type="galaxy.datatypes.xml:Owl"/><sniffer type="galaxy.datatypes.xml:GenericXml"/><sniffer type="galaxy.datatypes.sequence:Maf"/><sniffer type="galaxy.datatypes.sequence:Lav"/> @@ -294,6 +297,7 @@ <sniffer type="galaxy.datatypes.tabular:Sam"/><sniffer type="galaxy.datatypes.data:Newick"/><sniffer type="galaxy.datatypes.data:Nexus"/> + <sniffer type="galaxy.datatypes.text:Obo"/><sniffer type="galaxy.datatypes.text:Ipynb"/><sniffer type="galaxy.datatypes.text:Json"/><sniffer type="galaxy.datatypes.images:Jpg"/> diff -r a3ebaac5d31258a02bc7f037721f898c2c1e80e3 -r 25f0318f232ff783972c1e3e26fa853c0b9f085b lib/galaxy/datatypes/text.py --- a/lib/galaxy/datatypes/text.py +++ b/lib/galaxy/datatypes/text.py @@ -12,6 +12,7 @@ import subprocess import json import os +import re import logging log = logging.getLogger(__name__) @@ -119,3 +120,37 @@ Set the number of models in dataset. """ pass + + +class Obo( Text ): + """ + OBO file format description + http://www.geneontology.org/GO.format.obo-1_2.shtml + """ + file_ext = "obo" + + def set_peek( self, dataset, is_multi_byte=False ): + if not dataset.dataset.purged: + dataset.peek = get_file_peek( dataset.file_name, is_multi_byte=is_multi_byte ) + dataset.blurb = "Open Biomedical Ontology (OBO)" + else: + dataset.peek = 'file does not exist' + dataset.blurb = 'file purged from disc' + + def sniff( self, filename ): + """ + Try to load the string with the json module. If successful it's a json file. + """ + stanza = re.compile(r'^\[.*\]$') + with open( filename ) as handle: + first_line = handle.readline() + if not first_line.startswith('format-version:'): + return False + + for line in handle: + if stanza.match(line.strip()): + # a stanza needs to begin with an ID tag + if handle.next().startswith('id:'): + return True + return False + diff -r a3ebaac5d31258a02bc7f037721f898c2c1e80e3 -r 25f0318f232ff783972c1e3e26fa853c0b9f085b lib/galaxy/datatypes/xml.py --- a/lib/galaxy/datatypes/xml.py +++ b/lib/galaxy/datatypes/xml.py @@ -1,6 +1,7 @@ """ XML format classes """ +import re import data import logging from galaxy.datatypes.sniff import * @@ -116,3 +117,32 @@ """ return [ 'phyloviz' ] + + +class Owl( GenericXml ): + """ + Web Ontology Language OWL format description + http://www.w3.org/TR/owl-ref/ + """ + file_ext = "owl" + + def set_peek( self, dataset, is_multi_byte=False ): + if not dataset.dataset.purged: + dataset.peek = data.get_file_peek( dataset.file_name, is_multi_byte=is_multi_byte ) + dataset.blurb = "Web Ontology Language OWL" + else: + dataset.peek = 'file does not exist' + dataset.blurb = 'file purged from disc' + + def sniff( self, filename ): + """ + Try to load the string with the json module. If successful it's a json file. + """ + owl_marker = re.compile(r'\<owl:') + with open( filename ) as handle: + # Check first 200 lines for the string "<owl:" + first_lines = handle.readlines(200) + for line in first_lines: + if owl_marker.search( line ): + return True + return False Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.