// assumes at least one spectrum in allRefs void SearchLibrary::runSearch(Spectrum& s) { scoreMatches(s, cachedSpectra_, targetMatches_); scoreMatches(s, cachedDecoySpectra_, decoyMatches_); // keep scores from all target psms for estimating Weibull parameters vector<double> allScores; if(compute_pvalues_){ for(size_t i=0; i < targetMatches_.size(); i++){ double dotp = targetMatches_[i].getScore(DOTP); allScores.push_back(dotp); } } // there may have been spectra in cachedSpectra_ but none at the // correct charge state. Check again if( targetMatches_.size() == 0 ){ Verbosity::warn("No library spectra found for query %d " "(precursor m/z %.2f).", s.getScanNumber(), s.getMz()); return; } if( compute_pvalues_ ){ addNullScores(s, allScores); } // sort the matches descending sort(targetMatches_.begin(), targetMatches_.end(), compMatchDotScore); sort(decoyMatches_.begin(), decoyMatches_.end(), compMatchDotScore); setRank(); if( printAll_ ){ cout << "spec " << s.getScanNumber() << endl; } if( compute_pvalues_ ){ weibullEstimator_.estimateParams(allScores); // print params to file if( weibullParamFile_.is_open() ){ weibullParamFile_ << s.getScanNumber() << "\t" << weibullEstimator_.getEta() << "\t" << weibullEstimator_.getBeta() << "\t" << weibullEstimator_.getShift() << "\t" << weibullEstimator_.getCorrelation() << "\t" << weibullEstimator_.getNumPointsFit() //(int)(allScores.size() * fraction_to_fit_) << endl; } setMatchesPvalues(allScores.size()); } }
RefSpectrum::RefSpectrum(const Spectrum& s) { length = 0; annot = -1; copies = 1; id = -1; //or could do data = s.data and then change type and peaks data.type = REFERENCE; data.scanNumber = s.getScanNum(); data.mz = s.getMz(); data.numPeaks = s.getNumPeaks(); if(data.numPeaks) { data.peaks = new PEAK_T[data.numPeaks]; //add if(data.numPeaks?) s.getPeaks(data.peaks, data.numPeaks); } }
/** * Before searching each spectrum, set the appropriate precursor m/z * range and charge states. */ void SearchLibrary::initLibraries(Spectrum& querySpec){ // TODO: for cache, set min as max(cacheMax, searchMin) // max is still searchMax. charge is all charges // set the precursor m/z range and charge states in each library double minMZ = querySpec.getMz() - mzWindow_; double maxMZ = querySpec.getMz() + mzWindow_; for(size_t i = 0; i < libraries_.size(); i++){ LibReader* curLibrary = libraries_.at(i); curLibrary->setLowMZ(minMZ); curLibrary->setHighMZ(maxMZ); // set min and max charges to look for either by the query // charge or by the given parameters /* if( ignoreQueryCharge ){ ...use current else clause } else if*/ //if( querySpec.sizeZ() == 1 ){ const vector<int>& charges = querySpec.getPossibleCharges(); if( charges.size() == 1 ){ curLibrary->setCharge(charges.front()); } else { // TODO instead use min and max charge of query as range curLibrary->setLowChg(minSpecCharge_); curLibrary->setHighChg(maxSpecCharge_); curLibrary->setCharge(-1); // hack to say there is no one // charge } /* else { int min = 100; int max = 0; for(i=0; i < querySpec.sizeZ(); i++){ if( querySpec.atZ(i).z > max ) max = querySpec.atZ(i).z; } if( querySpec.atZ(i).z < min ) min = querySpec.atZ(i).z; } curLibrary->setLowChg(min); curLibrary->setHighChg(max); } */ } }
bool Spectrum::operator< (Spectrum otherSpec) { return data.mz < otherSpec.getMz(); }