Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def id_mapper(in_file, id_file, out_file, params, use_centroid_rt,
use_centroid_mz, use_subelements ):
in_type = pms.FileHandler.getType(in_file)
protein_ids = []
peptide_ids = []
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()
def id_mapper(in_file, id_file, out_file, params, use_centroid_rt,
use_centroid_mz, use_subelements ):
in_type = pms.FileHandler.getType(in_file)
protein_ids = []
peptide_ids = []
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()
def link(in_files, out_file, keep_subelements, params):
in_types = set(pms.FileHandler.getType(in_) for in_ in in_files)
if in_types == set((pms.Type.CONSENSUSXML,)):
link_features = False
elif in_types == set((pms.Type.FEATUREXML,)):
link_features = True
else:
raise Exception("different kinds of input files")
algorithm_parameters = params.copy("algorithm:", True)
algorithm = pms.FeatureGroupingAlgorithmQT()
algorithm.setParameters(algorithm_parameters)
out_map = pms.ConsensusMap()
fds = out_map.getColumnHeaders()
if link_features:
f = pms.FeatureXMLFile()
maps = []
for i, in_file in enumerate(in_files):
map_ = pms.FeatureMap()
f.load(in_file, map_)
# set filedescriptions
fd = fds.get(i, pms.ColumnHeader())
fd.filename = in_file
fd.size = map_.size()
fd.unique_id = map_.getUniqueId()
fds[i] = fd
maps.append(map_)
out_map.setColumnHeaders(fds)
f.load(in_file, map_)
# set filedescriptions
fd = fds.get(i, pms.ColumnHeader())
fd.filename = in_file
fd.size = map_.size()
fd.unique_id = map_.getUniqueId()
fds[i] = fd
maps.append(map_)
out_map.setColumnHeaders(fds)
algorithm.group(maps, out_map)
else:
f = pms.ConsensusXMLFile()
maps = []
for i, in_file in enumerate(in_files):
map_ = pms.ConsensusMap()
f.load(in_file, map_)
maps.append(map_)
algorithm.group(maps, out_map)
if not keep_subelements:
for i in range(len(in_files)):
# set filedescriptions
fd = fds.get(i, pms.ColumnHeader())
fd.filename = in_files[i]
fd.size = maps[i].size()
fd.unique_id = maps[i].getUniqueId()
fds[i] = fd
out_map.setColumnHeaders(fds)
else:
algorithm.transferSubelements(maps, out_map)
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