本文整理汇总了C++中boost::ptr_vector::front方法的典型用法代码示例。如果您正苦于以下问题:C++ ptr_vector::front方法的具体用法?C++ ptr_vector::front怎么用?C++ ptr_vector::front使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类boost::ptr_vector
的用法示例。
在下文中一共展示了ptr_vector::front方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: result
void SnpEstimation::result(const boost::ptr_vector<Snp> &snpList, const boost::ptr_vector<Region> ®ionList){
bool sign = !(snpList.front().getSign()==0);
double i2 = (m_bt)? usefulTools::dnorm(usefulTools::qnorm(m_prevalence))/(m_prevalence): 0;
i2 = i2*i2;
double adjust = 0.0;
size_t countNum = 0;
double sampleSize = 0.0;
std::vector<double> heritability;
std::vector<double> variance;
std::vector<double> effective;
for(size_t i = 0; i < regionList.size(); ++i){
// add stuff
heritability.push_back(0.0);
variance.push_back(regionList[i].getVariance());
effective.push_back(0.0);
}
std::ofstream fullOutput;
bool requireFullOut = false;
if(!m_output.empty()) requireFullOut = true;
if(requireFullOut){
std::string fullOutName = m_output;
fullOutName.append(".res");
fullOutput.open(fullOutName.c_str());
if(!fullOutput.is_open()){
requireFullOut = false;
fprintf(stderr, "Cannot access output file: %s\n", fullOutName.c_str());
fprintf(stderr, "Will only provide basic output\n");
}
else{
fullOutput << "Chr\tLoc\trsID\tZ\tF\tH\tStatus" << std::endl;
}
}
for(size_t i = 0; i < snpList.size(); ++i){
if(requireFullOut){
fullOutput << snpList[i].getChr() << "\t" << snpList[i].getLoc() << "\t" << snpList[i].getRs() << "\t" << snpList[i].getTStat() << "\t"<< snpList[i].getFStat() << "\t" << snpList[i].getHeritability() << "\t" << snpList[i].getStatus() << std::endl;
}
for(size_t j = 0; j < regionList.size(); ++j){
// if(j ==0) std::cerr << snpList[i].flag(j) << std::endl;
if(snpList[i].flag(j)) heritability[j]+=snpList[i].getHeritability();
if(snpList[i].flag(j)) effective[j] += snpList[i].getEffective();
}
sampleSize +=(double)(snpList[i].getSampleSize());
countNum++;
if(m_bt){
double portionCase = (double)(snpList[i].getNCase()) / (double)(snpList[i].getSampleSize());
adjust+= ((1.0-m_prevalence)*(1.0-m_prevalence))/(i2*portionCase*(1-portionCase));
}
}
if(requireFullOut) fullOutput.close();
double adjustment = adjust/(double)countNum; // we use the average adjustment value here
if(!m_bt) adjustment = m_extreme;
double averageSampleSize = sampleSize/(double)countNum;
if(!m_output.empty()) requireFullOut =true;
std::ofstream sumOut;
if(requireFullOut){
std::string sumOutName = m_output;
sumOutName.append(".sum");
sumOut.open(sumOutName.c_str());
if(!sumOut.is_open()){
fprintf(stderr, "Cannot access output file %s\n", sumOutName.c_str());
fprintf(stderr, "Will output to stdout instead\n");
requireFullOut=false;
}
}
// We separate it, because it is possible for the previous if to change the requireFullOut flag
if(!requireFullOut){
// Only output to the stdout
std::cout << "Region\tHeritability\tVariance" << std::endl;
for(size_t i = 0; i < regionList.size(); ++i){
std::cout << regionList[i].getName() << "\t" << adjustment*heritability[i] << "\t";
if(!sign) std::cout << adjustment*(2.0*(effective[i]*adjustment*adjustment+2.0*adjustment*heritability[i]*averageSampleSize)/(averageSampleSize*averageSampleSize)) << std::endl;
else std::cout << adjustment*adjustment*variance[i] << std::endl;
}
}
else{
sumOut << "Region\tHeritability\tVariance" << std::endl;
std::cout << "Region\tHeritability\tVariance" << std::endl;
for(size_t i = 0; i < regionList.size(); ++i){
sumOut << regionList[i].getName() << "\t" << adjustment*heritability[i] << "\t";
std::cout << regionList[i].getName() << "\t" << heritability[i] << "\t";
if(!sign){ // We use effective number
sumOut << adjustment*(2.0*(effective[i]*adjustment*adjustment+2.0*adjustment*heritability[i]*averageSampleSize)/(averageSampleSize*averageSampleSize)) << std::endl;
std::cout << adjustment*(2.0*(effective[i]*adjustment*adjustment+2.0*adjustment*heritability[i]*averageSampleSize)/(averageSampleSize*averageSampleSize)) << std::endl;
}
else{
sumOut << adjustment*adjustment*variance[i] << std::endl;
std::cout << adjustment*adjustment*variance[i] << std::endl;
}
}
sumOut.close();
}
}