def get_compound(self, compound_id): if compound_id not in self.compound_dict: logging.debug('Cache miss: %s' % str(compound_id)) inchi = self.compound_id2inchi[compound_id] comp = Compound.from_inchi('KEGG', compound_id, inchi) self.add(comp) logging.debug('Cache hit: %s' % str(compound_id)) return self.compound_dict[compound_id]
def get_compound(self, compound_id, kegg_additions_cids=None): if compound_id not in self.compound_dict: logging.debug('Cache miss: %s' % str(compound_id)) inchi = self.compound_id2inchi[compound_id] comp = Compound.from_inchi('KEGG', compound_id, inchi) self.add(comp) #if a compound id is in the kegg_additions.tsv #remove the one in cache, and replace it with new one else: if kegg_additions_cids is not None: if compound_id in kegg_additions_cids: self.remove(compound_id) logging.debug('Cache update: %s' % str(compound_id)) inchi = self.compound_id2inchi[compound_id] comp = Compound.from_inchi('KEGG', compound_id, inchi) self.add(comp) logging.debug('Cache hit: %s' % str(compound_id)) return self.compound_dict[compound_id]
def parse_novel_molecule(add_info): result = {} for cid, InChI in add_info.items(): c = Compound.from_inchi('Test', cid, InChI) result[cid] = c return result