virtual tribool less(const Spectrum& lhs,
                      const Spectrum& rhs) const
 {
     CVParam lhsMSLevel = lhs.cvParam(MS_ms_level);
     CVParam rhsMSLevel = rhs.cvParam(MS_ms_level);
     if (lhsMSLevel.empty() || rhsMSLevel.empty())
         return boost::logic::indeterminate;
     return lhsMSLevel.valueAs<int>() < rhsMSLevel.valueAs<int>();
 }
    virtual tribool accept(const Spectrum& spectrum) const
    {
        CVParam param = spectrum.cvParamChild(MS_spectrum_type);
        if (param.cvid == CVID_Unknown) return boost::logic::indeterminate;
        if (!cvIsA(param.cvid, MS_mass_spectrum))
            return true; // MS level filter doesn't affect non-MS spectra

        param = spectrum.cvParam(MS_ms_level);
        if (param.cvid == CVID_Unknown) return boost::logic::indeterminate;

        return (param.valueAs<int>() == 2);
    }
Example #3
0
PWIZ_API_DECL void SpectrumInfo::update(const Spectrum& spectrum, bool getBinaryData)
{
    *this = SpectrumInfo();
    clearBinaryData();

    id = spectrum.id;
    index = spectrum.index;
    scanNumber = id::valueAs<int>(spectrum.id, "scan");

    Scan dummy;
    const Scan& scan = spectrum.scanList.scans.empty() ? dummy : spectrum.scanList.scans[0];

    massAnalyzerType = CVID_Unknown;
    if (scan.instrumentConfigurationPtr.get())
        try
        {
            massAnalyzerType = scan.instrumentConfigurationPtr->componentList.analyzer(0)
                                        .cvParamChild(MS_mass_analyzer_type).cvid;
        }
        catch (out_of_range&)
        {
            // ignore out-of-range exception
        }

    scanEvent = scan.cvParam(MS_preset_scan_configuration).valueAs<int>(); 
    msLevel = spectrum.cvParam(MS_ms_level).valueAs<int>();
    isZoomScan = spectrum.hasCVParam(MS_zoom_scan);
    retentionTime = scan.cvParam(MS_scan_start_time).timeInSeconds();
    filterString = scan.cvParam(MS_filter_string).value;
    mzLow = spectrum.cvParam(MS_lowest_observed_m_z).valueAs<double>();        
    mzHigh = spectrum.cvParam(MS_highest_observed_m_z).valueAs<double>();        
    basePeakMZ = spectrum.cvParam(MS_base_peak_m_z).valueAs<double>();    
    basePeakIntensity = spectrum.cvParam(MS_base_peak_intensity).valueAs<double>();    
    totalIonCurrent = spectrum.cvParam(MS_total_ion_current).valueAs<double>();  
    ionInjectionTime = scan.cvParam(MS_ion_injection_time).valueAs<double>();

    UserParam userParamMonoisotopicMZ = scan.userParam("[Thermo Trailer Extra]Monoisotopic M/Z:");
    if (!userParamMonoisotopicMZ.name.empty())
        thermoMonoisotopicMZ = userParamMonoisotopicMZ.valueAs<double>();        
 
    for (vector<Precursor>::const_iterator it=spectrum.precursors.begin(); it!=spectrum.precursors.end(); ++it)
    {
        PrecursorInfo precursorInfo;
        precursorInfo.index = 0; // TODO
        if (!it->selectedIons.empty())
        {
            precursorInfo.mz = it->selectedIons[0].cvParam(MS_selected_ion_m_z).valueAs<double>();
            precursorInfo.charge = it->selectedIons[0].cvParam(MS_charge_state).valueAs<int>();
            precursorInfo.intensity = it->selectedIons[0].cvParam(MS_peak_intensity).valueAs<double>();
        }
        precursors.push_back(precursorInfo);
    }

    dataSize = spectrum.defaultArrayLength;
    if (getBinaryData && !spectrum.binaryDataArrayPtrs.empty())
        spectrum.getMZIntensityPairs(data);
}