Ejemplo 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
Ejemplo n.º 2
0
def main(options):
    precursor_tolerance = options.precursor_tolerance
    product_tolerance = options.product_tolerance
    out = options.outfile
    chromat_in = options.infile
    traml_in = options.traml_in

    # precursor_tolerance = 0.05
    # product_tolerance = 0.05
    # out = "/tmp/out.mzML"
    # chromat_in = "../source/TEST/TOPP/MRMMapping_input.chrom.mzML"
    # traml_in = "../source/TEST/TOPP/MRMMapping_input.TraML"

    ff = pyopenms.MRMFeatureFinderScoring()
    chromatogram_map = pyopenms.MSExperiment()
    fh = pyopenms.FileHandler()
    fh.loadExperiment(chromat_in, chromatogram_map)
    targeted = pyopenms.TargetedExperiment()
    tramlfile = pyopenms.TraMLFile()
    tramlfile.load(traml_in, targeted)

    output = algorithm(chromatogram_map, targeted, precursor_tolerance,
                       product_tolerance)

    pyopenms.MzMLFile().store(out, output)
Ejemplo n.º 3
0
    def test_run_mrmfeaturefinder(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()
        featurefinder.pickExperiment(chromatograms, output, targeted, trafo,
                                     empty_swath)

        self.assertAlmostEqual(output.size(), 3)
        self.assertAlmostEqual(output[0].getRT(), 3119.092041015, eps)
        self.assertAlmostEqual(output[0].getIntensity(), 3614.99755859375, eps)
        self.assertAlmostEqual(
            output[0].getMetaValue(b"var_xcorr_shape_weighted"),
            0.997577965259552, eps)
        self.assertAlmostEqual(output[0].getMetaValue(b"sn_ratio"),
                               86.00413513183594, eps)
Ejemplo n.º 4
0
def main(options):
    out = options.outfile
    chromat_in = options.infile
    traml_in = options.traml_in
    trafo_in = options.trafo_in

    pp = pyopenms.MRMTransitionGroupPicker()


    metabolomics = False
    # this is an important weight for RT-deviation -- the larger the value, the less importance will be given to exact RT matches
    # for proteomics data it tends to be a good idea to set it to the length of
    # the RT space (e.g. for 100 second RT space, set it to 100)
    rt_normalization_factor = 100.0

    pp_params = pp.getDefaults();
    pp_params.setValue("PeakPickerMRM:remove_overlapping_peaks", options.remove_overlapping_peaks, '')
    pp_params.setValue("PeakPickerMRM:method", options.method, '')
    if (metabolomics):
        # Need to change those for metabolomics and very short peaks!
        pp_params.setValue("PeakPickerMRM:signal_to_noise", 0.01, '')
        pp_params.setValue("PeakPickerMRM:peak_width", 0.1, '')
        pp_params.setValue("PeakPickerMRM:gauss_width", 0.1, '')
        pp_params.setValue("resample_boundary", 0.05, '')
        pp_params.setValue("compute_peak_quality", "true", '')
    pp.setParameters(pp_params)

    scorer = pyopenms.MRMFeatureFinderScoring()
    scoring_params = scorer.getDefaults();
    # Only report the top 5 features
    scoring_params.setValue("stop_report_after_feature", 5, '')
    scoring_params.setValue("rt_normalization_factor", rt_normalization_factor, '')
    scorer.setParameters(scoring_params);

    chromatograms = pyopenms.MSExperiment()
    fh = pyopenms.FileHandler()
    fh.loadExperiment(chromat_in, chromatograms)
    targeted = pyopenms.TargetedExperiment();
    tramlfile = pyopenms.TraMLFile();
    tramlfile.load(traml_in, targeted);

    trafoxml = pyopenms.TransformationXMLFile()
    trafo = pyopenms.TransformationDescription()
    if trafo_in is not None:
        model_params = pyopenms.Param()
        model_params.setValue("symmetric_regression", "false", "", [])
        model_type = "linear"
        trafoxml.load(trafo_in, trafo, True)
        trafo.fitModel(model_type, model_params);


    light_targeted = pyopenms.LightTargetedExperiment();
    pyopenms.OpenSwathDataAccessHelper().convertTargetedExp(targeted, light_targeted)
    output = algorithm(chromatograms, light_targeted, pp, scorer, trafo)

    pyopenms.FeatureXMLFile().store(out, output);
Ejemplo n.º 5
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)