def test_lipid_xreflist(): t = 'DAG 16:0;0_22:4;0' lipid = Lipid.parse(t) lipid.add_xref( Xref('TargetDB', 'targetid') ) assert len(lipid.xreflist) == 1
def test_swisslipids_xref(): lipid = Lipid.parse('CE(20:2)') lipid = SwissLipids.get_xrefs(lipid) for xref in lipid.xreflist: assert xref.target_db == SwissLipids.NAME assert any(x.target_id == 'SLM:000500283' for x in lipid.xreflist)
def test_parse(self): t = 'CE 16:2;0' lipid = Lipid.parse(t) assert lipid.lipidclass.name == 'CE' assert lipid.residueslist[0].carbon_atoms == 16 assert lipid.residueslist[0].double_bonds == 2 assert lipid.residueslist[0].oxidation == 0 t = 'CE(16:2;0)' lipid = Lipid.parse(t) assert lipid.lipidclass.name == 'CE' assert lipid.residueslist[0].carbon_atoms == 16 assert lipid.residueslist[0].double_bonds == 2 assert lipid.residueslist[0].oxidation == 0 t = 'DAG 16:0;0_22:4;0' lipid = Lipid.parse(t) assert lipid.lipidclass.name == 'DG' assert len(lipid.residueslist) == 2 assert lipid.residueslist[0].carbon_atoms == 16 assert lipid.residueslist[0].double_bonds == 0 assert lipid.residueslist[0].oxidation == 0 t = 'PC(28:5(13Z,16Z,19Z,22Z,25Z)/0:0)' lipid = Lipid.parse(t) assert lipid.lipidclass.name == 'PC' assert len(lipid.residueslist) == 2 assert lipid.residueslist[0].carbon_atoms == 28 assert lipid.residueslist[0].double_bonds == 5 assert lipid.residueslist[0].oxidation == None assert len(lipid.residueslist[0].zstatelist) == 5 assert str(lipid.residueslist[0].zstatelist[1]) == '16Z' t = 'chol' lipid = Lipid.parse(t) assert str(lipid.lipidclass) == 'chol'
def lipid_from_id(cls, swisslipidsid: str) -> Lipid: """ Call API to get details for a SwissLipids ID. :param swisslipidsid: The SwissLipids ID. :return: Return a Lipid. """ request_url = cls.BASE_URL + f'/entity/{swisslipidsid.strip()}' log.debug(f'Call: {request_url}') result = requests.get(request_url).json() # get abbreviation for synonym in result['synonyms']: if synonym['type'] == 'abbreviation': abbreviation = synonym['name'] lipid = Lipid.parse(abbreviation) lipid.add_xref(Xref(cls.NAME, swisslipidsid)) return lipid
def test_errors(self): with pytest.raises(TypeError): # string not ending with bracket Lipid.parse("CE(14:9(9Z)/8:0")