75 void CMacroFunction_SwapRelatedFeaturesQual_Depr::TheFunction()
79 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
80 if (!src_feat || !scope)
94 src_objs = m_Args[0]->GetObjects();
97 x_GetObjectsFromRef(src_objs, 0);
100 if (src_objs.empty()) {
108 if (feat_list.empty()) {
114 new_feat->Assign(*orig_feat);
115 CObjectInfo objInfo(new_feat.GetPointer(), new_feat.GetPointer()->GetTypeInfo());
118 const string& dest_field = m_Args[2]->GetString();
119 if (!
GetFieldsByName(&dest_objs, objInfo, dest_field) || dest_objs.empty()) {
123 CMQueryNodeValue::TObs::iterator src_it = src_objs.begin();
124 CMQueryNodeValue::TObs::iterator dest_it = dest_objs.begin();
126 while (src_it != src_objs.end() && dest_it != dest_objs.end()) {
130 m_QualsChangedCount += 2;
136 if (m_QualsChangedCount) {
137 m_DataIter->SetModified();
141 m_DataIter->RunCommand(
cmd, m_CmdComposite);
144 report[
"swapping qualifiers"] = m_QualsChangedCount;
146 x_LogChangedQuals(fnc_log);
150 bool CMacroFunction_SwapRelatedFeaturesQual_Depr::x_ValidArguments()
const
152 if (m_Args.size() != 3) {
156 if (!(m_Args[0]->IsString() || m_Args[0]->AreObjects() || m_Args[0]->IsRef()))
159 for (
size_t index = 1; index < m_Args.size(); ++index) {
185 const string& field_name = m_Args[0]->GetString();
190 res_oi = m_Args[0]->GetObjects();
193 x_GetObjectsFromRef(res_oi, 0);
196 if (res_oi.empty()) {
200 m_QualsChangedCount = s_RemoveFields(m_DataIter, res_oi);
202 if (m_QualsChangedCount) {
204 report[
"removal of qualifiers"] = m_QualsChangedCount;
206 x_LogChangedQuals(fnc_log);
212 if (
m_Args.empty())
return false;
213 bool first_ok = (
m_Args[0]->IsString() ||
m_Args[0]->AreObjects() ||
m_Args[0]->IsRef());
214 return (
m_Args.size() == 1 && first_ok);
222 Int4 quals_changed = 0;
226 bool is_gene_suppressed_before =
false;
227 bool is_gene_suppressed_after =
false;
232 is_gene_suppressed_before = gene_xref && gene_xref->
IsSuppressed();
267 dataiter->SetToDelete(
true);
284 dataiter->SetToDelete(
true);
294 cleanup.BasicCleanup(*seq_feat);
299 if (!is_gene_suppressed_before && is_gene_suppressed_after)
313 dataiter->SetModified();
315 return quals_changed;
324 bsrc.
SetOrg().SetOrgname().ResetMod();
342 void CMacroFunction_RemoveModifier::TheFunction()
346 x_GetObjectsFromRef(res_oi, 0);
347 if (res_oi.empty()) {
361 m_QualsChangedCount++;
365 if (m_QualsChangedCount) {
369 m_DataIter->SetModified();
372 report[
"removing source modifiers"] = m_QualsChangedCount;
374 x_LogChangedQuals(fnc_log);
378 bool CMacroFunction_RemoveModifier::x_ValidArguments()
const
403 res_oi = m_Args[0]->GetObjects();
406 x_GetObjectsFromRef(res_oi, 0);
410 if (res_oi.empty()) {
416 x_RmvOutsideFields(res_oi, *options);
418 if (m_QualsChangedCount) {
420 m_DataIter->SetModified();
423 log << m_DataIter->GetBestDescr() <<
": removed text outside string in " << m_QualsChangedCount <<
" qualifiers";
425 bool update_mrna = (m_Args.size() == 10) ? m_Args[9]->GetBool() :
false;
431 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
436 m_DataIter->RunCommand(
cmd, m_CmdComposite);
437 log <<
", applied " + prot_product +
" to mRNA product name ";
447 string left_del =
m_Args[start_index + 1]->GetString();
448 bool remove_before_match =
false;
449 if (
m_Args[start_index]->GetBool()) {
461 remove_before_match =
m_Args[start_index + 2]->GetBool();
466 string right_del =
m_Args[start_index + 4]->GetString();
467 bool remove_after_match =
false;
468 if (
m_Args[start_index + 3]->GetBool()) {
480 remove_after_match =
m_Args[start_index + 5]->GetBool();
483 bool case_insensitive =
m_Args[start_index + 6]->GetBool();
484 bool whole_word =
m_Args[start_index + 7]->GetBool();
487 after_match, right_del, remove_after_match,
488 case_insensitive, whole_word));
494 for (
auto& it : resolved_objs) {
497 for (
auto& iter : objs) {
559 for (
size_t i = index;
i <
m_Args.size(); ++
i) {
580 const string& action_type = m_Args[++index]->GetString();
582 bool remove_field =
false;
583 x_GetOptionalArgs(
delimiter, remove_field, index);
590 if (remove_field && newValue.empty()) {
594 else if (!newValue.empty() && !
SetFieldsByName(&res_oi, oi, m_Args[0]->GetString())) {
599 res_oi = m_Args[0]->GetObjects();
602 x_GetObjectsFromRef(res_oi, 0);
605 if (res_oi.empty()) {
609 if (!newValue.empty()) {
610 vector<string> new_values;
612 x_SetFields(res_oi, newValue, existing_text, new_values);
614 m_Result->SetBool(
false);
615 if (m_QualsChangedCount) {
617 m_DataIter->SetModified();
618 m_Result->SetBool(
true);
621 for (
size_t i = 0;
i < new_values.size(); ++
i) {
622 log << m_DataIter->GetBestDescr() <<
": set '" << new_values[
i] <<
"' as a new value\n";
627 else if (remove_field) {
629 if (m_QualsChangedCount) {
631 log << m_DataIter->GetBestDescr() <<
": removed " << m_QualsChangedCount <<
" qualifiers";
640 size_t arg_nr =
m_Args.size();
641 if (arg_nr < 3 && arg_nr > 5) {
646 bool first_ok =
m_Args[index]->IsString() ||
m_Args[index]->AreObjects() ||
m_Args[index]->IsRef();
647 if (!first_ok)
return false;
651 bool second_ok =
m_Args[index]->IsString() ||
m_Args[index]->IsInt() ||
m_Args[index]->IsDouble();
652 if (!second_ok)
return false;
654 if (!
m_Args[++index]->IsString())
return false;
656 if (arg_nr > 3 && (!
m_Args[++index]->IsString() && !
m_Args[index]->IsBool()))
return false;
658 if (arg_nr > 4 && !
m_Args[++index]->IsBool())
return false;
666 for (
auto& it : objs) {
677 new_values.push_back(newValue);
694 new_values.push_back(newValue);
699 new_values.push_back(newValue);
704 if (objs.size() > 1) {
716 new_values.push_back(newValue);
744 new_values.push_back(orig_value);
755 void CMacroFunction_SetRnaProduct::TheFunction()
759 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
760 if (!seq_feat || !seq_feat->
GetData().
IsRna() || !scope)
765 const string& action_type = m_Args[++index]->GetString();
767 bool remove_field =
false;
768 x_GetOptionalArgs(
delimiter, remove_field, index);
777 if (!newValue.empty()) {
781 m_QualsChangedCount++;
782 if (!remainder.empty()) {
790 else if (remove_field) {
793 m_QualsChangedCount++;
796 if (m_QualsChangedCount) {
797 m_DataIter->SetModified();
800 log << m_DataIter->GetBestDescr();
801 if (newValue.empty() && remove_field) {
802 log <<
": removed rna product";
805 log <<
": set '" << orig_value <<
"' as new rna product value";
811 bool CMacroFunction_SetRnaProduct::x_ValidArguments()
const
814 size_t arg_nr = m_Args.size();
815 if (arg_nr < 2 && arg_nr > 4) {
821 bool first_ok = m_Args[index]->IsString() || m_Args[index]->IsInt() || m_Args[index]->IsDouble();
822 if (!first_ok)
return false;
824 if (!m_Args[++index]->IsString())
return false;
825 if (arg_nr > 2 && (!m_Args[++index]->IsString() && !m_Args[index]->IsBool()))
return false;
826 if (arg_nr > 3 && !m_Args[++index]->IsBool())
return false;
838 void CMacroFunction_GetRnaProduct::TheFunction()
842 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
843 m_Result->SetNotSet();
850 if (m_Nested == eNotNested) {
851 m_Result->SetString(
value);
856 new_node->SetString(
value);
857 m_Result->SetRef(new_node);
861 bool CMacroFunction_GetRnaProduct::x_ValidArguments()
const
863 return (m_Args.empty());
870 void CMacroFunction_RemoveRnaProduct::TheFunction()
874 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
875 if (!edit_feat || !edit_feat->
GetData().
IsRna() || !scope)
882 m_DataIter->SetModified();
883 m_QualsChangedCount++;
886 report[
"removing RNA product"] = m_QualsChangedCount;
888 x_LogChangedQuals(fnc_log);
891 bool CMacroFunction_RemoveRnaProduct::x_ValidArguments()
const
893 return (m_Args.empty());
908 const string&
location = m_Args[++index]->GetString();
909 bool case_sensitive = m_Args[++index]->GetBool();
910 bool is_regex = (++index < m_Args.size()) ? m_Args[index]->GetBool() :
false;
912 m_Result->SetBool(
false);
923 res_oi = m_Args[0]->GetObjects();
926 x_GetObjectsFromRef(res_oi, 0);
930 if (res_oi.empty()) {
934 x_EditFields(res_oi, find_txt, repl_txt, s_GetLocFromName(
location), case_sensitive, is_regex);
935 if (m_QualsChangedCount) {
938 m_DataIter->SetModified();
939 m_Result->SetBool(
true);
942 log << m_DataIter->GetBestDescr() <<
": edited " << m_QualsChangedCount <<
" qualifiers, replaced " << find_txt;
944 repl_txt.assign(
"''");
946 log <<
" with " << repl_txt;
952 const string& replace,
ESearchLoc loc,
bool case_sensitive,
bool is_regex)
976 while (pos !=
NPOS) {
977 str =
str.substr(0, pos) + replace +
str.substr(pos + find.length());
978 if (case_sensitive) {
994 else if (loc ==
eEnd) {
996 pos =
str.length() - find.length();
1000 str =
str.substr(0, pos) + replace +
str.substr(pos + find.length());
1012 const string& find_txt,
1013 const string& repl_txt,
1015 bool case_sensitive,
1018 for (
auto& it : resolved_objs) {
1021 for(
auto& iter : objs) {
1025 if (
s_EditText(
value, find_txt, repl_txt, loc, case_sensitive, is_regex)) {
1043 if (
s_EditText(orig_val, find_txt, repl_txt, loc, case_sensitive, is_regex)) {
1058 if (
s_EditText(
value, find_txt, repl_txt, loc, case_sensitive, is_regex)) {
1094 bool first_ok =
m_Args[0]->IsString() ||
m_Args[0]->AreObjects() ||
m_Args[0]->IsRef();
1099 for (
size_t index = 1; index < 3; index++) {
1100 if (!
m_Args[index]->IsString() && !
m_Args[index]->IsInt()) {
1104 if (
m_Args.size() == 6) {
1105 if (!
m_Args.back()->IsBool())
1115 vector<string>
kSatelliteTypes = {
"satellite",
"microsatellite",
"minisatellite" };
1116 vector<string> kMobileETypeTypes = {
1117 "insertion sequence",
1121 "non-LTR retrotransposon",
1127 "transposable element",
1134 bool IstRNAProductField(
const CSeq_feat& feat,
const string& field_name);
1141 return GetBioSourceDestObjects(oi, field_name,
result);
1145 return SetFeatDestinationField(
Ref(feat), field_name,
result);
1153 if (field_name.empty())
1156 size_t orig_size = dest_objs.size();
1169 if ((*subsrc)->IsSetSubtype() && (*subsrc)->GetSubtype() == st) {
1170 CObjectInfo subsrc_oi((*subsrc).GetPointer(), (*subsrc)->GetTypeInfo());
1176 if (dest_objs.empty()) {
1178 sub_src->SetSubtype(st);
1180 CObjectInfo subsrc_oi(sub_src.GetPointer(), sub_src->GetTypeInfo());
1190 if ((*orgmod)->IsSetSubtype() && (*orgmod)->GetSubtype() == st) {
1191 CObjectInfo orgmod_oi((*orgmod).GetPointer(), (*orgmod)->GetTypeInfo());
1197 if (dest_objs.empty()) {
1199 orgmod->SetSubtype(st);
1203 orgname->SetMod().push_back(orgmod);
1204 bsrc->
SetOrg().SetOrgname(*orgname);
1207 bsrc->
SetOrg().SetOrgname().SetMod().push_back(orgmod);
1209 CObjectInfo orgmod_oi(orgmod.GetPointer(), orgmod->GetTypeInfo());
1219 return dest_objs.size() - orig_size > 0;
1225 if (feat.
IsNull() || field_name.empty())
1233 size_t orig_size =
result.size();
1234 string field = field_name;
1236 field =
"satellite";
1239 field =
"mobile-element-type";
1245 CObjectInfo gbqual_oi((*gbq_it).GetPointer(), (*gbq_it)->GetTypeInfo());
1256 feat->
SetQual().push_back(new_gbqual);
1257 CObjectInfo gbqual_oi(new_gbqual.GetPointer(), new_gbqual->GetTypeInfo());
1262 return result.size() - orig_size > 0;
1267 if (field_name.empty())
1275 string field = field_name;
1277 field =
"satellite";
1280 field =
"mobile-element-type";
1286 CObjectInfo gbqual_oi((*gbq_it).GetPointer(), (*gbq_it)->GetTypeInfo());
1291 return (!
result.empty());
1294 bool IstRNAProductField(
const CSeq_feat& feat,
const string& field_name)
1308 return CreateNewGene(src_feat, scope);
1313 return CreateNewProtein(src_feat, scope);
1348 new_gene->SetLocation(*gene_loc);
1377 list<CMappedFeat> cds_feats;
1379 for (
auto& it : cds_feats) {
1380 if (it.IsSetProduct()) {
1418 if (!x_GetSourceFields(oi, index, src_objs))
1422 if (!x_GetDestFields(oi, ++index, dest_objs))
1425 const string& action_type = m_Args[++index]->GetString();
1426 string delimiter = (++index < m_Args.size()) ? m_Args[index]->GetString() :
kEmptyStr;
1431 if (src_feat && m_Args[1]->IsString() &&
NStr::EndsWith(m_Args[1]->GetString(),
"::product")) {
1433 for (
auto&& it : src_objs) {
1438 string src_val = x_GetSourceString(src);
1441 edit_feat->
SetData().SetRna().SetRnaProductName(src_val, remainder);
1442 m_QualsChangedCount++;
1446 ChangeFields(src_objs, dest_objs);
1449 if (m_QualsChangedCount) {
1450 if (!dest_objs.empty()) {
1453 m_DataIter->SetModified();
1455 log << m_DataIter->GetBestDescr() <<
": copied " << m_QualsChangedCount <<
" qualifiers";
1462 size_t arg_size =
m_Args.size();
1463 if (arg_size != 3 && arg_size != 4) {
1467 for (
size_t i = 0;
i < 2; ++
i) {
1476 for (
size_t i = 2;
i < arg_size; ++
i) {
1509 if (!src_feat || !scope)
1512 const string& dest_field =
m_Args[2]->GetString();
1513 if (dest_field.empty())
1525 bool changed =
false,
created =
false;
1528 if (!feat_list.empty() && feat_list.size() == 1) {
1530 dest_feat->
Assign(*feat_list.front());
1531 if (!SetFeatDestinationField(dest_feat, dest_field, dest_objs)) {
1539 dest_feat = CreateNewRelatedFeature(*src_feat, dest_field, *scope);
1540 if (!dest_feat)
return;
1541 if (!SetFeatDestinationField(dest_feat, dest_field, dest_objs)) {
1548 if ((*it)->IsSetData() && (*it)->GetData().IsProt()) {
1549 dest_feat->
SetData().SetProt().Assign((*it)->GetData().GetProt());
1550 edit_feat->
SetXref().erase(it);
1554 if (edit_feat->
GetXref().empty()) {
1561 bool update_mrna =
m_Args[index]->GetBool();
1562 const string& action_type =
m_Args[++index]->GetString();
1567 if (IstRNAProductField(*dest_feat, dest_field)) {
1568 for (
auto&& it : src_objs) {
1576 dest_feat->
SetData().SetRna().SetRnaProductName(src_val, remainder);
1590 if (changed && fh) {
1605 cmd->AddCommand(*upd_cmd);
1606 log <<
", " << message;
1614 cmd->AddCommand(*upd_cmd);
1615 log <<
", applied " + prot_product +
" to mRNA product name ";
1633 for (
size_t index = 1; index <
m_Args.size(); ++index) {
1656 if (!rna_feat || !scope)
1662 const string& src_feat =
m_Args[0]->GetString();
1663 const string& dest_feat =
m_Args[2]->GetString();
1664 if (src_feat ==
"rna" && src_feat == dest_feat)
1667 if ((src_feat !=
"rna" && src_feat !=
"gene") || (dest_feat !=
"rna" && dest_feat !=
"gene"))
1671 const string& action_type =
m_Args[index]->GetString();
1675 if (src_feat ==
"rna" && dest_feat ==
"gene") {
1681 const string dest_field =
m_Args[3]->GetString();
1685 bool changed =
false,
created =
false;
1688 if (!feat_list.empty() && feat_list.size() == 1) {
1690 dest_feat->
Assign(*feat_list.front());
1691 if (!SetFeatDestinationField(dest_feat, dest_field, dest_objs)) {
1699 dest_feat = CreateNewRelatedFeature(*rna_feat, dest_field, *scope);
1700 if (!dest_feat)
return;
1701 if (!SetFeatDestinationField(dest_feat, dest_field, dest_objs)) {
1711 if (changed && fh) {
1727 else if (src_feat ==
"gene" && dest_feat ==
"gene") {
1733 if (!feat_list.empty() && feat_list.size() == 1) {
1735 gene_feat->
Assign(*feat_list.front());
1766 else if (src_feat ==
"gene" && dest_feat ==
"rna") {
1771 if (!feat_list.empty() && feat_list.size() == 1) {
1773 gene_feat->
Assign(*feat_list.front());
1790 for (
auto&& it : src_objs) {
1798 edit_feat->
SetData().SetRna().SetRnaProductName(src_val, remainder);
1823 for (
size_t index = 1; index < 4; index += 2) {
1824 if (!(
m_Args[index]->IsString() ||
m_Args[index]->AreObjects() ||
m_Args[index]->IsRef()))
1842 if (!src_feat || !scope)
1846 const string& field_name =
m_Args[1]->GetString();
1852 const string& action_type =
m_Args[++index]->GetString();
1854 bool remove_field =
false;
1855 bool update_mrna =
false;
1856 size_t arg_nr =
m_Args.size();
1858 if (++index < arg_nr) {
1859 if (
m_Args[index]->IsString()) {
1861 if (++index < arg_nr) {
1862 remove_field =
m_Args[index]->GetBool();
1863 if (++index < arg_nr)
1864 update_mrna =
m_Args[index]->GetBool();
1867 else if (
m_Args[index]->IsBool()) {
1868 remove_field =
m_Args[index]->GetBool();
1869 if (++index < arg_nr)
1870 update_mrna =
m_Args[index]->GetBool();
1875 if (!newValue.empty()) {
1877 bool changed =
false,
created =
false;
1880 if (!feat_list.empty() && feat_list.size() == 1) {
1882 dest_feat->
Assign(*feat_list.front());
1883 if (!SetFeatDestinationField(dest_feat, field_name, objs)) {
1891 dest_feat = CreateNewRelatedFeature(*src_feat, field_name, *scope);
1892 if (!dest_feat)
return;
1893 if (!SetFeatDestinationField(dest_feat, field_name, objs)) {
1900 if ((*it)->IsSetData() && (*it)->GetData().IsProt()) {
1901 dest_feat->
SetData().SetProt().Assign((*it)->GetData().GetProt());
1902 edit_feat->
SetXref().erase(it);
1907 if (edit_feat->
GetXref().empty()) {
1913 vector<string> new_values;
1914 x_SetFields(objs, newValue, existing_text, new_values);
1920 for (
size_t i = 0;
i < new_values.size(); ++
i) {
1921 log <<
": set '" << new_values[
i] <<
"' as a new value";
1924 if (changed && fh) {
1931 cmd->AddCommand(*upd_cmd);
1932 log <<
", applied " + prot_product +
" to mRNA product name ";
1945 cmd->AddCommand(*upd_cmd);
1946 log <<
", " << message;
1955 else if (remove_field) {
1959 if (!feat_list.empty() && feat_list.size() == 1) {
1961 dest_feat->
Assign(*feat_list.front());
1962 if (!GetFeatDestinationField(dest_feat, field_name, objs)) {
1968 for (
auto& it : objs) {
1978 cleanup.BasicCleanup(*dest_feat);
1988 cmd->AddCommand(*upd_cmd);
1989 log <<
", " << message;
2002 size_t arg_nr =
m_Args.size();
2003 if (arg_nr < 4 && arg_nr > 7) {
2009 for (; index < 4; ++index) {
2010 if (!
m_Args[index]->IsString())
2014 if (index < arg_nr && (!
m_Args[index]->IsString() && !
m_Args[index]->IsBool()))
return false;
2015 if (++index < arg_nr && !
m_Args[index]->IsBool())
return false;
2016 if (++index < arg_nr && !
m_Args[index]->IsBool())
return false;
2031 if (!src_feat || !scope)
2038 bool case_sensitive =
m_Args[++index]->GetBool();
2039 bool is_regex = (++index <
m_Args.size()) ?
m_Args[index]->GetBool() :
false;
2042 const string& field_name =
m_Args[1]->GetString();
2049 if (!feat_list.empty() && feat_list.size() == 1) {
2051 dest_feat->
Assign(*feat_list.front());
2052 if (!GetFeatDestinationField(dest_feat, field_name, objs)) {
2069 repl_txt.assign(
"''");
2071 log <<
" with " << repl_txt;
2081 for (
size_t index = 2; index < 4; index++) {
2087 if (
m_Args.size() == 7) {
2102 void CMacroFunction_RmvRelFeatQual::TheFunction()
2106 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
2107 if (!src_feat || !scope)
2111 const string& field_name = m_Args[1]->GetString();
2118 if (!feat_list.empty() && feat_list.size() == 1) {
2120 dest_feat->
Assign(*feat_list.front());
2121 if (!GetFeatDestinationField(dest_feat, field_name, objs)) {
2127 for (
auto& it : objs) {
2129 m_QualsChangedCount++;
2134 if (m_QualsChangedCount) {
2137 cleanup.BasicCleanup(*dest_feat);
2141 m_DataIter->RunCommand(
cmd, m_CmdComposite);
2144 log << m_DataIter->GetBestDescr() <<
": removed " << m_QualsChangedCount <<
" qualifiers";
2149 bool CMacroFunction_RmvRelFeatQual::x_ValidArguments()
const
2151 if (m_Args.size() != 2)
2155 return (m_Args[0]->IsString() && m_Args[1]->IsString());
2170 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
2171 if (!src_feat || !scope)
2175 const string& field_name = m_Args[1]->GetString();
2183 if (!feat_list.empty() && feat_list.size() == 1) {
2185 dest_feat->
Assign(*feat_list.front());
2186 if (!GetFeatDestinationField(dest_feat, field_name, objs)) {
2193 x_RmvOutsideFields(objs, *options);
2194 if (m_QualsChangedCount) {
2198 m_DataIter->RunCommand(
cmd, m_CmdComposite);
2202 log << m_DataIter->GetBestDescr() <<
": removed text outside string in " << m_QualsChangedCount <<
" qualifiers";
2204 bool update_mrna = (m_Args.size() == 11) ? m_Args[10]->GetBool() :
false;
2207 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
2211 m_DataIter->RunCommand(
cmd, m_CmdComposite);
2212 log <<
", applied " + prot_product +
" to mRNA product name ";
2235 _ASSERT(!src_objs.empty() && !dest_objs.empty());
2236 CMQueryNodeValue::TObs::iterator src_it = src_objs.begin();
2237 CMQueryNodeValue::TObs::iterator dest_it = dest_objs.begin();
2239 while (src_it != src_objs.end()) {
2246 CObjectInfo new_oi(dest_it->field.AddNewElement());
2249 for (
auto& it : src_prim_objs) {
2255 if (dest_it == dest_objs.end()) {
2263 if (index >=
m_Args.size())
2281 return (!
result.empty());
2290 const string& dest_field =
m_Args[index]->GetString();
2292 bool valid = GetDestinationObjects(
object, oi, dest_field,
result);
2293 if (valid &&
result.empty())
2331 if (src.
GetName() ==
"Dbtag") {
2334 tag->GetLabel(&src_val);
2356 if (!x_GetSourceFields(oi, index, src_objs))
2360 if (!x_GetDestFields(oi, ++index, dest_objs))
2363 const string& capitalization = m_Args[++index]->GetString();
2367 const string& action_type = m_Args[++index]->GetString();
2368 string delimiter = (++index < m_Args.size()) ? m_Args[index]->GetString() :
kEmptyStr;
2374 if (src_feat && m_Args[1]->IsString() &&
NStr::EndsWith(m_Args[1]->GetString(),
"::product")) {
2376 for (
auto&& it : src_objs) {
2381 string src_val = x_GetSourceString(src);
2384 edit_feat->
SetData().SetRna().SetRnaProductName(src_val, remainder);
2385 m_QualsChangedCount++;
2389 ChangeFields(src_objs, dest_objs);
2392 if (m_QualsChangedCount) {
2393 if (!dest_objs.empty()) {
2396 m_DataIter->SetModified();
2398 log << m_DataIter->GetBestDescr() <<
": converted " << m_QualsChangedCount <<
" qualifiers";
2430 size_t as =
m_Args.size();
2431 if (!(as == 5 || as == 6)) {
2435 for (
size_t i = 0;
i < 2; ++
i) {
2472 size_t src_index = 0, dest_index = 1;
2475 || m_Args.size() == 4) {
2480 bool src_set = x_DoFieldsExist(oi, src_objs, src_index);
2481 bool dest_set = x_DoFieldsExist(oi, dest_objs, dest_index);
2483 if (!src_set && !dest_set)
2487 bool is_gene_suppressed_before =
false;
2488 bool is_gene_suppressed_after =
false;
2493 is_gene_suppressed_before = gene_xref && gene_xref->
IsSuppressed();
2497 x_SetFields(oi, src_objs, src_index);
2500 x_SetFields(oi, dest_objs, dest_index);
2503 if (src_set && dest_set) {
2504 CMQueryNodeValue::TObs::iterator src_it = src_objs.begin();
2505 CMQueryNodeValue::TObs::iterator dest_it = dest_objs.begin();
2507 while (src_it != src_objs.end() && dest_it != dest_objs.end()) {
2514 CObjectInfo new_oi(dest_it->field.AddNewElement());
2517 x_SwapFields(src_prim_objs.front().field, dest_prim_objs.front().field);
2525 else if (!src_set) {
2527 x_CopyFields(dest_objs, src_objs);
2538 else if (!dest_set) {
2540 x_CopyFields(src_objs, dest_objs);
2555 cleanup.BasicCleanup(*seq_feat);
2559 if (!is_gene_suppressed_before && is_gene_suppressed_after)
2567 bsrc->
SetOrg().ResetDb();
2571 if (m_QualsChangedCount) {
2572 m_DataIter->SetModified();
2574 log << m_DataIter->GetBestDescr() <<
": swapped " << m_QualsChangedCount <<
" qualifiers";
2585 for (
auto& it :
m_Args) {
2597 if (index >=
m_Args.size())
2611 return (!
result.empty());
2616 if (index >=
m_Args.size())
2628 return (!
result.empty());
2633 if (field_name.empty())
2659 orgname->
SetMod().push_back(orgmod);
2660 bsrc->
SetOrg().SetOrgname(*orgname);
2663 orgname =
Ref(&(bsrc->
SetOrg().SetOrgname()));
2664 orgname->
SetMod().push_back(orgmod);
2678 if (field_name.empty())
2686 feat->
SetQual().push_back(new_gbqual);
2747 bool swapped =
false;
2824 CMQueryNodeValue::TObs::iterator src_it = src_objs.begin();
2825 CMQueryNodeValue::TObs::iterator dest_it = dest_objs.begin();
2827 while (src_it != src_objs.end() && dest_it != dest_objs.end()) {
2835 CObjectInfo new_oi(dest_it->field.AddNewElement());
2838 x_CopyFields(src_prim_objs.front().field, dest_prim_objs.front().field);
2876 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
2877 if (!src_feat || !scope)
2880 size_t src_index = 0, dest_index = 1;
2881 if (m_Args.size() == 5) {
2884 if (m_Args[dest_index]->GetString().empty() || m_Args[dest_index + 1]->GetString().empty())
2887 const string& dest_feattype = m_Args[dest_index]->GetString();
2888 const string& dest_field = m_Args[dest_index + 1]->GetString();
2890 m_Args[src_index]->GetString() :
kEmptyStr;
2893 m_ConstDestFeat.Reset(
nullptr);
2894 m_EditDestFeat.Reset(
nullptr);
2895 m_CreatedFeat.Reset(
nullptr);
2903 bool src_set = x_DoFieldsExist(oi, src_objs, src_index);
2904 if (IstRNAProductField(*src_feat, src_field)) {
2907 bool dest_set = x_DoDestFeatFieldsExist(*src_feat, dest_objs, dest_feattype, dest_field);
2909 if (!src_set && !dest_set)
2913 x_SetFields(oi, src_objs, src_index);
2916 x_SetOrCreateDestFeatFields(*src_feat, dest_objs, dest_index + 1);
2919 if (src_set && dest_set) {
2920 CMQueryNodeValue::TObs::iterator src_it = src_objs.begin();
2921 CMQueryNodeValue::TObs::iterator dest_it = dest_objs.begin();
2923 while (src_it != src_objs.end() && dest_it != dest_objs.end()) {
2930 CObjectInfo new_oi(dest_it->field.AddNewElement());
2933 x_SwapFields(src_prim_objs.front().field, dest_prim_objs.front().field);
2939 if (m_EditDestFeat && IstRNAProductField(*m_EditDestFeat, dest_field)) {
2940 while (src_it != src_objs.end()) {
2944 string dest_str = m_EditDestFeat->GetData().GetRna().GetRnaProductName();
2951 m_EditDestFeat->SetData().SetRna().SetRnaProductName(
tmp, remainder);
2952 m_QualsChangedCount++;
2957 else if (IstRNAProductField(*src_feat, src_field)) {
2958 while (dest_it != dest_objs.end()) {
2963 CObjectInfo new_oi(dest_it->field.AddNewElement());
2974 seq_feat->
SetData().SetRna().SetRnaProductName(
tmp, remainder);
2975 m_QualsChangedCount++;
2981 else if (!src_set) {
2983 x_CopyFields(dest_objs, src_objs);
2985 if (IstRNAProductField(*seq_feat, src_field)) {
2986 CMQueryNodeValue::TObs::iterator dest_it = dest_objs.begin();
2988 while (dest_it != dest_objs.end()) {
3002 seq_feat->
SetData().SetRna().SetRnaProductName(dest_val, remainder);
3003 m_QualsChangedCount++;
3008 if (m_EditDestFeat && IstRNAProductField(*m_EditDestFeat, dest_field)) {
3009 CMQueryNodeValue::TObs::iterator src_it = src_objs.begin();
3011 while (src_it != src_objs.end()) {
3015 string rna_str = m_EditDestFeat->GetData().GetRna().GetRnaProductName();
3018 m_QualsChangedCount++;
3024 if (m_EditDestFeat && IstRNAProductField(*m_EditDestFeat, dest_field)) {
3026 m_EditDestFeat->SetData().SetRna().SetRnaProductName(
kEmptyStr, remainder);
3030 if (it->parent.GetName() ==
"Gb-qual" && m_EditDestFeat) {
3031 const string& qual_name = m_Args[m_Args.size() - 2]->GetString();
3032 m_EditDestFeat->RemoveQualifier(qual_name);
3039 else if (!dest_set) {
3041 x_CopyFields(src_objs, dest_objs);
3043 if (m_EditDestFeat && IstRNAProductField(*m_EditDestFeat, dest_field)) {
3044 CMQueryNodeValue::TObs::iterator src_it = src_objs.begin();
3046 while (src_it != src_objs.end()) {
3060 m_EditDestFeat->SetData().SetRna().SetRnaProductName(src_val, remainder);
3061 m_QualsChangedCount++;
3066 if (IstRNAProductField(*seq_feat, src_field)) {
3067 CMQueryNodeValue::TObs::iterator dest_it = dest_objs.begin();
3069 while (dest_it != dest_objs.end()) {
3076 m_QualsChangedCount++;
3082 if (IstRNAProductField(*seq_feat, src_field)) {
3091 bool update_mrna = (m_Args.back()->GetDataType() ==
CMQueryNodeValue::eBool) ? m_Args.back()->GetBool() :
false;
3094 cleanup.BasicCleanup(*seq_feat);
3095 if (m_EditDestFeat) {
3096 cleanup.BasicCleanup(*m_EditDestFeat);
3098 else if (m_CreatedFeat) {
3099 cleanup.BasicCleanup(*m_CreatedFeat);
3102 if (m_QualsChangedCount) {
3103 m_DataIter->SetModified();
3105 log << m_DataIter->GetBestDescr() <<
": swapped " << m_QualsChangedCount <<
" qualifiers";
3108 if (m_ConstDestFeat && m_EditDestFeat) {
3116 cmd->AddCommand(*upd_cmd);
3117 log <<
", " << message;
3121 else if (m_CreatedFeat) {
3129 cmd->AddCommand(*upd_cmd);
3130 log <<
", " << message;
3135 m_DataIter->RunCommand(
cmd, m_CmdComposite);
3143 m_DataIter->RunCommand(upd_cmd, m_CmdComposite);
3144 log <<
", applied " + prot_product +
" to mRNA product name ";
3157 if (!feat_list.empty() && feat_list.size() == 1) {
3164 return (!
m_EditDestFeat->GetData().GetRna().GetRnaProductName().empty());
3168 return (!
result.empty());
3173 if (index >=
m_Args.size())
3175 const string& dest_field =
m_Args[index]->GetString();
3193 if ((*it)->IsSetData() && (*it)->GetData().IsProt()) {
3194 m_CreatedFeat->SetData().SetProt().Assign((*it)->GetData().GetProt());
3195 edit_feat->
SetXref().erase(it);
3199 if (edit_feat->
GetXref().empty()) {
3212 bool first_ok = (
m_Args[0]->IsString() ||
m_Args[0]->AreObjects() ||
m_Args[0]->IsRef());
3216 for (
size_t index = 1; index <
m_Args.size() - 1; ++index) {
3217 if (!
m_Args[index]->IsString()) {
3221 return (
m_Args.back()->IsBool());
3239 if (!src_feat || !scope)
3242 const string& dest_field =
m_Args[2]->GetString();
3243 if (dest_field.empty())
3255 bool changed =
false,
created =
false;
3258 if (!feat_list.empty() && feat_list.size() == 1) {
3260 dest_feat->
Assign(*feat_list.front());
3261 if (!SetFeatDestinationField(dest_feat, dest_field, dest_objs)) {
3269 dest_feat = CreateNewRelatedFeature(*src_feat, dest_field, *scope);
3270 if (!dest_feat)
return;
3271 if (!SetFeatDestinationField(dest_feat, dest_field, dest_objs)) {
3278 if ((*it)->IsSetData() && (*it)->GetData().IsProt()) {
3279 dest_feat->
SetData().SetProt().Assign((*it)->GetData().GetProt());
3280 edit_feat->
SetXref().erase(it);
3284 if (edit_feat->
GetXref().empty()) {
3291 const string& capitalization =
m_Args[index]->GetString();
3295 bool update_mrna =
m_Args[++index]->GetBool();
3296 const string& action_type =
m_Args[++index]->GetString();
3302 if (IstRNAProductField(*dest_feat, dest_field)) {
3303 for (
auto&& it : src_objs) {
3311 dest_feat->
SetData().SetRna().SetRnaProductName(src_val, remainder);
3325 if (changed && fh) {
3340 cmd->AddCommand(*upd_cmd);
3341 log <<
", " << message;
3349 cmd->AddCommand(*upd_cmd);
3350 log <<
", applied " + prot_product +
" to mRNA product name ";
3367 for (
size_t index = 1; index <
m_Args.size(); ++index) {
3389 if (!rna_feat || !scope)
3395 const string& src_feat =
m_Args[0]->GetString();
3396 const string& dest_feat =
m_Args[2]->GetString();
3397 if (src_feat ==
"rna" && src_feat == dest_feat)
3400 if ((src_feat !=
"rna" && src_feat !=
"gene") || (dest_feat !=
"rna" && dest_feat !=
"gene"))
3404 const string& capitalization =
m_Args[index]->GetString();
3408 const string& action_type =
m_Args[++index]->GetString();
3413 if (src_feat ==
"rna" && dest_feat ==
"gene") {
3419 const string dest_field =
m_Args[3]->GetString();
3423 bool changed =
false,
created =
false;
3426 if (!feat_list.empty() && feat_list.size() == 1) {
3428 dest_feat->
Assign(*feat_list.front());
3429 if (!SetFeatDestinationField(dest_feat, dest_field, dest_objs)) {
3437 dest_feat = CreateNewRelatedFeature(*rna_feat, dest_field, *scope);
3438 if (!dest_feat)
return;
3439 if (!SetFeatDestinationField(dest_feat, dest_field, dest_objs)) {
3449 if (changed && fh) {
3465 else if (src_feat ==
"gene" && dest_feat ==
"gene") {
3471 if (!feat_list.empty() && feat_list.size() == 1) {
3473 gene_feat->
Assign(*feat_list.front());
3504 else if (src_feat ==
"gene" && dest_feat ==
"rna") {
3509 if (!feat_list.empty() && feat_list.size() == 1) {
3511 gene_feat->
Assign(*feat_list.front());
3528 for (
auto&& it : src_objs) {
3536 edit_feat->
SetData().SetRna().SetRnaProductName(src_val, remainder);
3555 auto nr_args =
m_Args.size();
3556 if (nr_args < 7 || nr_args > 8)
3562 for (
size_t index = 1; index < 4; index += 2) {
3563 if (!(
m_Args[index]->IsString() ||
m_Args[index]->AreObjects() ||
m_Args[index]->IsRef()))
3567 for (
size_t index = 4; index < nr_args; ++index) {
3568 if (index != 5 && !
m_Args[index]->IsString())
3571 return (
m_Args[5]->IsBool());
3592 const string& capitalization =
m_Args[++index]->GetString();
3593 const string& action_type =
m_Args[++index]->GetString();
3603 for (
auto&& it : src_objs) {
3611 edit_feat->
SetData().SetRna().SetRnaProductName(src_val, remainder);
3619 if (!dest_objs.empty()) {
3656 size_t as =
m_Args.size();
3657 if (as < 1 || as > 5) {
3660 for (
size_t i = 0;
i < 2; ++
i) {
3664 for (
size_t index = 2; index < as; ++index) {
3665 if (!
m_Args[index]->IsString()) {
3685 if (!src_feat || !scope)
3688 const string& dest_field =
m_Args[2]->GetString();
3689 if (dest_field.empty())
3701 bool changed =
false,
created =
false;
3704 if (!feat_list.empty() && feat_list.size() == 1) {
3706 dest_feat->
Assign(*feat_list.front());
3707 if (!SetFeatDestinationField(dest_feat, dest_field, dest_objs)) {
3715 dest_feat = CreateNewRelatedFeature(*src_feat, dest_field, *scope);
3716 if (!dest_feat)
return;
3717 if (!SetFeatDestinationField(dest_feat, dest_field, dest_objs)) {
3724 if ((*it)->IsSetData() && (*it)->GetData().IsProt()) {
3725 dest_feat->
SetData().SetProt().Assign((*it)->GetData().GetProt());
3726 edit_feat->
SetXref().erase(it);
3730 if (edit_feat->
GetXref().empty()) {
3737 const string& capitalization =
m_Args[index]->GetString();
3738 bool update_mrna =
m_Args[++index]->GetBool();
3739 const string& action_type =
m_Args[++index]->GetString();
3745 if (IstRNAProductField(*dest_feat, dest_field)) {
3746 for (
auto&& it : src_objs) {
3754 dest_feat->
SetData().SetRna().SetRnaProductName(src_val, remainder);
3768 if (changed && fh) {
3783 cmd->AddCommand(*upd_cmd);
3784 log <<
", " << message;
3792 cmd->AddCommand(*upd_cmd);
3793 log <<
", applied " + prot_product +
" to mRNA product name ";
3814 for (
size_t index = 1; index <
m_Args.size(); ++index) {
3836 if (!rna_feat || !scope)
3842 const string& src_feat =
m_Args[0]->GetString();
3843 const string& dest_feat =
m_Args[2]->GetString();
3844 if (src_feat ==
"rna" && src_feat == dest_feat)
3847 if ((src_feat !=
"rna" && src_feat !=
"gene") || (dest_feat !=
"rna" && dest_feat !=
"gene"))
3851 const string& capitalization =
m_Args[index]->GetString();
3852 const string& action_type =
m_Args[++index]->GetString();
3857 if (src_feat ==
"rna" && dest_feat ==
"gene") {
3863 const string dest_field =
m_Args[3]->GetString();
3867 bool changed =
false,
created =
false;
3870 if (!feat_list.empty() && feat_list.size() == 1) {
3872 dest_feat->
Assign(*feat_list.front());
3873 if (!SetFeatDestinationField(dest_feat, dest_field, dest_objs)) {
3881 dest_feat = CreateNewRelatedFeature(*rna_feat, dest_field, *scope);
3882 if (!dest_feat)
return;
3883 if (!SetFeatDestinationField(dest_feat, dest_field, dest_objs)) {
3893 if (changed && fh) {
3909 else if (src_feat ==
"gene" && dest_feat ==
"gene") {
3915 if (!feat_list.empty() && feat_list.size() == 1) {
3917 gene_feat->
Assign(*feat_list.front());
3948 else if (src_feat ==
"gene" && dest_feat ==
"rna") {
3952 if (!feat_list.empty() && feat_list.size() == 1) {
3954 gene_feat->
Assign(*feat_list.front());
3971 for (
auto&& it : src_objs) {
3979 edit_feat->
SetData().SetRna().SetRnaProductName(src_val, remainder);
4004 for (
size_t index = 1; index < 4; index += 2) {
4005 if (!(
m_Args[index]->IsString() ||
m_Args[index]->AreObjects() ||
m_Args[index]->IsRef()))
4008 for (
size_t index = 4; index <
m_Args.size(); ++index) {
4009 if (!
m_Args[index]->IsString())
4034 string text_portion = parsed_obj.
GetString();
4035 if (text_portion.empty()) {
4044 const string& dest_field =
m_Args[index]->GetString();
4046 GetDestinationObjects(obj, oi, dest_field, dest_objs);
4049 dest_objs =
m_Args[index]->GetObjects();
4055 if (dest_objs.empty()) {
4059 const string& capitalization =
m_Args[++index]->GetString();
4060 const string& action_type =
m_Args[++index]->GetString();
4086 CObjectInfo new_oi(dest_objs.front().field.AddNewElement());
4104 size_t as =
m_Args.size();
4105 if (as != 4 && as != 5) {
4120 for (
size_t index = 2; index < as; ++index) {
4139 if (!src_feat || !scope)
4150 string text_portion = parsed_obj.
GetString();
4151 if (text_portion.empty()) {
4155 const string& dest_field =
m_Args[2]->GetString();
4156 if (dest_field.empty())
4163 bool changed =
false,
created =
false;
4167 if (!feat_list.empty() && feat_list.size() == 1) {
4169 dest_feat->
Assign(*feat_list.front());
4170 if (!SetFeatDestinationField(dest_feat, dest_field, dest_objs)) {
4178 dest_feat = CreateNewRelatedFeature(*src_feat, dest_field, *scope);
4179 if (!dest_feat)
return;
4180 if (!SetFeatDestinationField(dest_feat, dest_field, dest_objs)) {
4187 if ((*it)->IsSetData() && (*it)->GetData().IsProt()) {
4188 dest_feat->
SetData().SetProt().Assign((*it)->GetData().GetProt());
4189 edit_feat->
SetXref().erase(it);
4193 if (edit_feat->
GetXref().empty()) {
4200 const string& capitalization =
m_Args[index]->GetString();
4201 bool update_mrna =
m_Args[++index]->GetBool();
4202 const string& action_type =
m_Args[++index]->GetString();
4210 if (IstRNAProductField(*dest_feat, dest_field)) {
4212 dest_feat->
SetData().SetRna().SetRnaProductName(text_portion, remainder);
4224 if (changed && fh) {
4241 log <<
", " << message;
4257 for (
size_t index = 1; index <
m_Args.size(); ++index) {
4276 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
4277 if (!scope || !
object)
4284 string text_portion;
4289 const string& field = m_Args[0]->GetString();
4294 res_oi = m_Args[index]->GetObjects();
4295 if (!res_oi.empty()) {
4305 if (!res_oi.empty()) {
4318 if (text_portion.empty())
4321 x_SetFieldType(m_Args[++index]->GetString());
4322 string fieldname = (m_Type == eFieldValue) ? m_Args[++index]->GetString() :
kEmptyStr;
4323 if (m_Type == eFieldError) {
4324 NCBI_THROW(
CMacroExecException, eWrongArguments,
"Wrong structured comment fieldname is given (consider replacing it with either 'fieldvalue', 'dbname' or 'fieldname'");
4327 string capitalization, action_type;
4328 if (++index < m_Args.size()) {
4329 capitalization = m_Args[index]->GetString();
4331 if (++index < m_Args.size()) {
4332 action_type = m_Args[index]->GetString();
4334 if (capitalization.empty() || action_type.empty()) {
4338 string delimiter = (++index < m_Args.size()) ? m_Args[index]->GetString() :
kEmptyStr;
4352 for ( ; strcomm_it; ++strcomm_it) {
4357 const string kPrefix =
"StructuredCommentPrefix";
4358 const string kSuffix =
"StructuredCommentSuffix";
4362 new_desc->
Assign(*strcomm_it);
4367 if (m_Type == eFieldValue) {
4368 user_object.
AddField(fieldname, text_portion);
4369 m_QualsChangedCount++;
4373 if (m_Type == eFieldValue) {
4374 if (user_object.
HasField(fieldname)) {
4379 user_field.
SetData().SetStr(orig_val);
4380 m_QualsChangedCount++;
4386 user_object.
AddField(fieldname, text_portion);
4387 m_QualsChangedCount++;
4390 else if (m_Type == eDbName) {
4394 else if (m_Type == eFieldName) {
4402 user_field.
SetLabel().SetStr(orig_val);
4403 m_QualsChangedCount++;
4409 if (m_QualsChangedCount) {
4415 cmd->AddCommand(*ecmd);
4431 user_object.
AddField(fieldname, text_portion);
4432 m_QualsChangedCount++;
4437 m_QualsChangedCount++;
4441 m_QualsChangedCount++;
4447 if (m_QualsChangedCount) {
4454 m_DataIter->RunCommand(
cmd, m_CmdComposite);
4457 string msg =
"parsing text to structured comment ";
4460 msg +=
"field '" + fieldname +
"'";
4463 msg +=
"database name";
4471 report[msg] = m_QualsChangedCount;
4473 x_LogChangedQuals(fnc_log);
4485 for (
size_t index = 1; index <
m_Args.size(); ++index) {
4526 const string& field =
m_Args[0]->GetString();
4537 res_oi =
m_Args[0]->GetObjects();
4544 if (res_oi.empty())
return;
4555 string parsed_text = options->GetSelectedText(full_text);
4558 if (options->ShouldRemoveFromParsed()) {
4562 if (desc->IsTitle()) {
4563 string orig_val = desc->GetTitle();
4564 options->RemoveSelectedText(orig_val);
4565 if (!orig_val.empty()) {
4566 desc->SetTitle() = orig_val;
4570 cmd->AddCommand(*chg_cmd);
4577 else if (!res_oi.empty()) {
4585 options->RemoveSelectedText(orig_val);
4586 if (orig_val.empty()) {
4606 size_t as =
m_Args.size();
4607 if (as < 7 || as > 10) {
4617 for (
size_t i = 4;
i < as; ++
i) {
4627 if (bsh && bsh.
IsAa()) {
4633 if (!bsh)
return false;
4637 if (title_ci && !title_ci->
GetTitle().empty()) {
4639 new_desc->
Assign(*title_ci);
4653 if (!user.
GetData().empty()) {
4684 const string& left_del =
m_Args[start_index]->GetString();
4686 options->SetStartDigits();
4689 options->SetStartLetters();
4692 options->SetStartText(left_del);
4694 options->SetIncludeStart(
m_Args[++start_index]->GetBool());
4696 const string& right_del =
m_Args[++start_index]->GetString();
4698 options->SetStopDigits();
4701 options->SetStopLetters();
4704 options->SetStopText(right_del);
4706 options->SetIncludeStop(
m_Args[++start_index]->GetBool());
4708 options->SetCaseInsensitive(!
m_Args[++start_index]->GetBool());
4709 options->SetWholeWord(
m_Args[++start_index]->GetBool());
4711 auto nr_args =
m_Args.size();
4712 if (++start_index < nr_args) {
4713 options->SetShouldRemove(
m_Args[start_index]->GetBool());
4715 if (++start_index < nr_args) {
4716 options->SetShouldRmvBeforePattern(
m_Args[start_index]->GetBool());
4718 if (++start_index < nr_args) {
4719 options->SetShouldRmvAfterPattern(
m_Args[start_index]->GetBool());
4741 if (!rna_feat || !scope)
4747 const string& src_feat =
m_Args[0]->GetString();
4748 if (src_feat !=
"gene")
4755 if (!feat_list.empty() && feat_list.size() == 1) {
4757 gene_feat->
Assign(*feat_list.front());
4761 if (
m_Args[index]->IsString()) {
4765 else if (
m_Args[index]->AreObjects()) {
4766 res_oi =
m_Args[index]->GetObjects();
4768 else if (
m_Args[index]->IsRef()) {
4788 string parsed_text = options->GetSelectedText(full_text);
4791 if (!parsed_text.empty() && options->ShouldRemoveFromParsed()) {
4799 options->RemoveSelectedText(orig_val);
4800 if (orig_val.empty()) {
4819 size_t as =
m_Args.size();
4820 if (as < 8 || as > 11) {
4830 for (
size_t i = 5;
i < as; ++
i) {
4842 void CMacroFunction_LocalID::TheFunction()
4850 if (!user.
GetData().empty()) {
4867 if (m_Result->IsNotSet()) {
4871 if (m_Result->IsNotSet()) {
4878 bool CMacroFunction_LocalID::x_ValidArguments()
const
4880 return (m_Args.empty());
4903 res_oi = m_Args[0]->GetObjects();
4906 x_GetObjectsFromRef(res_oi, 0);
4909 if (res_oi.empty()) {
4915 m_QualsChangedCount++;
4919 if (m_QualsChangedCount) {
4921 m_DataIter->SetModified();
4923 log << m_DataIter->GetBestDescr() <<
": set new value to " << m_QualsChangedCount <<
" qualifiers";
4933 if (
m_Args.size() != 2 || !first_ok)
4936 if (!
m_Args[1]->IsSimpleType()) {
4960 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
4961 if (!scope || !bseq || bseq->
IsAa())
4965 const string& dblink = m_Args[index]->GetString();
4967 const string& existing_text_option = m_Args[++index]->GetString();
4969 bool remove_field =
false;
4970 x_GetOptionalArgs(
delimiter, remove_field, index);
4975 if (!newValue.empty()) {
4976 vector<pair<CSeqdesc_CI, CRef<CSeqdesc>>> changed_descs;
4982 if (desc_it->GetUser().GetType().IsStr() && desc_it->GetUser().GetType().GetStr() ==
"DBLink") {
4984 new_desc->
Assign(*desc_it);
4986 bool found_user_field =
false;
4990 found_user_field =
true;
4994 m_QualsChangedCount++;
5002 m_QualsChangedCount++;
5006 for (
auto& it : field.
SetData().SetStrs()) {
5007 string orig_value = it;
5010 m_QualsChangedCount++;
5019 m_QualsChangedCount++;
5021 changed_descs.push_back(make_pair(desc_it, new_desc));
5025 if (changed_descs.empty()) {
5029 m_QualsChangedCount++;
5034 else if (!changed_descs.empty()) {
5036 for (
auto& it : changed_descs) {
5038 cmd->AddCommand(*chg_cmd);
5042 if (m_QualsChangedCount) {
5044 report[
"setting new value to " + dblink] = m_QualsChangedCount;
5046 x_LogChangedQuals(fnc_log);
5049 else if (remove_field) {
5055 if (desc_it->GetUser().GetType().IsStr() && desc_it->GetUser().GetType().GetStr() ==
"DBLink") {
5057 new_desc->
Assign(*desc_it);
5063 m_QualsChangedCount++;
5071 cmd->AddCommand(*(
new CCmdDelDesc(desc_it.GetSeq_entry_Handle(), *desc_it)));
5078 cmd->AddCommand(*chg_cmd);
5082 if (m_QualsChangedCount) {
5084 report[
"removal of " + dblink +
" value"] = m_QualsChangedCount;
5086 x_LogChangedQuals(fnc_log);
5090 if (m_QualsChangedCount) {
5091 m_DataIter->RunCommand(
cmd, m_CmdComposite);
5097 if (!user_object_desc || dblink.empty())
5101 new_field->
SetLabel().SetStr(dblink);
5103 string del = (newValue.find(
',') !=
NPOS) ?
"," :
kEmptyStr;
5104 if (del.empty() && newValue.find(
';') !=
NPOS) {
5110 new_field->
SetData().SetStrs().push_back(newValue);
5126 vector<string> values;
5128 for (
auto&& it : values)
5138 if (!tmp_values.empty()) {
5139 tmp_values += del +
" ";
5144 if (!tmp_values.empty()) {
5145 tmp_values += del +
" ";
5147 tmp_values += newValue;
5153 string del = (newValue.find(
',') !=
NPOS) ?
"," :
kEmptyStr;
5154 if (del.empty() && newValue.find(
';') !=
NPOS) {
5159 user_field.
SetData().SetStrs().push_back(newValue);
5172 auto arg_nr =
m_Args.size();
5173 if (arg_nr < 3 || arg_nr > 5) {
5178 if (!
m_Args[index]->IsString())
return false;
5180 if (!
m_Args[index]->IsString() && !
m_Args[index]->IsInt())
5183 if (!
m_Args[++index]->IsString())
return false;
5184 if (arg_nr > 3 && (!
m_Args[++index]->IsString() && !
m_Args[index]->IsBool()))
return false;
5185 if (arg_nr > 4 && !
m_Args[++index]->IsBool())
return false;
5197 void CMacroFunction_AddUnverified::TheFunction()
5201 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
5202 if (!scope || !bseq || bseq->
IsAa())
5209 vector<pair<CSeqdesc_CI, CRef<CSeqdesc>>> changed_descs;
5213 if (desc_it->GetUser().IsUnverified()) {
5214 const auto& present_user = desc_it->GetUser();
5225 new_desc->Assign(*desc_it);
5227 changed_descs.push_back(make_pair(desc_it, new_desc));
5231 if (changed_descs.empty()) {
5234 m_QualsChangedCount++;
5238 m_DataIter->RunCommand(
cmd, m_CmdComposite);
5242 for (
auto& it : changed_descs) {
5244 cmd->AddCommand(*chg_cmd);
5245 m_QualsChangedCount++;
5247 m_DataIter->RunCommand(
cmd, m_CmdComposite);
5250 if (m_QualsChangedCount) {
5252 log << m_QualsChangedCount <<
";adding new Unverified user object ";
5280 bool CMacroFunction_AddUnverified::x_ValidArguments()
const
5282 return (m_Args.size() == 1 && m_Args[0]->IsString());
5291 void CMacroFunction_ParseToDBLink::TheFunction()
5295 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
5296 if (!scope || !bseq || bseq->
IsAa())
5303 string text_portion;
5306 if (m_Args[index]->IsString()) {
5307 const string& field = m_Args[index]->
GetString();
5311 else if (m_Args[index]->AreObjects()) {
5312 res_oi = m_Args[index]->GetObjects();
5313 if (!res_oi.empty()) {
5317 else if (m_Args[index]->IsRef()) {
5323 if (!res_oi.empty()) {
5336 if (text_portion.empty())
5341 if (m_Args[++index]->IsString()) {
5342 dblink = m_Args[index]->GetString();
5348 string capitalization = m_Args[++index]->GetString();
5349 string action_type = m_Args[++index]->GetString();
5350 string delimiter = (++index < m_Args.size()) ? m_Args[index]->GetString() :
kEmptyStr;
5359 vector<pair<CSeqdesc_CI, CRef<CSeqdesc>>> changed_descs;
5365 if (desc_it->GetUser().GetType().IsStr() && desc_it->GetUser().GetType().GetStr() ==
"DBLink") {
5367 new_desc->Assign(*desc_it);
5369 bool found_user_field =
false;
5373 found_user_field =
true;
5377 m_QualsChangedCount++;
5385 m_QualsChangedCount++;
5390 for (
auto& it : field.
SetData().SetStrs()) {
5391 string orig_value = it;
5394 m_QualsChangedCount++;
5403 m_QualsChangedCount++;
5405 changed_descs.push_back(make_pair(desc_it, new_desc));
5409 if (changed_descs.empty()) {
5411 new_desc->SetUser().SetType().SetStr(
"DBLink");
5413 m_QualsChangedCount++;
5418 else if (!changed_descs.empty()) {
5420 for (
auto& it : changed_descs) {
5422 cmd->AddCommand(*chg_cmd);
5426 if (m_QualsChangedCount) {
5427 m_DataIter->RunCommand(
cmd, m_CmdComposite);
5430 report[
"parsing text to " + dblink] = m_QualsChangedCount;
5432 x_LogChangedQuals(fnc_log);
5436 bool CMacroFunction_ParseToDBLink::x_ValidArguments()
const
5438 if (m_Args.size() > 5 || m_Args.size() < 4) {
5441 if (!(m_Args[0]->IsString() || m_Args[0]->AreObjects() || m_Args[0]->IsRef()))
5444 for (
size_t index = 1; index < m_Args.size(); ++index) {
5466 const string& subtype_name = m_Args[index]->GetString();
5468 const string& action_type = m_Args[++index]->GetString();
5470 bool remove_field =
false;
5471 x_GetOptionalArgs(
delimiter, remove_field, index);
5477 if (!newValue.empty()) {
5478 vector<string> new_values;
5484 if (const_bsrc && m_IsBiosrc) {
5485 x_AddBioSrcModifier(subtype_name, newValue);
5487 else if (const_feat && !m_IsBiosrc) {
5489 m_QualsChangedCount += s_AddGBQualifier(*seqfeat, subtype_name, newValue);
5491 new_values.push_back(newValue);
5499 for (
auto&& it : res_oi) {
5514 SetQualStringValue(value_oi, sat_value);
5515 new_values.push_back(sat_value);
5518 string orig_sat_type = sat_type;
5528 if (!sat_name.empty()) {
5529 sat_name = sat_type +
":" + sat_name;
5532 sat_name = sat_type;
5536 SetQualStringValue(value_oi, sat_value);
5537 new_values.push_back(sat_value);
5552 SetQualStringValue(value_oi, met_value);
5553 new_values.push_back(met_value);
5557 string orig_met_type = met_type;
5559 auto found_it = find(kMobileETypeTypes.begin(), kMobileETypeTypes.end(), met_type);
5560 bool good_type = (found_it != kMobileETypeTypes.end()) ?
true :
false;
5570 SetQualStringValue(value_oi, met_value);
5571 new_values.push_back(met_value);
5582 m_QualsChangedCount++;
5586 new_values.push_back(new_val.
GetString());
5592 if (m_QualsChangedCount) {
5593 m_DataIter->SetModified();
5595 log << m_DataIter->GetBestDescr();
5596 for (
size_t i = 0;
i < new_values.size(); ++
i) {
5597 log <<
" '" << new_values[
i] <<
"' has been set as a new value";
5602 else if (remove_field) {
5603 if (!res_oi.empty()) {
5605 for (
auto&& it : res_oi) {
5619 if (!newValue.empty()) {
5620 SetQualStringValue(value_oi, newValue);
5625 m_QualsChangedCount++;
5631 for (
auto&& it : res_oi) {
5645 if (!newValue.empty()) {
5646 SetQualStringValue(value_oi, newValue);
5651 m_QualsChangedCount++;
5657 for (
auto&& it : res_oi) {
5659 m_QualsChangedCount++;
5665 if (m_QualsChangedCount) {
5671 cleanup.BasicCleanup(*seq_feat);
5678 m_DataIter->SetModified();
5680 log << m_DataIter->GetBestDescr() <<
": removed " << m_QualsChangedCount <<
" modifiers";
5695 size_t arg_size =
m_Args.size();
5696 if (arg_size < 5 || arg_size > 7)
5704 if (!
m_Args[1]->IsString() || !
m_Args[2]->IsString())
return false;
5708 if (!type_ok)
return false;
5710 if (!
m_Args[4]->IsString())
return false;
5712 if (arg_size > 5 && (!
m_Args[5]->IsString() && !
m_Args[5]->IsBool()))
return false;
5714 if (arg_size > 6 && !
m_Args[6]->IsBool())
return false;
5751 string qualifier = qual_name;
5752 string apply_value = newValue;
5756 qualifier =
"satellite";
5760 qualifier =
"satellite";
5771 if (!apply_value.empty()) {
5787 orgname->
SetMod().push_back(orgmod);
5788 bsrc.
SetOrg().SetOrgname(*orgname);
5792 bsrc.
SetOrg().SetOrgname().SetMod().push_back(orgmod);
5822 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
5823 m_Result->SetNotSet();
5824 if (!feat || !scope || !feat->
IsSetQual())
5827 const string& qual_value = feat->
GetNamedQual(
"satellite");
5828 if (!qual_value.empty()) {
5830 switch (m_FieldType) {
5831 case eSatelliteType:
5832 value = s_GetSatelliteType(qual_value);
5834 case eSatelliteName:
5835 value = s_GetSatelliteName(qual_value);
5839 if (m_Nested == eNotNested) {
5840 m_Result->SetString(
value);
5846 m_Result->SetRef(new_node);
5855 return value.substr(0, pos);
5875 string new_type =
type;
5877 if (!name.empty()) {
5878 new_name =
":" + name;
5889 new_name =
":" +
type + new_name;
5892 return new_type + new_name;
5912 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
5913 m_Result->SetNotSet();
5914 if (!feat || !scope || !feat->
IsSetQual())
5918 if (!qual_value.empty()) {
5920 switch (m_FieldType) {
5921 case eMobileElemTType:
5922 value = s_GetMobileElemTType(qual_value);
5924 case eMobileElemTName:
5925 value = s_GetMobileElemTName(qual_value);
5929 if (m_Nested == eNotNested) {
5930 m_Result->SetString(
value);
5936 m_Result->SetRef(new_node);
5946 auto it = find(kMobileETypeTypes.begin(), kMobileETypeTypes.end(),
type);
5950 auto it = find(kMobileETypeTypes.begin(), kMobileETypeTypes.end(),
value);
5959 string name =
value.substr(pos + 1,
NPOS);
5960 auto it = find(kMobileETypeTypes.begin(), kMobileETypeTypes.end(),
type);
5961 return (it != kMobileETypeTypes.end()) ? name :
value;
5964 auto it = find(kMobileETypeTypes.begin(), kMobileETypeTypes.end(),
value);
5972 if (!
type.empty()) {
5973 auto found_it = find(kMobileETypeTypes.begin(), kMobileETypeTypes.end(),
type);
5974 bool good_type = (found_it != kMobileETypeTypes.end()) ?
true :
false;
5977 if (!name.empty()) {
6001 void CMacroFunction_EditSubfield::TheFunction()
6004 const string& subfield = m_Args[1]->GetString();
6005 if (subfield.empty())
6010 const string&
location = m_Args[++index]->GetString();
6011 bool case_sensitive = m_Args[++index]->GetBool();
6012 bool is_regex = (++index < m_Args.size()) ? m_Args[index]->GetBool() :
false;
6015 if (m_Args[0]->AreObjects()) {
6018 else if (m_Args[0]->IsRef()) {
6019 x_GetObjectsFromRef(objs, 0);
6026 for (
auto&& it : objs) {
6038 SetQualStringValue(value_oi, newValue);
6042 string orig_sat_type = sat_type;
6051 if (!sat_name.empty())
6052 sat_name = sat_type +
":" + sat_name;
6055 SetQualStringValue(value_oi, newValue);
6065 SetQualStringValue(value_oi, newValue);
6069 string orig_met_type = met_type;
6071 auto found_it = find(kMobileETypeTypes.begin(), kMobileETypeTypes.end(), met_type);
6072 bool good_type = (found_it != kMobileETypeTypes.end()) ?
true :
false;
6080 SetQualStringValue(value_oi, newValue);
6086 string inst, coll, id;
6102 SetQualStringValue(value_oi, newValue);
6107 if (m_QualsChangedCount) {
6108 m_DataIter->SetModified();
6110 log << m_DataIter->GetBestDescr() <<
": edited " << m_QualsChangedCount <<
" qualifiers, replaced " << find_txt;
6112 repl_txt.assign(
"''");
6114 log <<
" with " << repl_txt;
6119 bool CMacroFunction_EditSubfield::x_ValidArguments()
const
6121 if (m_Args.size() != 7)
6124 bool first_ok = m_Args[0]->AreObjects() || m_Args[0]->IsRef();
6125 if (!first_ok || !m_Args[1]->IsString()) {
6129 for (
size_t index = 2; index < 4; index++) {
6130 if (!m_Args[index]->IsString() && !m_Args[index]->IsInt()) {
6134 return (m_Args[4]->IsString() && m_Args[5]->IsBool() && m_Args[6]->IsBool());
6143 void CMacroFunction_RemoveSubfield::TheFunction()
6145 const string& subfield = m_Args[1]->GetString();
6146 if (subfield.empty())
6150 if (m_Args[0]->AreObjects()) {
6151 objs = m_Args[0]->GetObjects();
6153 else if (m_Args[0]->IsRef()) {
6154 x_GetObjectsFromRef(objs, 0);
6160 for (
auto&& it : objs) {
6184 string inst, coll, id;
6197 if (!newValue.empty()) {
6198 SetQualStringValue(value_oi, newValue);
6203 m_QualsChangedCount++;
6208 if (m_QualsChangedCount) {
6210 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
6215 cleanup.BasicCleanup(*seq_feat);
6222 m_DataIter->SetModified();
6224 log << m_DataIter->GetBestDescr() <<
": removed " << m_QualsChangedCount <<
" qualifiers";
6230 bool CMacroFunction_RemoveSubfield::x_ValidArguments()
const
6232 return m_Args.size() == 2 && (m_Args[0]->AreObjects() || m_Args[0]->IsRef()) && m_Args[1]->IsString();
6243 if (ch ==
'A' || ch ==
'T' || ch ==
'G' || ch ==
'C' || ch ==
'U') {
6254 "AC",
"AG",
"CG",
"ACG",
"AT",
"CT",
"ACT",
"GT",
"AGT",
"CGT",
"ACGT" };
6259 if (pos != string::npos) {
6270 vector<string> replacements;
6272 if (codon.length() == 3 &&
s_IsATGC(codon.c_str()[0])) {
6273 string this_codon = codon.substr(0, 1);
6274 replacements.push_back(this_codon);
6276 for (
int i = 1;
i < 3;
i++) {
6278 size_t num_now = replacements.size();
6280 for (
unsigned int j = 1; j < ch.length(); j++) {
6281 for (
unsigned int k = 0; k < num_now; k++) {
6282 string cpy = replacements[k];
6283 replacements.push_back(cpy);
6286 for (
unsigned int k = 0; k < num_now; k++) {
6287 for (
unsigned int j = 0; j < ch.length(); j++) {
6288 replacements[j * num_now + k].append(ch.substr(j, 1));
6294 replacements.push_back(codon);
6296 return replacements;
6300 void CMacroFunction_SetCodonsRecognized::TheFunction()
6309 if (m_Args[0]->IsRef()) {
6317 else if (m_Args[0]->IsString()) {
6318 value = m_Args[0]->GetString();
6321 if (
value.empty()) {
6329 edit_feat->
SetData().SetRna().SetExt().SetTRNA().ResetCodon();
6337 for (
unsigned int j = 0; j <
codons.size(); j++)
6342 edit_feat->
SetData().SetRna().SetExt().SetTRNA().SetCodon().push_back(val);
6346 m_DataIter->SetModified();
6349 log << m_DataIter->GetBestDescr() <<
": set codons-recognized";
6354 bool CMacroFunction_SetCodonsRecognized::x_ValidArguments()
const
6356 return (m_Args.size() == 1 && (m_Args[0]->IsRef() || m_Args[0]->IsString()));
6366 void CMacroFunction_SetStructCommField::TheFunction()
6369 const CBioseq* bioseq =
dynamic_cast<const CBioseq*
>(
object.GetPointer());
6371 if (!(bioseq && bioseq->
IsNa()) &&
6381 const string& field_name = m_Args[index]->GetString();
6382 const string& field_value = m_Args[++index]->GetString();
6383 const string& existing_text_option = m_Args[++index]->GetString();
6385 bool remove_field =
false;
6386 x_GetOptionalArgs(
delimiter, remove_field, index);
6389 if (!field_value.empty()) {
6395 user_object->
AddField(field_name, field_value);
6396 m_QualsChangedCount++;
6399 if (user_object->
HasField(field_name)) {
6404 user_field.
SetData().SetStr(orig_val);
6405 m_QualsChangedCount++;
6411 user_object->
AddField(field_name, field_value);
6412 m_QualsChangedCount++;
6416 if (m_QualsChangedCount) {
6430 if (!edit_bseq)
return;
6433 if (!seqdesc)
return;
6441 user_field.
SetData().SetStr(orig_val);
6442 m_QualsChangedCount++;
6446 user_field.
SetData().SetStr(field_value);
6447 m_QualsChangedCount++;
6453 m_QualsChangedCount++;
6456 if (m_QualsChangedCount) {
6462 if (m_QualsChangedCount) {
6463 m_DataIter->SetModified();
6465 log << m_DataIter->GetBestDescr() <<
": applied ('" << field_name <<
"', '" << field_value <<
"') field-value pair";
6469 else if (remove_field) {
6474 m_QualsChangedCount++;
6485 if (!edit_bseq)
return;
6489 if (!seqdesc)
return;
6492 m_QualsChangedCount++;
6496 if (m_QualsChangedCount) {
6497 m_DataIter->SetModified();
6499 log << m_DataIter->GetBestDescr() <<
": removed " << m_QualsChangedCount <<
" structured comment fields";
6505 bool CMacroFunction_SetStructCommField::x_ValidArguments()
const
6507 if (m_Args.size() < 3 || m_Args.size() > 6)
6510 if (m_Args[0]->IsRef()) {
6516 else if (!m_Args[0]->IsString()) {
6521 for (
size_t i = 1;
i < m_Args.size(); ++
i) {
6522 if (!m_Args[
i]->IsString() && !m_Args[
i]->IsBool()) {
6539 const CBioseq* bioseq =
dynamic_cast<const CBioseq*
>(
object.GetPointer());
6541 if (!(bioseq && bioseq->
IsNa()) &&
6547 const string& db_name = m_Args[index]->GetString();
6548 const string kPrefix =
"StructuredCommentPrefix";
6549 const string kSuffix =
"StructuredCommentSuffix";
6550 const string& existing_text_option = m_Args[++index]->GetString();
6552 bool remove_field =
false;
6553 x_GetOptionalArgs(
delimiter, remove_field, index);
6556 if (!db_name.empty()) {
6562 m_DataIter->SetModified();
6566 bool found_user =
false;
6570 new_seqdesc->
Assign(*desc_it);
6571 m_QualsChangedCount += s_UpdateStructCommentDb(*new_seqdesc,
kPrefix, db_name, existing_text);
6572 m_QualsChangedCount += s_UpdateStructCommentDb(*new_seqdesc,
kSuffix, db_name, existing_text);
6574 if (m_QualsChangedCount) {
6578 cmd->AddCommand(*ecmd);
6579 m_DataIter->RunCommand(
cmd, m_CmdComposite);
6585 m_DataIter->SetModified();
6593 m_QualsChangedCount += s_UpdateStructCommentDb(*user_object,
kPrefix, db_name, existing_text);
6594 m_QualsChangedCount += s_UpdateStructCommentDb(*user_object,
kSuffix, db_name, existing_text);
6595 m_DataIter->SetModified();
6597 if (m_QualsChangedCount) {
6598 log << m_DataIter->GetBestDescr() <<
": applied structured comment database name '" << db_name <<
"'";
6602 else if (remove_field) {
6608 m_QualsChangedCount++;
6609 m_DataIter->SetModified();
6612 m_QualsChangedCount++;
6613 m_DataIter->SetModified();
6627 new_seqdesc->
Assign(*desc_it);
6629 m_QualsChangedCount++;
6631 m_QualsChangedCount++;
6633 if (m_QualsChangedCount) {
6636 cmd->AddCommand(*ecmd);
6637 m_DataIter->RunCommand(
cmd, m_CmdComposite);
6643 if (m_QualsChangedCount) {
6645 log << m_DataIter->GetBestDescr() <<
": removed " << m_QualsChangedCount <<
" structured comment fields";
6662 if (!edit_bseq)
return false;
6664 auto& descriptors = edit_bseq->
SetDescr().Set();
6665 descriptors.push_back(seqdesc);
6682 if (!
m_Args[0]->IsString() || !
m_Args[1]->IsString()) {
6717 user_field.
SetData().SetStr(orig_val);
6722 user_field.
SetData().SetStr(root);
6737 auto& user_fields = user_object.
SetData();
6739 for (CUser_object::TData::iterator it = user_fields.begin(); it != user_fields.end(); ++it) {
6743 swap(*it, *(user_fields.end() - 1));
6756 void CMacroFunction_ValueFromTable::TheFunction()
6758 const string&
table_name = m_Args[0]->GetString();
6759 int col = (
int)m_Args[1]->GetInt();
6764 m_Result->SetNotSet();
6766 string value = m_DataIter->GetValueFromTable(col - 1);
6767 m_Result->SetString(
value);
6771 bool CMacroFunction_ValueFromTable::x_ValidArguments()
const
6773 if (m_Args.size() != 2)
6776 return (m_Args[0]->IsString() && m_Args[1]->IsInt());
6785 void CMacroFunction_GeneQual::TheFunction()
6793 string field_name = m_Args[0]->GetString();
6799 field_name =
"data.gene." + field_name;
6809 bool found_qual =
false;
6825 m_Result->SetObjects().push_back(it);
6833 for (
auto&& it : feat->
SetXref()) {
6834 if (it->IsSetData() && it->GetData().IsGene()) {
6835 gene_xref = &(it->SetData().SetGene());
6848 m_Result->GetObjects().empty()) {
6849 m_Result->SetNotSet();
6853 bool CMacroFunction_GeneQual::x_ValidArguments()
const
6875 string voucher_type;
6876 string voucher_part = m_Args[index]->GetString();
6878 const string& action_type = m_Args[++index]->GetString();
6880 bool remove_field =
false;
6881 x_GetOptionalArgs(
delimiter, remove_field, index);
6886 if (m_Args[0]->IsString()) {
6889 else if (m_Args[0]->AreObjects()) {
6890 objs = m_Args[0]->GetObjects();
6892 else if (m_Args[0]->IsRef()) {
6893 x_GetObjectsFromRef(objs, 0);
6896 if (voucher_type.empty() && objs.empty()) {
6906 if (!voucher_type.empty()) {
6913 if (!newValue.empty()) {
6915 bool has_voucher =
false;
6917 auto orgmod = *mod_it;
6918 if (orgmod->IsSetSubtype() && orgmod->GetSubtype() == subtype) {
6919 x_ApplyPart(*orgmod, part, newValue, existing_text);
6925 auto new_mod = x_AddNewQual(subtype, part, newValue);
6926 bsrc->
SetOrg().SetOrgname().SetMod().push_back(new_mod);
6927 m_QualsChangedCount++;
6931 auto new_mod = x_AddNewQual(subtype, part, newValue);
6932 bsrc->
SetOrg().SetOrgname().SetMod().push_back(new_mod);
6933 m_QualsChangedCount++;
6936 else if (remove_field) {
6938 auto orgmod = *mod_it;
6939 if (orgmod->IsSetSubtype() && orgmod->GetSubtype() == subtype) {
6940 x_RemovePart(*orgmod, part);
6941 m_QualsChangedCount++;
6942 if (orgmod->GetSubname().empty())
6947 bsrc->
SetOrg().SetOrgname().ResetMod();
6952 for (
auto&& it : objs) {
6959 if (!newValue.empty()) {
6961 x_ApplyPart(*
mod, part, newValue, existing_text);
6964 auto new_mod = x_AddNewQual(
mod->GetSubtype(), part, newValue);
6965 bsrc->
SetOrg().SetOrgname().SetMod().push_back(new_mod);
6966 m_QualsChangedCount++;
6969 else if (remove_field) {
6970 x_RemovePart(*
mod, part);
6972 m_QualsChangedCount++;
6979 if (m_QualsChangedCount) {
6980 m_DataIter->SetModified();
6983 if (!newValue.empty()) {
6984 report[
"setting new value to structured voucher " + voucher_part] = m_QualsChangedCount;
6986 else if (remove_field) {
6987 report[
"removal of structured voucher " + voucher_part] = m_QualsChangedCount;
6990 x_LogChangedQuals(fnc_log);
6998 auto arg_nr =
m_Args.size();
6999 if (arg_nr < 4 || arg_nr > 6)
7002 bool first_ok =
m_Args[0]->IsString() ||
m_Args[0]->AreObjects() ||
m_Args[0]->IsRef();
7003 if (!first_ok)
return false;
7005 if (!
m_Args[1]->IsString())
return false;
7008 bool third_ok =
m_Args[2]->IsString() ||
m_Args[2]->IsInt() ||
m_Args[2]->IsDouble();
7009 if (!third_ok)
return false;
7011 if (!
m_Args[3]->IsString())
return false;
7013 if (arg_nr > 4 && (!
m_Args[4]->IsString() && !
m_Args[4]->IsBool()))
return false;
7015 if (arg_nr > 5 && !
m_Args[5]->IsBool())
return false;
7024 string orig_inst, orig_coll, orig_id;
7029 auto update = [&newValue, existing_text,
this](
string&
value,
const string& orig_value)
7036 string inst{ orig_inst }, coll{ orig_coll },
id{ orig_id };
7049 string inst, coll, id;
7068 string inst, coll, id;
7084 void CMacroFunction_SetAutodefOption::TheFunction()
7093 string field_name = m_Args[index]->GetString();
7095 const string& field_value = m_Args[++index]->GetString();
7096 const string& existing_text_option = m_Args[++index]->GetString();
7098 bool remove_field =
false;
7099 x_GetOptionalArgs(
delimiter, remove_field, index);
7107 user_object->
AddField(field_name, field_value);
7108 m_QualsChangedCount++;
7111 if (user_object->
HasField(field_name)) {
7116 user_field.
SetData().SetStr(orig_val);
7117 m_QualsChangedCount++;
7123 user_object->
AddField(field_name, field_value);
7124 m_QualsChangedCount++;
7128 if (m_QualsChangedCount) {
7129 m_DataIter->SetModified();
7131 log << m_DataIter->GetBestDescr() <<
": applied ('" << field_name <<
"', '" << field_value <<
"') field-value pair";
7137 bool CMacroFunction_SetAutodefOption::x_ValidArguments()
const
7139 if (m_Args.size() < 3 || m_Args.size() > 4)
7142 for (
size_t i = 0;
i < m_Args.size(); ++
i) {
7143 if (!m_Args[
i]->IsString()) {
User-defined methods of the data storage class.
@ eExtreme_Biological
5' and 3'
bool IsSetOrgMod(void) const
bool IsSetOrgname(void) const
static bool CleanupUserObject(CUser_object &object)
@Gb_qual.hpp User-defined methods of the data storage class.
static int CodonToIndex(char base1, char base2, char base3)
bool IsSuppressed(void) const
Subclass of the IQueryParseUserObject which is held as the user-defined object in each CQueryParseNod...
class CMacroExecException
@Name_std.hpp User-defined methods of the data storage class.
@OrgMod.hpp User-defined methods of the data storage class.
static bool IsValidSubtypeName(const string &str, EVocabulary vocabulary=eVocabulary_raw)
static TSubtype GetSubtypeValue(const string &str, EVocabulary vocabulary=eVocabulary_raw)
static string MakeStructuredVoucher(const string &inst, const string &coll, const string &id)
static bool ParseStructuredVoucher(const string &str, string &inst, string &coll, string &id)
@RNA_ref.hpp User-defined methods of the data storage class.
string GetRnaProductName(void) const
void SetRnaProductName(const string &product, string &remainder)
ESubtype GetSubtype(void) const
@ eSubtype_mat_peptide_aa
namespace ncbi::objects::
const string & GetNamedQual(const CTempString &qual_name) const
Return a named qualifier.
void AddQualifier(const string &qual_name, const string &qual_val)
Add a qualifier to this feature.
const CGene_ref * GetGeneXref(void) const
See related function in util/feature.hpp.
static TSubtype GetSubtypeValue(const string &str, EVocabulary vocabulary=eVocabulary_raw)
static bool IsValidSubtypeName(const string &str, EVocabulary vocabulary=eVocabulary_raw)
CUser_field & SetValue(int value)
set a data field to a given value Int8 and TGi values can be stored into 'str' field if the value doe...
void SetObjectType(EObjectType obj_type)
void AddUnverifiedOrganism()
void AddUnverifiedContaminant()
bool RemoveNamedField(const string &field_name, NStr::ECase ecase=NStr::eCase)
@ eObjectType_StructuredComment
bool HasField(const string &str, const string &delim=".", NStr::ECase use_case=NStr::eCase) const
Verify that a named field exists.
bool IsAutodefOptions() const
CUser_object & AddField(const string &label, const string &value, EParseField parse=eParse_String)
add a data field to the user object that holds a given value
void AddUnverifiedMisassembled()
CUser_field & SetField(const string &str, const string &delim=".", const string &obj_subtype=kEmptyStr, NStr::ECase use_case=NStr::eCase)
Access a named field in this user object.
EObjectType GetObjectType() const
void AddUnverifiedFeature()
static auto & FixCapitalizationInString
static const string kSatelliteTypes[]
static void cleanup(void)
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
static const char table_name[]
static const char * str(char *buf, int n)
static const char location[]
Utility macros and typedefs for exploring NCBI objects from general.asn.
#define EDIT_EACH_USERFIELD_ON_USEROBJECT(Itr, Var)
#define ERASE_USERFIELD_ON_USEROBJECT(Itr, Var)
ERASE_USERFIELD_ON_USEROBJECT.
const TResidue codons[4][4]
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
void swap(NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair1, NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair2)
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
const CMemberId & GetId(void) const
const string & GetName(void) const
objects::ECapChange ConvertStringtoCapitalOption(const string &cap_name)
virtual bool x_ValidArguments(void) const
Tests the number and the type of function arguments.
virtual bool x_ChangeFields(CObjectInfo &src, CObjectInfo &dest)
virtual void TheFunction()
class CMacroFunction_EditStringQual Usage: EditStringQual(field_name|rt_obj, find_text,...
bool StringsAreEquivalent(const string &name1, const string &name2)
bool RemoveFirstName(objects::CName_std &std_name)
static bool s_EditText(string &str, const string &find, const string &repl, ESearchLoc loc, bool case_sensitive, bool is_regex=false)
bool SetQualStringValue(CObjectInfo &oi, const string &value)
Functions make the action and collect statistics.
void CleanupForTaxnameChange(CObjectInfo oi)
void SetString(const string &data)
Set/get underlying data type.
void x_RemovePart(objects::COrgMod &orgmod, NMacroUtil::EStructVoucherPart part)
static void s_MoveSuffixToTheEnd(objects::CUser_object &user_object)
virtual void TheFunction()
Function implementation.
static bool s_IsATGC(char ch)
CMacroFunction_SetCodonsRecognized SetCodonsRecognized(field_name) The field_name specifies one of th...
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
void x_SetOrCreateDestFeatFields(const objects::CSeq_feat &src_feat, CMQueryNodeValue::TObs &result, size_t index)
virtual bool x_ValidArguments(void) const
Tests the number and the type of function arguments.
objects::CSeqFeatData::ESubtype GetFeatSubtype(const string &feat_type)
void x_SetFields(CMQueryNodeValue::TObs &objs, const string &newValue, objects::edit::EExistingText existing_text, vector< string > &new_values)
CRef< CMacroCmdComposite > m_CmdComposite
static void s_ResetModSubsrcQuals(CBioSource &bsrc)
static bool s_AddSrcSubSource(objects::CBioSource &bsrc, int subtype, const string &value)
const char * kMobileElementTType
static string s_GetMobileElemTType(const string &value)
static vector< string > ParseDegenerateCodons(string codon)
bool x_GetSourceFields(CObjectInfo oi, size_t index, CMQueryNodeValue::TObs &result)
virtual bool x_ChangeFields(CObjectInfo &src, CObjectInfo &dest)=0
virtual void TheFunction()
Function implementation.
static bool s_SetEnumValue(CObjectInfo &obj, const string &str)
virtual bool x_ValidArguments(void) const
Tests the number and the type of function arguments.
bool x_GetSpecialField(const string &field, CMQueryNodeValue::TObs &objs, objects::CScope &scope)
CMQueryNodeValue::EType GetPrimitiveFromRef(CMQueryNodeValue &node)
void x_SetNewPrimitiveValue(CObjectInfo &oi, const string &newValue, objects::edit::EExistingText existing_text, vector< string > &new_values)
virtual bool x_ValidArguments(void) const
Tests the number and the type of function arguments.
static void s_AddNewDBlinkValue(CUser_field &user_field, const string &newValue)
AddDBLink(dblink_type, newValue, existing_text, delimiter, remove_blank) The last parameter is option...
static string s_GetMobileElemTName(const string &value)
virtual void TheFunction()
class CMacroFunction_ConvertStringQual ConvertStringQual(src_field, dst_field, capitalization,...
bool ResolveAndSetSimpleTypeValue(CObjectInfo &oi, const string &field_name, const CMQueryNodeValue &value, objects::edit::EExistingText existing_text=objects::edit::eExistingText_replace_old)
Resolve dot qualified ASN.1 node_name using the object information instance provided as a parameter (...
bool RemoveFieldByName(CMQueryNodeValue::SResolvedField &res_field)
Remove the object information instance corresponding to field, using information about its parent nod...
list< SResolvedField > TObs
virtual bool x_ValidArguments(void) const
Tests the number and the type of function arguments.
virtual void TheFunction()
Function implementation.
static string s_GetEnumValue(CObjectInfo &obj)
bool GetSimpleTypeValue(CObjectInfo &oi, const string &field_name, CMQueryNodeValue &value)
Get single node data from the node specified by parameter of type CObjectInfo and additionally field ...
virtual void TheFunction()
class CMacroFunction_SetStringQual Expected Syntax: SetStringQual(field_name, newValue,...
bool x_CheckArguments(size_t index) const
virtual bool x_ValidArguments(void) const
Tests the number and the type of function arguments.
void Dereference()
If it is a reference it is resolved to the first non reference type in the hierarchy.
const TObs & GetObjects() const
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
bool x_SetFields(CObjectInfo oi, CMQueryNodeValue::TObs &result, size_t index)
void GetPrimitiveObjInfosWithContainers(CMQueryNodeValue::TObs &objs, const CMQueryNodeValue::SResolvedField &info)
bool ResolveIdentToObjects(const CObjectInfo &oi, const string &identifier, CMQueryNodeValue &v)
Resolve name to the list of objects.
static void s_SetFeatField(CRef< CSeq_feat > feat, CObjectInfo &oi, const string &field_name, CMQueryNodeValue::TObs &result)
const char * kStrCommFieldValue
bool SetSimpleTypeValue(CObjectInfo &oi, const CMQueryNodeValue &value, objects::edit::EExistingText existing_text=objects::edit::eExistingText_replace_old)
Set single node data to the node specified by parameter of type CObjectInfo.
static const string s_GetExpansion(const string &ch)
virtual bool x_ValidArguments(void) const
Tests the number and the type of function arguments.
CConstRef< objects::CSeq_feat > m_ConstDestFeat
void RemoveGeneXref(objects::CSeq_feat &feat)
void ChangeFields(CMQueryNodeValue::TObs &src_objs, CMQueryNodeValue::TObs &dest_objs)
void SetDataType(EType dt)
bool x_MakeNewStructuredComment(const string &db_name, const string &kPrefix, const string &kSuffix)
string GetStringValue(CRef< CMQueryNodeValue > &value)
converts ints and doubles into string, by changing the type of the value
virtual bool x_ValidArguments(void) const
Tests the number and the type of function arguments.
void x_AddBioSrcModifier(const string &subtype, const string &newValue)
void x_ParseFields(CMQueryNodeValue::TObs &dest_objs, const string &text_portion, objects::edit::EExistingText existing_text)
string x_GetSourceString(CObjectInfo &src)
static bool s_AddNewUserField(CRef< CSeqdesc > &user_object_desc, const string &dblink, const string &newValue)
const char * kSatelliteType
const char * kSatelliteName
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
void x_RmvOutsideFields(CMQueryNodeValue::TObs &resolved_objs, const CRemoveTextOptions &options)
CObjectInfo GetPrimitiveObjInfo(const CObjectInfo &info)
bool x_GetDestFields(CObjectInfo oi, size_t index, CMQueryNodeValue::TObs &result)
const string & GetString() const
virtual bool x_ValidArguments(void) const
Tests the number and the type of function arguments.
EType GetDataType() const
CRef< CRemoveTextOptions > x_GetRemoveTextOptions(size_t start_index) const
virtual bool x_ValidArguments(void) const
Tests the number and the type of function arguments.
CRef< objects::CSeq_feat > m_EditDestFeat
const char * kStrCommFieldName
bool x_DoFieldsExist(CObjectInfo oi, CMQueryNodeValue::TObs &result, size_t index)
virtual bool x_ValidArguments(void) const
Tests the number and the type of function arguments.
void GetPrimitiveObjectInfos(CMQueryNodeValue::TObs &objs, const CMQueryNodeValue::SResolvedField &info)
virtual void TheFunction()
class CMacroFunction_ConvertStringQual ConvertStringQual(src_field, dst_field, capitalization,...
EStructVoucherPart GetSVPartFromString(const string voucher_part)
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
virtual void TheFunction()
Function implementation.
static string s_MakeSatellite(const string &type, const string &name)
Int4 m_QualsChangedCount
Number of changed qualifiers during the function call.
bool GetFieldsByName(CMQueryNodeValue::TObs *results, const CObjectInfo &oi_i, const string &field_name)
Resolve existing dot qualified ASN.1 name (field_name) starting from the object information instance ...
virtual bool x_ValidArguments(void) const
Tests the number and the type of function arguments.
bool x_DoDestFeatFieldsExist(const objects::CSeq_feat &src_feat, CMQueryNodeValue::TObs &result, const string &dest_feattype, const string &dest_field)
bool IsTaxname(CMQueryNodeValue::SResolvedField &res)
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
virtual void TheFunction()
class CMacroFunction_CopyStringQual Expected syntax: CopyStringQual( src_field, dest_field,...
CRef< objects::edit::CParseTextOptions > x_GetParseOptions(size_t start_index)
static string s_GetSatelliteName(const string &value)
virtual bool x_ValidArguments(void) const
Tests the number and the type of function arguments.
static const string kAmbiguities
static int s_AddGBQualifier(objects::CSeq_feat &feat, const string &qual_name, const string &newValue)
static void s_SetVectorValue(CUser_field &user_field, const string &newValue, const string &del)
virtual void TheFunction()
Function implementation.
virtual bool x_ValidArguments(void) const
Tests the number and the type of function arguments.
CRef< objects::COrgMod > x_AddNewQual(objects::COrgMod::TSubtype subtype, NMacroUtil::EStructVoucherPart part, const string &newValue)
bool ResolveIdentToSimple(const CObjectInfo &oi, const string &identifier, CMQueryNodeValue &v)
Resolve name to simple types value.
bool SetFieldsByName(CMQueryNodeValue::TObs *results, CObjectInfo &oi_i, const string &field_name)
Resolve not necessarily existing dot qualified ASN.1 name (field_name) starting from the object infor...
void x_CopyFields(CMQueryNodeValue::TObs &src_objs, CMQueryNodeValue::TObs &dest_objs)
virtual void TheFunction()
Function implementation.
static string s_GatherExistingValues(CUser_field &user_field, const string &newValue, const string &del)
virtual bool x_ValidArguments(void) const
Tests the number and the type of function arguments.
void x_GetObjectsFromRef(CMQueryNodeValue::TObs &objects, const size_t &index)
objects::edit::EExistingText ActionTypeToExistingTextOption(const string &action_type, const string &delimiter)
CRef< CMQueryNodeValue > m_Result
virtual bool x_ValidArguments(void) const
Tests the number and the type of function arguments.
static Int4 s_RemoveFields(CIRef< IMacroBioDataIter > &dataiter, CMQueryNodeValue::TObs &objs)
virtual bool x_ValidArguments(void) const
Tests the number and the type of function arguments.
void x_SetFieldType(const string &strcomm_field)
bool IsSatelliteSubfield(const string &field)
static int s_UpdateStructCommentDb(objects::CSeqdesc &seqdesc, const string &field, const string &db_name, objects::edit::EExistingText existing_text)
objects::ECapChange m_CapChange
static ESearchLoc s_GetLocFromName(const string &name)
bool IsMobileElementTSubfield(const string &field)
const char * kMobileElementTQual
static string s_MakeMobileElementT(const string &type, const string &name)
virtual void TheFunction()
class CMacroFunction_CopyStringQual Expected syntax: CopyStringQual( src_field, dest_field,...
static const string kReplacements[]
bool x_SwapFields(CObjectInfo &src, CObjectInfo &dest)
static void s_AddUnverifiedType(CUser_object &user, NMacroUtil::EUnverifiedType type)
class CMacroFunction_AddUnverified AddUnverified("Features"); The user object will be added only to n...
string x_GetSourceString(CObjectInfo &src)
void x_LogFunction(CNcbiOstrstream &logstr)
virtual bool x_ValidArguments(void) const
Tests the number and the type of function arguments.
bool ApplyFirstName(objects::CName_std &std_name, const string &newValue, objects::edit::EExistingText existing_text)
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
bool IsBiosourceModifier(const string &field)
virtual bool x_ValidArguments(void) const
Tests the number and the type of function arguments.
virtual bool x_ChangeFields(CObjectInfo &src, CObjectInfo &dest)
static void s_SetBioSourceField(CRef< CBioSource > bsrc, CObjectInfo &oi, const string &field_name, CMQueryNodeValue::TObs &dest_objs)
bool EditText(string &str) const
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
CRef< objects::CSeq_feat > m_CreatedFeat
void x_SetField(CConstRef< CObject > &obj, const string &fieldname, CMQueryNodeValue::TObs &result)
void SwapGbQualWithValues(CMQueryNodeValue::TObs &objs)
void SetObjects(const TObs &obs)
static const char * sm_FunctionName
EditRelatedFeatureQual(feat_type, field_name, find_text, repl_text, location, case_sensitive,...
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
string x_GetSourceString(CObjectInfo &src)
const char * kMobileElementTName
DEFINE_MACRO_FUNCNAME(CMacroFunction_CopyFeatQual, "CopyFeatureQual")
CopyFeatureQual(src_field, dest_feature_type, dest_feature_field, update_mrna, existing_text_opt,...
virtual bool x_ChangeFields(CObjectInfo &src, CObjectInfo &dest)
void x_ApplyPart(objects::COrgMod &orgmod, NMacroUtil::EStructVoucherPart part, const string &newValue, objects::edit::EExistingText existing_text)
static bool s_AddSrcOrgMod(objects::CBioSource &bsrc, int subtype, const string &value)
EUnverifiedType GetUnverifiedType(const string &value)
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
CIRef< IMacroBioDataIter > m_DataIter
static bool s_SwapFields(CObjectInfo &src, CObjectInfo &dest)
vector< CConstRef< objects::CSeq_feat > > TVecFeatList
virtual bool x_ValidArguments(void) const
Tests the number and the type of function arguments.
vector< pair< objects::CSeqdesc_CI, CRef< objects::CSeqdesc > > > m_ChangedDescriptors
virtual void TheFunction()
Function implementation.
objects::edit::EExistingText m_ExistingText
void RemoveEmptyDescriptors(objects::CBioseq &bseq)
const char * kStrCommDbname
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
void x_EditFields(CMQueryNodeValue::TObs &resolved_objs, const string &find_txt, const string &repl_txt, ESearchLoc loc, bool case_sensitive, bool is_regex)
static string s_GetSatelliteType(const string &value)
size_t TMemberIndex
Type used for indexing class members and choice variants.
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
virtual const CTypeInfo * GetThisTypeInfo(void) const =0
static const TObjectType * SafeCast(TTypeInfo type)
@ ePrimitiveValueString
string|char*|const char*
@ ePrimitiveValueInteger
(signed|unsigned) (char|short|int|long)
@ ePrimitiveValueChar
char
@ ePrimitiveValueBool
bool
@ ePrimitiveValueEnum
enum
@ ePrimitiveValueReal
float|double
CElementIterator BeginElements(void) const
Create container elements iterator.
CObjectInfo AddNewPointedElement(void) const
add new pointer element, create new pointed object and return it
CObjectInfo GetPointedObject(void) const
Get data and type information of object to which this type refers.
bool GetPrimitiveValueBool(void) const
Get boolean data.
const CMemberInfo * GetMemberInfo(void) const
TObjectPtr GetObjectPtr(void) const
Get pointer to object.
CObjectInfo GetMember(void) const
Get class member data.
void SetPrimitiveValueString(const string &value)
void SetPrimitiveValueBool(bool value)
Set boolean data.
int GetPrimitiveValueInt(void) const
Get data as int.
void SetPrimitiveValueInt8(Int8 value)
void SetPrimitiveValueInt4(Int4 value)
CObjectInfo AddNewElement(void) const
Add and return new element object.
CMemberIterator GetClassMemberIterator(TMemberIndex index) const
Create class member iterator that initially points to specified member.
ETypeFamily GetTypeFamily(void) const
Get data type family.
void GetPrimitiveValueString(string &value) const
Get string data.
double GetPrimitiveValueDouble(void) const
Get data as double.
CMemberIterator FindClassMember(const string &memberName) const
Find class member by its name.
Int4 GetPrimitiveValueInt4(void) const
Get data as Int4.
void SetPrimitiveValueDouble(double value)
const string & GetName(void) const
Get type name.
void SetPrimitiveValueInt(int value)
EPrimitiveValueType GetPrimitiveValueType(void) const
Get type of primitive value.
Int8 GetPrimitiveValueInt8(void) const
Get data as Int8.
bool IsSet(void) const
Is member assigned a value.
CObjectTypeInfo GetElementType(void) const
Get type information of an element of container.
void GetCdssForGene(const CMappedFeat &gene_feat, list< CMappedFeat > &cds_feats, CFeatTree *feat_tree=0, const SAnnotSelector *base_sel=0)
CMappedFeat GetBestMrnaForCds(const CMappedFeat &cds_feat, CFeatTree *feat_tree=0, const SAnnotSelector *base_sel=0)
CMappedFeat GetBestCdsForMrna(const CMappedFeat &mrna_feat, CFeatTree *feat_tree=0, const SAnnotSelector *base_sel=0)
CRef< CSeq_loc > Seq_loc_Merge(const CSeq_loc &loc, CSeq_loc::TOpFlags flags, CScope *scope)
Merge ranges in the seq-loc.
const CSeq_feat * GetCDSForProduct(const CBioseq &product, CScope *scope)
Get the encoding CDS feature of a given protein sequence.
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
CSeq_feat_Handle GetSeq_featHandle(const CSeq_feat &feat, EMissing action=eMissing_Default)
CConstRef< CBioseq > GetCompleteBioseq(void) const
Get the complete bioseq.
CSeq_entry_Handle GetSeq_entry_Handle(void) const
Get parent Seq-entry handle.
virtual const CSeq_loc & GetProduct(void) const
bool IsSetProduct(void) const
virtual const CSeq_loc & GetLocation(void) const
CConstRef< CSeq_feat > GetOriginalSeq_feat(void) const
CSeq_entry_Handle GetSeq_entry_Handle(void) const
TObjectType * GetPointer(void) const THROWS_NONE
Get pointer,.
TObjectType * GetNCPointer(void) const THROWS_NONE
Get pointer,.
CConstRef< C > ConstRef(const C *object)
Template function for conversion of const object pointer to CConstRef.
CRef< C > Ref(C *object)
Helper functions to get CRef<> and CConstRef<> objects.
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
void Reset(void)
Reset reference object.
void Reset(void)
Reset reference object.
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
TObjectType & GetObject(void) const
Get object.
int32_t Int4
4-byte (32-bit) signed integer
int64_t Int8
8-byte (64-bit) signed integer
size_t Replace(CTempStringEx search, CTempString replace, CRegexp::TCompile compile_flags=CRegexp::fCompile_default, CRegexp::TMatch match_flags=CRegexp::fMatch_default, size_t max_replace=0)
Replace occurrences of a substring within a string by pattern.
unsigned int TCompile
Type definitions used for code clarity.
string GetResult(void)
Get result string.
#define END_NCBI_SCOPE
End previously defined NCBI scope.
#define USING_SCOPE(ns)
Use the specified namespace.
#define END_SCOPE(ns)
End the previously defined scope.
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
#define BEGIN_SCOPE(ns)
Define a new scope.
NCBI_NS_STD::string::size_type SIZE_TYPE
static string Int8ToString(Int8 value, TNumToStringFlags flags=0, int base=10)
Convert Int8 to string.
static string DoubleToString(double value, int precision=-1, TNumToStringFlags flags=0)
Convert double to string.
static Int8 StringToInt8(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to Int8.
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 FindNoCase(const CTempString str, const CTempString pattern, SIZE_TYPE start, SIZE_TYPE end, EOccurrence which=eFirst)
Find the pattern in the specified range of a string using a case insensitive search.
static bool EndsWith(const CTempString str, const CTempString end, ECase use_case=eCase)
Check if a string ends with a specified suffix value.
static bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
static const string BoolToString(bool value)
Convert bool to string.
static void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string (in-place)
static string IntToString(int value, TNumToStringFlags flags=0, int base=10)
Convert int to string.
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 bool EqualCase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-sensitive equality of a substring with another string.
static SIZE_TYPE FindCase(const CTempString str, const CTempString pattern, SIZE_TYPE start, SIZE_TYPE end, EOccurrence which=eFirst)
Find the pattern in the specified range of a string using a case sensitive search.
static long StringToLong(const CTempString str, TStringToNumFlags flags=0, int base=10)
Convert string to long.
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.
static enable_if< is_arithmetic< TNumeric >::value||is_convertible< TNumeric, Int8 >::value, string >::type NumericToString(TNumeric value, TNumToStringFlags flags=0, int base=10)
Convert numeric value to 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.
static string & ToUpper(string &str)
Convert string to upper case – string& version.
@ fConvErr_NoThrow
Do not throw an exception on error.
@ eNocase
Case insensitive compare.
@ eCase
Case sensitive compare.
const TSubtype & GetSubtype(void) const
Get the Subtype member data.
void SetSubtype(TSubtype value)
Assign a value to Subtype data member.
bool IsSetOrg(void) const
Check if a value has been assigned to Org data member.
bool IsSetSubtype(void) const
Check if a value has been assigned to Subtype data member.
const TOrg & GetOrg(void) const
Get the Org member data.
void SetOrg(TOrg &value)
Assign a value to Org data member.
void SetName(const TName &value)
Assign a value to Name data member.
TSubtype & SetSubtype(void)
Assign a value to Subtype data member.
void ResetSubtype(void)
Reset Subtype data member.
const TStr & GetStr(void) const
Get the variant data.
bool IsSetData(void) const
the object itself Check if a value has been assigned to Data data member.
bool IsStr(void) const
Check if variant Str is selected.
bool IsStrs(void) const
Check if variant Strs is selected.
const TStrs & GetStrs(void) const
Get the variant data.
const TData & GetData(void) const
Get the Data member data.
bool IsStr(void) const
Check if variant Str is selected.
bool IsSetLabel(void) const
field label Check if a value has been assigned to Label data member.
TData & SetData(void)
Assign a value to Data data member.
void SetNum(TNum value)
Assign a value to Num data member.
const TStr & GetStr(void) const
Get the variant data.
void SetLabel(TLabel &value)
Assign a value to Label data member.
const TData & GetData(void) const
Get the Data member data.
void SetType(TType &value)
Assign a value to Type data member.
void ResetNum(void)
Reset Num data member.
void SetData(TData &value)
Assign a value to Data data member.
const TLabel & GetLabel(void) const
Get the Label member data.
const TType & GetType(void) const
Get the Type member data.
bool IsSetData(void) const
Check if a value has been assigned to Data data member.
E_Choice Which(void) const
Which variant is currently selected.
@ e_not_set
No variant selected.
const TMod & GetMod(void) const
Get the Mod member data.
bool IsSetDb(void) const
ids in taxonomic or culture dbases Check if a value has been assigned to Db data member.
const TSubname & GetSubname(void) const
Get the Subname member data.
void SetSubtype(TSubtype value)
Assign a value to Subtype data member.
const TDb & GetDb(void) const
Get the Db member data.
bool IsSetSubname(void) const
Check if a value has been assigned to Subname data member.
TMod & SetMod(void)
Assign a value to Mod data member.
void SetSubname(const TSubname &value)
Assign a value to Subname data member.
const TOrgname & GetOrgname(void) const
Get the Orgname member data.
@ eSubtype_specimen_voucher
@ eSubtype_culture_collection
const TName & GetName(void) const
Get the Name member data.
TType GetType(void) const
Get the Type member data.
bool IsSetType(void) const
Check if a value has been assigned to Type data member.
TXref & SetXref(void)
Assign a value to Xref data member.
bool IsSetComment(void) const
Check if a value has been assigned to Comment data member.
bool IsSetData(void) const
the specific data Check if a value has been assigned to Data data member.
bool IsSetQual(void) const
qualifiers Check if a value has been assigned to Qual data member.
bool IsProt(void) const
Check if variant Prot is selected.
bool IsCdregion(void) const
Check if variant Cdregion is selected.
void SetComment(const TComment &value)
Assign a value to Comment data member.
bool IsSetXref(void) const
cite other relevant features Check if a value has been assigned to Xref data member.
const TLocation & GetLocation(void) const
Get the Location member data.
bool IsGene(void) const
Check if variant Gene is selected.
const TData & GetData(void) const
Get the Data member data.
void SetData(TData &value)
Assign a value to Data data member.
const TProduct & GetProduct(void) const
Get the Product member data.
const TProt & GetProt(void) const
Get the variant data.
const TXref & GetXref(void) const
Get the Xref member data.
vector< CRef< CSeqFeatXref > > TXref
void ResetXref(void)
Reset Xref data member.
const TRna & GetRna(void) const
Get the variant data.
TQual & SetQual(void)
Assign a value to Qual data member.
bool IsSetProduct(void) const
product of process Check if a value has been assigned to Product data member.
bool IsRna(void) const
Check if variant Rna is selected.
bool IsSetLocation(void) const
feature made from Check if a value has been assigned to Location data member.
bool IsGenbank(void) const
Check if variant Genbank is selected.
const TUser & GetUser(void) const
Get the variant data.
const TTitle & GetTitle(void) const
Get the variant data.
const TGenbank & GetGenbank(void) const
Get the variant data.
void SetDescr(TDescr &value)
Assign a value to Descr data member.
TUser & SetUser(void)
Select the variant.
bool IsUser(void) const
Check if variant User is selected.
@ e_User
user defined object
@ e_Title
a title for this sequence
unsigned int
A callback function used to compare two keys in a database.
Functions that resolve field names described in asn format.
const struct ncbi::grid::netcache::search::fields::CREATED created
const GenericPointer< typename T::ValueType > T2 value
static const char delimiter[]
Utility macros and typedefs for exploring NCBI objects from seqfeat.asn.
#define ERASE_ORGMOD_ON_BIOSOURCE(Itr, Var)
ERASE_ORGMOD_ON_BIOSOURCE.
#define EDIT_EACH_ORGMOD_ON_BIOSOURCE(Itr, Var)
#define EDIT_EACH_SUBSOURCE_ON_BIOSOURCE(Itr, Var)
#define EDIT_EACH_GBQUAL_ON_SEQFEAT(Itr, Var)
@ eExistingText_append_semi
@ eExistingText_leave_old
@ eExistingText_replace_old
bool AddValueToString(string &str, const string &value, EExistingText existing_text)
Add text to an existing string, using the "existing_text" directive to combine new text with existing...
C++ wrappers for the Perl-compatible regular expression (PCRE) library.
CRef< CCmdComposite > UpdatemRNAProduct(const objects::CSeq_feat &protein, objects::CScope &scope, string &message)
void SetProteinFeature(objects::CSeq_feat &prot, objects::CBioseq_Handle product, const objects::CSeq_feat &cds)