本文整理汇总了C++中ConsensusFeature::setCharge方法的典型用法代码示例。如果您正苦于以下问题:C++ ConsensusFeature::setCharge方法的具体用法?C++ ConsensusFeature::setCharge怎么用?C++ ConsensusFeature::setCharge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ConsensusFeature
的用法示例。
在下文中一共展示了ConsensusFeature::setCharge方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: recomputeConsensus_
void BaseLabeler::recomputeConsensus_(const FeatureMapSim & simulated_features)
{
// iterate over all given features stored in the labeling consensus and try to find the corresponding feature in
// in the feature map
// build index for faster access
Map<String, IntList> id_map;
Map<UInt64, Size> features_per_labeled_map;
for (Size i = 0; i < simulated_features.size(); ++i)
{
if (simulated_features[i].metaValueExists("parent_feature"))
{
LOG_DEBUG << "Checking [" << i << "]: " << simulated_features[i].getPeptideIdentifications()[0].getHits()[0].getSequence().toString()
<< " with charge " << simulated_features[i].getCharge() << " (" << simulated_features[i].getMetaValue("charge_adducts") << ")"
<< " parent was " << simulated_features[i].getMetaValue("parent_feature") << std::endl;
id_map[simulated_features[i].getMetaValue("parent_feature")].push_back((Int)i);
UInt64 map_index = 0;
if (simulated_features[i].metaValueExists("map_index"))
{
map_index = simulated_features[i].getMetaValue("map_index");
}
++features_per_labeled_map[map_index];
}
}
for (Map<String, IntList>::iterator it = id_map.begin(); it != id_map.end(); ++it)
{
LOG_DEBUG << it->first << " " << it->second << std::endl;
}
// new consensus map
ConsensusMap new_cm;
// initialize submaps in consensus map
for (Map<UInt64, Size>::Iterator it = features_per_labeled_map.begin(); it != features_per_labeled_map.end(); ++it)
{
new_cm.getFileDescriptions()[it->first].size = it->second;
new_cm.getFileDescriptions()[it->first].unique_id = simulated_features.getUniqueId();
}
for (ConsensusMap::iterator cm_iter = consensus_.begin(); cm_iter != consensus_.end(); ++cm_iter)
{
bool complete = true;
LOG_DEBUG << "Checking consensus feature containing: " << std::endl;
// check if we have all elements of current CF in the new feature map (simulated_features)
for (ConsensusFeature::iterator cf_iter = (*cm_iter).begin(); cf_iter != (*cm_iter).end(); ++cf_iter)
{
complete &= id_map.has(String((*cf_iter).getUniqueId()));
LOG_DEBUG << "\t" << String((*cf_iter).getUniqueId()) << std::endl;
}
if (complete)
{
// get all elements sorted by charge state; since the same charge can be achieved by different
// adduct compositions we use the adduct-string as indicator to find the groups
Map<String, std::set<FeatureHandle, FeatureHandle::IndexLess> > charge_mapping;
for (ConsensusFeature::iterator cf_iter = (*cm_iter).begin(); cf_iter != (*cm_iter).end(); ++cf_iter)
{
IntList feature_indices = id_map[String((*cf_iter).getUniqueId())];
for (IntList::iterator it = feature_indices.begin(); it != feature_indices.end(); ++it)
{
UInt64 map_index = 0;
if (simulated_features[*it].metaValueExists("map_index"))
{
map_index = simulated_features[*it].getMetaValue("map_index");
}
if (charge_mapping.has(simulated_features[*it].getMetaValue("charge_adducts")))
{
charge_mapping[simulated_features[*it].getMetaValue("charge_adducts")].insert(FeatureHandle(map_index, simulated_features[*it]));
}
else
{
LOG_DEBUG << "Create new set with charge composition " << simulated_features[*it].getMetaValue("charge_adducts") << std::endl;
std::set<FeatureHandle, FeatureHandle::IndexLess> fh_set;
fh_set.insert(FeatureHandle(map_index, simulated_features[*it]));
charge_mapping.insert(std::make_pair(simulated_features[*it].getMetaValue("charge_adducts"), fh_set));
}
}
}
// create new consensus feature from derived features (separated by charge, if charge != 0)
for (Map<String, std::set<FeatureHandle, FeatureHandle::IndexLess> >::const_iterator charge_group_it = charge_mapping.begin();
charge_group_it != charge_mapping.end();
++charge_group_it)
{
ConsensusFeature cf;
cf.setCharge((*(*charge_group_it).second.begin()).getCharge());
cf.setMetaValue("charge_adducts", charge_group_it->first);
std::vector<PeptideIdentification> ids;
for (std::set<FeatureHandle, FeatureHandle::IndexLess>::const_iterator fh_it = (charge_group_it->second).begin(); fh_it != (charge_group_it->second).end(); ++fh_it)
{
cf.insert(*fh_it);
//.........这里部分代码省略.........
示例2: main_
//.........这里部分代码省略.........
else
{
swap(m_traces_final, split_mtraces);
}
}
//-------------------------------------------------------------
// writing consensus map output
//-------------------------------------------------------------
if (out_type == FileTypes::CONSENSUSXML)
{
ConsensusMap consensus_map;
StringList ms_runs;
ms_peakmap.getPrimaryMSRunPath(ms_runs);
consensus_map.setPrimaryMSRunPath(ms_runs);
for (Size i = 0; i < m_traces_final.size(); ++i)
{
if (m_traces_final[i].getSize() == 0) continue;
ConsensusFeature fcons;
int k = 0;
for (MassTrace::const_iterator it = m_traces_final[i].begin(); it != m_traces_final[i].end(); ++it)
{
FeatureHandle fhandle;
fhandle.setRT(it->getRT());
fhandle.setMZ(it->getMZ());
fhandle.setIntensity(it->getIntensity());
fhandle.setUniqueId(++k);
fcons.insert(fhandle);
}
fcons.setMetaValue(3, m_traces_final[i].getLabel());
fcons.setCharge(0);
fcons.setWidth(m_traces_final[i].estimateFWHM(use_epd));
fcons.setQuality(1 - (1.0 / m_traces_final[i].getSize()));
fcons.setRT(m_traces_final[i].getCentroidRT());
fcons.setMZ(m_traces_final[i].getCentroidMZ());
fcons.setIntensity(m_traces_final[i].getIntensity(false));
consensus_map.push_back(fcons);
}
consensus_map.applyMemberFunction(&UniqueIdInterface::setUniqueId);
addDataProcessing_(consensus_map, getProcessingInfo_(DataProcessing::QUANTITATION));
consensus_map.setUniqueId();
ConsensusXMLFile().store(out, consensus_map);
}
else //(out_type == FileTypes::FEATUREXML)
{
//-----------------------------------------------------------
// convert mass traces to features
//-----------------------------------------------------------
std::vector<double> stats_sd;
FeatureMap ms_feat_map;
StringList ms_runs;
ms_peakmap.getPrimaryMSRunPath(ms_runs);
ms_feat_map.setPrimaryMSRunPath(ms_runs);
for (Size i = 0; i < m_traces_final.size(); ++i)
{
if (m_traces_final[i].getSize() == 0) continue;
m_traces_final[i].updateMeanMZ();
m_traces_final[i].updateWeightedMZsd();
示例3: load
//.........这里部分代码省略.........
std::vector<String> parts;
input_it->split(separator, parts);
//abort if line does not contain enough fields
if (parts.size() < 3)
{
throw Exception::ParseError(__FILE__, __LINE__, __PRETTY_FUNCTION__, "",
String("Failed parsing in line ")
+ String((input_it - input.begin()) + 1)
+ ": At least three columns are needed! (got "
+ String(parts.size())
+ ")\nOffending line: '"
+ line_trimmed
+ "' (line "
+ String((input_it - input.begin()) + 1)
+ ")\n");
}
ConsensusFeature cf;
cf.setUniqueId();
try
{
// Convert values. Will return -1 if not available.
rt = checkedToDouble_(parts, 0);
mz = checkedToDouble_(parts, 1);
it = checkedToDouble_(parts, 2);
ch = checkedToInt_(parts, 3);
cf.setRT(rt);
cf.setMZ(mz);
cf.setIntensity(it);
if (input_type != TYPE_OLD_NOCHARGE)
cf.setCharge(ch);
}
catch (Exception::BaseException&)
{
throw Exception::ParseError(__FILE__, __LINE__, __PRETTY_FUNCTION__, "", String("Failed parsing in line ") + String((input_it - input.begin()) + 1) + ": Could not convert the first three columns to a number!\nOffending line: '" + line_trimmed + "' (line " + String((input_it - input.begin()) + 1) + ")\n");
}
// Check all features in one line
for (Size j = 1; j < input_features; ++j)
{
try
{
Feature f;
f.setUniqueId();
// Convert values. Will return -1 if not available.
rt = checkedToDouble_(parts, j * 4 + 0);
mz = checkedToDouble_(parts, j * 4 + 1);
it = checkedToDouble_(parts, j * 4 + 2);
ch = checkedToInt_(parts, j * 4 + 3);
// Only accept features with at least RT and MZ set
if (rt != -1 && mz != -1)
{
f.setRT(rt);
f.setMZ(mz);
f.setIntensity(it);
f.setCharge(ch);
cf.insert(j - 1, f);
}
}
catch (Exception::BaseException&)