annotate galaxy.datatypes.mrh.py @ 10:c11b964e96b3 draft

planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
author sauria
date Wed, 26 Aug 2015 16:46:18 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
10
c11b964e96b3 planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
1 from galaxy import eggs
c11b964e96b3 planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
2
c11b964e96b3 planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
3 import pkg_resources
c11b964e96b3 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" )
c11b964e96b3 planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
5
c11b964e96b3 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
c11b964e96b3 planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
7 import data
c11b964e96b3 planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
8 from galaxy import util
c11b964e96b3 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 *
c11b964e96b3 planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
10 from cgi import escape
c11b964e96b3 planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
11 import urllib
c11b964e96b3 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 *
c11b964e96b3 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
c11b964e96b3 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
c11b964e96b3 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
c11b964e96b3 planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
16
c11b964e96b3 planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
17
c11b964e96b3 planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
18 class Mrh( Binary ):
c11b964e96b3 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"""
c11b964e96b3 planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
20 file_ext = "mrh"
c11b964e96b3 planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
21
c11b964e96b3 planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
22 def sniff( self, filename ):
c11b964e96b3 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.
c11b964e96b3 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'.
c11b964e96b3 planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
25 try:
c11b964e96b3 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)
c11b964e96b3 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' ):
c11b964e96b3 planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
28 return True
c11b964e96b3 planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
29 return False
c11b964e96b3 planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
30 except:
c11b964e96b3 planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
31 return False
c11b964e96b3 planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit ded5555ebf85f4807cbe4f1bf1945a757bdc724d
sauria
parents:
diff changeset
32
c11b964e96b3 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)