本文整理汇总了C++中ConsensusMap类的典型用法代码示例。如果您正苦于以下问题:C++ ConsensusMap类的具体用法?C++ ConsensusMap怎么用?C++ ConsensusMap使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了ConsensusMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: includeMSMSPeptides_
//TODO include run information for each peptide
//includes all MSMS derived peptides into the graph --consensusXML
Size ProteinResolver::includeMSMSPeptides_(ConsensusMap & consensus, vector<PeptideEntry> & peptide_nodes)
{
Size found_peptide = 0;
for (Size pep = 0; pep != consensus.size(); ++pep)
{
ConsensusFeature & feature = consensus.at(pep);
// get all peptide identifications
const vector<PeptideIdentification> & pep_id = feature.getPeptideIdentifications();
for (Size cons_pep = 0; cons_pep < pep_id.size(); ++cons_pep)
{
String seq = pep_id.at(cons_pep).getHits().front().getSequence().toUnmodifiedString();
Size peptide_entry = findPeptideEntry_(seq, peptide_nodes);
if (peptide_entry != peptide_nodes.size())
{
if (!peptide_nodes.at(peptide_entry).experimental)
{
++found_peptide;
}
//should be changed -- for consensus peptide_identification is the consensus and peptide_hit is the PeptideIdentification. PeptideHit is only top hit at the moment
peptide_nodes.at(peptide_entry).peptide_identification = pep;
peptide_nodes.at(peptide_entry).peptide_hit = cons_pep; //only top hit is used at the moment
peptide_nodes.at(peptide_entry).experimental = true;
// get intensity of the feature
peptide_nodes.at(peptide_entry).intensity = feature.getIntensity();
peptide_nodes.at(peptide_entry).origin = feature.getMetaValue("file_origin");
}
}
}
return found_peptide;
}
示例2: main_
ExitCodes main_(int, const char **)
{
String in = getStringOption_("in"), out = getStringOption_("out");
FileTypes::Type in_type = FileHandler::getType(in);
if (in_type == FileTypes::FEATUREXML)
{
FeatureMap<> features;
FeatureXMLFile().load(in, features);
for (FeatureMap<>::Iterator feat_it = features.begin();
feat_it != features.end(); ++feat_it)
{
resolveConflict_(feat_it->getPeptideIdentifications());
}
addDataProcessing_(features,
getProcessingInfo_(DataProcessing::FILTERING));
FeatureXMLFile().store(out, features);
}
else // consensusXML
{
ConsensusMap consensus;
ConsensusXMLFile().load(in, consensus);
for (ConsensusMap::Iterator cons_it = consensus.begin();
cons_it != consensus.end(); ++cons_it)
{
resolveConflict_(cons_it->getPeptideIdentifications());
}
addDataProcessing_(consensus,
getProcessingInfo_(DataProcessing::FILTERING));
ConsensusXMLFile().store(out, consensus);
}
return EXECUTION_OK;
}
示例3: point
void SeedListGenerator::generateSeedLists(const ConsensusMap& consensus,
Map<UInt64, SeedList>& seed_lists)
{
seed_lists.clear();
// iterate over all consensus features...
for (ConsensusMap::ConstIterator cons_it = consensus.begin();
cons_it != consensus.end(); ++cons_it)
{
DPosition<2> point(cons_it->getRT(), cons_it->getMZ());
// for each sub-map in the consensus map, add a seed at the position of
// this consensus feature:
for (ConsensusMap::FileDescriptions::const_iterator file_it =
consensus.getFileDescriptions().begin(); file_it !=
consensus.getFileDescriptions().end(); ++file_it)
seed_lists[file_it->first].push_back(point);
// for each feature contained in the consensus feature, remove the seed of
// the corresponding map:
for (ConsensusFeature::HandleSetType::const_iterator feat_it =
cons_it->getFeatures().begin(); feat_it !=
cons_it->getFeatures().end(); ++feat_it)
{
seed_lists[feat_it->getMapIndex()].pop_back();
}
// this leaves seeds for maps where no feature was found near the
// consensus position
}
}
示例4: if
boost::shared_ptr<IsobaricQuantitationMethod> IBSpectraFile::guessExperimentType_(const ConsensusMap& cm)
{
if (cm.getExperimentType() != "labeled_MS2" && cm.getExperimentType() != "itraq")
{
throw Exception::InvalidParameter(__FILE__,
__LINE__,
__PRETTY_FUNCTION__,
"Given ConsensusMap does not hold any isobaric quantification data.");
}
// we take the mapcount as approximation
if (cm.getFileDescriptions().size() == 4)
{
return boost::shared_ptr<IsobaricQuantitationMethod>(new ItraqFourPlexQuantitationMethod);
}
else if (cm.getFileDescriptions().size() == 6)
{
return boost::shared_ptr<IsobaricQuantitationMethod>(new TMTSixPlexQuantitationMethod);
}
else if (cm.getFileDescriptions().size() == 8)
{
return boost::shared_ptr<IsobaricQuantitationMethod>(new ItraqEightPlexQuantitationMethod);
}
else
{
throw Exception::InvalidParameter(__FILE__,
__LINE__,
__PRETTY_FUNCTION__,
"Could not guess isobaric quantification data from ConsensusMap due to non-matching number of input maps.");
}
}
示例5: input
void MapAlignmentAlgorithmPoseClustering::align(const ConsensusMap & map, TransformationDescription & trafo)
{
// TODO: move this to updateMembers_? (if consensusMap prevails)
// TODO: why does superimposer work on consensus map???
const ConsensusMap & map_model = reference_;
ConsensusMap map_scene = map;
// run superimposer to find the global transformation
TransformationDescription si_trafo;
superimposer_.run(map_model, map_scene, si_trafo);
// apply transformation to consensus features and contained feature
// handles
for (Size j = 0; j < map_scene.size(); ++j)
{
//Calculate new RT
double rt = map_scene[j].getRT();
rt = si_trafo.apply(rt);
//Set RT of consensus feature centroid
map_scene[j].setRT(rt);
//Set RT of consensus feature handles
map_scene[j].begin()->asMutable().setRT(rt);
}
//run pairfinder to find pairs
ConsensusMap result;
//TODO: add another 2map interface to pairfinder?
std::vector<ConsensusMap> input(2);
input[0] = map_model;
input[1] = map_scene;
pairfinder_.run(input, result);
// calculate the local transformation
si_trafo.invert(); // to undo the transformation applied above
TransformationDescription::DataPoints data;
for (ConsensusMap::Iterator it = result.begin(); it != result.end();
++it)
{
if (it->size() == 2) // two matching features
{
ConsensusFeature::iterator feat_it = it->begin();
double y = feat_it->getRT();
double x = si_trafo.apply((++feat_it)->getRT());
// one feature should be from the reference map:
if (feat_it->getMapIndex() != 0)
{
data.push_back(make_pair(x, y));
}
else
{
data.push_back(make_pair(y, x));
}
}
}
trafo = TransformationDescription(data);
trafo.fitModel("linear");
}
示例6: feat_lookup
void FeatureGroupingAlgorithm::transferSubelements(const vector<ConsensusMap>& maps, ConsensusMap& out) const
{
// accumulate file descriptions from the input maps:
// cout << "Updating file descriptions..." << endl;
out.getFileDescriptions().clear();
// mapping: (map index, original id) -> new id
map<pair<Size, UInt64>, Size> mapid_table;
for (Size i = 0; i < maps.size(); ++i)
{
const ConsensusMap& consensus = maps[i];
for (ConsensusMap::FileDescriptions::const_iterator desc_it = consensus.getFileDescriptions().begin(); desc_it != consensus.getFileDescriptions().end(); ++desc_it)
{
Size counter = mapid_table.size();
mapid_table[make_pair(i, desc_it->first)] = counter;
out.getFileDescriptions()[counter] = desc_it->second;
}
}
// look-up table: input map -> unique ID -> consensus feature
// cout << "Creating look-up table..." << endl;
vector<map<UInt64, ConsensusMap::ConstIterator> > feat_lookup(maps.size());
for (Size i = 0; i < maps.size(); ++i)
{
const ConsensusMap& consensus = maps[i];
for (ConsensusMap::ConstIterator feat_it = consensus.begin();
feat_it != consensus.end(); ++feat_it)
{
// do NOT use "id_lookup[i][feat_it->getUniqueId()] = feat_it;" here as
// you will get "attempt to copy-construct an iterator from a singular
// iterator" in STL debug mode:
feat_lookup[i].insert(make_pair(feat_it->getUniqueId(), feat_it));
}
}
// adjust the consensus features:
// cout << "Adjusting consensus features..." << endl;
for (ConsensusMap::iterator cons_it = out.begin(); cons_it != out.end(); ++cons_it)
{
ConsensusFeature adjusted = ConsensusFeature(
static_cast<BaseFeature>(*cons_it)); // remove sub-features
for (ConsensusFeature::HandleSetType::const_iterator sub_it = cons_it->getFeatures().begin(); sub_it != cons_it->getFeatures().end(); ++sub_it)
{
UInt64 id = sub_it->getUniqueId();
Size map_index = sub_it->getMapIndex();
ConsensusMap::ConstIterator origin = feat_lookup[map_index][id];
for (ConsensusFeature::HandleSetType::const_iterator handle_it = origin->getFeatures().begin(); handle_it != origin->getFeatures().end(); ++handle_it)
{
FeatureHandle handle = *handle_it;
Size new_id = mapid_table[make_pair(map_index, handle.getMapIndex())];
handle.setMapIndex(new_id);
adjusted.insert(handle);
}
}
*cons_it = adjusted;
}
}
示例7: main_
ExitCodes main_(int, const char **) override
{
String in = getStringOption_("in");
String out = getStringOption_("out");
String algo_type = getStringOption_("algorithm_type");
String acc_filter = getStringOption_("accession_filter");
String desc_filter = getStringOption_("description_filter");
double ratio_threshold = getDoubleOption_("ratio_threshold");
ConsensusXMLFile infile;
infile.setLogType(log_type_);
ConsensusMap map;
infile.load(in, map);
//map normalization
if (algo_type == "robust_regression")
{
map.sortBySize();
vector<double> results = ConsensusMapNormalizerAlgorithmThreshold::computeCorrelation(map, ratio_threshold, acc_filter, desc_filter);
ConsensusMapNormalizerAlgorithmThreshold::normalizeMaps(map, results);
}
else if (algo_type == "median")
{
ConsensusMapNormalizerAlgorithmMedian::normalizeMaps(map, ConsensusMapNormalizerAlgorithmMedian::NM_SCALE, acc_filter, desc_filter);
}
else if (algo_type == "median_shift")
{
ConsensusMapNormalizerAlgorithmMedian::normalizeMaps(map, ConsensusMapNormalizerAlgorithmMedian::NM_SHIFT, acc_filter, desc_filter);
}
else if (algo_type == "quantile")
{
if (acc_filter != "" || desc_filter != "")
{
LOG_WARN << endl << "NOTE: Accession / description filtering is not supported in quantile normalization mode. Ignoring filters." << endl << endl;
}
ConsensusMapNormalizerAlgorithmQuantile::normalizeMaps(map);
}
else
{
cerr << "Unknown algorithm type '" << algo_type.c_str() << "'." << endl;
return ILLEGAL_PARAMETERS;
}
//annotate output with data processing info and save output file
addDataProcessing_(map, getProcessingInfo_(DataProcessing::NORMALIZATION));
infile.store(out, map);
return EXECUTION_OK;
}
示例8: transformSingleConsensusMap
void MapAlignmentTransformer::transformSingleConsensusMap(ConsensusMap & cmap,
const TransformationDescription & trafo)
{
for (ConsensusMap::Iterator cmit = cmap.begin(); cmit != cmap.end();
++cmit)
{
applyToConsensusFeature_(*cmit, trafo);
}
// adapt RT values of unassigned peptides:
if (!cmap.getUnassignedPeptideIdentifications().empty())
{
transformSinglePeptideIdentification(
cmap.getUnassignedPeptideIdentifications(), trafo);
}
}
示例9: normalizeMaps
void ConsensusMapNormalizerAlgorithmThreshold::normalizeMaps(ConsensusMap& map, const vector<double>& ratios)
{
ConsensusMap::Iterator cf_it;
ProgressLogger progresslogger;
progresslogger.setLogType(ProgressLogger::CMD);
progresslogger.startProgress(0, map.size(), "normalizing maps");
for (cf_it = map.begin(); cf_it != map.end(); ++cf_it)
{
progresslogger.setProgress(cf_it - map.begin());
ConsensusFeature::HandleSetType::const_iterator f_it;
for (f_it = cf_it->getFeatures().begin(); f_it != cf_it->getFeatures().end(); ++f_it)
{
f_it->asMutable().setIntensity(f_it->getIntensity() * ratios[f_it->getMapIndex()]);
}
}
progresslogger.endProgress();
}
示例10: ConsensusXMLFile
void QuantitativeExperimentalDesign::mergeConsensusMaps_(ConsensusMap & out, const String & experiment, StringList & file_paths)
{
ConsensusMap map;
LOG_INFO << "Merge consensus maps: " << endl;
UInt counter = 1;
for (StringList::Iterator file_it = file_paths.begin(); file_it != file_paths.end(); ++file_it, ++counter)
{
//load should clear the map
ConsensusXMLFile().load(*file_it, map);
for (ConsensusMap::iterator it = map.begin(); it != map.end(); ++it)
{
it->setMetaValue("experiment", DataValue(experiment));
}
out += map;
}
LOG_INFO << endl;
}
示例11: setNormalizedIntensityValues
void ConsensusMapNormalizerAlgorithmQuantile::setNormalizedIntensityValues(const vector<vector<double> >& feature_ints, ConsensusMap& map)
{
//assumes the input map and feature_ints are in the same order as in the beginning,
//although feature_ints has normalized values now (but the same ranks as before)
Size number_of_maps = map.getColumnHeaders().size();
ConsensusMap::ConstIterator cf_it;
vector<Size> progress_indices(number_of_maps);
for (cf_it = map.begin(); cf_it != map.end(); ++cf_it)
{
ConsensusFeature::HandleSetType::const_iterator f_it;
for (f_it = cf_it->getFeatures().begin(); f_it != cf_it->getFeatures().end(); ++f_it)
{
Size map_idx = f_it->getMapIndex();
double intensity = feature_ints[map_idx][progress_indices[map_idx]++];
f_it->asMutable().setIntensity(intensity);
}
}
}
示例12: mapFiles2Design_
void QuantitativeExperimentalDesign::applyDesign2Quantifier(PeptideAndProteinQuant & quantifier, TextFile & file, StringList & file_paths)
{
// vector< pair<PeptideAndProteinQuant::PeptideData,PeptideAndProteinQuant::ProteinQuant> >& result)
//create mapping from experimental setting to all respective file names
map<String, StringList> design2FileBaseName;
mapFiles2Design_(design2FileBaseName, file);
//filter out all non-existing files
map<String, StringList> design2FilePath;
findRelevantFilePaths_(design2FileBaseName, design2FilePath, file_paths);
//determine wether we deal with idXML or featureXML
FileTypes::Type in_type = FileHandler::getType(file_paths.front());
if (in_type == FileTypes::FEATUREXML)
{
FeatureMap<> features;
for (map<String, StringList>::iterator iter = design2FilePath.begin(); iter != design2FilePath.end(); ++iter)
{
mergeFeatureMaps_(features, iter->first, iter->second);
}
LOG_INFO << "Number of proteinIdentifications: " << features.getProteinIdentifications().size() << endl;
ProteinIdentification & proteins = features.getProteinIdentifications()[0];
quantifier.quantifyPeptides(features);
quantifier.quantifyProteins(proteins);
}
else
{
ConsensusMap consensus;
for (map<String, StringList>::iterator iter = design2FilePath.begin(); iter != design2FilePath.end(); ++iter)
{
mergeConsensusMaps_(consensus, iter->first, iter->second);
}
LOG_INFO << "Number of proteinIdentifications: " << consensus.getProteinIdentifications().size() << endl;
ProteinIdentification & proteins = consensus.getProteinIdentifications()[0];
quantifier.quantifyPeptides(consensus);
quantifier.quantifyProteins(proteins);
}
}
示例13: store
void EDTAFile::store(const String& filename, const ConsensusMap& map) const
{
TextFile tf;
// search for maximum number of sub-features (since this determines the number of columns)
Size max_sub(0);
for (Size i = 0; i < map.size(); ++i)
{
max_sub = std::max(max_sub, map[i].getFeatures().size());
}
// write header
String header("RT\tm/z\tintensity\tcharge");
for (Size i = 1; i <= max_sub; ++i)
{
header += "\tRT" + String(i) + "\tm/z" + String(i) + "\tintensity" + String(i) + "\tcharge" + String(i);
}
tf.addLine(header);
for (Size i = 0; i < map.size(); ++i)
{
ConsensusFeature f = map[i];
// consensus
String entry = String(f.getRT()) + "\t" + f.getMZ() + "\t" + f.getIntensity() + "\t" + f.getCharge();
// sub-features
ConsensusFeature::HandleSetType handle = f.getFeatures();
for (ConsensusFeature::HandleSetType::const_iterator it = handle.begin(); it != handle.end(); ++it)
{
entry += String("\t") + it->getRT() + "\t" + it->getMZ() + "\t" + it->getIntensity() + "\t" + it->getCharge();
}
// missing sub-features
for (Size j = handle.size(); j < max_sub; ++j)
{
entry += "\tNA\tNA\tNA\tNA";
}
tf.addLine(entry);
}
tf.store(filename);
}
示例14: infer
void ProteinInference::infer(ConsensusMap & consensus_map, const UInt reference_map)
{
// we infer Proteins for every IdentificationRun separately. If you want this combined, then
// do that before calling this function
// Each ProteinIdentification will be augmented with the quantification (where possible)
for (size_t i = 0;
i < consensus_map.getProteinIdentifications().size();
++i)
{
infer_(consensus_map, i, reference_map);
}
}
示例15: add
void MetaDataBrowser::add(ConsensusMap & map)
{
//identifier
add(static_cast<DocumentIdentifier &>(map));
// protein identifications
for (Size i = 0; i < map.getProteinIdentifications().size(); ++i)
{
add(map.getProteinIdentifications()[i]);
}
//unassigned peptide ids
for (Size i = 0; i < map.getUnassignedPeptideIdentifications().size(); ++i)
{
add(map.getUnassignedPeptideIdentifications()[i]);
}
add(static_cast<MetaInfoInterface &>(map));
treeview_->expandItem(treeview_->findItems(QString::number(0), Qt::MatchExactly, 1).first());
}