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

Go to the SVN repository for this file.

1 /* $Id: unit_test_seq_loc_cmp.cpp 80547 2017-12-19 19:36:12Z vasilche $
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: Aleksey Grichenko
27 *
28 * File Description:
29 * Unit tests for seq_loc_util functions.
30 *
31 * ===========================================================================
32 */
33 #define NCBI_TEST_APPLICATION
34 #include <ncbi_pch.hpp>
35 
36 #include <corelib/ncbi_system.hpp>
37 
38 // This macro should be defined before inclusion of test_boost.hpp in all
39 // "*.cpp" files inside executable except one. It is like function main() for
40 // non-Boost.Test executables is defined only in one *.cpp file - other files
41 // should not include it. If NCBI_BOOST_NO_AUTO_TEST_MAIN will not be defined
42 // then test_boost.hpp will define such "main()" function for tests.
43 //
44 // Usually if your unit tests contain only one *.cpp file you should not
45 // care about this macro at all.
46 //
47 //#define NCBI_BOOST_NO_AUTO_TEST_MAIN
48 
49 
50 // This header must be included before all Boost.Test headers if there are any
51 #include <corelib/test_boost.hpp>
52 
58 #include <objmgr/util/sequence.hpp>
59 #include <objmgr/seq_vector.hpp>
61 
62 
65 USING_SCOPE(sequence);
66 
67 
68 extern const char* sc_TestEntry;
69 
71 {
72  static CScope s_Scope(*CObjectManager::GetInstance());
73  static CRef<CSeq_entry> s_Entry;
74  if (!s_Entry) {
75  s_Entry.Reset(new CSeq_entry);
77  istr >> MSerial_AsnText >> *s_Entry;
78  s_Scope.AddTopLevelSeqEntry(*s_Entry);
79  }
80  return s_Scope;
81 }
82 
83 
84 CRef<CSeq_loc> MakeBond(TGi giA, TSeqPos posA, TGi giB = ZERO_GI, TSeqPos posB = 0)
85 {
86  CRef<CSeq_loc> ret(new CSeq_loc);
87  ret->SetBond().SetA().SetId().SetGi(giA);
88  ret->SetBond().SetA().SetPoint(posA);
89  if (giB) {
90  ret->SetBond().SetB().SetId().SetGi(giB);
91  ret->SetBond().SetB().SetPoint(posB);
92  }
93  return ret;
94 }
95 
96 
98  TSeqPos from,
99  TSeqPos to,
101 {
102  CRef<CSeq_loc> ret(new CSeq_loc);
103  ret->SetInt().SetId().SetGi(gi);
104  ret->SetInt().SetFrom(from);
105  ret->SetInt().SetTo(to);
106  if (strand != eNa_strand_unknown) {
107  ret->SetInt().SetStrand(strand);
108  }
109  return ret;
110 }
111 
112 
114  TSeqPos from,
115  TSeqPos to,
117 {
118  CRef<CSeq_loc> ret(new CSeq_loc);
119  ret->SetInt().SetId(*id);
120  ret->SetInt().SetFrom(from);
121  ret->SetInt().SetTo(to);
122  if (strand != eNa_strand_unknown) {
123  ret->SetInt().SetStrand(strand);
124  }
125  return ret;
126 }
127 
128 
130 {
131  CRef<CSeq_loc> ret(new CSeq_loc);
132  ret->SetPnt().SetId().SetGi(gi);
133  ret->SetPnt().SetPoint(pos);
134  return ret;
135 }
136 
137 
138 BOOST_AUTO_TEST_CASE(Test_Compare_whole_vs_whole)
139 {
140  CScope* scope = &GetScope();
141 
142  CSeq_loc wg2, wg3, wl2, wl3;
143  wg2.SetWhole().SetGi(2);
144  wg3.SetWhole().SetGi(3);
145  wl2.SetWhole().SetLocal().SetStr("local2");
146  wl3.SetWhole().SetLocal().SetStr("local3");
147 
148  BOOST_CHECK_EQUAL(Compare(wg2, wg2, scope, fCompareOverlapping), eSame);
149  BOOST_CHECK_EQUAL(Compare(wg2, wl2, scope, fCompareOverlapping), eSame);
150  BOOST_CHECK_EQUAL(Compare(wg2, wg3, scope, fCompareOverlapping), eNoOverlap);
151  BOOST_CHECK_EQUAL(Compare(wg2, wl3, scope, fCompareOverlapping), eNoOverlap);
152 }
153 
154 
155 BOOST_AUTO_TEST_CASE(Test_Compare_whole_vs_interval)
156 {
157  CScope* scope = &GetScope();
158 
159  CSeq_loc wg2, wg3;
160  wg2.SetWhole().SetGi(2);
161  wg3.SetWhole().SetGi(3);
162 
163  // Partial overlap
164  CRef<CSeq_loc> i = MakeInterval(2, 10, 20);
165  BOOST_CHECK_EQUAL(Compare(wg2, *i, scope, fCompareOverlapping), eContains);
166  BOOST_CHECK_EQUAL(Compare(*i, wg2, scope, fCompareOverlapping), eContained);
167  BOOST_CHECK_EQUAL(Compare(wg3, *i, scope, fCompareOverlapping), eNoOverlap);
168  BOOST_CHECK_EQUAL(Compare(*i, wg3, scope, fCompareOverlapping), eNoOverlap);
169 
170  // Full bioseq
171  i = MakeInterval(2, 0, 1441);
172  BOOST_CHECK_EQUAL(Compare(wg2, *i, scope, fCompareOverlapping), eSame);
173  BOOST_CHECK_EQUAL(Compare(*i, wg2, scope, fCompareOverlapping), eSame);
174 }
175 
176 
177 BOOST_AUTO_TEST_CASE(Test_Compare_whole_vs_packed_interval)
178 {
179  CScope* scope = &GetScope();
180 
181  CSeq_loc wg2, wg3;
182  wg2.SetWhole().SetGi(2);
183  wg3.SetWhole().SetGi(3);
184 
185  CSeq_id gi2("gi|2");
186  CSeq_id gi3("gi|3");
187 
188  CSeq_loc pki;
189  pki.SetPacked_int().AddInterval(gi2, 10, 20);
190  BOOST_CHECK_EQUAL(Compare(wg2, pki, scope, fCompareOverlapping), eContains);
191  BOOST_CHECK_EQUAL(Compare(pki, wg2, scope, fCompareOverlapping), eContained);
192  BOOST_CHECK_EQUAL(Compare(wg3, pki, scope, fCompareOverlapping), eNoOverlap);
193  BOOST_CHECK_EQUAL(Compare(pki, wg3, scope, fCompareOverlapping), eNoOverlap);
194 
195  pki.SetPacked_int().AddInterval(gi3, 30, 40);
196  BOOST_CHECK_EQUAL(Compare(wg2, pki, scope, fCompareOverlapping), eOverlap);
197  BOOST_CHECK_EQUAL(Compare(pki, wg2, scope, fCompareOverlapping), eOverlap);
198  BOOST_CHECK_EQUAL(Compare(wg3, pki, scope, fCompareOverlapping), eOverlap);
199  BOOST_CHECK_EQUAL(Compare(pki, wg3, scope, fCompareOverlapping), eOverlap);
200 
201  pki.SetPacked_int().Set().clear();
202  pki.SetPacked_int().AddInterval(gi2, 0, 1441);
203  pki.SetPacked_int().AddInterval(gi3, 0, 374);
204  BOOST_CHECK_EQUAL(Compare(wg2, pki, scope, fCompareOverlapping), eContained);
205  BOOST_CHECK_EQUAL(Compare(pki, wg2, scope, fCompareOverlapping), eContains);
206  BOOST_CHECK_EQUAL(Compare(wg3, pki, scope, fCompareOverlapping), eContained);
207  BOOST_CHECK_EQUAL(Compare(pki, wg3, scope, fCompareOverlapping), eContains);
208 }
209 
210 
211 BOOST_AUTO_TEST_CASE(Test_Compare_whole_vs_point)
212 {
213  CScope* scope = &GetScope();
214 
215  CSeq_loc wg2, wg3;
216  wg2.SetWhole().SetGi(2);
217  wg3.SetWhole().SetGi(3);
218 
219  CRef<CSeq_loc> pt = MakePoint(2, 10);
220  BOOST_CHECK_EQUAL(Compare(wg2, *pt, scope, fCompareOverlapping), eContains);
221  BOOST_CHECK_EQUAL(Compare(*pt, wg2, scope, fCompareOverlapping), eContained);
222  BOOST_CHECK_EQUAL(Compare(wg3, *pt, scope, fCompareOverlapping), eNoOverlap);
223  BOOST_CHECK_EQUAL(Compare(*pt, wg3, scope, fCompareOverlapping), eNoOverlap);
224 }
225 
226 
227 BOOST_AUTO_TEST_CASE(Test_Compare_whole_vs_packed_point)
228 {
229  CScope* scope = &GetScope();
230 
231  CSeq_loc wg2, wg3, wl2, wl3;
232  wg2.SetWhole().SetGi(2);
233  wg3.SetWhole().SetGi(3);
234  wl2.SetWhole().SetLocal().SetStr("local2");
235  wl3.SetWhole().SetLocal().SetStr("local3");
236 
237  CSeq_loc pp;
238  pp.SetPacked_pnt().SetId().SetGi(2);
239  pp.SetPacked_pnt().AddPoint(10);
240  pp.SetPacked_pnt().AddPoint(20);
241  pp.SetPacked_pnt().AddPoint(30);
242  BOOST_CHECK_EQUAL(Compare(wg2, pp, scope, fCompareOverlapping), eContains);
243  BOOST_CHECK_EQUAL(Compare(pp, wg2, scope, fCompareOverlapping), eContained);
244  BOOST_CHECK_EQUAL(Compare(wl3, pp, scope, fCompareOverlapping), eNoOverlap);
245  BOOST_CHECK_EQUAL(Compare(pp, wl3, scope, fCompareOverlapping), eNoOverlap);
246 }
247 
248 
249 BOOST_AUTO_TEST_CASE(Test_Compare_whole_vs_mix)
250 {
251  CScope* scope = &GetScope();
252 
253  CSeq_loc w;
254  w.SetWhole().SetGi(2);
255 
256  // Check some basic cases
257  CSeq_loc mix;
258  mix.SetMix().Set().push_back(MakeInterval(3, 10, 20));
259  BOOST_CHECK_EQUAL(Compare(w, mix, scope, fCompareOverlapping), eNoOverlap);
260 
261  mix.SetMix().Set().clear();
262  mix.SetMix().Set().push_back(MakeInterval(2, 10, 20));
263  BOOST_CHECK_EQUAL(Compare(w, mix, scope, fCompareOverlapping), eContains);
264  BOOST_CHECK_EQUAL(Compare(mix, w, scope, fCompareOverlapping), eContained);
265 
266  mix.SetMix().Set().clear();
267  mix.SetMix().Set().push_back(MakeInterval(2, 10, 20));
268  mix.SetMix().Set().push_back(MakeInterval(2, 30, 40));
269  BOOST_CHECK_EQUAL(Compare(w, mix, scope, fCompareOverlapping), eContains);
270  BOOST_CHECK_EQUAL(Compare(mix, w, scope, fCompareOverlapping), eContained);
271 
272  mix.SetMix().Set().clear();
273  mix.SetMix().Set().push_back(MakeInterval(2, 10, 20));
274  mix.SetMix().Set().push_back(MakeInterval(3, 30, 40));
275  BOOST_CHECK_EQUAL(Compare(w, mix, scope, fCompareOverlapping), eOverlap);
276  BOOST_CHECK_EQUAL(Compare(mix, w, scope, fCompareOverlapping), eOverlap);
277 
278  mix.SetMix().Set().clear();
279  mix.SetMix().Set().push_back(MakeInterval(2, 0, 1441));
280  mix.SetMix().Set().push_back(MakeInterval(3, 30, 40));
281  BOOST_CHECK_EQUAL(Compare(w, mix, scope, fCompareOverlapping), eContained);
282  BOOST_CHECK_EQUAL(Compare(mix, w, scope, fCompareOverlapping), eContains);
283 
284  mix.SetMix().Set().clear();
285  mix.SetMix().Set().push_back(MakeInterval(2, 0, 1441));
286  CRef<CSeq_loc> sub(new CSeq_loc);
287  sub->SetWhole().SetGi(2);
288  mix.SetMix().Set().push_back(sub);
289  BOOST_CHECK_EQUAL(Compare(w, mix, scope, fCompareOverlapping), eContains);
290  BOOST_CHECK_EQUAL(Compare(mix, w, scope, fCompareOverlapping), eContains);
291 }
292 
293 
294 BOOST_AUTO_TEST_CASE(Test_Compare_whole_vs_bond)
295 {
296  CScope* scope = &GetScope();
297 
298  CSeq_loc wg2, wg3;
299  wg2.SetWhole().SetGi(2);
300  wg3.SetWhole().SetGi(3);
301 
302  // B not set
303  CRef<CSeq_loc> bond = MakeBond(2, 10);
304  BOOST_CHECK_EQUAL(Compare(wg2, *bond, scope, fCompareOverlapping), eContains);
305  BOOST_CHECK_EQUAL(Compare(*bond, wg2, scope, fCompareOverlapping), eContained);
306  BOOST_CHECK_EQUAL(Compare(wg3, *bond, scope, fCompareOverlapping), eNoOverlap);
307  BOOST_CHECK_EQUAL(Compare(*bond, wg3, scope, fCompareOverlapping), eNoOverlap);
308 
309  // A and B on different bioseqs
310  bond = MakeBond(2, 10, 3, 20);
311  BOOST_CHECK_EQUAL(Compare(wg2, *bond, scope, fCompareOverlapping), eOverlap);
312  BOOST_CHECK_EQUAL(Compare(*bond, wg2, scope, fCompareOverlapping), eOverlap);
313  BOOST_CHECK_EQUAL(Compare(wg3, *bond, scope, fCompareOverlapping), eOverlap);
314  BOOST_CHECK_EQUAL(Compare(*bond, wg3, scope, fCompareOverlapping), eOverlap);
315 
316  // A and B on the same bioseq
317  bond = MakeBond(2, 10, 2, 20);
318  BOOST_CHECK_EQUAL(Compare(wg2, *bond, scope, fCompareOverlapping), eContains);
319  BOOST_CHECK_EQUAL(Compare(*bond, wg2, scope, fCompareOverlapping), eContained);
320  BOOST_CHECK_EQUAL(Compare(wg3, *bond, scope, fCompareOverlapping), eNoOverlap);
321  BOOST_CHECK_EQUAL(Compare(*bond, wg3, scope, fCompareOverlapping), eNoOverlap);
322 }
323 
324 
325 BOOST_AUTO_TEST_CASE(Test_Compare_interval_vs_interval)
326 {
327  CScope* scope = &GetScope();
328 
329  CRef<CSeq_loc> i2 = MakeInterval(2, 10, 20);
330  CRef<CSeq_loc> i3 = MakeInterval(3, 10, 20);
331 
332  CRef<CSeq_loc> i = MakeInterval(2, 25, 35);
333  // No overlap
334  BOOST_CHECK_EQUAL(Compare(*i2, *i, scope, fCompareOverlapping), eNoOverlap);
335 
336  // Abutting but not overlapping
337  i = MakeInterval(2, 0, 22);
338  i2 = MakeInterval(2, 23, 40);
339  BOOST_CHECK_EQUAL(Compare(*i2, *i, scope, fCompareOverlapping), eNoOverlap);
340  BOOST_CHECK_EQUAL(Compare(*i, *i2, scope, fCompareOverlapping), eNoOverlap);
341 
342  i2 = MakeInterval(2, 10, 20);
343  i = MakeInterval(2, 5, 15);
344  // Partial overlap
345  BOOST_CHECK_EQUAL(Compare(*i2, *i, scope, fCompareOverlapping), eOverlap);
346  BOOST_CHECK_EQUAL(Compare(*i, *i2, scope, fCompareOverlapping), eOverlap);
347  BOOST_CHECK_EQUAL(Compare(*i3, *i, scope, fCompareOverlapping), eNoOverlap);
348 
349  i = MakeInterval(2, 5, 25);
350  // Contained/contains
351  BOOST_CHECK_EQUAL(Compare(*i2, *i, scope, fCompareOverlapping), eContained);
352  BOOST_CHECK_EQUAL(Compare(*i, *i2, scope, fCompareOverlapping), eContains);
353  i = MakeInterval(2, 10, 25); // same on the right
354  BOOST_CHECK_EQUAL(Compare(*i2, *i, scope, fCompareOverlapping), eContained);
355  BOOST_CHECK_EQUAL(Compare(*i, *i2, scope, fCompareOverlapping), eContains);
356  i = MakeInterval(2, 5, 20); // same on the left
357  BOOST_CHECK_EQUAL(Compare(*i2, *i, scope, fCompareOverlapping), eContained);
358  BOOST_CHECK_EQUAL(Compare(*i, *i2, scope, fCompareOverlapping), eContains);
359 
360  i = MakeInterval(2, 10, 20);
361  // Same
362  BOOST_CHECK_EQUAL(Compare(*i2, *i, scope, fCompareOverlapping), eSame);
363  BOOST_CHECK_EQUAL(Compare(*i, *i2, scope, fCompareOverlapping), eSame);
364 }
365 
366 
367 BOOST_AUTO_TEST_CASE(Test_Compare_interval_vs_packed_interval)
368 {
369  CScope* scope = &GetScope();
370 
371  CRef<CSeq_loc> i2 = MakeInterval(2, 10, 20);
372  CRef<CSeq_loc> i3 = MakeInterval(3, 30, 40);
373 
374  CSeq_id gi2("gi|2");
375  CSeq_id gi3("gi|3");
376 
377  CSeq_loc pki;
378  // Check different combinations of overlaps. Make sure the order
379  // of ranges does not affect the result.
380 
381  // eNoOverlap + eNoOverlap = eNoOverlap
382  pki.SetPacked_int().AddInterval(gi2, 25, 35);
383  pki.SetPacked_int().AddInterval(gi2, 35, 45);
384  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eNoOverlap);
385  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eNoOverlap);
386 
387  // eNoOverlap + eContained = eOverlap
388  pki.SetPacked_int().Set().clear();
389  pki.SetPacked_int().AddInterval(gi2, 1, 5);
390  pki.SetPacked_int().AddInterval(gi2, 11, 19);
391  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eOverlap);
392  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eOverlap);
393  pki.SetPacked_int().Set().reverse();
394  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eOverlap);
395  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eOverlap);
396 
397  // eNoOverlap + eContains = eContains
398  pki.SetPacked_int().Set().clear();
399  pki.SetPacked_int().AddInterval(gi2, 1, 5);
400  pki.SetPacked_int().AddInterval(gi2, 9, 21);
401  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
402  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContained);
403  pki.SetPacked_int().Set().reverse();
404  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
405  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContained);
406 
407  // eNoOverlap + eSame = eContains
408  pki.SetPacked_int().Set().clear();
409  pki.SetPacked_int().AddInterval(gi2, 1, 5);
410  pki.SetPacked_int().AddInterval(gi2, 10, 20);
411  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
412  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContained);
413  pki.SetPacked_int().Set().reverse();
414  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
415  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContained);
416 
417  // eNoOverlap + eOverlap = eOverlap
418  pki.SetPacked_int().Set().clear();
419  pki.SetPacked_int().AddInterval(gi2, 1, 5);
420  pki.SetPacked_int().AddInterval(gi2, 15, 22);
421  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eOverlap);
422  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eOverlap);
423  pki.SetPacked_int().Set().reverse();
424  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eOverlap);
425  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eOverlap);
426 
427  // eContained + eContained = eContained
428  pki.SetPacked_int().Set().clear();
429  pki.SetPacked_int().AddInterval(gi2, 11, 13);
430  pki.SetPacked_int().AddInterval(gi2, 15, 18);
431  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContained);
432  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContains);
433  pki.SetPacked_int().Set().reverse();
434  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContained);
435  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContains);
436 
437  // eContained + eContains = eContains
438  pki.SetPacked_int().Set().clear();
439  pki.SetPacked_int().AddInterval(gi2, 11, 13);
440  pki.SetPacked_int().AddInterval(gi2, 9, 21);
441  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
442  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContained);
443  pki.SetPacked_int().Set().reverse();
444  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
445  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContained);
446 
447  // eContained + eSame = eContains
448  pki.SetPacked_int().Set().clear();
449  pki.SetPacked_int().AddInterval(gi2, 11, 13);
450  pki.SetPacked_int().AddInterval(gi2, 10, 20);
451  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
452  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContains);
453  pki.SetPacked_int().Set().reverse();
454  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
455  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContains);
456 
457  // eContained + eOverlap = eOverlap
458  pki.SetPacked_int().Set().clear();
459  pki.SetPacked_int().AddInterval(gi2, 11, 13);
460  pki.SetPacked_int().AddInterval(gi2, 15, 22);
461  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eOverlap);
462  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eOverlap);
463  pki.SetPacked_int().Set().reverse();
464  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eOverlap);
465  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eOverlap);
466 
467  // eContains + eContains = eContains
468  pki.SetPacked_int().Set().clear();
469  pki.SetPacked_int().AddInterval(gi2, 9, 21);
470  pki.SetPacked_int().AddInterval(gi2, 5, 25);
471  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
472  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContained);
473  pki.SetPacked_int().Set().reverse();
474  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
475  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContained);
476 
477  // eContains + eSame = eContains
478  pki.SetPacked_int().Set().clear();
479  pki.SetPacked_int().AddInterval(gi2, 9, 21);
480  pki.SetPacked_int().AddInterval(gi2, 10, 20);
481  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
482  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContained);
483  pki.SetPacked_int().Set().reverse();
484  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
485  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContained);
486 
487  // eContains + eOverlap = eContains
488  pki.SetPacked_int().Set().clear();
489  pki.SetPacked_int().AddInterval(gi2, 9, 21);
490  pki.SetPacked_int().AddInterval(gi2, 15, 22);
491  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
492  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContained);
493  pki.SetPacked_int().Set().reverse();
494  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
495  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContained);
496 
497  // eSame + eSame = eContains
498  pki.SetPacked_int().Set().clear();
499  pki.SetPacked_int().AddInterval(gi2, 10, 20);
500  pki.SetPacked_int().AddInterval(gi2, 10, 20);
501  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
502  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContains);
503 
504  // eSame + eOverlap = eContains
505  pki.SetPacked_int().Set().clear();
506  pki.SetPacked_int().AddInterval(gi2, 10, 20);
507  pki.SetPacked_int().AddInterval(gi2, 15, 22);
508  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
509  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContained);
510  pki.SetPacked_int().Set().reverse();
511  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
512  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContained);
513 
514  // eOverlap + eOverlap = eOverlap
515  pki.SetPacked_int().Set().clear();
516  pki.SetPacked_int().AddInterval(gi2, 8, 13);
517  pki.SetPacked_int().AddInterval(gi2, 16, 22);
518  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eOverlap);
519  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eOverlap);
520  pki.SetPacked_int().Set().reverse();
521  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eOverlap);
522  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eOverlap);
523 
524  // eNoOverlap + eContains = eContains
525  pki.SetPacked_int().Set().clear();
526  pki.SetPacked_int().AddInterval(gi2, 10, 20);
527  pki.SetPacked_int().AddInterval(gi2, 11, 19);
528  pki.SetPacked_int().AddInterval(gi2, 25, 35);
529  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
530  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContained);
531  pki.SetPacked_int().Set().reverse();
532  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
533  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContained);
534 
535  // eContained + eContains = eContains
536  pki.SetPacked_int().Set().clear();
537  pki.SetPacked_int().AddInterval(gi2, 10, 20);
538  pki.SetPacked_int().AddInterval(gi2, 11, 19);
539  pki.SetPacked_int().AddInterval(gi2, 12, 18);
540  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
541  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContains);
542  pki.SetPacked_int().Set().reverse();
543  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
544  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContains);
545 
546  // eContains + eContains = eContains
547  pki.SetPacked_int().Set().clear();
548  pki.SetPacked_int().AddInterval(gi2, 10, 20);
549  pki.SetPacked_int().AddInterval(gi2, 11, 19);
550  pki.SetPacked_int().AddInterval(gi2, 9, 21);
551  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
552  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContained);
553  pki.SetPacked_int().Set().reverse();
554  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
555  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContained);
556 
557  // eSame + eContains = eContains
558  pki.SetPacked_int().Set().clear();
559  pki.SetPacked_int().AddInterval(gi2, 10, 20);
560  pki.SetPacked_int().AddInterval(gi2, 11, 19);
561  pki.SetPacked_int().AddInterval(gi2, 10, 20);
562  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
563  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContains);
564 
565  // eOverlap + eContains = eContains
566  pki.SetPacked_int().Set().clear();
567  pki.SetPacked_int().AddInterval(gi2, 10, 20);
568  pki.SetPacked_int().AddInterval(gi2, 11, 19);
569  pki.SetPacked_int().AddInterval(gi2, 15, 25);
570  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
571  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContained);
572  pki.SetPacked_int().Set().reverse();
573  BOOST_CHECK_EQUAL(Compare(pki, *i2, scope, fCompareOverlapping), eContains);
574  BOOST_CHECK_EQUAL(Compare(*i2, pki, scope, fCompareOverlapping), eContained);
575 }
576 
577 
578 BOOST_AUTO_TEST_CASE(Test_Compare_interval_vs_point)
579 {
580  CScope* scope = &GetScope();
581 
582  CRef<CSeq_loc> i2 = MakeInterval(2, 10, 20);
583  CRef<CSeq_loc> i3 = MakeInterval(3, 10, 20);
584 
585  CRef<CSeq_loc> pt = MakePoint(2, 5);
586  // No overlap
587  BOOST_CHECK_EQUAL(Compare(*i2, *pt, scope, fCompareOverlapping), eNoOverlap);
588  pt = MakePoint(2, 15);
589  BOOST_CHECK_EQUAL(Compare(*i3, *pt, scope, fCompareOverlapping), eNoOverlap);
590 
591  // Overlap
592  BOOST_CHECK_EQUAL(Compare(*i2, *pt, scope, fCompareOverlapping), eContains);
593  BOOST_CHECK_EQUAL(Compare(*pt, *i2, scope, fCompareOverlapping), eContained);
594 
595  // Same - interval of length 1
596  CRef<CSeq_loc> i1 = MakeInterval(2, 15, 15);
597  BOOST_CHECK_EQUAL(Compare(*pt, *i1, scope, fCompareOverlapping), eSame);
598  BOOST_CHECK_EQUAL(Compare(*i1, *pt, scope, fCompareOverlapping), eSame);
599 }
600 
601 
602 BOOST_AUTO_TEST_CASE(Test_Compare_interval_vs_packed_point)
603 {
604  CScope* scope = &GetScope();
605 
606  CRef<CSeq_loc> i2 = MakeInterval(2, 10, 20);
607  CRef<CSeq_loc> i3 = MakeInterval(3, 10, 20);
608 
609  CSeq_loc pp;
610  pp.SetPacked_pnt().SetId().SetGi(2);
611  pp.SetPacked_pnt().AddPoint(5);
612 
613  // No overlap
614  BOOST_CHECK_EQUAL(Compare(*i2, pp, scope, fCompareOverlapping), eNoOverlap);
615  pp.SetPacked_pnt().SetPoints().front() = 15;
616  BOOST_CHECK_EQUAL(Compare(*i3, pp, scope, fCompareOverlapping), eNoOverlap);
617 
618  // Contained in the interval
619  BOOST_CHECK_EQUAL(Compare(*i2, pp, scope, fCompareOverlapping), eContains);
620  BOOST_CHECK_EQUAL(Compare(pp, *i2, scope, fCompareOverlapping), eContained);
621 
622  // Overlap
623  pp.SetPacked_pnt().AddPoint(5);
624  pp.SetPacked_pnt().AddPoint(25);
625  BOOST_CHECK_EQUAL(Compare(*i2, pp, scope, fCompareOverlapping), eOverlap);
626  BOOST_CHECK_EQUAL(Compare(pp, *i2, scope, fCompareOverlapping), eOverlap);
627 }
628 
629 
630 BOOST_AUTO_TEST_CASE(Test_Compare_interval_vs_mix)
631 {
632  CScope* scope = &GetScope();
633 
634  CRef<CSeq_loc> i = MakeInterval(2, 20, 80);
635 
636  CSeq_loc mix;
637  CRef<CSeq_loc> sub, sub2;
638 
639  mix.SetMix().Set().push_back(MakeInterval(3, 10, 90));
640  BOOST_CHECK_EQUAL(Compare(*i, mix, scope, fCompareOverlapping), eNoOverlap);
641  BOOST_CHECK_EQUAL(Compare(mix, *i, scope, fCompareOverlapping), eNoOverlap);
642 
643  // Whole
644  mix.SetMix().Set().clear();
645  sub.Reset(new CSeq_loc);
646  sub->SetWhole().SetGi(2);
647  mix.SetMix().Set().push_back(sub);
648  BOOST_CHECK_EQUAL(Compare(*i, mix, scope, fCompareOverlapping), eContained);
649  BOOST_CHECK_EQUAL(Compare(mix, *i, scope, fCompareOverlapping), eContains);
650 
651  // Points
652  mix.SetMix().Set().clear();
653  mix.SetMix().Set().push_back(MakePoint(2, 50));
654  BOOST_CHECK_EQUAL(Compare(*i, mix, scope, fCompareOverlapping), eContains);
655  BOOST_CHECK_EQUAL(Compare(mix, *i, scope, fCompareOverlapping), eContained);
656  mix.SetMix().Set().push_back(MakePoint(2, 60));
657  BOOST_CHECK_EQUAL(Compare(*i, mix, scope, fCompareOverlapping), eContains);
658  BOOST_CHECK_EQUAL(Compare(mix, *i, scope, fCompareOverlapping), eContained);
659  mix.SetMix().Set().push_back(MakePoint(2, 150));
660  BOOST_CHECK_EQUAL(Compare(*i, mix, scope, fCompareOverlapping), eOverlap);
661  BOOST_CHECK_EQUAL(Compare(mix, *i, scope, fCompareOverlapping), eOverlap);
662 
663  // Packed points - some more complicated cases
664  mix.SetMix().Set().clear();
665  sub.Reset(new CSeq_loc);
666  sub->SetPacked_pnt().SetId().SetGi(2);
667  sub->SetPacked_pnt().AddPoint(30);
668  sub->SetPacked_pnt().AddPoint(60);
669  mix.SetMix().Set().push_back(sub);
670  BOOST_CHECK_EQUAL(Compare(*i, mix, scope, fCompareOverlapping), eContains);
671  BOOST_CHECK_EQUAL(Compare(mix, *i, scope, fCompareOverlapping), eContained);
672  sub2.Reset(new CSeq_loc);
673  sub2->SetPacked_pnt().SetId().SetGi(2);
674  sub2->SetPacked_pnt().AddPoint(10);
675  sub2->SetPacked_pnt().AddPoint(50);
676  mix.SetMix().Set().push_back(sub2);
677  BOOST_CHECK_EQUAL(Compare(*i, mix, scope, fCompareOverlapping), eOverlap);
678  BOOST_CHECK_EQUAL(Compare(mix, *i, scope, fCompareOverlapping), eOverlap);
679 
680  // Intervals
681  mix.SetMix().Set().clear();
682  mix.SetMix().Set().push_back(MakeInterval(2, 10, 15));
683  mix.SetMix().Set().push_back(MakeInterval(2, 85, 90));
684  BOOST_CHECK_EQUAL(Compare(*i, mix, scope, fCompareOverlapping), eNoOverlap);
685  BOOST_CHECK_EQUAL(Compare(mix, *i, scope, fCompareOverlapping), eNoOverlap);
686 
687  mix.SetMix().Set().clear();
688  mix.SetMix().Set().push_back(MakeInterval(2, 20, 25));
689  mix.SetMix().Set().push_back(MakeInterval(2, 55, 70));
690  BOOST_CHECK_EQUAL(Compare(*i, mix, scope, fCompareOverlapping), eContains);
691  BOOST_CHECK_EQUAL(Compare(mix, *i, scope, fCompareOverlapping), eContained);
692 
693  mix.SetMix().Set().clear();
694  mix.SetMix().Set().push_back(MakeInterval(2, 10, 35));
695  mix.SetMix().Set().push_back(MakeInterval(2, 70, 90));
696  BOOST_CHECK_EQUAL(Compare(*i, mix, scope, fCompareOverlapping), eOverlap);
697  BOOST_CHECK_EQUAL(Compare(mix, *i, scope, fCompareOverlapping), eOverlap);
698 
699  // This results in eOverlap although the mix covers the whole interval.
700  mix.SetMix().Set().clear();
701  mix.SetMix().Set().push_back(MakeInterval(2, 10, 55));
702  mix.SetMix().Set().push_back(MakeInterval(2, 50, 90));
703  BOOST_CHECK_EQUAL(Compare(*i, mix, scope, fCompareOverlapping), eOverlap);
704  BOOST_CHECK_EQUAL(Compare(mix, *i, scope, fCompareOverlapping), eOverlap);
705 
706  mix.SetMix().Set().clear();
707  mix.SetMix().Set().push_back(MakeInterval(2, 10, 30));
708  mix.SetMix().Set().push_back(MakeInterval(2, 10, 90));
709  mix.SetMix().Set().push_back(MakeInterval(2, 70, 90));
710  BOOST_CHECK_EQUAL(Compare(*i, mix, scope, fCompareOverlapping), eContained);
711  BOOST_CHECK_EQUAL(Compare(mix, *i, scope, fCompareOverlapping), eContains);
712 
713  mix.SetMix().Set().clear();
714  mix.SetMix().Set().push_back(MakeInterval(2, 20, 30));
715  mix.SetMix().Set().push_back(MakeInterval(2, 20, 80));
716  mix.SetMix().Set().push_back(MakeInterval(2, 70, 80));
717  BOOST_CHECK_EQUAL(Compare(*i, mix, scope, fCompareOverlapping), eContains);
718  BOOST_CHECK_EQUAL(Compare(mix, *i, scope, fCompareOverlapping), eContains);
719 
720  // Packed intervals
721  mix.SetMix().Set().clear();
722  sub.Reset(new CSeq_loc);
723  sub->SetPacked_int().Set().push_back(
724  Ref(&MakeInterval(2, 10, 30)->SetInt()));
725  sub->SetPacked_int().Set().push_back(
726  Ref(&MakeInterval(2, 40, 60)->SetInt()));
727  sub->SetPacked_int().Set().push_back(
728  Ref(&MakeInterval(2, 70, 90)->SetInt()));
729  mix.SetMix().Set().push_back(sub);
730  BOOST_CHECK_EQUAL(Compare(*i, mix, scope, fCompareOverlapping), eOverlap);
731  BOOST_CHECK_EQUAL(Compare(mix, *i, scope, fCompareOverlapping), eOverlap);
732 
733  mix.SetMix().Set().clear();
734  sub.Reset(new CSeq_loc);
735  sub->SetPacked_int().Set().push_back(
736  Ref(&MakeInterval(3, 10, 30)->SetInt()));
737  sub->SetPacked_int().Set().push_back(
738  Ref(&MakeInterval(2, 10, 90)->SetInt()));
739  sub->SetPacked_int().Set().push_back(
740  Ref(&MakeInterval(2, 70, 90)->SetInt()));
741  mix.SetMix().Set().push_back(sub);
742  try {
743  Compare(*i, mix, scope, fCompareOverlapping);
744  }
745  catch (...) {
746  }
747  BOOST_CHECK_EQUAL(Compare(*i, mix, scope, fCompareOverlapping), eContained);
748  BOOST_CHECK_EQUAL(Compare(mix, *i, scope, fCompareOverlapping), eContains);
749 
750  // Mixed sub-location types
751  mix.SetMix().Set().clear();
752  sub.Reset(new CSeq_loc);
753  sub->SetPnt().SetId().SetGi(2);
754  sub->SetPnt().SetPoint(30);
755  mix.SetMix().Set().push_back(MakePoint(2, 30));
756  mix.SetMix().Set().push_back(MakeInterval(2, 35, 40));
757  sub.Reset(new CSeq_loc);
758  sub->SetPacked_int().Set().push_back(
759  Ref(&MakeInterval(2, 45, 50)->SetInt()));
760  sub->SetPacked_int().Set().push_back(
761  Ref(&MakeInterval(2, 50, 55)->SetInt()));
762  mix.SetMix().Set().push_back(sub);
763  BOOST_CHECK_EQUAL(Compare(*i, mix, scope, fCompareOverlapping), eContains);
764  BOOST_CHECK_EQUAL(Compare(mix, *i, scope, fCompareOverlapping), eContained);
765 
766  mix.SetMix().Set().clear();
767  mix.SetMix().Set().push_back(MakeInterval(2, 10, 90));
768  sub.Reset(new CSeq_loc);
769  sub->SetPacked_int().Set().push_back(
770  Ref(&MakeInterval(2, 40, 50)->SetInt()));
771  sub->SetPacked_int().Set().push_back(
772  Ref(&MakeInterval(2, 50, 85)->SetInt()));
773  mix.SetMix().Set().push_back(sub);
774  BOOST_CHECK_EQUAL(Compare(*i, mix, scope, fCompareOverlapping), eContained);
775  BOOST_CHECK_EQUAL(Compare(mix, *i, scope, fCompareOverlapping), eContains);
776 
777  mix.SetMix().Set().clear();
778  sub.Reset(new CSeq_loc);
779  mix.SetMix().Set().push_back(MakeInterval(2, 40, 50));
780  mix.SetMix().Set().push_back(MakeInterval(2, 60, 70));
781  mix.SetMix().Set().push_back(sub);
782  mix.SetMix().Set().push_back(MakeBond(2, 50, 3, 40));
783  BOOST_CHECK_EQUAL(Compare(*i, mix, scope, fCompareOverlapping), eOverlap);
784  BOOST_CHECK_EQUAL(Compare(mix, *i, scope, fCompareOverlapping), eOverlap);
785 }
786 
787 
788 BOOST_AUTO_TEST_CASE(Test_Compare_interval_vs_bond)
789 {
790  CScope* scope = &GetScope();
791 
792  CRef<CSeq_loc> bA2 = MakeBond(2, 10);
793  CRef<CSeq_loc> bA3 = MakeBond(3, 10);
794  CRef<CSeq_loc> bA2B3 = MakeBond(2, 10, 3, 20);
795  CRef<CSeq_loc> bA3B2 = MakeBond(3, 20, 2, 10);
796  CRef<CSeq_loc> bA2B2 = MakeBond(2, 10, 2, 20);
797 
798  CRef<CSeq_loc> i = MakeInterval(2, 15, 25);
799  // No overlap
800  BOOST_CHECK_EQUAL(Compare(*bA2, *i, scope, fCompareOverlapping), eNoOverlap);
801 
802  i = MakeInterval(2, 5, 15);
803  // Overlap with one point (no B)
804  BOOST_CHECK_EQUAL(Compare(*bA2, *i, scope, fCompareOverlapping), eContained);
805  BOOST_CHECK_EQUAL(Compare(*i, *bA2, scope, fCompareOverlapping), eContains);
806  // Overlap with only one of A or B
807  BOOST_CHECK_EQUAL(Compare(*bA2B3, *i, scope, fCompareOverlapping), eOverlap);
808  BOOST_CHECK_EQUAL(Compare(*i, *bA2B3, scope, fCompareOverlapping), eOverlap);
809  BOOST_CHECK_EQUAL(Compare(*bA3B2, *i, scope, fCompareOverlapping), eOverlap);
810  BOOST_CHECK_EQUAL(Compare(*i, *bA3B2, scope, fCompareOverlapping), eOverlap);
811  // B is on the same bioseq but out of range
812  BOOST_CHECK_EQUAL(Compare(*bA2B2, *i, scope, fCompareOverlapping), eOverlap);
813  BOOST_CHECK_EQUAL(Compare(*i, *bA2B2, scope, fCompareOverlapping), eOverlap);
814 
815  i = MakeInterval(2, 5, 25);
816  // Overlap with both A and B
817  BOOST_CHECK_EQUAL(Compare(*bA2B2, *i, scope, fCompareOverlapping), eContained);
818  BOOST_CHECK_EQUAL(Compare(*i, *bA2B2, scope, fCompareOverlapping), eContains);
819 }
820 
821 
822 BOOST_AUTO_TEST_CASE(Test_Compare_packed_interval_vs_packed_interval)
823 {
824  CScope* scope = &GetScope();
825 
826  CSeq_id gi2("gi|2");
827  CSeq_id gi3("gi|3");
828  CSeq_id lcl2;
829  lcl2.SetLocal().SetStr("local2");
830 
831  CSeq_loc pk1, pk2;
832 
833  // Complicated case: although different seq-ids are used in both
834  // locations and the order is wrong, eSame should be returned.
835  pk1.SetPacked_int().AddInterval(gi2, 10, 20);
836  pk1.SetPacked_int().AddInterval(lcl2, 30, 40);
837  pk2.SetPacked_int().AddInterval(gi2, 30, 40);
838  pk2.SetPacked_int().AddInterval(lcl2, 10, 20);
839  BOOST_CHECK_EQUAL(Compare(pk1, pk2, scope, fCompareOverlapping), eSame);
840  BOOST_CHECK_EQUAL(Compare(pk2, pk1, scope, fCompareOverlapping), eSame);
841 
842  pk1.SetPacked_int().Set().clear();
843  pk1.SetPacked_int().AddInterval(gi2, 10, 20);
844  pk1.SetPacked_int().AddInterval(gi2, 30, 40);
845  pk2.SetPacked_int().Set().clear();
846  pk2.SetPacked_int().AddInterval(gi3, 10, 20);
847  pk2.SetPacked_int().AddInterval(gi2, 50, 60);
848  BOOST_CHECK_EQUAL(Compare(pk1, pk2, scope, fCompareOverlapping), eNoOverlap);
849 
850  pk1.SetPacked_int().Set().clear();
851  pk1.SetPacked_int().AddInterval(gi2, 15, 20);
852  pk1.SetPacked_int().AddInterval(gi2, 60, 70);
853  pk2.SetPacked_int().Set().clear();
854  pk2.SetPacked_int().AddInterval(gi2, 5, 10);
855  pk2.SetPacked_int().AddInterval(gi2, 50, 55);
856  BOOST_CHECK_EQUAL(Compare(pk1, pk2, scope, fCompareOverlapping), eNoOverlap);
857 
858  pk1.SetPacked_int().Set().clear();
859  pk1.SetPacked_int().AddInterval(gi2, 10, 40);
860  pk1.SetPacked_int().AddInterval(gi2, 60, 90);
861  pk2.SetPacked_int().Set().clear();
862  pk2.SetPacked_int().AddInterval(gi2, 20, 30);
863  pk2.SetPacked_int().AddInterval(gi2, 70, 80);
864  BOOST_CHECK_EQUAL(Compare(pk1, pk2, scope, fCompareOverlapping), eContains);
865  BOOST_CHECK_EQUAL(Compare(pk2, pk1, scope, fCompareOverlapping), eContained);
866  pk2.SetPacked_int().Set().reverse();
867  BOOST_CHECK_EQUAL(Compare(pk1, pk2, scope, fCompareOverlapping), eContains);
868  BOOST_CHECK_EQUAL(Compare(pk2, pk1, scope, fCompareOverlapping), eContained);
869 
870  pk1.SetPacked_int().Set().clear();
871  pk1.SetPacked_int().AddInterval(gi2, 10, 40);
872  pk1.SetPacked_int().AddInterval(gi3, 60, 90);
873  pk2.SetPacked_int().Set().clear();
874  pk2.SetPacked_int().AddInterval(gi2, 20, 30);
875  pk2.SetPacked_int().AddInterval(gi3, 70, 80);
876  BOOST_CHECK_EQUAL(Compare(pk1, pk2, scope, fCompareOverlapping), eContains);
877  BOOST_CHECK_EQUAL(Compare(pk2, pk1, scope, fCompareOverlapping), eContained);
878  pk2.SetPacked_int().Set().reverse();
879  BOOST_CHECK_EQUAL(Compare(pk1, pk2, scope, fCompareOverlapping), eContains);
880  BOOST_CHECK_EQUAL(Compare(pk2, pk1, scope, fCompareOverlapping), eContained);
881 
882  pk1.SetPacked_int().Set().clear();
883  pk1.SetPacked_int().AddInterval(gi2, 10, 40);
884  pk1.SetPacked_int().AddInterval(gi2, 50, 70);
885  pk2.SetPacked_int().Set().clear();
886  pk2.SetPacked_int().AddInterval(gi2, 20, 30);
887  pk2.SetPacked_int().AddInterval(gi2, 60, 80);
888  BOOST_CHECK_EQUAL(Compare(pk1, pk2, scope, fCompareOverlapping), eOverlap);
889  BOOST_CHECK_EQUAL(Compare(pk2, pk1, scope, fCompareOverlapping), eOverlap);
890  pk2.SetPacked_int().Set().reverse();
891  BOOST_CHECK_EQUAL(Compare(pk1, pk2, scope, fCompareOverlapping), eOverlap);
892  BOOST_CHECK_EQUAL(Compare(pk2, pk1, scope, fCompareOverlapping), eOverlap);
893 
894  pk1.SetPacked_int().Set().clear();
895  pk1.SetPacked_int().AddInterval(gi2, 10, 20);
896  pk1.SetPacked_int().AddInterval(gi2, 50, 70);
897  pk2.SetPacked_int().Set().clear();
898  pk2.SetPacked_int().AddInterval(gi2, 10, 20);
899  pk2.SetPacked_int().AddInterval(gi2, 60, 80);
900  BOOST_CHECK_EQUAL(Compare(pk1, pk2, scope, fCompareOverlapping), eOverlap);
901  BOOST_CHECK_EQUAL(Compare(pk2, pk1, scope, fCompareOverlapping), eOverlap);
902  pk2.SetPacked_int().Set().reverse();
903  BOOST_CHECK_EQUAL(Compare(pk1, pk2, scope, fCompareOverlapping), eOverlap);
904  BOOST_CHECK_EQUAL(Compare(pk2, pk1, scope, fCompareOverlapping), eOverlap);
905 
906  pk1.SetPacked_int().Set().clear();
907  pk1.SetPacked_int().AddInterval(gi2, 10, 20);
908  pk1.SetPacked_int().AddInterval(gi2, 30, 40);
909  pk2.SetPacked_int().Set().clear();
910  pk2.SetPacked_int().AddInterval(gi2, 10, 20);
911  pk2.SetPacked_int().AddInterval(gi2, 30, 40);
912  BOOST_CHECK_EQUAL(Compare(pk1, pk2, scope, fCompareOverlapping), eSame);
913  BOOST_CHECK_EQUAL(Compare(pk2, pk1, scope, fCompareOverlapping), eSame);
914  // The order does not matter.
915  pk2.SetPacked_int().Set().reverse();
916  BOOST_CHECK_EQUAL(Compare(pk1, pk2, scope, fCompareOverlapping), eSame);
917  BOOST_CHECK_EQUAL(Compare(pk2, pk1, scope, fCompareOverlapping), eSame);
918 
919  pk1.SetPacked_int().Set().clear();
920  pk1.SetPacked_int().AddInterval(gi2, 10, 20);
921  pk1.SetPacked_int().AddInterval(gi2, 10, 90);
922  pk1.SetPacked_int().AddInterval(gi2, 80, 90);
923  pk2.SetPacked_int().Set().clear();
924  pk2.SetPacked_int().AddInterval(gi2, 10, 90);
925  pk2.SetPacked_int().AddInterval(gi2, 50, 60);
926  BOOST_CHECK_EQUAL(Compare(pk1, pk2, scope, fCompareOverlapping), eContains);
927  BOOST_CHECK_EQUAL(Compare(pk2, pk1, scope, fCompareOverlapping), eContains);
928  pk2.SetPacked_int().Set().reverse();
929  BOOST_CHECK_EQUAL(Compare(pk1, pk2, scope, fCompareOverlapping), eContains);
930  BOOST_CHECK_EQUAL(Compare(pk2, pk1, scope, fCompareOverlapping), eContains);
931 
932  pk1.SetPacked_int().Set().clear();
933  pk1.SetPacked_int().AddInterval(gi2, 10, 19);
934  pk1.SetPacked_int().AddInterval(gi3, 20, 29);
935  pk2.SetPacked_int().Set().clear();
936  pk2.SetPacked_int().AddInterval(gi2, 20, 29);
937  pk2.SetPacked_int().AddInterval(gi3, 10, 19);
938  BOOST_CHECK_EQUAL(Compare(pk1, pk2, scope, fCompareOverlapping), eNoOverlap);
939  BOOST_CHECK_EQUAL(Compare(pk2, pk1, scope, fCompareOverlapping), eNoOverlap);
940  pk2.SetPacked_int().Set().reverse();
941  BOOST_CHECK_EQUAL(Compare(pk1, pk2, scope, fCompareOverlapping), eNoOverlap);
942  BOOST_CHECK_EQUAL(Compare(pk2, pk1, scope, fCompareOverlapping), eNoOverlap);
943 }
944 
945 
946 BOOST_AUTO_TEST_CASE(Test_Compare_packed_interval_vs_point)
947 {
948  CScope* scope = &GetScope();
949 
950  CRef<CSeq_loc> pt = MakePoint(2, 15);
951 
952  CSeq_id gi2("gi|2");
953  CSeq_loc pki;
954 
955  pki.SetPacked_int().AddInterval(gi2, 1, 5);
956  BOOST_CHECK_EQUAL(Compare(pki, *pt, scope, fCompareOverlapping), eNoOverlap);
957  BOOST_CHECK_EQUAL(Compare(*pt, pki, scope, fCompareOverlapping), eNoOverlap);
958  pki.SetPacked_int().AddInterval(gi2, 20, 25);
959  BOOST_CHECK_EQUAL(Compare(pki, *pt, scope, fCompareOverlapping), eNoOverlap);
960  BOOST_CHECK_EQUAL(Compare(*pt, pki, scope, fCompareOverlapping), eNoOverlap);
961 
962  pki.SetPacked_int().Set().clear();
963  pki.SetPacked_int().AddInterval(gi2, 10, 20);
964  BOOST_CHECK_EQUAL(Compare(pki, *pt, scope, fCompareOverlapping), eContains);
965  BOOST_CHECK_EQUAL(Compare(*pt, pki, scope, fCompareOverlapping), eContained);
966 
967  pki.SetPacked_int().Set().clear();
968  pki.SetPacked_int().AddInterval(gi2, 15, 15);
969  BOOST_CHECK_EQUAL(Compare(pki, *pt, scope, fCompareOverlapping), eSame);
970  BOOST_CHECK_EQUAL(Compare(*pt, pki, scope, fCompareOverlapping), eSame);
971 
972  pki.SetPacked_int().AddInterval(gi2, 15, 15);
973  BOOST_CHECK_EQUAL(Compare(pki, *pt, scope, fCompareOverlapping), eContains);
974  BOOST_CHECK_EQUAL(Compare(*pt, pki, scope, fCompareOverlapping), eContains);
975 }
976 
977 
978 BOOST_AUTO_TEST_CASE(Test_Compare_packed_interval_vs_packed_point)
979 {
980  CScope* scope = &GetScope();
981 
982  CSeq_loc pkp;
983  pkp.SetPacked_pnt().SetId().SetGi(2);
984  pkp.SetPacked_pnt().AddPoint(15);
985 
986  CSeq_id gi2("gi|2");
987  CSeq_id gi3("gi|3");
988 
989  CSeq_loc pki;
990 
991  pki.SetPacked_int().AddInterval(gi2, 1, 5);
992  BOOST_CHECK_EQUAL(Compare(pki, pkp, scope, fCompareOverlapping), eNoOverlap);
993  BOOST_CHECK_EQUAL(Compare(pkp, pki, scope, fCompareOverlapping), eNoOverlap);
994  pki.SetPacked_int().AddInterval(gi2, 20, 25);
995  BOOST_CHECK_EQUAL(Compare(pki, pkp, scope, fCompareOverlapping), eNoOverlap);
996  BOOST_CHECK_EQUAL(Compare(pkp, pki, scope, fCompareOverlapping), eNoOverlap);
997 
998  pki.SetPacked_int().Set().clear();
999  pki.SetPacked_int().AddInterval(gi2, 10, 20);
1000  BOOST_CHECK_EQUAL(Compare(pki, pkp, scope, fCompareOverlapping), eContains);
1001  BOOST_CHECK_EQUAL(Compare(pkp, pki, scope, fCompareOverlapping), eContained);
1002 
1003  pki.SetPacked_int().Set().clear();
1004  pki.SetPacked_int().AddInterval(gi2, 15, 15);
1005  BOOST_CHECK_EQUAL(Compare(pki, pkp, scope, fCompareOverlapping), eSame);
1006  BOOST_CHECK_EQUAL(Compare(pkp, pki, scope, fCompareOverlapping), eSame);
1007 
1008  pki.SetPacked_int().AddInterval(gi2, 15, 15);
1009  BOOST_CHECK_EQUAL(Compare(pki, pkp, scope, fCompareOverlapping), eContains);
1010  BOOST_CHECK_EQUAL(Compare(pkp, pki, scope, fCompareOverlapping), eContains);
1011 
1012  pki.SetPacked_int().AddInterval(gi2, 25, 25);
1013  BOOST_CHECK_EQUAL(Compare(pki, pkp, scope, fCompareOverlapping), eContains);
1014  BOOST_CHECK_EQUAL(Compare(pkp, pki, scope, fCompareOverlapping), eContained);
1015 
1016  pkp.SetPacked_pnt().AddPoint(25);
1017 
1018  pki.SetPacked_int().Set().clear();
1019  pki.SetPacked_int().AddInterval(gi2, 17, 23);
1020  BOOST_CHECK_EQUAL(Compare(pki, pkp, scope, fCompareOverlapping), eNoOverlap);
1021  BOOST_CHECK_EQUAL(Compare(pkp, pki, scope, fCompareOverlapping), eNoOverlap);
1022 
1023  pki.SetPacked_int().Set().clear();
1024  pki.SetPacked_int().AddInterval(gi2, 10, 30);
1025  BOOST_CHECK_EQUAL(Compare(pki, pkp, scope, fCompareOverlapping), eContains);
1026  BOOST_CHECK_EQUAL(Compare(pkp, pki, scope, fCompareOverlapping), eContained);
1027 
1028  pki.SetPacked_int().Set().clear();
1029  pki.SetPacked_int().AddInterval(gi2, 10, 20);
1030  pki.SetPacked_int().AddInterval(gi2, 30, 40);
1031  BOOST_CHECK_EQUAL(Compare(pki, pkp, scope, fCompareOverlapping), eOverlap);
1032  BOOST_CHECK_EQUAL(Compare(pkp, pki, scope, fCompareOverlapping), eOverlap);
1033 
1034  pki.SetPacked_int().Set().clear();
1035  pki.SetPacked_int().AddInterval(gi2, 5, 10);
1036  pki.SetPacked_int().AddInterval(gi2, 20, 30);
1037  BOOST_CHECK_EQUAL(Compare(pki, pkp, scope, fCompareOverlapping), eOverlap);
1038  BOOST_CHECK_EQUAL(Compare(pkp, pki, scope, fCompareOverlapping), eOverlap);
1039 
1040  // Complicated case: each interval contains just one of the
1041  // points.
1042  pki.SetPacked_int().Set().clear();
1043  pki.SetPacked_int().AddInterval(gi2, 10, 20);
1044  pki.SetPacked_int().AddInterval(gi2, 21, 30);
1045  BOOST_CHECK_EQUAL(Compare(pki, pkp, scope, fCompareOverlapping), eContains);
1046  BOOST_CHECK_EQUAL(Compare(pkp, pki, scope, fCompareOverlapping), eContained);
1047 
1048  pki.SetPacked_int().Set().clear();
1049  pki.SetPacked_int().AddInterval(gi2, 10, 20);
1050  pki.SetPacked_int().AddInterval(gi2, 20, 30);
1051  BOOST_CHECK_EQUAL(Compare(pki, pkp, scope, fCompareOverlapping), eContains);
1052  BOOST_CHECK_EQUAL(Compare(pkp, pki, scope, fCompareOverlapping), eContained);
1053 
1054  pki.SetPacked_int().Set().clear();
1055  pki.SetPacked_int().AddInterval(gi2, 10, 20);
1056  pki.SetPacked_int().AddInterval(gi3, 20, 30);
1057  BOOST_CHECK_EQUAL(Compare(pki, pkp, scope, fCompareOverlapping), eOverlap);
1058  BOOST_CHECK_EQUAL(Compare(pkp, pki, scope, fCompareOverlapping), eOverlap);
1059 }
1060 
1061 
1062 BOOST_AUTO_TEST_CASE(Test_Compare_packed_interval_vs_mix)
1063 {
1064  CScope* scope = &GetScope();
1065 
1066  CSeq_id gi2("gi|2");
1067  CSeq_id gi3("gi|3");
1068 
1069  CSeq_loc pki;
1070  pki.SetPacked_int().AddInterval(gi2, 20, 80);
1071 
1072  CSeq_loc mix;
1073  CRef<CSeq_loc> sub, sub2;
1074 
1075  mix.SetMix().Set().push_back(MakeInterval(3, 10, 90));
1076  BOOST_CHECK_EQUAL(Compare(pki, mix, scope, fCompareOverlapping), eNoOverlap);
1077  BOOST_CHECK_EQUAL(Compare(mix, pki, scope, fCompareOverlapping), eNoOverlap);
1078 
1079  // Whole
1080  mix.SetMix().Set().clear();
1081  sub.Reset(new CSeq_loc);
1082  sub->SetWhole().SetGi(2);
1083  mix.SetMix().Set().push_back(sub);
1084  BOOST_CHECK_EQUAL(Compare(pki, mix, scope, fCompareOverlapping), eContained);
1085  BOOST_CHECK_EQUAL(Compare(mix, pki, scope, fCompareOverlapping), eContains);
1086 
1087  pki.SetPacked_int().Set().clear();
1088  pki.SetPacked_int().AddInterval(gi2, 0, 1441);
1089  BOOST_CHECK_EQUAL(Compare(pki, mix, scope, fCompareOverlapping), eSame);
1090  BOOST_CHECK_EQUAL(Compare(mix, pki, scope, fCompareOverlapping), eSame);
1091 
1092  // Points
1093  pki.SetPacked_int().Set().clear();
1094  pki.SetPacked_int().AddInterval(gi2, 10, 20);
1095  pki.SetPacked_int().AddInterval(gi2, 30, 40);
1096  mix.SetMix().Set().clear();
1097  mix.SetMix().Set().push_back(MakePoint(2, 15));
1098  BOOST_CHECK_EQUAL(Compare(pki, mix, scope, fCompareOverlapping), eContains);
1099  BOOST_CHECK_EQUAL(Compare(mix, pki, scope, fCompareOverlapping), eContained);
1100  mix.SetMix().Set().push_back(MakePoint(2, 35));
1101  BOOST_CHECK_EQUAL(Compare(pki, mix, scope, fCompareOverlapping), eContains);
1102  BOOST_CHECK_EQUAL(Compare(mix, pki, scope, fCompareOverlapping), eContained);
1103  mix.SetMix().Set().push_back(MakePoint(2, 150));
1104  BOOST_CHECK_EQUAL(Compare(pki, mix, scope, fCompareOverlapping), eOverlap);
1105  BOOST_CHECK_EQUAL(Compare(mix, pki, scope, fCompareOverlapping), eOverlap);
1106 
1107  // Packed points - some more complicated cases
1108  mix.SetMix().Set().clear();
1109  sub.Reset(new CSeq_loc);
1110  sub->SetPacked_pnt().SetId().SetGi(2);
1111  sub->SetPacked_pnt().AddPoint(15);
1112  sub->SetPacked_pnt().AddPoint(33);
1113  mix.SetMix().Set().push_back(sub);
1114  BOOST_CHECK_EQUAL(Compare(pki, mix, scope, fCompareOverlapping), eContains);
1115  BOOST_CHECK_EQUAL(Compare(mix, pki, scope, fCompareOverlapping), eContained);
1116  sub2.Reset(new CSeq_loc);
1117  sub2->SetPacked_pnt().SetId().SetGi(2);
1118  sub2->SetPacked_pnt().AddPoint(5);
1119  sub2->SetPacked_pnt().AddPoint(37);
1120  mix.SetMix().Set().push_back(sub2);
1121  BOOST_CHECK_EQUAL(Compare(pki, mix, scope, fCompareOverlapping), eOverlap);
1122  BOOST_CHECK_EQUAL(Compare(mix, pki, scope, fCompareOverlapping), eOverlap);
1123 
1124  // Intervals
1125  pki.SetPacked_int().Set().clear();
1126  pki.SetPacked_int().AddInterval(gi2, 20, 80);
1127  mix.SetMix().Set().clear();
1128  mix.SetMix().Set().push_back(MakeInterval(2, 10, 15));
1129  mix.SetMix().Set().push_back(MakeInterval(2, 85, 90));
1130  BOOST_CHECK_EQUAL(Compare(pki, mix, scope, fCompareOverlapping), eNoOverlap);
1131  BOOST_CHECK_EQUAL(Compare(mix, pki, scope, fCompareOverlapping), eNoOverlap);
1132 
1133  mix.SetMix().Set().clear();
1134  mix.SetMix().Set().push_back(MakeInterval(2, 20, 25));
1135  mix.SetMix().Set().push_back(MakeInterval(2, 55, 70));
1136  BOOST_CHECK_EQUAL(Compare(pki, mix, scope, fCompareOverlapping), eContains);
1137  BOOST_CHECK_EQUAL(Compare(mix, pki, scope, fCompareOverlapping), eContained);
1138 
1139  mix.SetMix().Set().clear();
1140  mix.SetMix().Set().push_back(MakeInterval(2, 10, 35));
1141  mix.SetMix().Set().push_back(MakeInterval(2, 70, 90));
1142  BOOST_CHECK_EQUAL(Compare(pki, mix, scope, fCompareOverlapping), eOverlap);
1143  BOOST_CHECK_EQUAL(Compare(mix, pki, scope, fCompareOverlapping), eOverlap);
1144 
1145  // This results in eOverlap although the mix covers the whole interval.
1146  mix.SetMix().Set().clear();
1147  mix.SetMix().Set().push_back(MakeInterval(2, 10, 55));
1148  mix.SetMix().Set().push_back(MakeInterval(2, 50, 90));
1149  BOOST_CHECK_EQUAL(Compare(pki, mix, scope, fCompareOverlapping), eOverlap);
1150  BOOST_CHECK_EQUAL(Compare(mix, pki, scope, fCompareOverlapping), eOverlap);
1151 
1152  // The same problem here.
1153  pki.SetPacked_int().Set().clear();
1154  pki.SetPacked_int().AddInterval(gi2, 10, 60);
1155  pki.SetPacked_int().AddInterval(gi2, 56, 90);
1156  BOOST_CHECK_EQUAL(Compare(pki, mix, scope, fCompareOverlapping), eOverlap);
1157  BOOST_CHECK_EQUAL(Compare(mix, pki, scope, fCompareOverlapping), eOverlap);
1158 
1159  pki.SetPacked_int().Set().clear();
1160  pki.SetPacked_int().AddInterval(gi2, 20, 80);
1161  pki.SetPacked_int().AddInterval(gi2, 30, 70);
1162  mix.SetMix().Set().clear();
1163  mix.SetMix().Set().push_back(MakeInterval(2, 10, 30));
1164  mix.SetMix().Set().push_back(MakeInterval(2, 10, 90));
1165  mix.SetMix().Set().push_back(MakeInterval(2, 70, 90));
1166  BOOST_CHECK_EQUAL(Compare(pki, mix, scope, fCompareOverlapping), eContained);
1167  BOOST_CHECK_EQUAL(Compare(mix, pki, scope, fCompareOverlapping), eContains);
1168 
1169  mix.SetMix().Set().clear();
1170  mix.SetMix().Set().push_back(MakeInterval(2, 20, 30));
1171  mix.SetMix().Set().push_back(MakeInterval(2, 20, 80));
1172  mix.SetMix().Set().push_back(MakeInterval(2, 70, 80));
1173  BOOST_CHECK_EQUAL(Compare(pki, mix, scope, fCompareOverlapping), eContains);
1174  BOOST_CHECK_EQUAL(Compare(mix, pki, scope, fCompareOverlapping), eContains);
1175 
1176  // Packed intervals
1177  pki.SetPacked_int().Set().clear();
1178  pki.SetPacked_int().AddInterval(gi2, 20, 40);
1179  pki.SetPacked_int().AddInterval(gi2, 50, 70);
1180  mix.SetMix().Set().clear();
1181  sub.Reset(new CSeq_loc);
1182  sub->SetPacked_int().Set().push_back(
1183  Ref(&MakeInterval(2, 10, 30)->SetInt()));
1184  sub->SetPacked_int().Set().push_back(
1185  Ref(&MakeInterval(2, 50, 60)->SetInt()));
1186  sub->SetPacked_int().Set().push_back(
1187  Ref(&MakeInterval(2, 70, 90)->SetInt()));
1188  mix.SetMix().Set().push_back(sub);
1189  BOOST_CHECK_EQUAL(Compare(pki, mix, scope, fCompareOverlapping), eOverlap);
1190  BOOST_CHECK_EQUAL(Compare(mix, pki, scope, fCompareOverlapping), eOverlap);
1191 
1192  mix.SetMix().Set().clear();
1193  sub.Reset(new CSeq_loc);
1194  sub->SetPacked_int().Set().push_back(
1195  Ref(&MakeInterval(3, 10, 30)->SetInt()));
1196  sub->SetPacked_int().Set().push_back(
1197  Ref(&MakeInterval(2, 10, 90)->SetInt()));
1198  sub->SetPacked_int().Set().push_back(
1199  Ref(&MakeInterval(2, 70, 90)->SetInt()));
1200  mix.SetMix().Set().push_back(sub);
1201  BOOST_CHECK_EQUAL(Compare(pki, mix, scope, fCompareOverlapping), eContained);
1202  BOOST_CHECK_EQUAL(Compare(mix, pki, scope, fCompareOverlapping), eContains);
1203 
1204  // Mixed sub-location types
1205  mix.SetMix().Set().clear();
1206  sub.Reset(new CSeq_loc);
1207  sub->SetPnt().SetId().SetGi(2);
1208  sub->SetPnt().SetPoint(30);
1209  mix.SetMix().Set().push_back(MakePoint(2, 30));
1210  mix.SetMix().Set().push_back(MakeInterval(2, 35, 40));
1211  sub.Reset(new CSeq_loc);
1212  sub->SetPacked_int().Set().push_back(
1213  Ref(&MakeInterval(2, 55, 60)->SetInt()));
1214  sub->SetPacked_int().Set().push_back(
1215  Ref(&MakeInterval(2, 60, 65)->SetInt()));
1216  mix.SetMix().Set().push_back(sub);
1217  BOOST_CHECK_EQUAL(Compare(pki, mix, scope, fCompareOverlapping), eContains);
1218  BOOST_CHECK_EQUAL(Compare(mix, pki, scope, fCompareOverlapping), eContained);
1219 
1220  mix.SetMix().Set().clear();
1221  mix.SetMix().Set().push_back(MakeInterval(2, 10, 40));
1222  sub.Reset(new CSeq_loc);
1223  sub->SetPacked_int().Set().push_back(
1224  Ref(&MakeInterval(2, 40, 50)->SetInt()));
1225  sub->SetPacked_int().Set().push_back(
1226  Ref(&MakeInterval(2, 50, 85)->SetInt()));
1227  mix.SetMix().Set().push_back(sub);
1228  BOOST_CHECK_EQUAL(Compare(pki, mix, scope, fCompareOverlapping), eContained);
1229  BOOST_CHECK_EQUAL(Compare(mix, pki, scope, fCompareOverlapping), eContains);
1230 }
1231 
1232 
1233 BOOST_AUTO_TEST_CASE(Test_Compare_packed_interval_vs_bond)
1234 {
1235  CScope* scope = &GetScope();
1236 
1237  CRef<CSeq_loc> b = MakeBond(2, 15);
1238 
1239  CSeq_id gi2("gi|2");
1240  CSeq_id gi3("gi|3");
1241 
1242  CSeq_loc pki;
1243 
1244  pki.SetPacked_int().AddInterval(gi2, 1, 5);
1245  BOOST_CHECK_EQUAL(Compare(pki, *b, scope, fCompareOverlapping), eNoOverlap);
1246  BOOST_CHECK_EQUAL(Compare(*b, pki, scope, fCompareOverlapping), eNoOverlap);
1247  pki.SetPacked_int().AddInterval(gi2, 20, 25);
1248  BOOST_CHECK_EQUAL(Compare(pki, *b, scope, fCompareOverlapping), eNoOverlap);
1249  BOOST_CHECK_EQUAL(Compare(*b, pki, scope, fCompareOverlapping), eNoOverlap);
1250 
1251  pki.SetPacked_int().Set().clear();
1252  pki.SetPacked_int().AddInterval(gi2, 10, 20);
1253  BOOST_CHECK_EQUAL(Compare(pki, *b, scope, fCompareOverlapping), eContains);
1254  BOOST_CHECK_EQUAL(Compare(*b, pki, scope, fCompareOverlapping), eContained);
1255 
1256  // For bonds we only detect no-overlap/overlap/contained, not same.
1257  pki.SetPacked_int().Set().clear();
1258  pki.SetPacked_int().AddInterval(gi2, 15, 15);
1259  BOOST_CHECK_EQUAL(Compare(pki, *b, scope, fCompareOverlapping), eSame);
1260  BOOST_CHECK_EQUAL(Compare(*b, pki, scope, fCompareOverlapping), eSame);
1261 
1262  pki.SetPacked_int().AddInterval(gi2, 15, 15);
1263  BOOST_CHECK_EQUAL(Compare(pki, *b, scope, fCompareOverlapping), eContains);
1264  BOOST_CHECK_EQUAL(Compare(*b, pki, scope, fCompareOverlapping), eContains);
1265 
1266  b->SetBond().SetB().SetId().SetGi(2);
1267  b->SetBond().SetB().SetPoint(25);
1268 
1269  pki.SetPacked_int().Set().clear();
1270  pki.SetPacked_int().AddInterval(gi2, 17, 23);
1271  BOOST_CHECK_EQUAL(Compare(pki, *b, scope, fCompareOverlapping), eNoOverlap);
1272  BOOST_CHECK_EQUAL(Compare(*b, pki, scope, fCompareOverlapping), eNoOverlap);
1273 
1274  pki.SetPacked_int().Set().clear();
1275  pki.SetPacked_int().AddInterval(gi2, 10, 30);
1276  BOOST_CHECK_EQUAL(Compare(pki, *b, scope, fCompareOverlapping), eContains);
1277  BOOST_CHECK_EQUAL(Compare(*b, pki, scope, fCompareOverlapping), eContained);
1278 
1279  pki.SetPacked_int().Set().clear();
1280  pki.SetPacked_int().AddInterval(gi2, 10, 20);
1281  pki.SetPacked_int().AddInterval(gi2, 30, 40);
1282  BOOST_CHECK_EQUAL(Compare(pki, *b, scope, fCompareOverlapping), eOverlap);
1283  BOOST_CHECK_EQUAL(Compare(*b, pki, scope, fCompareOverlapping), eOverlap);
1284 
1285  pki.SetPacked_int().Set().clear();
1286  pki.SetPacked_int().AddInterval(gi2, 5, 10);
1287  pki.SetPacked_int().AddInterval(gi2, 20, 30);
1288  BOOST_CHECK_EQUAL(Compare(pki, *b, scope, fCompareOverlapping), eOverlap);
1289  BOOST_CHECK_EQUAL(Compare(*b, pki, scope, fCompareOverlapping), eOverlap);
1290 
1291  pki.SetPacked_int().Set().clear();
1292  pki.SetPacked_int().AddInterval(gi2, 10, 20);
1293  pki.SetPacked_int().AddInterval(gi2, 20, 30);
1294  BOOST_CHECK_EQUAL(Compare(pki, *b, scope, fCompareOverlapping), eContains);
1295  BOOST_CHECK_EQUAL(Compare(*b, pki, scope, fCompareOverlapping), eContained);
1296 
1297  b->SetBond().SetB().SetId().SetGi(3);
1298 
1299  pki.SetPacked_int().Set().clear();
1300  pki.SetPacked_int().AddInterval(gi2, 20, 30);
1301  BOOST_CHECK_EQUAL(Compare(pki, *b, scope, fCompareOverlapping), eNoOverlap);
1302  BOOST_CHECK_EQUAL(Compare(*b, pki, scope, fCompareOverlapping), eNoOverlap);
1303 
1304  pki.SetPacked_int().Set().clear();
1305  pki.SetPacked_int().AddInterval(gi2, 10, 30);
1306  BOOST_CHECK_EQUAL(Compare(pki, *b, scope, fCompareOverlapping), eOverlap);
1307  BOOST_CHECK_EQUAL(Compare(*b, pki, scope, fCompareOverlapping), eOverlap);
1308 
1309  pki.SetPacked_int().Set().clear();
1310  pki.SetPacked_int().AddInterval(gi2, 10, 20);
1311  pki.SetPacked_int().AddInterval(gi2, 20, 30);
1312  BOOST_CHECK_EQUAL(Compare(pki, *b, scope, fCompareOverlapping), eOverlap);
1313  BOOST_CHECK_EQUAL(Compare(*b, pki, scope, fCompareOverlapping), eOverlap);
1314 
1315  pki.SetPacked_int().Set().clear();
1316  pki.SetPacked_int().AddInterval(gi2, 10, 20);
1317  pki.SetPacked_int().AddInterval(gi3, 20, 30);
1318  BOOST_CHECK_EQUAL(Compare(pki, *b, scope, fCompareOverlapping), eContains);
1319  BOOST_CHECK_EQUAL(Compare(*b, pki, scope, fCompareOverlapping), eContained);
1320 }
1321 
1322 
1323 BOOST_AUTO_TEST_CASE(Test_Compare_point_vs_point)
1324 {
1325  CScope* scope = &GetScope();
1326 
1327  CRef<CSeq_loc> p2a = MakePoint(2, 10);
1328  CRef<CSeq_loc> p2b = MakePoint(2, 15);
1329  CRef<CSeq_loc> p3 = MakePoint(3, 20);
1330 
1331  BOOST_CHECK_EQUAL(Compare(*p2a, *p2a, scope, fCompareOverlapping), eSame);
1332  BOOST_CHECK_EQUAL(Compare(*p2a, *p2b, scope, fCompareOverlapping), eNoOverlap);
1333  BOOST_CHECK_EQUAL(Compare(*p2a, *p3, scope, fCompareOverlapping), eNoOverlap);
1334 }
1335 
1336 
1337 BOOST_AUTO_TEST_CASE(Test_Compare_point_vs_packed_point)
1338 {
1339  CScope* scope = &GetScope();
1340 
1341  CRef<CSeq_loc> p = MakePoint(2, 5);
1342 
1343  CSeq_loc pp;
1344  pp.SetPacked_pnt().SetId().SetGi(2);
1345  pp.SetPacked_pnt().AddPoint(10);
1346 
1347  // No overlap
1348  BOOST_CHECK_EQUAL(Compare(*p, pp, scope, fCompareOverlapping), eNoOverlap);
1349  BOOST_CHECK_EQUAL(Compare(pp, *p, scope, fCompareOverlapping), eNoOverlap);
1350 
1351  p = MakePoint(2, 10);
1352  // Single entry in packed points
1353  BOOST_CHECK_EQUAL(Compare(*p, pp, scope, fCompareOverlapping), eSame);
1354  BOOST_CHECK_EQUAL(Compare(pp, *p, scope, fCompareOverlapping), eSame);
1355 
1356  pp.SetPacked_pnt().AddPoint(20);
1357  pp.SetPacked_pnt().AddPoint(30);
1358  // Multiple points
1359  BOOST_CHECK_EQUAL(Compare(*p, pp, scope, fCompareOverlapping), eContained);
1360  BOOST_CHECK_EQUAL(Compare(pp, *p, scope, fCompareOverlapping), eContains);
1361 
1362  // Special case: all packed points are the same.
1363  // The first seq-loc contains the second one in any direction.
1364  pp.Reset();
1365  pp.SetPacked_pnt().SetId().SetGi(2);
1366  pp.SetPacked_pnt().AddPoint(10);
1367  pp.SetPacked_pnt().AddPoint(10);
1368  BOOST_CHECK_EQUAL(Compare(*p, pp, scope, fCompareOverlapping), eContains);
1369  BOOST_CHECK_EQUAL(Compare(pp, *p, scope, fCompareOverlapping), eContains);
1370 }
1371 
1372 
1373 BOOST_AUTO_TEST_CASE(Test_Compare_point_vs_mix)
1374 {
1375  CScope* scope = &GetScope();
1376 
1377  CRef<CSeq_loc> p = MakePoint(2, 50);
1378 
1379  CSeq_loc mix;
1380 
1381  mix.SetMix().Set().push_back(MakeInterval(3, 10, 90));
1382  BOOST_CHECK_EQUAL(Compare(*p, mix, scope, fCompareOverlapping), eNoOverlap);
1383 
1384  mix.SetMix().Set().clear();
1385  mix.SetMix().Set().push_back(MakeInterval(2, 10, 40));
1386  mix.SetMix().Set().push_back(MakeInterval(2, 60, 90));
1387  BOOST_CHECK_EQUAL(Compare(*p, mix, scope, fCompareOverlapping), eNoOverlap);
1388  mix.SetMix().Set().push_back(MakeInterval(2, 40, 60));
1389  BOOST_CHECK_EQUAL(Compare(*p, mix, scope, fCompareOverlapping), eContained);
1390  BOOST_CHECK_EQUAL(Compare(mix, *p, scope, fCompareOverlapping), eContains);
1391 
1392  mix.SetMix().Set().clear();
1393  mix.SetMix().Set().push_back(MakePoint(2, 50));
1394  BOOST_CHECK_EQUAL(Compare(*p, mix, scope, fCompareOverlapping), eSame);
1395  BOOST_CHECK_EQUAL(Compare(mix, *p, scope, fCompareOverlapping), eSame);
1396  mix.SetMix().Set().push_back(MakePoint(2, 50));
1397  BOOST_CHECK_EQUAL(Compare(*p, mix, scope, fCompareOverlapping), eContains);
1398  BOOST_CHECK_EQUAL(Compare(mix, *p, scope, fCompareOverlapping), eContains);
1399 }
1400 
1401 
1402 BOOST_AUTO_TEST_CASE(Test_Compare_point_vs_bond)
1403 {
1404  CScope* scope = &GetScope();
1405 
1406  CRef<CSeq_loc> bA2 = MakeBond(2, 10);
1407  CRef<CSeq_loc> bA2B3 = MakeBond(2, 10, 3, 20);
1408  CRef<CSeq_loc> bA2B2 = MakeBond(2, 10, 2, 20);
1409  CRef<CSeq_loc> bA2B2eq = MakeBond(2, 10, 2, 10);
1410 
1411  CRef<CSeq_loc> p = MakePoint(2, 5);
1412  // No overlap
1413  BOOST_CHECK_EQUAL(Compare(*bA2, *p, scope, fCompareOverlapping), eNoOverlap);
1414 
1415  p = MakePoint(2, 10);
1416  // Overlap with A
1417  BOOST_CHECK_EQUAL(Compare(*bA2, *p, scope, fCompareOverlapping), eSame);
1418  BOOST_CHECK_EQUAL(Compare(*bA2B3, *p, scope, fCompareOverlapping), eContains);
1419  BOOST_CHECK_EQUAL(Compare(*p, *bA2B3, scope, fCompareOverlapping), eContained);
1420  BOOST_CHECK_EQUAL(Compare(*bA2B2, *p, scope, fCompareOverlapping), eContains);
1421  BOOST_CHECK_EQUAL(Compare(*p, *bA2B2, scope, fCompareOverlapping), eContained);
1422 
1423  // Special case - A==B, contains in both directions.
1424  BOOST_CHECK_EQUAL(Compare(*bA2B2eq, *p, scope, fCompareOverlapping), eContains);
1425  BOOST_CHECK_EQUAL(Compare(*p, *bA2B2eq, scope, fCompareOverlapping), eContains);
1426 }
1427 
1428 
1429 BOOST_AUTO_TEST_CASE(Test_Compare_packed_point_vs_packed_point)
1430 {
1431  CScope* scope = &GetScope();
1432 
1433  CSeq_loc pp1;
1434  pp1.SetPacked_pnt().SetId().SetGi(2);
1435  pp1.SetPacked_pnt().AddPoint(10);
1436 
1437  CSeq_loc pp2;
1438  pp2.SetPacked_pnt().SetId().SetGi(3);
1439  pp2.SetPacked_pnt().AddPoint(10);
1440 
1441  // No overlap for different bioseqs
1442  BOOST_CHECK_EQUAL(Compare(pp1, pp2, scope, fCompareOverlapping), eNoOverlap);
1443  pp1.SetPacked_pnt().AddPoint(20);
1444  pp2.SetPacked_pnt().SetId().SetGi(2);
1445  pp2.SetPacked_pnt().SetPoints().front() = 5;
1446  pp2.SetPacked_pnt().AddPoint(15);
1447  BOOST_CHECK_EQUAL(Compare(pp1, pp2, scope, fCompareOverlapping), eNoOverlap);
1448  pp1.SetPacked_pnt().AddPoint(30);
1449  BOOST_CHECK_EQUAL(Compare(pp1, pp2, scope, fCompareOverlapping), eNoOverlap);
1450 
1451  // Same
1452  pp2.Assign(pp1);
1453  BOOST_CHECK_EQUAL(Compare(pp1, pp2, scope, fCompareOverlapping), eSame);
1454 
1455  // Overlap
1456  pp2.SetPacked_pnt().SetPoints().clear();
1457  pp2.SetPacked_pnt().AddPoint(5);
1458  pp2.SetPacked_pnt().AddPoint(10);
1459  pp2.SetPacked_pnt().AddPoint(15);
1460  BOOST_CHECK_EQUAL(Compare(pp1, pp2, scope, fCompareOverlapping), eOverlap);
1461  BOOST_CHECK_EQUAL(Compare(pp2, pp1, scope, fCompareOverlapping), eOverlap);
1462 
1463  // Contained/contains
1464  pp1.SetPacked_pnt().AddPoint(40); // 10, 20, 30, 40
1465  pp2.SetPacked_pnt().SetPoints().clear();
1466  pp2.SetPacked_pnt().AddPoint(20); // 20
1467  BOOST_CHECK_EQUAL(Compare(pp1, pp2, scope, fCompareOverlapping), eContains);
1468  BOOST_CHECK_EQUAL(Compare(pp2, pp1, scope, fCompareOverlapping), eContained);
1469  pp2.SetPacked_pnt().AddPoint(30); // 20, 30
1470  BOOST_CHECK_EQUAL(Compare(pp1, pp2, scope, fCompareOverlapping), eContains);
1471  BOOST_CHECK_EQUAL(Compare(pp2, pp1, scope, fCompareOverlapping), eContained);
1472  // Wrong order of points should still work
1473  pp2.SetPacked_pnt().AddPoint(10); // 20, 30, 10
1474  BOOST_CHECK_EQUAL(Compare(pp1, pp2, scope, fCompareOverlapping), eContains);
1475  BOOST_CHECK_EQUAL(Compare(pp2, pp1, scope, fCompareOverlapping), eContained);
1476  // Duplicate points - same result
1477  pp2.SetPacked_pnt().AddPoint(20); // 20, 30, 10, 20
1478  BOOST_CHECK_EQUAL(Compare(pp1, pp2, scope, fCompareOverlapping), eContains);
1479  BOOST_CHECK_EQUAL(Compare(pp2, pp1, scope, fCompareOverlapping), eContained);
1480 
1481  // Special case - due to duplicate points both sets contain each other
1482  // but are not equal
1483  pp2.SetPacked_pnt().AddPoint(40); // 20, 30, 10, 20, 40
1484  BOOST_CHECK_EQUAL(Compare(pp1, pp2, scope, fCompareOverlapping), eContains);
1485  BOOST_CHECK_EQUAL(Compare(pp2, pp1, scope, fCompareOverlapping), eContains);
1486 
1487  // Now they just overlap
1488  pp1.SetPacked_pnt().AddPoint(45);
1489  pp2.SetPacked_pnt().AddPoint(5);
1490  BOOST_CHECK_EQUAL(Compare(pp1, pp2, scope, fCompareOverlapping), eOverlap);
1491  BOOST_CHECK_EQUAL(Compare(pp2, pp1, scope, fCompareOverlapping), eOverlap);
1492 }
1493 
1494 
1495 BOOST_AUTO_TEST_CASE(Test_Compare_packed_point_vs_mix)
1496 {
1497  CScope* scope = &GetScope();
1498 
1499  CSeq_loc pp;
1500  pp.SetPacked_pnt().SetId().SetGi(2);
1501  pp.SetPacked_pnt().AddPoint(25);
1502  pp.SetPacked_pnt().AddPoint(85);
1503 
1504  CSeq_loc mix;
1505 
1506  // Each point is contained in a separate sub-location.
1507  mix.SetMix().Set().push_back(MakeInterval(2, 30, 70));
1508  BOOST_CHECK_EQUAL(Compare(pp, mix, scope, fCompareOverlapping), eNoOverlap);
1509  pp.SetPacked_pnt().AddPoint(50);
1510  BOOST_CHECK_EQUAL(Compare(pp, mix, scope, fCompareOverlapping), eOverlap);
1511  BOOST_CHECK_EQUAL(Compare(pp, mix, scope, fCompareOverlapping), eOverlap);
1512  mix.SetMix().Set().push_back(MakeInterval(2, 20, 30));
1513  mix.SetMix().Set().push_back(MakeInterval(2, 70, 90));
1514  BOOST_CHECK_EQUAL(Compare(pp, mix, scope, fCompareOverlapping), eContained);
1515  BOOST_CHECK_EQUAL(Compare(mix, pp, scope, fCompareOverlapping), eContains);
1516 }
1517 
1518 
1519 BOOST_AUTO_TEST_CASE(Test_Compare_packed_point_vs_bond)
1520 {
1521  CScope* scope = &GetScope();
1522 
1523  CSeq_loc pp;
1524  pp.SetPacked_pnt().SetId().SetGi(2);
1525  pp.SetPacked_pnt().AddPoint(10);
1526 
1527  CRef<CSeq_loc> b = MakeBond(3, 10);
1528  // No overlap
1529  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eNoOverlap);
1530  b = MakeBond(2, 20);
1531  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eNoOverlap);
1532 
1533  b = MakeBond(2, 10);
1534  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eSame);
1535  b = MakeBond(2, 10, 3, 10);
1536  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eContained);
1537  BOOST_CHECK_EQUAL(Compare(*b, pp, scope, fCompareOverlapping), eContains);
1538  b = MakeBond(2, 10, 2, 20);
1539  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eContained);
1540  BOOST_CHECK_EQUAL(Compare(*b, pp, scope, fCompareOverlapping), eContains);
1541  b = MakeBond(3, 10, 2, 10);
1542  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eContained);
1543  BOOST_CHECK_EQUAL(Compare(*b, pp, scope, fCompareOverlapping), eContains);
1544  b = MakeBond(2, 10, 2, 10);
1545  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eContains);
1546  BOOST_CHECK_EQUAL(Compare(*b, pp, scope, fCompareOverlapping), eContains);
1547 
1548  pp.SetPacked_pnt().AddPoint(20);
1549  b = MakeBond(2, 10);
1550  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eContains);
1551  BOOST_CHECK_EQUAL(Compare(*b, pp, scope, fCompareOverlapping), eContained);
1552  b = MakeBond(2, 10, 2, 20);
1553  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eSame);
1554  BOOST_CHECK_EQUAL(Compare(*b, pp, scope, fCompareOverlapping), eSame);
1555  // The order of points does not matter.
1556  b = MakeBond(2, 20, 2, 10);
1557  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eSame);
1558  BOOST_CHECK_EQUAL(Compare(*b, pp, scope, fCompareOverlapping), eSame);
1559  b = MakeBond(2, 10, 3, 10);
1560  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eOverlap);
1561  BOOST_CHECK_EQUAL(Compare(*b, pp, scope, fCompareOverlapping), eOverlap);
1562  b = MakeBond(3, 10, 2, 10);
1563  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eOverlap);
1564  BOOST_CHECK_EQUAL(Compare(*b, pp, scope, fCompareOverlapping), eOverlap);
1565  b = MakeBond(2, 10, 2, 10);
1566  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eContains);
1567  BOOST_CHECK_EQUAL(Compare(*b, pp, scope, fCompareOverlapping), eContained);
1568  b = MakeBond(2, 20, 2, 20);
1569  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eContains);
1570  BOOST_CHECK_EQUAL(Compare(*b, pp, scope, fCompareOverlapping), eContained);
1571  b = MakeBond(2, 10, 2, 40);
1572  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eOverlap);
1573  BOOST_CHECK_EQUAL(Compare(*b, pp, scope, fCompareOverlapping), eOverlap);
1574 
1575  pp.SetPacked_pnt().AddPoint(30);
1576  b = MakeBond(2, 10);
1577  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eContains);
1578  BOOST_CHECK_EQUAL(Compare(*b, pp, scope, fCompareOverlapping), eContained);
1579  b = MakeBond(2, 10, 2, 30);
1580  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eContains);
1581  BOOST_CHECK_EQUAL(Compare(*b, pp, scope, fCompareOverlapping), eContained);
1582  b = MakeBond(2, 30, 2, 10);
1583  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eContains);
1584  BOOST_CHECK_EQUAL(Compare(*b, pp, scope, fCompareOverlapping), eContained);
1585  b = MakeBond(2, 10, 3, 10);
1586  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eOverlap);
1587  BOOST_CHECK_EQUAL(Compare(*b, pp, scope, fCompareOverlapping), eOverlap);
1588  b = MakeBond(3, 10, 2, 10);
1589  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eOverlap);
1590  BOOST_CHECK_EQUAL(Compare(*b, pp, scope, fCompareOverlapping), eOverlap);
1591  b = MakeBond(2, 10, 2, 10);
1592  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eContains);
1593  BOOST_CHECK_EQUAL(Compare(*b, pp, scope, fCompareOverlapping), eContained);
1594  b = MakeBond(2, 10, 2, 40);
1595  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eOverlap);
1596  BOOST_CHECK_EQUAL(Compare(*b, pp, scope, fCompareOverlapping), eOverlap);
1597 
1598  pp.SetPacked_pnt().SetPoints().clear();
1599  pp.SetPacked_pnt().AddPoint(10);
1600  pp.SetPacked_pnt().AddPoint(20);
1601  pp.SetPacked_pnt().AddPoint(20);
1602  b = MakeBond(2, 10);
1603  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eContains);
1604  BOOST_CHECK_EQUAL(Compare(*b, pp, scope, fCompareOverlapping), eContained);
1605  b = MakeBond(2, 10, 2, 20);
1606  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eContains);
1607  BOOST_CHECK_EQUAL(Compare(*b, pp, scope, fCompareOverlapping), eContains);
1608  b = MakeBond(2, 10, 2, 30);
1609  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eOverlap);
1610  BOOST_CHECK_EQUAL(Compare(*b, pp, scope, fCompareOverlapping), eOverlap);
1611  b = MakeBond(2, 30, 2, 10);
1612  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eOverlap);
1613  BOOST_CHECK_EQUAL(Compare(*b, pp, scope, fCompareOverlapping), eOverlap);
1614  b = MakeBond(2, 10, 2, 20);
1615  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eContains);
1616  BOOST_CHECK_EQUAL(Compare(*b, pp, scope, fCompareOverlapping), eContains);
1617  b = MakeBond(2, 20, 2, 10);
1618  BOOST_CHECK_EQUAL(Compare(pp, *b, scope, fCompareOverlapping), eContains);
1619  BOOST_CHECK_EQUAL(Compare(*b, pp, scope, fCompareOverlapping), eContains);
1620 }
1621 
1622 
1623 BOOST_AUTO_TEST_CASE(Test_Compare_mix_vs_mix)
1624 {
1625  CScope* scope = &GetScope();
1626 
1627  CSeq_loc mix1, mix2;
1628 
1629  mix1.SetMix().Set().push_back(MakeInterval(2, 10, 20));
1630  mix1.SetMix().Set().push_back(MakeInterval(2, 50, 60));
1631  mix2.SetMix().Set().push_back(MakeInterval(2, 30, 40));
1632  mix2.SetMix().Set().push_back(MakeInterval(2, 70, 80));
1633  BOOST_CHECK_EQUAL(Compare(mix1, mix2, scope, fCompareOverlapping), eNoOverlap);
1634  mix1.SetMix().Set().push_back(MakeInterval(3, 30, 40));
1635  BOOST_CHECK_EQUAL(Compare(mix1, mix2, scope, fCompareOverlapping), eNoOverlap);
1636  mix2.SetMix().Set().push_front(MakeInterval(3, 20, 35));
1637  BOOST_CHECK_EQUAL(Compare(mix1, mix2, scope, fCompareOverlapping), eOverlap);
1638 
1639  mix1.SetMix().Set().clear();
1640  mix1.SetMix().Set().push_back(MakeInterval(2, 10, 30));
1641  mix1.SetMix().Set().push_back(MakeInterval(2, 50, 70));
1642  mix2.SetMix().Set().clear();
1643  mix2.SetMix().Set().push_back(MakeInterval(2, 60, 65));
1644  mix2.SetMix().Set().push_back(MakeInterval(2, 20, 25));
1645  BOOST_CHECK_EQUAL(Compare(mix1, mix2, scope, fCompareOverlapping), eContains);
1646  BOOST_CHECK_EQUAL(Compare(mix2, mix1, scope, fCompareOverlapping), eContained);
1647 
1648  mix2.SetMix().Set().push_back(MakeInterval(2, 50, 70));
1649  mix2.SetMix().Set().push_back(MakeInterval(2, 10, 30));
1650  BOOST_CHECK_EQUAL(Compare(mix1, mix2, scope, fCompareOverlapping), eContains);
1651  BOOST_CHECK_EQUAL(Compare(mix2, mix1, scope, fCompareOverlapping), eContains);
1652 
1653  // Empty should not change anything (?)
1654  CRef<CSeq_loc> sub(new CSeq_loc);
1655  sub->SetEmpty().SetGi(2);
1656  mix2.SetMix().Set().push_back(sub);
1657  BOOST_CHECK_EQUAL(Compare(mix1, mix2, scope, fCompareOverlapping), eContains);
1658  BOOST_CHECK_EQUAL(Compare(mix2, mix1, scope, fCompareOverlapping), eContains);
1659 
1660  mix2.SetMix().Set().push_back(MakePoint(3, 100));
1661  BOOST_CHECK_EQUAL(Compare(mix1, mix2, scope, fCompareOverlapping), eContained);
1662  BOOST_CHECK_EQUAL(Compare(mix2, mix1, scope, fCompareOverlapping), eContains);
1663 
1664  mix1.SetMix().Set().push_back(MakePoint(2, 110));
1665  BOOST_CHECK_EQUAL(Compare(mix1, mix2, scope, fCompareOverlapping), eOverlap);
1666  BOOST_CHECK_EQUAL(Compare(mix2, mix1, scope, fCompareOverlapping), eOverlap);
1667 }
1668 
1669 
1670 BOOST_AUTO_TEST_CASE(Test_Compare_mix_vs_bond)
1671 {
1672  CScope* scope = &GetScope();
1673 
1674  CRef<CSeq_loc> b = MakeBond(2, 50);
1675 
1676  CSeq_loc mix;
1677 
1678  // Each point is contained in a separate sub-location.
1679  mix.SetMix().Set().push_back(MakeInterval(2, 10, 30));
1680  BOOST_CHECK_EQUAL(Compare(*b, mix, scope, fCompareOverlapping), eNoOverlap);
1681  mix.SetMix().Set().push_back(MakeInterval(2, 70, 90));
1682  BOOST_CHECK_EQUAL(Compare(*b, mix, scope, fCompareOverlapping), eNoOverlap);
1683  mix.SetMix().Set().push_back(MakeInterval(2, 40, 60));
1684  BOOST_CHECK_EQUAL(Compare(*b, mix, scope, fCompareOverlapping), eContained);
1685  BOOST_CHECK_EQUAL(Compare(mix, *b, scope, fCompareOverlapping), eContains);
1686 
1687  b = MakeBond(2, 20, 3, 40);
1688  BOOST_CHECK_EQUAL(Compare(*b, mix, scope, fCompareOverlapping), eOverlap);
1689  BOOST_CHECK_EQUAL(Compare(mix, *b, scope, fCompareOverlapping), eOverlap);
1690 
1691  mix.SetMix().Set().push_back(MakeInterval(3, 30, 50));
1692  BOOST_CHECK_EQUAL(Compare(*b, mix, scope, fCompareOverlapping), eContained);
1693  BOOST_CHECK_EQUAL(Compare(mix, *b, scope, fCompareOverlapping), eContains);
1694 
1695  mix.SetMix().Set().clear();
1696  mix.SetMix().Set().push_back(MakePoint(2, 20));
1697  BOOST_CHECK_EQUAL(Compare(*b, mix, scope, fCompareOverlapping), eContains);
1698  BOOST_CHECK_EQUAL(Compare(mix, *b, scope, fCompareOverlapping), eContained);
1699 
1700  mix.SetMix().Set().push_back(MakePoint(3, 40));
1701  BOOST_CHECK_EQUAL(Compare(*b, mix, scope, fCompareOverlapping), eSame);
1702  BOOST_CHECK_EQUAL(Compare(mix, *b, scope, fCompareOverlapping), eSame);
1703  mix.SetMix().Set().reverse();
1704  BOOST_CHECK_EQUAL(Compare(*b, mix, scope, fCompareOverlapping), eSame);
1705  BOOST_CHECK_EQUAL(Compare(mix, *b, scope, fCompareOverlapping), eSame);
1706 
1707  mix.SetMix().Set().clear();
1708  mix.SetMix().Set().push_back(MakeInterval(2, 20, 20));
1709  mix.SetMix().Set().push_back(MakeInterval(3, 40, 40));
1710  BOOST_CHECK_EQUAL(Compare(*b, mix, scope, fCompareOverlapping), eSame);
1711  BOOST_CHECK_EQUAL(Compare(mix, *b, scope, fCompareOverlapping), eSame);
1712  mix.SetMix().Set().reverse();
1713  BOOST_CHECK_EQUAL(Compare(*b, mix, scope, fCompareOverlapping), eSame);
1714  BOOST_CHECK_EQUAL(Compare(mix, *b, scope, fCompareOverlapping), eSame);
1715  mix.SetMix().Set().push_back(MakeInterval(3, 40, 40));
1716  mix.SetMix().Set().reverse();
1717  BOOST_CHECK_EQUAL(Compare(*b, mix, scope, fCompareOverlapping), eContains);
1718  BOOST_CHECK_EQUAL(Compare(mix, *b, scope, fCompareOverlapping), eContains);
1719 }
1720 
1721 
1722 BOOST_AUTO_TEST_CASE(Test_Compare_bond_vs_bond)
1723 {
1724  CScope* scope = &GetScope();
1725 
1726  CRef<CSeq_loc> b1 = MakeBond(2, 10);
1727  CRef<CSeq_loc> b2 = MakeBond(3, 10);
1728  BOOST_CHECK_EQUAL(Compare(*b1, *b2, scope, fCompareOverlapping), eNoOverlap);
1729 
1730  b2 = MakeBond(2, 20);
1731  BOOST_CHECK_EQUAL(Compare(*b1, *b2, scope, fCompareOverlapping), eNoOverlap);
1732 
1733  b2 = MakeBond(2, 10);
1734  BOOST_CHECK_EQUAL(Compare(*b1, *b2, scope, fCompareOverlapping), eSame);
1735 
1736  b2 = MakeBond(2, 10, 3, 20);
1737  BOOST_CHECK_EQUAL(Compare(*b1, *b2, scope, fCompareOverlapping), eContained);
1738  BOOST_CHECK_EQUAL(Compare(*b2, *b1, scope, fCompareOverlapping), eContains);
1739  b1 = MakeBond(2, 10, 3, 25);
1740  BOOST_CHECK_EQUAL(Compare(*b1, *b2, scope, fCompareOverlapping), eOverlap);
1741  BOOST_CHECK_EQUAL(Compare(*b2, *b1, scope, fCompareOverlapping), eOverlap);
1742  b1 = MakeBond(2, 10, 3, 20);
1743  BOOST_CHECK_EQUAL(Compare(*b1, *b2, scope, fCompareOverlapping), eSame);
1744  BOOST_CHECK_EQUAL(Compare(*b2, *b1, scope, fCompareOverlapping), eSame);
1745 
1746  b2 = MakeBond(2, 15, 3, 20);
1747  BOOST_CHECK_EQUAL(Compare(*b1, *b2, scope, fCompareOverlapping), eOverlap);
1748  BOOST_CHECK_EQUAL(Compare(*b2, *b1, scope, fCompareOverlapping), eOverlap);
1749  b2 = MakeBond(2, 10, 3, 20);
1750  BOOST_CHECK_EQUAL(Compare(*b1, *b2, scope, fCompareOverlapping), eSame);
1751  BOOST_CHECK_EQUAL(Compare(*b2, *b1, scope, fCompareOverlapping), eSame);
1752  // The order or ranges is not important
1753  b2 = MakeBond(3, 20, 2, 10);
1754  BOOST_CHECK_EQUAL(Compare(*b1, *b2, scope, fCompareOverlapping), eSame);
1755  BOOST_CHECK_EQUAL(Compare(*b2, *b1, scope, fCompareOverlapping), eSame);
1756 
1757  b1 = MakeBond(2, 10, 2, 10);
1758  b2 = MakeBond(2, 10, 2, 10);
1759  BOOST_CHECK_EQUAL(Compare(*b1, *b2, scope, fCompareOverlapping), eSame);
1760  BOOST_CHECK_EQUAL(Compare(*b2, *b1, scope, fCompareOverlapping), eSame);
1761 
1762  b1 = MakeBond(2, 10, 3, 20);
1763  b2 = MakeBond(3, 20);
1764  BOOST_CHECK_EQUAL(Compare(*b1, *b2, scope, fCompareOverlapping), eContains);
1765  BOOST_CHECK_EQUAL(Compare(*b2, *b1, scope, fCompareOverlapping), eContained);
1766  b2 = MakeBond(3, 20, 2, 15);
1767  BOOST_CHECK_EQUAL(Compare(*b1, *b2, scope, fCompareOverlapping), eOverlap);
1768  BOOST_CHECK_EQUAL(Compare(*b2, *b1, scope, fCompareOverlapping), eOverlap);
1769 
1770  b1 = MakeBond(2, 10, 2, 10);
1771  b2 = MakeBond(2, 10);
1772  BOOST_CHECK_EQUAL(Compare(*b1, *b2, scope, fCompareOverlapping), eContains);
1773  BOOST_CHECK_EQUAL(Compare(*b2, *b1, scope, fCompareOverlapping), eContains);
1774  b2 = MakeBond(2, 10, 3, 15);
1775  BOOST_CHECK_EQUAL(Compare(*b1, *b2, scope, fCompareOverlapping), eContained);
1776  BOOST_CHECK_EQUAL(Compare(*b2, *b1, scope, fCompareOverlapping), eContains);
1777 
1778  b1 = MakeBond(2, 15, 3, 20);
1779  b2 = MakeBond(3, 20, 3, 20);
1780  BOOST_CHECK_EQUAL(Compare(*b1, *b2, scope, fCompareOverlapping), eContains);
1781  BOOST_CHECK_EQUAL(Compare(*b2, *b1, scope, fCompareOverlapping), eContained);
1782 }
1783 
1784 
1785 const char* sc_TestEntry = "\
1786 Seq-entry ::= set {\
1787  class nuc-prot,\
1788  seq-set {\
1789  seq {\
1790  id {\
1791  local str \"local2\",\
1792  gi 2\
1793  },\
1794  inst {\
1795  repr raw,\
1796  mol rna,\
1797  length 1442,\
1798  seq-data iupacna \"TTTTTTTTTTTGAGATGGAGTTTTCGCTCTTGTTGCCCAGGCTGGAGTGCAA\
1799 TGGCGCAATCTCAGCTCACCGCAACCTCCGCCTCCCGGGTTCAAGCGATTCTCCTGCCTCAGCCTCCCCAGTAGCTGG\
1800 GATTACAGGCATGTGCACCCACGCTCGGCTAATTTTGTATTTTTTTTTAGTAGAGATGGAGTTTCTCCATGTTGGTCA\
1801 GGCTGGTCTCGAACTCCCGACCTCAGATGATCCCTCCGTCTCGGCCTCCCAAAGTGCTAGATACAGGACTGGCCACCA\
1802 TGCCCGGCTCTGCCTGGCTAATTTTTGTGGTAGAAACAGGGTTTCACTGATGTGCCCAAGCTGGTCTCCTGAGCTCAA\
1803 GCAGTCCACCTGCCTCAGCCTCCCAAAGTGCTGGGATTACAGGCGTGCAGCCGTGCCTGGCCTTTTTATTTTATTTTT\
1804 TTTAAGACACAGGTGTCCCACTCTTACCCAGGATGAAGTGCAGTGGTGTGATCACAGCTCACTGCAGCCTTCAACTCC\
1805 TGAGATCAAGCATCCTCCTGCCTCAGCCTCCCAAGTAGCTGGGACCAAAGACATGCACCACTACACCTGGCTAATTTT\
1806 TATTTTTATTTTTAATTTTTTGAGACAGAGTCTCAACTCTGTCACCCAGGCTGGAGTGCAGTGGCGCAATCTTGGCTC\
1807 ACTGCAACCTCTGCCTCCCGGGTTCAAGTTATTCTCCTGCCCCAGCCTCCTGAGTAGCTGGGACTACAGGCGCCCACC\
1808 ACGCCTAGCTAATTTTTTTGTATTTTTAGTAGAGATGGGGTTCACCATGTTCGCCAGGTTGATCTTGATCTCTGGACC\
1809 TTGTGATCTGCCTGCCTCGGCCTCCCAAAGTGCTGGGATTACAGGCGTGAGCCACCACGCCCGGCTTATTTTTAATTT\
1810 TTGTTTGTTTGAAATGGAATCTCACTCTGTTACCCAGGCTGGAGTGCAATGGCCAAATCTCGGCTCACTGCAACCTCT\
1811 GCCTCCCGGGCTCAAGCGATTCTCCTGTCTCAGCCTCCCAAGCAGCTGGGATTACGGGCACCTGCCACCACACCCCGC\
1812 TAATTTTTGTATTTTCATTAGAGGCGGGGTTTCACCATATTTGTCAGGCTGGTCTCAAACTCCTGACCTCAGGTGACC\
1813 CACCTGCCTCAGCCTTCCAAAGTGCTGGGATTACAGGCGTGAGCCACCTCACCCAGCCGGCTAATTTAGATAAAAAAA\
1814 TATGTAGCAATGGGGGGTCTTGCTATGTTGCCCAGGCTGGTCTCAAACTTCTGGCTTCATGCAATCCTTCCAAATGAG\
1815 CCACAACACCCAGCCAGTCACATTTTTTAAACAGTTACATCTTTATTTTAGTATACTAGAAAGTAATACAATAAACAT\
1816 GTCAAACCTGCAAATTCAGTAGTAACAGAGTTCTTTTATAACTTTTAAACAAAGCTTTAGAGCA\"\
1817  }\
1818  },\
1819  seq {\
1820  id {\
1821  local str \"local3\",\
1822  gi 3\
1823  },\
1824  inst {\
1825  repr raw,\
1826  mol aa,\
1827  length 375,\
1828  topology not-set,\
1829  seq-data ncbieaa \"MEFSLLLPRLECNGAISAHRNLRLPGSSDSPASASPVAGITGMCTHARLILY\
1830 FFLVEMEFLHVGQAGLELPTSDDPSVSASQSARYRTGHHARLCLANFCGRNRVSLMCPSWSPELKQSTCLSLPKCWDY\
1831 RRAAVPGLFILFFLRHRCPTLTQDEVQWCDHSSLQPSTPEIKHPPASASQVAGTKDMHHYTWLIFIFIFNFLRQSLNS\
1832 VTQAGVQWRNLGSLQPLPPGFKLFSCPSLLSSWDYRRPPRLANFFVFLVEMGFTMFARLILISGPCDLPASASQSAGI\
1833 TGVSHHARLIFNFCLFEMESHSVTQAGVQWPNLGSLQPLPPGLKRFSCLSLPSSWDYGHLPPHPANFCIFIRGGVSPY\
1834 LSGWSQTPDLR\"\
1835  }\
1836  },\
1837  seq {\
1838  id {\
1839  local str \"local102\",\
1840  gi 102\
1841  },\
1842  inst {\
1843  repr raw,\
1844  mol rna,\
1845  length 1442,\
1846  topology circular,\
1847  seq-data iupacna \"TTTTTTTTTTTGAGATGGAGTTTTCGCTCTTGTTGCCCAGGCTGGAGTGCAA\
1848 TGGCGCAATCTCAGCTCACCGCAACCTCCGCCTCCCGGGTTCAAGCGATTCTCCTGCCTCAGCCTCCCCAGTAGCTGG\
1849 GATTACAGGCATGTGCACCCACGCTCGGCTAATTTTGTATTTTTTTTTAGTAGAGATGGAGTTTCTCCATGTTGGTCA\
1850 GGCTGGTCTCGAACTCCCGACCTCAGATGATCCCTCCGTCTCGGCCTCCCAAAGTGCTAGATACAGGACTGGCCACCA\
1851 TGCCCGGCTCTGCCTGGCTAATTTTTGTGGTAGAAACAGGGTTTCACTGATGTGCCCAAGCTGGTCTCCTGAGCTCAA\
1852 GCAGTCCACCTGCCTCAGCCTCCCAAAGTGCTGGGATTACAGGCGTGCAGCCGTGCCTGGCCTTTTTATTTTATTTTT\
1853 TTTAAGACACAGGTGTCCCACTCTTACCCAGGATGAAGTGCAGTGGTGTGATCACAGCTCACTGCAGCCTTCAACTCC\
1854 TGAGATCAAGCATCCTCCTGCCTCAGCCTCCCAAGTAGCTGGGACCAAAGACATGCACCACTACACCTGGCTAATTTT\
1855 TATTTTTATTTTTAATTTTTTGAGACAGAGTCTCAACTCTGTCACCCAGGCTGGAGTGCAGTGGCGCAATCTTGGCTC\
1856 ACTGCAACCTCTGCCTCCCGGGTTCAAGTTATTCTCCTGCCCCAGCCTCCTGAGTAGCTGGGACTACAGGCGCCCACC\
1857 ACGCCTAGCTAATTTTTTTGTATTTTTAGTAGAGATGGGGTTCACCATGTTCGCCAGGTTGATCTTGATCTCTGGACC\
1858 TTGTGATCTGCCTGCCTCGGCCTCCCAAAGTGCTGGGATTACAGGCGTGAGCCACCACGCCCGGCTTATTTTTAATTT\
1859 TTGTTTGTTTGAAATGGAATCTCACTCTGTTACCCAGGCTGGAGTGCAATGGCCAAATCTCGGCTCACTGCAACCTCT\
1860 GCCTCCCGGGCTCAAGCGATTCTCCTGTCTCAGCCTCCCAAGCAGCTGGGATTACGGGCACCTGCCACCACACCCCGC\
1861 TAATTTTTGTATTTTCATTAGAGGCGGGGTTTCACCATATTTGTCAGGCTGGTCTCAAACTCCTGACCTCAGGTGACC\
1862 CACCTGCCTCAGCCTTCCAAAGTGCTGGGATTACAGGCGTGAGCCACCTCACCCAGCCGGCTAATTTAGATAAAAAAA\
1863 TATGTAGCAATGGGGGGTCTTGCTATGTTGCCCAGGCTGGTCTCAAACTTCTGGCTTCATGCAATCCTTCCAAATGAG\
1864 CCACAACACCCAGCCAGTCACATTTTTTAAACAGTTACATCTTTATTTTAGTATACTAGAAAGTAATACAATAAACAT\
1865 GTCAAACCTGCAAATTCAGTAGTAACAGAGTTCTTTTATAACTTTTAAACAAAGCTTTAGAGCA\"\
1866  }\
1867  },\
1868  seq {\
1869  id {\
1870  local str \"local202\",\
1871  gi 202\
1872  },\
1873  inst {\
1874  repr raw,\
1875  mol rna,\
1876  length 642,\
1877  topology circular,\
1878  seq-data iupacna \"TTTTTTTTTTTGAGATGGAGTTTTCGCTCTTGTTGCCCAGGCTGGAGTGCAA\
1879 TTGTGATCTGCCTGCCTCGGCCTCCCAAAGTGCTGGGATTACAGGCGTGAGCCACCACGCCCGGCTTATTTTTAATTT\
1880 TTGTTTGTTTGAAATGGAATCTCACTCTGTTACCCAGGCTGGAGTGCAATGGCCAAATCTCGGCTCACTGCAACCTCT\
1881 GCCTCCCGGGCTCAAGCGATTCTCCTGTCTCAGCCTCCCAAGCAGCTGGGATTACGGGCACCTGCCACCACACCCCGC\
1882 TAATTTTTGTATTTTCATTAGAGGCGGGGTTTCACCATATTTGTCAGGCTGGTCTCAAACTCCTGACCTCAGGTGACC\
1883 CACCTGCCTCAGCCTTCCAAAGTGCTGGGATTACAGGCGTGAGCCACCTCACCCAGCCGGCTAATTTAGATAAAAAAA\
1884 TATGTAGCAATGGGGGGTCTTGCTATGTTGCCCAGGCTGGTCTCAAACTTCTGGCTTCATGCAATCCTTCCAAATGAG\
1885 CCACAACACCCAGCCAGTCACATTTTTTAAACAGTTACATCTTTATTTTAGTATACTAGAAAGTAATACAATAAACAT\
1886 GTCAAACCTGCAAATTCAGTAGTAACAGAGTTCTTTTATAACTTTTAAACAAAGCTTTAGAGCA\"\
1887  }\
1888  }\
1889  }\
1890 }";
User-defined methods of the data storage class.
CScope –.
Definition: scope.hpp:92
Definition: Seq_entry.hpp:56
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define ZERO_GI
Definition: ncbimisc.hpp:1088
#define MSerial_AsnText
I/O stream manipulators –.
Definition: serialbase.hpp:696
void SetPacked_int(TPacked_int &v)
Definition: Seq_loc.hpp:984
void SetMix(TMix &v)
Definition: Seq_loc.hpp:987
void SetWhole(TWhole &v)
Definition: Seq_loc.hpp:982
void SetPacked_pnt(TPacked_pnt &v)
Definition: Seq_loc.hpp:986
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Override Assign() to incorporate cache invalidation.
Definition: Seq_loc.cpp:337
void SetPnt(TPnt &v)
Definition: Seq_loc.hpp:985
void SetEmpty(TEmpty &v)
Definition: Seq_loc.hpp:981
void SetInt(TInt &v)
Definition: Seq_loc.hpp:983
void SetBond(TBond &v)
Definition: Seq_loc.hpp:989
sequence::ECompare Compare(const CSeq_loc &loc1, const CSeq_loc &loc2, CScope *scope)
Returns the sequence::ECompare containment relationship between CSeq_locs.
@ fCompareOverlapping
Check if seq-locs are overlapping.
@ eContains
First CSeq_loc contains second.
@ eOverlap
CSeq_locs overlap.
@ eSame
CSeq_locs contain each other.
@ eContained
First CSeq_loc contained by second.
@ eNoOverlap
CSeq_locs do not overlap or abut.
static CRef< CObjectManager > GetInstance(void)
Return the existing object manager or create one.
CSeq_entry_Handle AddTopLevelSeqEntry(CSeq_entry &top_entry, TPriority pri=kPriority_Default, EExist action=eExist_Default)
Add seq_entry, default priority is higher than for defaults or loaders Add object to the score with p...
Definition: scope.cpp:522
CRef< C > Ref(C *object)
Helper functions to get CRef<> and CConstRef<> objects.
Definition: ncbiobj.hpp:2015
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
TStr & SetStr(void)
Select the variant.
Definition: Object_id_.hpp:304
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
virtual void Reset(void)
Reset the whole object.
Definition: Seq_loc_.cpp:59
TLocal & SetLocal(void)
Select the variant.
Definition: Seq_id_.cpp:199
@ eNa_strand_unknown
Definition: Na_strand_.hpp:65
int i
The Object manager core.
Utility stuff for more convenient using of Boost.Test library.
USING_SCOPE(objects)
CScope & GetScope()
const char * sc_TestEntry
CRef< CSeq_loc > MakeInterval(TGi gi, TSeqPos from, TSeqPos to, ENa_strand strand=eNa_strand_unknown)
CRef< CSeq_loc > MakeBond(TGi giA, TSeqPos posA, TGi giB=ZERO_GI, TSeqPos posB=0)
CRef< CSeq_loc > MakePoint(TGi gi, TSeqPos pos)
BOOST_AUTO_TEST_CASE(Test_Compare_whole_vs_whole)
Modified on Mon May 20 05:06:19 2024 by modify_doxy.py rev. 669887