Example #1
0
    def test_peaks(self):
        assert Spectrum().peaks == []
        assert Spectrum(peaks=[]).peaks == []
        assert Spectrum(peaks=()).peaks == []

        spectrum = Spectrum(
            peaks=[Peak(170.0965, 172.1028, 890559.25, 1, "M+H")])
        assert spectrum.peaks == [
            Peak(170.0965, 172.1028, 890559.25, 1, "M+H")
        ]
Example #2
0
def spectrum():
	return Spectrum(
			spectrum_type="FbF",
			algorithm="FindByFormula",
			saturation_limit=10000,
			scans=1,
			scan_type="Scan",
			ionisation="Esi",
			polarity='+',
			peaks=[Peak(170.0965, 172.1028, 890559.25, 1, "M+H")],
			rt_ranges=[RTRange(12, 34)],
			)
Example #3
0
def fbf_spectrum():
	return Spectrum(
			spectrum_type="FbF",
			algorithm="FindByFormula",
			scan_type="Scan",
			ionisation="Esi",
			polarity='+',
			device=Device(device_type="QuadrupoleTimeOfFlight", number=1),
			peaks=[
					Peak(170.0965, 170.0964, 890559.25, charge=1, label="M+H"),
					Peak(171.0998, 171.0996, 114286.09, charge=1, label="M+H+1"),
					Peak(172.1033, 172.1028, 7151.12, charge=1, label="M+H+2"),
					Peak(192.0831, 192.0784, 490.62, charge=1, label="M+Na"),
					],
			)
Example #4
0
def tof_spectrum():
	return Spectrum(
			spectrum_type="TOF-MS1",
			algorithm="FindByFormula",
			saturation_limit=16742400,
			scans=12,
			scan_type="Scan",
			ionisation="Esi",
			polarity='+',
			voltage="380V",
			device=Device(device_type="QuadrupoleTimeOfFlight", number=1),
			peaks=[
					Peak(170.0965, 170.0964, 890559.25, charge=1, label="M+H"),
					Peak(171.0998, 171.0996, 114286.09, charge=1, label="M+H+1"),
					Peak(172.1033, 172.1028, 7151.12, charge=1, label="M+H+2"),
					Peak(192.0831, 192.0784, 490.62, charge=1, label="M+Na"),
					],
			rt_ranges=[RTRange(13.561, 13.808)],
			)
Example #5
0
 def test_voltage(self, voltage, expected):
     assert Spectrum(voltage=voltage).voltage == expected
Example #6
0
 def test_rt_ranges(self):
     assert Spectrum().rt_ranges == []
     assert Spectrum(rt_ranges=[]).rt_ranges == []
     assert Spectrum(rt_ranges=()).rt_ranges == []
     assert Spectrum(rt_ranges=[RTRange(12, 34)
                                ], ).rt_ranges == [RTRange(12, 34)]
Example #7
0
 def test_ionisation(self):
     assert Spectrum(ionisation="Esi").ionisation == "Esi"
Example #8
0
 def test_polarity(self, polarity, expected):
     assert Spectrum(polarity=polarity).polarity == expected
Example #9
0
 def test_scans(self):
     assert Spectrum(scans=1).scans == 1
     assert Spectrum(scans='1').scans == 1  # type: ignore
Example #10
0
 def test_scan_type(self):
     assert Spectrum(scan_type="Scan").scan_type == "Scan"
Example #11
0
def test_from_xml(raw_xml, expects):
    tree = lxml.objectify.fromstring(raw_xml)
    spec = Spectrum.from_xml(tree)
    assert spec == expects
Example #12
0
 def test_saturation_limit(self):
     assert Spectrum(saturation_limit=10000).saturation_limit == 10000
     assert Spectrum(
         saturation_limit="10000").saturation_limit == 10000  # type: ignore
Example #13
0
 def test_algorithm(self):
     assert Spectrum(algorithm="FindByFormula").algorithm == "FindByFormula"
Example #14
0
 def test_spectrum_type(self):
     assert Spectrum(spectrum_type="FbF").spectrum_type == "FbF"
Example #15
0
		<p x="195.0612" rx="195.0652" y="690.56" z="1" s="M+H" />
		<p x="196.0679" rx="196.0686" y="22.97" z="1" s="M+H+1" />
		<p x="217.0466" rx="217.0471" y="1286.60" z="1" s="M+Na" />
		<p x="219.0532" rx="219.0524" y="44.93" z="1" s="M+Na+1" />
	</MSPeaks>
</Spectrum>
"""

fbf_expects = Spectrum(
    spectrum_type="FbF",
    algorithm="FindByFormula",
    scans=0,
    scan_type="Scan",
    ionisation="Esi",
    polarity='+',
    peaks=[
        Peak(x=195.0612, rx=195.0652, y=690.56, charge=1, label="M+H"),
        Peak(x=196.0679, rx=196.0686, y=22.97, charge=1, label="M+H+1"),
        Peak(x=217.0466, rx=217.0471, y=1286.60, charge=1, label="M+Na"),
        Peak(x=219.0532, rx=219.0524, y=44.93, charge=1, label="M+Na+1"),
    ],
    device=Device("QuadrupoleTimeOfFlight", 1),
)

raw_xml_tof = """
<Spectrum type="TOF-MS1" satLimit="16742400" scans="28" cpdAlgo="FindByFormula">
	<MSDetails scanType="Scan" is="Esi" p="+" fv="380.0V" />
	<RTRanges>
		<RTRange min="12.158" max="12.461" />
	</RTRanges>
	<Device type="QuadrupoleTimeOfFlight" num="1" />