NCBI C++ ToolKit
autodef_functions.cpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: autodef_functions.cpp 47302 2023-01-09 19:12:19Z asztalos $
2  * ===========================================================================
3  *
4  * PUBLIC DOMAIN NOTICE
5  * National Center for Biotechnology Information
6  *
7  * This software/database is a "United States Government Work" under the
8  * terms of the United States Copyright Act. It was written as part of
9  * the author's official duties as a United States Government employee and
10  * thus cannot be copyrighted. This software/database is freely available
11  * to the public for use. The National Library of Medicine and the U.S.
12  * Government have not placed any restriction on its use or reproduction.
13  *
14  * Although all reasonable efforts have been taken to ensure the accuracy
15  * and reliability of the software and data, the NLM and the U.S.
16  * Government do not and cannot warrant the performance or results that
17  * may be obtained by using this software or data. The NLM and the U.S.
18  * Government disclaim all warranties, express or implied, including
19  * warranties of performance, merchantability or fitness for any particular
20  * purpose.
21  *
22  * Please cite the author in any work or product based on this material.
23  *
24  * ===========================================================================
25  *
26  * Authors: Colleen Bollin, Andrea Asztalos
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
34 #include <objmgr/bioseq_ci.hpp>
35 #include <objmgr/seqdesc_ci.hpp>
37 
44 
46 #include <objmgr/seq_entry_ci.hpp>
47 
50 
52 {
53  CAutoDef autodef;
54  autodef.AddSources(seh);
56  src_combo->GetAvailableModifiers(params.m_ModifierList);
57  /* set requested */
58  for (size_t n = 0; n < params.m_ModifierList.size(); n++) {
59  if (params.m_ModifierList[n].AnyPresent()) {
60  if (params.m_ModifierList[n].IsOrgMod()) {
61  if (src_combo->HasOrgMod(params.m_ModifierList[n].GetOrgModType())) {
62  params.m_ModifierList[n].SetRequested(true);
63  }
64  }
65  else if (src_combo->HasSubSource(params.m_ModifierList[n].GetSubSourceType())) {
66  params.m_ModifierList[n].SetRequested(true);
67  }
68  }
69  }
70  params.m_NeedHIVRule = src_combo->HasTrickyHIV();
71  params.m_UseLabels = true;
72 }
73 
75 {
76  macro::CMacroFunction_AutodefId::s_ConfigureAutodefOptionsForID(params.m_ModifierList, seh);
77  params.m_UseLabels = true;
78 }
79 
81 {
82  unsigned int found_modifier = 0;
83  CAutoDef autodef;
84  autodef.AddSources(seh);
86  src_combo->GetAvailableModifiers(params.m_ModifierList);
87 
88  for (size_t n = 0; n < params.m_ModifierList.size(); n++)
89  if (params.m_ModifierList[n].AnyPresent() && !NStr::IsBlank(params.m_ModifierList[n].Label())){
90  params.m_ModifierList[n].SetRequested(true);
91  found_modifier++;
92  }
93  return found_modifier;
94 }
95 
97 {
98  autodef.AddSources(entry);
99  CAutoDefModifierCombo *mod_combo = autodef.GetEmptyCombo();
100 
101  if (params) {
102  for (size_t n = 0; n < params->m_ModifierList.size(); n++) {
103  if (params->m_ModifierList[n].IsRequested()) {
104  if (params->m_ModifierList[n].IsOrgMod()) {
105  mod_combo->AddOrgMod(params->m_ModifierList[n].GetOrgModType(), true);
106  }
107  else {
108  mod_combo->AddSubsource(params->m_ModifierList[n].GetSubSourceType(), true);
109  }
110  }
111  }
112  mod_combo->SetExcludeSpOrgs(params->m_DoNotApplyToSp);
113  mod_combo->SetExcludeNrOrgs(params->m_DoNotApplyToNr);
114  mod_combo->SetExcludeCfOrgs(params->m_DoNotApplyToCf);
115  mod_combo->SetExcludeAffOrgs(params->m_DoNotApplyToAff);
116  mod_combo->SetMaxModifiers(params->m_MaxMods);
117  mod_combo->SetUseModifierLabels(params->m_UseLabels);
118  mod_combo->SetKeepParen(params->m_LeaveParenthetical);
119  mod_combo->SetKeepCountryText(params->m_IncludeCountryText);
120  mod_combo->SetKeepAfterSemicolon(params->m_KeepAfterSemicolon);
121 
122  if (params->m_NeedHIVRule) {
124  }
125 
130  }
131  else if (params->m_NuclearCopyFlag != CBioSource::eGenome_unknown) {
133  }
134 
136  autodef.SetAltSpliceFlag(params->m_AltSpliceFlag);
137  autodef.SetUseNcRNAComment(params->m_UseNcRNAComment);
138  autodef.SetSuppressLocusTags(params->m_SuppressLocusTags);
144  autodef.SetKeepExons(params->m_KeepExons);
145  autodef.SetKeepIntrons(params->m_KeepIntrons);
147  autodef.SetUseFakePromoters(params->m_UseFakePromoters);
148  autodef.SetKeepLTRs(params->m_KeepLTRs);
149  autodef.SetKeep3UTRs(params->m_Keep3UTRs);
150  autodef.SetKeep5UTRs(params->m_Keep5UTRs);
151  autodef.SetKeepMiscRecomb(params->m_KeepMiscRecomb);
152  autodef.SetKeepRepeatRegion(params->m_KeepRepeatRegion);
153 
154  // suppress features
156  autodef.SuppressFeature(*it);
157  }
158 
159  // custom phrase
161  }
162  return mod_combo;
163 }
164 
166 {
167  CAutoDefWithTaxonomy autodef;
168  CAutoDefModifierCombo* mod_combo = ConfigureAutodefForSeqEntry(autodef, entry, params);
169 
170  CRef<CCmdComposite> cmd(new CCmdComposite("Autodef"));
171  if (!docsum_only) {
172  macro::CMacroFunction_Autodef::s_AutodefBioseqsNoTitle(entry, autodef, mod_combo, cmd);
173  }
174  delete mod_combo;
175 
176  macro::CMacroFunction_Autodef::s_AutodefSetsNoTitle(entry, autodef, cmd);
177  return cmd;
178 }
179 
181 {
182  CRef<CCmdComposite> cmd(new CCmdComposite("Autodef"));
183 
184  CAutoDefWithTaxonomy autodef;
185  CAutoDefModifierCombo* mod_combo = ConfigureAutodefForSeqEntry(autodef, entry, params);
186 
187  autodef.SetOptions(*mod_combo);
188 
189  CSeqdesc_CI desc(target, CSeqdesc::e_Title);
190  while (desc) {
191  CRef<CCmdDelDesc> delcmd(new CCmdDelDesc(desc.GetSeq_entry_Handle(), *desc));
192  cmd->AddCommand(*delcmd);
193  ++desc;
194  }
195 
196  macro::CMacroFunction_Autodef::s_AddAutodefOptions(autodef, target, cmd);
197 
198  delete mod_combo;
199  return cmd;
200 }
201 
203 {
204  CRef<CCmdComposite> cmd(new CCmdComposite("InstantiateProteinTitles"));
205  bool any = false;
206 
207  sequence::CDeflineGenerator gen;
208  for (CBioseq_CI b_iter(entry, CSeq_inst::eMol_aa); b_iter; ++b_iter) {
209  string defline = gen.GenerateDefline(*b_iter,
210  sequence::CDeflineGenerator::fIgnoreExisting |
211  sequence::CDeflineGenerator::fAllProteinNames);
212 
213  CRef<CSeqdesc> new_desc(new CSeqdesc());
214  new_desc->SetTitle(defline);
215  CSeqdesc_CI desc(*b_iter, CSeqdesc::e_Title);
216  if (desc) {
217  CRef<CCmdChangeSeqdesc> ecmd(new CCmdChangeSeqdesc(desc.GetSeq_entry_Handle(), *desc, *new_desc));
218  cmd->AddCommand(*ecmd);
219  }
220  else {
221  cmd->AddCommand(*CRef<CCmdCreateDesc>(new CCmdCreateDesc((*b_iter).GetSeq_entry_Handle(), *new_desc)));
222  }
223  any = true;
224  }
225 
226  if (!any) {
227  cmd.Reset(NULL);
228  }
229  return cmd;
230 }
231 
CRef< CCmdComposite > InstantiateProteinTitles(CSeq_entry_Handle entry)
USING_SCOPE(objects)
CAutoDefModifierCombo * ConfigureAutodefForSeqEntry(CAutoDef &autodef, CSeq_entry_Handle entry, SAutodefParams *params)
unsigned int ConfigureParamsForPrefixCombo(SAutodefParams &params, CSeq_entry_Handle seh)
void ConfigureAutodefParamsForID(SAutodefParams &params, CSeq_entry_Handle seh)
CRef< CCmdComposite > AutodefSeqEntryNoTitle(CSeq_entry_Handle entry, SAutodefParams *params, bool docsum_only)
void ConfigureAutodefParamsForBestCombo(SAutodefParams &params, CSeq_entry_Handle seh)
void SetExcludeCfOrgs(bool exclude)
void SetHIVCloneIsolateRule(CAutoDefOptions::EHIVCloneIsolateRule rule_num)
void SetKeepAfterSemicolon(bool keep)
void SetExcludeNrOrgs(bool exclude)
void AddOrgMod(COrgMod::ESubtype st, bool even_if_not_uniquifying=false)
void AddSubsource(CSubSource::ESubtype st, bool even_if_not_uniquifying=false)
void SetMaxModifiers(int max_mods)
void SetUseModifierLabels(bool use)
void SetExcludeSpOrgs(bool exclude)
void SetExcludeAffOrgs(bool exclude)
void SetKeepParen(bool keep)
void SetKeepCountryText(bool keep)
void SetKeepIntrons(bool keep)
Definition: autodef.hpp:262
void SetUseFakePromoters(bool use_fake)
Definition: autodef.hpp:334
void SuppressMiscFeatSubfeatures(bool suppress)
Definition: autodef.hpp:248
void SetKeepLTRs(bool keep)
Definition: autodef.hpp:275
void SetSpecifyNuclearProduct(bool specify_nuclear_product)
Definition: autodef.hpp:206
void SetKeep5UTRs(bool keep)
Definition: autodef.hpp:289
void SetKeepExons(bool keep)
Definition: autodef.hpp:255
void SetSuppressLocusTags(bool suppress_locus_tags)
Definition: autodef.hpp:220
void SetKeepRegulatoryFeatures(bool keep)
Definition: autodef.hpp:269
void SetKeepMiscRecomb(bool keep)
Definition: autodef.hpp:321
void SetProductFlag(CBioSource::EGenome product_flag)
Definition: autodef.hpp:192
void SetCustomFeatureClause(const string &custom_feature_clause)
Definition: autodef.hpp:341
void SetKeepRepeatRegion(bool keep)
Definition: autodef.hpp:315
void SetSuppressFeatureAltSplice(bool suppress_alt_splice)
Definition: autodef.hpp:234
void AddSources(CSeq_entry_Handle se)
Definition: autodef.cpp:93
void SetGeneClusterOppStrand(bool gene_opp_strand)
Definition: autodef.hpp:227
void SetKeep3UTRs(bool keep)
Definition: autodef.hpp:282
void SetNuclearCopyFlag(CBioSource::EGenome product_flag)
Definition: autodef.hpp:199
void SetOptions(const CAutoDefModifierCombo &mod_combo)
Definition: autodef.cpp:1201
void SetFeatureListType(CAutoDefOptions::EFeatureListType feature_list_type)
Definition: autodef.hpp:178
CRef< CAutoDefModifierCombo > FindBestModifierCombo()
Definition: autodef.cpp:210
void SetMiscFeatRule(CAutoDefOptions::EMiscFeatRule misc_feat_rule)
Definition: autodef.hpp:185
void SetUseNcRNAComment(bool use_comment)
Definition: autodef.hpp:327
void SuppressFeature(const objects::CFeatListItem &feat)
Definition: autodef.cpp:408
void SetAltSpliceFlag(bool alt_splice_flag)
Definition: autodef.hpp:213
void SuppressMobileElementAndInsertionSequenceSubfeatures(bool suppress)
Definition: autodef.hpp:241
CAutoDefModifierCombo * GetEmptyCombo()
Definition: autodef.cpp:296
CBioseq_CI –.
Definition: bioseq_ci.hpp:69
CBioseq_Handle –.
CRef –.
Definition: ncbiobj.hpp:618
CSeq_entry_Handle –.
CSeqdesc_CI –.
Definition: seqdesc_ci.hpp:65
bool m_SuppressMiscFeatSubfeatures
set< objects::CFeatListItem > m_SuppressedFeatures
bool m_SuppressMobileElementSubfeatures
unsigned int m_MiscFeatRule
objects::CAutoDefSourceDescription::TAvailableModifierVector m_ModifierList
bool m_KeepRegulatoryFeatures
bool m_SuppressFeatureAltSplice
unsigned int m_ProductFlag
unsigned int m_NuclearCopyFlag
unsigned int m_FeatureListType
string m_CustomFeatureClause
bool m_SpecifyNuclearProduct
unsigned int m_HIVRule
unsigned int m_MaxMods
API (CDeflineGenerator) for computing sequences' titles ("definitions").
static CS_COMMAND * cmd
Definition: ct_dynamic.c:26
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NULL
Definition: ncbistd.hpp:225
CSeq_entry_Handle GetSeq_entry_Handle(void) const
Definition: seqdesc_ci.cpp:326
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
static bool IsBlank(const CTempString str, SIZE_TYPE pos=0)
Check if a string is blank (has no text).
Definition: ncbistr.cpp:106
EGenome
biological context
Definition: BioSource_.hpp:97
TTitle & SetTitle(void)
Select the variant.
Definition: Seqdesc_.hpp:1039
@ e_Title
a title for this sequence
Definition: Seqdesc_.hpp:115
yy_size_t n
Functions used in the DO/DONE section affecting the top seq-entry.
The Object manager core.
Modified on Wed Sep 04 15:03:23 2024 by modify_doxy.py rev. 669887