def test_location(self): assert Compound( algo="FindByFormula", location={'m': 169.0893, "rt": 13.649, 'a': 29388223, 'y': 3377289} ).location == {'m': 169.0893, "rt": 13.649, 'a': 29388223, 'y': 3377289} assert Compound( algo="FindByFormula", location={'m': 169.0893, "rt": 13.649, 'a': 29388223, 'y': 3377289} ).location == {'m': 169.0893, "rt": 13.649, 'a': 29388223, 'y': 3377289} assert Compound(algo="FindByFormula").location == {}
def compound(spectrum, molecule): return Compound( algo="FindByFormula", location={'m': 169.0893, "rt": 13.649, 'a': 29388223, 'y': 3377289}, results=[molecule], spectra=[spectrum], compound_scores={"fbf": Score(62.90, flag_string="low score", flag_severity=2)}, )
def test_repr(compound, spectrum, molecule, file_regression: FileRegressionFixture): assert str(compound) == "Compound([Molecule(Dimethyl Phthalate, C10H10O4)])" assert repr(compound) == "<Compound([<Molecule(Dimethyl Phthalate, Formula({'C': 10, 'H': 10, 'O': 4}))>])>" compound = Compound( algo="FindByFormula", location={'m': 169.0893, "rt": 13.649, 'a': 29388223, 'y': 3377289}, results=[molecule, molecule, molecule, molecule, molecule], spectra=[spectrum], compound_scores={"fbf": Score(62.90, flag_string="low score", flag_severity=2)}, ) file_regression.check(str(compound), encoding="UTF-8", extension="_str.txt") file_regression.check(repr(compound), encoding="UTF-8", extension="_repr.txt")
def expected_compound(fbf_spectrum, tof_spectrum): score = Score(99.79) return Compound( algo="FindByFormula", location={'m': 169.0893, "rt": 13.649, 'a': 29388223, 'y': 3377289}, compound_scores={"fbf": score}, results=[ Molecule( name="Diphenylamine", formula="C12 H11 N", matches={ "overall": score, "tgt": score, } ) ], spectra=[fbf_spectrum, tof_spectrum], )
def test_spectra(self, spectrum): assert Compound(algo="FindByFormula", spectra=[spectrum]).spectra == [spectrum] assert Compound(algo="FindByFormula", spectra=(spectrum, )).spectra == [spectrum] assert Compound(algo="FindByFormula", spectra=()).spectra == [] assert Compound(algo="FindByFormula", spectra=[]).spectra == [] assert Compound(algo="FindByFormula").spectra == []
def test_results(self, molecule): results = [molecule, molecule] assert Compound(algo="FindByFormula", results=results).results == copy.deepcopy(results) assert Compound(algo="FindByFormula", results=()).results == [] assert Compound(algo="FindByFormula", results=[]).results == [] assert Compound(algo="FindByFormula").results == []
def test_compound_scores(self, scores): assert Compound(algo="FindByFormula", compound_scores=scores).compound_scores == copy.deepcopy(scores) assert Compound(algo="FindByFormula").compound_scores == {}
def test_algo(self): assert Compound(algo="FindByFormula").algo == "FindByFormula"
def test_from_xml(fbf_spectrum, tof_spectrum, expected_compound): tree = lxml.objectify.fromstring(raw_xml) spec = Compound.from_xml(tree) assert spec == expected_compound