Skip to content

Commit

Permalink
updated for windows compatibility
Browse files Browse the repository at this point in the history
  • Loading branch information
Henric Zazzi committed Apr 11, 2014
1 parent 87ca16a commit aeb76d3
Show file tree
Hide file tree
Showing 4 changed files with 71 additions and 40 deletions.
4 changes: 2 additions & 2 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ set(CMAKE_MODULE_PATH ${CMAKE_CURRENT_SOURCE_DIR}/cmake)

set(POUT2MZIML_VERSION_MAJOR "0")
set(POUT2MZIML_VERSION_MINOR "2")
set(POUT2MZIML_VERSION_PATCH "6")
set(POUT2MZIML_VERSION_PATCH "7")

configure_file( version_config.h.in ${CMAKE_BINARY_DIR}/version_config.h )

Expand Down Expand Up @@ -41,7 +41,7 @@ include_directories(${XSD_INCLUDE_DIR})

SET (Boost_ADDITIONAL_VERSIONS "1.36" "1.36.0" "1.41" "1.41.0" "1.39" "1.39.0" "1.42.0" "1.42" "1.43.0"
"1.43." "1.44.0" "1.44.0" "1.45.0" "1.45" "1.46.0" "1.46" "1.47.0" "1.47")
find_package(Boost COMPONENTS filesystem system REQUIRED)
find_package(Boost COMPONENTS filesystem system program_options REQUIRED)
if(Boost_FOUND)
message(STATUS "Package Boost-${Boost_VERSION} found : ${Boost_INCLUDE_DIR}")
else(Boost_FOUND)
Expand Down
32 changes: 31 additions & 1 deletion global.h
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,37 @@ namespace global {
}
}
//------------------------------------------------------------------------------
// strings used for reporting error messages and status
// strings used for options
//------------------------------------------------------------------------------
namespace CMDOPTIONS {
const char HELP_OPTION[]="help,h";
const char HELP_TEST[]="help";
const char HELP_TEXT[]="Displays available commands\n";
const char PERCOLATORFILE_OPTION[]="percolatorfile,p";
const char PERCOLATORFILE_TEST[]="percolatorfile";
const char PERCOLATORFILE_TEXT[]="Percolator Out XML result file\n";
const char MZIDFILE_OPTION[]="mzidfile,m";
const char MZIDFILE_TEST[]="mzidfile";
const char MZIDFILE_TEXT[]="MzIdentML input file\n";
const char MZIDOUTPUT_OPTION[]="output,o";
const char MZIDOUTPUT_TEST[]="output";
const char MZIDOUTPUT_TEXT[]="Outputs the results to original filename+[File]+.mzid.\n"
"DEFAULT: output to stdout\n";
const char MZIDFILES_OPTION[]="filesmzid,f";
const char MZIDFILES_TEST[]="filesmzid";
const char MZIDFILES_TEXT[]="File containing a list of mzIdentML filenames\n";
const char DECOY_OPTION[]="decoy,d";
const char DECOY_TEST[]="decoy";
const char DECOY_TEXT[]="Only adds results to entries with decoy set to true. DEFAULT: false\n";
const char VALIDATION_OPTION[]="validate,v";
const char VALIDATION_TEST[]="validate";
const char VALIDATION_TEXT[]="Sets that validation of XML schema should not be performed. Faster parsing.\n";
const char WARNING_OPTION[]="warning,w";
const char WARNING_TEST[]="warning";
const char WARNING_TEXT[]="Sets that upon warning the software should terminate.\n";
}
//------------------------------------------------------------------------------
// strings used for reporting error messages, status
//------------------------------------------------------------------------------
namespace PRINT_TEXT {
const char HELP[]="pout2mzid [OPTIONS]\n"
Expand Down
74 changes: 38 additions & 36 deletions main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -17,8 +17,10 @@

#include "version_config.h"
#include "xmlio.h"
#include "boost/program_options.hpp"

//------------------------------------------------------------------------------
namespace prgm_opt=boost::program_options;
PercolatorOutI percolator;
MzIDIO mzid;
boost::unordered_map<PercolatorOutFeatures, string, PercolatorOutFeatures> pout_values;
Expand All @@ -30,44 +32,44 @@ void CleanUp(bool exitvalue) {
}
//------------------------------------------------------------------------------
int main(int argc, char **argv) {
int opt;
prgm_opt::variables_map option_map;
prgm_opt::options_description options("Options");

try {
while ((opt=getopt(argc,argv,"o::m:p:f:vdhw")) != EOF)
switch(opt) {
case 'd':
percolator.setDecoy();
break;
case 'v':
percolator.unsetValidation();
mzid.unsetValidation();
break;
case 'o':
mzid.setOutputFileEnding(optarg?optarg:MZID_PARAM::FILE_END_DEFAULT);
break;
case 'p':
if (!percolator.setFilename(optarg))
THROW_ERROR_VALUE(PRINT_TEXT::NO_PERCOLATOR_FILE,optarg);
break;
case 'm':
mzid.setFilename(optarg);
break;
case 'f':
if (!mzid.addFilenames(optarg))
THROW_ERROR_VALUE(PRINT_TEXT::NO_MZID_FILE,optarg);
break;
case 'w':
mzid.unsetWarningFlag();
break;
case 'h':
case '?':
printVersion();
cout << PRINT_TEXT::HELP << endl;
CleanUp(EXIT_SUCCESS);
break;
default:
CleanUp(EXIT_SUCCESS);
}
prgm_opt::arg="[File]";
options.add_options()
(CMDOPTIONS::HELP_OPTION,CMDOPTIONS::HELP_TEXT)
(CMDOPTIONS::PERCOLATORFILE_OPTION,prgm_opt::value<string>()->required(),CMDOPTIONS::PERCOLATORFILE_TEXT)
(CMDOPTIONS::MZIDFILE_OPTION,prgm_opt::value<string>()->required(),CMDOPTIONS::MZIDFILE_TEXT)
(CMDOPTIONS::MZIDOUTPUT_OPTION,prgm_opt::value<string>()->required(),CMDOPTIONS::MZIDOUTPUT_TEXT)
(CMDOPTIONS::MZIDFILES_OPTION,prgm_opt::value<string>()->required(),CMDOPTIONS::MZIDFILES_TEXT)
(CMDOPTIONS::DECOY_OPTION,CMDOPTIONS::DECOY_TEXT)
(CMDOPTIONS::VALIDATION_OPTION,CMDOPTIONS::VALIDATION_TEXT)
(CMDOPTIONS::WARNING_OPTION,CMDOPTIONS::WARNING_TEXT);
prgm_opt::store(prgm_opt::parse_command_line(argc,argv,options),option_map);
if (option_map.count(CMDOPTIONS::HELP_TEST)) {
printVersion();
cout << options;
CleanUp(EXIT_SUCCESS);
}
if (option_map.count(CMDOPTIONS::DECOY_TEST))
percolator.setDecoy();
if (option_map.count(CMDOPTIONS::VALIDATION_TEST)) {
percolator.unsetValidation();
mzid.unsetValidation();
}
if (option_map.count(CMDOPTIONS::MZIDOUTPUT_TEST))
mzid.setOutputFileEnding(option_map[CMDOPTIONS::MZIDOUTPUT_TEST].as<string>());
if (option_map.count(CMDOPTIONS::PERCOLATORFILE_TEST))
if (!percolator.setFilename(option_map[CMDOPTIONS::PERCOLATORFILE_TEST].as<string>()))
THROW_ERROR_VALUE(PRINT_TEXT::NO_PERCOLATOR_FILE,option_map[CMDOPTIONS::PERCOLATORFILE_TEST].as<string>());
if (option_map.count(CMDOPTIONS::MZIDFILE_TEST))
mzid.setFilename(option_map[CMDOPTIONS::MZIDFILE_TEST].as<string>());
if (option_map.count(CMDOPTIONS::MZIDFILES_TEST))
if (!mzid.addFilenames(option_map[CMDOPTIONS::MZIDFILES_TEST].as<string>()))
THROW_ERROR_VALUE(PRINT_TEXT::NO_MZID_FILE,option_map[CMDOPTIONS::MZIDFILES_TEST].as<string>());
if (option_map.count(CMDOPTIONS::WARNING_TEST))
mzid.unsetWarningFlag();
if (!mzid.checkFilenames())
CleanUp(EXIT_FAILURE);
if (percolator.noFilename())
Expand Down
1 change: 0 additions & 1 deletion xmlio.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@ using namespace std;
namespace MZID_PARAM {
const char SCHEMA_NAME[]="http://psidev.info/psi/pi/mzIdentML/1.1";
const char SCHEMA[]="mzIdentML1.1.0.xsd";
const char FILE_END_DEFAULT[]="_output";
enum ELEMENT_TYPE { USERPARAM,CVPARAM };

namespace ELEMENT_DATA {
Expand Down

0 comments on commit aeb76d3

Please sign in to comment.