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

Go to the SVN repository for this file.

1 /* $Id: seq_loc_cvt.cpp 73104 2016-06-20 16:37:02Z 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: Eugene Vasilchenko
27 *
28 * File Description:
29 * Class for mapping Seq-loc between sequences.
30 *
31 */
32 
33 #include <ncbi_pch.hpp>
35 
38 #include <objmgr/seq_map_ci.hpp>
44 
55 #include <algorithm>
56 
59 
60 /////////////////////////////////////////////////////////////////////////////
61 // CSeq_loc_Conversion
62 /////////////////////////////////////////////////////////////////////////////
63 
65  const CSeq_id_Handle& dst_id,
66  const CSeqMap_CI& seg,
67  const CSeq_id_Handle& src_id,
68  CScope* scope)
69  : m_Src_id_Handle(src_id),
70  m_Src_from(0),
71  m_Src_to(0),
72  m_Shift(0),
73  m_Reverse(false),
74  m_Dst_id_Handle(dst_id),
75  m_Dst_loc_Empty(&master_loc_empty),
76  m_Partial(false),
77  m_PartialHasUnconvertedId(false),
78  m_PartialFlag(0),
79  m_LastType(eMappedObjType_not_set),
80  m_LastStrand(eNa_strand_unknown),
81  m_Scope(scope)
82 {
83  SetConversion(seg);
84  Reset();
85 }
86 
87 
89  const CSeq_id_Handle& dst_id,
90  const TRange& dst_rg,
91  const CSeq_id_Handle& src_id,
92  TSeqPos src_start,
93  bool reverse,
94  CScope* scope)
95  : m_Src_id_Handle(src_id),
96  m_Src_from(0),
97  m_Src_to(0),
98  m_Shift(0),
99  m_Reverse(reverse),
100  m_Dst_id_Handle(dst_id),
101  m_Dst_loc_Empty(&master_loc_empty),
102  m_Partial(false),
103  m_PartialHasUnconvertedId(false),
104  m_PartialFlag(0),
105  m_LastType(eMappedObjType_not_set),
106  m_LastStrand(eNa_strand_unknown),
107  m_Scope(scope)
108 {
109  m_Src_from = src_start;
110  m_Src_to = m_Src_from + dst_rg.GetLength() - 1;
111  if ( !m_Reverse ) {
112  m_Shift = dst_rg.GetFrom() - m_Src_from;
113  }
114  else {
115  m_Shift = dst_rg.GetFrom() + m_Src_to;
116  }
117  Reset();
118 }
119 
120 
122 {
123  _ASSERT(!IsSpecialLoc());
124 }
125 
126 
128 {
129  _ASSERT(!IsSpecialLoc());
131  m_PartialFlag = 0;
135 }
136 
137 
139 {
141  m_Partial = false;
143 }
144 
145 
147 {
149  TRange dst_rg = GetDstRange();
150  TRange cvt_src_rg = cvt.GetSrcRange();
151  TRange overlap = dst_rg & cvt_src_rg;
152  _ASSERT( !overlap.Empty() );
153 
154  TSeqPos new_dst_from = cvt.ConvertPos(overlap.GetFrom());
155  _ASSERT(new_dst_from != kInvalidSeqPos);
156  _ASSERT(cvt.ConvertPos(overlap.GetTo()) != kInvalidSeqPos);
157  bool new_reverse = cvt.m_Reverse ? !m_Reverse : m_Reverse;
158  if (overlap.GetFrom() > dst_rg.GetFrom()) {
159  TSeqPos l_trunc = overlap.GetFrom() - dst_rg.GetFrom();
160  // Truncated range
161  if ( !m_Reverse ) {
162  m_Src_from += l_trunc;
163  }
164  else {
165  m_Src_to -= l_trunc;
166  }
167  }
168  if (overlap.GetTo() < dst_rg.GetTo()) {
169  TSeqPos r_trunc = dst_rg.GetTo() - overlap.GetTo();
170  // Truncated range
171  if ( !m_Reverse ) {
172  m_Src_to -= r_trunc;
173  }
174  else {
175  m_Src_from += r_trunc;
176  }
177  }
178  m_Reverse = new_reverse;
179  if ( !m_Reverse ) {
180  m_Shift = new_dst_from - m_Src_from;
181  }
182  else {
183  m_Shift = new_dst_from + m_Src_to;
184  }
187  cvt.Reset();
188  Reset();
189 }
190 
191 
193 {
194  m_Src_from = seg.GetRefPosition();
195  m_Src_to = m_Src_from + seg.GetLength() - 1;
197  if ( !m_Reverse ) {
198  m_Shift = seg.GetPosition() - m_Src_from;
199  }
200  else {
201  m_Shift = seg.GetPosition() + m_Src_to;
202  }
203 }
204 
205 
208 {
209  if ( fuzz.IsLim() ) {
210  CInt_fuzz::ELim lim = fuzz.GetLim();
211  switch ( lim ) {
212  case CInt_fuzz::eLim_lt: lim = CInt_fuzz::eLim_gt; break;
213  case CInt_fuzz::eLim_gt: lim = CInt_fuzz::eLim_lt; break;
214  case CInt_fuzz::eLim_tr: lim = CInt_fuzz::eLim_tl; break;
215  case CInt_fuzz::eLim_tl: lim = CInt_fuzz::eLim_tr; break;
216  default: return ConstRef(&fuzz);
217  }
218  CRef<CInt_fuzz> ret(new CInt_fuzz);
219  ret->SetLim(lim);
220  return ret;
221  }
222  return ConstRef(&fuzz);
223 }
224 
225 
227  const CRange<TSeqPos> src_range,
228  const SAnnotObject_Index& src_index)
229 {
230  if ( src_id != m_Src_id_Handle ) {
232  return;
233  }
234 
235  ENa_strand strand;
236  switch ( src_index.m_Flags & src_index.fStrand_mask ) {
238  strand = eNa_strand_plus;
239  break;
241  strand = eNa_strand_minus;
242  break;
243  default:
244  strand = eNa_strand_unknown;
245  break;
246  }
247  if ( src_index.LocationIsPoint() ) {
248  ConvertPoint(src_range.GetFrom(), strand);
249  }
250  else if ( src_index.LocationIsInterval() ) {
251  ConvertInterval(src_range.GetFrom(), src_range.GetTo(), strand);
252  }
253  else {
254  _ASSERT(src_index.LocationIsWhole());
255  CBioseq_Handle bh =
258  }
259 }
260 
261 
263 {
264  ENa_strand strand = src.IsSetStrand()? src.GetStrand(): eNa_strand_unknown;
265  bool ret = GoodSrcId(src.GetId()) && ConvertPoint(src.GetPoint(), strand);
266  if ( ret ) {
267  if ( src.IsSetFuzz() ) {
268  if ( m_Reverse ) {
270  }
271  else {
272  m_DstFuzz_from = &src.GetFuzz();
273  }
274  // normalize left and right fuzz values
275  if ( m_DstFuzz_from && m_DstFuzz_from->IsLim() &&
279  }
280  }
281  }
282  else if ( m_GraphRanges ) {
284  }
285  return ret;
286 }
287 
288 
290 {
291  ENa_strand strand = src.IsSetStrand()? src.GetStrand(): eNa_strand_unknown;
292  bool ret = GoodSrcId(src.GetId()) &&
293  ConvertInterval(src.GetFrom(), src.GetTo(), strand);
294  if ( ret ) {
295  if ( m_Reverse ) {
296  if ( !(m_PartialFlag & fPartial_to) && src.IsSetFuzz_from() ) {
298  }
299  if ( !(m_PartialFlag & fPartial_from) && src.IsSetFuzz_to() ) {
301  }
302  }
303  else {
304  if ( !(m_PartialFlag & fPartial_from) && src.IsSetFuzz_from() ) {
305  m_DstFuzz_from = &src.GetFuzz_from();
306  }
307  if ( !(m_PartialFlag & fPartial_to) && src.IsSetFuzz_to() ) {
308  m_DstFuzz_to = &src.GetFuzz_to();
309  }
310  }
311  // normalize left and right fuzz values
312  if ( m_DstFuzz_from && m_DstFuzz_from->IsLim() &&
316  }
317  if ( m_DstFuzz_to && m_DstFuzz_to->IsLim() &&
321  }
322  }
323  else if ( m_GraphRanges ) {
325  }
326  return ret;
327 }
328 
329 
331  ENa_strand src_strand)
332 {
333  _ASSERT(!IsSpecialLoc());
334  m_PartialFlag = 0;
337  if ( src_pos < m_Src_from || src_pos > m_Src_to ) {
338  m_Partial = true;
339  return false;
340  }
341  TSeqPos dst_pos;
342  if ( !m_Reverse ) {
343  m_LastStrand = src_strand;
344  dst_pos = m_Shift + src_pos;
345  }
346  else {
347  m_LastStrand = Reverse(src_strand);
348  dst_pos = m_Shift - src_pos;
349  }
351  m_TotalRange += m_LastRange.SetFrom(dst_pos).SetTo(dst_pos);
352  if ( m_GraphRanges ) {
353  m_GraphRanges->AddRange(TRange(src_pos, src_pos));
355  }
356  return true;
357 }
358 
359 
361  ENa_strand src_strand)
362 {
363  _ASSERT(!IsSpecialLoc());
364  m_PartialFlag = 0;
367  bool partial_from = false, partial_to = false;
368  TSeqPos len = src_to - src_from + 1;
369  TRange graph_rg(0, len - 1);
370  if ( src_from < m_Src_from ) {
371  m_Partial = partial_from = true;
372  graph_rg.SetFrom(m_Src_from - src_from);
373  src_from = m_Src_from;
374  }
375  if ( src_to > m_Src_to ) {
376  m_Partial = partial_to = true;
377  graph_rg.SetLength(m_Src_to - src_from + 1);
378  src_to = m_Src_to;
379  }
380  if ( src_from > src_to ) {
381  m_Partial = true;
382  return false;
383  }
384  TSeqPos dst_from, dst_to;
385  if ( !m_Reverse ) {
386  m_LastStrand = src_strand;
387  dst_from = m_Shift + src_from;
388  dst_to = m_Shift + src_to;
389  }
390  else {
391  m_LastStrand = Reverse(src_strand);
392  dst_from = m_Shift - src_to;
393  dst_to = m_Shift - src_from;
394  swap(partial_from, partial_to);
395  }
397  m_TotalRange += m_LastRange.SetFrom(dst_from).SetTo(dst_to);
398  if ( partial_from ) {
400  }
401  if ( partial_to ) {
403  }
404  if ( m_GraphRanges ) {
405  m_GraphRanges->AddRange(graph_rg);
407  }
408  return true;
409 }
410 
411 
412 inline
414 {
416  NCBI_THROW(CAnnotException, eBadLocation,
417  "Wrong last location type");
418  }
420 }
421 
422 
423 inline
425 {
427  NCBI_THROW(CAnnotException, eBadLocation,
428  "Wrong last location type");
429  }
431 }
432 
433 
434 inline
436 {
438  NCBI_THROW(CAnnotException, eBadLocation,
439  "Wrong last location type");
440  }
442 }
443 
444 
446 {
449  CSeq_interval& interval = *ret;
450  interval.SetId(GetDstId());
451  interval.SetFrom(m_LastRange.GetFrom());
452  interval.SetTo(m_LastRange.GetTo());
453  if ( m_LastStrand != eNa_strand_unknown ) {
454  interval.SetStrand(m_LastStrand);
455  }
456  if ( m_PartialFlag & fPartial_from ) {
457  interval.SetFuzz_from().SetLim(CInt_fuzz::eLim_lt);
458  }
459  else if ( m_DstFuzz_from ) {
460  interval.SetFuzz_from(const_cast<CInt_fuzz&>(*m_DstFuzz_from));
461  }
462  if ( m_PartialFlag & fPartial_to ) {
463  interval.SetFuzz_to().SetLim(CInt_fuzz::eLim_gt);
464  }
465  else if ( m_DstFuzz_to ) {
466  interval.SetFuzz_to(const_cast<CInt_fuzz&>(*m_DstFuzz_to));
467  }
468  return ret;
469 }
470 
471 
473 {
474  CheckDstPoint();
475  _ASSERT(m_LastRange.GetLength() == 1);
476  CRef<CSeq_point> ret(new CSeq_point);
477  CSeq_point& point = *ret;
478  point.SetId(GetDstId());
479  point.SetPoint(m_LastRange.GetFrom());
480  // Points can not be partial
481  if ( m_LastStrand != eNa_strand_unknown ) {
482  point.SetStrand(m_LastStrand);
483  }
484  if ( m_PartialFlag & fPartial_from ) {
485  point.SetFuzz().SetLim(CInt_fuzz::eLim_lt);
486  }
487  else if ( m_DstFuzz_from ) {
488  point.SetFuzz(const_cast<CInt_fuzz&>(*m_DstFuzz_from));
489  }
490  return ret;
491 }
492 
493 
495  const CSeq_loc_mix& src) const
496 {
497  CSeq_loc_mix::Tdata& dst_mix = dst.Set();
498  const CSeq_loc_mix::Tdata& src_mix = src.Get();
499  ITERATE ( CSeq_loc_mix::Tdata, it, src_mix ) {
500  const CSeq_interval& src_int = (*it)->GetInt();
501  CRef<CSeq_loc> dst_loc(new CSeq_loc);
502  CSeq_interval& dst_int = dst_loc->SetInt();
504  ENa_strand src_strand =
505  src_int.IsSetStrand()? src_int.GetStrand(): eNa_strand_unknown;
506  TSeqPos src_from = src_int.GetFrom(), src_to = src_int.GetTo();
507  ENa_strand dst_strand;
508  TSeqPos dst_from, dst_to;
509  if ( !m_Reverse ) {
510  dst_strand = src_strand;
511  dst_from = m_Shift + src_from;
512  dst_to = m_Shift + src_to;
513  }
514  else {
515  dst_strand = Reverse(src_strand);
516  dst_from = m_Shift - src_to;
517  dst_to = m_Shift - src_from;
518  }
519  if ( dst_strand != eNa_strand_unknown ) {
520  dst_int.SetStrand(dst_strand);
521  }
522  dst_int.SetFrom(dst_from);
523  dst_int.SetTo(dst_to);
524  dst_mix.push_back(dst_loc);
525  }
526 }
527 
528 
530 {
532  CheckDstMix();
533  MakeDstMix(*ret, m_SrcLoc->GetMix());
534  m_SrcLoc.Reset();
535  return ret;
536 }
537 
538 
540 {
541  CSeq_loc* loc = 0;
542  if ( !dst ) {
543  switch ( m_LastType ) {
545  dst.Reset(loc = new CSeq_loc);
546  loc->SetInt(*GetDstInterval());
547  break;
549  dst.Reset(loc = new CSeq_loc);
550  loc->SetPnt(*GetDstPoint());
551  break;
553  dst.Reset(loc = new CSeq_loc);
554  loc->SetMix(*GetDstMix());
555  break;
556  default:
557  _ASSERT(0);
558  break;
559  }
560  }
561  else {
562  _ASSERT(!IsSpecialLoc());
563  }
564 }
565 
566 
568  CRef<CSeq_loc>& dst)
569 {
571  const CPacked_seqint::Tdata& src_ints = src.GetPacked_int().Get();
572  CPacked_seqint::Tdata* dst_ints = 0;
573  // If the result contains NULLs, may need to use mix instead.
574  CSeq_loc_mix::Tdata* dst_mix = 0;
575  bool last_truncated = false;
576  ITERATE ( CPacked_seqint::Tdata, i, src_ints ) {
577  if ( ConvertInterval(**i) ) {
578  if ( !dst_ints && !dst_mix ) {
579  dst.Reset(new CSeq_loc);
580  dst_ints = &dst->SetPacked_int().Set();
581  }
583  if ( last_truncated &&
585  !dst_int->IsPartialStart(eExtreme_Biological) ) {
586  dst_int->SetPartialStart(true, eExtreme_Biological);
587  }
588  if ( dst_mix ) {
589  CRef<CSeq_loc> mix_loc(new CSeq_loc);
590  mix_loc->SetInt(*dst_int);
591  dst_mix->push_back(mix_loc);
592  }
593  else {
594  dst_ints->push_back(dst_int);
595  }
596  last_truncated = false;
597  }
598  else {
599  if (last_truncated) continue;
602  _ASSERT(dst_mix);
603  CRef<CSeq_loc> null_loc(new CSeq_loc);
604  null_loc->SetNull();
605  dst_mix->push_back(null_loc);
606  }
607  else if (dst && !dst->IsPartialStop(eExtreme_Biological) ) {
609  }
610  last_truncated = true;
611  }
612  }
613 }
614 
615 
617  CRef<CSeq_loc>& dst)
618 {
620  const CPacked_seqpnt& src_pack_pnts = src.GetPacked_pnt();
621  if ( !GoodSrcId(src_pack_pnts.GetId()) ) {
622  if ( m_GraphRanges ) {
623  m_GraphRanges->IncOffset(TSeqPos(src_pack_pnts.GetPoints().size()));
624  }
625  return;
626  }
627  const CPacked_seqpnt::TPoints& src_pnts = src_pack_pnts.GetPoints();
628  CPacked_seqpnt::TPoints* dst_pnts = 0;
629  CSeq_loc_mix::Tdata* dst_mix = 0;
630  ENa_strand dst_strand = eNa_strand_unknown;
631  CRef<CInt_fuzz> dst_fuzz;
632  if ( src_pack_pnts.IsSetStrand() ) {
633  dst_strand = ConvertStrand(src_pack_pnts.GetStrand());
634  }
635  if ( src_pack_pnts.IsSetFuzz() ) {
636  dst_fuzz.Reset(new CInt_fuzz);
637  if ( m_Reverse ) {
638  dst_fuzz->Assign(*ReverseFuzz(src_pack_pnts.GetFuzz()));
639  }
640  else {
641  dst_fuzz->Assign(src_pack_pnts.GetFuzz());
642  }
643  }
644 
645  ITERATE ( CPacked_seqpnt::TPoints, i, src_pnts ) {
646  TSeqPos dst_pos = ConvertPos(*i);
647  if ( dst_pos == kInvalidSeqPos )
648  {
650  dst_mix = s_ConvertToMix(dst);
651  CRef<CSeq_loc> null_loc(new CSeq_loc);
652  null_loc->SetNull();
653  dst_mix->push_back(null_loc);
654  }
655  continue;
656  }
657  if ( dst_mix ) {
658  CRef<CSeq_loc> mix_loc(new CSeq_loc);
659  mix_loc->SetPnt().SetId(GetDstId());
660  mix_loc->SetPnt().SetPoint(dst_pos);
661  if ( src_pack_pnts.IsSetStrand() ) {
662  mix_loc->SetPnt().SetStrand(dst_strand);
663  }
664  if ( dst_fuzz ) {
665  mix_loc->SetPnt().SetFuzz(*dst_fuzz);
666  }
667  }
668  else {
669  if ( !dst_pnts ) {
670  dst.Reset(new CSeq_loc);
671  CPacked_seqpnt& pnts = dst->SetPacked_pnt();
672  pnts.SetId(GetDstId());
673  dst_pnts = &pnts.SetPoints();
674  if ( src_pack_pnts.IsSetStrand() ) {
675  pnts.SetStrand(dst_strand);
676  }
677  if ( dst_fuzz ) {
678  pnts.SetFuzz(*dst_fuzz);
679  }
680  }
681  dst_pnts->push_back(dst_pos);
682  }
683  m_TotalRange += TRange(dst_pos, dst_pos);
684  }
685 }
686 
687 
689 {
690  const CSeq_loc_mix::Tdata& src_mix = src.GetMix().Get();
691  if ( src_mix.empty() ) {
692  return false;
693  }
694  const CSeq_loc& first_loc = **src_mix.begin();
695  if ( !first_loc.IsInt() ) {
696  return false;
697  }
698  const CSeq_interval& first_int = first_loc.GetInt();
699  ENa_strand src_strand =
700  first_int.IsSetStrand()? first_int.GetStrand(): eNa_strand_unknown;
701  TSeqPos src_from, src_to;
702  if ( !IsReverse(src_strand) ) {
703  // forward
704  TSeqPos prev_pos = m_Src_from;
705  src_from = first_int.GetFrom();
706  ITERATE ( CSeq_loc_mix::Tdata, i, src_mix ) {
707  const CSeq_loc& loc = **i;
708  if ( !loc.IsInt() ) {
709  return false;
710  }
711  const CSeq_interval& cur_int = loc.GetInt();
712  if ( cur_int.IsSetFuzz_from() || cur_int.IsSetFuzz_to() ) {
713  return false;
714  }
715  if ( !GoodSrcId(cur_int.GetId()) ) {
716  return false;
717  }
718  ENa_strand strand =
719  cur_int.IsSetStrand()? cur_int.GetStrand(): eNa_strand_unknown;
720  if ( strand != src_strand ) {
721  return false;
722  }
723 
724  TSeqPos from = cur_int.GetFrom();
725  TSeqPos to = cur_int.GetTo();
726  if ( to < from || from < prev_pos || to > m_Src_to ) {
727  return false;
728  }
729  prev_pos = to+1;
730  }
731  src_to = prev_pos-1;
732  }
733  else {
734  TSeqPos prev_pos = m_Src_to;
735  src_to = first_int.GetTo();
736  ITERATE ( CSeq_loc_mix::Tdata, i, src_mix ) {
737  const CSeq_loc& loc = **i;
738  if ( !loc.IsInt() ) {
739  return false;
740  }
741  const CSeq_interval& cur_int = loc.GetInt();
742  if ( cur_int.IsSetFuzz_from() || cur_int.IsSetFuzz_to() ) {
743  return false;
744  }
745  if ( !GoodSrcId(cur_int.GetId()) ) {
746  return false;
747  }
748  ENa_strand strand =
749  cur_int.IsSetStrand()? cur_int.GetStrand(): eNa_strand_unknown;
750  if ( strand != src_strand ) {
751  return false;
752  }
753 
754  TSeqPos from = cur_int.GetFrom();
755  TSeqPos to = cur_int.GetTo();
756  if ( to < from || to > prev_pos || from < m_Src_from ) {
757  return false;
758  }
759  prev_pos = from-1;
760  }
761  src_from = prev_pos+1;
762  }
763  ENa_strand dst_strand;
764  TSeqPos dst_from, dst_to;
765  if ( !m_Reverse ) {
766  dst_strand = src_strand;
767  dst_from = m_Shift + src_from;
768  dst_to = m_Shift + src_to;
769  }
770  else {
771  dst_strand = Reverse(src_strand);
772  dst_from = m_Shift - src_to;
773  dst_to = m_Shift - src_from;
774  }
775  m_PartialFlag = 0;
778  m_LastStrand = dst_strand;
780  m_SrcLoc = &src;
781  m_TotalRange += m_LastRange.SetFrom(dst_from).SetTo(dst_to);
782  return true;
783 }
784 
785 
787  CRef<CSeq_loc>& dst,
788  EConvertFlag flag)
789 {
790  _ASSERT(src.Which() == CSeq_loc::e_Mix);
791  if ( flag != eCnvAlways && ConvertSimpleMix(src) ) {
792  return;
793  }
794  const CSeq_loc_mix::Tdata& src_mix = src.GetMix().Get();
795  CSeq_loc_mix::Tdata* dst_mix = 0;
796  CRef<CSeq_loc> dst_loc;
797  bool last_truncated = false;
798  ITERATE ( CSeq_loc_mix::Tdata, i, src_mix ) {
799  if ( Convert(**i, dst_loc, eCnvAlways) ) {
800  _ASSERT(dst_loc);
801  dst_mix = s_ConvertToMix(dst);
802  if ( last_truncated &&
804  !dst_loc->IsPartialStart(eExtreme_Biological) ) {
805  dst_loc->SetPartialStart(true, eExtreme_Biological);
806  }
807  dst_mix->push_back(dst_loc);
808  last_truncated = false;
809  }
810  else {
811  if (last_truncated) continue;
813  CRef<CSeq_loc> null_loc(new CSeq_loc);
814  null_loc->SetNull();
815  dst_mix = s_ConvertToMix(dst);
816  dst_mix->push_back(null_loc);
817  }
818  else if (dst && !dst->IsPartialStop(eExtreme_Biological)) {
820  }
821  last_truncated = true;
822  }
823  }
824 }
825 
826 
828  CRef<CSeq_loc>& dst)
829 {
830  _ASSERT(src.Which() == CSeq_loc::e_Equiv);
831  const CSeq_loc_equiv::Tdata& src_equiv = src.GetEquiv().Get();
832  CSeq_loc_equiv::Tdata* dst_equiv = 0;
833  CRef<CSeq_loc> dst_loc;
834  ITERATE ( CSeq_loc_equiv::Tdata, i, src_equiv ) {
835  if ( Convert(**i, dst_loc, eCnvAlways) ||
837  if ( !dst_equiv ) {
838  dst.Reset(new CSeq_loc);
839  dst_equiv = &dst->SetEquiv().Set();
840  }
841  if (!dst_loc) {
842  dst_loc.Reset(new CSeq_loc);
843  dst_loc->SetNull();
844  }
845  dst_equiv->push_back(dst_loc);
846  }
847  }
848 }
849 
850 
852  CRef<CSeq_loc>& dst)
853 {
854  _ASSERT(src.Which() == CSeq_loc::e_Bond);
855  const CSeq_bond& src_bond = src.GetBond();
856  CSeq_bond* dst_bond = 0;
857  if ( ConvertPoint(src_bond.GetA()) ) {
858  dst.Reset(new CSeq_loc);
859  dst_bond = &dst->SetBond();
860  dst_bond->SetA(*GetDstPoint());
861  if ( src_bond.IsSetB() ) {
862  dst_bond->SetB().Assign(src_bond.GetB());
863  }
864  }
865  if ( src_bond.IsSetB() ) {
866  if ( ConvertPoint(src_bond.GetB()) ) {
867  if ( !dst_bond ) {
868  dst.Reset(new CSeq_loc);
869  dst_bond = &dst->SetBond();
870  dst_bond->SetA().Assign(src_bond.GetA());
871  }
872  dst_bond->SetB(*GetDstPoint());
873  }
874  }
875 }
876 
877 
879  CRef<CSeq_loc>& dst,
880  EConvertFlag flag)
881 {
882  dst.Reset();
883  CSeq_loc* loc = 0;
884  _ASSERT(!IsSpecialLoc());
886  switch ( src.Which() ) {
887  case CSeq_loc::e_not_set:
888  case CSeq_loc::e_Feat:
889  // Nothing to do, although this should never happen --
890  // the seq_loc is intersecting with the conv. loc.
891  _ASSERT("this cannot happen" && 0);
892  break;
893  case CSeq_loc::e_Null:
894  {
895  dst.Reset(loc = new CSeq_loc);
896  loc->SetNull();
897  break;
898  }
899  case CSeq_loc::e_Empty:
900  {
901  if ( GoodSrcId(src.GetEmpty()) ) {
902  dst.Reset(loc = new CSeq_loc);
903  loc->SetEmpty(GetDstId());
904  }
905  break;
906  }
907  case CSeq_loc::e_Whole:
908  {
909  const CSeq_id& src_id = src.GetWhole();
910  // Convert to the allowed master seq interval
911  if ( GoodSrcId(src_id) ) {
912  CBioseq_Handle bh =
916  }
917  else if ( m_GraphRanges ) {
918  CBioseq_Handle bh =
922  }
923  break;
924  }
925  case CSeq_loc::e_Int:
926  {
927  ConvertInterval(src.GetInt());
928  break;
929  }
930  case CSeq_loc::e_Pnt:
931  {
932  ConvertPoint(src.GetPnt());
933  break;
934  }
936  {
937  ConvertPacked_int(src, dst);
938  break;
939  }
941  {
942  ConvertPacked_pnt(src, dst);
943  break;
944  }
945  case CSeq_loc::e_Mix:
946  {
947  ConvertMix(src, dst, flag);
948  break;
949  }
950  case CSeq_loc::e_Equiv:
951  {
952  ConvertEquiv(src, dst);
953  break;
954  }
955  case CSeq_loc::e_Bond:
956  {
957  ConvertBond(src, dst);
958  break;
959  }
960  default:
961  NCBI_THROW(CAnnotException, eBadLocation,
962  "Unsupported location type");
963  }
964  if ( flag == eCnvAlways && IsSpecialLoc() ) {
965  SetDstLoc(dst);
966  }
967  return dst.NotEmpty();
968 }
969 
970 
972  const CSeq_feat& orig_feat,
973  CRef<CSeq_feat>& mapped_feat)
974 {
975  const CAnnotObject_Info& obj = ref.GetAnnotObject_Info();
976  _ASSERT( obj.IsFeat() );
977  const CSeqFeatData& src_feat_data = orig_feat.GetData();
978  _ASSERT( src_feat_data.IsCdregion() );
979  if (!src_feat_data.GetCdregion().IsSetCode_break()) {
980  return;
981  }
982  const CCdregion& src_cd = src_feat_data.GetCdregion();
983  // Map code-break locations
984  const CCdregion::TCode_break& src_cb = src_cd.GetCode_break();
985  mapped_feat.Reset(new CSeq_feat);
986  // Initialize mapped feature
988  *mapped_feat);
989 
990  // Copy Cd-region, do not change the original one
991  CRef<CSeqFeatData> new_data(new CSeqFeatData);
992  mapped_feat->SetData(*new_data);
993  CCdregion& new_cd = new_data->SetCdregion();
994 
995  if ( src_cd.IsSetOrf() ) {
996  new_cd.SetOrf(src_cd.GetOrf());
997  }
998  else {
999  new_cd.ResetOrf();
1000  }
1001  if ( src_cd.IsSetFrame() ) {
1002  new_cd.SetFrame(src_cd.GetFrame());
1003  }
1004  else {
1005  new_cd.ResetFrame();
1006  }
1007  if ( src_cd.IsSetConflict() ) {
1008  new_cd.SetConflict(src_cd.GetConflict());
1009  }
1010  else {
1011  new_cd.ResetConflict();
1012  }
1013  if ( src_cd.IsSetGaps() ) {
1014  new_cd.SetGaps(src_cd.GetGaps());
1015  }
1016  else {
1017  new_cd.ResetGaps();
1018  }
1019  if ( src_cd.IsSetMismatch() ) {
1020  new_cd.SetMismatch(src_cd.GetMismatch());
1021  }
1022  else {
1023  new_cd.ResetMismatch();
1024  }
1025  if ( src_cd.IsSetCode() ) {
1026  new_cd.SetCode(const_cast<CGenetic_code&>(src_cd.GetCode()));
1027  }
1028  else {
1029  new_cd.ResetCode();
1030  }
1031  if ( src_cd.IsSetStops() ) {
1032  new_cd.SetStops(src_cd.GetStops());
1033  }
1034  else {
1035  new_cd.ResetStops();
1036  }
1037 
1038  CCdregion::TCode_break& mapped_cbs = new_cd.SetCode_break();
1039  mapped_cbs.clear();
1040  ITERATE(CCdregion::TCode_break, it, src_cb) {
1041  CRef<CSeq_loc> cb_loc;
1042  Convert((*it)->GetLoc(), cb_loc, eCnvAlways);
1043  // Preserve partial flag
1044  ResetKeepPartial();
1045  if (cb_loc && cb_loc->Which() != CSeq_loc::e_not_set) {
1047  cb->SetAa(const_cast<CCode_break::TAa&>((*it)->GetAa()));
1048  cb->SetLoc(*cb_loc);
1049  mapped_cbs.push_back(cb);
1050  }
1051  /*else {
1052  // Keep the original code-break
1053  CRef<CCode_break> cb(&const_cast<CCode_break&>(**it));
1054  mapped_cbs.push_back(cb);
1055  }*/
1056  }
1057 }
1058 
1059 
1061  const CSeq_feat& orig_feat,
1062  CRef<CSeq_feat>& mapped_feat)
1063 {
1064  const CAnnotObject_Info& obj = ref.GetAnnotObject_Info();
1065  _ASSERT( obj.IsFeat() );
1066  const CSeqFeatData& src_feat_data = orig_feat.GetData();
1067  _ASSERT( src_feat_data.IsRna() );
1068  if (!src_feat_data.GetRna().IsSetExt() ||
1069  !src_feat_data.GetRna().GetExt().IsTRNA() ||
1070  !src_feat_data.GetRna().GetExt().GetTRNA().IsSetAnticodon()) {
1071  return;
1072  }
1073  const CRNA_ref::TExt& src_ext = src_feat_data.GetRna().GetExt();
1074  // Map anticodon location
1075  const CSeq_loc& src_anticodon = src_ext.GetTRNA().GetAnticodon();
1076  mapped_feat.Reset(new CSeq_feat);
1077  // Initialize mapped feature
1079  *mapped_feat);
1080 
1081  // Copy RNA-ext, do not change the original one
1082  CRef<CRNA_ref::TExt> new_ext(new CRNA_ref::TExt);
1083 
1084  // Shallow-copy the feature, replace data.rna.ext.trna.anticodon
1085  // with the mapped location
1086  mapped_feat->Assign(*obj.GetFeatFast(), eShallow);
1087  mapped_feat->SetData(*(new CSeqFeatData));
1088  mapped_feat->SetData().Assign(src_feat_data, eShallow);
1089  mapped_feat->SetData().SetRna(*(new CRNA_ref));
1090 
1091  mapped_feat->SetData().SetRna().SetType(src_feat_data.GetRna().GetType());
1092  if ( src_feat_data.GetRna().IsSetPseudo() ) {
1093  mapped_feat->SetData().SetRna().SetPseudo(
1094  src_feat_data.GetRna().GetPseudo());
1095  }
1096  else {
1097  mapped_feat->SetData().SetRna().ResetPseudo();
1098  }
1099  mapped_feat->SetData().SetRna().SetExt().SetTRNA().SetAa(
1100  const_cast<CTrna_ext::C_Aa&>(src_ext.GetTRNA().GetAa()));
1101  if ( src_ext.GetTRNA().IsSetCodon() ) {
1102  mapped_feat->SetData().SetRna().SetExt().SetTRNA().SetCodon() =
1103  src_ext.GetTRNA().GetCodon();
1104  }
1105  else {
1106  mapped_feat->SetData().SetRna().SetExt().SetTRNA().ResetCodon();
1107  }
1108  CRef<CSeq_loc> ac_loc;
1109  Convert(src_anticodon, ac_loc, eCnvAlways);
1110  // Preserve partial flag
1111  ResetKeepPartial();
1112  if (ac_loc && ac_loc->Which() != CSeq_loc::e_not_set) {
1113  mapped_feat->SetData()
1114  .SetRna().SetExt().SetTRNA().SetAnticodon(*ac_loc);
1115  }
1116  else {
1117  mapped_feat->SetData()
1118  .SetRna().SetExt().SetTRNA().ResetAnticodon();
1119  }
1120 }
1121 
1122 
1123 static inline
1126 {
1127  if ( loctype != CSeq_loc_Conversion::eLocation ) {
1128  return false;
1129  }
1130  const CAnnotObject_Info& obj = ref.GetAnnotObject_Info();
1131  _ASSERT( obj.IsFeat() );
1133 
1134  if ( type == CSeqFeatData::e_Rna ) {
1135  if ( !obj.IsRegular() ) {
1136  return true;
1137  }
1138  const CSeqFeatData& data = obj.GetFeatFast()->GetData();
1139  _ASSERT( data.IsRna() );
1140  return data.GetRna().IsSetExt() &&
1141  data.GetRna().GetExt().IsTRNA() &&
1142  data.GetRna().GetExt().GetTRNA().IsSetAnticodon();
1143  }
1144  else if ( type == CSeqFeatData::e_Cdregion ) {
1145  if ( !obj.IsRegular() ) {
1146  return true;
1147  }
1148  const CSeqFeatData& data = obj.GetFeatFast()->GetData();
1149  _ASSERT( data.IsCdregion() );
1150  return data.GetCdregion().IsSetCode_break();
1151  }
1152  return false;
1153 }
1154 
1155 
1157  const CSeq_feat& orig_feat,
1158  CRef<CSeq_feat>& mapped_feat)
1159 {
1160  switch ( orig_feat.GetData().Which() ) {
1162  ConvertCdregion(ref, orig_feat, mapped_feat);
1163  break;
1164  case CSeqFeatData::e_Rna:
1165  ConvertRna(ref, orig_feat, mapped_feat);
1166  break;
1167  default:
1168  break;
1169  }
1170 }
1171 
1172 
1174 {
1175  Reset();
1176  CAnnotMapping_Info& map_info = ref.GetMappingInfo();
1177  const CAnnotObject_Info& obj = ref.GetAnnotObject_Info();
1178  switch ( obj.Which() ) {
1180  {
1181  if ( NeedFullFeature(ref, loctype) ) {
1182  CConstRef<CSeq_feat> orig_feat;
1183  if ( obj.IsRegular() ) {
1184  orig_feat = obj.GetFeatFast();
1185  }
1186  else {
1187  CRef<CSeq_feat> created_feat;
1188  CRef<CSeq_point> created_point;
1189  CRef<CSeq_interval> created_interval;
1190  const CSeq_annot_Info& annot = obj.GetSeq_annot_Info();
1191  annot.UpdateTableFeat(created_feat,
1192  created_point,
1193  created_interval,
1194  obj);
1195  orig_feat = created_feat;
1196  }
1197  CRef<CSeq_feat> mapped_feat;
1198  CRef<CSeq_loc> mapped_loc;
1199  if ( loctype == eLocation ) {
1200  ConvertFeature(ref, *orig_feat, mapped_feat);
1201  Convert(orig_feat->GetLocation(), mapped_loc);
1202  }
1203  else {
1204  Convert(orig_feat->GetProduct(), mapped_loc);
1205  }
1206  map_info.SetMappedSeq_loc(mapped_loc.GetPointerOrNull());
1207  if ( mapped_feat ) {
1208  // SetMappedLocation must be called before SetMappedSeq_feat
1209  SetMappedLocation(ref, loctype);
1210  // This will also set location and partial of mapped feature
1211  map_info.SetMappedSeq_feat(*mapped_feat);
1212  return;
1213  }
1214  }
1215  else {
1216  CConstRef<CSeq_loc> orig_loc;
1217  if ( obj.IsRegular() ) {
1218  if ( loctype == eLocation ) {
1219  orig_loc = &obj.GetFeatFast()->GetLocation();
1220  }
1221  else {
1222  orig_loc = &obj.GetFeatFast()->GetProduct();
1223  }
1224  }
1225  else {
1226  CRef<CSeq_loc> created_loc;
1227  CRef<CSeq_point> created_point;
1228  CRef<CSeq_interval> created_interval;
1229  const CSeq_annot_Info& annot = obj.GetSeq_annot_Info();
1230  if ( loctype == eLocation ) {
1231  annot.UpdateTableFeatLocation(created_loc,
1232  created_point,
1233  created_interval,
1234  obj);
1235  }
1236  else {
1237  annot.UpdateTableFeatProduct(created_loc,
1238  created_point,
1239  created_interval,
1240  obj);
1241  }
1242  orig_loc = created_loc;
1243  }
1244  CRef<CSeq_loc> mapped_loc;
1245  Convert(*orig_loc, mapped_loc);
1246  map_info.SetMappedSeq_loc(mapped_loc.GetPointerOrNull());
1247  }
1248  break;
1249  }
1251  {
1252  CRef<CSeq_loc> mapped_loc;
1254  Convert(obj.GetGraphFast()->GetLoc(), mapped_loc);
1255  map_info.SetMappedSeq_loc(mapped_loc.GetPointerOrNull());
1257  break;
1258  }
1259  default:
1260  _ASSERT(0);
1261  break;
1262  }
1263  SetMappedLocation(ref, loctype);
1264 }
1265 
1266 
1268  ELocationType loctype,
1269  const CSeq_id_Handle& id,
1270  const CRange<TSeqPos>& range,
1271  const SAnnotObject_Index& index)
1272 {
1273  Reset();
1274  CAnnotMapping_Info& map_info = ref.GetMappingInfo();
1275  const CAnnotObject_Info& obj = ref.GetAnnotObject_Info();
1276  switch ( obj.Which() ) {
1278  {
1279  if ( NeedFullFeature(ref, loctype) ) {
1280  CConstRef<CSeq_feat> orig_feat;
1281  if ( obj.IsRegular() ) {
1282  orig_feat = obj.GetFeatFast();
1283  }
1284  else {
1285  CRef<CSeq_feat> created_feat;
1286  CRef<CSeq_point> created_point;
1287  CRef<CSeq_interval> created_interval;
1288  const CSeq_annot_Info& annot = obj.GetSeq_annot_Info();
1289  annot.UpdateTableFeat(created_feat,
1290  created_point,
1291  created_interval,
1292  obj);
1293  orig_feat = created_feat;
1294  }
1295  CRef<CSeq_feat> mapped_feat;
1296  CRef<CSeq_loc> mapped_loc;
1297  if ( loctype == eLocation ) {
1298  ConvertFeature(ref, *orig_feat, mapped_feat);
1299  Convert(orig_feat->GetLocation(), mapped_loc, eCnvAlways);
1300  }
1301  else {
1302  Convert(orig_feat->GetProduct(), mapped_loc, eCnvAlways);
1303  }
1304  map_info.SetMappedSeq_loc(mapped_loc.GetPointerOrNull());
1305  if ( mapped_feat ) {
1306  // SetMappedLocation must be called before SetMappedSeq_feat
1307  SetMappedLocation(ref, loctype);
1308  // This will also set location and partial of mapped feature
1309  map_info.SetMappedSeq_feat(*mapped_feat);
1310  return;
1311  }
1312  }
1313  else if ( index.LocationIsSimple() ) {
1314  // simple conversion of location is possible
1315  // no need for ConvertFeature
1316  ConvertSimpleLoc(id, range, index);
1317  }
1318  else {
1319  CConstRef<CSeq_loc> orig_loc;
1320  if ( obj.IsRegular() ) {
1321  if ( loctype == eLocation ) {
1322  orig_loc = &obj.GetFeatFast()->GetLocation();
1323  }
1324  else {
1325  orig_loc = &obj.GetFeatFast()->GetProduct();
1326  }
1327  }
1328  else {
1329  CRef<CSeq_loc> created_loc;
1330  CRef<CSeq_point> created_point;
1331  CRef<CSeq_interval> created_interval;
1332  const CSeq_annot_Info& annot = obj.GetSeq_annot_Info();
1333  if ( loctype == eLocation ) {
1334  annot.UpdateTableFeatLocation(created_loc,
1335  created_point,
1336  created_interval,
1337  obj);
1338  }
1339  else {
1340  annot.UpdateTableFeatProduct(created_loc,
1341  created_point,
1342  created_interval,
1343  obj);
1344  }
1345  orig_loc = created_loc;
1346  }
1347  CRef<CSeq_loc> mapped_loc;
1348  Convert(*orig_loc, mapped_loc);
1349  map_info.SetMappedSeq_loc(mapped_loc.GetPointerOrNull());
1350  }
1351  break;
1352  }
1354  {
1355  CRef<CSeq_loc> mapped_loc;
1357  Convert(obj.GetGraphFast()->GetLoc(), mapped_loc);
1358  map_info.SetMappedSeq_loc(mapped_loc.GetPointerOrNull());
1360  break;
1361  }
1363  {
1364  CRef<CSeq_loc> mapped_loc;
1365  const CSeq_annot_Info& annot = obj.GetSeq_annot_Info();
1366  const CSeqTableInfo& table = annot.GetTableInfo();
1367  CConstRef<CSeq_loc> loc = table.GetTableLocation();
1368  if ( loc ) {
1369  Convert(*loc, mapped_loc);
1370  map_info.SetMappedSeq_loc(mapped_loc.GetPointerOrNull());
1371  }
1372  break;
1373  }
1374  default:
1375  _ASSERT(0);
1376  break;
1377  }
1378  SetMappedLocation(ref, loctype);
1379 }
1380 
1381 
1383  ELocationType loctype)
1384 {
1385  CAnnotMapping_Info& map_info = ref.GetMappingInfo();
1386  map_info.SetProduct(loctype == eProduct);
1387  map_info.SetPartial(m_Partial || map_info.IsPartial());
1388  map_info.SetTotalRange(m_TotalRange);
1389  if ( IsSpecialLoc() ) {
1390  if ( m_DstFuzz_from || m_DstFuzz_to ) {
1391  CRef<CSeq_loc> mapped_loc;
1392  SetDstLoc(mapped_loc);
1393  map_info.SetMappedSeq_loc(mapped_loc);
1394  }
1395  else if ( m_LastType != eMappedObjType_Seq_loc_mix ) {
1396  // special interval or point
1397  map_info.SetMappedSeq_id(GetDstId(),
1399  map_info.SetMappedStrand(m_LastStrand);
1400  if ( m_PartialFlag & fPartial_from ) {
1401  map_info.SetMappedPartial_from();
1402  }
1403  if ( m_PartialFlag & fPartial_to ) {
1404  map_info.SetMappedPartial_to();
1405  }
1406  }
1407  else {
1408  // special mix
1409  map_info.SetMappedConverstion(*this);
1410  map_info.SetMappedStrand(m_LastStrand);
1411  }
1413  }
1414  else if ( map_info.GetMappedObjectType() ==
1416  if ( m_Partial ) {
1417  // set empty location
1419  }
1420  }
1421 }
1422 
1423 
1425 {
1426  if ( !loc ) {
1427  loc.Reset(new CSeq_loc);
1428  return &loc->SetMix().Set();
1429  }
1430  if (loc->IsMix()) return &loc->SetMix().Set();
1431 
1432  CRef<CSeq_loc> new_dst(new CSeq_loc);
1433  CSeq_loc_mix::Tdata* dst_mix = &new_dst->SetMix().Set();
1434  switch (loc->Which()) {
1437  CRef<CSeq_loc> mix_loc(new CSeq_loc);
1438  mix_loc->SetInt(**ii);
1439  dst_mix->push_back(mix_loc);
1440  }
1441  break;
1443  {
1444  CPacked_seqpnt& ppnt = loc->SetPacked_pnt();
1446  CRef<CSeq_loc> mix_loc(new CSeq_loc);
1447  mix_loc->SetPnt().SetId(ppnt.SetId());
1448  if (ppnt.IsSetFuzz()) {
1449  mix_loc->SetPnt().SetFuzz(ppnt.SetFuzz());
1450  }
1451  if (ppnt.IsSetStrand()) {
1452  mix_loc->SetPnt().SetStrand(ppnt.SetStrand());
1453  }
1454  mix_loc->SetPnt().SetPoint(*pi);
1455  dst_mix->push_back(mix_loc);
1456  }
1457  break;
1458  }
1459  default:
1460  dst_mix->push_back(loc);
1461  break;
1462  }
1463  loc.Reset(new_dst);
1464  return dst_mix;
1465 }
1466 
1467 
1468 /////////////////////////////////////////////////////////////////////////////
1469 // CSeq_loc_Conversion_Set
1470 /////////////////////////////////////////////////////////////////////////////
1471 
1472 
1474  : m_SingleConv(0),
1475  m_SingleIndex(0),
1476  m_Partial(false),
1477  m_PartialHasUnconvertedId(false),
1478  m_TotalRange(TRange::GetEmpty()),
1479  m_Scope(scope)
1480 {
1481  return;
1482 }
1483 
1484 
1486  unsigned int loc_index)
1487 {
1489  if (!m_SingleConv) {
1490  m_SingleConv.Reset(&cvt);
1491  m_SingleIndex = loc_index;
1492  return;
1493  }
1494  else if ( m_CvtByIndex.empty() ) {
1496  }
1497  x_Add(cvt, loc_index);
1498 }
1499 
1500 
1502  unsigned int loc_index)
1503 {
1504  TIdMap& id_map = m_CvtByIndex[loc_index];
1505  TRangeMap& ranges = id_map[cvt.GetSrc_id_Handle()];
1507  cvt.GetSrc_to()),
1508  Ref(&cvt)));
1509 }
1510 
1511 
1514  TSeqPos from,
1515  TSeqPos to,
1516  unsigned int loc_index)
1517 {
1518  TConvByIndex::iterator index_iter = m_CvtByIndex.find(loc_index);
1519  if ( index_iter == m_CvtByIndex.end() ) {
1520  index_iter = m_CvtByIndex.find(kAllIndexes);
1521  }
1522  if ( index_iter != m_CvtByIndex.end() ) {
1523  TIdMap::iterator ranges = index_iter->second.find(id);
1524  if ( ranges != index_iter->second.end() ) {
1525  return ranges->second.begin(TRange(from, to));
1526  }
1527  }
1529  return TRangeIterator();
1530 }
1531 
1532 
1534  const CSeq_feat& orig_feat,
1535  CRef<CSeq_feat>& mapped_feat)
1536 {
1537  const CAnnotObject_Info& obj = ref.GetAnnotObject_Info();
1538  _ASSERT( obj.IsFeat() );
1539  const CSeqFeatData& src_feat_data = orig_feat.GetData();
1540  _ASSERT( src_feat_data.IsCdregion() );
1541  if (!src_feat_data.GetCdregion().IsSetCode_break()) {
1542  return;
1543  }
1544  const CCdregion& src_cd = src_feat_data.GetCdregion();
1545  // Map code-break locations
1546  const CCdregion::TCode_break& src_cb = src_cd.GetCode_break();
1547  mapped_feat.Reset(new CSeq_feat);
1548  // Initialize mapped feature
1550  *mapped_feat);
1551 
1552  // Copy Cd-region, do not change the original one
1553  CRef<CSeqFeatData> new_data(new CSeqFeatData);
1554  mapped_feat->SetData(*new_data);
1555  CCdregion& new_cd = new_data->SetCdregion();
1556 
1557  if ( src_cd.IsSetOrf() ) {
1558  new_cd.SetOrf(src_cd.GetOrf());
1559  }
1560  else {
1561  new_cd.ResetOrf();
1562  }
1563  if ( src_cd.IsSetFrame() ) {
1564  new_cd.SetFrame(src_cd.GetFrame());
1565  }
1566  else {
1567  new_cd.ResetFrame();
1568  }
1569  if ( src_cd.IsSetConflict() ) {
1570  new_cd.SetConflict(src_cd.GetConflict());
1571  }
1572  else {
1573  new_cd.ResetConflict();
1574  }
1575  if ( src_cd.IsSetGaps() ) {
1576  new_cd.SetGaps(src_cd.GetGaps());
1577  }
1578  else {
1579  new_cd.ResetGaps();
1580  }
1581  if ( src_cd.IsSetMismatch() ) {
1582  new_cd.SetMismatch(src_cd.GetMismatch());
1583  }
1584  else {
1585  new_cd.ResetMismatch();
1586  }
1587  if ( src_cd.IsSetCode() ) {
1588  new_cd.SetCode(const_cast<CGenetic_code&>(src_cd.GetCode()));
1589  }
1590  else {
1591  new_cd.ResetCode();
1592  }
1593  if ( src_cd.IsSetStops() ) {
1594  new_cd.SetStops(src_cd.GetStops());
1595  }
1596  else {
1597  new_cd.ResetStops();
1598  }
1599 
1600  CCdregion::TCode_break& mapped_cbs = new_cd.SetCode_break();
1601  mapped_cbs.clear();
1602  ITERATE(CCdregion::TCode_break, it, src_cb) {
1603  CRef<CSeq_loc> cb_loc;
1604  Convert((*it)->GetLoc(), cb_loc, 0);
1606  if (cb_loc && cb_loc->Which() != CSeq_loc::e_not_set) {
1608  cb->SetAa(const_cast<CCode_break::TAa&>((*it)->GetAa()));
1609  cb->SetLoc(*cb_loc);
1610  mapped_cbs.push_back(cb);
1611  }
1612  }
1613 }
1614 
1615 
1617  const CSeq_feat& orig_feat,
1618  CRef<CSeq_feat>& mapped_feat)
1619 {
1620  const CAnnotObject_Info& obj = ref.GetAnnotObject_Info();
1621  _ASSERT( obj.IsFeat() );
1622  const CSeqFeatData& src_feat_data = orig_feat.GetData();
1623  _ASSERT( src_feat_data.IsRna() );
1624  if (!src_feat_data.GetRna().IsSetExt() ||
1625  !src_feat_data.GetRna().GetExt().IsTRNA() ||
1626  !src_feat_data.GetRna().GetExt().GetTRNA().IsSetAnticodon()) {
1627  return;
1628  }
1629  const CRNA_ref::TExt& src_ext = src_feat_data.GetRna().GetExt();
1630  // Map anticodon location
1631  const CSeq_loc& src_anticodon = src_ext.GetTRNA().GetAnticodon();
1632  mapped_feat.Reset(new CSeq_feat);
1633  // Initialize mapped feature
1635  *mapped_feat);
1636 
1637  // Copy RNA-ext, do not change the original one
1638  CRef<CRNA_ref::TExt> new_ext(new CRNA_ref::TExt);
1639 
1640  // Shallow-copy the feature, replace data.rna.ext.trna.anticodon
1641  // with the mapped location
1642  mapped_feat->Assign(*obj.GetFeatFast(), eShallow);
1643  mapped_feat->SetData(*(new CSeqFeatData));
1644  mapped_feat->SetData().Assign(src_feat_data, eShallow);
1645  mapped_feat->SetData().SetRna(*(new CRNA_ref));
1646 
1647  mapped_feat->SetData().SetRna().SetType(src_feat_data.GetRna().GetType());
1648  if ( src_feat_data.GetRna().IsSetPseudo() ) {
1649  mapped_feat->SetData().SetRna().SetPseudo(
1650  src_feat_data.GetRna().GetPseudo());
1651  }
1652  else {
1653  mapped_feat->SetData().SetRna().ResetPseudo();
1654  }
1655  mapped_feat->SetData().SetRna().SetExt().SetTRNA().SetAa(
1656  const_cast<CTrna_ext::C_Aa&>(src_ext.GetTRNA().GetAa()));
1657  if ( src_ext.GetTRNA().IsSetCodon() ) {
1658  mapped_feat->SetData().SetRna().SetExt().SetTRNA().SetCodon() =
1659  src_ext.GetTRNA().GetCodon();
1660  }
1661  else {
1662  mapped_feat->SetData().SetRna().SetExt().SetTRNA().ResetCodon();
1663  }
1664  CRef<CSeq_loc> ac_loc;
1665  Convert(src_anticodon, ac_loc, 0);
1666  // Preserve partial flag
1668  if (ac_loc && ac_loc->Which() != CSeq_loc::e_not_set) {
1669  mapped_feat->SetData()
1670  .SetRna().SetExt().SetTRNA().SetAnticodon(*ac_loc);
1671  }
1672  else {
1673  mapped_feat->SetData()
1674  .SetRna().SetExt().SetTRNA().ResetAnticodon();
1675  }
1676 }
1677 
1678 
1680  const CSeq_feat& orig_feat,
1681  CRef<CSeq_feat>& mapped_feat)
1682 {
1683  switch ( orig_feat.GetData().Which() ) {
1685  ConvertCdregion(ref, orig_feat, mapped_feat);
1686  break;
1687  case CSeqFeatData::e_Rna:
1688  ConvertRna(ref, orig_feat, mapped_feat);
1689  break;
1690  default:
1691  break;
1692  }
1693 }
1694 
1695 
1697 {
1699  m_Partial = false;
1700  m_PartialHasUnconvertedId = false;
1701  m_GraphRanges.Reset();
1702 }
1703 
1704 
1707  loctype)
1708 {
1709  if ( !m_SingleConv ) {
1711  // Special case - empty set for filtering duplicates only,
1712  // no mapping required
1713  return;
1714  }
1715  if ( m_CvtByIndex.empty() && !ref.IsAlign() ) {
1716  // No multiple mappings
1717  m_SingleConv->Convert(ref, loctype);
1722  return;
1723  }
1724 
1725  Reset();
1726 
1727  CRef<CSeq_feat> mapped_feat;
1728  CAnnotMapping_Info& map_info = ref.GetMappingInfo();
1729  const CAnnotObject_Info& obj = ref.GetAnnotObject_Info();
1730  switch ( obj.Which() ) {
1732  {
1733  CRef<CSeq_loc> mapped_loc;
1734  const CSeq_loc* src_loc;
1735  unsigned int loc_index = 0;
1736  if ( loctype != CSeq_loc_Conversion::eProduct ) {
1737  ConvertFeature(ref, *obj.GetFeatFast(), mapped_feat);
1738  src_loc = &obj.GetFeatFast()->GetLocation();
1739  }
1740  else {
1741  src_loc = &obj.GetFeatFast()->GetProduct();
1742  loc_index = 1;
1743  }
1744  Convert(*src_loc, mapped_loc, loc_index);
1745  map_info.SetMappedSeq_loc(mapped_loc.GetPointerOrNull());
1746  break;
1747  }
1749  {
1750  CRef<CSeq_loc> mapped_loc;
1752  Convert(obj.GetGraphFast()->GetLoc(), mapped_loc, 0);
1753  map_info.SetMappedSeq_loc(mapped_loc.GetPointerOrNull());
1755  break;
1756  }
1758  {
1759  map_info.SetMappedSeq_align_Cvts(*this);
1760  break;
1761  }
1762  default:
1763  _ASSERT(0);
1764  break;
1765  }
1766  map_info.SetProduct(loctype == CSeq_loc_Conversion::eProduct);
1767  map_info.SetPartial(m_Partial || map_info.IsPartial());
1768  map_info.SetTotalRange(m_TotalRange);
1769  if ( mapped_feat ) {
1770  // This will also set location and partial of the mapped feature
1771  map_info.SetMappedSeq_feat(*mapped_feat);
1772  }
1773 }
1774 
1775 
1777  CRef<CSeq_loc>& dst,
1778  unsigned int loc_index)
1779 {
1780  bool res = false;
1782  src.GetPoint(), src.GetPoint(), loc_index);
1783  for ( ; mit; ++mit) {
1784  CSeq_loc_Conversion& cvt = *mit->second;
1785  cvt.Reset();
1786  if (cvt.ConvertPoint(src)) {
1787  dst->SetPnt(*cvt.GetDstPoint());
1788  m_TotalRange += cvt.GetTotalRange();
1789  res = true;
1790  break;
1791  }
1792  }
1793  if ( !res && m_GraphRanges ) {
1795  }
1796  m_Partial |= !res;
1797  return res;
1798 }
1799 
1800 
1801 namespace {
1802  struct FConversions_Less
1803  {
1804  bool operator()(const CSeq_loc_Conversion& cvt1,
1805  const CSeq_loc_Conversion& cvt2) const
1806  {
1807  if ( cvt1.GetSrc_from() != cvt2.GetSrc_from() ) {
1808  return cvt1.GetSrc_from() < cvt2.GetSrc_from();
1809  }
1810  if ( cvt1.GetSrc_to() != cvt2.GetSrc_to() ) {
1811  return cvt1.GetSrc_to() > cvt2.GetSrc_to();
1812  }
1813  //return &cvt1 < &cvt2;
1814  return false;
1815  }
1816  bool operator()(const CRef<CSeq_loc_Conversion>& cvt1,
1817  const CRef<CSeq_loc_Conversion>& cvt2) const
1818  {
1819  return (*this)(*cvt1, *cvt2);
1820  }
1821  };
1822 
1823  struct FConversions_ReverseLess
1824  {
1825  bool operator()(const CSeq_loc_Conversion& cvt1,
1826  const CSeq_loc_Conversion& cvt2) const
1827  {
1828  if ( cvt1.GetSrc_to() != cvt2.GetSrc_to() ) {
1829  return cvt1.GetSrc_to() > cvt2.GetSrc_to();
1830  }
1831  if ( cvt1.GetSrc_from() != cvt2.GetSrc_from() ) {
1832  return cvt1.GetSrc_from() < cvt2.GetSrc_from();
1833  }
1834  //return &cvt1 < &cvt2;
1835  return false;
1836  }
1837  bool operator()(const CRef<CSeq_loc_Conversion>& cvt1,
1838  const CRef<CSeq_loc_Conversion>& cvt2) const
1839  {
1840  return (*this)(*cvt1, *cvt2);
1841  }
1842  };
1843 
1844  struct FConversions_Equal
1845  {
1846  bool operator()(const CSeq_loc_Conversion& cvt1,
1847  const CSeq_loc_Conversion& cvt2) const
1848  {
1849  return cvt1.GetSrc_from() == cvt2.GetSrc_from() &&
1850  cvt1.GetSrc_to() == cvt2.GetSrc_to();
1851  }
1852  bool operator()(const CRef<CSeq_loc_Conversion>& cvt1,
1853  const CRef<CSeq_loc_Conversion>& cvt2) const
1854  {
1855  return (*this)(*cvt1, *cvt2);
1856  }
1857  };
1858 }
1859 
1860 
1862  CRef<CSeq_loc>& dst,
1863  unsigned int loc_index)
1864 {
1866  CPacked_seqint::Tdata& ints = tmp->SetPacked_int().Set();
1867  TRange total_range(TRange::GetEmpty());
1868  bool revert_order = (src.IsSetStrand() && IsReverse(src.GetStrand()));
1869  bool res = false;
1870  typedef vector< CRef<CSeq_loc_Conversion> > TConversions;
1871  TConversions cvts;
1873  src.GetFrom(), src.GetTo(), loc_index);
1874  for ( ; mit; ++mit) {
1875  cvts.push_back(mit->second);
1876  }
1877  if ( revert_order ) {
1878  reverse(cvts.begin(), cvts.end());
1879  stable_sort(cvts.begin(), cvts.end(), FConversions_ReverseLess());
1880  cvts.erase(unique(cvts.begin(), cvts.end(), FConversions_Equal()),
1881  cvts.end());
1882  }
1883  else {
1884  stable_sort(cvts.begin(), cvts.end(), FConversions_Less());
1885  cvts.erase(unique(cvts.begin(), cvts.end(), FConversions_Equal()),
1886  cvts.end());
1887  }
1888  CRef<CSeq_interval> last_int;
1889  TSeqPos last_to = kInvalidSeqPos;
1890  TSeqPos graph_offset = m_GraphRanges ? m_GraphRanges->GetOffset() : 0;
1891  NON_CONST_ITERATE ( TConversions, it, cvts ) {
1892  CRef<CSeq_loc_Conversion> cvt = *it;
1893  cvt->Reset();
1895  if (cvt->ConvertInterval(src)) {
1896  CRef<CSeq_interval> mapped = cvt->GetDstInterval();
1897  if ( revert_order ) {
1898  if (last_int && cvt->GetSrc_to() == last_to - 1) {
1899  last_int->SetPartialStop(false, eExtreme_Biological);
1900  mapped->SetPartialStart(false, eExtreme_Biological);
1901  //last_int->ResetFuzz_from();
1902  //mapped->ResetFuzz_to();
1903  }
1904  last_to = cvt->GetSrc_from();
1905  }
1906  else {
1907  if (last_int && cvt->GetSrc_from() == last_to + 1) {
1908  last_int->SetPartialStop(false, eExtreme_Biological);
1909  mapped->SetPartialStart(false, eExtreme_Biological);
1910  //last_int->ResetFuzz_to();
1911  //mapped->ResetFuzz_from();
1912  }
1913  last_to = cvt->GetSrc_to();
1914  }
1915  last_int = mapped;
1916  ints.push_back(mapped);
1917  total_range += cvt->GetTotalRange();
1918  res = true;
1919  }
1920  if (m_GraphRanges) {
1921  // All conversions start with the same offset
1922  m_GraphRanges->SetOffset(graph_offset);
1923  }
1924  }
1925  if ( m_GraphRanges ) {
1926  // Now it's time to update the offset
1928  }
1929  if (ints.size() > 1) {
1930  dst.Reset(tmp);
1931  }
1932  else if (ints.size() == 1) {
1933  dst->SetInt(**ints.begin());
1934  }
1935  m_TotalRange += total_range;
1936  // does not guarantee the whole interval is mapped, but should work
1937  // in normal situations
1938  m_Partial |= (!res || src.GetLength() > total_range.GetLength());
1939  return res;
1940 }
1941 
1942 
1944  CRef<CSeq_loc>& dst,
1945  unsigned int loc_index)
1946 {
1947  bool res = false;
1949  const CPacked_seqint::Tdata& src_ints = src.GetPacked_int().Get();
1950  CPacked_seqint::Tdata* dst_ints = &dst->SetPacked_int().Set();
1951  // If the result contains NULLs, may need to use mix instead.
1952  CSeq_loc_mix::Tdata* dst_mix = 0;
1953  bool last_truncated = false;
1954  ITERATE ( CPacked_seqint::Tdata, i, src_ints ) {
1955  CRef<CSeq_loc> dst_int(new CSeq_loc);
1956  bool mapped = ConvertInterval(**i, dst_int, loc_index);
1957  if (mapped) {
1958  if ( last_truncated &&
1960  !dst_int->IsPartialStart(eExtreme_Biological) ) {
1961  dst_int->SetPartialStart(true, eExtreme_Biological);
1962  }
1963  if (dst_mix) {
1964  dst_mix->push_back(dst_int);
1965  }
1966  else {
1967  if ( dst_int->IsInt() ) {
1968  dst_ints->push_back(CRef<CSeq_interval>(&dst_int->SetInt()));
1969  }
1970  else if ( dst_int->IsPacked_int() ) {
1971  dst_ints->splice(dst_ints->end(),
1972  dst_int->SetPacked_int().Set());
1973  }
1974  else {
1975  dst_mix = CSeq_loc_Conversion::s_ConvertToMix(dst);
1976  _ASSERT(dst_mix);
1977  dst_mix->push_back(dst_int);
1978  }
1979  }
1980  }
1981  else {
1982  if (last_truncated) continue;
1984  dst_mix = CSeq_loc_Conversion::s_ConvertToMix(dst);
1985  _ASSERT(dst_mix);
1986  CRef<CSeq_loc> null_loc(new CSeq_loc);
1987  null_loc->SetNull();
1988  dst_mix->push_back(null_loc);
1989  }
1990  else if (!dst->IsPartialStop(eExtreme_Biological)) {
1991  dst->SetPartialStop(true, eExtreme_Biological);
1992  }
1993  }
1994  m_Partial |= !mapped;
1995  res |= mapped;
1996  last_truncated = !mapped;
1997  }
1998  return res;
1999 }
2000 
2001 
2003  CRef<CSeq_loc>& dst,
2004  unsigned int loc_index)
2005 {
2006  bool res = false;
2008  const CPacked_seqpnt& src_pack_pnts = src.GetPacked_pnt();
2009  const CPacked_seqpnt::TPoints& src_pnts = src_pack_pnts.GetPoints();
2010  // using mix, not point, since mappings may have
2011  // different strand, fuzz etc.
2012  if (!dst) {
2013  dst.Reset(new CSeq_loc);
2014  }
2015  CSeq_loc_mix::Tdata& locs = dst->SetMix().Set();
2016  ITERATE ( CPacked_seqpnt::TPoints, i, src_pnts ) {
2017  bool mapped = false;
2018  TSeqPos graph_offset = m_GraphRanges ? m_GraphRanges->GetOffset() : 0;
2020  CSeq_id_Handle::GetHandle(src_pack_pnts.GetId()),
2021  *i, *i,
2022  loc_index);
2023  for ( ; mit; ++mit) {
2024  CSeq_loc_Conversion& cvt = *mit->second;
2025  cvt.Reset();
2026  if ( !cvt.GoodSrcId(src_pack_pnts.GetId()) ) {
2027  continue;
2028  }
2029  TSeqPos dst_pos = cvt.ConvertPoint(*i,
2030  src_pack_pnts.IsSetStrand() ?
2031  src_pack_pnts.GetStrand() : eNa_strand_unknown);
2032  if ( dst_pos != kInvalidSeqPos ) {
2033  CRef<CSeq_loc> pnt(new CSeq_loc);
2034  pnt->SetPnt(*cvt.GetDstPoint());
2035  _ASSERT(pnt);
2036  locs.push_back(pnt);
2037  m_TotalRange += cvt.GetTotalRange();
2038  mapped = true;
2039  break;
2040  }
2041  if ( m_GraphRanges ) {
2042  m_GraphRanges->SetOffset(graph_offset);
2043  }
2044  }
2045  if ( m_GraphRanges ) {
2047  }
2048  if (!mapped && CSeq_loc_Mapper::GetNonMappingAsNull()) {
2049  CRef<CSeq_loc> null_loc(new CSeq_loc);
2050  null_loc->SetNull();
2051  locs.push_back(null_loc);
2052  }
2053  m_Partial |= !mapped;
2054  res |= mapped;
2055  }
2056  return res;
2057 }
2058 
2059 
2061  CRef<CSeq_loc>& dst,
2062  unsigned int loc_index)
2063 {
2064  bool res = false;
2065  _ASSERT(src.Which() == CSeq_loc::e_Mix);
2066  const CSeq_loc_mix::Tdata& src_mix = src.GetMix().Get();
2067  CRef<CSeq_loc> dst_loc;
2068  CSeq_loc_mix::Tdata& dst_mix = dst->SetMix().Set();
2069  bool last_truncated = false;
2070  ITERATE ( CSeq_loc_mix::Tdata, i, src_mix ) {
2071  dst_loc.Reset(new CSeq_loc);
2072  if ( Convert(**i, dst_loc, loc_index) ) {
2073  _ASSERT(dst_loc);
2074  if ( last_truncated &&
2076  !dst_loc->IsPartialStart(eExtreme_Biological) ) {
2077  dst_loc->SetPartialStart(true, eExtreme_Biological);
2078  }
2079  dst_mix.push_back(dst_loc);
2080  res = true;
2081  last_truncated = false;
2082  }
2083  else {
2084  if (last_truncated) continue;
2086  CRef<CSeq_loc> null_loc(new CSeq_loc);
2087  null_loc->SetNull();
2088  dst_mix.push_back(null_loc);
2089  }
2090  else if (!dst->IsPartialStop(eExtreme_Biological)) {
2091  dst->SetPartialStop(true, eExtreme_Biological);
2092  }
2093  last_truncated = true;
2094  }
2095  }
2096  m_Partial |= !res;
2097  return res;
2098 }
2099 
2100 
2102  CRef<CSeq_loc>& dst,
2103  unsigned int loc_index)
2104 {
2105  bool res = false;
2106  _ASSERT(src.Which() == CSeq_loc::e_Equiv);
2107  const CSeq_loc_equiv::Tdata& src_equiv = src.GetEquiv().Get();
2108  CRef<CSeq_loc> dst_loc;
2109  CSeq_loc_equiv::Tdata& dst_equiv = dst->SetEquiv().Set();
2110  ITERATE ( CSeq_loc_equiv::Tdata, i, src_equiv ) {
2111  if ( Convert(**i, dst_loc, loc_index) ||
2113  if (!dst_loc) {
2114  dst_loc.Reset(new CSeq_loc);
2115  dst_loc->SetNull();
2116  }
2117  dst_equiv.push_back(dst_loc);
2118  res = true;
2119  }
2120  }
2121  m_Partial |= !res;
2122  return res;
2123 }
2124 
2125 
2127  CRef<CSeq_loc>& dst,
2128  unsigned int loc_index)
2129 {
2130  bool res = false;
2131  _ASSERT(src.Which() == CSeq_loc::e_Bond);
2132  const CSeq_bond& src_bond = src.GetBond();
2133  // using mix, not bond, since mappings may have
2134  // different strand, fuzz etc.
2135  dst->SetBond();
2136  CRef<CSeq_point> pntA;
2137  CRef<CSeq_point> pntB;
2138  {{
2140  CSeq_id_Handle::GetHandle(src_bond.GetA().GetId()),
2141  src_bond.GetA().GetPoint(), src_bond.GetA().GetPoint(),
2142  loc_index);
2143  for ( ; mit && !pntA; ++mit) {
2144  CSeq_loc_Conversion& cvt = *mit->second;
2145  cvt.Reset();
2146  if (cvt.ConvertPoint(src_bond.GetA())) {
2147  pntA = cvt.GetDstPoint();
2148  m_TotalRange += cvt.GetTotalRange();
2149  res = true;
2150  }
2151  }
2152  }}
2153  if ( src_bond.IsSetB() ) {
2155  CSeq_id_Handle::GetHandle(src_bond.GetB().GetId()),
2156  src_bond.GetB().GetPoint(), src_bond.GetB().GetPoint(),
2157  loc_index);
2158  for ( ; mit && !pntB; ++mit) {
2159  CSeq_loc_Conversion& cvt = *mit->second;
2160  cvt.Reset();
2161  if (!pntB && cvt.ConvertPoint(src_bond.GetB())) {
2162  pntB = cvt.GetDstPoint();
2163  m_TotalRange += cvt.GetTotalRange();
2164  res = true;
2165  }
2166  }
2167  }
2168  CSeq_bond& dst_bond = dst->SetBond();
2169  if ( pntA || pntB ) {
2170  if ( pntA ) {
2171  dst_bond.SetA(*pntA);
2172  }
2173  else {
2174  dst_bond.SetA().Assign(src_bond.GetA());
2175  }
2176  if ( pntB ) {
2177  dst_bond.SetB(*pntB);
2178  }
2179  else if ( src_bond.IsSetB() ) {
2180  dst_bond.SetB().Assign(src_bond.GetB());
2181  }
2182  }
2183  m_Partial |= (!pntA || !pntB);
2184  return res;
2185 }
2186 
2187 
2189  CRef<CSeq_loc>& dst,
2190  unsigned int loc_index)
2191 {
2192  dst.Reset(new CSeq_loc);
2193  bool res = false;
2194  switch ( src.Which() ) {
2195  case CSeq_loc::e_not_set:
2196  case CSeq_loc::e_Feat:
2197  // Nothing to do, although this should never happen --
2198  // the seq_loc is intersecting with the conv. loc.
2199  _ASSERT("this cannot happen" && 0);
2200  break;
2201  case CSeq_loc::e_Null:
2202  {
2203  dst->SetNull();
2204  res = true;
2205  break;
2206  }
2207  case CSeq_loc::e_Empty:
2208  {
2211  TRange::GetWhole().GetTo(),
2212  loc_index);
2213  for ( ; mit; ++mit) {
2214  CSeq_loc_Conversion& cvt = *mit->second;
2215  cvt.Reset();
2216  if ( cvt.GoodSrcId(src.GetEmpty()) ) {
2217  dst->SetEmpty(cvt.GetDstId());
2218  res = true;
2219  break;
2220  }
2221  }
2222  break;
2223  }
2224  case CSeq_loc::e_Whole:
2225  {
2226  const CSeq_id& src_id = src.GetWhole();
2227  // Convert to the allowed master seq interval
2228  CSeq_interval whole_int;
2229  whole_int.SetId().Assign(src_id);
2230  whole_int.SetFrom(0);
2231  CBioseq_Handle bh =
2234  whole_int.SetTo(bh.GetBioseqLength());
2235  res = ConvertInterval(whole_int, dst, loc_index);
2236  break;
2237  }
2238  case CSeq_loc::e_Int:
2239  {
2240  res = ConvertInterval(src.GetInt(), dst, loc_index);
2241  break;
2242  }
2243  case CSeq_loc::e_Pnt:
2244  {
2245  res = ConvertPoint(src.GetPnt(), dst, loc_index);
2246  break;
2247  }
2249  {
2250  res = ConvertPacked_int(src, dst, loc_index);
2251  break;
2252  }
2254  {
2255  res = ConvertPacked_pnt(src, dst, loc_index);
2256  break;
2257  }
2258  case CSeq_loc::e_Mix:
2259  {
2260  res = ConvertMix(src, dst, loc_index);
2261  break;
2262  }
2263  case CSeq_loc::e_Equiv:
2264  {
2265  res = ConvertEquiv(src, dst, loc_index);
2266  break;
2267  }
2268  case CSeq_loc::e_Bond:
2269  {
2270  res = ConvertBond(src, dst, loc_index);
2271  break;
2272  }
2273  default:
2274  NCBI_THROW(CAnnotException, eBadLocation,
2275  "Unsupported location type");
2276  }
2277  return res;
2278 }
2279 
2280 
2282  CRef<CSeq_align>& dst)
2283 {
2284  CSeq_loc_Mapper loc_mapper(0, NULL);
2285  CSeq_align_Mapper mapper(src, loc_mapper);
2286  mapper.Convert(*this);
2287  dst = mapper.GetDstAlign();
2288 }
2289 
2290 
static CRef< CScope > m_Scope
User-defined methods of the data storage class.
User-defined methods of the data storage class.
bool IsReverse(ENa_strand s)
Definition: Na_strand.hpp:75
ENa_strand Reverse(ENa_strand s)
Definition: Na_strand.hpp:90
@ eExtreme_Biological
5' and 3'
Definition: Na_strand.hpp:62
User-defined methods of the data storage class.
User-defined methods of the data storage class.
#define false
Definition: bool.h:36
Annotation iterators exceptions.
void InitializeMappedSeq_feat(const CSeq_feat &src, CSeq_feat &dst) const
void SetMappedSeq_align_Cvts(CSeq_loc_Conversion_Set &cvts)
void SetMappedPartial_to(void)
void SetMappedSeq_id(CSeq_id &id)
void SetTotalRange(const TRange &range)
void SetProduct(bool product)
void SetGraphRanges(CGraphRanges *ranges)
void SetMappedPartial_from(void)
EMappedObjectType GetMappedObjectType(void) const
void SetMappedSeq_loc(CSeq_loc &loc)
void SetMappedConverstion(CSeq_loc_Conversion &cvt)
void SetMappedSeq_feat(CSeq_feat &feat)
void SetMappedStrand(ENa_strand strand)
bool IsPartial(void) const
void SetPartial(bool value)
TAnnotType Which(void) const
const CSeq_annot_Info & GetSeq_annot_Info(void) const
bool IsRegular(void) const
const CSeq_feat * GetFeatFast(void) const
TFeatType GetFeatType(void) const
bool IsFeat(void) const
const CSeq_graph * GetGraphFast(void) const
const CAnnotObject_Info & GetAnnotObject_Info(void) const
bool IsAlign(void) const
CAnnotMapping_Info & GetMappingInfo(void) const
CBioseq_Handle –.
CCdregion –.
Definition: Cdregion.hpp:66
CCode_break –.
Definition: Code_break.hpp:66
Helper class for mapping graphs.
@RNA_ref.hpp User-defined methods of the data storage class.
Definition: RNA_ref.hpp:54
CBioseq_Handle GetBioseqHandle(const CSeq_id_Handle &id, int get_flag)
CScope –.
Definition: scope.hpp:92
void SetCdregion(TCdregion &v)
Iterator over CSeqMap.
Definition: seq_map_ci.hpp:252
CRef< CSeq_align > GetDstAlign(void) const
Create mapped alignment.
void Convert(CSeq_loc_Conversion_Set &cvts)
void UpdateTableFeatLocation(CRef< CSeq_loc > &seq_loc, CRef< CSeq_point > &seq_point, CRef< CSeq_interval > &seq_interval, const CAnnotObject_Info &feat_info) const
void UpdateTableFeatProduct(CRef< CSeq_loc > &seq_loc, CRef< CSeq_point > &seq_point, CRef< CSeq_interval > &seq_interval, const CAnnotObject_Info &feat_info) const
void UpdateTableFeat(CRef< CSeq_feat > &seq_feat, CRef< CSeq_point > &seq_point, CRef< CSeq_interval > &seq_interval, const CAnnotObject_Info &feat_info) const
const CSeqTableInfo & GetTableInfo(void) const
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
bool IsPartialStart(ESeqLocExtremes ext) const
TSeqPos GetLength(void) const
void SetPartialStart(bool val, ESeqLocExtremes ext)
void SetPartialStop(bool val, ESeqLocExtremes ext)
bool ConvertPacked_int(const CSeq_loc &src, CRef< CSeq_loc > &dst, unsigned int loc_index)
void ConvertCdregion(CAnnotObject_Ref &ref, const CSeq_feat &orig_feat, CRef< CSeq_feat > &mapped_feat)
bool ConvertEquiv(const CSeq_loc &src, CRef< CSeq_loc > &dst, unsigned int loc_index)
unsigned int m_SingleIndex
bool ConvertPoint(const CSeq_point &src, CRef< CSeq_loc > &dst, unsigned int loc_index)
bool ConvertMix(const CSeq_loc &src, CRef< CSeq_loc > &dst, unsigned int loc_index)
TSeq_id_Handles m_Dst_id_Handles
CRange< TSeqPos > TRange
void Add(CSeq_loc_Conversion &cvt, unsigned int loc_index)
void ConvertFeature(CAnnotObject_Ref &ref, const CSeq_feat &orig_feat, CRef< CSeq_feat > &mapped_feat)
bool ConvertPacked_pnt(const CSeq_loc &src, CRef< CSeq_loc > &dst, unsigned int loc_index)
TRangeIterator BeginRanges(CSeq_id_Handle id, TSeqPos from, TSeqPos to, unsigned int loc_index)
void ConvertRna(CAnnotObject_Ref &ref, const CSeq_feat &orig_feat, CRef< CSeq_feat > &mapped_feat)
bool ConvertBond(const CSeq_loc &src, CRef< CSeq_loc > &dst, unsigned int loc_index)
void x_Add(CSeq_loc_Conversion &cvt, unsigned int loc_index)
CSeq_loc_Conversion_Set(CHeapScope &scope)
CRef< CGraphRanges > m_GraphRanges
void Convert(CAnnotObject_Ref &obj, CSeq_loc_Conversion::ELocationType loctype)
bool ConvertInterval(const CSeq_interval &src, CRef< CSeq_loc > &dst, unsigned int loc_index)
TRangeMap::iterator TRangeIterator
CRef< CSeq_loc_Conversion > m_SingleConv
void ConvertMix(const CSeq_loc &src, CRef< CSeq_loc > &dst, EConvertFlag flag=eCnvDefault)
void CheckDstMix(void)
void ConvertFeature(CAnnotObject_Ref &ref, const CSeq_feat &orig_feat, CRef< CSeq_feat > &mapped_feat)
CSeq_id_Handle m_Src_id_Handle
CRef< CSeq_point > GetDstPoint(void)
bool HasUnconvertedId(void) const
bool Convert(const CSeq_loc &src, CRef< CSeq_loc > &dst, EConvertFlag flag=eCnvDefault)
CRef< CSeq_loc_mix > GetDstMix(void)
bool IsPartial(void) const
void ConvertPacked_int(const CSeq_loc &src, CRef< CSeq_loc > &dst)
void MakeDstMix(CSeq_loc_mix &dst, const CSeq_loc_mix &src) const
CSeq_id & GetDstId(void)
CRange< TSeqPos > TRange
Definition: seq_loc_cvt.hpp:79
CConstRef< CInt_fuzz > m_DstFuzz_to
CRef< CSeq_loc > m_Dst_loc_Empty
void ConvertRna(CAnnotObject_Ref &ref, const CSeq_feat &orig_feat, CRef< CSeq_feat > &mapped_feat)
bool ConvertInterval(TSeqPos src_from, TSeqPos src_to, ENa_strand src_strand)
CConstRef< CInt_fuzz > ReverseFuzz(const CInt_fuzz &fuzz) const
void ResetKeepPartial(void)
void ConvertEquiv(const CSeq_loc &src, CRef< CSeq_loc > &dst)
const TRange & GetTotalRange(void) const
TSeqPos GetSrc_from(void) const
static CSeq_loc_mix::Tdata * s_ConvertToMix(CRef< CSeq_loc > &loc)
void ConvertSimpleLoc(const CSeq_id_Handle &src_id, const CRange< TSeqPos > src_range, const SAnnotObject_Index &src_index)
void SetMappedLocation(CAnnotObject_Ref &ref, ELocationType loctype)
ENa_strand m_LastStrand
bool GoodSrcId(const CSeq_id &id)
EMappedObjectType m_LastType
void CheckDstInterval(void)
ENa_strand ConvertStrand(ENa_strand strand) const
bool IsSpecialLoc(void) const
CSeq_id_Handle m_Dst_id_Handle
void ConvertPacked_pnt(const CSeq_loc &src, CRef< CSeq_loc > &dst)
TPartialFlag m_PartialFlag
void ConvertCdregion(CAnnotObject_Ref &ref, const CSeq_feat &orig_feat, CRef< CSeq_feat > &mapped_feat)
CConstRef< CInt_fuzz > m_DstFuzz_from
TSeqPos GetSrc_to(void) const
void CombineWith(CSeq_loc_Conversion &cvt)
TRange GetSrcRange(void) const
bool ConvertPoint(TSeqPos src_pos, ENa_strand src_strand)
bool ConvertSimpleMix(const CSeq_loc &src)
void SetDstLoc(CRef< CSeq_loc > &loc)
TSeqPos ConvertPos(TSeqPos src_pos)
void SetConversion(const CSeqMap_CI &seg)
CConstRef< CSeq_loc > m_SrcLoc
TRange GetDstRange(void)
void ConvertBond(const CSeq_loc &src, CRef< CSeq_loc > &dst)
const CSeq_id_Handle & GetDst_id_Handle(void) const
TSignedSeqPos m_Shift
CSeq_loc_Conversion(CSeq_loc &master_loc_empty, const CSeq_id_Handle &dst_id, const CSeqMap_CI &seg, const CSeq_id_Handle &src_id, CScope *scope)
Definition: seq_loc_cvt.cpp:64
const CSeq_id_Handle & GetSrc_id_Handle(void) const
CRef< CSeq_interval > GetDstInterval(void)
CRef< CGraphRanges > m_GraphRanges
void CheckDstPoint(void)
CSeq_loc_Mapper –.
aa this carries
Definition: Trna_ext_.hpp:96
const_iterator end() const
Definition: map.hpp:152
bool empty() const
Definition: map.hpp:149
const_iterator find(const key_type &key) const
Definition: map.hpp:153
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
#define ITERATE(Type, Var, Cont)
ITERATE macro to sequence through container elements.
Definition: ncbimisc.hpp:815
#define NON_CONST_ITERATE(Type, Var, Cont)
Non constant version of ITERATE macro.
Definition: ncbimisc.hpp:822
const TSeqPos kInvalidSeqPos
Define special value for invalid sequence position.
Definition: ncbimisc.hpp:878
void swap(NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair1, NCBI_NS_NCBI::pair_base_member< T1, T2 > &pair2)
Definition: ncbimisc.hpp:1508
#define NULL
Definition: ncbistd.hpp:225
#define NCBI_THROW(exception_class, err_code, message)
Generic macro to throw an exception, given the exception class, error code and message string.
Definition: ncbiexpt.hpp:704
const float pi
Definition: math.hpp:54
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Set object to copy of another one.
@ eShallow
Assign/Compare pointers only.
Definition: serialdef.hpp:193
static CSeq_id_Handle GetHandle(const CSeq_id &id)
Normal way of getting a handle, works for any seq-id.
void SetPacked_int(TPacked_int &v)
Definition: Seq_loc.hpp:984
void SetMix(TMix &v)
Definition: Seq_loc.hpp:987
void SetPacked_pnt(TPacked_pnt &v)
Definition: Seq_loc.hpp:986
bool IsPartialStart(ESeqLocExtremes ext) const
check start or stop of location for e_Lim fuzz
Definition: Seq_loc.cpp:3222
void SetPnt(TPnt &v)
Definition: Seq_loc.hpp:985
const_iterator begin(void) const
Definition: Seq_loc.cpp:1028
void SetEmpty(TEmpty &v)
Definition: Seq_loc.hpp:981
void SetInt(TInt &v)
Definition: Seq_loc.hpp:983
void SetPartialStart(bool val, ESeqLocExtremes ext)
set / remove e_Lim fuzz on start or stop (lt/gt - indicating partial interval)
Definition: Seq_loc.cpp:3280
void SetEquiv(TEquiv &v)
Definition: Seq_loc.hpp:988
void SetBond(TBond &v)
Definition: Seq_loc.hpp:989
void SetPartialStop(bool val, ESeqLocExtremes ext)
Definition: Seq_loc.cpp:3313
void SetNull(void)
Override all setters to incorporate cache invalidation.
Definition: Seq_loc.hpp:960
bool IsPartialStop(ESeqLocExtremes ext) const
Definition: Seq_loc.cpp:3251
void AddRange(const TRange &rg)
TSeqPos GetOffset(void) const
void IncOffset(TSeqPos inc)
static bool GetNonMappingAsNull(void)
void SetOffset(TSeqPos offset)
@ eGetBioseq_All
Search bioseq, load if not loaded yet.
Definition: scope.hpp:128
TSeqPos GetBioseqLength(void) const
TSeqPos GetRefPosition(void) const
Definition: seq_map_ci.hpp:693
bool GetRefMinusStrand(void) const
Definition: seq_map_ci.hpp:700
TSeqPos GetPosition(void) const
return position of current segment in sequence
Definition: seq_map_ci.hpp:665
TSeqPos GetLength(void) const
return length of current segment
Definition: seq_map_ci.hpp:672
CConstRef< C > ConstRef(const C *object)
Template function for conversion of const object pointer to CConstRef.
Definition: ncbiobj.hpp:2024
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:1439
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
bool NotEmpty(void) const THROWS_NONE
Check if CRef is not empty – pointing to an object and has a non-null value.
Definition: ncbiobj.hpp:726
TObjectType * GetPointerOrNull(void) THROWS_NONE
Get pointer value.
Definition: ncbiobj.hpp:986
TObjectType & GetNCObject(void) const
Get object.
Definition: ncbiobj.hpp:1187
position_type GetLength(void) const
Definition: range.hpp:158
TParent::value_type value_type
Definition: rangemap.hpp:611
iterator insert(const value_type &value)
Definition: rangemap.hpp:629
position_type GetTo(void) const
Definition: range.hpp:142
position_type GetFrom(void) const
Definition: range.hpp:134
static TThisType GetEmpty(void)
Definition: range.hpp:306
TThisType & SetLength(position_type length)
Definition: range.hpp:194
bool Empty(void) const
Definition: range.hpp:148
static TThisType GetWhole(void)
Definition: range.hpp:272
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
void SetFrom(TFrom value)
Assign a value to From data member.
Definition: Range_.hpp:231
TTo GetTo(void) const
Get the To member data.
Definition: Range_.hpp:269
TFrom GetFrom(void) const
Get the From member data.
Definition: Range_.hpp:222
bool IsLim(void) const
Check if variant Lim is selected.
Definition: Int_fuzz_.hpp:636
TLim GetLim(void) const
Get the variant data.
Definition: Int_fuzz_.hpp:642
ELim
some limit value
Definition: Int_fuzz_.hpp:209
TLim & SetLim(void)
Select the variant.
Definition: Int_fuzz_.hpp:649
@ eLim_gt
greater than
Definition: Int_fuzz_.hpp:211
@ eLim_lt
less than
Definition: Int_fuzz_.hpp:212
@ eLim_tl
space to left of position
Definition: Int_fuzz_.hpp:214
@ eLim_tr
space to right of position
Definition: Int_fuzz_.hpp:213
const TAnticodon & GetAnticodon(void) const
Get the Anticodon member data.
Definition: Trna_ext_.hpp:649
TType GetType(void) const
Get the Type member data.
Definition: RNA_ref_.hpp:529
const TAa & GetAa(void) const
Get the Aa member data.
Definition: Trna_ext_.hpp:603
const TCodon & GetCodon(void) const
Get the Codon member data.
Definition: Trna_ext_.hpp:624
bool IsTRNA(void) const
Check if variant TRNA is selected.
Definition: RNA_ref_.hpp:498
bool IsSetAnticodon(void) const
location of anticodon Check if a value has been assigned to Anticodon data member.
Definition: Trna_ext_.hpp:637
bool IsSetExt(void) const
generic fields for ncRNA, tmRNA, miscRNA Check if a value has been assigned to Ext data member.
Definition: RNA_ref_.hpp:604
bool IsSetCodon(void) const
codon(s) as in Genetic-code Check if a value has been assigned to Codon data member.
Definition: Trna_ext_.hpp:612
TPseudo GetPseudo(void) const
Get the Pseudo member data.
Definition: RNA_ref_.hpp:576
bool IsSetPseudo(void) const
Check if a value has been assigned to Pseudo data member.
Definition: RNA_ref_.hpp:557
const TExt & GetExt(void) const
Get the Ext member data.
Definition: RNA_ref_.hpp:616
const TTRNA & GetTRNA(void) const
Get the variant data.
Definition: RNA_ref_.cpp:134
void SetAa(TAa &value)
Assign a value to Aa data member.
bool IsSetOrf(void) const
just an ORF ? Check if a value has been assigned to Orf data member.
Definition: Cdregion_.hpp:462
void SetStops(TStops value)
Assign a value to Stops data member.
Definition: Cdregion_.hpp:774
void ResetMismatch(void)
Reset Mismatch data member.
Definition: Cdregion_.hpp:665
E_Choice Which(void) const
Which variant is currently selected.
bool IsSetCode(void) const
genetic code used Check if a value has been assigned to Code data member.
Definition: Cdregion_.hpp:700
TGaps GetGaps(void) const
Get the Gaps member data.
Definition: Cdregion_.hpp:625
bool IsCdregion(void) const
Check if variant Cdregion is selected.
TStops GetStops(void) const
Get the Stops member data.
Definition: Cdregion_.hpp:765
TOrf GetOrf(void) const
Get the Orf member data.
Definition: Cdregion_.hpp:481
void ResetCode(void)
Reset Code data member.
Definition: Cdregion_.cpp:63
void ResetGaps(void)
Reset Gaps data member.
Definition: Cdregion_.hpp:618
void SetCode(TCode &value)
Assign a value to Code data member.
Definition: Cdregion_.cpp:68
const TLocation & GetLocation(void) const
Get the Location member data.
Definition: Seq_feat_.hpp:1117
E_Choice
Choice variants.
bool IsSetConflict(void) const
conflict Check if a value has been assigned to Conflict data member.
Definition: Cdregion_.hpp:559
list< CRef< CCode_break > > TCode_break
Definition: Cdregion_.hpp:111
TFrame GetFrame(void) const
Get the Frame member data.
Definition: Cdregion_.hpp:534
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
const TCode & GetCode(void) const
Get the Code member data.
Definition: Cdregion_.hpp:712
void ResetFrame(void)
Reset Frame data member.
Definition: Cdregion_.hpp:521
void ResetConflict(void)
Reset Conflict data member.
Definition: Cdregion_.hpp:571
void SetData(TData &value)
Assign a value to Data data member.
Definition: Seq_feat_.cpp:94
TCode_break & SetCode_break(void)
Assign a value to Code_break data member.
Definition: Cdregion_.hpp:739
bool IsSetStops(void) const
number of stop codons on above Check if a value has been assigned to Stops data member.
Definition: Cdregion_.hpp:746
const TCdregion & GetCdregion(void) const
Get the variant data.
TMismatch GetMismatch(void) const
Get the Mismatch member data.
Definition: Cdregion_.hpp:672
void SetLoc(TLoc &value)
Assign a value to Loc data member.
const TProduct & GetProduct(void) const
Get the Product member data.
Definition: Seq_feat_.hpp:1096
void SetGaps(TGaps value)
Assign a value to Gaps data member.
Definition: Cdregion_.hpp:634
void SetConflict(TConflict value)
Assign a value to Conflict data member.
Definition: Cdregion_.hpp:587
bool IsSetGaps(void) const
number of gaps on conflict/except Check if a value has been assigned to Gaps data member.
Definition: Cdregion_.hpp:606
void ResetOrf(void)
Reset Orf data member.
Definition: Cdregion_.hpp:474
const TRna & GetRna(void) const
Get the variant data.
void ResetStops(void)
Reset Stops data member.
Definition: Cdregion_.hpp:758
const TCode_break & GetCode_break(void) const
Get the Code_break member data.
Definition: Cdregion_.hpp:733
void SetMismatch(TMismatch value)
Assign a value to Mismatch data member.
Definition: Cdregion_.hpp:681
bool IsRna(void) const
Check if variant Rna is selected.
bool IsSetMismatch(void) const
number of mismatches on above Check if a value has been assigned to Mismatch data member.
Definition: Cdregion_.hpp:653
void SetOrf(TOrf value)
Assign a value to Orf data member.
Definition: Cdregion_.hpp:490
void SetFrame(TFrame value)
Assign a value to Frame data member.
Definition: Cdregion_.hpp:540
TConflict GetConflict(void) const
Get the Conflict member data.
Definition: Cdregion_.hpp:578
bool IsSetCode_break(void) const
individual exceptions Check if a value has been assigned to Code_break data member.
Definition: Cdregion_.hpp:721
bool IsSetFrame(void) const
Check if a value has been assigned to Frame data member.
Definition: Cdregion_.hpp:509
void SetTo(TTo value)
Assign a value to To data member.
const TFuzz_from & GetFuzz_from(void) const
Get the Fuzz_from member data.
void SetPoint(TPoint value)
Assign a value to Point data member.
Definition: Seq_point_.hpp:312
void SetId(TId &value)
Assign a value to Id data member.
Definition: Seq_point_.cpp:61
void SetA(TA &value)
Assign a value to A data member.
Definition: Seq_bond_.cpp:60
bool IsMix(void) const
Check if variant Mix is selected.
Definition: Seq_loc_.hpp:552
const TB & GetB(void) const
Get the B member data.
Definition: Seq_bond_.hpp:243
list< CRef< CSeq_interval > > Tdata
ENa_strand
strand of nucleic acid
Definition: Na_strand_.hpp:64
const Tdata & Get(void) const
Get the member data.
TStrand GetStrand(void) const
Get the Strand member data.
const TId & GetId(void) const
Get the Id member data.
const TPnt & GetPnt(void) const
Get the variant data.
Definition: Seq_loc_.cpp:238
TPoint GetPoint(void) const
Get the Point member data.
Definition: Seq_point_.hpp:303
const TFuzz_to & GetFuzz_to(void) const
Get the Fuzz_to member data.
const TWhole & GetWhole(void) const
Get the variant data.
Definition: Seq_loc_.cpp:172
void SetId(TId &value)
Assign a value to Id data member.
void SetStrand(TStrand value)
Assign a value to Strand data member.
Definition: Seq_point_.hpp:359
bool IsSetStrand(void) const
Check if a value has been assigned to Strand data member.
TFrom GetFrom(void) const
Get the From member data.
void SetFuzz(TFuzz &value)
Assign a value to Fuzz data member.
Definition: Seq_point_.cpp:71
bool IsSetFuzz(void) const
Check if a value has been assigned to Fuzz data member.
Definition: Seq_point_.hpp:408
list< CRef< CSeq_loc > > Tdata
const TFuzz & GetFuzz(void) const
Get the Fuzz member data.
Definition: Seq_point_.hpp:420
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_loc_.hpp:475
const TId & GetId(void) const
Get the Id member data.
const TId & GetId(void) const
Get the Id member data.
Definition: Seq_point_.hpp:390
void SetFrom(TFrom value)
Assign a value to From data member.
TStrand GetStrand(void) const
Get the Strand member data.
Definition: Seq_point_.hpp:350
void SetStrand(TStrand value)
Assign a value to Strand data member.
bool IsSetFuzz(void) const
Check if a value has been assigned to Fuzz data member.
const Tdata & Get(void) const
Get the member data.
const TPacked_pnt & GetPacked_pnt(void) const
Get the variant data.
Definition: Seq_loc_.cpp:260
void SetFuzz(TFuzz &value)
Assign a value to Fuzz data member.
void SetId(TId &value)
Assign a value to Id data member.
const Tdata & Get(void) const
Get the member data.
const TEquiv & GetEquiv(void) const
Get the variant data.
Definition: Seq_loc_.cpp:304
TPoints & SetPoints(void)
Assign a value to Points data member.
list< CRef< CSeq_loc > > Tdata
vector< TSeqPos > TPoints
void SetFuzz_to(TFuzz_to &value)
Assign a value to Fuzz_to data member.
void SetFuzz_from(TFuzz_from &value)
Assign a value to Fuzz_from data member.
bool IsPacked_int(void) const
Check if variant Packed_int is selected.
Definition: Seq_loc_.hpp:534
const TA & GetA(void) const
Get the A member data.
Definition: Seq_bond_.hpp:213
const TEmpty & GetEmpty(void) const
Get the variant data.
Definition: Seq_loc_.cpp:150
bool IsSetStrand(void) const
Check if a value has been assigned to Strand data member.
Tdata & Set(void)
Assign a value to data member.
bool IsSetFuzz_to(void) const
Check if a value has been assigned to Fuzz_to data member.
bool IsSetStrand(void) const
Check if a value has been assigned to Strand data member.
Definition: Seq_point_.hpp:331
const TPoints & GetPoints(void) const
Get the Points member data.
TStrand GetStrand(void) const
Get the Strand member data.
TTo GetTo(void) const
Get the To member data.
bool IsInt(void) const
Check if variant Int is selected.
Definition: Seq_loc_.hpp:528
const TInt & GetInt(void) const
Get the variant data.
Definition: Seq_loc_.cpp:194
void SetB(TB &value)
Assign a value to B data member.
Definition: Seq_bond_.cpp:70
bool IsSetFuzz_from(void) const
Check if a value has been assigned to Fuzz_from data member.
void SetStrand(TStrand value)
Assign a value to Strand data member.
const TFuzz & GetFuzz(void) const
Get the Fuzz member data.
const TMix & GetMix(void) const
Get the variant data.
Definition: Seq_loc_.cpp:282
bool IsSetB(void) const
other end may not be available Check if a value has been assigned to B data member.
Definition: Seq_bond_.hpp:231
const TPacked_int & GetPacked_int(void) const
Get the variant data.
Definition: Seq_loc_.cpp:216
const TBond & GetBond(void) const
Get the variant data.
Definition: Seq_loc_.cpp:326
@ eNa_strand_plus
Definition: Na_strand_.hpp:66
@ eNa_strand_minus
Definition: Na_strand_.hpp:67
@ eNa_strand_unknown
Definition: Na_strand_.hpp:65
@ e_not_set
No variant selected.
Definition: Seq_loc_.hpp:97
@ e_Null
not placed
Definition: Seq_loc_.hpp:98
@ e_Equiv
equivalent sets of locations
Definition: Seq_loc_.hpp:106
@ e_Empty
to NULL one Seq-id in a collection
Definition: Seq_loc_.hpp:99
@ e_Feat
indirect, through a Seq-feat
Definition: Seq_loc_.hpp:108
@ e_Int
from to
Definition: Seq_loc_.hpp:101
@ e_Whole
whole sequence
Definition: Seq_loc_.hpp:100
const TLoc & GetLoc(void) const
Get the Loc member data.
Definition: Seq_graph_.hpp:869
<!DOCTYPE HTML >< html > n< header > n< title > PubSeq Gateway Help Page</title > n< style > n table
int i
int len
range(_Ty, _Ty) -> range< _Ty >
static char tmp[2048]
Definition: utf8.c:42
static bool NeedFullFeature(const CAnnotObject_Ref &ref, CSeq_loc_Conversion::ELocationType loctype)
bool LocationIsWhole(void) const
bool LocationIsSimple(void) const
bool LocationIsInterval(void) const
bool LocationIsPoint(void) const
Definition: type.c:6
#define _ASSERT
#define const
Definition: zconf.h:230
Modified on Thu Sep 21 03:44:29 2023 by modify_doxy.py rev. 669887