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

Go to the SVN repository for this file.

1 /* $Id: autodef_with_tax.cpp 99480 2023-04-04 12:08:46Z stakhovv $
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 * Author: Colleen Bollin
27 *
28 * File Description:
29 * Extends CAutoDef to create docsum titles (which require a call to taxonomy)
30 */
31 
32 #include <ncbi_pch.hpp>
34 #include <objmgr/bioseq_ci.hpp>
35 #include <objmgr/seqdesc_ci.hpp>
42 
45 
46 
48 {
51  while (b && !options) {
54  ++desc;
55  }
56  if (desc) {
57  options.Reset(&(desc->GetUser()));
58  }
59  }
60  return options;
61 }
62 
64 {
65  bool any = false;
66  // update the title of the set
68  if (si->IsSet() && si->GetSet().GetCompleteBioseq_set()->NeedsDocsumTitle()) {
69  CAutoDefWithTaxonomy autodef;
70  CConstRef<CUser_object> options = GetOptionsForSet(si->GetSet());
71  if (options) {
72  autodef.SetOptionsObject(*options);
73  }
74  autodef.AddSources(se);
75  string defline = autodef.GetDocsumDefLine(*si);
76 
77  bool found_existing = false;
78  CBioseq_set_EditHandle bsseh(si->GetSet());
80  if ((*it)->IsTitle()) {
81  if (!NStr::Equal((*it)->GetTitle(), defline)) {
82  (*it)->SetTitle(defline);
83  any = true;
84  }
85  found_existing = true;
86  break;
87  }
88  }
89  if (!found_existing) {
90  CRef<CSeqdesc> new_desc(new CSeqdesc());
91  new_desc->SetTitle(defline);
92  bsseh.SetDescr().Set().push_back(new_desc);
93  any = true;
94  }
95  }
96  }
97  return any;
98 }
99 
100 
102 {
103  bool any = RegenerateSequenceDefLines(se);
104 
105  any |= RegeneratePopsetTitles(se);
106  return any;
107 }
108 
109 
111 {
112  string joined_org = "Mixed organisms";
113 
114  CRef<CT3Request> rq(new CT3Request());
116  while (bi) {
117  CSeqdesc_CI desc_ci(*bi, CSeqdesc::e_Source);
118  if (desc_ci && desc_ci->GetSource().IsSetOrg()) {
119  TTaxId taxid = desc_ci->GetSource().GetOrg().GetTaxId();
120  if (taxid > ZERO_TAX_ID) {
121  rq->SetJoin().Set().push_back(TAX_ID_TO(int, taxid));
122  }
123  }
124  ++bi;
125  }
126  if (rq->IsJoin() && rq->GetJoin().Get().size() > 0) {
127  CTaxon3_request request;
128  request.SetRequest().push_back(rq);
130  CRef<CTaxon3_reply> reply = taxon3.SendRequest(request);
131  if (reply) {
132  CTaxon3_reply::TReply::const_iterator reply_it = reply->GetReply().begin();
133  while (reply_it != reply->GetReply().end()) {
134  if ((*reply_it)->IsData()
135  && (*reply_it)->GetData().GetOrg().IsSetTaxname()) {
136  joined_org = (*reply_it)->GetData().GetOrg().GetTaxname();
137  break;
138  }
139  ++reply_it;
140  }
141  }
142  }
143 
144  return joined_org;
145 }
146 
147 
149 {
150  string org_desc = GetDocsumOrgDescription(se);
151 
152  string feature_clauses;
154  if (bi) {
157  if (di && di->GetSource().IsSetGenome()) {
158  genome_val = di->GetSource().GetGenome();
159  }
160  feature_clauses = GetOneFeatureClauseList(*bi, genome_val);
161  }
162 
163  return org_desc + feature_clauses;
164 }
165 
166 
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.
CConstRef< CUser_object > GetOptionsForSet(CBioseq_set_Handle set)
static bool RegeneratePopsetTitles(CSeq_entry_Handle se)
string GetDocsumDefLine(CSeq_entry_Handle se)
static string GetDocsumOrgDescription(CSeq_entry_Handle se)
static bool RegenerateDefLines(CSeq_entry_Handle se)
void SetOptionsObject(const CUser_object &user)
Definition: autodef.cpp:1196
void AddSources(CSeq_entry_Handle se)
Definition: autodef.cpp:93
static bool RegenerateSequenceDefLines(CSeq_entry_Handle se)
Definition: autodef.cpp:1248
string GetOneFeatureClauseList(CBioseq_Handle bh, unsigned int genome_val)
Definition: autodef.cpp:971
CBioseq_CI –.
Definition: bioseq_ci.hpp:69
CBioseq_set_EditHandle –.
CBioseq_set_Handle –.
CConstRef –.
Definition: ncbiobj.hpp:1266
TTaxId GetTaxId() const
Definition: Org_ref.cpp:72
CSeq_entry_CI –.
CSeq_entry_Handle –.
CSeqdesc_CI –.
Definition: seqdesc_ci.hpp:65
CT3Request –.
Definition: T3Request.hpp:66
CTaxon3_request –.
virtual CRef< CTaxon3_reply > SendRequest(const CTaxon3_request &request)
Definition: taxon3.cpp:115
@ eObjectType_AutodefOptions
EObjectType GetObjectType() const
Definition: set.hpp:45
static const char si[8][64]
Definition: des.c:146
#define ZERO_TAX_ID
Definition: ncbimisc.hpp:1115
#define TAX_ID_TO(T, tax_id)
Definition: ncbimisc.hpp:1110
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
SStrictId_Tax::TId TTaxId
Taxon id type.
Definition: ncbimisc.hpp:1048
void SetDescr(TDescr &v) const
@ fIncludeGivenEntry
Include the top (given) entry.
@ fRecursive
Iterate recursively.
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:1439
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
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.
Definition: ncbistr.hpp:5384
TGenome GetGenome(void) const
Get the Genome member data.
Definition: BioSource_.hpp:422
bool IsSetOrg(void) const
Check if a value has been assigned to Org data member.
Definition: BioSource_.hpp:497
const TOrg & GetOrg(void) const
Get the Org member data.
Definition: BioSource_.hpp:509
bool IsSetGenome(void) const
Check if a value has been assigned to Genome data member.
Definition: BioSource_.hpp:397
list< CRef< CSeqdesc > > Tdata
Definition: Seq_descr_.hpp:91
const TUser & GetUser(void) const
Get the variant data.
Definition: Seqdesc_.cpp:384
TTitle & SetTitle(void)
Select the variant.
Definition: Seqdesc_.hpp:1039
const TSource & GetSource(void) const
Get the variant data.
Definition: Seqdesc_.cpp:566
@ e_User
user defined object
Definition: Seqdesc_.hpp:124
@ e_Source
source of materials, includes Org-ref
Definition: Seqdesc_.hpp:133
@ eMol_na
just a nucleic acid
Definition: Seq_inst_.hpp:113
TRequest & SetRequest(void)
Assign a value to Request data member.
Modified on Thu Apr 25 08:20:24 2024 by modify_doxy.py rev. 669887