Beispiel #1
0
	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 == {}
Beispiel #2
0
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)},
			)
Beispiel #3
0
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")
Beispiel #4
0
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],
			)
Beispiel #5
0
	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 == []
Beispiel #6
0
	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 == []
Beispiel #7
0
	def test_compound_scores(self, scores):
		assert Compound(algo="FindByFormula", compound_scores=scores).compound_scores == copy.deepcopy(scores)
		assert Compound(algo="FindByFormula").compound_scores == {}
Beispiel #8
0
	def test_algo(self):
		assert Compound(algo="FindByFormula").algo == "FindByFormula"
Beispiel #9
0
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