当前位置: 首页>>代码示例>>C++>>正文


C++ Peak::setAbundance方法代码示例

本文整理汇总了C++中Peak::setAbundance方法的典型用法代码示例。如果您正苦于以下问题:C++ Peak::setAbundance方法的具体用法?C++ Peak::setAbundance怎么用?C++ Peak::setAbundance使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Peak的用法示例。


在下文中一共展示了Peak::setAbundance方法的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);
//.........这里部分代码省略.........
开发者ID:hroest,项目名称:sima,代码行数:101,代码来源:PeakListCollection.cpp


注:本文中的Peak::setAbundance方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。