Repository 'oxli_datatypes'
hg clone https://toolshed.g2.bx.psu.edu/repos/crusoe/oxli_datatypes

Changeset 0:3641a7d3b7c4 (2015-07-07)
Commit message:
planemo upload commit d8e0950d53e504e02ee5db43c0804142b14d7fd2-dirty
added:
datatypes_conf.xml
oxli.py
b
diff -r 000000000000 -r 3641a7d3b7c4 datatypes_conf.xml
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/datatypes_conf.xml Tue Jul 07 12:27:08 2015 -0400
b
@@ -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>
b
diff -r 000000000000 -r 3641a7d3b7c4 oxli.py
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/oxli.py Tue Jul 07 12:27:08 2015 -0400
b
@@ -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)