;
80 void Init()
override;
84 voidSetup(
const CArgs& args);
85 voidx_AliasLogFile();
90 CThreadExitDataxValidateThreadSeparateOutputs(
const string& filename);
96 size_tValidateOneDirectory(
stringdir_name,
106atomic<size_t> m_NumFiles{0};
117 if(in_filename.empty()) {
122path = in_filename.substr(0, pos);
126path.append(
".val");
128 if(! outputDir.empty()) {
134 returnunique_ptr<CNcbiOstream>(
newofstream(path));
145 autopOstr =
s_MakeOstream(filename, m_InputDir, m_OutputDir);
146 returnxValidate(filename, *pOstr);
151 returnxValidateSeparateOutputs(filename);
164 static const stringstr_sev[] = {
165 "NOTE",
"WARNING",
"ERROR",
"REJECT",
"FATAL",
"MAX" 170 if(sev == 0 && is_xml) {
195 if(args[
"logfile"]) {
196 if(
NStr::Equal(args[
"L"].AsString(), args[
"logfile"].AsString())) {
214arg_desc->AddOptionalKey
215(
"indir",
"Directory",
"Path to ASN.1 Files. '-x' specifies the input-file suffix",
218arg_desc->AddOptionalKey
219(
"i",
"InFile",
"Single Input File",
224arg_desc->AddOptionalKey(
225 "outdir",
"Directory",
"Output directory",
230arg_desc->AddOptionalKey(
231 "o",
"OutFile",
"Single Output File",
233arg_desc->AddOptionalKey(
234 "f",
"Filter",
"Substring Filter",
236arg_desc->AddDefaultKey
238arg_desc->AddFlag(
"u",
"Recurse");
239arg_desc->AddDefaultKey(
240 "R",
"SevCount",
"Severity for Error in Return Code\n\ 248arg_desc->AddDefaultKey(
249 "Q",
"SevLevel",
"Lowest Severity for Error to Show\n\ 257arg_desc->AddDefaultKey(
258 "P",
"SevLevel",
"Highest Severity for Error to Show\n\ 267arg_desc->SetConstraint(
"Q", constraint);
268arg_desc->SetConstraint(
"P", constraint);
269arg_desc->SetConstraint(
"R", constraint);
270arg_desc->AddOptionalKey(
271 "E",
"String",
"Only Error Code to Show",
274arg_desc->AddDefaultKey(
"a",
"a",
287arg_desc->AddFlag(
"b",
"Input is in binary format; obsolete",
289arg_desc->AddFlag(
"c",
"Batch File is Compressed; obsolete",
292arg_desc->AddFlag(
"quiet",
"Do not log progress");
295arg_desc->AddFlag(
"annot",
"Verify Seq-annots only");
297arg_desc->AddOptionalKey(
298 "L",
"OutFile",
"Log File",
301arg_desc->AddDefaultKey(
"v",
"Verbosity",
303 "\t1 Standard Report\n" 304 "\t2 Accession / Severity / Code(space delimited)\n" 305 "\t3 Accession / Severity / Code(tab delimited)\n" 309arg_desc->SetConstraint(
"v", v_constraint);
311arg_desc->AddFlag(
"cleanup",
"Perform BasicCleanup before validating (to match C Toolkit); obsolete",
313arg_desc->AddFlag(
"batch",
"Process NCBI release file (Seq-submit or Bioseq-set only)");
314arg_desc->AddFlag(
"huge",
"Execute in huge-file mode");
315arg_desc->AddFlag(
"disable-huge",
"Explicitly disable huge-files mode");
316arg_desc->SetDependency(
"disable-huge",
320arg_desc->AddOptionalKey(
321 "D",
"String",
"Path to lat_lon country data files",
330arg_desc->SetUsageContext(
"",
"ASN Validator");
333SetupArgDescriptions(arg_desc.release());
341 size_tnum_to_process = 0;
347 stringsuffix =
".ent";
349suffix = args[
"x"].AsString();
351 string mask=
"*"+ suffix;
355 boolseparate_outputs = !args[
"o"];
358 if(!m_OutputDir.empty()) {
359 stringoutputDirName =
NStr::Replace(dir_name, m_InputDir, m_OutputDir, 0, 1);
360 CDiroutputDir(outputDirName);
361 if(! outputDir.
Exists()) {
366 if(separate_outputs) {
368 stringfname = ii->GetName();
370(!args[
"f"] ||
NStr::Find(fname, args[
"f"].AsString()) !=
NPOS)) {
375{
returnxValidateThreadSeparateOutputs(fpath); };
383 stringfname = ii->GetName();
385(!args[
"f"] ||
NStr::Find(fname, args[
"f"].AsString()) !=
NPOS)) {
390{
returnxValidateThreadSingleOutput(fpath, *pMsgHandler); };
401 stringsubdir = ii->GetName();
404num_to_process += ValidateOneDirectory(
subname, recurse, pMsgHandler);
409 returnnum_to_process;
418 autofut = m_queue.GetNext();
419 if(!fut.has_value())
422 autoexit_data = *fut;
426combined_exit_data.
mReported+= exit_data.mReported;
428combined_exit_data.
mNumRecords+= exit_data.mNumRecords;
429 if(exit_data.mLongest > combined_exit_data.
mLongest) {
430combined_exit_data.
mLongest= exit_data.mLongest;
431combined_exit_data.
mLongestId= exit_data.mLongestId;
434 returncombined_exit_data;
442 if(args[
"indir"]) {
443m_InputDir = args[
"indir"].AsString();
446 if(args[
"outdir"]) {
447m_OutputDir = args[
"outdir"].AsString();
450mTaxUpdater.reset(
newedit::CTaxonomyUpdater(
nullptr));
452 CTime expires= GetFullVersion().GetBuildInfo().GetBuildTime();
458 NcbiCerr<<
"This copy of "<< GetProgramDisplayName()
459<<
" is more than 1 year old. Please download the current version if it is newer."<< endl;
465std::ostream* ValidErrorStream =
nullptr;
467ValidErrorStream = &args[
"o"].AsOutputFile();
471 stringlat_lon_path = args[
"D"].AsString();
472 if(! lat_lon_path.empty()) {
473SetEnvironment(
"NCBI_LAT_LON_DATA_PATH", lat_lon_path );
478cerr <<
"Warning: -b is deprecated; do not use"<< endl;
481 if(args[
"cleanup"]) {
482cerr <<
"Warning: -cleanup is deprecated; do not use"<< endl;
486 boolexception_caught =
false;
488 if(!m_InputDir.empty()) {
490 if(ValidErrorStream) {
494 autowriter_task = std::async([
this, &msgHandler] { msgHandler.
Write(); });
496 autocombination_task = std::async([
this, &exit_data]()
499 autofut = m_queue.GetNext();
500 if(fut.has_value()) {
501auto exitData = *fut;
502exit_data.mReported += exitData.mReported;
503exit_data.mNumRecords += exitData.mNumRecords;
504if (exitData.mLongest > exit_data.mLongest) {
505exit_data.mLongest = exitData.mLongest;
506exit_data.mLongestId = exitData.mLongestId;
515ValidateOneDirectory(m_InputDir, args[
"u"], &msgHandler);
516m_queue.request_stop();
518combination_task.wait();
519msgHandler.RequestStop();
521exit_data.
mReported+= msgHandler.GetNumReported();
524 autowriter_task = std::async([
this, ValidErrorStream] {
returnxCombinedStatsTask(); });
526ValidateOneDirectory(m_InputDir, args[
"u"]);
527m_queue.request_stop();
529exit_data = writer_task.get();
533 stringin_filename = (args[
"i"]) ? args[
"i"].AsString() :
"";
535 if(ValidErrorStream) {
536exit_data = xValidate(in_filename, *ValidErrorStream);
539exit_data = xValidate(in_filename, *pOstr);
545exception_caught =
true;
547 if(m_NumFiles == 0) {
548 ERR_POST(
"No matching files found");
551time_t stop_time = time(
NULL);
552 if(! mAppConfig->mQuiet ) {
554 LOG_POST_XX(Corelib_App, 1,
"Longest processing time "<< exit_data.mLongest <<
" seconds on "<< exit_data.mLongestId);
555 LOG_POST_XX(Corelib_App, 1,
"Total number of records "<< exit_data.mNumRecords);
558 return(exit_data.mReported > 0 || exception_caught);
587list<string> split_args;
588vector<const char*> new_argv;
590 if(argc==2 && argv && argv[1] && strchr(argv[1],
' '))
594argc = 1 + split_args.size();
595new_argv.reserve(argc);
596new_argv.push_back(argv[0]);
597 for(
auto& s : split_args) {
598new_argv.push_back(s.c_str());
600std::cerr << s.c_str() <<
" ";
605argv = new_argv.data();
string s_GetSeverityLabel(EDiagSev sev, bool is_xml)
#define asnvalidate_app_main
static unique_ptr< CNcbiOstream > s_MakeOstream(const string &in_filename, const string &inputDir=kEmptyStr, const string &outputDir=kEmptyStr)
ncbi::TMaskedQueryRegions mask
CThreadExitData xValidateSeparateOutputs(const string &filename)
int Run() override
Run the application.
void Setup(const CArgs &args)
unique_ptr< edit::CTaxonomyUpdater > mTaxUpdater
CThreadExitData xValidateThreadSingleOutput(const string &filename, CAsyncMessageHandler &msgHandler)
size_t ValidateOneDirectory(string dir_name, bool recurse, CAsyncMessageHandler *pMessageHandler=nullptr)
CThreadExitData xCombinedStatsTask()
CThreadExitData xValidateThreadSeparateOutputs(const string &filename)
CValidatorThreadPool m_thread_pool2
void Init() override
Initialize the application.
CThreadExitData xValidate(const string &filename, CNcbiOstream &ostr)
unique_ptr< CAppConfig > mAppConfig
CValidatorThreadPool m_thread_pool1
CThreadExitData ValidateOneFile(const string &infilename, CNcbiOstream &ostr)
void SetInvokeWrite(bool invokeWrite) override
static void SetupObjectManager(const CArgs &args, objects::CObjectManager &obj_mgr, TLoaders loaders=fDefault)
Set up the standard object manager data loaders according to the arguments provided above.
static void AddArgumentDescriptions(CArgDescriptions &arg_desc, TLoaders loaders=fDefault)
Add a standard set of arguments used to configure the object manager.
static void SetupArgDescriptions(CArgDescriptions *arg_desc)
Setup core splign argument descriptions for the application.
Include a standard set of the NCBI C++ Toolkit most basic headers.
const CNcbiRegistry & GetConfig(void) const
Get the application's cached configuration parameters (read-only).
int AppMain(int argc, const char *const *argv, const char *const *envp=0, EAppDiagStream diag=eDS_Default, const char *conf=NcbiEmptyCStr, const string &name=NcbiEmptyString)
Main function (entry point) for the NCBI application.
@ fHidden
Hide it in Usage.
@ eRequires
One argument requires another.
@ eExcludes
One argument excludes another.
@ eInputFile
Name of file (must exist and be readable)
@ eString
An arbitrary string.
@ eOutputFile
Name of file (must be writable)
@ eInteger
Convertible into an integer number (int or Int8)
bool SetLogFile(const string &file_name, EDiagFileType file_type=eDiagFile_All, bool quick_flush=true)
Set log files.
#define ERR_POST(message)
Error posting with file, line number information but without error codes.
EDiagSev
Severity level for the posted diagnostics.
#define LOG_POST_XX(error_name, err_subcode, message)
@ eDiagSevMin
Verbosity level for min. severity.
@ eDiagSevMax
Verbosity level for max. severity.
void Error(CExceptionArgs_Base &args)
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
TEntries GetEntries(const string &mask=kEmptyStr, TGetEntriesFlags flags=0) const
Get directory entries based on the specified "mask".
static string MakePath(const string &dir=kEmptyStr, const string &base=kEmptyStr, const string &ext=kEmptyStr)
Assemble a path from basic components.
virtual bool Exists(void) const
Check if directory "dirname" exists.
bool Create(TCreateFlags flags=fCreate_Default) const
Create the directory using "dirname" passed in the constructor.
static CRef< CObjectManager > GetInstance(void)
Return the existing object manager or create one.
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
static list< string > & Split(const CTempString str, const CTempString delim, list< string > &arr, TSplitFlags flags=0, vector< SIZE_TYPE > *token_pos=NULL)
Split a string using specified delimiters.
static SIZE_TYPE Find(const CTempString str, const CTempString pattern, ECase use_case=eCase, EDirection direction=eForwardSearch, SIZE_TYPE occurrence=0)
Find the pattern in the string.
static string & Replace(const string &src, const string &search, const string &replace, string &dst, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
static bool Equal(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2, ECase use_case=eCase)
Test for equality of a substring with another string.
static string & ReplaceInPlace(string &src, const string &search, const string &replace, SIZE_TYPE start_pos=0, SIZE_TYPE max_replace=0, SIZE_TYPE *num_replace=0)
Replace occurrences of a substring within a string.
@ fSplit_CanEscape
Allow \... escaping.
@ fSplit_MergeDelimiters
Merge adjacent delimiters.
@ eReverseSearch
Search in a backward direction.
@ eNocase
Case insensitive compare.
void Run(void)
Enter the main loop.
@ eCurrent
Use current time. See also CCurrentTime.
const struct ncbi::grid::netcache::search::fields::EXPIRES expires
Magic spell ;-) needed for some weird compilers... very empiric.
#define NCBI_SC_VERSION_PROXY
#define NCBI_TEAMCITY_BUILD_NUMBER_PROXY
Defines the CNcbiApplication and CAppException classes for creating NCBI applications.
#define GetArgs
Avoid preprocessor name clash with the NCBI C Toolkit.
Defines command line argument related classes.
NCBI C++ stream class wrappers for triggering between "new" and "old" C++ stream libraries.
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4