#include <OpenMS/KERNEL/MSSpectrum.h> //这里出错了,说是无法打开openms/kernel/msspectrum.h
#include<iostream>
using namespace OpenMS; /这个地方也出错了,说是,名称必须是命名空间名
using namespace std;
int main()
{
// Create spectrum
MSSpectrum spectrum; //这个地方也出错,我怀疑还是头文件不对,或者命名空间
Peak1D peak; //这个地方也出错,我怀疑还是头文件不对
for (float mz = 1500.0; mz >= 500; mz -= 100.0)
{
peak.setMZ(mz);
spectrum.push_back(peak);
}
// Sort the peaks according to ascending mass-to-charge ratio
spectrum.sortByPosition();
// Iterate over spectrum of those peaks between 800 and 1000 Thomson
for (auto it = spectrum.MZBegin(800.0); it != spectrum.MZEnd(1000.0); ++it)
{
cout << it->getMZ() << endl;
}
// Access a peak by index
cout << spectrum[1].getMZ() << " " << spectrum[1].getIntensity() << endl;
// ... and many more
return 0;
}
新建的vs2019项目,复制学习教程上的一段代码,这个头文件包我有,这个头文件里还有别的头文件,都在Openms路径下)