Exemplo n.º 1
0
def algorithm(chromatograms, targeted):
    # Create empty files as input and finally as output
    empty_swath = pyopenms.MSExperiment()
    trafo = pyopenms.TransformationDescription()
    output = pyopenms.FeatureMap()

    # set up featurefinder and run
    featurefinder = pyopenms.MRMFeatureFinderScoring()
    # set the correct rt use values
    scoring_params = pyopenms.MRMFeatureFinderScoring().getDefaults()
    scoring_params.setValue("Scores:use_rt_score", 'false', '')
    featurefinder.setParameters(scoring_params)
    featurefinder.pickExperiment(chromatograms, output, targeted, trafo,
                                 empty_swath)

    # get the pairs
    pairs = []
    simple_find_best_feature(output, pairs, targeted)
    pairs_corrected = pyopenms.MRMRTNormalizer().rm_outliers(pairs, 0.95, 0.6)
    pairs_corrected = [list(p) for p in pairs_corrected]

    # // store transformation, using a linear model as default
    trafo_out = pyopenms.TransformationDescription()
    trafo_out.setDataPoints(pairs_corrected)
    model_params = pyopenms.Param()
    model_params.setValue("symmetric_regression", 'false', '')
    model_type = "linear"
    trafo_out.fitModel(model_type, model_params)
    return trafo_out
Exemplo n.º 2
0
    def test_run_mrmrtnormalizer(self):

        # load chromatograms
        chromatograms = pyopenms.MSExperiment()
        fh = pyopenms.FileHandler()
        fh.loadExperiment(self.chromatograms, chromatograms)

        # load TraML file
        targeted = pyopenms.TargetedExperiment()
        tramlfile = pyopenms.TraMLFile()
        tramlfile.load(self.tramlfile, targeted)

        # Create empty files as input and finally as output
        empty_swath = pyopenms.MSExperiment()
        trafo = pyopenms.TransformationDescription()
        output = pyopenms.FeatureMap()

        # set up featurefinder and run
        featurefinder = pyopenms.MRMFeatureFinderScoring()
        # set the correct rt use values
        scoring_params = pyopenms.MRMFeatureFinderScoring().getDefaults()
        scoring_params.setValue("Scores:use_rt_score".encode(),
                                'false'.encode(), ''.encode())
        featurefinder.setParameters(scoring_params)
        featurefinder.pickExperiment(chromatograms, output, targeted, trafo,
                                     empty_swath)

        # get the pairs
        pairs = []
        simple_find_best_feature(output, pairs, targeted)
        pairs_corrected = pyopenms.MRMRTNormalizer().removeOutliersIterative(
            pairs, 0.95, 0.6, True, "iter_jackknife")
        pairs_corrected = [list(p) for p in pairs_corrected]

        expected = [(1497.56884765625, 1881.0), (2045.9776611328125, 2409.0),
                    (2151.4814453125, 2509.0), (1924.0750732421875, 2291.0),
                    (612.9832153320312, 990.0), (1086.2474365234375, 1470.0),
                    (1133.89404296875, 1519.0), (799.5291137695312, 1188.0),
                    (1397.1541748046875, 1765.0)]

        for exp, res in zip(expected, pairs_corrected):
            self.assertAlmostEqual(exp[0], res[0], eps)
            self.assertAlmostEqual(exp[1], res[1], eps)