1 /* $Id: Seq_interval.cpp 433711 2014-04-29 13:46:53Z 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:  .......
27  *
28  * File Description:
29  *   .......
30  *
31  * Remark:
32  *   This code was originally generated by application DATATOOL
33  *   using specifications from the ASN data definition file
34  *   'seqloc.asn'.
35  */
36 
37 // standard includes
38 #include <ncbi_pch.hpp>
39 #include <objects/seqloc/Seq_interval.hpp>
40 
41 // generated includes
42 #include <objects/general/Int_fuzz.hpp>
43 
44 // generated classes
45 
46 BEGIN_NCBI_SCOPE
47 
48 BEGIN_objects_SCOPE // namespace ncbi::objects::
49 
50 // destructor
~CSeq_interval(void)51 CSeq_interval::~CSeq_interval(void)
52 {
53 }
54 
55 
x_IsMinusStrand(void) const56 bool CSeq_interval::x_IsMinusStrand(void) const
57 {
58     return IsSetStrand() && IsReverse(GetStrand());
59 }
60 
61 
IsPartialStart(ESeqLocExtremes ext) const62 bool CSeq_interval::IsPartialStart(ESeqLocExtremes ext) const
63 {
64     if (ext == eExtreme_Biological  &&  x_IsMinusStrand()) {
65         if (IsSetFuzz_to()) {
66             const CInt_fuzz& ifp = GetFuzz_to();
67             if (ifp.IsLim()  &&  ifp.GetLim() == CInt_fuzz::eLim_gt) {
68                 return true;
69             }
70         }
71     } else {
72         if (IsSetFuzz_from()) {
73             const CInt_fuzz& ifp = GetFuzz_from();
74             if (ifp.IsLim()  &&  ifp.GetLim() == CInt_fuzz::eLim_lt) {
75                 return true;
76             }
77         }
78     }
79     return false;
80 }
81 
IsPartialStop(ESeqLocExtremes ext) const82 bool CSeq_interval::IsPartialStop(ESeqLocExtremes ext) const
83 {
84     if (ext == eExtreme_Biological  &&  x_IsMinusStrand()) {
85         if (IsSetFuzz_from()) {
86             const CInt_fuzz& ifp = GetFuzz_from();
87             if (ifp.IsLim()  &&  ifp.GetLim() == CInt_fuzz::eLim_lt) {
88                 return true;
89             }
90         }
91     } else {
92         if (IsSetFuzz_to()) {
93             const CInt_fuzz& ifp = GetFuzz_to();
94             if (ifp.IsLim()  &&  ifp.GetLim() == CInt_fuzz::eLim_gt) {
95                 return true;
96             }
97         }
98     }
99     return false;
100 }
101 
102 
103 // set / remove e_Lim fuzz on left (5') or right (3') end
SetPartialStart(bool val,ESeqLocExtremes ext)104 void CSeq_interval::SetPartialStart(bool val, ESeqLocExtremes ext)
105 {
106     if (val != IsPartialStart(ext)) {
107         if (val) {
108             if (ext == eExtreme_Biological  &&  x_IsMinusStrand()) {
109                 SetFuzz_to().SetLim(CInt_fuzz::eLim_gt);
110             } else {
111                 SetFuzz_from().SetLim(CInt_fuzz::eLim_lt);
112             }
113         } else {
114             if (ext == eExtreme_Biological  &&  x_IsMinusStrand()) {
115                 ResetFuzz_to();
116             } else {
117                 ResetFuzz_from();
118             }
119         }
120     }
121     _ASSERT(val == IsPartialStart(ext));
122 }
123 
124 
SetPartialStop(bool val,ESeqLocExtremes ext)125 void CSeq_interval::SetPartialStop(bool val, ESeqLocExtremes ext)
126 {
127     if (val != IsPartialStop(ext)) {
128         if (val) {
129             if (ext == eExtreme_Biological  &&  x_IsMinusStrand()) {
130                 SetFuzz_from().SetLim(CInt_fuzz::eLim_lt);
131             } else {
132                 SetFuzz_to().SetLim(CInt_fuzz::eLim_gt);
133             }
134         } else {
135             if (ext == eExtreme_Biological  &&  x_IsMinusStrand()) {
136                 ResetFuzz_from();
137             } else {
138                 ResetFuzz_to();
139             }
140         }
141     }
142     _ASSERT(val == IsPartialStop(ext));
143 }
144 
145 
IsTruncatedStart(ESeqLocExtremes ext) const146 bool CSeq_interval::IsTruncatedStart(ESeqLocExtremes ext) const
147 {
148     if (ext == eExtreme_Biological  &&  x_IsMinusStrand()) {
149         if (IsSetFuzz_to()) {
150             const CInt_fuzz& ifp = GetFuzz_to();
151             if (ifp.IsLim()  &&  ifp.GetLim() == CInt_fuzz::eLim_tr) {
152                 return true;
153             }
154         }
155     } else {
156         if (IsSetFuzz_from()) {
157             const CInt_fuzz& ifp = GetFuzz_from();
158             if (ifp.IsLim()  &&  ifp.GetLim() == CInt_fuzz::eLim_tl) {
159                 return true;
160             }
161         }
162     }
163     return false;
164 }
165 
166 
IsTruncatedStop(ESeqLocExtremes ext) const167 bool CSeq_interval::IsTruncatedStop(ESeqLocExtremes ext) const
168 {
169     if (ext == eExtreme_Biological  &&  x_IsMinusStrand()) {
170         if (IsSetFuzz_from()) {
171             const CInt_fuzz& ifp = GetFuzz_from();
172             if (ifp.IsLim()  &&  ifp.GetLim() == CInt_fuzz::eLim_tl) {
173                 return true;
174             }
175         }
176     } else {
177         if (IsSetFuzz_to()) {
178             const CInt_fuzz& ifp = GetFuzz_to();
179             if (ifp.IsLim()  &&  ifp.GetLim() == CInt_fuzz::eLim_tr) {
180                 return true;
181             }
182         }
183     }
184     return false;
185 }
186 
187 
SetTruncatedStart(bool val,ESeqLocExtremes ext)188 void CSeq_interval::SetTruncatedStart(bool val, ESeqLocExtremes ext)
189 {
190     if (val != IsTruncatedStart(ext)) {
191         if (val) {
192             if (ext == eExtreme_Biological  &&  x_IsMinusStrand()) {
193                 SetFuzz_to().SetLim(CInt_fuzz::eLim_tr);
194             } else {
195                 SetFuzz_from().SetLim(CInt_fuzz::eLim_tl);
196             }
197         } else {
198             if (ext == eExtreme_Biological  &&  x_IsMinusStrand()) {
199                 ResetFuzz_to();
200             } else {
201                 ResetFuzz_from();
202             }
203         }
204     }
205     _ASSERT(val == IsTruncatedStart(ext));
206 }
207 
208 
SetTruncatedStop(bool val,ESeqLocExtremes ext)209 void CSeq_interval::SetTruncatedStop(bool val, ESeqLocExtremes ext)
210 {
211     if (val != IsTruncatedStop(ext)) {
212         if (val) {
213             if (ext == eExtreme_Biological  &&  x_IsMinusStrand()) {
214                 SetFuzz_from().SetLim(CInt_fuzz::eLim_tl);
215             } else {
216                 SetFuzz_to().SetLim(CInt_fuzz::eLim_tr);
217             }
218         } else {
219             if (ext == eExtreme_Biological  &&  x_IsMinusStrand()) {
220                 ResetFuzz_from();
221             } else {
222                 ResetFuzz_to();
223             }
224         }
225     }
226     _ASSERT(val == IsTruncatedStop(ext));
227 }
228 
229 
GetStart(ESeqLocExtremes ext) const230 TSeqPos CSeq_interval::GetStart(ESeqLocExtremes ext) const
231 {
232     return ext == eExtreme_Biological  &&  x_IsMinusStrand()?
233         GetTo(): GetFrom();
234 }
235 
236 
GetStop(ESeqLocExtremes ext) const237 TSeqPos CSeq_interval::GetStop (ESeqLocExtremes ext) const
238 {
239     return ext == eExtreme_Biological  &&  x_IsMinusStrand()?
240         GetFrom(): GetTo();
241 }
242 
243 
FlipStrand(void)244 void CSeq_interval::FlipStrand(void)
245 {
246     if (IsSetStrand()) {
247         SetStrand(Reverse(GetStrand()));
248     } else {
249         SetStrand(eNa_strand_minus);
250     }
251 }
252 
253 
254 END_objects_SCOPE // namespace ncbi::objects::
255 
256 END_NCBI_SCOPE
257 
258 /* Original file checksum: lines: 61, chars: 1895, CRC32: 81b5bfaa */
259