path = ['Import', 'Sequence features', 'gff annotations'] tooltip = 'Import feature annotations from a general feature format file.' @classmethod def applicable(cls, target, coord=None): if target.msaview_classname == 'data.msa': return cls(target.features) if target.msaview_classname == 'data.sequence_features': return cls(target) def run(self): gff = open(self.params['location']) features = [] for annotation in iter_gff_annotations(gff): annotation.sequence_index = get_id_index(self.target.msa.ids, annotation.sequence_id) if annotation.sequence_index is None: continue annotation.mapping = map_region_to_msa(annotation.region, self.target.msa.msa_positions[annotation.sequence_index]) if annotation.mapping is None: continue features.append(annotation) self.target.add_features(features) def get_options(self): path = '' if self.target and self.target.msa.path: path = self.target.msa.path + '.gff' return [Option(propname='location', default=path, value=path, nick='Location', tooltip='Where to read the GFF annotations from.')] register_action(ImportGFFAnnotations)
@classmethod def applicable(cls, target, coord=None): cm = target.get_compute_manager() if not cm: return a = cls(target, coord) if not cm.computing(): a.path = list(cls.path) a.path[-1] += ' (nothing to do)' return a def run(self): self.target.get_compute_manager().compute_all() register_action(ComputeAll) class AbortAllComputations(Action): action_name = "abort-all-computations" path = ['Computation', 'Abort all computations'] tooltip = "Abort all running background tasks." @classmethod def applicable(cls, target, coord=None): cm = target.get_compute_manager() if not (cm and cm.computing()): return return cls(target, coord) def run(self): self.target.get_compute_manager().abort_all()
action_name = 'open-fasta-alignment' path = ['Open', 'Fasta alignment'] tooltip = 'Read a gapped fasta alignment file.' @classmethod def applicable(cls, target=None, coord=None): if target.msaview_classname == 'data.msa': return cls(target) def get_options(self): return [Option(propname='location', default='', value='', nick='Location', tooltip='The alignment file to read.')] def run(self): self.target.read_fasta(open(self.params['location'])) register_action(ReadFasta) class SaveFasta(Action): action_name = 'save-fasta-alignment' path = ['Save', 'Fasta alignment'] tooltip = 'Save alignment in gapped fasta format.' @classmethod def applicable(cls, target=None, coord=None): if target.msaview_classname == 'data.msa': return cls(target) def get_options(self): try: path = os.path.splitext(self.target.path)[0] + '.gfasta' except: