changeset 0:08a714ff4ea5 draft default tip

planemo upload commit d8e0950d53e504e02ee5db43c0804142b14d7fd2-dirty
author crusoe
date Tue, 07 Jul 2015 11:58:46 -0400
parents
children
files datatypes_conf.xml oxli.py
diffstat 2 files changed, 67 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/datatypes_conf.xml	Tue Jul 07 11:58:46 2015 -0400
@@ -0,0 +1,16 @@
+<?xml version="1.0"?>
+<datatypes>
+    <datatype_files>
+        <datatype_file name="oxli.py"/>
+    </datatype_files>
+  <registration>
+	  <datatype extension="ct" type="galaxy.datatypes.oxli:Count"
+		  mimetype="application/octet-stream" display_in_upload="true"/>
+	  <datatype extension="pt" type="galaxy.datatypes.oxli:Presence"
+		  mimetype="application/octet-stream" display_in_upload="true"/>
+  </registration>
+  <sniffers>
+    <sniffer type="galaxy.datatypes.oxli:Count"/>
+    <sniffer type="galaxy.datatypes.oxli:Presence"/>
+  </sniffers>
+</datatypes>
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/oxli.py	Tue Jul 07 11:58:46 2015 -0400
@@ -0,0 +1,51 @@
+"""
+k-mer count and presence
+"""
+
+from galaxy.datatypes.binary import Binary
+import binascii
+
+import logging
+
+log = logging.getLogger(__name__)
+
+
+class OxliBinary(Binary):
+
+    def __init__(self, **kwd):
+        Binary.__init__(self, **kwd)
+
+    def sniff(self, filename, filetype):
+        try:
+            with open(filename) as fileobj:
+                header = fileobj.read(4)
+                if binascii.b2a_hex(header) == binascii.hexlify('OXLI'):
+                    fileobj.seek(1)
+                    ftype = fileobj.read(1)
+                    if binascii.b2a_hex(ftype) == filetype:
+                        return True
+            return False
+        except IOError:
+            return False
+
+
+class Count(OxliBinary):
+
+    def __init__(self, **kwd):
+        OxliBinary.__init__(self, **kwd)
+
+    def sniff(self, filename):
+        return OxliBinary.sniff(self, filename, "01")
+
+
+class Presence(OxliBinary):
+
+    def __init__(self, **kwd):
+        OxliBinary.__init__(self, **kwd)
+
+    def sniff(self, filename):
+        return OxliBinary.sniff(self, filename, "02")
+
+
+Binary.register_sniffable_binary_format("ct", "ct", Count)
+Binary.register_sniffable_binary_format("pt", "pt", Presence)