Mercurial > repos > crusoe > oxli_datatypes
view oxli.py @ 0:08a714ff4ea5 draft default tip
planemo upload commit d8e0950d53e504e02ee5db43c0804142b14d7fd2-dirty
author | crusoe |
---|---|
date | Tue, 07 Jul 2015 11:58:46 -0400 |
parents | |
children |
line wrap: on
line source
""" 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)