comparison mira.py @ 85:59500bcfaf82 draft default tip

planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/datatypes/mira_datatypes commit f7e6686f564972fb2892bec8da890565bb41e0ac-dirty
author peterjc
date Mon, 01 Jul 2019 14:02:09 -0400
parents 8d7684a3346a
children
comparison
equal deleted inserted replaced
84:8d7684a3346a 85:59500bcfaf82
1 """MiraAssemblyFormat class for the 'mira' format within Galaxy."""
2
3 from galaxy.datatypes.data import Text
4
5
6 class MiraAssemblyFormat(Text):
7 """MIRA Assembly Format data."""
8
9 file_ext = "mira"
10
11 def sniff(self, filename):
12 """Determine if the file is a MIRA Assembly Format file.
13
14 Note currently this only detects MIRA Assembly Format v2.0,
15 as used in MIRA v3.9 and v4.0.
16
17 It does not detect MIRA Assembly Format v1 as used in both
18 MIRA v3.2 and v3.4.
19 """
20 h = open(filename)
21 line = h.readline()
22 if line.rstrip() != "@Version\t2\t0":
23 h.close()
24 return False
25 line = h.readline()
26 if line.rstrip() != "@Program\tMIRALIB":
27 h.close()
28 return False
29 return True
30
31 def merge(split_files, output_file):
32 """Merge MIRA assembly files (not implemented).
33
34 Merging multiple MIRA files is non-trivial and may not be possible...
35 """
36 if len(split_files) == 1:
37 # For one file only, use base class method (move/copy)
38 return Text.merge(split_files, output_file)
39 if not split_files:
40 raise ValueError(
41 "No MIRA files to merge, %r, into %r" % (split_files, output_file)
42 )
43 raise NotImplementedError(
44 "Merging MIRA Assembly Files has not been implemented"
45 )
46
47 merge = staticmethod(merge)
48
49 def split(cls, input_datasets, subdir_generator_function, split_params):
50 """Split a MIRA Assembly File (not implemented for now)."""
51 if split_params is None:
52 return None
53 raise NotImplementedError("Can't yet split a MIRA Assembly Format file")
54
55 merge = staticmethod(merge)