def test_lipid_abbreviation(): l = Lipid(LipidClass('CE'), ResidueList([Residue(16, 2)])) assert l.abbreviation() == 'CE(16:2)' l = Lipid(LipidClass('CE'), ResidueList([Residue(16, 2), Residue(18, 1)])) assert l.abbreviation() == 'CE(16:2/18:1)' assert l.abbreviation(summed=True) == 'CE(34:3)' l = Lipid( LipidClass('CE'), ResidueList([ Residue(16, 2, modification=ResidueModification('O-')), Residue(18, 1) ])) assert l.abbreviation() == 'CE(O-16:2/18:1)' assert l.abbreviation(summed=True) == 'CE(O-34:3)' # no residues, assure that abbreviation/summed fails with AttributeError l = Lipid(LipidClass('CE')) assert l.abbreviation() == 'CE' assert l.abbreviation(summed=True) == 'CE'
def get_xrefs(cls, lipid: Lipid, summed: bool = False) -> XrefList: xreflist = XrefList() try: search_term = lipid.abbreviation(summed) except Exception as e: log.debug( f"No abbreviation for lipid: {lipid.lipidclass}, {lipid.residueslist}." ) log.error(f"Failed with {e}") search_term = lipid.abbreviation() search_result = cls.run_search(search_term) # search result can be empyt if search_result: for entity in cls.run_search(lipid.abbreviation(summed)): xreflist.append(Xref(cls.NAME, entity['entity_id'])) return xreflist