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:
|
|
12 conn = sqlite.connect( filename )
|
|
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:
|
|
22 log.warning( '%s, sniff Exception: %s', self, e )
|
|
23 return False
|
9
|
24
|
28
|
25 class FlapjackMapFormat(Tabular):
|
4
|
26 file_ext = "fjmap"
|
|
27
|
|
28 def sniff( self, filename ):
|
|
29 h = open(filename)
|
|
30 line = h.readline()
|
|
31 if line.rstrip() != "# fjFile = MAP":
|
|
32 h.close()
|
|
33 return False
|
|
34 return True
|
|
35
|
28
|
36 class FlapjackGenotypeFormat(Tabular):
|
4
|
37 file_ext = "fjgenotype"
|
|
38
|
|
39 def sniff( self, filename ):
|
|
40 h = open(filename)
|
|
41 line = h.readline()
|
|
42 if line.rstrip() != "# fjFile = GENOTYPE":
|
|
43 h.close()
|
|
44 return False
|
|
45 return True
|
|
46
|
28
|
47 class FlapjackPhenotypeFormat(Tabular):
|
4
|
48 file_ext = "fjphenotye"
|
|
49
|
|
50 def sniff( self, filename ):
|
|
51 h = open(filename)
|
|
52 line = h.readline()
|
|
53 if line.rstrip() != "# fjFile = PHENOTYPE":
|
|
54 h.close()
|
|
55 return False
|
|
56 return True
|
|
57
|
28
|
58 class FlapjackQtlFormat(Tabular):
|
4
|
59 file_ext = "fjqtl"
|
|
60
|
|
61 def sniff( self, filename ):
|
|
62 h = open(filename)
|
|
63 line = h.readline()
|
|
64 if line.rstrip() != "# fjFile = QTL":
|
|
65 h.close()
|
|
66 return False
|
|
67 return True
|
|
68
|
28
|
69 class FlapjackGraphFormat(Tabular):
|
4
|
70 file_ext = "fjgraph"
|
|
71
|
|
72 def sniff( self, filename ):
|
|
73 h = open(filename)
|
|
74 line = h.readline()
|
|
75 if line.rstrip() != "# fjFile = GRAPH":
|
|
76 h.close()
|
|
77 return False
|
|
78 return True |