def test_four(self): import emzed.utils import tempfile, pytest ft = emzed.utils.integrate(self.ft, "max") tmpdir = tempfile.mkdtemp() with pytest.raises(Exception): ftneu, ft2neu = rtAlign([ft,self.ft2], destination=tmpdir, nPeaks=9999, numBreakpoints=5) ftneu, ft2neu = rtAlign([ft,self.ft2], destination=tmpdir, nPeaks=9999, numBreakpoints=5, resetIntegration=True)
def realignment_should_fail(ft, ft2, ftneu, ft2neu, path, regtest): ex = None try: ftneu, ft2neu = rtAlign([ftneu, ft2neu], destination=path, nPeaks=9999, numBreakpoints=2) except Exception, e: ex = e
def test_three(input_tables, regtest, tmpdir): tmpdir = tmpdir.strpath ft, ft2 = input_tables ftneu, ft2neu = rtAlign([ft, ft2], destination=tmpdir, nPeaks=9999, numBreakpoints=3) check(ft, ft2, ftneu, ft2neu, tmpdir, regtest)
def test_three(self): import tempfile tmpdir = tempfile.mkdtemp() ft, ft2 = self.ft, self.ft2 ftneu, ft2neu = rtAlign([ft,ft2], destination=tmpdir, nPeaks=9999, numBreakpoints=5) check(ft, ft2, ftneu, ft2neu, tmpdir)
def test_four(input_tables, regtest, tmpdir): import emzed.utils ft, ft2 = input_tables ft = emzed.utils.integrate(ft, "max") tmpdir = tmpdir.strpath # fails becaus one is integrated, after alignment the integration would be infeasible: with pytest.raises(Exception): ftneu, ft2neu = rtAlign([ft, ft2], destination=tmpdir, nPeaks=9999, numBreakpoints=3) assert ft.method.countNotNone() > 0 assert ft.area.countNotNone() > 0 assert ft.params.countNotNone() > 0 # enforces alignment, but sets integration related columns to None ftneu, ft2neu = rtAlign([ft, ft2], destination=tmpdir, nPeaks=9999, numBreakpoints=5, resetIntegration=True) # all Nones: assert ftneu.method.countNotNone() == 0 assert ftneu.area.countNotNone() == 0 assert ftneu.params.countNotNone() == 0
def check(ft, ft2, ftneu, ft2neu, path): def getrt(t, what): return np.array([t.getValue(row, what) for row in t.rows]) # refmap ft should not be changed: assert np.all(getrt(ftneu, "rt") == getrt(ft, "rt")) assert np.all(getrt(ftneu, "rtmin") == getrt(ft, "rtmin")) assert np.all(getrt(ftneu, "rtmax") == getrt(ft, "rtmax")) # but ft2 should: assert np.linalg.norm(getrt(ft2neu, "rt") - getrt(ft2, "rt")) >= 2.0 assert np.linalg.norm(getrt(ft2neu, "rtmin") - getrt(ft2, "rtmin")) >= 2.0 assert np.linalg.norm(getrt(ft2neu, "rtmax") - getrt(ft2, "rtmax")) >= 2.0 # now ftneu and ft2neu should be very near. # remenber: ft2 has not as much rows as ft, so: assert np.linalg.norm(getrt(ft2neu, "rt") - getrt(ftneu, "rt")[:-1]) < 1e-4 assert max(abs(getrt(ft2neu, "rtmin")- getrt(ftneu, "rtmin")[:-1])) < 0.2 assert max(abs(getrt(ft2neu, "rtmax")[:-1] - getrt(ftneu, "rtmax")[:-2])) < 1e-3 def getrtsfrompeakmap(table): pms = set(table.getValue(row, "peakmap") for row in table.rows) assert len(pms) == 1 pm = pms.pop() return np.array([ spec.rt for spec in pm.spectra]) assert max(abs(getrtsfrompeakmap(ft2neu)- getrtsfrompeakmap(ftneu))) < 2.2 ex = None try: ftneu, ft2neu = rtAlign([ftneu,ft2neu], destination=path, nPeaks=9999, numBreakpoints=2) except Exception, e: ex = e