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

Go to the SVN repository for this file.

1 #ifndef OBJTOOLS_FORMAT_ITEMS___FLAT_SEQLOC__HPP
2 #define OBJTOOLS_FORMAT_ITEMS___FLAT_SEQLOC__HPP
3 
4 /* $Id: flat_seqloc.hpp 99481 2023-04-04 13:16:28Z stakhovv $
5 * ===========================================================================
6 *
7 * PUBLIC DOMAIN NOTICE
8 * National Center for Biotechnology Information
9 *
10 * This software/database is a "United States Government Work" under the
11 * terms of the United States Copyright Act. It was written as part of
12 * the author's official duties as a United States Government employee and
13 * thus cannot be copyrighted. This software/database is freely available
14 * to the public for use. The National Library of Medicine and the U.S.
15 * Government have not placed any restriction on its use or reproduction.
16 *
17 * Although all reasonable efforts have been taken to ensure the accuracy
18 * and reliability of the software and data, the NLM and the U.S.
19 * Government do not and cannot warrant the performance or results that
20 * may be obtained by using this software or data. The NLM and the U.S.
21 * Government disclaim all warranties, express or implied, including
22 * warranties of performance, merchantability or fitness for any particular
23 * purpose.
24 *
25 * Please cite the author in any work or product based on this material.
26 *
27 * ===========================================================================
28 *
29 * Author: Aaron Ucko, NCBI
30 *
31 * File Description:
32 * new (early 2003) flat-file generator -- location representation
33 *
34 */
35 
36 #include <corelib/ncbiobj.hpp>
37 #include <corelib/ncbimtx.hpp>
38 #include <util/range.hpp>
40 
43 
44 // forward declarations
45 class CInt_fuzz;
46 class CSeq_id;
47 class CSeq_interval;
48 class CSeq_loc;
49 class CBioseqContext;
50 
51 
53 {
54 public:
55  typedef TSeqPos TLength;
56 
57  CFlatGapLoc(TLength value) : m_Length(value), m_Fuzz(nullptr) { SetNull(); }
58 
59  TLength GetLength(void) const { return m_Length; }
60  void SetLength(const TLength& value) { m_Length = value; }
61 
62  const CInt_fuzz* GetFuzz() const { return m_Fuzz; }
63  void SetFuzz(const CInt_fuzz* fuzz) { m_Fuzz = fuzz; }
64 
65 private:
67  const CInt_fuzz* m_Fuzz;
68 };
69 
70 
71 class NCBI_FORMAT_EXPORT CFlatSeqLoc : public CObject // derived from CObject to allow for caching
72 {
73 public:
74  enum EType
75  {
76  eType_location, // Seq-loc
77  eType_assembly // Genome assembly
78  };
79  typedef EType TType;
80 
81  // ID-4736 : The add_join flag is needed for the GBSeq format
82  // (<GBSeq_contig> node), where the wrapping join(...) is
83  // required even when location consists of a single interval.
84  CFlatSeqLoc(const CSeq_loc& loc, CBioseqContext& ctx,
85  TType type = eType_location, bool show_all_accns = false,
86  bool add_join = false, bool suppress_accession = false);
87 
88  const string& GetString(void) const { return m_String; }
89 
90 private:
91 
92  enum EHTML {
93  eHTML_None = 0,
94  eHTML_Yes
95  };
96 
97  enum EForce {
98  eForce_None = 0,
99  eForce_ToRange
100  };
101 
102  enum ESource {
103  eSource_Other = 0,
104  eSource_Point
105  };
106 
107  bool x_Add(const CSeq_loc& loc, CNcbiOstrstream& oss,
108  CBioseqContext& ctx, TType type, bool show_comp,
109  bool show_all_accns = false, bool join_whole_loc = false,
110  bool suppress_accession = false);
111  bool x_Add(const CSeq_interval& si, CNcbiOstrstream& oss,
112  CBioseqContext& ctx, TType type, bool show_comp,
113  bool show_all_accns = false, bool suppress_accession = false);
114  bool x_Add(const CSeq_point& pnt, CNcbiOstrstream& oss,
115  CBioseqContext& ctx, TType type, bool show_comp,
116  bool show_all_accns = false, bool suppress_accession = false);
117  bool x_Add(TSeqPos pnt, const CInt_fuzz* fuzz, CNcbiOstrstream& oss,
118  EHTML html, EForce force = eForce_None, ESource source = eSource_Other,
119  bool show_all_accns = false, bool suppress_accession = false);
120  void x_AddID(const CSeq_id& id, CNcbiOstrstream& oss,
121  CBioseqContext& ctx, TType type,
122  bool show_all_accns = false, bool suppress_accession = false);
123 
124  bool x_IsAccessionVersion( CSeq_id_Handle id );
125 
126  bool x_FuzzToDisplayed(const CSeq_interval& si) const;
127 
128  // data
129  string m_String; // whole location, as a GB-style string
130 
131  typedef std::map<CSeq_id_Handle, CSeq_id_Handle> TToAccessionMap;
132  // a map of Seq_id_Handle to Seq_id_Handle (accession) which is
133  // guarded by mutex (mutex needed since it's static)
135  public:
136  void Insert( CSeq_id_Handle from, CSeq_id_Handle to );
137  // It's an empty Seq_id_Handle if not found
139 
140  private:
141  // make sure to use the mutex anytime you read/write m_TheMap
144  };
146 };
147 
148 
151 
152 #endif /* OBJTOOLS_FORMAT_ITEMS___FLAT_SEQLOC__HPP */
CFastMutex –.
Definition: ncbimtx.hpp:667
void SetLength(const TLength &value)
Definition: flat_seqloc.hpp:60
CFlatGapLoc(TLength value)
Definition: flat_seqloc.hpp:57
TLength GetLength(void) const
Definition: flat_seqloc.hpp:59
const CInt_fuzz * GetFuzz() const
Definition: flat_seqloc.hpp:62
TLength m_Length
Definition: flat_seqloc.hpp:66
const CInt_fuzz * m_Fuzz
Definition: flat_seqloc.hpp:67
TSeqPos TLength
Definition: flat_seqloc.hpp:55
void SetFuzz(const CInt_fuzz *fuzz)
Definition: flat_seqloc.hpp:63
std::map< CSeq_id_Handle, CSeq_id_Handle > TToAccessionMap
static CGuardedToAccessionMap m_ToAccessionMap
const string & GetString(void) const
Definition: flat_seqloc.hpp:88
string m_String
CObject –.
Definition: ncbiobj.hpp:180
char value[7]
Definition: config.c:431
CS_CONTEXT * ctx
Definition: t0006.c:12
static const char si[8][64]
Definition: des.c:146
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
void SetNull(void)
Override all setters to incorporate cache invalidation.
Definition: Seq_loc.hpp:960
#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_FORMAT_EXPORT
Definition: ncbi_export.h:496
const TYPE & Get(const CNamedParameterList *param)
const CharType(& source)[N]
Definition: pointer.h:1149
#define nullptr
Definition: ncbimisc.hpp:45
Multi-threading – mutexes; rw-locks; semaphore.
Portable reference counted smart and weak pointers using CWeakRef, CRef, CObject and CObjectEx.
static string query
Definition: type.c:6
Modified on Sat Feb 24 07:49:27 2024 by modify_doxy.py rev. 669887