32
|
1 from galaxy.datatypes.data import Text
|
31
|
2 from galaxy.datatypes.tabular import Tabular
|
35
|
3 from galaxy.datatypes.binary import SQlite
|
4
|
4
|
35
|
5 class FlapjackFormat(SQlite):
|
9
|
6 file_ext = "flapjack"
|
35
|
7
|
|
8 def sniff(self, filename):
|
|
9 if super(FlapjackFormat, self).sniff(filename):
|
|
10 fj_table_names = ["objects", "project"]
|
|
11 try:
|
36
|
12 conn = sqlite.connect(filename)
|
35
|
13 c = conn.cursor()
|
|
14 tables_query = "SELECT name FROM sqlite_master WHERE type='table' ORDER BY name"
|
|
15 result = c.execute(tables_query).fetchall()
|
|
16 result = [_[0] for _ in result]
|
|
17 for table_name in fj_table_names:
|
|
18 if table_name not in result:
|
|
19 return False
|
|
20 return True
|
|
21 except Exception as e:
|
36
|
22 log.warning('%s, sniff Exception: %s', self, e)
|
35
|
23 return False
|
38
|
24
|
|
25 Binary.register_sniffable_binary_format( "flapjack", "flapjack", FlapjackFormat)
|
9
|
26
|
28
|
27 class FlapjackMapFormat(Tabular):
|
4
|
28 file_ext = "fjmap"
|
|
29
|
|
30 def sniff( self, filename ):
|
|
31 h = open(filename)
|
|
32 line = h.readline()
|
|
33 if line.rstrip() != "# fjFile = MAP":
|
|
34 h.close()
|
|
35 return False
|
|
36 return True
|
|
37
|
28
|
38 class FlapjackGenotypeFormat(Tabular):
|
4
|
39 file_ext = "fjgenotype"
|
|
40
|
|
41 def sniff( self, filename ):
|
|
42 h = open(filename)
|
|
43 line = h.readline()
|
|
44 if line.rstrip() != "# fjFile = GENOTYPE":
|
|
45 h.close()
|
|
46 return False
|
|
47 return True
|
|
48
|
28
|
49 class FlapjackPhenotypeFormat(Tabular):
|
4
|
50 file_ext = "fjphenotye"
|
|
51
|
|
52 def sniff( self, filename ):
|
|
53 h = open(filename)
|
|
54 line = h.readline()
|
|
55 if line.rstrip() != "# fjFile = PHENOTYPE":
|
|
56 h.close()
|
|
57 return False
|
|
58 return True
|
|
59
|
28
|
60 class FlapjackQtlFormat(Tabular):
|
4
|
61 file_ext = "fjqtl"
|
|
62
|
|
63 def sniff( self, filename ):
|
|
64 h = open(filename)
|
|
65 line = h.readline()
|
|
66 if line.rstrip() != "# fjFile = QTL":
|
|
67 h.close()
|
|
68 return False
|
|
69 return True
|
|
70
|
28
|
71 class FlapjackGraphFormat(Tabular):
|
4
|
72 file_ext = "fjgraph"
|
|
73
|
|
74 def sniff( self, filename ):
|
|
75 h = open(filename)
|
|
76 line = h.readline()
|
|
77 if line.rstrip() != "# fjFile = GRAPH":
|
|
78 h.close()
|
|
79 return False
|
|
80 return True |