86 void CMacroFunction_TrimStopFromCompleteCDS::TheFunction()
90 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
91 if (!edit_feat || !scope)
99 m_DataIter->RunCommand(
cmd, m_CmdComposite);
104 log <<
"Removed trailing * from protein sequence " << best_id;
109 bool CMacroFunction_TrimStopFromCompleteCDS::x_ValidArguments()
const
111 return (m_Args.empty());
121 void CMacroFunction_SynchronizeCDSPartials::TheFunction()
125 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
126 if (!edit_feat || !scope)
132 m_DataIter->SetModified();
138 m_DataIter->RunCommand(synch_cmd, m_CmdComposite);
141 if (change || synch_cmd) {
143 log << m_DataIter->GetBestDescr() <<
" synchronized coding region partials";
148 bool CMacroFunction_SynchronizeCDSPartials::x_ValidArguments()
const
150 return (m_Args.empty());
159 void CMacroFunction_AdjustConsensusSpliceSites::TheFunction()
163 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
164 if (!edit_feat || !scope)
168 orig_feat.
Assign(*edit_feat);
175 bool changed = worker.AdjustCDS(*edit_feat);
177 m_DataIter->SetModified();
182 m_DataIter->RunCommand(update_cmd, m_CmdComposite);
185 log <<
"Adjusted location for splice consensus: " << m_DataIter->GetBestDescr() <<
" became ";
203 bool CMacroFunction_AdjustConsensusSpliceSites::x_ValidArguments()
const
205 return (m_Args.empty());
215 void CMacroFunction_RemoveInvalidECNumbers::TheFunction()
224 if (!
prot.IsSetEc() ||
prot.GetEc().empty())
227 typedef vector< CProt_ref::EECNumberStatus > TVecStatus;
229 TVecStatus st_before;
236 unsigned int replaced = 0;
237 TVecStatus::const_iterator it_bef = st_before.begin();
238 CProt_ref::TEc::const_iterator ec =
prot.GetEc().begin();
239 for (; ec !=
prot.GetEc().
end() && it_bef != st_before.end(); ++ec, ++it_bef) {
247 unsigned int removed = (
unsigned int)(st_before.size() -
prot.GetEc().size());
249 if (replaced || removed) {
250 m_DataIter->SetModified();
252 log << m_DataIter->GetBestDescr() <<
": ";
254 log <<
" replaced " << replaced <<
" EC numbers";
257 log <<
" removed " << removed <<
" EC numbers";
263 bool CMacroFunction_RemoveInvalidECNumbers::x_ValidArguments()
const
265 return (m_Args.empty());
276 void CMacroFunction_UpdateReplacedECNumbers::TheFunction()
278 bool del_improper_format = m_Args[0]->GetBool();
279 bool del_unrecognized = m_Args[1]->GetBool();
280 bool del_mult_replacement = m_Args[2]->GetBool();
284 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
285 if (!prot_feat || !prot_feat->
GetData().
IsProt() || !scope) {
290 if (!
prot.IsSetEc() ||
prot.GetEc().empty())
294 string locus_tag(
"No locus tag");
298 CProt_ref::TEc::iterator ec =
prot.SetEc().begin();
299 while (ec !=
prot.SetEc().end()) {
300 bool removed =
false;
307 log << locus_tag <<
": replaced " << *ec <<
" with " << repl_ec <<
"\n";
310 else if (del_mult_replacement) {
311 log << locus_tag <<
": removed " << *ec <<
"\n";
312 ec =
prot.SetEc().erase(ec);
318 log << locus_tag <<
": removed " << *ec <<
"\n";
319 ec =
prot.SetEc().erase(ec);
324 if (del_improper_format) {
325 log << locus_tag <<
": removed " << *ec <<
"\n";
326 ec =
prot.SetEc().erase(ec);
336 if (
prot.GetEc().empty()) {
340 m_DataIter->SetModified();
344 bool CMacroFunction_UpdateReplacedECNumbers::x_ValidArguments()
const
346 size_t arg_size = m_Args.size();
351 for (
size_t n = 0;
n < arg_size; ++
n) {
364 void CMacroFunction_UpdatemRNAProduct::TheFunction()
366 if (!m_Args.empty()) {
381 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
383 if (!prot_feat || !scope ||
390 string product =
prot.GetName().front();
392 log << m_DataIter->GetBestDescr() <<
": ";
401 new_mrna->Assign(*mrna);
403 bool modified =
false;
408 log <<
"Reset the mRNA product name ";
412 rna.SetExt().SetName(product);
413 log <<
"Applied " << product <<
" to mRNA product name ";
422 cmd->AddCommand(*chgFeat);
423 m_DataIter->RunCommand(
cmd, m_CmdComposite);
431 bool CMacroFunction_UpdatemRNAProduct::x_ValidArguments()
const
447 void CMacroFunction_RemoveFeature::TheFunction()
449 if (!m_DataIter->IsFeature()) {
453 m_DataIter->SetToDelete(
true);
455 bool delete_gene =
false;
457 if (m_Args.size() == 1 && m_Args[0]->GetBool()) {
461 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
467 cmd->AddCommand(*del_cmd);
468 m_DataIter->RunCommand(
cmd, m_CmdComposite);
474 log << m_DataIter->GetBestDescr() <<
": feature removed";
476 log <<
" and the overlapping gene";
481 bool CMacroFunction_RemoveFeature::x_ValidArguments()
const
483 return m_Args.empty() || (m_Args.size() == 1 && m_Args[0]->IsBool());
492 void CMacroFunction_CopyNameToCDSNote::TheFunction()
496 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
498 if (!prot_feat || !scope ||
505 string product =
prot.GetName().front();
507 log << m_DataIter->GetBestDescr() <<
": ";
514 new_cds->Assign(*cds);
516 bool modified =
false;
517 string orig_comment = (new_cds->IsSetComment()) ? new_cds->GetComment() :
kEmptyStr;
519 new_cds->SetComment(orig_comment);
520 log <<
"Copied protein name to CDS note";
528 cmd->AddCommand(*chgFeat);
529 m_DataIter->RunCommand(
cmd, m_CmdComposite);
536 bool CMacroFunction_CopyNameToCDSNote::x_ValidArguments()
const
538 return (m_Args.empty());
551 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
555 bool remove_proteins =
true;
560 else if (bseq && bseq->
IsNa()) {
567 if (!m_DataIter->HasBeenCompleted()) {
568 m_ProductToCds.clear();
570 m_DataIter->SetCompleted();
583 m_DataIter->RunCommand(delete_features_cmd, m_CmdComposite);
585 log <<
"Removed " << count <<
" features";
600 void CMacroFunction_RemoveDuplFeatures::TheFunction()
604 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
609 bool check_partials = m_Args[1]->GetBool();
610 bool case_sensitive = m_Args[2]->GetBool();
611 bool remove_proteins = m_Args[3]->GetBool();
617 for (
CFeat_CI feat_it1(bsh, sel); feat_it1; ++feat_it1) {
618 for (
CFeat_CI feat_it2(*scope, feat_it1->GetLocation(), sel); feat_it2; ++feat_it2) {
619 if (feat_it1->GetSeq_feat_Handle() < feat_it2->GetSeq_feat_Handle()) {
622 duplicates.
insert(feat_it2->GetSeq_feat_Handle());
628 if (duplicates.
empty())
636 m_DataIter->RunCommand(
cmd, m_CmdComposite);
638 report[
"removal of duplicate features"] = duplicates.
size();
640 x_LogChangedQuals(fnc_log);
643 bool CMacroFunction_RemoveDuplFeatures::x_ValidArguments()
const
645 if (m_Args.size() != 4 || !m_Args[0]->IsString()) {
649 for (
size_t i = 1;
i < m_Args.size(); ++
i) {
650 if (!m_Args[
i]->IsBool())
667 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
674 if (m_DataIter->IsHugeDataMode()) {
675 vector<string> seh_taxnames;
678 x_FixProteinNames(prot_feat->
SetData().SetProt(), seh_taxnames);
681 if (m_NewNames.empty()) {
682 const auto& taxnames = m_DataIter->GetTaxnames();
683 x_FixProteinNames(prot_feat->
SetData().SetProt(), taxnames);
686 if (!m_NewNames.empty()) {
687 m_DataIter->SetModified();
689 for (
size_t n = 0;
n < m_NewNames.size(); ++
n) {
690 log <<
"On " << m_DataIter->GetBestDescr();
691 log <<
": changed protein name from " << m_OrigNames[
n];
692 log <<
" to " << m_NewNames[
n];
700 for (
auto& it :
prot.SetName()) {
720 if (taxnames.empty())
723 string new_prot(protein);
724 vector<string> pattern;
725 pattern.push_back(
"()");
726 pattern.push_back(
"( )");
727 pattern.push_back(
"[]");
728 pattern.push_back(
"[ ]");
729 ITERATE(vector<string>, name, taxnames) {
732 new_prot = protein.substr(0, pos) + protein.substr(pos + name->length());
736 ITERATE(vector<string>, pat_it, pattern) {
775 m_Seqfeat->GetLocation().GetLabel(&new_loc);
777 log << descr <<
" for " <<
m_DataIter->GetBestDescr() <<
" to " << new_loc;
783 if (adjust_gene_cmd) {
785 cmd->AddCommand(*adjust_gene_cmd);
787 log <<
" and adjusted gene location.";
799 if (!
m_DataIter->HasBeenCompleted() && feat_iter) {
800 feat_iter->SetCreateGeneralIdFlag();
804 bool cds_change =
false;
809 log <<
" and retranslated the coding region ";
817 log <<
" and synchronized CDS partials";
834 if (!x_CheckInitFeature())
837 m_Modified = s_SetBothEndsPartial(*m_Seqfeat, *
m_Scope, m_Args[0]->GetString(), m_Args[1]->GetBool());
839 m_RetranslateCDS = (m_Args.size() > 2) ? m_Args[2]->GetBool() :
false;
840 m_AdjustGene = (m_Args.size() == 4) ? m_Args[3]->GetBool() :
false;
841 x_RetranslateCDSAdjustGene(
"Set both end partials");
854 edit::CLocationEditPolicy::EPartialPolicy policy5 = edit::CLocationEditPolicy::ePartialPolicy_eNoChange;
855 edit::CLocationEditPolicy::EPartialPolicy policy3 = edit::CLocationEditPolicy::ePartialPolicy_eNoChange;
857 policy5 = edit::CLocationEditPolicy::ePartialPolicy_eSet;
858 policy3 = edit::CLocationEditPolicy::ePartialPolicy_eSet;
863 && edit::CLocationEditPolicy::Is5AtEndOfSeq(feat.
GetLocation(), bsh)
864 && edit::CLocationEditPolicy::Is3AtEndOfSeq(feat.
GetLocation(), bsh)) {
866 policy5 = edit::CLocationEditPolicy::ePartialPolicy_eSetAtEnd;
867 policy3 = edit::CLocationEditPolicy::ePartialPolicy_eSetAtEnd;
871 bool extend5(
false), extend3(
false);
878 return policy->ApplyPolicyToFeature(feat, scope);
887 for (
size_t i = 1;
i <
m_Args.size(); ++
i) {
905 if (!x_CheckInitFeature())
908 m_Modified = s_RemoveBothPartials(*m_Seqfeat, *
m_Scope, m_Args[0]->GetString());
910 m_RetranslateCDS = (m_Args.size() > 1) ? m_Args[1]->GetBool() :
false;
911 m_AdjustGene = (m_Args.size() == 3) ? m_Args[2]->GetBool() :
false;
912 x_RetranslateCDSAdjustGene(
"Removed both ends partial");
925 edit::CLocationEditPolicy::EPartialPolicy policy5 = edit::CLocationEditPolicy::ePartialPolicy_eNoChange;
926 edit::CLocationEditPolicy::EPartialPolicy policy3 = edit::CLocationEditPolicy::ePartialPolicy_eNoChange;
928 policy5 = edit::CLocationEditPolicy::ePartialPolicy_eClear;
929 policy3 = edit::CLocationEditPolicy::ePartialPolicy_eClear;
934 && !edit::CLocationEditPolicy::Is5AtEndOfSeq(feat.
GetLocation(), bsh)
935 && !edit::CLocationEditPolicy::Is3AtEndOfSeq(feat.
GetLocation(), bsh)) {
937 policy5 = edit::CLocationEditPolicy::ePartialPolicy_eClearNotAtEnd;
938 policy3 = edit::CLocationEditPolicy::ePartialPolicy_eClearNotAtEnd;
942 bool extend5 =
false, extend3 =
false;
944 return policy->ApplyPolicyToFeature(feat, scope);
952 for (
size_t i = 1;
i <
m_Args.size(); ++
i) {
968 if (!x_CheckInitFeature())
971 m_Modified = s_Set5EndPartial(*m_Seqfeat, *
m_Scope, m_Args[0]->GetString(), m_Args[1]->GetBool());
973 m_RetranslateCDS = (m_Args.size() > 2) ? m_Args[2]->GetBool() :
false;
974 m_AdjustGene = (m_Args.size() == 4) ? m_Args[3]->GetBool() :
false;
975 x_RetranslateCDSAdjustGene(
"Set 5' end partial");
988 edit::CLocationEditPolicy::EPartialPolicy policy5 = edit::CLocationEditPolicy::ePartialPolicy_eNoChange;
991 policy5 = edit::CLocationEditPolicy::ePartialPolicy_eSet;
994 policy5 = edit::CLocationEditPolicy::ePartialPolicy_eSetAtEnd;
997 policy5 = edit::CLocationEditPolicy::ePartialPolicy_eSetForBadEnd;
1000 policy5 = edit::CLocationEditPolicy::ePartialPolicy_eSetForFrame;
1004 bool extend3 =
false;
1005 CRef<edit::CLocationEditPolicy> policy(
new edit::CLocationEditPolicy(policy5, edit::CLocationEditPolicy::ePartialPolicy_eNoChange, extend5, extend3));
1006 return policy->ApplyPolicyToFeature(feat, scope);
1014 for (
size_t i = 1;
i <
m_Args.size(); ++
i) {
1030 if (!x_CheckInitFeature())
1033 m_Modified = s_Set3EndPartial(*m_Seqfeat, *
m_Scope, m_Args[0]->GetString(), m_Args[1]->GetBool());
1035 m_RetranslateCDS = (m_Args.size() > 2) ? m_Args[2]->GetBool() :
false;
1036 m_AdjustGene = (m_Args.size() == 4) ? m_Args[3]->GetBool() :
false;
1037 x_RetranslateCDSAdjustGene(
"Set 3' end partial");
1050 edit::CLocationEditPolicy::EPartialPolicy policy3 = edit::CLocationEditPolicy::ePartialPolicy_eNoChange;
1053 policy3 = edit::CLocationEditPolicy::ePartialPolicy_eSet;
1056 policy3 = edit::CLocationEditPolicy::ePartialPolicy_eSetAtEnd;
1059 policy3 = edit::CLocationEditPolicy::ePartialPolicy_eSetForBadEnd;
1063 bool extend5 =
false;
1064 CRef<edit::CLocationEditPolicy> policy(
new edit::CLocationEditPolicy(edit::CLocationEditPolicy::ePartialPolicy_eNoChange, policy3, extend5, extend3));
1065 return policy->ApplyPolicyToFeature(feat, scope);
1073 for (
size_t i = 1;
i <
m_Args.size(); ++
i) {
1088 if (!x_CheckInitFeature())
1091 m_Modified = s_Clear5EndPartial(*m_Seqfeat, *
m_Scope, m_Args[0]->GetString());
1093 m_RetranslateCDS = (m_Args.size() > 1) ? m_Args[1]->GetBool() :
false;
1094 m_AdjustGene = (m_Args.size() == 3) ? m_Args[2]->GetBool() :
false;
1095 x_RetranslateCDSAdjustGene(
"Cleared 5' end partial");
1108 edit::CLocationEditPolicy::EPartialPolicy policy5 = edit::CLocationEditPolicy::ePartialPolicy_eNoChange;
1111 policy5 = edit::CLocationEditPolicy::ePartialPolicy_eClear;
1114 policy5 = edit::CLocationEditPolicy::ePartialPolicy_eClearNotAtEnd;
1117 policy5 = edit::CLocationEditPolicy::ePartialPolicy_eClearForGoodEnd;
1121 bool extend5 =
false, extend3 =
false;
1122 CRef<edit::CLocationEditPolicy> policy(
new edit::CLocationEditPolicy(policy5, edit::CLocationEditPolicy::ePartialPolicy_eNoChange, extend5, extend3));
1123 return policy->ApplyPolicyToFeature(feat, scope);
1131 for (
size_t i = 1;
i <
m_Args.size(); ++
i) {
1148 if (!x_CheckInitFeature())
1151 m_Modified = s_Clear3EndPartial(*m_Seqfeat, *
m_Scope, m_Args[0]->GetString());
1153 m_RetranslateCDS = (m_Args.size() > 1) ? m_Args[1]->GetBool() :
false;
1154 m_AdjustGene = (m_Args.size() == 3) ? m_Args[2]->GetBool() :
false;
1155 x_RetranslateCDSAdjustGene(
"Cleared 3' end partial");
1168 edit::CLocationEditPolicy::EPartialPolicy policy3 = edit::CLocationEditPolicy::ePartialPolicy_eNoChange;
1171 policy3 = edit::CLocationEditPolicy::ePartialPolicy_eClear;
1174 policy3 = edit::CLocationEditPolicy::ePartialPolicy_eClearNotAtEnd;
1177 policy3 = edit::CLocationEditPolicy::ePartialPolicy_eClearForGoodEnd;
1181 bool extend5 =
false, extend3 =
false;
1182 CRef<edit::CLocationEditPolicy> policy(
new edit::CLocationEditPolicy(edit::CLocationEditPolicy::ePartialPolicy_eNoChange, policy3, extend5, extend3));
1183 return policy->ApplyPolicyToFeature(feat, scope);
1191 for (
size_t i = 1;
i <
m_Args.size(); ++
i) {
1209 if (!x_CheckInitFeature())
1212 m_RetranslateCDS = (m_Args.size() > 2) ? m_Args[2]->GetBool() :
false;
1213 m_AdjustGene = (m_Args.size() == 4) ? m_Args[3]->GetBool() :
false;
1215 m_Modified = s_ConvertLocationStrand(*m_Seqfeat, *
m_Scope, m_Args[0]->GetString(), m_Args[1]->GetString());
1220 m_DataIter->SetModified();
1222 m_Seqfeat->GetLocation().GetLabel(&new_loc);
1224 log <<
"Converted location strand for " << m_DataIter->GetBestDescr() <<
" to " << new_loc;
1227 x_RetranslateCDS(
log);
1229 if (m_AdjustGene && !m_Seqfeat->GetData().IsGene()) {
1233 new_gene->
Assign(*overlap_gene);
1234 bool change_gene = s_ConvertLocationStrand(*new_gene, *
m_Scope, m_Args[0]->GetString(), m_Args[1]->GetString());
1240 cmd->AddCommand(*chgFeat);
1241 m_DataIter->RunCommand(
cmd, m_CmdComposite);
1242 log <<
" and adjusted gene location.";
1268 bool modified =
false;
1273 string from = str_from;
1294 if (start_any || strand_from == current_strand) {
1312 else if (strand_to != current_strand) {
1326 for (
size_t i = 2;
i <
m_Args.size(); ++
i) {
1342 if (!x_CheckInitFeature())
1345 m_RetranslateCDS = (m_Args.size() > 1) ? m_Args[1]->GetBool() :
false;
1346 m_AdjustGene = (m_Args.size() == 3) ? m_Args[2]->GetBool() :
false;
1348 m_Modified = s_ConvertLocationType(*m_Seqfeat, *
m_Scope, m_Args[0]->GetString());
1353 m_DataIter->SetModified();
1355 m_Seqfeat->GetLocation().GetLabel(&new_loc);
1357 log <<
"Converted location type for " << m_DataIter->GetBestDescr() <<
" to " << new_loc;
1360 x_RetranslateCDS(
log);
1362 if (m_AdjustGene && !m_Seqfeat->GetData().IsGene()) {
1366 new_gene->
Assign(*overlap_gene);
1367 bool change_gene = s_ConvertLocationType(*new_gene, *
m_Scope, m_Args[0]->GetString());
1373 cmd->AddCommand(*chgFeat);
1374 m_DataIter->RunCommand(
cmd, m_CmdComposite);
1375 log <<
" and adjusted gene location.";
1386 edit::CLocationEditPolicy::EMergePolicy merge_type = edit::CLocationEditPolicy::eMergePolicy_NoChange;
1389 merge_type = edit::CLocationEditPolicy::eMergePolicy_Join;
1392 merge_type = edit::CLocationEditPolicy::eMergePolicy_Order;
1395 merge_type = edit::CLocationEditPolicy::eMergePolicy_SingleInterval;
1402 policy->SetMergePolicy(merge_type);
1403 return policy->ApplyPolicyToFeature(feat, scope);
1411 for (
size_t i = 1;
i <
m_Args.size(); ++
i) {
1426 if (!x_CheckInitFeature())
1429 m_Modified = edit::CLocationEditPolicy::Extend5(*m_Seqfeat, *
m_Scope);
1431 m_RetranslateCDS = (m_Args.empty()) ?
false : m_Args[0]->GetBool();
1432 m_AdjustGene = (m_Args.size() == 2) ? m_Args[1]->GetBool() :
false;
1433 x_RetranslateCDSAdjustGene(
"Extended feature to 5' end");
1442 for (
auto& it :
m_Args) {
1458 if (!x_CheckInitFeature())
1461 m_Modified = edit::CLocationEditPolicy::Extend3(*m_Seqfeat, *
m_Scope);
1463 m_RetranslateCDS = (m_Args.empty()) ?
false : m_Args[0]->GetBool();
1464 m_AdjustGene = (m_Args.size() == 2) ? m_Args[1]->GetBool() :
false;
1465 x_RetranslateCDSAdjustGene(
"Extended feature to 3' end");
1474 for (
auto& it :
m_Args) {
1492 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
1497 ECdsFrame frame = s_GetFrameFromName(m_Args[0]->GetString());
1502 bool modified = s_SetCDSFrame(*cds, frame, *scope);
1505 m_DataIter->SetModified();
1511 if (!m_DataIter->HasBeenCompleted() && feat_iter) {
1512 feat_iter->SetCreateGeneralIdFlag();
1513 m_DataIter->SetCompleted();
1519 m_DataIter->RunCommand(upd_cmd, m_CmdComposite);
1523 log << m_DataIter->GetBestDescr() <<
": the " << m_Args[0]->GetString() <<
" frame was set";
1539 switch (frame_type) {
1550 bool modified =
false;
1551 if (orig_frame != new_frame) {
1552 cds.
SetData().SetCdregion().SetFrame(new_frame);
1575 string orig_prot_seq;
1585 tmp_cds->
SetData().SetCdregion().SetFrame(fr);
1587 string new_prot_seq;
1590 new_prot_seq.erase(new_prot_seq.end() - 1);
1634 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
1635 if (!from_feat || !const_feat || !scope) {
1639 const string& to_feat = m_Args[0]->GetString();
1652 x_SetConvertOptions(converter);
1654 bool keep_orig(
true);
1658 m_DataIter->RunCommand(convert_cmd, m_CmdComposite);
1660 log <<
"Converted " << m_DataIter->GetBestDescr() <<
" to " << to_feat;
1683 const string& opt_label = (*it)->GetLabel();
1685 (*it)->SetBool()->SetVal(
m_Args[index]->GetBool());
1689 (*it)->SetBool()->SetVal(
m_Args[index]->GetBool());
1693 (*it)->SetBool()->SetVal(
m_Args[index]->GetBool());
1701 const string& opt_label = (*it)->GetLabel();
1703 (*it)->SetString()->SetVal(
m_Args[1]->GetString());
1708 const string& opt_label = (*it)->GetLabel();
1710 (*it)->SetString()->SetVal(
m_Args[1]->GetString());
1715 const string& opt_label = (*it)->GetLabel();
1717 (*it)->SetString()->SetVal(
m_Args[1]->GetString());
1723 const string& opt_label = (*it)->GetLabel();
1725 (*it)->SetBool()->SetVal(
m_Args[1]->GetBool());
1743 for (
size_t index =
m_Args.size() - 1; index <
m_Args.size() - 3; --index) {
1757 void CMacroFunction_AddGeneXref::TheFunction()
1761 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
1771 m_DataIter->SetModified();
1774 log <<
"Added Gene xref to " << m_DataIter->GetBestDescr();
1778 bool CMacroFunction_AddGeneXref::x_ValidArguments()
const
1780 return (m_Args.empty());
1794 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
1795 if (!edit_feat || !edit_feat->
IsSetXref() || !scope) {
1800 const string& suppr_str = m_Args[0]->GetString();
1808 const string& necessary_str = m_Args[0]->GetString();
1815 bool removed(
false);
1816 CSeq_feat::TXref::iterator xref_it = edit_feat->
SetXref().begin();
1817 while (xref_it != edit_feat->
SetXref().end()) {
1818 if ((*xref_it)->IsSetData() && (*xref_it)->GetData().IsGene() &&
1819 s_GeneXrefMatchesSuppression((*xref_it)->GetData().GetGene(), suppr_type) &&
1820 s_GeneXrefMatchesNecessary((*xref_it)->GetData().GetGene(), *edit_feat, *scope, necessary_type)) {
1821 xref_it = edit_feat->
SetXref().erase(xref_it);
1834 m_DataIter->SetModified();
1836 log <<
"Removed Gene xref from " << m_DataIter->GetBestDescr();
1843 if (
m_Args.size() != 2) {
1855 switch (necessary_type) {
1872 switch (suppr_type) {
1901 if (strand1 == strand2) {
1903 return (start1 > start2);
1906 return (start1 < start2);
1910 return strand1 < strand2;
1913 return product1 < product2;
1932 void CMacroFunction_JoinShorttRNAs::TheFunction()
1936 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
1937 if (!bseq || !scope)
1940 vector<CConstRef<CSeq_feat> > tRNAFeats;
1943 const CSeq_feat& feature = *feat_it->GetOriginalSeq_feat();
1945 tRNAFeats.push_back(feat_it->GetOriginalSeq_feat());
1953 auto it = tRNAFeats.begin();
1954 auto modified =
false;
1955 while (it != tRNAFeats.end()) {
1960 vector<string> comments;
1966 rnaLoc->Add((*next)->GetLocation());
1967 if ((*next)->IsSetComment()) {
1968 comments.push_back((*next)->GetComment());
1977 cmd->AddCommand(*delGene);
1980 geneLoc->Add((*next)->GetLocation());
1986 cmd->AddCommand(*delNext);
1993 newtRNA->Assign(**it);
1995 rnaLoc->Add((*it)->GetLocation());
1997 newtRNA->SetLocation(*rnaLoc);
1999 if (!comments.empty()) {
2000 string origComment = (*it)->IsSetComment() ? (*it)->GetComment() :
kEmptyStr;
2002 if (origComment.empty()) {
2003 origComment = comments[0];
2006 for ( ; index < comments.size(); ++index) {
2009 if (!origComment.empty()) {
2010 newtRNA->SetComment(origComment);
2021 log <<
"Joined " << loc_ci.GetSize() <<
" short tRNAs with product name " << newtRNA->GetData().GetRna().GetRnaProductName();
2029 newGene->Assign(*gene);
2030 newGene->SetLocation(*geneLoc);
2035 newGene->GetLocation().GetLabel(&
label);
2036 log <<
"\n" <<
"Corresponding gene has been extended to " <<
label <<
"\n";
2045 m_DataIter->RunCommand(
cmd, m_CmdComposite);
2050 bool CMacroFunction_JoinShorttRNAs::x_ValidArguments()
const
2052 return (m_Args.empty());
2066 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
2085 auto it = find_if(
names.begin(),
names.end(), [](
const string&
str) { return (NStr::Find(str,
"seleno") != NPOS); });
2086 if (it ==
names.end()) {
2108 unsigned int replaced = 0;
2112 for (
size_t index = 0; index < prot_seq.size(); ++index) {
2113 if (prot_seq[index] ==
'*') {
2123 if (codon ==
"TGA") {
2125 code_break->
SetLoc(*nuc_loc);
2126 code_break->
SetAa().SetNcbieaa(
'U');
2127 cds_feat->
SetData().SetCdregion().SetCode_break().push_back(code_break);
2131 log <<
"Unable to add transl_except for stop codon at position " << index + 1;
2132 log <<
" in protein " << prot_label <<
" because codon is not TGA\n";
2142 if (!m_DataIter->HasBeenCompleted() && feat_iter) {
2143 feat_iter->SetCreateGeneralIdFlag();
2144 m_DataIter->SetCompleted();
2147 bool transl_change =
false;
2150 m_DataIter->RunCommand(retransl_cmd, m_CmdComposite);
2154 m_DataIter->SetModified();
2155 log <<
"Replaced " << replaced <<
" stops with selenocysteine.";
2172 prot_loc->
SetPnt(*prot_pnt);
2185 void CMacroFunction_RetranslateCDS::TheFunction()
2189 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
2197 bool obey_stop_codon = m_Args[0]->GetBool();
2202 if (!m_DataIter->HasBeenCompleted() && feat_iter) {
2203 feat_iter->SetCreateGeneralIdFlag();
2204 m_DataIter->SetCompleted();
2207 bool transl_change =
false;
2211 m_DataIter->RunCommand(retransl_cmd, m_CmdComposite);
2212 if (cds_change || transl_change) {
2213 m_DataIter->SetModified();
2215 log <<
"Retranslated " << m_DataIter->GetBestDescr();
2220 bool CMacroFunction_RetranslateCDS::x_ValidArguments()
const
2235 if (!bseq || !scope)
2244 if (index <
m_Args.size()) {
2246 if (
m_Args[index]->GetInt() < 1) {
2268 if (!x_SetCurrentBioseq())
2271 x_HandleNegativeCoordinates(0);
2272 x_HandleNegativeCoordinates(1);
2274 ENa_strand strand = x_GetStrand(m_Args.back()->GetString());
2280 if (to > m_Bsh.GetBioseqLength() - 1) {
2281 to = m_Bsh.GetBioseqLength() - 1;
2284 if (m_Args[2]->GetBool()) {
2287 if (m_Args[3]->GetBool()) {
2317 if (!x_SetCurrentBioseq())
2320 ENa_strand strand = x_GetStrand(m_Args.back()->GetString());
2322 if (m_Args[0]->GetBool()) {
2325 if (m_Args[1]->GetBool()) {
2353 if (!x_SetCurrentBioseq())
2356 x_HandleNegativeCoordinates(0);
2357 ENa_strand strand = x_GetStrand(m_Args.back()->GetString());
2359 if (point > m_Bsh.GetBioseqLength() - 1) {
2360 point = m_Bsh.GetBioseqLength() - 1;
2364 location->SetPnt().SetPoint(point);
2365 location->SetPnt().SetId().Assign(*m_Bsh.GetCompleteBioseq()->GetFirstId());
2366 location->SetPnt().SetStrand(strand);
2367 if (m_Args[1]->GetBool()) {
2370 if (m_Args[2]->GetBool()) {
2398 bool add_redundant =
m_Args[index]->GetBool();
2399 if (add_redundant) {
2412 if (location_obj.empty()) {
2416 if (
NStr::EqualCase(location_obj.front().field.GetName(),
"Seq-loc")) {
2436 size_t arg_size =
m_Args.size();
2437 while (index < arg_size) {
2438 const string field =
m_Args[index]->GetString();
2439 if (field ==
"qual.qual") {
2440 const string qualifier =
m_Args[++index]->GetString();
2444 m_NewFeat->SetQual().push_back(new_gbqual);
2453 if (index < arg_size) {
2478 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
2480 if (!bseq || !scope || bseq->
IsAa())
2484 m_NewFeat->SetData().SetCdregion();
2489 m_NewFeat->SetData().SetCdregion().SetCode(*
code);
2492 bool find_best_frame =
false;
2493 size_t fr_index = 2;
2497 find_best_frame =
true;
2504 switch (m_Args[fr_index]->GetInt()) {
2519 if (!x_SetLocation(3) || !x_ShouldAddRedundant(4))
2522 x_SetAdditionalFields(6);
2524 bool add_mRNA = m_Args[5]->GetBool();
2525 const string& protein_name = m_Args[0]->GetString();
2526 const string& protein_descr = m_Args[1]->GetString();
2535 new_mrna->
SetData().SetRna().SetExt().SetName(protein_name);
2539 if (m_Location->IsPnt()) {
2543 if (find_best_frame) {
2544 bool ambiguous =
false;
2548 m_NewFeat->SetData().SetCdregion().SetFrame(codon_start);
2556 if (!protein_name.empty()) {
2557 prot->SetData().SetProt().SetName().push_back(protein_name);
2559 if (!protein_descr.empty()) {
2560 prot->SetData().SetProt().SetDesc(protein_descr);
2569 cleanup.BasicCleanup(*m_NewFeat);
2573 m_DataIter->RunCommand(
cmd, m_CmdComposite);
2578 log <<
"Added CDS feature to " << best_id;
2588 bool good =
m_Args[0]->IsString()
2596 for (
size_t index = 6; index <
m_Args.size(); ++index) {
2597 if (!
m_Args[index]->IsString()) {
2615 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
2617 if (!bseq || !scope || bseq->
IsAa())
2627 const string& rna_name = m_Args[1]->GetString();
2632 m_NewFeat->SetData().SetRna().Assign(*rna_ref);
2634 if (!x_SetLocation(2) || !x_ShouldAddRedundant(3))
2637 x_SetAdditionalFields(4);
2639 cleanup.BasicCleanup(*m_NewFeat);
2645 m_DataIter->RunCommand(
cmd, m_CmdComposite);
2650 log <<
"Added " << m_Args[0]->GetString() <<
" feature to " << best_id;
2666 for (
size_t index = 4; index <
m_Args.size(); ++index) {
2688 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
2691 if (!bseq || !scope || bseq->
IsAa())
2695 if (!x_SetLocation(0))
2698 x_SetAdditionalFields(1);
2705 m_DataIter->RunCommand(
cmd, m_CmdComposite);
2709 log <<
"Added Gene feature to " << best_id;
2722 for (
size_t index = 1; index <
m_Args.size(); ++index) {
2745 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
2747 if (!bseq || !scope)
2751 CObjectInfo oi(m_NewFeat, m_NewFeat->GetTypeInfo());
2758 const string& new_str = m_Args[1]->
GetString();
2774 if (!SetQualStringValue(new_oi, new_str)) {
2785 if (!x_SetLocation(2) || !x_ShouldAddRedundant(3))
2788 x_SetAdditionalFields(4);
2795 m_DataIter->RunCommand(
cmd, m_CmdComposite);
2800 log <<
"Added feature to " << best_id;
2813 for (
size_t index = 4; index <
m_Args.size(); ++index) {
2829 void CMacroFunction_RestoreRNAEditing::TheFunction()
2833 CRef<CScope> scope = m_DataIter->GetScopedObject().scope;
2837 string prot_name = m_Args[0]->GetString();
2840 bool good_cds =
false;
2851 prot_vec.GetSeqData(0, prot_vec.size(), prot_seq);
2853 if (!prot_seq.empty() && prot_seq.front() !=
'M') {
2859 if (prot_name == *name_it) {
2876 m_DataIter->SetModified();
2883 new_inst->Assign(prot_bsh.
GetInst());
2884 new_inst->ResetSeq_data();
2887 new_inst->ResetExt();
2888 new_inst->SetRepr(objects::CSeq_inst::eRepr_raw);
2889 new_inst->SetSeq_data().SetNcbieaa().Set(prot_seq);
2890 new_inst->SetLength(
TSeqPos(prot_seq.length()));
2893 upd_cmd->AddCommand(*chgInst);
2896 m_DataIter->RunCommand(upd_cmd, m_CmdComposite);
2900 log << m_DataIter->GetBestDescr() <<
" restored RNA editing";
2904 bool CMacroFunction_RestoreRNAEditing::x_ValidArguments()
const
2906 return (m_Args.size() == 1 && m_Args[0]->IsString());
static CRef< CScope > m_Scope
User-defined methods of the data storage class.
User-defined methods of the data storage class.
@ eExtreme_Positional
numerical value
@ eExtreme_Biological
5' and 3'
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
bool TruncateCDSAtStop(CSeq_feat &cds, CScope &scope)
TruncateCDSAtStop A function to truncate a CDS location after the first stop codon in the protein tra...
bool IsGeneralIdProtPresent(objects::CSeq_entry_Handle tse)
CRef< CGenetic_code > GetGeneticCodeForBioseq(CBioseq_Handle bh)
GetGeneticCodeForBioseq A function to construct the appropriate CGenetic_code object to use when cons...
static bool s_IsBioseqGood_Strict(const objects::CBioseq_Handle &bsh)
const CSeq_id * GetFirstId() const
static bool IsGeneXrefUnnecessary(const CSeq_feat &sf, CScope &scope, const CGene_ref &gene_xref)
Calculates whether a Gene-xref is unnecessary (because it refers to the same gene as would be calcula...
static bool FixRNAEditingCodingRegion(CSeq_feat &cds)
From GB-7563 An action has been requested that will do the following: 1.
void AddCommand(IEditCommand &command)
static CRef< CConvertFeatureBase > Create(objects::CSeqFeatData::ESubtype subtype_from, objects::CSeqFeatData::ESubtype subtype_to)
static const string s_PlaceOnProt
static const string s_RemoveTranscriptID
static const string s_SiteType
virtual CRef< CCmdComposite > Convert(const objects::CSeq_feat &orig, bool keep_orig, objects::CScope &scope)
static const string s_BondType
virtual string GetDescription()
static const string s_NcrnaClass
static const string s_RemovemRNA
vector< CRef< CConversionOption > > TOptions
static const string s_RemoveGene
@Gb_qual.hpp User-defined methods of the data storage class.
bool IsSuppressed(void) const
Subclass of the IQueryParseUserObject which is held as the user-defined object in each CQueryParseNod...
CMacroBioData_FeatIterBase - iterates over any type of features.
class CMacroExecException
class CMacroExecException
static bool IsValidECNumberFormat(const string &ecno)
Verify correct form of EC number.
static const string & GetECNumberReplacement(const string &old_ecno)
Return a replaced EC number's replacement.
EECNumberStatus
Enzyme Commission number status.
@ eEC_replaced
Obsolete synonym for some other EC number.
@ eEC_ambiguous
Valid wildcard for a broader family.
@ eEC_specific
Specifically identifies a valid classification.
static EECNumberStatus GetECNumberStatus(const string &ecno)
Determine an EC number's validity and specificity.
@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
static E_Choice GetTypeFromSubtype(ESubtype subtype)
namespace ncbi::objects::
void SetGeneXref(CGene_ref &value)
Seq-loc iterator class – iterates all intervals from a seq-loc in the correct order.
static bool GetBestId(CSeq_id_Handle, CScope &, string &)
iterator_bool insert(const value_type &val)
CRef< objects::CSeq_entry > CreateTranslatedProteinSequence(CRef< objects::CSeq_feat > cds, objects::CBioseq_Handle nuc_h, bool create_general_only, int *offset=nullptr)
CRef< objects::CSeq_feat > AddProteinFeatureToProtein(CRef< objects::CSeq_entry > protein, bool partial5, bool partial3)
static const char location[]
static const string kConversionNotSupported
static void cleanup(void)
constexpr auto end(const ct_const_array< T, N > &in) noexcept
static const struct name_t names[]
static DLIST_TYPE *DLIST_NAME() next(DLIST_LIST_TYPE *list, DLIST_TYPE *item)
static auto & FindOrgNames
unsigned int TSeqPos
Type for sequence locations and lengths.
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
#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.
#define NCBI_RETHROW2(prev_exception, exception_class, err_code, message, extra)
Re-throw exception with extra parameter.
@ eUnknown
Unknown exception.
void x_FixProteinNames(objects::CProt_ref &prot, const vector< string > &taxnames)
static bool s_Set5EndPartial(objects::CSeq_feat &feat, objects::CScope &scope, const string &descr, bool extend5=false)
CRef< objects::CScope > m_Scope
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
void x_SetConvertOptions(CRef< CConvertFeatureBase > converter)
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
static bool s_Clear5EndPartial(objects::CSeq_feat &feat, objects::CScope &scope, const string &descr)
static ECdsFrame s_GetFrameFromName(const string &name)
static bool s_ShouldBeMerged(const CSeq_feat &feat1, const CSeq_feat &feat2)
objects::CSeqFeatData::ESubtype GetFeatSubtype(const string &feat_type)
CRef< CMacroCmdComposite > m_CmdComposite
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
static bool s_ConvertLocationType(objects::CSeq_feat &feat, objects::CScope &scope, const string &descr)
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
CConstRef< objects::CSeq_feat > m_Origfeat
list< SResolvedField > TObs
void x_RetranslateCDS(CNcbiOstrstream &log)
static string s_FixProteinNameFormat(const string &protein, const vector< string > &taxnames)
void Dereference()
If it is a reference it is resolved to the first non reference type in the hierarchy.
static bool s_GeneXrefMatchesSuppression(const objects::CGene_ref &gene, objects::EGene_xref_suppression_type suppr_type)
bool ResolveIdentToObjects(const CObjectInfo &oi, const string &identifier, CMQueryNodeValue &v)
Resolve name to the list of objects.
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.
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
bool x_SetCurrentBioseq()
class CMacroFunction_MakeLocation Generates different type of seq-loc objects
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
CRef< objects::CSeq_feat > m_Seqfeat
const string & GetString() const
EType GetDataType() const
void GetPrimitiveObjectInfos(CMQueryNodeValue::TObs &objs, const CMQueryNodeValue::SResolvedField &info)
objects::CRNA_ref::EType GetRNAType(const string &rna_type)
bool x_ShouldAddRedundant(size_t index)
class CMacroFunction_ApplyFeature Generates different types of apply feature commands
objects::CBioseq_Handle m_Bsh
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
static objects::ENa_strand s_GetStrandFromString(const string &str)
void x_RetranslateCDSAdjustGene(const string &descr)
bool x_SetLocation(size_t index)
vector< string > m_NewNames
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
static bool s_GeneXrefMatchesNecessary(const objects::CGene_ref &gene, const objects::CSeq_feat &feat, objects::CScope &scope, objects::EGene_xref_necessary_type necessary_type)
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...
static bool s_SetBothEndsPartial(objects::CSeq_feat &feat, objects::CScope &scope, const string &descr, bool extend=false)
void x_GetObjectsFromRef(CMQueryNodeValue::TObs &objects, const size_t &index)
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
bool GetLocusTagFromProtRef(const objects::CSeq_feat &prot_feat, objects::CScope &scope, string &locus_tag)
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
static bool s_SortShorttRNAs(const CConstRef< CSeq_feat > &feat1, const CConstRef< CSeq_feat > &feat2)
class CMacroFunction_JoinShorttRNAs JoinShorttRNAs() - joins short (< 50bp) tRNAs and extends the cor...
objects::ENa_strand x_GetStrand(const string &str)
CRef< objects::CSeq_loc > m_Location
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
static bool s_Clear3EndPartial(objects::CSeq_feat &feat, objects::CScope &scope, const string &descr)
DEFINE_MACRO_FUNCNAME(CMacroFunction_TrimStopFromCompleteCDS, "TrimStopsFromCompleteCDS")
class CMacroFunction_TrimStopFromCompleteCDS TrimStopsFromCompleteCDS()
CRef< objects::CSeq_feat > m_NewFeat
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
static bool s_RemoveBothPartials(objects::CSeq_feat &feat, objects::CScope &scope, const string &descr)
void x_LogFunction(CNcbiOstrstream &logstr)
CRef< objects::CSeq_loc > x_GetProteinLoc(const objects::CSeq_id &prot_id, TSeqPos pos) const
bool x_CheckInitFeature()
static bool s_Set3EndPartial(objects::CSeq_feat &feat, objects::CScope &scope, const string &descr, bool extend3=false)
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
void x_SetAdditionalFields(size_t index)
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
vector< string > m_OrigNames
static bool s_ConvertLocationStrand(objects::CSeq_feat &feat, objects::CScope &scope, const string &str_from, const string &str_to)
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
static objects::CCdregion::TFrame s_FindMatchingFrame(const objects::CSeq_feat &cds, objects::CScope &scope)
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
CIRef< IMacroBioDataIter > m_DataIter
static bool s_SetCDSFrame(objects::CSeq_feat &cds, ECdsFrame frame_type, objects::CScope &scope)
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
void x_HandleNegativeCoordinates(size_t index)
objects::CBioseq_Handle m_Bsh
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
virtual bool x_ValidArguments() const
Tests the number and the type of function arguments.
objects::CBioseq_Handle GetBioseqForSeqFeat(const objects::CSeq_feat &f, objects::CScope &scope)
C & SerialAssign(C &dest, const C &src, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
#define ENUM_METHOD_NAME(EnumName)
static const TObjectType * SafeCast(TTypeInfo type)
void GetLabel(string *label, ELabelType type=eDefault, TLabelFlags flags=fLabel_Default) const
Append a label for this Seq-id to the supplied string.
CConstRef< CSeq_id > GetSeqId(void) const
static CSeq_id_Handle GetHandle(const CSeq_id &id)
Normal way of getting a handle, works for any seq-id.
bool IsPartialStart(ESeqLocExtremes ext) const
check start or stop of location for e_Lim fuzz
ENa_strand GetStrand(void) const
Get the location's strand.
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Override Assign() to incorporate cache invalidation.
TSeqPos GetStart(ESeqLocExtremes ext) const
Return start and stop positions of the seq-loc.
bool IsSetStrand(EIsSetStrand flag=eIsSetStrand_Any) const
Check if strand is set for any/all part(s) of the seq-loc depending on the flag.
const CSeq_id * GetId(void) const
Get the id of the location return NULL if has multiple ids or no id at all.
void GetLabel(string *label) const
Appends a label suitable for display (e.g., error messages) label must point to an existing string ob...
bool IsPartialStop(ESeqLocExtremes ext) const
TSeqPos GetStop(ESeqLocExtremes ext) const
TObjectPtr GetObjectPtr(void) const
Get pointer to object.
CObjectInfo AddNewElement(void) const
Add and return new element object.
ETypeFamily GetTypeFamily(void) const
Get data type family.
bool AdjustFeaturePartialFlagForLocation(CSeq_feat &new_feat)
AdjustFeaturePartialFlagForLocation A function to ensure that Seq-feat.partial is set if either end o...
TSeqPos GetLength(const CSeq_id &id, CScope *scope)
Get sequence length if scope not null, else return max possible TSeqPos.
void ChangeSeqLocId(CSeq_loc *loc, bool best, CScope *scope)
Change each of the CSeq_ids embedded in a CSeq_loc to the best or worst CSeq_id accoring to the value...
CRef< CSeq_loc > Seq_loc_Merge(const CSeq_loc &loc, CSeq_loc::TOpFlags flags, CScope *scope)
Merge ranges in the seq-loc.
CSeq_loc * SeqLocRevCmpl(const CSeq_loc &loc, CScope *scope)
Get reverse complement of the seq-loc (?)
const CSeq_feat * GetCDSForProduct(const CBioseq &product, CScope *scope)
Get the encoding CDS feature of a given protein sequence.
bool IsPseudo(const CSeq_feat &feat, CScope &scope)
Determines whether given feature is pseudo, using gene associated with feature if necessary Checks to...
CConstRef< CSeq_feat > GetOverlappingGene(const CSeq_loc &loc, CScope &scope, ETransSplicing eTransSplicing=eTransSplicing_Auto)
CConstRef< CSeq_feat > GetGeneForFeature(const CSeq_feat &feat, CScope &scope)
Finds gene for feature, but obeys SeqFeatXref directives.
static CCdregion::EFrame FindBestFrame(const CSeq_feat &cds, CScope &scope)
Find "best" frame for a coding region.
CConstRef< CSeq_feat > GetmRNAforCDS(const CSeq_feat &cds, CScope &scope)
GetmRNAforCDS A function to find a CSeq_feat representing the appropriate mRNA for a given CDS.
static void Translate(const string &seq, string &prot, const CGenetic_code *code, bool include_stop=true, bool remove_trailing_X=false, bool *alt_start=NULL, bool is_5prime_complete=true, bool is_3prime_complete=true)
Translate a string using a specified genetic code.
CRef< CSeq_loc > Map(const CSeq_loc &src_loc)
Map seq-loc.
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)
@ eProductToLocation
Map from the feature's product to location.
CConstRef< CBioseq > GetCompleteBioseq(void) const
Get the complete bioseq.
CSeq_id_Handle GetAccessSeq_id_Handle(void) const
Get any CSeq_id_Handle handle that can be used to access this bioseq Use GetSeq_id_Handle() if it's n...
const CSeqFeatData & GetData(void) const
bool IsProtein(void) const
bool IsSetData(void) const
CSeqVector GetSeqVector(EVectorCoding coding, ENa_strand strand=eNa_strand_plus) const
Get sequence: Iupacna or Iupacaa if use_iupac_coding is true.
const TInst & GetInst(void) const
@ eCoding_Ncbi
Set coding to binary coding (Ncbi4na or Ncbistdaa)
@ eCoding_Iupac
Set coding to printable coding (Iupacna or Iupacaa)
const CSeq_feat_Handle & GetSeq_feat_Handle(void) const
Get original feature handle.
void GetSeqData(TSeqPos start, TSeqPos stop, string &buffer) const
Fill the buffer string with the sequence data for the interval [start, stop).
void SetCoding(TCoding coding)
void SetIupacCoding(void)
Set coding to either Iupacaa or Iupacna depending on molecule type.
TObjectType * GetPointer(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.
bool IsNull(void) const THROWS_NONE
Check if pointer is null – same effect as Empty().
#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.
bool IsOssEmpty(CNcbiOstrstream &oss)
NCBI_NS_STD::string::size_type SIZE_TYPE
static string Int8ToString(Int8 value, TNumToStringFlags flags=0, int base=10)
Convert Int8 to string.
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 void TruncateSpacesInPlace(string &str, ETrunc where=eTrunc_Both)
Truncate spaces in a string (in-place)
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 bool EqualNocase(const CTempString s1, SIZE_TYPE pos, SIZE_TYPE n, const char *s2)
Case-insensitive equality of a substring with another 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 & ToLower(string &str)
Convert string to lower case – string& version.
static const char label[]
EPartial_both_clear_constraint
Access to EPartial_both_clear_constraint's attributes (values, names) as defined in spec.
EPartial_3_clear_constraint
Access to EPartial_3_clear_constraint's attributes (values, names) as defined in spec.
EPartial_3_set_constraint
Access to EPartial_3_set_constraint's attributes (values, names) as defined in spec.
EPartial_both_set_constraint
Access to EPartial_both_set_constraint's attributes (values, names) as defined in spec.
EGene_xref_suppression_type
Access to EGene_xref_suppression_type's attributes (values, names) as defined in spec.
EGene_xref_necessary_type
Access to EGene_xref_necessary_type's attributes (values, names) as defined in spec.
EFeature_location_strand_from
Access to EFeature_location_strand_from's attributes (values, names) as defined in spec.
EPartial_5_clear_constraint
Access to EPartial_5_clear_constraint's attributes (values, names) as defined in spec.
EPartial_5_set_constraint
Access to EPartial_5_set_constraint's attributes (values, names) as defined in spec.
EFeature_location_strand_to
Access to EFeature_location_strand_to's attributes (values, names) as defined in spec.
@ ePartial_both_clear_constraint_all
@ ePartial_3_clear_constraint_good_end
@ ePartial_3_clear_constraint_not_at_end
@ ePartial_3_clear_constraint_all
@ ePartial_3_set_constraint_all
@ ePartial_3_set_constraint_bad_end
@ ePartial_3_set_constraint_at_end
@ ePartial_both_set_constraint_all
@ eGene_xref_suppression_type_non_suppressing
@ eGene_xref_suppression_type_any
@ eGene_xref_suppression_type_suppressing
@ eGene_xref_necessary_type_any
@ eGene_xref_necessary_type_unnecessary
@ eGene_xref_necessary_type_necessary
@ ePartial_5_clear_constraint_all
@ ePartial_5_clear_constraint_not_at_end
@ ePartial_5_clear_constraint_good_start
@ ePartial_5_set_constraint_bad_start
@ ePartial_5_set_constraint_frame_not_one
@ ePartial_5_set_constraint_at_end
@ ePartial_5_set_constraint_all
const TName & GetName(void) const
Get the Name member data.
bool IsSetName(void) const
protein name Check if a value has been assigned to Name data member.
TType GetType(void) const
Get the Type member data.
void SetType(TType value)
Assign a value to Type data member.
void SetAa(TAa &value)
Assign a value to Aa data member.
TXref & SetXref(void)
Assign a value to Xref data member.
bool IsSetData(void) const
the specific data Check if a value has been assigned to Data data member.
bool IsProt(void) const
Check if variant Prot is selected.
void SetLocation(TLocation &value)
Assign a value to Location data member.
bool IsCdregion(void) const
Check if variant Cdregion is selected.
void SetPartial(TPartial value)
Assign a value to Partial 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.
TFrame GetFrame(void) const
Get the Frame member data.
const TData & GetData(void) const
Get the Data member data.
void SetData(TData &value)
Assign a value to Data data member.
const TCdregion & GetCdregion(void) const
Get the variant data.
void SetLoc(TLoc &value)
Assign a value to Loc data member.
const TProduct & GetProduct(void) const
Get the Product member data.
const TGene & GetGene(void) const
Get the variant data.
const TProt & GetProt(void) const
Get the variant data.
const TXref & GetXref(void) const
Get the Xref member data.
void ResetXref(void)
Reset Xref data member.
const TRna & GetRna(void) const
Get the variant data.
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 IsSetFrame(void) const
Check if a value has been assigned to Frame data member.
bool IsSetLocation(void) const
feature made from Check if a value has been assigned to Location data member.
@ eFrame_not_set
not set, code uses one
@ eFrame_three
reading frame
ENa_strand
strand of nucleic acid
@ eNa_strand_both
in forward orientation
@ e_not_set
No variant selected.
@ e_Ncbieaa
extended ASCII 1 letter aa codes
unsigned int
A callback function used to compare two keys in a database.
Functions that resolve field names described in asn format.
constexpr auto sort(_Init &&init)
Utility macros and typedefs for exploring NCBI objects from seqfeat.asn.
#define FOR_EACH_NAME_ON_PROTREF(Itr, Var)
FOR_EACH_NAME_ON_PROTREF EDIT_EACH_NAME_ON_PROTREF.
static const char * str(char *buf, int n)
@ eExistingText_append_semi
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...
CRef< CCmdChangeSeq_feat > AdjustGene(const objects::CSeq_feat &orig_feat, const objects::CSeq_feat &new_feat, objects::CScope &scope)
CRef< CCmdComposite > GetSynchronizeProteinPartialsCommand(objects::CScope &scope, const objects::CSeq_feat &cds)
CRef< CCmdComposite > GetRetranslateCDSCommand(objects::CScope &scope, const objects::CSeq_feat &cds, bool create_general_only)
void GetProductToCDSMap(objects::CScope &scope, map< objects::CBioseq_Handle, set< objects::CSeq_feat_Handle > > &product_to_cds)
CRef< CCmdComposite > TrimStopsFromCompleteCDS(const objects::CSeq_feat &cds, objects::CScope &scope)
CRef< CCmdComposite > GetDeleteAllFeaturesCommand(objects::CSeq_entry_Handle seh, size_t &count, bool remove_proteins=true)
CRef< CCmdComposite > GetDeleteFeatureCommand(const objects::CSeq_feat_Handle &fh, bool remove_proteins=true)