本文整理汇总了C++中Peak::setCharge方法的典型用法代码示例。如果您正苦于以下问题:C++ Peak::setCharge方法的具体用法?C++ Peak::setCharge怎么用?C++ Peak::setCharge使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Peak
的用法示例。
在下文中一共展示了Peak::setCharge方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mergePeakLists_
//Merge Peaklists merge_lower and merge_upper
void PeakListCollection::mergePeakLists_(unsigned int merge_lower, unsigned int merge_upper, std::vector<PeakList>& c,
double drt, double dmz, double dz, double dint = 0.)
{
PeakList newPeakList; //Peaklists will be merged into newPeakList
std::vector<map_item> newCorrespondenceMapColumn; //correspondenceMap information will be merged in here
//get assignments via StableMarriage
StableMarriage sm(c[merge_lower], c[merge_upper], drt, dmz, dz, dint);
//set limit: do not assign Peaks with distance larger than 1. Note: normalization constants
//drt and dmz must be adjusted properly.
sm.setLimit(1.);
StableMarriage::Assignment assign = sm.getAssignment();
//process peaks with a partner
for(unsigned int i = 0; i < assign.ass12.size(); i++){
if(assign.ass12[i] > -1){
//write matched Peaks into newPeaklist
//calculate average Rt, Mz and Intensity values
//Peak1: PL: merge_lower ; Item: i ; plContent: correspondenceMap_[merge_lower][i].size()
//Peak2: PL: merge_upper ; Item: assign.ass12[i] ; plContent: correspondenceMap_[merge_upper][assign.ass12[i]].size()
//Number of peaks merged into single peak = size of originInformation vector
double plc_lower = correspondenceMap_[merge_lower][i].size();
double plc_upper = correspondenceMap_[merge_upper][assign.ass12[i]].size();
double avRt = (c[merge_lower][i].getRt()*plc_lower +
c[merge_upper][assign.ass12[i]].getRt()*plc_upper) /
(plc_lower + plc_upper);
double avMz = (c[merge_lower][i].getMz()*plc_lower +
c[merge_upper][assign.ass12[i]].getMz()*plc_upper) /
(plc_lower + plc_upper);
double avInt = (c[merge_lower][i].getAbundance()*plc_lower +
c[merge_upper][assign.ass12[i]].getAbundance()*plc_upper) /
(plc_lower + plc_upper);
//create temporary peak and fill with averaged values
Peak temp;
temp.setCharge(c[merge_lower][i].getCharge()); //charge is assumed to be equal
temp.setRt(avRt);
temp.setMz(avMz);
temp.setAbundance(avInt);
//add temporary peak to peaklist
newPeakList.push_back(temp);
//write origin information of matched peaks
map_item tempItem;
//copy all origin information from merge_lower
for(unsigned int j = 0; j < correspondenceMap_[merge_lower][i].size(); j++){
tempItem.push_back(correspondenceMap_[merge_lower][i][j]);
}
//copy all origin information from merge_upper
for(unsigned int j = 0; j < correspondenceMap_[merge_upper][assign.ass12[i]].size(); j++){
tempItem.push_back(correspondenceMap_[merge_upper][assign.ass12[i]][j]);
}
//add item to column
newCorrespondenceMapColumn.push_back(tempItem);
}
}
//process PeakList merge_lower
for(unsigned int i = 0; i < assign.ass12.size(); i++){
if(assign.ass12[i] == -1){
newPeakList.push_back(c[merge_lower][i]);
map_item tempItem;
//copy all origin information
for(unsigned int j = 0; j < correspondenceMap_[merge_lower][i].size(); j++){
tempItem.push_back(correspondenceMap_[merge_lower][i][j]);
}
newCorrespondenceMapColumn.push_back(tempItem);
}
}
//process PeakList merge_upper
for(unsigned int i = 0; i < assign.ass21.size(); i++){
if(assign.ass21[i] == -1){
newPeakList.push_back(c[merge_upper][i]);
map_item tempItem;
//copy all origin information
for(unsigned int j = 0; j < correspondenceMap_[merge_upper][i].size(); j++){
tempItem.push_back(correspondenceMap_[merge_upper][i][j]);
}
newCorrespondenceMapColumn.push_back(tempItem);
//.........这里部分代码省略.........