Mercurial > repos > sauria > hifive
annotate galaxy.datatypes.mrh.py @ 6:32cb153901b9 draft
planemo upload for repository https://github.com/bxlab/galaxy_tools/suites/suite_hifive commit 031f802858c1b8e03cdc3dac9fc79b96b21db181-dirty
author | sauria |
---|---|
date | Thu, 11 Feb 2016 11:01:50 -0500 |
parents | cb4f92e6fd4e |
children |
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) |