def protein_step(self): """ Check mutations are valid """ self.start_timer() if self.has(): # this is already done (very unlikely/ protein = system_storage[self.handle] else: log.info( f'Step 1 analysis requested by {User.get_username(self.request)}' ) uniprot = self.request.params['uniprot'] taxid = self.request.params['species'] mutation_text = self.request.params['mutation'] ## Do analysis mutation = Mutation(mutation_text) protein = ProteinAnalyser(uniprot=uniprot, taxid=taxid) protein.load() protein.mutation = mutation # assess if not protein.check_mutation(): log.info('protein mutation discrepancy error') discrepancy = protein.mutation_discrepancy() self.reply = { **self.reply, 'error': 'mutation', 'msg': discrepancy, 'status': 'error' } raise VenusException(discrepancy) else: system_storage[self.handle] = protein self.reply['protein'] = self.jsonable(protein) self.stop_timer()
def protein_step(): uniprot = request.params['uniprot'] taxid = request.params['species'] mutation = Mutation(request.params['mutation']) protein = ProteinAnalyser(uniprot=uniprot, taxid=taxid) try: protein.load() except FutureWarning: log.error( f'There was no pickle for uniprot {uniprot} taxid {taxid}. TREMBL code via API?' ) #protein.__dict__ = ProteinGatherer(uniprot=uniprot, taxid=taxid).get_uniprot().__dict__ protein.mutation = mutation if not protein.check_mutation(): log.info('protein mutation discrepancy error') return { 'error': 'mutation', 'msg': protein.mutation_discrepancy(), 'status': 'error' } else: handle = request.params['uniprot'] + request.params['mutation'] system_storage[handle] = protein return {'protein': jsonable(protein), 'status': 'success'}
def load_protein(self) -> ProteinAnalyser: protein = ProteinAnalyser(uniprot=self.uniprot, taxid=self.taxid) protein.load() # self.reply['protein'] = self.jsonable(protein) return protein