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

Go to the SVN repository for this file.

1 #ifndef OBJTOOLS_ALNMGR___SEQID_COMP__HPP
2 #define OBJTOOLS_ALNMGR___SEQID_COMP__HPP
3 /* $Id: seqid_comp.hpp 91306 2020-10-08 11:57:15Z gouriano $
4 * ===========================================================================
5 *
6 * PUBLIC DOMAIN NOTICE
7 * National Center for Biotechnology Information
8 *
9 * This software/database is a "United States Government Work" under the
10 * terms of the United States Copyright Act. It was written as part of
11 * the author's official duties as a United States Government employee and
12 * thus cannot be copyrighted. This software/database is freely available
13 * to the public for use. The National Library of Medicine and the U.S.
14 * Government have not placed any restriction on its use or reproduction.
15 *
16 * Although all reasonable efforts have been taken to ensure the accuracy
17 * and reliability of the software and data, the NLM and the U.S.
18 * Government do not and cannot warrant the performance or results that
19 * may be obtained by using this software or data. The NLM and the U.S.
20 * Government disclaim all warranties, express or implied, including
21 * warranties of performance, merchantability or fitness for any particular
22 * purpose.
23 *
24 * Please cite the author in any work or product based on this material.
25 *
26 * ===========================================================================
27 *
28 * Author: Kamen Todorov, NCBI
29 *
30 * File Description:
31 * Seq-id comparison functors
32 *
33 * ===========================================================================
34 */
35 
36 
37 #include <corelib/ncbistd.hpp>
38 #include <corelib/ncbiobj.hpp>
39 
41 
42 #include <objmgr/scope.hpp>
43 
44 /// Implementation includes
45 
46 
49 
50 
51 template <typename TSeqIdPtr>
53 {
54 public:
55  bool operator()(TSeqIdPtr left_seq_id,
56  TSeqIdPtr right_seq_id) const
57  {
58  return left_seq_id->CompareOrdered(*right_seq_id) < 0;
59  }
60 };
61 
62 
63 template <typename TSeqIdPtr>
65 {
66 public:
68 
69  bool operator()(TSeqIdPtr left_seq_id,
70  TSeqIdPtr right_seq_id) const
71  {
72  CBioseq_Handle l_bioseq_handle = m_Scope.GetBioseqHandle(*left_seq_id);
73  CBioseq_Handle r_bioseq_handle = m_Scope.GetBioseqHandle(*right_seq_id);
74  if ( !l_bioseq_handle ) {
75  string err_str =
76  string("Seq-id cannot be resolved: ")
77  + left_seq_id->AsFastaString();
78  NCBI_THROW(CSeqalignException, eInvalidSeqId, err_str);
79  }
80  if ( !r_bioseq_handle ) {
81  string err_str =
82  string("Seq-id cannot be resolved: ")
83  + right_seq_id->AsFastaString();
84  NCBI_THROW(CSeqalignException, eInvalidSeqId, err_str);
85  }
86  return l_bioseq_handle < r_bioseq_handle;
87  }
88 private:
90 };
91 
92 
93 
95 
96 #endif // OBJTOOLS_ALNMGR___SEQID_COMP__HPP
CBioseq_Handle –.
CScope –.
Definition: scope.hpp:92
bool operator()(TSeqIdPtr left_seq_id, TSeqIdPtr right_seq_id) const
Definition: seqid_comp.hpp:69
CSeqIdBioseqHandleComp(CScope &scope)
Definition: seqid_comp.hpp:67
bool operator()(TSeqIdPtr left_seq_id, TSeqIdPtr right_seq_id) const
Definition: seqid_comp.hpp:55
Include a standard set of the NCBI C++ Toolkit most basic headers.
string
Definition: cgiapp.hpp:687
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
const string AsFastaString(void) const
Definition: Seq_id.cpp:2265
int CompareOrdered(const CSeq_id &sid2) const
Definition: Seq_id.cpp:486
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
USING_SCOPE(objects)
Implementation includes.
Modified on Fri Dec 01 04:43:29 2023 by modify_doxy.py rev. 669887