comparison mira.py @ 58:293ae67375e3 draft

planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/datatypes/mira_datatypes commit 0f1bb5279a25edaf91444752f13e07c7c283a115
author peterjc
date Wed, 14 Nov 2018 05:58:42 -0500
parents ce83350d97de
children
comparison
equal deleted inserted replaced
57:a8c4fba5e503 58:293ae67375e3
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("Given no MIRA, %r, to merge into %s"
41 % (split_files, output_file))
42 raise NotImplementedError("Merging MIRA Assembly Files has not been implemented")
43 merge = staticmethod(merge)
44
45 def split(cls, input_datasets, subdir_generator_function, split_params):
46 """Split a MIRA Assembly File (not implemented for now)."""
47 if split_params is None:
48 return None
49 raise NotImplementedError("Can't yet split a MIRA Assembly Format file")
50 merge = staticmethod(merge)