NCBI C++ ToolKit
cuTaxClient.hpp
Go to the documentation of this file.

Go to the SVN repository for this file.

1 /* $Id: cuTaxClient.hpp 98531 2022-11-30 20:25:57Z gaudaensj $
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: Adapted from CDTree-1 files by Chris Lanczycki
27  *
28  * File Description:
29  *
30  * Various utilities and classes for obtaining taxonomy information
31  * from ASN objects and NCBI taxonomy services.
32  * Also maintain lists of preferred and model tax nodes.
33  *
34  * ===========================================================================
35  */
36 
37 #ifndef CU_TAXCLIENT_HPP
38 #define CU_TAXCLIENT_HPP
39 
43 #include <objmgr/scope.hpp>
44 
45 #include <math.h>
48 BEGIN_SCOPE(cd_utils)
49 
51 {
52 
53  static const bool REFRESH_DEFAULT;
54 
55 public:
56 
57  TaxClient(bool refresh = REFRESH_DEFAULT);
58  virtual ~TaxClient();
59 
60  virtual bool init();
61  // return true is the CTaxon1 object has been created and is alive
62  virtual bool IsAlive();
63 
64  // return 0 if Get*TaxID*(...) fails
65  virtual TTaxId GetTaxIDForSeqId(CConstRef< CSeq_id > sid); // was GetTaxIDForSequence
66  virtual TTaxId GetTaxIDForGI(TGi gi);
67 
68  virtual bool GetOrgRef(TTaxId taxId, COrg_ref& orgRef);
69  virtual bool GetOrgRef(TTaxId taxId, CRef< COrg_ref >& orgRef);
70 
71  // Set mode for synonyms in OrgRef
72  // Returns: previous mode
73  // Default value: false (do not copy synonyms to the new OrgRef)
74  virtual bool SetSynonyms(bool on_off);
75 
76  virtual short GetRankID(TTaxId taxId, string& rankName);
77 
78  // Look through the bioseq for a COrg object, and use it to get taxid.
79  // Use tax server by default, unless server fails and lookInBioseq is true.
80  virtual TTaxId GetTaxIDFromBioseq(const CBioseq& bioseq, bool lookInBioseq);
81  virtual string GetTaxNameForTaxID(TTaxId taxid);
82  virtual string GetSuperKingdom(TTaxId taxid);
83 
84  // Returns true on success, false in case of error.
85  virtual bool GetDisplayCommonName(TTaxId taxid, string& displayCommonName);
86 
87  // Returns zero if the client is not alive (i.e., IsAlive() returns false).
88  virtual TTaxId GetParentTaxID(TTaxId taxid);
89  //is tax2 the descendant of tax1?
90  virtual bool IsTaxDescendant(TTaxId tax1, TTaxId tax2);
91 
92  // On success, lineageFromRoot contains the path in the taxonomy from the root to taxid.
93  // Returns true on success (i.e., a non-empty lineage), false in case of error.
94  virtual bool GetFullLineage(TTaxId taxid, vector<TTaxId>& lineageFromRoot);
95 
96  // On success, lineageFromRoot contains (taxid, taxname) for each step along the path
97  // in the taxonomy from the root to provided taxid. An empty string is used should any
98  // individual taxname not be found.
99  // When 'useCommonName' is true, the taxname is the 'common name'; otherwise, it is
100  // the preferred formal name found in the corresponding COrg_ref for the taxid (and
101  // shown in lineages on the Entrez taxonomy pages).
102  // Returns true on success (i.e., a non-empty lineage), false in case of error.
103  virtual bool GetFullLineage(TTaxId taxid, vector< pair<TTaxId, string> >& lineageFromRoot, bool useCommonName = false);
104 
105  virtual bool ConnectToTaxServer();
106 
107  // Wrapper functions to invoke CTaxon1 methods.
108  CConstRef< COrg_ref > GetOrgRef(TTaxId tax_id, bool& is_species, bool& is_uncultured, string& blast_name);
109  TTaxId Join(TTaxId taxid1, TTaxId taxid2);
110 
111 private:
112 
115 };
116 
117 END_SCOPE(cd_utils)
119 
120 #endif
User-defined methods of the data storage class.
CScope –.
Definition: scope.hpp:92
static const bool REFRESH_DEFAULT
Definition: cuTaxClient.hpp:53
CTaxon1 * m_taxonomyClient
CScope * m_scope
USING_SCOPE(objects)
static void DLIST_NAME() init(DLIST_LIST_TYPE *list)
Definition: dlist.tmpl.h:40
SStrictId_Tax::TId TTaxId
Taxon id type.
Definition: ncbimisc.hpp:1048
#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
#define NCBI_CDUTILS_EXPORT
Definition: ncbi_export.h:376
unique_ptr< CLocalTaxon > tax1
The Object manager core.
Modified on Fri Sep 20 14:57:49 2024 by modify_doxy.py rev. 669887