(it.m_CreateProteins) {
87macros.push_back(script);
102 if(it->IsSetLabel() && it->GetLabel().IsStr()) {
103 column= it->GetLabel().GetStr().substr(
string(
"Column.").length(),
NPOS);
110 if(it->IsSetData() && it->GetData().IsStr()) {
111 stringcol_meta_info = it->GetData().GetStr();
113 if(skipped ==
"true") {
124 _ASSERT(!qualifier_type.empty());
136 stringiterator =
x_GetIterator(qualifier_type, field_type, qualifier,
true);
138[field_type, &iterator](
const SOneMacroData& elem){ return elem.m_Fieldtype == field_type; });
141 if(it->m_Iterator.empty()) {
142it->m_Iterator = iterator;
144it->m_Values.emplace_back(qualifier,
column);
145it->m_ColumnInfo.push_back(col_meta_info);
161 stringmacro_script =
"MACRO TableReaderMacro \"Description\"\n";
162macro_script +=
"VAR\n";
166macro_script +=
x_GetVariables(del_options, list_update_mrna) +
"\n";
167macro_script +=
"FOR EACH "+
data.m_Iterator +
"\n";
173vector<string> pure_constraints;
174pure_constraints.reserve(constraints.size());
175 for(
autop : constraints) {
176pure_constraints.push_back(p.second);
178macro_script +=
"WHERE "+
NStr::Join(pure_constraints,
" AND ") +
"\n";
179macro_script +=
"DO\n"+ do_function +
"\nDONE\n";
180macro_script +=
"---------------------------------------------------\n";
186 stringmacro_script =
"MACRO CreateProtFeats \"Create full length protein features\"\n";
187macro_script +=
"FOR EACH TSEntry\n";
188macro_script +=
"DO\n"+ macro::CMacroFunction_CreateProteinFeats::GetFuncName() +
"();\nDONE\n";
189macro_script +=
"---------------------------------------------------\n";
202 if(list_update_mrna) {
210 const string& qualifier,
boolapply)
212 if(qual_type.empty())
216 returnmacro::CMacroBioData::sm_BioSource;
224 returnmacro::CMacroBioData::sm_SeqNa;
229 returnmacro::CMacroBioData::sm_Seq;
232 returnmacro::CMacroBioData::sm_MolInfo;
237 returnmacro::CMacroBioData::sm_StrComm;
241 returnmacro::CMacroBioData::sm_Pubdesc;
245 returnmacro::CMacroBioData::sm_SeqNa;
254vector<string> tokens;
256 if(tokens.size() == 2) {
261 returnmacro::CMacroBioData::sm_SeqFeat;
266 stringrna_type, ncRNA_class, rna_qual;
277 if(del ==
"\t") del =
"\\t";
282vector<string> tokens;
284 if(tokens.size() == 2) {
292 stringrna_type, ncRNA_class, rna_qual;
299 if(path.find(
',') !=
NPOS) {
300vector<string> tokens;
302path =
"\""+ tokens[0] +
"\", \""+ tokens[1] +
"\"";
304 else if(path.find(
'(') !=
NPOS) {
308path =
"\""+ path +
"\"";
317 if(
data.m_Iterator == macro::CMacroBioData::sm_MolInfo) {
318constraint = macro::CMacroFunction_GetSeqdesc::sm_BsrcForMolinfo +
string(
"(") + path +
")";
320 else if(
data.m_Iterator == macro::CMacroBioData::sm_StrComm ||
321 data.m_Iterator == macro::CMacroBioData::sm_Pubdesc) {
322constraint = macro::CMacroFunction_GetSeqdesc::sm_BsrcForSeqdesc +
string(
"(") + path +
")";
324 else if(
data.m_Iterator == macro::CMacroBioData::sm_Seq ||
325 data.m_Iterator == macro::CMacroBioData::sm_SeqNa) {
326constraint = macro::CMacroFunction_GetSeqdesc::sm_BsrcForSeq +
string(
"(") + path +
")";
329constraint = macro::CMacroFunction_GetSeqdesc::sm_BsrcForFeat +
string(
"(") + path +
")";
331 else if(
data.m_Iterator == macro::CMacroBioData::sm_BioSource) {
341 if(
data.m_Iterator == macro::CMacroBioData::sm_MolInfo) {
343constraint =
CTempString(macro::CMacroFunction_GetSequence::sm_SeqForDescr) +
"("+ path +
")";
346 else if(
data.m_Iterator == macro::CMacroBioData::sm_Seqdesc) {
348constraint =
CTempString(macro::CMacroFunction_GetSequence::sm_SeqForDescr) +
"("+ path +
")";
353constraint =
CTempString(macro::CMacroFunction_GetSequence::sm_SeqForFeat) +
"("+ path +
")";
356constraint =
CTempString(macro::CMacroFunction_GetSeqdesc::sm_MolinfoForFeat) +
"("+ path +
")";
359 else if(
data.m_Iterator == macro::CMacroBioData::sm_BioSource) {
361constraint =
CTempString(macro::CMacroFunction_GetSequence::sm_SeqForDescr) +
"("+ path +
")";
364constraint =
CTempString(macro::CMacroFunction_GetSeqdesc::sm_MolinfoForBsrc) +
"("+ path +
")";
367 else if(
data.m_Iterator == macro::CMacroBioData::sm_Seq ||
368 data.m_Iterator == macro::CMacroBioData::sm_SeqNa ||
369 data.m_Iterator == macro::CMacroBioData::sm_SeqAa) {
375constraint = macro::CMacroFunction_GetDBLink::GetFuncName() +
"(\""+
m_MatchField.
m_GUIName+
"\")";
379constraint = macro::CMacroFunction_StructCommDatabase::GetFuncName() +
"()";
382constraint = macro::CMacroFunction_StructCommFieldname::GetFuncName() +
"()";
389constraint = macro::CMacroFunction_StructCommField::GetFuncName();
390constraint +=
"(\""+ field_name +
"\")";
398 if(!constraint.empty()) {
412 stringfield_in_macro;
414 if(field_name_panel) {
415 stringfield_name = field_name_panel->
GetFieldName(
false);
420 if(!str_constraint.empty()) {
421constraints.emplace_back(field_in_macro, str_constraint);
449 stringfirst_field =
data.m_Values.front().first;
450 stringfeat_type, feat_qual;
455 boolupdate_mrna =
false;
457 data.m_Iterator, update_mrna,
data.m_ColumnInfo);
461 stringfirst_field =
data.m_Values.front().first;
462vector<string> tokens;
464 if(tokens.size() == 2) {
467 boolupdate_mrna =
false;
469 data.m_Iterator, update_mrna,
data.m_ColumnInfo);
472 stringfirst_field =
data.m_Values.front().first;
473 stringrna_type, ncRNA_class, rna_qual;
479rna_type,
data.m_ColumnInfo);
482 if(
data.m_Iterator == macro::CMacroBioData::sm_Protein &&
485 for(
auto&& it :
data.m_Values) {
491 data.m_CreateProteins =
true;
500 if(macros.empty()) {
501 LOG_POST(
Info<<
"List of macros generated by Table Reader is empty");
508 boolapply_pmid =
false;
509 for(
auto& it : macros) {
510 if(it.find(macro::CMacroFunction_SetPubPMID::GetFuncName()) !=
NPOS)
522 autostart = chrono::steady_clock::now();
523macro::CMacroEngine macro_engine;
524 booldata_updated =
false;
526 stringignored_lines;
528 for(
auto&& it : macros) {
532 LOG_POST(
Info<<
"Parsing the macro for Table Reader has failed");
536macro::CMacroBioData bio_data(entry);
538macro_engine.Exec(*macro_rep, bio_data, macro_cmd,
true);
540 catch(
constmacro::CMacroExecException& e) {
542 if(e.GetErrCode() == macro::CMacroExecException::eMultipleEntries) {
547 string msg= e.ReportAll();
548 size_tpos =
msg.find(
"'");
549 size_tend_pos =
msg.find(
" ([Error]");
550 if(pos !=
NPOS&& end_pos !=
NPOS) {
551 msg=
msg.substr(pos, end_pos - pos);
554report->SetTitle(
wxT(
"Duplicate row ids"));
556report->Show(
true);
557 NCBI_THROW(
CException, eInvalid,
"Multiple rows apply to the same object. Cannot continue.");
562 LOG_POST(
Info<<
"Execution of the macro has failed at "<<
563macro_rep->GetTitle() <<
" step:\n"<< err.
ReportAll());
567 const auto& macro_stat = macro_engine.GetStatistics();
568 const auto& report = macro_stat.GetMacroReport();
569 if(!report.GetLog().empty()) {
570report_all += report.GetName() +
":\n"+ report.GetLog() +
"\n";
573 const auto& logs = macro_stat.GetFunctionsLog();
575report_all += report.GetName() +
":\n";
577 for(
const auto& it : logs) {
578report_all += it->Print() +
"\n";
582 if(!report.GetErrorLog().empty()) {
583report_all +=
"\nERRORS:\n"+ report.GetErrorLog();
586 const auto& unmatched = macro_stat.GetUnmatchedTableEntries();
587 if(!unmatched.empty()) {
588 _ASSERT(unmatched.size() == 1);
589 stringtemp = unmatched.front().first;
590 int count= unmatched.front().second;
592 size_tnl_pos = temp.find(
"\n");
594temp = temp.substr(nl_pos + 1);
595nl_pos = temp.find(
"\n");
596 string value= temp.substr(0, nl_pos);
598 if(!ignored_lines.empty()) {
599ignored_lines +=
"\n";
601ignored_lines +=
value;
608data_updated |= macro_stat.HasDataUpdated();
623cmd_processor->
Execute(macro_cmd);
625 autostop = chrono::steady_clock::now();
626chrono::duration<double> elapsed = stop - start;
627 LOG_POST(
Info<<
"Total time spent on executing the macro is: "<< elapsed.count() <<
" seconds.");
637 NcbiInfoBox(
"Table was applied successfully. No data change has occurred.");
639 else if(!ignored_lines.empty()) {
640 NcbiInfoBox(
"No matches were found for these values present in the table:\n"+ ignored_lines);
static string s_GetFunction(const TStringPairsVector &values, TConstraints &constraints, bool del_enabled, const string &target, bool update_mrna, const vector< string > &column_info={})
static string s_GetFunction(const TStringPairsVector &values, TConstraints &constraints, bool del_enabled, const vector< string > &column_info={})
static string s_GetFunction(const TStringPairsVector &values, TConstraints &constraints, bool del_enabled, const string &target, bool update_mrna, const vector< string > &column_info={})
static string s_GetFunction(const TStringPairsVector &values, TConstraints &constraints, bool del_enabled, const vector< string > &column_info={})
static string s_GetFunction(const TStringPairsVector &values, TConstraints &constraints, bool del_enabled, const vector< string > &column_info={})
static string s_GetFunction(const TStringPairsVector &values, TConstraints &constraints, bool del_enabled, const vector< string > &column_info={})
static string s_GetFunction(const TStringPairsVector &values, TConstraints &constraints, bool del_enabled, const string &target_rna_type, const vector< string > &column_info={})
static string s_GetFunction(const TStringPairsVector &values, TConstraints &constraints, bool del_enabled, const vector< string > &column_info={})
static string s_GetFunction(const TStringPairsVector &values, TConstraints &constraints, bool del_enabled, const vector< string > &column_info={})
static string s_GetMatchFieldConstraint(const SFieldFromTable &match_field, const string &delimiter, EMacroFieldType field_type, const string &target=kEmptyStr)
static string s_GetMacroFieldName(const string &field_name, const string &target, const string &selected_field=kEmptyStr)
void AddCommand(IEditCommand &command)
CFieldNamePanel * GetFieldNamePanel(void)
string GetMacroStringConstraint(const string &field_name)
static string s_GetMacroFieldName(const string &feature, const string &qualifier, const string &target, const string &selected_field=kEmptyStr)
static string AutoMatch(string field_name)
virtual string GetFieldName(const bool subfield=false)=0
Returns the name of the field as selected in the panel.
virtual string GetMacroFieldName(const string &target, const string &selected_field=kEmptyStr)
static bool IsFeature(const string &target)
void SetText(const wxString &text)
implements special composite command, which does not call to its internal commands when run the very ...
string GetAsnPathToFieldName(const string &field, EMacroFieldType type, const string &target=kEmptyStr)
static CMacroEditorContext & GetInstance()
static CRef< CCmdComposite > GetPropagateUpCommand(objects::CSeq_entry_Handle seh)
static CRef< CCmdComposite > GetPropagateDownCommand(objects::CSeq_entry_Handle seh)
static string s_GetMacroFieldName(const string &rna_type, const string &qual_field, const string &target, const string &selected_field=kEmptyStr)
TVecMacroNames CreateMacros(const wxString &filename, CRef< objects::CUser_object > column_properties, const SColumnDelimiters &del_options, CConstraintPanel *panel=nullptr, bool test=false)
CMacroWorker::TVecMacroNames TVecMacroNames
SFieldFromTable m_MatchField
TStringPairsVector x_GetStringConstraint(const string &target)
static bool s_LooksLikeHeader(const string &value)
vector< SOneMacroData > m_MacroVec
string x_GetFunction(SOneMacroData &data, TStringPairsVector &constraints)
CConstraintPanel * m_ConstraintPnl
void x_GatherValuesAndMatchField()
void x_GetMatchFieldConstraint(const SOneMacroData &data, const string &delimiter, TStringPairsVector &constraints)
string x_GetVariables(const SColumnDelimiters &del_options, bool list_update_mrna=false) const
string x_GetCreateProtFeatsMacro()
EMacroFieldType m_MatchFieldType
CConstRef< objects::CUser_object > m_ColProperties
string x_GetIterator(const string &qual_type, EMacroFieldType &field_type, const string &qualifier, bool apply=false)
string x_GetMacro(SOneMacroData &data, const SColumnDelimiters &del_options)
bool RunMacro(const TVecMacroNames ¯os, objects::CSeq_entry_Handle entry, ICommandProccessor *cmd_processor)
CTempString implements a light-weight string on top of a storage buffer whose lifetime management is ...
Undo/Redo interface for editing operations.
virtual void Execute(IEditCommand *command, wxWindow *window=0)=0
const char * kStructCommFieldName
const char * kFieldTypeSeqId
const char * kStructCommDBName
const char * kStructCommFieldValuePair
#define test(a, b, c, d, e)
static const char * column
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
string ReportAll(TDiagPostFlags flags=eDPF_Exception) const
Report all exceptions.
void Info(CExceptionArgs_Base &args)
bool StringsAreEquivalent(const string &name1, const string &name2)
virtual void Execute()
Do the editing action.
virtual void Unexecute()
Undo (opposite to Execute())
EDialogReturnValue NcbiInfoBox(const string &message, const string &title="Info")
specialized Message Box function for reporting general information messages
#define MSerial_AsnText
I/O stream manipulators â.
void Reset(void)
Reset reference object.
TObjectType & GetObject(void) const
Get object.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
static bool StringToBool(const CTempString str)
Convert string to bool.
vector< pair< string, string > > TStringPairsVector
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 const string BoolToString(bool value)
Convert bool to string.
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate whitespace in a string (in-place)
static string Join(const TContainer &arr, const CTempString &delim)
Join strings using the specified delimiter.
static bool StartsWith(const CTempString str, const CTempString start, ECase use_case=eCase)
Check if a string starts with a specified prefix value.
static bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another string.
@ eNocase
Case insensitive compare.
Macro engine for macro execution.
Functions used in the DO/DONE section affecting the top seq-entry.
void UpdateConstraintsForDualCdsGeneProt(TConstraints &constraints, const string &src_feat)
CTempString UpdateTargetForFeatures(const string &feature, const string &qualifier, bool for_removal=false)
void UpdateConstraintsForFeatures(TConstraints &constraints, const string &feature)
void GetRNASpecificFieldsForTableReader(const string &field_name, string &rna_type, string &ncRNA_type, string &rna_qual)
CTempString UpdateTargetForRnas(const string &rna_type)
void UpdateConstraintsForRnas(TConstraints &constraints, const CArgumentList &arg_list)
CTempString UpdateTargetForCdsGeneProt(const string &fieldname)
void GetFeatureAndField(const string &field_name, string &feature, string &field)
string GetPropertyFromInfo(const string &info, const string &property)
const string kConvertMulti
const string kMultipleSpsOnly
constexpr bool empty(list< Ts... >) noexcept
const GenericPointer< typename T::ValueType > T2 value
static const char delimiter[]
static SLJIT_INLINE sljit_ins msg(sljit_gpr r, sljit_s32 d, sljit_gpr x, sljit_gpr b)
bool m_Merge_first_two_cols
bool m_Multiple_spaces_only
EMacroFieldType m_Fieldtype
TStringPairsVector m_Values
vector< string > m_ColumnInfo
wxString GetAbsolutePath(const wxString &localpath)
string ToStdString(const wxString &s)
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