本文整理汇总了C++中SpectrumPtr::get方法的典型用法代码示例。如果您正苦于以下问题:C++ SpectrumPtr::get方法的具体用法?C++ SpectrumPtr::get怎么用?C++ SpectrumPtr::get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SpectrumPtr
的用法示例。
在下文中一共展示了SpectrumPtr::get方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: mzDBMSDataTomzMLMSData
void mzDBMSDataTomzMLMSData(MzDBFile* f, MSDataPtr mzdb, MSDataPtr raw) {
//out = mzdb; //to catch all metadata
ofstream fileHandle("ErrorPercentage.txt", ios::out | ios::trunc);
//ofstream fileHandle_2("ErrorNbPoints.txt", ios::out | ios::trunc);
FILE* fileHandle_2 = fopen("ErrorNbPoints.txt", "w");
FILE* fileHandle_3 = fopen("ymax.txt", "w");
if ( ! fileHandle || ! fileHandle_2)
printf("Failed to create ratiosPercentage file\n");
mzDataCache* cache = new mzDataCache;
cache->open();
int lastPercent = 0;
//BinnedSpectrum::getMzDataInterval(300., 2001, 0.);
//printf("\ninterval vector size : %d\n", BinnedSpectrum::mzData.size());
SpectrumListPtr spec = mzdb->run.spectrumListPtr;
SpectrumListPtr rawSpec = raw->run.spectrumListPtr;
for (size_t i = 0; i < spec->size(); ++i) {
SpectrumPtr ptr = spec->spectrum(i, true);
SpectrumPtr rawSpectrum = rawSpec->spectrum(i, true);
//if( i != 1 ) { continue; }
mzScan* scan = (mzScan*)(ptr.get());
if (! scan) {
printf("Empty pointer\n");
exit(0);
}
vector<double>& mz = scan->mz;
vector<double>& intens = scan->intensities;
vector<float>& lwhm = scan->lwhm;
vector<float>& rwhm = scan->rwhm;
/*printf("%d\n", mz.size());
for (size_t j = 0; j < mz.size(); ++j) {
printf("%f\n", mz[j]);
}
printf("\n");*/
if ( scan->encoding.mode == FITTED) {
BinnedSpectrum binnedSpectrum(rawSpectrum);
//printf("size of mzdata:%d\n", binnedSpectrum.mzData.size());
vector<double> intData(binnedSpectrum.mzData.size(), 0);
for (size_t j=0; j < mz.size(); ++j) {
double y_max = intens[j];
double x_zero = mz[j];
fprintf( fileHandle_3, "%.5f\t%f\n", x_zero,y_max);
//printf("max value: %f\n", y_max);
// add the apex
size_t index = binnedSpectrum.getLeftIndex(x_zero);
//get the limit of ppm
double ppmLimit = 1.1 * sqrt(x_zero);
double maxDistFromTheApex = (x_zero * (ppmLimit / 2)) / 1e6;
double mzLeftLimit = x_zero - maxDistFromTheApex;
double mzRightLimit = x_zero + maxDistFromTheApex;
//binnedSpectrum.putFromIndex(index, y_max);
//intData[index] += mzMath::y(binnedSpectrum.mzData[index], x_zero, y_max, sigmal_squared);// y_max;
double lwhm_j = static_cast<double>(lwhm[j]);
double rwhm_j = static_cast<double>(rwhm[j]);
//generate x value;
//printf("%f, %f, %f, %f\n", mz[j], intens[j], lwhm[j], rwhm[j]);
//if ( lwhm_j ) {
double sigmal = (2.0 * lwhm_j) / SIGMA_FACTOR;
//99% of the value 6 sigma goes to 3/4 sigmas up and down
double sigmal_x6 = sigmal * 2;
double min_x_left = x_zero - sigmal_x6;
size_t index_left = index;//(index - 1 >= 0) ? index - 1 : 0;
double sigmal_squared = sigmal * sigmal;
double x_zero_pl = binnedSpectrum.mzData[index_left];//binnedSpectrum.getPairFromIndex(index_left).first;//
double y_vall = mzMath::y(x_zero_pl, x_zero, y_max, sigmal_squared);
bool makeBounds = false;
if (y_vall < 6e3)
makeBounds = true;
//visitedLeftIndexes.push_back(index);
//size_t counter = 0;
while ( x_zero_pl > min_x_left ) {
if (x_zero_pl < mzLeftLimit && makeBounds)
break;
//binnedSpectrum.putFromIndex(index_left, y_vall);
intData[index_left] += y_vall;
//.........这里部分代码省略.........
示例2: spectrum
PWIZ_API_DECL SpectrumPtr SpectrumList_ABI::spectrum(size_t index, DetailLevel detailLevel, const pwiz::util::IntegerSet& msLevelsToCentroid) const
{
boost::lock_guard<boost::mutex> lock(readMutex); // lock_guard will unlock mutex when out of scope or when exception thrown (during destruction)
boost::call_once(indexInitialized_.flag, boost::bind(&SpectrumList_ABI::createIndex, this));
if (index >= size_)
throw runtime_error("[SpectrumList_ABI::spectrum()] Bad index: " + lexical_cast<string>(index));
// allocate a new Spectrum
IndexEntry& ie = index_[index];
SpectrumPtr result = SpectrumPtr(new Spectrum);
if (!result.get())
throw std::runtime_error("[SpectrumList_ABI::spectrum()] Allocation error.");
result->index = index;
result->id = ie.id;
//Console::WriteLine("spce: {0}.{1}.{2}.{3}", ie.sample, ie.period, ie.cycle, ie.experiment);
result->scanList.set(MS_no_combination);
result->scanList.scans.push_back(Scan());
Scan& scan = result->scanList.scans[0];
ExperimentPtr msExperiment = ie.experiment;
// Synchronize access to cached spectrum for multi-threaded use
pwiz::vendor_api::ABI::SpectrumPtr spectrum;
{
boost::mutex::scoped_lock spectrum_lock(spectrum_mutex);
if (spectrumLastIndex_ != index)
{
spectrumLastIndex_ = index;
spectrumLast_ = wifffile_->getSpectrum(msExperiment, ie.cycle);
}
spectrum = spectrumLast_;
}
double scanTime = spectrum->getStartTime();
if (scanTime > 0)
scan.set(MS_scan_start_time, scanTime, UO_minute);
scan.set(MS_preset_scan_configuration, msExperiment->getExperimentNumber());
ExperimentType experimentType = msExperiment->getExperimentType();
int msLevel = spectrum->getMSLevel();
result->set(MS_ms_level, msLevel);
result->set(translateAsSpectrumType(experimentType));
result->set(translate(msExperiment->getPolarity()));
// CONSIDER: Can anything below here be added to instant?
if (detailLevel == DetailLevel_InstantMetadata)
return result;
// Revert to previous behavior for getting binary data or not.
bool getBinaryData = (detailLevel == DetailLevel_FullData);
double startMz, stopMz;
msExperiment->getAcquisitionMassRange(startMz, stopMz);
scan.scanWindows.push_back(ScanWindow(startMz, stopMz, MS_m_z));
// decide whether to use Points or Peaks to populate data arrays
bool doCentroid = msLevelsToCentroid.contains(msLevel);
bool continuousData = spectrum->getDataIsContinuous();
if (continuousData && !doCentroid)
result->set(MS_profile_spectrum);
else
{
result->set(MS_centroid_spectrum);
doCentroid = continuousData;
}
/*if (experimentType == MRM)
{
MRMTransitions^ transitions = msExperiment->MRMTransitions;
double q1mz = transitions[ie.transition]->Q1Mass;//ie.transition->first;
double q3mz = transitions[ie.transition]->Q3Mass;
double intensity = points[ie.transition]->Y;
result->defaultArrayLength = 1;//ie.transition->second.size();
Precursor precursor;
SelectedIon selectedIon;
selectedIon.set(MS_selected_ion_m_z, q1mz, MS_m_z);
precursor.activation.set(MS_CID); // assume CID
precursor.selectedIons.push_back(selectedIon);
result->precursors.push_back(precursor);
if (getBinaryData)
{
mzArray.resize(result->defaultArrayLength, q3mz);
intensityArray.resize(result->defaultArrayLength, intensity);
}
}
else*/
{
if (spectrum->getHasPrecursorInfo())
{
//.........这里部分代码省略.........
示例3: test
void test(bool indexed)
{
if (os_) *os_ << "test(): indexed=\"" << boolalpha << indexed << "\"\n";
MSData tiny;
examples::initializeTiny(tiny);
Serializer_mzML::Config config;
config.indexed = indexed;
Serializer_mzML serializer(config);
ostringstream oss;
serializer.write(oss, tiny);
if (os_) *os_ << "oss:\n" << oss.str() << endl;
shared_ptr<istream> is(new istringstream(oss.str()));
// dummy would normally be read in from file
MSData dummy;
ParamGroupPtr pg1(new ParamGroup);
pg1->id = "CommonMS1SpectrumParams";
pg1->cvParams.push_back(MS_positive_scan);
pg1->cvParams.push_back(MS_full_scan);
dummy.paramGroupPtrs.push_back(pg1);
ParamGroupPtr pg2(new ParamGroup);
pg2->id = "CommonMS2SpectrumParams";
pg2->cvParams.push_back(MS_positive_scan);
pg2->cvParams.push_back(MS_full_scan);
dummy.paramGroupPtrs.push_back(pg2);
// so we don't have any dangling references
dummy.instrumentConfigurationPtrs.push_back(InstrumentConfigurationPtr(new InstrumentConfiguration("LCQDeca")));
dummy.dataProcessingPtrs.push_back(DataProcessingPtr(new DataProcessing("XcaliburProcessing")));
SpectrumListPtr sl = SpectrumList_mzML::create(is, dummy, indexed);
// check easy functions
unit_assert(sl.get());
unit_assert(sl->size() == 4);
unit_assert(sl->find ("S19") == 0);
unit_assert(sl->findNative("19") == 0);
unit_assert(sl->find("S20") == 1);
unit_assert(sl->findNative("20") == 1);
unit_assert(sl->find("S21") == 2);
unit_assert(sl->findNative("21") == 2);
unit_assert(sl->find("S22") == 3);
unit_assert(sl->findNative("22") == 3);
unit_assert(sl->findSpotID("A1").empty());
IndexList spotIndexList = sl->findSpotID("A1,42x42,4242x4242");
unit_assert(spotIndexList.size() == 1);
unit_assert(spotIndexList[0] == 3);
// check scan 19
SpectrumPtr s = sl->spectrum(0); // read without binary data
unit_assert(s.get());
unit_assert(s->id == "S19");
unit_assert(s->nativeID == "19");
unit_assert(s->spotID.empty());
unit_assert(s->cvParam(MS_ms_level).valueAs<int>() == 1);
unit_assert(s->binaryDataArrayPtrs.empty());
unit_assert(sl->spectrumIdentity(0).index == 0);
unit_assert(sl->spectrumIdentity(0).id == "S19");
unit_assert(sl->spectrumIdentity(0).nativeID == "19");
unit_assert(sl->spectrumIdentity(0).spotID.empty());
SpectrumPtr s_cache = sl->spectrum(0); // cache read
unit_assert(s_cache.get() == s.get());
s = sl->spectrum(0, true); // read with binary data
unit_assert(s_cache.get() != s.get());
vector<MZIntensityPair> pairs;
s->getMZIntensityPairs(pairs);
unit_assert(pairs.size() == 15);
for (int i=0; i<15; i++)
unit_assert(pairs[i].mz==i && pairs[i].intensity==15-i);
unit_assert(s->spectrumDescription.scan.paramGroupPtrs.size() == 1);
unit_assert(s->spectrumDescription.scan.paramGroupPtrs.back()->id == "CommonMS1SpectrumParams");
unit_assert(s->spectrumDescription.scan.paramGroupPtrs.back()->cvParams.size() == 2);
// check scan 20
s = sl->spectrum(1, true);
unit_assert(s.get());
unit_assert(s->id == "S20");
unit_assert(s->nativeID == "20");
unit_assert(s->spotID.empty());
unit_assert(s->cvParam(MS_ms_level).valueAs<int>() == 2);
unit_assert(sl->spectrumIdentity(1).index == 1);
//.........这里部分代码省略.........