Mercurial > repos > peterjc > mira_datatypes
comparison mira.py @ 82:ae4607906a65 draft
planemo upload for repository https://github.com/peterjc/pico_galaxy/tree/master/datatypes/mira_datatypes commit 89578746a1c5b29c84a173d8b2709f086f69a7b6
| author | peterjc |
|---|---|
| date | Mon, 17 Jun 2019 13:50:39 -0400 |
| parents | 65ea1ef0181d |
| children |
comparison
equal
deleted
inserted
replaced
| 81:024d20f0b4fb | 82:ae4607906a65 |
|---|---|
| 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) |
