Mercurial > repos > jorrit > obotools
comparison termenrichment.py @ 1:646b05282962
Uploaded
author | jorrit |
---|---|
date | Tue, 12 Feb 2013 13:46:10 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
0:4f8ea94020b1 | 1:646b05282962 |
---|---|
1 """ | |
2 Term enrichment datatypes | |
3 | |
4 """ | |
5 import pkg_resources | |
6 pkg_resources.require( "bx-python" ) | |
7 | |
8 import logging, os, sys, time, tempfile, shutil | |
9 import data | |
10 from galaxy import util | |
11 from galaxy.datatypes.sniff import * | |
12 from galaxy.web import url_for | |
13 from cgi import escape | |
14 import urllib | |
15 from bx.intervals.io import * | |
16 from galaxy.datatypes import metadata | |
17 from galaxy.datatypes.metadata import MetadataElement | |
18 from galaxy.datatypes.tabular import Tabular | |
19 import math | |
20 | |
21 log = logging.getLogger(__name__) | |
22 | |
23 class TermEnrichmentResult( data.Text ): | |
24 """Any term enrichment format""" | |
25 file_ext = "enrichment" | |
26 | |
27 def init_meta( self, dataset, copy_from=None ): | |
28 data.Text.init_meta( self, dataset, copy_from=copy_from ) | |
29 | |
30 | |
31 class TerfTab( TermEnrichmentResult ): | |
32 """TERF TSV Format""" | |
33 file_ext = "terf" | |
34 | |
35 def init_meta( self, dataset, copy_from=None ): | |
36 data.Text.init_meta( self, dataset, copy_from=copy_from ) | |
37 def sniff( self, filename ): | |
38 """ | |
39 Determines whether the file is in TERF format | |
40 """ | |
41 headers = get_headers( filename, '\n' ) | |
42 try: | |
43 for hdr in headers: | |
44 if hdr and hdr[0].startswith( '##terf-version' ) : | |
45 return True | |
46 return False | |
47 except: | |
48 return False | |
49 | |
50 | |
51 |