Exemplo n.º 1
0
void FidoInterface::computeProbabilities(const std::string& fname) {
  ifstream fin;
  if (fname.size() > 0) {
    fin.open(fname.c_str());
    proteinGraph_->read(fin);
  } else {
    proteinGraph_->read(peptideScores_);
  }
  
  if (trivialGrouping_) updateTargetDecoySizes();
  
  time_t startTime;
  clock_t startClock;
  time(&startTime);
  startClock = clock();
  
  if (mayufdr) {
    computeFDR();
  }
  
  if (doGridSearch_) {
    if (VERB > 1) {
      std::cerr << "The parameters for the model will be estimated by grid search.\n" << std::endl;
    }
    
    if (kOptimizeParams)
      gridSearchOptimize(); 
    else
      gridSearch();
    
    time_t procStart;
    clock_t procStartClock = clock();
    time(&procStart);
    double diff = difftime(procStart, startTime);
    if (VERB > 1) cerr << "Estimating the parameters took : "
      << ((double)(procStartClock - startClock)) / (double)CLOCKS_PER_SEC
      << " cpu seconds or " << diff << " seconds wall time" << endl;
  }

  if (VERB > 1) {
    cerr << "The following parameters have been chosen:\n";
    std::cerr.precision(10);
    cerr << "alpha = " << alpha_ << endl;
    cerr << "beta  = " << beta_ << endl;
    cerr << "gamma = " << gamma_ << endl;
    std::cerr.unsetf(std::ios::floatfield);
    cerr << "\nProtein level probabilities will now be estimated\n";
  }


  if (gridSearchThreshold_ > 0.0 && doGridSearch_) {
    //NOTE reset the tree after grid searching
    proteinGraph_->setProteinThreshold(proteinThreshold_);
    proteinGraph_->setPsmThreshold(kPsmThreshold);
    proteinGraph_->setPeptideThreshold(kPeptideThreshold);
    proteinGraph_->setNoClustering(noClustering_);
    proteinGraph_->setNoPartitioning(noPartitioning_);
    proteinGraph_->setNoPruning(noPruning_);
    proteinGraph_->setTrivialGrouping(trivialGrouping_);
    proteinGraph_->setMultipleLabeledPeptides(kAddPeptideDecoyLabel);
    
    if (fname.size() > 0) {
      proteinGraph_->read(fin);
    } else {
      proteinGraph_->read(peptideScores_);
    }
    if (trivialGrouping_) updateTargetDecoySizes();
  }
  
  proteinGraph_->setAlphaBetaGamma(alpha_, beta_, gamma_);
  proteinGraph_->getProteinProbs();
  pepProteinMap_.clear();
  proteinGraph_->getProteinProbsPercolator(pepProteinMap_);
}
Exemplo n.º 2
0
//NOTE almost entirely duplicated of computeProbabilities, it could be refactored
void FidoInterface::computeProbabilitiesFromFile(ifstream &fin)
{
  
  proteinGraph->read(fin);
  
  time_t startTime;
  clock_t startClock;
  time(&startTime);
  startClock = clock();
  
  if(mayufdr)
  {
    computeFDR();
  }
  
  if(dogridSearch) 
  {
    if(VERB > 1) 
    {
      std::cerr << "The parameters for the model will be estimated by grid search.\n" << std::endl;
    }
    
    if(optimize)
      gridSearchOptimize(); 
    else
      gridSearch();
    
    time_t procStart;
    clock_t procStartClock = clock();
    time(&procStart);
    double diff = difftime(procStart, startTime);
    if (VERB > 1) cerr << "Estimating the parameters took : "
      << ((double)(procStartClock - startClock)) / (double)CLOCKS_PER_SEC
      << " cpu seconds or " << diff << " seconds wall time" << endl;
  }

  if(VERB > 1) 
  {
      cerr << "The following parameters have been chosen:\n";
      std::cerr.precision(10);
      cerr << "gamma = " << gamma << endl;
      cerr << "alpha = " << alpha << endl;
      cerr << "beta  = " << beta << endl;
      std::cerr.unsetf(std::ios::floatfield);
      cerr << "\nProtein level probabilities will now be estimated";
  }


  if(dogridSearch && reduceTree)
  {
    //NOTE lets create the tree again with all the members
    double local_protein_threshold = proteinThreshold;
    if(truncate) local_protein_threshold = 0.0;
    proteinGraph->setProteinThreshold(local_protein_threshold);
    proteinGraph->setPsmThreshold(psmThreshold);
    proteinGraph->setPeptideThreshold(peptideThreshold);
    proteinGraph->setGroupProteins(nogroupProteins);
    proteinGraph->setSeparateProteins(noseparate);
    proteinGraph->setPruneProteins(noprune);
    proteinGraph->setMultipleLabeledPeptides(allow_multiple_labeled_peptides);
    proteinGraph->read(fin);
  }
  
  proteinGraph->setAlphaBetaGamma(alpha,beta,gamma);
  proteinGraph->getProteinProbs();
  pepProteins.clear();
  proteinGraph->getProteinProbsPercolator(pepProteins);
}