0
|
1 """
|
|
2 PRIMS proteomics classes for types defined in datatypes_conf.xml
|
|
3 """
|
|
4 import logging
|
|
5 import re
|
|
6 from galaxy.datatypes.data import *
|
|
7 from galaxy.datatypes.xml import *
|
|
8 from galaxy.datatypes.sniff import *
|
|
9 from galaxy.datatypes.binary import *
|
|
10 from galaxy.datatypes.interval import *
|
|
11
|
|
12 log = logging.getLogger(__name__)
|
|
13
|
|
14
|
|
15 class ProteomicsXml(GenericXml):
|
|
16 """ An enhanced XML datatype used to reuse code across several
|
|
17 proteomic/mass-spec datatypes. (this part of the code is taken from protk proteomics datatypes package) """
|
|
18
|
|
19 def sniff(self, filename):
|
|
20 """ Determines whether the file is the correct XML type. """
|
|
21 with open(filename, 'r') as contents:
|
|
22 while True:
|
|
23 line = contents.readline()
|
|
24 if line == None or not line.startswith('<?'):
|
|
25 break
|
|
26 pattern = '^<(\w*:)?%s' % self.root # pattern match <root or <ns:root for any ns string
|
|
27 return line != None and re.match(pattern, line) != None
|
|
28
|
|
29 def set_peek( self, dataset, is_multi_byte=False ):
|
|
30 """Set the peek and blurb text"""
|
|
31 if not dataset.dataset.purged:
|
|
32 dataset.peek = data.get_file_peek( dataset.file_name, is_multi_byte=is_multi_byte )
|
|
33 dataset.blurb = self.blurb
|
|
34 else:
|
|
35 dataset.peek = 'file does not exist'
|
|
36 dataset.blurb = 'file purged from disk'
|
|
37
|
|
38 class Apml( ProteomicsXml ):
|
|
39 """APML data"""
|
|
40 file_ext = "apml"
|
|
41 blurb = 'PRIMS APML proteomics data'
|
|
42 root = "apml" |