Mercurial > repos > peterjc > mira_datatypes
comparison mira.py @ 0:ddd2e3362c5e draft default tip
Uploaded v0.0.1, previously only on the Test Tool Shed
author | peterjc |
---|---|
date | Fri, 21 Nov 2014 06:38:46 -0500 |
parents | |
children |
comparison
equal
deleted
inserted
replaced
-1:000000000000 | 0:ddd2e3362c5e |
---|---|
1 """ | |
2 MiraAssemblyFormat class for the 'mira' format within Galaxy | |
3 """ | |
4 | |
5 from galaxy.datatypes.data import Text | |
6 | |
7 | |
8 class MiraAssemblyFormat(Text): | |
9 """MIRA Assembly Format data""" | |
10 file_ext = "mira" | |
11 | |
12 def sniff( self, filename ): | |
13 """Determines whether the file is a MIRA Assembly Format file. | |
14 | |
15 Note currently this only detects MIRA Assembly Format v2.0, | |
16 as used in MIRA v3.9 and v4.0. | |
17 | |
18 It does not detect MIRA Assembly Format v1 as used in both | |
19 MIRA v3.2 and v3.4. | |
20 """ | |
21 h = open(filename) | |
22 line = h.readline() | |
23 if line.rstrip() != "@Version\t2\t0": | |
24 h.close() | |
25 return False | |
26 line = h.readline() | |
27 if line.rstrip() != "@Program\tMIRALIB": | |
28 h.close() | |
29 return False | |
30 return True | |
31 | |
32 def merge(split_files, output_file): | |
33 """Merging multiple MIRA files is non-trivial and may not be possible...""" | |
34 if len(split_files) == 1: | |
35 #For one file only, use base class method (move/copy) | |
36 return Text.merge(split_files, output_file) | |
37 if not split_files: | |
38 raise ValueError("Given no MIRA, %r, to merge into %s" \ | |
39 % (split_files, output_file)) | |
40 raise NotImplementedError("Merging MIRA Assembly Files has not been implemented") | |
41 merge = staticmethod(merge) | |
42 | |
43 def split( cls, input_datasets, subdir_generator_function, split_params): | |
44 """Split a MIRA Assembly File (not implemented for now).""" | |
45 if split_params is None: | |
46 return None | |
47 raise NotImplementedError("Can't yet split a MIRA Assembly Format file") | |
48 merge = staticmethod(merge) |