Closed GoogleCodeExporter closed 9 years ago
Okay. I have gotten a little further along.
This is my new main function. My current problem is that I cannot open the
mzXML file for reading. No obvious reason why, but the code at least compiles
and doesn't give errors. Any suggestions?
/******************************************************************************/
int main(int argc, char* argv[]) {
if(argc < 2) {
cerr << "\nUSAGE: mzMLreaderCPP.exe scan_index mzXML\n\n";
return 0;
}
int scan = atoi(argv[1]); // provide scan number to retrieve from the mzXML file
string mzXML_file = argv[2];
cerr << "\nInput file: " << mzXML_file << "\nScan index: " << scan << endl << endl;
Spectrum S;
MSReader *reader = new MSReader();
//bool status = reader->readFile(mzXML_file.c_str(), S, scan);
bool status = reader->readFile(mzXML_file.c_str(), S);
if(status) {
cerr << "Opened " << mzXML_file << endl;
}
else cerr << "Unable to open " << mzXML_file << endl;
delete(reader);
return 0;
}
/******************************************************************************/
Original comment by damian.f...@gmail.com
on 29 Jul 2013 at 1:34
Hi Damian,
You're quite right that example code is needed. I only have a few minutes right
now, so I'll copy a quick program that I usually use as an example. If I find
time later, I will post the modifications to your code to get it to work.
Pretty much you have it figured out, you're just stuck on some of the
deprecated functions that I have to carry along for other people.
Cheers,
Mike
#include <iostream>
#include <iomanip>
#include "MSToolkitTypes.h"
#include "MSReader.h"
#include "MSObject.h"
#include "Spectrum.h"
using namespace std;
int main(int argc, char *argv[]){
//Here are all the variable we are going to need
MSReader r;
Spectrum s;
int j;
if(argc==1){
printf("DESCRIPTION: Reads an MS/MS spectrum from any MSToolkit supported file type and outputs to screen in MS2 format.\n\n");
printf("USAGE: MSSingleScan [scan number] [file]\n");
exit(0);
}
//Adding filters are necessary. At least one scan type must be specified.
r.setFilter(MS1);
r.addFilter(MS2);
//This is where you grab a file. Specify the filename (or NULL to read from
//the same file as the last read), a spectrum object, and (optionally) a scan
//number. If you omit the scan number, the next scan after the last read is
//extracted from the file.
r.readFile(argv[2],s,atoi(argv[1]));
//Your scan number will equal 0 if loading failed. Possible reason for failure
//is end of file or requesting a non-existent scan number.
if(s.getScanNumber()==0) exit(-1);
printf("S\t%d\t%d",s.getScanNumber(),s.getScanNumber());
for(j=0;j<s.sizeMZ();j++){
printf("\t%.*lf",4,s.getMZ(j));
}
printf("\n");
if(s.getRTime()>0) printf("I\tRTime\t%.*f\n",4,s.getRTime());
for(j=0;j<s.sizeZ();j++){
printf("Z\t%d\t%.*f\n",s.atZ(j).z,6,s.atZ(j).mz);
}
for(j=0;j<s.size();j++){
printf("%.4f %.4f\n",s.at(j).mz,s.at(j).intensity);
}
return 0;
}
Original comment by mhoopm...@systemsbiology.org
on 29 Jul 2013 at 5:15
I'll handle this one.
Original comment by mhoopm...@systemsbiology.org
on 12 Aug 2014 at 4:16
Original comment by mhoopm...@systemsbiology.org
on 12 Aug 2014 at 4:16
Original issue reported on code.google.com by
damian.f...@gmail.com
on 28 Jul 2013 at 2:35