MCPcopy Create free account
hub / github.com/OpenMS/OpenMS / main_

Method main_

src/topp/SageAdapter.cpp:429–646  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

427
428
429 ExitCodes main_(int, const char**) override
430 {
431 //-------------------------------------------------------------
432 // parsing parameters
433 //-------------------------------------------------------------
434
435 // do this early, to see if Sage is installed
436 String sage_executable = getStringOption_("sage_executable");
437 String proc_stdout, proc_stderr;
438 TOPPBase::ExitCodes exit_code = runExternalProcess_(sage_executable.toQString(), QStringList() << "--help", proc_stdout, proc_stderr, "");
439 auto major_minor_patch = getVersionNumber_(proc_stdout);
440 String sage_version = std::get<0>(major_minor_patch) + "." + std::get<1>(major_minor_patch) + "." + std::get<2>(major_minor_patch);
441
442 //-------------------------------------------------------------
443 // run sage
444 //-------------------------------------------------------------
445 StringList input_files = getStringList_("in");
446 String output_file = getStringOption_("out");
447 String output_folder = File::path(output_file);
448 String fasta_file = getStringOption_("database");
449 int batch = getIntOption_("batch_size");
450 String decoy_prefix = getStringOption_("decoy_prefix");
451
452 // create config
453 String config = imputeConfigIntoTemplate();
454
455 // store config in config_file
456 OPENMS_LOG_INFO << "Creating temp file name..." << std::endl;
457 String config_file = File::getTempDirectory() + "/" + File::getUniqueName() + ".json";
458 OPENMS_LOG_INFO << "Creating Sage config file..." << config_file << std::endl;
459 ofstream config_stream(config_file.c_str());
460 config_stream << config;
461 config_stream.close();
462
463 // keep config file if debug mode is set
464 if (getIntOption_("debug") > 1)
465 {
466 String debug_config_file = output_folder + "/" + File::getUniqueName() + ".json";
467 ofstream debug_config_stream(debug_config_file.c_str());
468 debug_config_stream << config;
469 debug_config_stream.close();
470 }
471
472 QStringList arguments;
473 arguments << config_file.toQString()
474 << "-f" << fasta_file.toQString()
475 << "-o" << output_folder.toQString()
476 << "--write-pin";
477 if (batch >= 1) arguments << "--batch-size" << QString(batch);
478 for (auto s : input_files) arguments << s.toQString();
479
480 OPENMS_LOG_INFO << "Sage command line: " << sage_executable << " " << arguments.join(' ').toStdString() << std::endl;
481
482 // Sage execution with the executable and the arguments StringList
483 exit_code = runExternalProcess_(sage_executable.toQString(), arguments);
484 if (exit_code != EXECUTION_OK)
485 {
486 return exit_code;

Callers

nothing calls this directly

Calls 15

concatenateFunction · 0.85
getInstanceFunction · 0.85
metaValueExistsMethod · 0.80
getMetaValueMethod · 0.80
setSearchEngineMethod · 0.80
getEnzymeMethod · 0.80
getParam_Method · 0.80
getToolPrefixMethod · 0.80
setMSLevelsMethod · 0.80
setFillDataMethod · 0.80
getNativeIDMethod · 0.80

Tested by

no test coverage detected