How to use the pyopenms.FileHandler function in pyopenms

To help you get started, we’ve selected a few pyopenms examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github OpenMS / OpenMS / src / pyOpenMS / pyTOPP / MRMTransitionGroupScorer.py View on Github external
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();
github OpenMS / OpenMS / pyOpenMS / pyTOPP / MRMMapper.py View on Github external
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);
github OpenMS / OpenMS / src / pyOpenMS / pyTOPP / MRMMapper.py View on Github external
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);
github metaspace2020 / metaspace / metaspace / engine / sm / engine / lcms_geometry_factory.py View on Github external
def _acquisition_grid(self):
        ms_experiment = ms.MSExperiment()
        file_handler = ms.FileHandler()
        file_handler.loadExperiment(self.ms_file_path, ms_experiment)
        pixel_coords = [(spec.getRT(), 0.0) for spec in ms_experiment]
        return {
            ACQ_GEOMETRY_KEYS.AcqGridSection.REGULAR_GRID: False,
            ACQ_GEOMETRY_KEYS.AcqGridSection.PIXEL_CORRD_LIST: pixel_coords
        }
github OpenMS / OpenMS / pyOpenMS / pyTOPP / OpenSwathChromatogramExtractor.py View on Github external
def main(options):

    # load TraML file
    targeted = pyopenms.TargetedExperiment();
    pyopenms.TraMLFile().load(options.traml_in, targeted);

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

    # load input
    for infile in options.infiles:
        exp = pyopenms.MSExperiment()
        pyopenms.FileHandler().loadExperiment(infile, exp)

        transition_exp_used = pyopenms.TargetedExperiment();

        do_continue = True
        if options.is_swath:
            do_continue = pyopenms.OpenSwathHelper().checkSwathMapAndSelectTransitions(exp, targeted, transition_exp_used, options.min_upper_edge_dist)
        else:
            transition_exp_used = targeted

        if do_continue:
            # set up extractor and run
            tmp_out = pyopenms.MSExperiment();
            extractor = pyopenms.ChromatogramExtractor()
            extractor.extractChromatograms(exp, tmp_out, targeted, options.extraction_window, options.ppm, trafo, options.rt_extraction_window, options.extraction_function)
            # add all chromatograms to the output
            for chrom in tmp_out.getChromatograms():
github OpenMS / OpenMS / pyOpenMS / pyTOPP / SILACAnalyzer.py View on Github external
def main(options):

    # make sure that the ids are "correct" for the testcase
    date_time = pyopenms.DateTime();
    if options.test:
        date_time.set("1999-12-31 23:59:59");
        pyopenms.UniqueIdGenerator().setSeed(date_time);
    else:
        date_time = pyopenms.DateTime.now();

    exp = pyopenms.MSExperiment()
    out_map = pyopenms.ConsensusMap()
    pyopenms.FileHandler().loadExperiment(options.infile, exp)
    exp.updateRanges()

    # 
    # 1. filter MS1 level (only keep MS1)
    # 
    tmp = copy.copy(exp)
    tmp.clear(False); 
    for spectrum in exp:
        if spectrum.getMSLevel() == 1:
            tmp.push_back(spectrum)
    exp = tmp
    exp.sortSpectra(True)

    # 
    # 2. set parameters
    # 
github OpenMS / OpenMS / src / pyOpenMS / pyTOPP / OpenSwathRTNormalizer.py View on Github external
def main(options):

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

    # load TraML file
    targeted = pyopenms.TargetedExperiment();
    tramlfile = pyopenms.TraMLFile();
    tramlfile.load(options.traml_in, targeted);

    trafo_out = algorithm(chromatograms, targeted)

    pyopenms.TransformationXMLFile().store(options.outfile, trafo_out);
github metaspace2020 / metaspace / metaspace / engine / sm / engine / mzml_reading.py View on Github external
def read_ms1_experiment(filepath):
    source_experiment = MSExperiment()
    file_handler = FileHandler()
    # bytes is required by `loadExperiment()` called below
    typed_fp = filepath if isinstance(filepath, bytes) else filepath.encode()
    file_handler.loadExperiment(typed_fp, source_experiment)

    ms1_experiment = MSExperiment()
    for spectrum in source_experiment:
        if spectrum.getMSLevel() == 1:
            ms1_experiment.addSpectrum(spectrum)
    return ms1_experiment