From: <ch...@us...> - 2009-09-28 20:51:23
|
Revision: 1366 http://proteowizard.svn.sourceforge.net/proteowizard/?rev=1366&view=rev Author: chambm Date: 2009-09-28 20:51:16 +0000 (Mon, 28 Sep 2009) Log Message: ----------- - fixed SpectrumList_Agilent always returning centroid data when both profile and centroid data are available in the file (i.e. "mixed") - added zero-sample filter for profile data (TODO: move to a common location) Modified Paths: -------------- trunk/pwiz/pwiz/data/vendor_readers/Agilent/Reader_Agilent_Test.data.tar.bz2 trunk/pwiz/pwiz/data/vendor_readers/Agilent/SpectrumList_Agilent.cpp trunk/pwiz/pwiz/utility/vendor_api/Agilent/MassHunterData.cpp Modified: trunk/pwiz/pwiz/data/vendor_readers/Agilent/Reader_Agilent_Test.data.tar.bz2 =================================================================== (Binary files differ) Modified: trunk/pwiz/pwiz/data/vendor_readers/Agilent/SpectrumList_Agilent.cpp =================================================================== --- trunk/pwiz/pwiz/data/vendor_readers/Agilent/SpectrumList_Agilent.cpp 2009-09-28 15:56:17 UTC (rev 1365) +++ trunk/pwiz/pwiz/data/vendor_readers/Agilent/SpectrumList_Agilent.cpp 2009-09-28 20:51:16 UTC (rev 1366) @@ -116,7 +116,7 @@ result->index = index; result->id = ie.id; - pwiz::vendor_api::Agilent::SpectrumPtr spectrumPtr = rawfile_->getProfileSpectrumByRow(ie.rowNumber); + pwiz::vendor_api::Agilent::SpectrumPtr spectrumPtr = rawfile_->getProfileSpectrumById(ie.scanId); MSScanType scanType = spectrumPtr->getMSScanType(); DeviceType deviceType = spectrumPtr->getDeviceType(); @@ -142,8 +142,7 @@ bool doCentroid = msLevelsToCentroid.contains(msLevel); MSStorageMode storageMode = spectrumPtr->getMSStorageMode(); - bool hasProfile = storageMode == MSStorageMode_ProfileSpectrum || - storageMode == MSStorageMode_Mixed; + bool hasProfile = storageMode == MSStorageMode_ProfileSpectrum; if (hasProfile && (!canCentroid || !doCentroid)) { @@ -218,11 +217,9 @@ result->set(MS_highest_observed_m_z, massList->data()[massList->size()-1].mass, MS_m_z); }*/ - // if a centroided spectrum is desired, we make a new call - if (doCentroid) - { + // if a centroided spectrum is desired and we currently have profile, we make a new call + if (doCentroid && storageMode != MSStorageMode_PeakDetectedSpectrum) spectrumPtr = rawfile_->getPeakSpectrumByRow(ie.rowNumber); - } if (getBinaryData) { @@ -230,17 +227,81 @@ automation_vector<double> xArray; spectrumPtr->getXArray(xArray); - result->getMZArray()->data.assign(xArray.begin(), xArray.end()); automation_vector<float> yArray; spectrumPtr->getYArray(yArray); - result->getIntensityArray()->data.assign(yArray.begin(), yArray.end()); - result->defaultArrayLength = xArray.size(); + vector<double>& mzArray = result->getMZArray()->data; + vector<double>& intensityArray = result->getIntensityArray()->data; + + if (doCentroid || xArray.size() < 3) + { + mzArray.assign(xArray.begin(), xArray.end()); + intensityArray.assign(yArray.begin(), yArray.end()); + } + else + { + // Agilent profile mode data returns all zero-intensity samples, so we filter out + // samples that aren't adjacent to a non-zero-intensity sample value. + + // special case for the first sample + if (yArray[0] > 0 || yArray[1] > 0) + { + mzArray.push_back(xArray[0]); + intensityArray.push_back(yArray[0]); + } + + size_t lastIndex = yArray.size() - 1; + + for (size_t i=0; i < lastIndex; ++i) + if (yArray[i-1] > 0 || yArray[i] > 0 || yArray[i+1] > 0) + { + mzArray.push_back(xArray[i]); + intensityArray.push_back(yArray[i]); + } + + // special case for the last sample + if (yArray[lastIndex-1] > 0 || yArray[lastIndex] > 0) + { + mzArray.push_back(xArray[lastIndex]); + intensityArray.push_back(yArray[lastIndex]); + } + } + + result->defaultArrayLength = mzArray.size(); } else - result->defaultArrayLength = (size_t) spectrumPtr->getTotalDataPoints(); + { + automation_vector<float> yArray; + spectrumPtr->getYArray(yArray); + if (doCentroid || yArray.size() < 3) + { + result->defaultArrayLength = (size_t) yArray.size(); + } + else + { + // Agilent profile mode data returns all zero-intensity samples, so we filter out + // samples that aren't adjacent to a non-zero-intensity sample value. + + result->defaultArrayLength = 0; + + // special case for the first sample + if (yArray[0] > 0 || yArray[1] > 0) + ++result->defaultArrayLength; + + size_t lastIndex = yArray.size() - 1; + + for (size_t i=0; i < lastIndex; ++i) + if (yArray[i-1] > 0 || yArray[i] > 0 || yArray[i+1] > 0) + ++result->defaultArrayLength; + + // special case for the last sample + if (yArray[lastIndex-1] > 0 || yArray[lastIndex] > 0) + ++result->defaultArrayLength; + } + } + return result; } Modified: trunk/pwiz/pwiz/utility/vendor_api/Agilent/MassHunterData.cpp =================================================================== --- trunk/pwiz/pwiz/utility/vendor_api/Agilent/MassHunterData.cpp 2009-09-28 15:56:17 UTC (rev 1365) +++ trunk/pwiz/pwiz/utility/vendor_api/Agilent/MassHunterData.cpp 2009-09-28 20:51:16 UTC (rev 1366) @@ -105,10 +105,16 @@ return result; } -MHDAC::IBDASpecFilter^ bdaSpecFilterForScanId(int scanId) +MHDAC::IBDASpecFilter^ bdaSpecFilterForScanId(int scanId, bool preferProfileData = false ) { MHDAC::IBDASpecFilter^ result = gcnew MHDAC::BDASpecFilter(); result->ScanIds = gcnew cli::array<int> { scanId }; + result->SpectrumType = MHDAC::SpecType::MassSpectrum; + + // default is DesiredMSStorageType::PeakElseProfile + if (preferProfileData) + result->DesiredMSStorageType = MHDAC::DesiredMSStorageType::ProfileElsePeak; + return result; } @@ -419,7 +425,7 @@ SpectrumPtr MassHunterDataImpl::getProfileSpectrumById(int scanId) const { - return SpectrumPtr(new SpectrumImpl(reader_->GetSpectrum(bdaSpecFilterForScanId(scanId), nullptr)[0])); + return SpectrumPtr(new SpectrumImpl(reader_->GetSpectrum(bdaSpecFilterForScanId(scanId, true), nullptr)[0])); } SpectrumPtr MassHunterDataImpl::getPeakSpectrumById(int scanId, PeakFilterPtr peakFilter /*= PeakFilterPtr()*/) const This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |