Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def algorithm(exp, targeted, picker, scorer, trafo):
output = pyopenms.FeatureMap()
scorer.prepareProteinPeptideMaps_(targeted)
chrom_map = {}
pepmap = {}
trmap = {}
for i, chrom in enumerate(exp.getChromatograms()):
chrom_map[ chrom.getNativeID() ] = i
for i, pep in enumerate(targeted.getCompounds() ):
pepmap[ pep.id ] = i
for i, tr in enumerate(targeted.getTransitions() ):
tmp = trmap.get( tr.getPeptideRef() , [])
tmp.append( i )
trmap[ tr.getPeptideRef() ] = tmp
swath_maps_dummy = []
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)
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:
pms.IdXMLFile().load(id_file, protein_ids, peptide_ids)
mapper = pms.IDMapper()
mapper.setParameters(params)
if in_type == pms.Type.CONSENSUSXML:
file_ = pms.ConsensusXMLFile()
map_ = pms.ConsensusMap()
file_.load(in_file, map_)
mapper.annotate(map_, peptide_ids, protein_ids, use_subelements)
addDataProcessing(map_, params, pms.ProcessingAction.IDENTIFICATION_MAPPING)
file_.store(out_file, map_)
elif in_type == pms.Type.FEATUREXML:
file_ = pms.FeatureXMLFile()
map_ = pms.FeatureMap()
file_.load(in_file, map_)
mapper.annotate(map_, peptide_ids, protein_ids, use_centroid_rt,
use_centroid_mz)
addDataProcessing(map_, params, pms.ProcessingAction.IDENTIFICATION_MAPPING)
file_.store(out_file, map_)
elif in_type == pms.Type.MZQ:
file_ = pms.MzQuantMLFile()
msq = pms.MSQuantifications()
file_.load(in_file, msq)
maps = msq.getConsensusMaps()
for map_ in maps:
mapper.annotate(map_, peptide_ids, protein_ids, use_subelements)
addDataProcessing(map_, params, pms.ProcessingAction.IDENTIFICATION_MAPPING)
msq.setConsensusMaps(maps)
file_.store(out_file, msq)
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)
fh = pms.FeatureXMLFile()
fh.store(out_path, features)
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)
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")
def algorithm(exp, targeted, picker):
output = pyopenms.FeatureMap()
chrom_map = {}
pepmap = {}
trmap = {}
for i, chrom in enumerate(exp.getChromatograms()):
chrom_map[ chrom.getNativeID() ] = i
for i, pep in enumerate(targeted.getPeptides() ):
pepmap[ pep.id ] = i
for i, tr in enumerate(targeted.getTransitions() ):
tmp = trmap.get( tr.getPeptideRef() , [])
tmp.append( i )
trmap[ tr.getPeptideRef() ] = tmp
for key, value in trmap.iteritems():
print key, value
transition_group = getTransitionGroup(exp, targeted, key, value, chrom_map)