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