annotate galaxy.datatypes.mrh.py @ 8:0b5a01448cb5 draft

planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit 225579f0fe2a3a5fb846db38eca83020a945beb3
author sauria
date Fri, 13 Jan 2017 13:57:11 -0500
parents cb4f92e6fd4e
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
1 from galaxy import eggs
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
2
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
3 import pkg_resources
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
4 pkg_resources.require( "bx-python" )
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
5
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
6 import logging, os, sys, time, sets, tempfile, shutil
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
7 import data
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
8 from galaxy import util
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
9 from galaxy.datatypes.sniff import *
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
10 from cgi import escape
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
11 import urllib
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
12 from bx.intervals.io import *
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
13 from galaxy.datatypes import metadata
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
14 from galaxy.datatypes.metadata import MetadataElement
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
15 from galaxy.datatypes.binary import Binary
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
16
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
17
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
18 class Mrh( Binary ):
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
19 """Class describing a MRH file"""
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
20 file_ext = "mrh"
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
21
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
22 def sniff( self, filename ):
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
23 # MRH is a binary file type.
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
24 # The first 8 bytes of any mrh file is '42054205'.
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
25 try:
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
26 header = open( filename, 'rb' ).read(8)
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
27 if binascii.b2a_hex( header ) == binascii.hexlify( '42054205' ):
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
28 return True
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
29 return False
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
30 except:
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
31 return False
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
32
cb4f92e6fd4e planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
33 Binary.register_sniffable_binary_format("mrh", "mrh", Mrh)