How to use the pyopenms.MzMLFile 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 / pyOpenMS / pyTOPP / OpenSwathChromatogramExtractor.py View on Github external
for chrom in tmp_out.getChromatograms():
                output.addChromatogram(chrom)

    dp = pyopenms.DataProcessing()
    pa = pyopenms.ProcessingAction().SMOOTHING
    dp.setProcessingActions(set([pa]))

    chromatograms = output.getChromatograms();
    for chrom in chromatograms:
        this_dp = chrom.getDataProcessing()
        this_dp.append(dp)
        chrom.setDataProcessing(this_dp)

    output.setChromatograms(chromatograms);

    pyopenms.MzMLFile().store(options.outfile, output);
github OpenMS / OpenMS / src / pyOpenMS / pyTOPP / MapAlignerPoseClustering.py View on Github external
plog.setLogType(pms.LogType.CMD)

    if reference_file:
        file_ = reference_file
    elif reference_index > 0:
        file_ = in_files[reference_index-1]
    else:
        sizes = []
        if align_features:
            fh = pms.FeatureXMLFile()
            plog.startProgress(0, len(in_files), "Determine Reference map")
            for i, in_f in enumerate(in_files):
                sizes.append((fh.loadSize(in_f), in_f))
                plog.setProgress(i)
        else:
            fh = pms.MzMLFile()
            mse = pms.MSExperiment()
            plog.startProgress(0, len(in_files), "Determine Reference map")
            for i, in_f in enumerate(in_files):
                fh.load(in_f, mse)
                mse.updateRanges()
                sizes.append((mse.getSize(), in_f))
                plog.setProgress(i)
        plog.endProgress()
        __, file_ = max(sizes)

    f_fmxl = pms.FeatureXMLFile()
    if not out_files:
        options = f_fmxl.getOptions()
        options.setLoadConvexHull(False)
        options.setLoadSubordinates(False)
        f_fmxl.setOptions(options)
github msproteomicstools / msproteomicstools / analysis / scripts / DIA / makeSwathFile.py View on Github external
elif precusorsisolation == "Missing":
                pass
            else:
                raise Exception("precusorsisolation needs to be {Missing,Pwiz,OpenSwath}")
            prec.setMZ(400 + i *25 + 12.5);
            spec.setPrecursors( [prec])
            pk_list = [ [500.01+i, intensity*3000] , [500.15+i, intensity*3000/2.0], [500.25+i, intensity*3000/3.0]  ]
            peaks = numpy.array(pk_list, dtype=numpy.float32)
            spec.set_peaks(peaks)
            exp.addSpectrum(spec)
    return exp

exp = getSwathExperiment(20,5, "OpenSwath") 
pyopenms.MzMLFile().store("Swath_test_osw.mzML", exp)
exp = getSwathExperiment(20,5, "Pwiz") 
pyopenms.MzMLFile().store("Swath_test_pwiz.mzML", exp)
exp = getSwathExperiment(20,5, "Missing") 
pyopenms.MzMLFile().store("Swath_test_missing.mzML", exp)
github OpenMS / OpenMS / src / pyOpenMS / pyTOPP / MapAlignerPoseClustering.py View on Github external
options.setLoadConvexHull(False)
        options.setLoadSubordinates(False)
        f_fmxl.setOptions(options)

    if align_features:
        map_ref = pms.FeatureMap()
        f_fxml_tmp = pms.FeatureXMLFile()
        options = f_fmxl.getOptions()
        options.setLoadConvexHull(False)
        options.setLoadSubordinates(False)
        f_fxml_tmp.setOptions(options)
        f_fxml_tmp.load(file_, map_ref)
        algorithm.setReference(map_ref)
    else:
        map_ref = pms.MSExperiment()
        pms.MzMLFile().load(file_, map_ref)
        algorithm.setReference(map_ref)

    plog.startProgress(0, len(in_files), "Align input maps")
    for i, in_file in enumerate(in_files):
        trafo = pms.TransformationDescription()
        if align_features:
            map_ = pms.FeatureMap()
            f_fxml_tmp = pms.FeatureXMLFile()
            f_fxml_tmp.setOptions(f_fmxl.getOptions())
            f_fxml_tmp.load(in_file, map_)
            if in_file == file_:
                trafo.fitModel("identity")
            else:
                algorithm.align(map_, trafo)
            if out_files:
                pms.MapAlignmentTransformer.transformRetentionTimes(map_, trafo)
github OpenMS / OpenMS / pyOpenMS / pyTOPP / MRMMapper.py View on Github external
# 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 msproteomicstools / msproteomicstools / analysis / scripts / filterChrom.py View on Github external
#try: 
            pr.setMZ( chrom["precursors"][0]["mz"] )
            #except Exception: pass
            c.setPrecursor(pr)
            timea = numpy.array( chrom.time , dtype=numpy.float32)
            inta = numpy.array( chrom.i , dtype=numpy.float32)
            peaks = numpy.ndarray(shape=(len(timea), 2), dtype=numpy.float32)
            peaks[:,0] = timea
            peaks[:,1] = inta
            c.set_peaks(peaks)
            chroms_out.append(c)

except ImportError:

    exp = pyopenms.MSExperiment()
    pyopenms.MzMLFile().load(infile, exp)
    exp2 = exp
    exp2.clear(False)
    chroms = exp2.getChromatograms()
    for c in chroms:
        if (inverse and not re.search(filter_criteria, key)) \
           or (not inverse and re.search(filter_criteria, key)):
            chroms_out.append(c)


# Sort chromatograms and store again
print("Retrieved", len(chroms_out), "chromatograms.")
chroms_out.sort(key=lambda x: x.getNativeID())
exp2.setChromatograms(chroms_out)
pyopenms.MzMLFile().store(outfile, exp2)
github OpenMS / OpenMS / pyOpenMS / pyTOPP / FeatureFinderCentroided.py View on Github external
def run_featurefinder_centroided(input_path, params, seeds, out_path):

    fh = pms.MzMLFile()
    options = pms.PeakFileOptions()
    options.setMSLevels([1,1])
    fh.setOptions(options)
    input_map = pms.MSExperiment()
    fh.load(input_path, input_map)
    input_map.updateRanges()

    ff = pms.FeatureFinder()
    ff.setLogType(pms.LogType.CMD)

    features = pms.FeatureMap()
    name = pms.FeatureFinderAlgorithmPicked.getProductName()
    ff.run(name, input_map, features, params, seeds)

    features.setUniqueIds()
    addDataProcessing(features, params, pms.ProcessingAction.QUANTITATION)
github OpenMS / OpenMS / src / pyOpenMS / pyTOPP / MapAlignerPoseClustering.py View on Github external
algorithm.align(map_, trafo)
            if out_files:
                pms.MapAlignmentTransformer.transformRetentionTimes(map_, trafo)
                addDataProcessing(map_, params, pms.ProcessingAction.ALIGNMENT)
                f_fxml_tmp.store(out_files[i], map_)
        else:
            map_ = pms.MSExperiment()
            pms.MzMLFile().load(in_file, map_)
            if in_file == file_:
                trafo.fitModel("identity")
            else:
                algorithm.align(map_, trafo)
            if out_files:
                pms.MapAlignmentTransformer.transformRetentionTimes(map_, trafo)
                addDataProcessing(map_, params, pms.ProcessingAction.ALIGNMENT)
                pms.MzMLFile().store(out_files[i], map_)
        if out_trafos:
            pms.TransformationXMLFile().store(out_trafos[i], trafo)

        plog.setProgress(i+1)

    plog.endProgress()
github msproteomicstools / msproteomicstools / analysis / scripts / filterChrom.py View on Github external
exp = pyopenms.MSExperiment()
    pyopenms.MzMLFile().load(infile, exp)
    exp2 = exp
    exp2.clear(False)
    chroms = exp2.getChromatograms()
    for c in chroms:
        if (inverse and not re.search(filter_criteria, key)) \
           or (not inverse and re.search(filter_criteria, key)):
            chroms_out.append(c)


# Sort chromatograms and store again
print("Retrieved", len(chroms_out), "chromatograms.")
chroms_out.sort(key=lambda x: x.getNativeID())
exp2.setChromatograms(chroms_out)
pyopenms.MzMLFile().store(outfile, exp2)