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

Go to the SVN repository for this file.

1 /* $Id: loc_edit.hpp 93572 2021-04-30 13:48:31Z 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  * Authors: Colleen Bollin
27  */
28 
29 
30 #ifndef _LOC_EDIT_H_
31 #define _LOC_EDIT_H_
32 
33 #include <corelib/ncbistd.hpp>
34 
35 #include <objmgr/scope.hpp>
36 
37 #include <objmgr/scope.hpp>
39 
40 
42 
45 
46 NCBI_XOBJEDIT_EXPORT string PrintBestSeqId(const CSeq_id& sid, CScope& scope);
47 NCBI_XOBJEDIT_EXPORT string PrintSeqIntUseBestID(const CSeq_interval& seq_int, CScope& scope, bool range_only);
48 NCBI_XOBJEDIT_EXPORT string PrintPntAndPntsUseBestID(const CSeq_loc& seq_loc, CScope& scope, bool range_only = false);
49 NCBI_XOBJEDIT_EXPORT string SeqLocPrintUseBestID(const CSeq_loc& seq_loc, CScope& scope, bool range_only = false);
50 
52 {
53 public:
55  ePartialPolicy_eNoChange = 0,
62  ePartialPolicy_eClearForGoodEnd };
63 
64  enum EMergePolicy {
65  eMergePolicy_NoChange = 0,
68  eMergePolicy_SingleInterval };
69 
70  CLocationEditPolicy(EPartialPolicy partial5 = ePartialPolicy_eNoChange,
71  EPartialPolicy partial3 = ePartialPolicy_eNoChange,
72  bool extend_5 = true,
73  bool extend_3 = true,
74  EMergePolicy merge = eMergePolicy_NoChange
75  )
76  : m_PartialPolicy5(partial5),
77  m_PartialPolicy3(partial3),
78  m_Extend5(extend_5),
79  m_Extend3(extend_3),
80  m_MergePolicy(merge)
81  {};
82 
84 
85  EPartialPolicy GetPartial5Policy() { return m_PartialPolicy5; };
86  EPartialPolicy GetPartial3Policy() { return m_PartialPolicy3; };
87  void SetPartial5Policy(EPartialPolicy policy) { m_PartialPolicy5 = policy; };
88  void SetPartial3Policy(EPartialPolicy policy) { m_PartialPolicy3 = policy; };
89  EMergePolicy GetMergePolicy() { return m_MergePolicy; };
90  void SetMergePolicy(EMergePolicy policy) { m_MergePolicy = policy; };
91  bool GetExtend5() { return m_Extend5; };
92  bool GetExtend3() { return m_Extend3; };
93  void SetExtend5(bool policy) { m_Extend5 = policy; };
94  void SetExtend3(bool policy) { m_Extend3 = policy; };
95 
96  bool ApplyPolicyToFeature(CSeq_feat& feat, CScope& scope) const;
97  bool Interpret5Policy(const CSeq_feat& orig_feat, CScope& scope, bool& do_set_5_partial, bool& do_clear_5_partial) const;
98  bool Interpret3Policy(const CSeq_feat& orig_feat, CScope& scope, bool& do_set_3_partial, bool& do_clear_3_partial) const;
99  static CRef<CSeq_loc> ConvertToJoin(const CSeq_loc& orig_loc, bool &changed);
100  static CRef<CSeq_loc> ConvertToOrder(const CSeq_loc& orig_loc, bool &changed);
101  static bool Extend5(CSeq_feat& feat, CScope& scope);
102  static bool Extend3(CSeq_feat& feat, CScope& scope);
103  static bool HasNulls(const CSeq_loc& orig_loc);
104 
105  static bool Is5AtEndOfSeq(const CSeq_loc& loc, CBioseq_Handle bsh);
106  static bool Is3AtEndOfSeq(const CSeq_loc& loc, CBioseq_Handle bsh);
107 
108  // Note that for these two functions, "confident" is set to true if either
109  // we can be sure that the location is at the specified end because the end
110  // point is zero, or because we were able to find the Bioseq for that end
111  // and the endpoint is at the end of the Bioseq. If fetching the Bioseq is
112  // required but the Bioseq is not present, "confident" will be set to false.
113  static bool Is5AtEndOfSeq(const CSeq_loc& loc, CScope& scope, bool& confident);
114  static bool Is3AtEndOfSeq(const CSeq_loc& loc, CScope& scope, bool& confident);
115 
116 private:
119  bool m_Extend5;
120  bool m_Extend3;
122 };
123 
124 
127  const CSeq_feat& orig_feat,
128  CScope& scope,
129  bool adjust_gene, bool retranslate_cds);
130 
132  SeqLocExtend(const CSeq_loc& loc, size_t pos, CScope* scope);
133 
135 
137 
139  TSeqPos from, TSeqPos to,
140  const CSeq_id* seqid,
141  bool& bCompleteCut,
142  TSeqPos& trim5,
143  bool& bAdjusted);
144 
146  TSeqPos from, TSeqPos to,
147  const CSeq_id* seqid);
148 
150  TSeqPos from, TSeqPos to,
151  const CSeq_id* seqid,
152  bool& bCompleteCut,
153  bool& bAdjusted);
154 
156  TSeqPos from, TSeqPos to,
157  const CSeq_id* seqid);
158 
159 
160 typedef enum {
165 
167  void SplitLocationForGap(CSeq_loc& loc1, CSeq_loc& loc2,
168  size_t start, size_t stop,
169  const CSeq_id* seqid,
171 
172 /// Correct the order of consecutive intervals with the same
173 /// Seq-id on the same strand
175 bool CorrectIntervalOrder(CSeq_loc& loc);
176 
177 // This function will adjust the partial ends of a feature so that it will
178 // abut a gap or the end of the sequence if the end is currently
179 // three or fewer nucleotides away
182 
183 // This function will indicate whether a given feature would be extended by
184 // the above function
186 bool IsExtendable(const CSeq_feat& cds, CScope& scope);
187 
188 
192 
193 #endif
194 
CBioseq_Handle –.
EPartialPolicy GetPartial5Policy()
Definition: loc_edit.hpp:85
void SetPartial3Policy(EPartialPolicy policy)
Definition: loc_edit.hpp:88
EPartialPolicy m_PartialPolicy3
Definition: loc_edit.hpp:118
EPartialPolicy GetPartial3Policy()
Definition: loc_edit.hpp:86
void SetPartial5Policy(EPartialPolicy policy)
Definition: loc_edit.hpp:87
CLocationEditPolicy(EPartialPolicy partial5=ePartialPolicy_eNoChange, EPartialPolicy partial3=ePartialPolicy_eNoChange, bool extend_5=true, bool extend_3=true, EMergePolicy merge=eMergePolicy_NoChange)
Definition: loc_edit.hpp:70
EPartialPolicy m_PartialPolicy5
Definition: loc_edit.hpp:117
EMergePolicy m_MergePolicy
Definition: loc_edit.hpp:121
void SetExtend3(bool policy)
Definition: loc_edit.hpp:94
void SetMergePolicy(EMergePolicy policy)
Definition: loc_edit.hpp:90
EMergePolicy GetMergePolicy()
Definition: loc_edit.hpp:89
void SetExtend5(bool policy)
Definition: loc_edit.hpp:93
CObject –.
Definition: ncbiobj.hpp:180
CScope –.
Definition: scope.hpp:92
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
Include a standard set of the NCBI C++ Toolkit most basic headers.
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#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_XOBJEDIT_EXPORT
Definition: ncbi_export.h:1291
bool CorrectIntervalOrder(CSeq_loc &loc)
Correct the order of consecutive intervals with the same Seq-id on the same strand.
Definition: loc_edit.cpp:2346
ESplitLocOptions
Definition: loc_edit.hpp:160
@ eSplitLocOption_split_in_intron
Definition: loc_edit.hpp:163
@ eSplitLocOption_make_partial
Definition: loc_edit.hpp:161
@ eSplitLocOption_split_in_exon
Definition: loc_edit.hpp:162
void FeatureAdjustForInsert(CSeq_feat &feat, TSeqPos from, TSeqPos to, const CSeq_id *seqid)
Definition: loc_edit.cpp:2141
bool ExtendPartialFeatureEnds(CBioseq_Handle bsh)
Definition: loc_edit.cpp:2585
void ReverseComplementFeature(CSeq_feat &feat, CScope &scope)
Definition: loc_edit.cpp:1068
string PrintSeqIntUseBestID(const CSeq_interval &seq_int, CScope &scope, bool range_only)
Definition: loc_edit.cpp:82
string PrintBestSeqId(const CSeq_id &sid, CScope &scope)
Definition: loc_edit.cpp:64
bool ApplyPolicyToFeature(const CLocationEditPolicy &policy, const CSeq_feat &orig_feat, CScope &scope, bool adjust_gene, bool retranslate_cds)
Definition: loc_edit.cpp:835
void FeatureAdjustForTrim(CSeq_feat &feat, TSeqPos from, TSeqPos to, const CSeq_id *seqid, bool &bCompleteCut, bool &bAdjusted)
Definition: loc_edit.cpp:2087
bool IsExtendable(const CSeq_feat &cds, CScope &scope)
Definition: loc_edit.cpp:2555
string PrintPntAndPntsUseBestID(const CSeq_loc &seq_loc, CScope &scope, bool range_only=false)
Definition: loc_edit.cpp:131
void SeqLocAdjustForInsert(CSeq_loc &loc, TSeqPos from, TSeqPos to, const CSeq_id *seqid)
Definition: loc_edit.cpp:1682
string SeqLocPrintUseBestID(const CSeq_loc &seq_loc, CScope &scope, bool range_only=false)
Definition: loc_edit.cpp:153
void SplitLocationForGap(CSeq_loc &loc1, CSeq_loc &loc2, size_t start, size_t stop, const CSeq_id *seqid, unsigned int options=eSplitLocOption_make_partial|eSplitLocOption_split_in_exon)
Definition: loc_edit.cpp:1833
void SeqLocAdjustForTrim(CSeq_loc &loc, TSeqPos from, TSeqPos to, const CSeq_id *seqid, bool &bCompleteCut, TSeqPos &trim5, bool &bAdjusted)
Definition: loc_edit.cpp:1489
void ReverseComplementLocation(CSeq_loc &loc, CScope &scope)
Definition: loc_edit.cpp:991
CRef< CSeq_loc > SeqLocExtend(const CSeq_loc &loc, size_t pos, CScope *scope)
Definition: loc_edit.cpp:546
Definition: fix_pub.hpp:45
Modified on Fri Sep 20 14:58:14 2024 by modify_doxy.py rev. 669887