30 using namespace pwiz::util;
31 using namespace pwiz::minimxml;
33 using namespace pwiz::data;
34 using namespace pwiz::msdata;
35 using boost::iostreams::stream_offset;
41 template <
typename object_type>
44 if (
os_) *
os_ <<
"testObject(): " <<
typeid(a).name() << endl;
51 if (
os_) *
os_ << oss.str() << endl;
56 istringstream iss(oss.str());
62 if (diff &&
os_) *
os_ <<
"diff:\n" << diff << endl;
67 template <
typename object_type>
70 if (
os_) *
os_ <<
"testObject(): " <<
typeid(a).name() << endl;
77 if (
os_) *
os_ << oss.str() << endl;
82 istringstream iss(oss.str());
88 if (diff &&
os_) *
os_ <<
"diff:\n" << diff << endl;
95 if (
os_) *
os_ <<
"testObject_SpectrumList(): " << endl;
103 if (
os_) *
os_ << oss.str() << endl;
108 istringstream iss(oss.str());
114 if (diff &&
os_) *
os_ <<
"diff:\n" << diff << endl;
123 if (
os_) *
os_ <<
"testObject_ChromatogramList(): " << endl;
130 if (
os_) *
os_ << oss.str() << endl;
135 istringstream iss(oss.str());
141 if (diff &&
os_) *
os_ <<
"diff:\n" << diff << endl;
191 template <
typename object_type>
195 a.userParams.push_back(
UserParam(
"goober",
"goo",
"peanuts"));
205 SourceFile a(
"id123",
"name456",
"location789");
234 Sample a(
"id123",
"name456");
304 a.
id =
"msdata processing";
404 a.
scans.push_back(a1);
405 a.
scans.push_back(a2);
414 if (
os_) *
os_ <<
"testBinaryDataArray():\n";
417 for (
int i=0; i<10; i++) a.
data.push_back(i);
425 if (
os_) *
os_ << oss.str() << endl;
430 istringstream iss(oss.str());
436 if (diff &&
os_) *
os_ <<
"diff:\n" << diff << endl;
445 config.
precision = BinaryDataEncoder::Precision_32;
446 config.
byteOrder = BinaryDataEncoder::ByteOrder_LittleEndian;
449 config.
precision = BinaryDataEncoder::Precision_64;
450 config.
byteOrder = BinaryDataEncoder::ByteOrder_LittleEndian;
460 <binaryDataArray encodedLength=\"160\" arrayLength=\"15\"> \
461 <referenceableParamGroupRef ref=\"mz_params\"/> \
462 <binary>AAAAAAAAAAAAAAAAAADwPwAAAAAAAABAAAAAAAAACEAAAAAAAAAQQAAAAAAAABRAAAAAAAAAGEAAAAAAAAAcQAAAAAAAACBAAAAAAAAAIkAAAAAAAAAkQAAAAAAAACZAAAAAAAAAKEAAAAAAAAAqQAAAAAAAACxA</binary> \
472 pg->id =
"mz_params";
486 for (
size_t i=0; i<15; i++)
493 if (
os_) *
os_ <<
"testSpectrum():\n";
540 if (
os_) *
os_ << oss.str() << endl;
545 istringstream iss(oss.str());
552 if (diff &&
os_) *
os_ <<
"diff:\n" << diff << endl;
571 if (
os_) *
os_ <<
"testChromatogram():\n";
594 if (
os_) *
os_ << oss.str() << endl;
599 istringstream iss(oss.str());
606 if (diff &&
os_) *
os_ <<
"diff:\n" << diff << endl;
628 spectrum1->id =
"goober";
629 spectrum1->index = 0;
630 spectrum1->defaultArrayLength = 666;
631 spectrum1->userParams.push_back(
UserParam(
"description1"));
634 spectrum2->id =
"raisinet";
635 spectrum2->index = 1;
636 spectrum2->defaultArrayLength = 667;
637 spectrum2->userParams.push_back(
UserParam(
"description2"));
639 a.
spectra.push_back(spectrum1);
640 a.
spectra.push_back(spectrum2);
649 if (
os_) *
os_ <<
"testSpectrumListWithPositions()\n ";
654 spectrum1->id =
"goober";
655 spectrum1->index = 0;
656 spectrum1->defaultArrayLength = 666;
657 spectrum1->userParams.push_back(
UserParam(
"description1"));
660 spectrum2->id =
"raisinet";
661 spectrum2->index = 1;
662 spectrum2->defaultArrayLength = 667;
663 spectrum2->userParams.push_back(
UserParam(
"description2"));
665 a.
spectra.push_back(spectrum1);
666 a.
spectra.push_back(spectrum2);
670 vector<stream_offset> positions;
676 copy(positions.begin(), positions.end(), ostream_iterator<stream_offset>(*
os_,
" "));
677 *os_ << endl << oss.str() << endl;
697 const vector<size_t>&
indices()
const {
return indices_;}
715 const vector<size_t>&
indices()
const {
return indices_;}
724 if (
os_) *
os_ <<
"testSpectrumListWriteProgress()\n ";
728 for (
size_t i=0; i<11; i++)
733 spectrum->defaultArrayLength = 666;
750 *
os_ <<
"callback indices: ";
752 ostream_iterator<size_t>(*
os_,
" "));
776 *
os_ <<
"callback indices: ";
777 copy(cancelListener.
indices().begin(), cancelListener.
indices().end(),
778 ostream_iterator<size_t>(*
os_,
" "));
793 chromatogram1->id =
"goober";
794 chromatogram1->index = 0;
795 chromatogram1->defaultArrayLength = 666;
798 chromatogram2->id =
"raisinet";
799 chromatogram2->index = 1;
800 chromatogram2->defaultArrayLength = 667;
812 if (
os_) *
os_ <<
"testChromatogramListWithPositions()\n ";
817 chromatogram1->id =
"goober";
818 chromatogram1->index = 0;
819 chromatogram1->defaultArrayLength = 666;
822 chromatogram2->id =
"raisinet";
823 chromatogram2->index = 1;
824 chromatogram2->defaultArrayLength = 667;
831 vector<stream_offset> positions;
836 copy(positions.begin(), positions.end(), ostream_iterator<stream_offset>(*
os_,
" "));
837 *os_ << endl << oss.str() << endl;
849 if (
os_) *
os_ <<
"testRun():\n";
864 spectrum1->id =
"goober";
865 spectrum1->index = 0;
866 spectrum1->defaultArrayLength = 666;
867 spectrum1->userParams.push_back(
UserParam(
"description1"));
870 spectrum2->id =
"raisinet";
871 spectrum2->index = 1;
872 spectrum2->defaultArrayLength = 667;
873 spectrum2->userParams.push_back(
UserParam(
"description2"));
875 spectrumListSimple->spectra.push_back(spectrum1);
876 spectrumListSimple->spectra.push_back(spectrum2);
885 chromatogram1->id =
"goober";
886 chromatogram1->index = 0;
887 chromatogram1->defaultArrayLength = 666;
890 chromatogram2->id =
"raisinet";
891 chromatogram2->index = 1;
892 chromatogram2->defaultArrayLength = 667;
894 chromatogramListSimple->chromatograms.push_back(chromatogram1);
895 chromatogramListSimple->chromatograms.push_back(chromatogram2);
906 if (
os_) *
os_ << oss.str() << endl;
911 istringstream iss(oss.str());
917 if (diff &&
os_) *
os_ <<
"diff:\n" << diff << endl;
927 IO::read(iss, c, IO::ReadSpectrumList);
932 if (diff &&
os_) *
os_ <<
"diff:\n" << diff << endl;
953 cv.
URI =
"http://psidev.sourceforge.net/ms/xml/mzdata/psi-ms.2.0.2.obo";
955 cv.
fullName =
"Proteomics Standards Initiative Mass Spectrometry Ontology";
966 sfp->name =
"tiny1.RAW";
967 sfp->location =
"file://F:/data/Exp01";
969 sfp->cvParams.push_back(
CVParam(
MS_SHA_1,
"71be39fb2700ab2f3c8b2234b91274968b6899b1"));
979 "Higglesworth University, 12 Higglesworth Avenue, 12045, HI, USA"));
986 pg1->id =
"CommonMS1SpectrumParams";
992 pg2->id =
"CommonMS2SpectrumParams";
1000 samplePtr->id =
"1";
1001 samplePtr->name =
"Sample1";
1007 instrumentConfigurationPtr->id =
"LCQ Deca";
1008 instrumentConfigurationPtr->cvParams.push_back(
MS_LCQ_Deca);
1015 softwareXcalibur->id =
"Xcalibur";
1017 softwareXcalibur->version =
"2.0.5";
1018 instrumentConfigurationPtr->softwarePtr = softwareXcalibur;
1025 softwareBioworks->id =
"Bioworks";
1027 softwareBioworks->version =
"3.3.1 sp1";
1030 software_pwiz->id =
"pwiz";
1032 software_pwiz->version =
"1.0";
1041 dpXcalibur->id =
"Xcalibur Processing";
1050 dpXcalibur->processingMethods.push_back(procXcal);
1053 dp_msconvert->id =
"pwiz conversion";
1056 proc_msconvert.
order = 2;
1060 dp_msconvert->processingMethods.push_back(proc_msconvert);
1066 as1->sourceFilePtrs.push_back(sfp_parameters);
1071 as1->targets.push_back(t1);
1072 as1->targets.push_back(t2);
1077 msd.
run.
id =
"Exp01";
1089 Spectrum& s19 = *spectrumList->spectra[0];
1113 s19_mz->dataProcessingPtr = dpXcalibur;
1115 s19_mz->data.resize(10);
1116 for (
int i=0; i<10; i++)
1117 s19_mz->data[i] = i;
1120 s19_intensity->dataProcessingPtr = dpXcalibur;
1122 s19_intensity->data.resize(10);
1123 for (
int i=0; i<10; i++)
1124 s19_intensity->data[i] = 10-i;
1129 Spectrum& s20 = *spectrumList->spectra[1];
1165 s20_mz->dataProcessingPtr = dpXcalibur;
1167 s20_mz->data.resize(10);
1168 for (
int i=0; i<10; i++)
1169 s20_mz->data[i] = i;
1172 s20_intensity->dataProcessingPtr = dpXcalibur;
1174 s20_intensity->data.resize(10);
1175 for (
int i=0; i<10; i++)
1176 s20_intensity->data[i] = 10-i;
1188 Chromatogram& tic = *chromatogramList->chromatograms[0];
1195 tic_time->dataProcessingPtr = dp_msconvert;
1197 tic_time->data.resize(10);
1198 for (
int i=0; i<10; i++)
1199 tic_time->data[i] = i;
1202 tic_intensity->dataProcessingPtr = dp_msconvert;
1204 tic_intensity->data.resize(10);
1205 for (
int i=0; i<10; i++)
1206 tic_intensity->data[i] = 10-i;
1215 if (
os_) *
os_ <<
"testMSData():\n";
1225 if (
os_) *
os_ << oss.str() << endl;
1230 istringstream iss(oss.str());
1236 if (diff &&
os_) *
os_ <<
"diff:\n" << diff << endl;
1246 IO::read(iss, c, IO::ReadSpectrumList);
1251 if (diff &&
os_) *
os_ <<
"diff:\n" << diff << endl;
1269 testNamedParamContainer<FileContent>();
1271 testNamedParamContainer<Contact>();
1280 testNamedParamContainer<Target>();
1282 testNamedParamContainer<IsolationWindow>();
1283 testNamedParamContainer<SelectedIon>();
1284 testNamedParamContainer<Activation>();
1287 testNamedParamContainer<ScanWindow>();
1310 if (argc>1 && !strcmp(argv[1],
"-v"))
os_ = &cout;
1314 catch (exception&
e)