Esempio n. 1
0
def test_interpret_pepmass(input_pepmass, expected_results):
    """Test if example inputs are correctly converted"""
    mz = numpy.array([100, 200.])
    intensities = numpy.array([0.7, 0.1])
    metadata = {'pepmass': input_pepmass}
    spectrum_in = SpectrumBuilder().with_mz(mz).with_intensities(
        intensities).with_metadata(metadata).build()

    spectrum = interpret_pepmass(spectrum_in)
    mz = spectrum.get("precursor_mz")
    intensity = spectrum.get("precursor_intensity")
    charge = spectrum.get("charge")
    assert (mz, intensity, charge) == expected_results, \
        "Expected different 3 values."
Esempio n. 2
0
def test_interpret_pepmass_intensity_present(caplog):
    """Test if example inputs are correctly converted when entries already exist"""
    mz = numpy.array([100, 200.])
    intensities = numpy.array([0.7, 0.1])
    metadata = {'pepmass': (203, 44, "2-"), 'precursor_intensity': 100}
    spectrum_in = SpectrumBuilder().with_mz(mz).with_intensities(
        intensities).with_metadata(metadata).build()

    spectrum = interpret_pepmass(spectrum_in)
    mz = spectrum.get("precursor_mz")
    intensity = spectrum.get("precursor_intensity")
    charge = spectrum.get("charge")
    assert (mz, intensity, charge) == (203, 44, -2), \
        "Expected different 3 values."
    assert "Overwriting existing precursor_intensity 100 with new one: 44" in caplog.text, \
        "Expected different log message"
Esempio n. 3
0
def test_empty_spectrum():
    spectrum_in = None
    spectrum = interpret_pepmass(spectrum_in)

    assert spectrum is None, "Expected different handling of None spectrum."