Mercurial > repos > peterjc > mira_datatypes
comparison mira.py @ 53:7f01823efdd5 draft
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/datatypes/mira_datatypes commit 791c2c3ab336c519634fc0d335e3010fbf41a088
| author | peterjc |
|---|---|
| date | Mon, 02 Apr 2018 12:54:44 -0400 |
| parents | 94e05a9e3957 |
| children | 2bd1f1175fb2 |
comparison
equal
deleted
inserted
replaced
| 52:0ea7020685e2 | 53:7f01823efdd5 |
|---|---|
| 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) |
