当前位置: 首页>>代码示例>>C++>>正文


C++ SpectrumPtr::hasCVParam方法代码示例

本文整理汇总了C++中SpectrumPtr::hasCVParam方法的典型用法代码示例。如果您正苦于以下问题:C++ SpectrumPtr::hasCVParam方法的具体用法?C++ SpectrumPtr::hasCVParam怎么用?C++ SpectrumPtr::hasCVParam使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在SpectrumPtr的用法示例。


在下文中一共展示了SpectrumPtr::hasCVParam方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: getScanNumber

void RAMPAdapter::Impl::getScanHeader(size_t index, ScanHeaderStruct& result, bool reservePeaks /*= true*/) const
{
    // use previous spectrum if possible
    if (!lastSpectrum.get() || lastSpectrum->index != index)
        lastSpectrum = msd_.run.spectrumListPtr->spectrum(index, reservePeaks);

    SpectrumPtr spectrum = lastSpectrum;

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

    result.seqNum = static_cast<int>(index + 1);
    result.acquisitionNum = getScanNumber(index);
    result.msLevel = spectrum->cvParam(MS_ms_level).valueAs<int>();
    result.peaksCount = static_cast<int>(spectrum->defaultArrayLength);
    result.totIonCurrent = spectrum->cvParam(MS_total_ion_current).valueAs<double>();
    result.retentionTime = scan.cvParam(MS_scan_start_time).timeInSeconds();
    result.basePeakMZ = spectrum->cvParam(MS_base_peak_m_z).valueAs<double>();    
    result.basePeakIntensity = spectrum->cvParam(MS_base_peak_intensity).valueAs<double>();    
    result.collisionEnergy = 0;
    result.ionisationEnergy = spectrum->cvParam(MS_ionization_energy).valueAs<double>();
    result.lowMZ = spectrum->cvParam(MS_lowest_observed_m_z).valueAs<double>();        
    result.highMZ = spectrum->cvParam(MS_highest_observed_m_z).valueAs<double>();        
    result.precursorScanNum = 0;
    result.precursorMZ = 0;
    result.precursorCharge = 0;
    result.precursorIntensity = 0;
    result.compensationVoltage = 0;
    

    std::string filterLine = scan.cvParam(MS_filter_string).value;
    
    size_t found = filterLine.find("cv=");
    
    if (found!=string::npos) {
      filterLine = filterLine.substr(found+3);
      found = filterLine.find_first_of(" ");
      if (found!=string::npos) {
          filterLine = filterLine.substr(0, found);
          result.compensationVoltage = atof(filterLine.c_str());
      }
    }

    result.filterLine = filterLine;



    if (!spectrum->precursors.empty())
    {
        const Precursor& precursor = spectrum->precursors[0];
        result.collisionEnergy = precursor.activation.cvParam(MS_collision_energy).valueAs<double>();
        size_t precursorIndex = msd_.run.spectrumListPtr->find(precursor.spectrumID);

        if (precursorIndex < msd_.run.spectrumListPtr->size())
        {
            const SpectrumIdentity& precursorSpectrum = msd_.run.spectrumListPtr->spectrumIdentity(precursorIndex);
            string precursorScanNumber = id::translateNativeIDToScanNumber(nativeIdFormat_, precursorSpectrum.id);
            
            if (precursorScanNumber.empty()) // unsupported nativeID type
            {
                // assume scanNumber is a 1-based index, consistent with this->index() method
                result.precursorScanNum = precursorIndex+1;
            } 
            else 
            {
                result.precursorScanNum = lexical_cast<int>(precursorScanNumber);
            }
        }
        if (!precursor.selectedIons.empty())
        {
            result.precursorMZ = precursor.selectedIons[0].cvParam(MS_selected_ion_m_z).valueAs<double>();
            if (!result.precursorMZ)
            { // mzML 1.0?
                result.precursorMZ = precursor.selectedIons[0].cvParam(MS_m_z).valueAs<double>();
            }
            result.precursorCharge = precursor.selectedIons[0].cvParam(MS_charge_state).valueAs<int>();
            result.precursorIntensity = precursor.selectedIons[0].cvParam(MS_peak_intensity).valueAs<double>();
        }
    }

    BOOST_STATIC_ASSERT(SCANTYPE_LENGTH > 4);
    memset(result.scanType, 0, SCANTYPE_LENGTH);
    strcpy(result.scanType, "Full"); // default
    if (spectrum->hasCVParam(MS_zoom_scan))
        strcpy(result.scanType, "Zoom");

    result.mergedScan = 0; // TODO 
    result.mergedResultScanNum = 0; // TODO 
    result.mergedResultStartScanNum = 0; // TODO 
    result.mergedResultEndScanNum = 0; // TODO 
    result.filePosition = spectrum->sourceFilePosition; 
}
开发者ID:AlexandreBurel,项目名称:pwiz-mzdb,代码行数:92,代码来源:RAMPAdapter.cpp

示例2: writeSpectrumText

    void writeSpectrumText(SpectrumPtr s, ostream& os)
    {
        os << std::setprecision(7); // 123.4567
        bool ms1File = s->cvParam(MS_ms_level).valueAs<int>() == 1;
        
        // Write the scan numbers 
        os << "S\t";
        int scanNum = getScanNumber(s);
        os << scanNum <<  "\t" << scanNum;

        if (!ms1File)
        {
            // Write the precursor mz
            Precursor& precur = s->precursors[0];
            double mz = precur.isolationWindow.cvParam(MS_isolation_window_target_m_z).valueAs<double>();
            os << "\t" << mz;
        }
        os << "\n";
        
        // Write the scan time, if available
        if( !(s->scanList.empty()) && s->scanList.scans[0].cvParam(MS_scan_start_time).timeInSeconds() )
          os << "I\tRTime\t" << s->scanList.scans[0].cvParam(MS_scan_start_time).timeInSeconds()/60 << "\n";

        if (s->defaultArrayLength > 0)
        {
            // Write the base peak intensity and base peak m/z
            if (s->hasCVParam(MS_base_peak_intensity))
            {
                double bpi = s->cvParam(MS_base_peak_intensity).valueAs<double>();
                os << "I\tBPI\t" << bpi << "\n";
            }
            if (s->hasCVParam(MS_base_peak_m_z))
            {
                double bpm = s->cvParam(MS_base_peak_m_z).valueAs<double>();
                os << "I\tBPM\t" << bpm << "\n";
            }

            // Write the total ion current
            if (s->hasCVParam(MS_total_ion_current))
            {
                double tic = s->cvParam(MS_total_ion_current).valueAs<double>();
                os << "I\tTIC\t" << tic << "\n";
            }
        }

        //TODO 
        // Write ConvA/ConvB information
        // Write the ion injection time
        //os << "I\tIIT\t" << s->scanList.scans[0].cvParam(MS_ion_injection_time).timeInSeconds()/60 << "\n";

        if (!ms1File)
        {
            Precursor& precur = s->precursors[0];
            SelectedIon& si = precur.selectedIons[0];
            // Collect charge and mass info
            vector<int> charges;
            vector<double> masses;
            int numChargeStates = 0;
            // for each selected ion
            BOOST_FOREACH(const SelectedIon& curIon, precur.selectedIons){
              numChargeStates += getChargeStates(curIon, charges, masses);
            }

            // Write EZ lines if accurate masses are available
            CVParam massParam = si.cvParam(MS_accurate_mass_OBSOLETE);
            if( !massParam.empty() ){
              for(int i=0; i < numChargeStates; i++){
                os << "I\tEZ\t" << charges[i] << "\t" << masses[i] << "\t0\t0" << endl; // pad last two fields with 0
              }
            }

            // For each charge, write the charge and mass
            for(int i = 0; i < numChargeStates; i++)
            {
              os << "Z\t" << charges[i] << "\t" << masses[i] << "\n"; 
            }
        }
开发者ID:tomas-pluskal,项目名称:pwiz,代码行数:77,代码来源:Serializer_MSn.cpp


注:本文中的SpectrumPtr::hasCVParam方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。