26 #include "boost/filesystem/path.hpp"
27 #include "boost/filesystem/fstream.hpp"
32 using namespace pwiz::data;
33 using namespace pwiz::msdata;
34 using namespace pwiz::util;
35 namespace bfs = boost::filesystem;
53 {4, 122, 576.82, 139, 176.381, 0.9,
"",
"2 3"},
54 {6, 125, 785.72, 76, 333.224, 0.8,
"",
"2 3"},
55 {2, 120, 508.95, 82, 261.342, 0.7,
"",
"2 3"}
63 spec_info->SpectrumInfo::update(*s,
true);
79 *
os_ <<
"spectrum index: " << spec_info->
index <<
"\t"
80 <<
"scan number: " << spec_info->
scanNumber <<
"\t"
81 <<
"level: " << spec_info->
msLevel <<
"\t";
83 *
os_ <<
"precursor mz: " << spec_info->
precursors[0].mz <<
"\t";
85 *
os_ <<
"num peaks: " << spec_info->
data.size() <<
"\t"
86 <<
"first peak mz: " << spec_info->
data.at(0).mz <<
"\t"
87 <<
"intenisity: " << spec_info->
data.at(0).intensity <<
"\t"
88 <<
"possible charges: ";
101 size_t numChargeStates = 0;
125 void test(
const bfs::path& datadir,
int msLevel)
127 if (
os_) *
os_ <<
"test()\n";
131 filenames.push_back(
"10-spec.ms1");
132 filenames.push_back(
"10-spec.bms1");
133 filenames.push_back(
"10-spec.cms1");
134 }
else if (msLevel == 2) {
135 filenames.push_back(
"10-spec.ms2");
136 filenames.push_back(
"10-spec.bms2");
137 filenames.push_back(
"10-spec.bms2.gz");
138 filenames.push_back(
"10-spec.cms2");
140 cerr <<
"Invalid MS level." << endl;
145 size_t indexes[] = {4, 6, 2};
146 size_t num_spec =
sizeof(indexes)/
sizeof(
size_t);
149 vector<string>::const_iterator file_it = filenames.begin();
150 for (; file_it != filenames.end(); ++file_it)
152 string filename = *file_it;
153 MSDataFile data_file((datadir / filename).
string());
162 <<
" in " << filename << endl;
166 for (
size_t i=0; i<num_spec; i++)
168 SpectrumPtr cur_spec = all_spectra->spectrum(indexes[i],
true);
175 *
os_ <<
"Use scan numbers to get the same spec." << endl;
178 size_t scan_nums[] = {122, 125, 120};
179 num_spec =
sizeof(scan_nums)/
sizeof(
size_t);
180 for (
size_t i=0; i<num_spec; i++)
185 *
os_ <<
"Looking for the " << i <<
"th scan num, " << scan_nums[i]
186 <<
", id " << id_str << endl;
189 size_t found_index = all_spectra->find(id_str);
192 *
os_ <<
"found_index = " << found_index << endl;
195 if (found_index == all_spectra->size())
199 *
os_ <<
"Not found." << endl;
204 SpectrumPtr cur_spec = all_spectra->spectrum(found_index,
true);
211 int main(
int argc,
char* argv[])
217 if (argc>1 && !strcmp(argv[1],
"-v"))
os_ = &cout;
219 std::string buildparent(argv[0]);
220 size_t pos = buildparent.find(
"build");
221 if (string::npos==pos)
223 buildparent = __FILE__;
225 pos = buildparent.rfind(
"pwiz");
227 buildparent.resize(pos);
228 bfs::path example_data_dir = buildparent +
"example_data/";
229 test(example_data_dir, 1);
230 test(example_data_dir, 2);