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

Go to the SVN repository for this file.

1 /* $Id: Location_constraint.cpp 78532 2017-06-27 16:51:54Z bollin $
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: J. Chen
27  *
28  * File Description:
29  * Evaluate if feature matches to CLocation_constraint
30  *
31  * Remark:
32  * This code was originally generated by application DATATOOL
33  * using the following specifications:
34  * 'macro.asn'.
35  */
36 
37 // standard includes
38 #include <ncbi_pch.hpp>
39 
40 // generated includes
48 
49 // generated classes
50 
52 
53 BEGIN_objects_SCOPE // namespace ncbi::objects::
54 
55 // destructor
57 {
58 }
59 
61 {
68  || (IsSetEnd3() && GetEnd3().Which() != CLocation_pos_constraint::e_not_set)) {
69  return false;
70  }
71  return true;
72 };
73 
75 {
76  if (loc.Which() == CSeq_loc::e_not_set) {
77  return false;
78  }
80  return true;
81  }
82 
83  if (loc.GetStrand() == eNa_strand_minus) {
85  return true;
86  }
87  else return false;
88  }
89  else {
91  return true;
92  }
93  else return false;
94  }
95 };
96 
98 {
99  if (seq_type == eSeqtype_constraint_any
100  || (bioseq->IsNa() && seq_type == eSeqtype_constraint_nuc)
101  || (bioseq->IsAa() && seq_type == eSeqtype_constraint_prot)) {
102  return true;
103  }
104  else return false;
105 };
106 
108 {
109  bool partial5 = loc.IsPartialStart(eExtreme_Biological);
110  bool partial3 = loc.IsPartialStop(eExtreme_Biological);
111  if ( (GetPartial5() == ePartial_constraint_partial && !partial5)
112  || (GetPartial5() == ePartial_constraint_complete && partial5)
113  || (GetPartial3() == ePartial_constraint_partial && !partial3)
114  || (GetPartial3() == ePartial_constraint_complete && partial3) ) {
115  return false;
116  }
117  else return true;
118 };
119 
121 {
122  bool has_null = false;
123  int num_intervals = 0;
124 
126  return true;
127  }
128  else
129  {
130  for (CSeq_loc_CI sl_ci(seq_loc); sl_ci; ++ sl_ci) {
131  if (sl_ci.GetEmbeddingSeq_loc().Which() == CSeq_loc::e_Null) {
132  has_null = true;
133  }
134  else if (!sl_ci.IsEmpty()) num_intervals ++;
135  }
136 
138  {
139  if (num_intervals == 1) {
140  return true;
141  }
142  }
144  if (num_intervals > 1 && !has_null) {
145  return true;
146  }
147  }
149  if (num_intervals > 1 && has_null) {
150  return true;
151  }
152  }
153  }
154  return false;
155 };
156 
158 {
159  if (!CanGetEnd5() && !CanGetEnd3()) {
160  return true;
161  }
162 
163  // pre-check to see if bioseq is required
164  if (loc.IsSetStrand() && loc.GetStrand() == eNa_strand_minus) {
165  if (IsSetEnd5() && !bioseq) {
166  return false;
167  }
168  } else {
169  if (IsSetEnd3() && !bioseq) {
170  return false;
171  }
172  }
173 
174  TSeqPos loc_upstream = loc.GetStart(eExtreme_Positional);
175  TSeqPos loc_downstream = loc.GetStop(eExtreme_Positional);
176  TSeqPos downstream_dist = bioseq->GetLength() - loc_downstream;
177 
178  if (loc.IsSetStrand() && loc.GetStrand() == eNa_strand_minus) {
179  if (IsSetEnd5() && !GetEnd5().Match(downstream_dist)) {
180  return false;
181  }
182  if (IsSetEnd3() && !GetEnd3().Match(loc_upstream)) {
183  return false;
184  }
185  } else {
186  if (IsSetEnd5() && !GetEnd5().Match(loc_upstream)) {
187  return false;
188  }
189  if (IsSetEnd3() && !GetEnd3().Match(downstream_dist)) {
190  return false;
191  }
192  }
193 
194  return true;
195 };
196 
198 {
199  if (IsEmpty()) {
200  return true;
201  }
202 
203  const CSeq_loc& feat_loc = feat.GetLocation();
205  if (feat_bioseq.Empty()) {
206  return false;
207  }
208  else if (feat_bioseq->IsAa()) {
209  if (feat_to.Empty()) { // when feat is product, feat_to points to cds
210  return false;
211  }
212  else if (!x_DoesStrandMatchConstraint (feat_to->GetLocation())) {
213  return false;
214  }
215  }
216  else if (!x_DoesStrandMatchConstraint (feat_loc)) {
217  return false;
218  }
219  }
220 
221  if (!x_DoesBioseqMatchSequenceType(feat_bioseq, GetSeq_type())) {
222  return false;
223  }
224 
226  return false;
227  }
228 
229  if (!x_DoesLocationMatchTypeConstraint (feat_loc)) {
230  return false;
231  }
232 
233  if (!x_DoesLocationMatchDistanceConstraint(feat_bioseq, feat_loc)) {
234  return false;
235  }
236 
237  return true;
238 };
239 
240 
241 END_objects_SCOPE // namespace ncbi::objects::
242 
244 
245 /* Original file checksum: lines: 57, chars: 1750, CRC32: b7e64033 */
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
@ eExtreme_Positional
numerical value
Definition: Na_strand.hpp:63
@ eExtreme_Biological
5' and 3'
Definition: Na_strand.hpp:62
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
TSeqPos GetLength(void) const
Definition: Bioseq.cpp:360
bool IsNa(void) const
Definition: Bioseq.cpp:345
bool IsAa(void) const
Definition: Bioseq.cpp:350
bool x_DoesBioseqMatchSequenceType(CConstRef< CBioseq > bioseq, const ESeqtype_constraint &seq_type) const
bool x_DoesLocationMatchTypeConstraint(const CSeq_loc &seq_loc) const
bool Match(const CSeq_feat &feat, CConstRef< CSeq_feat > feat_to, CConstRef< CBioseq > feat_bioseq) const
bool x_DoesLocationMatchPartialnessConstraint(const CSeq_loc &loc) const
bool x_DoesLocationMatchDistanceConstraint(CConstRef< CBioseq > bioseq_hl, const CSeq_loc &loc) const
bool x_DoesStrandMatchConstraint(const CSeq_loc &loc) const
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
Seq-loc iterator class – iterates all intervals from a seq-loc in the correct order.
Definition: Seq_loc.hpp:453
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
bool IsPartialStart(ESeqLocExtremes ext) const
check start or stop of location for e_Lim fuzz
Definition: Seq_loc.cpp:3222
ENa_strand GetStrand(void) const
Get the location's strand.
Definition: Seq_loc.cpp:882
TSeqPos GetStart(ESeqLocExtremes ext) const
Return start and stop positions of the seq-loc.
Definition: Seq_loc.cpp:915
bool IsSetStrand(EIsSetStrand flag=eIsSetStrand_Any) const
Check if strand is set for any/all part(s) of the seq-loc depending on the flag.
Definition: Seq_loc.cpp:858
bool IsPartialStop(ESeqLocExtremes ext) const
Definition: Seq_loc.cpp:3251
TSeqPos GetStop(ESeqLocExtremes ext) const
Definition: Seq_loc.cpp:963
bool Empty(void) const THROWS_NONE
Check if CConstRef is empty – not pointing to any object which means having a null value.
Definition: ncbiobj.hpp:1385
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
bool IsSetLocation_type(void) const
Check if a value has been assigned to Location_type data member.
TStrand GetStrand(void) const
Get the Strand member data.
bool IsSetEnd3(void) const
Check if a value has been assigned to End3 data member.
bool IsSetPartial3(void) const
Check if a value has been assigned to Partial3 data member.
TPartial3 GetPartial3(void) const
Get the Partial3 member data.
ESeqtype_constraint
Access to ESeqtype_constraint's attributes (values, names) as defined in spec.
const TEnd5 & GetEnd5(void) const
Get the End5 member data.
TLocation_type GetLocation_type(void) const
Get the Location_type member data.
bool IsSetSeq_type(void) const
Check if a value has been assigned to Seq_type data member.
TSeq_type GetSeq_type(void) const
Get the Seq_type member data.
bool CanGetEnd5(void) const
Check if it is safe to call GetEnd5 method.
bool IsSetEnd5(void) const
Check if a value has been assigned to End5 data member.
TPartial5 GetPartial5(void) const
Get the Partial5 member data.
bool CanGetEnd3(void) const
Check if it is safe to call GetEnd3 method.
bool IsSetStrand(void) const
Check if a value has been assigned to Strand data member.
const TEnd3 & GetEnd3(void) const
Get the End3 member data.
bool IsSetPartial5(void) const
Check if a value has been assigned to Partial5 data member.
@ eStrand_constraint_any
@ eStrand_constraint_plus
@ eStrand_constraint_minus
@ eSeqtype_constraint_any
@ eSeqtype_constraint_prot
@ eSeqtype_constraint_nuc
@ ePartial_constraint_complete
@ ePartial_constraint_partial
@ ePartial_constraint_either
@ eLocation_type_constraint_ordered
@ eLocation_type_constraint_joined
@ eLocation_type_constraint_any
@ eLocation_type_constraint_single_interval
const TLocation & GetLocation(void) const
Get the Location member data.
Definition: Seq_feat_.hpp:1117
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_loc_.hpp:475
@ eNa_strand_minus
Definition: Na_strand_.hpp:67
@ e_not_set
No variant selected.
Definition: Seq_loc_.hpp:97
@ e_Null
not placed
Definition: Seq_loc_.hpp:98
Modified on Sun May 05 05:21:01 2024 by modify_doxy.py rev. 669887