Example #1
0
/**
 * Compare the given query spectrum to all library spectra.  Create a
 * match for each and add to matches.
 */
void SearchLibrary::scoreMatches(Spectrum& s, deque<RefSpectrum*>& spectra,
                                 vector<Match>& matches ){
    Verbosity::debug("Scoring %d matches.", spectra.size());
    // get the charge states we will search
    const vector<int>& charges = s.getPossibleCharges();
    
    // compare all ref spec to query, create match for each
    for(size_t i=0; i< spectra.size(); i++) {
        // is there a better place to check this?
        if(spectra.at(i)->getNumProcessedPeaks() == 0 ){ 
            Verbosity::debug("Skipping library spectrum %d.  No peaks.", 
                             spectra.at(i)->getLibSpecID());
            continue;
        }
        
        if( ! checkCharge(charges, spectra.at(i)->getCharge()) ){
            continue;
        }
        
        Match thisMatch(&s, spectra.at(i));  
        
        thisMatch.setMatchLibID(spectra.at(i)->getLibID());
        
        Verbosity::comment(V_ALL, "Comparing query spec %d and library spec %d",
                           s.getScanNumber(), spectra.at(i)->getLibSpecID());
        
        DotProduct::compare(thisMatch); //static method
        
        // save match for reporting
        matches.push_back(thisMatch);
    }  
}
Example #2
0
/**
 * 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);
        } */
    }
}