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

Go to the SVN repository for this file.

1 /* $Id: aln_generators.cpp 101716 2024-01-31 14:29:46Z grichenk $
2 * ===========================================================================
3 *
4 * PUBLIC DOMAIN NOTICE
5 * National Center for Biotechnology Information
6 *
7 * This software/database is a "United States Government Work" under the
8 * terms of the United States Copyright Act. It was written as part of
9 * the author's official duties as a United States Government employee and
10 * thus cannot be copyrighted. This software/database is freely available
11 * to the public for use. The National Library of Medicine and the U.S.
12 * Government have not placed any restriction on its use or reproduction.
13 *
14 * Although all reasonable efforts have been taken to ensure the accuracy
15 * and reliability of the software and data, the NLM and the U.S.
16 * Government do not and cannot warrant the performance or results that
17 * may be obtained by using this software or data. The NLM and the U.S.
18 * Government disclaim all warranties, express or implied, including
19 * warranties of performance, merchantability or fitness for any particular
20 * purpose.
21 *
22 * Please cite the author in any work or product based on this material.
23 *
24 * ===========================================================================
25 *
26 * Authors: Kamen Todorov, NCBI
27 *
28 * File Description:
29 * Alignment generators
30 *
31 * ===========================================================================
32 */
33 
34 
35 #include <ncbi_pch.hpp>
36 
47 #include <objmgr/scope.hpp>
48 #include <objmgr/bioseq_handle.hpp>
49 
52 
57 
58 #define USE_RANGE_SET
59 #ifdef USE_RANGE_SET
60 # include <util/range_set.hpp>
61 # define CRangeCollection CRangeSet
62 #else
63 # include <util/range_coll.hpp>
64 #endif
65 
66 #include <serial/typeinfo.hpp> // for SerialAssign
67 
70 
71 
75  CScope* scope)
76 {
79  sa->SetDim(anchored_aln.GetDim());
80 
81  switch(choice) {
83  CreateDense_diagFromAnchoredAln(sa->SetSegs().SetDendiag(), anchored_aln, scope);
84  break;
86  sa->SetSegs().SetDenseg(*CreateDensegFromAnchoredAln(anchored_aln, scope));
87  break;
89  sa->SetSegs().SetPacked(*CreatePackedsegFromAnchoredAln(anchored_aln, scope));
90  break;
92  sa->SetSegs().SetDisc(*CreateAlignSetFromAnchoredAln(anchored_aln, scope));
93  break;
95  sa->SetSegs().SetSpliced(*CreateSplicedsegFromAnchoredAln(anchored_aln, scope));
96  break;
98  NCBI_THROW(CAlnException, eUnsupported,
99  "Unsupported alignment type: e_Std.");
100  break;
102  NCBI_THROW(CAlnException, eUnsupported,
103  "Unsupported alignment type: e_Sparse.");
104  break;
106  NCBI_THROW(CAlnException, eInvalidRequest,
107  "Invalid CSeq_align::TSegs type.");
108  break;
109  }
110  return sa;
111 }
112 
113 
117  CScope* scope)
118 {
121  sa->SetDim(2);
122 
123  switch(choice) {
125  sa->SetSegs().SetDenseg(*CreateDensegFromPairwiseAln(pairwise_aln, scope));
126  break;
128  sa->SetSegs().SetDisc(*CreateAlignSetFromPairwiseAln(pairwise_aln, scope));
129  break;
131  sa->SetSegs().SetPacked(*CreatePackedsegFromPairwiseAln(pairwise_aln, scope));
132  break;
134  sa->SetSegs().SetSpliced(*CreateSplicedsegFromPairwiseAln(pairwise_aln, scope));
135  break;
140  NCBI_THROW(CAlnException, eInvalidRequest,
141  "Unsupported CSeq_align::TSegs type.");
142  break;
143  }
144  return sa;
145 }
146 
147 
148 //#define _TRACE_CSegmentedRangeCollection
149 #ifdef _TRACE_CSegmentedRangeCollection
150 ostream& operator<<(ostream& out, const CRangeCollection<CPairwiseAln::TPos>& segmetned_range_coll)
151 {
152  out << "CRangeCollection<CPairwiseAln::TPos>" << endl;
153 
154  ITERATE (CRangeCollection<CPairwiseAln::TPos>, rng_it, segmetned_range_coll) {
155  out << (CPairwiseAln::TRng)*rng_it << endl;
156  }
157  return out << endl;
158 }
159 #endif
160 
161 class CSegmentedRangeCollection : public CRangeCollection<CPairwiseAln::TPos>
162 {
163 public:
164  typedef ncbi::CRangeCollection<CPairwiseAln::TPos> TParent;
165 
167  if ( pos > 0 ) {
168  DivideAfter(pos-1);
169  }
170  }
171 
172  void insert(const TRange& r) {
173 #ifdef _TRACE_CSegmentedRangeCollection
174  cerr << "=====================" << endl;
175  cerr << "Original:" << *this;
176  cerr << "Inserting: " << endl << (CPairwiseAln::TRng)r << endl << endl;
177 #endif
178  // Cut
179  CutAtPosition(r.GetFrom());
180  CutAtPosition(r.GetToOpen());
181 #ifdef _TRACE_CSegmentedRangeCollection
182  cerr << "After the cut:" << *this << endl;
183 #endif
184 
185  // Find the diff if any
186  TParent addition;
187  addition += r;
188  addition -= *this;
189 
190  if ( !addition.empty() ) {
191 #ifdef _TRACE_CSegmentedRangeCollection
192  cerr << "Addition: " << addition << endl;
193 #endif
194  // Insert the diff
195 #ifndef USE_RANGE_SET
196  iterator it = find_nc(addition.begin()->GetToOpen());
197  ITERATE(TParent, add_it, addition) {
198  TRange rr(add_it->GetFrom(), add_it->GetTo());
199  while (it != TParent::m_vRanges.end() &&
200  rr.GetFrom() >= it->GetFrom()) {
201  ++it;
202  }
203  it = TParent::m_vRanges.insert(it, rr);
204  ++it;
205  }
206 #else
207  CombineWithAndKeepAbutting(addition);
208 #endif
209  }
210 #ifdef _TRACE_CSegmentedRangeCollection
211  else {
212  cerr << "No addition." << endl << endl;
213  }
214 #endif
215 #ifdef _TRACE_CSegmentedRangeCollection
216  cerr << "Result: " << *this;
217  cerr << "=====================" << endl << endl;
218 #endif
219  }
220 };
221 
222 
223 void
225  const CAnchoredAln& anchored_aln,
226  CScope* scope)
227 {
228  const CAnchoredAln::TPairwiseAlnVector& pairwises = anchored_aln.GetPairwiseAlns();
229 
230  typedef CSegmentedRangeCollection TAnchorSegments;
231  TAnchorSegments anchor_segments;
232  ITERATE(CAnchoredAln::TPairwiseAlnVector, pairwise_aln_i, pairwises) {
233  ITERATE (CPairwiseAln::TAlnRngColl, rng_i, **pairwise_aln_i) {
234  anchor_segments.insert(CPairwiseAln::TRng(rng_i->GetFirstFrom(), rng_i->GetFirstTo()));
235  }
236  }
237 
239  CDense_diag::TDim dim = anchored_aln.GetDim();
240  for ( auto anchor_segments_seg = anchor_segments.begin(); anchor_segments_seg != anchor_segments.end(); ++anchor_segments_seg ) {
241  CRef<CDense_diag> diag(new CDense_diag);
242  diag->SetDim(dim);
243  diag->SetIds().resize(dim);
244  for (int row = 0; row < dim; ++row) {
245  CRef<CSeq_id> id(new CSeq_id);
246  id->Assign(anchored_aln.GetId(dim - row - 1)->GetSeqId());
247  diag->SetIds()[row] = id;
248  }
249  diag->SetStarts().resize(dim, kInvalidSeqPos);
250  diag->SetStrands().resize(dim);
251  diag->SetLen(anchor_segments_seg->GetLength());
252  diags.push_back(diag);
253  }
254 
255  for (int row = 0; row < dim; ++row) {
256  CSeq_align::TSegs::TDendiag::iterator diag_it = diags.begin();
257 
258  TAnchorSegments::const_iterator seg_i = anchor_segments.begin();
260  pairwises[dim - row - 1]->begin();
261  bool direct = aln_rng_i->IsDirect();
262  TSignedSeqPos left_delta = 0;
263  TSignedSeqPos right_delta = aln_rng_i->GetLength();
264  while (seg_i != anchor_segments.end()) {
265  if (aln_rng_i != pairwises[dim - row - 1]->end() &&
266  seg_i->GetFrom() >= aln_rng_i->GetFirstFrom()) {
267  _ASSERT(seg_i->GetToOpen() <= aln_rng_i->GetFirstToOpen());
268  if (seg_i->GetToOpen() > aln_rng_i->GetFirstToOpen()) {
269  NCBI_THROW(CAlnException, eInternalFailure,
270  "seg_i->GetToOpen() > aln_rng_i->GetFirstToOpen()");
271  }
272 
273  // dec right_delta
274  _ASSERT(right_delta >= seg_i->GetLength());
275  if (right_delta < seg_i->GetLength()) {
276  NCBI_THROW(CAlnException, eInternalFailure,
277  "right_delta < seg_i->GetLength()");
278  }
279  right_delta -= seg_i->GetLength();
280 
281  (*diag_it)->SetStarts()[row] =
282  (direct ?
283  aln_rng_i->GetSecondFrom() + left_delta :
284  aln_rng_i->GetSecondFrom() + right_delta);
285 
286  // inc left_delta
287  left_delta += seg_i->GetLength();
288 
289  if (right_delta == 0) {
290  _ASSERT(left_delta == aln_rng_i->GetLength());
291  ++aln_rng_i;
292  if (aln_rng_i != pairwises[dim - row - 1]->end()) {
293  direct = aln_rng_i->IsDirect();
294  left_delta = 0;
295  right_delta = aln_rng_i->GetLength();
296  }
297  }
298  }
299  (*diag_it)->SetStrands()[row] =
300  (direct ? eNa_strand_plus : eNa_strand_minus);
301  ++seg_i;
302  ++diag_it;
303  }
304  }
305  // Cleanup: remove rows with gaps, remove one-row diags.
307  size_t row = 0;
308  CDense_diag& diag = **diag_it;
309  CDense_diag::TStarts& starts = diag.SetStarts();
310  while (row < starts.size()) {
311  if (starts[row] == kInvalidSeqPos) {
312  starts.erase(starts.begin() + row);
313  CDense_diag::TIds& ids = diag.SetIds();
314  ids.erase(ids.begin() + row);
315  CDense_diag::TStrands& strands = diag.SetStrands();
316  strands.erase(strands.begin() + row);
317  continue;
318  }
319  ++row;
320  }
321  if (diag.GetStarts().size() < 2) continue;
322  diag.SetDim(CDense_diag::TDim(starts.size()));
323 #if _DEBUG
324  diag.Validate();
325 #endif
326  dd.push_back(*diag_it);
327  }
328 }
329 
330 
333  CScope* scope)
334 {
335  const CAnchoredAln::TPairwiseAlnVector& pairwises = anchored_aln.GetPairwiseAlns();
336 
337  typedef CSegmentedRangeCollection TAnchorSegments;
338  TAnchorSegments anchor_segments;
339  ITERATE(CAnchoredAln::TPairwiseAlnVector, pairwise_aln_i, pairwises) {
340  ITERATE (CPairwiseAln::TAlnRngColl, rng_i, **pairwise_aln_i) {
341  anchor_segments.insert(CPairwiseAln::TRng(rng_i->GetFirstFrom(), rng_i->GetFirstTo()));
342  }
343  }
344 
345  // Create a dense-seg
347 
348  // Determine dimensions
349  CDense_seg::TNumseg& numseg = ds->SetNumseg();
350  numseg = CDense_seg::TNumseg(anchor_segments.size());
351  CDense_seg::TDim& dim = ds->SetDim();
352  dim = anchored_aln.GetDim();
353 
354  // Tmp vars
357 
358  // Ids
359  CDense_seg::TIds& ids = ds->SetIds();
360  ids.resize(dim);
361  for (row = 0; row < dim; ++row) {
362  ids[row].Reset(new CSeq_id);
363  SerialAssign<CSeq_id>(*ids[row], anchored_aln.GetId(dim - row - 1)->GetSeqId());
364  }
365 
366  // Lens
367  CDense_seg::TLens& lens = ds->SetLens();
368  lens.resize(numseg);
369  TAnchorSegments::const_iterator seg_i = anchor_segments.begin();
370  for (seg = 0; seg < numseg; ++seg, ++seg_i) {
371  lens[seg] = seg_i->GetLength();
372  }
373 
374  int matrix_size = dim * numseg;
375 
376  // Strands (just resize, will set while setting starts)
377  CDense_seg::TStrands& strands = ds->SetStrands();
378  strands.resize(matrix_size, eNa_strand_unknown);
379 
380  // Starts and strands
381  CDense_seg::TStarts& starts = ds->SetStarts();
382  starts.resize(matrix_size, -1);
383  for (row = 0; row < dim; ++row) {
384  seg = 0;
385  int matrix_row_pos = row; // optimization to eliminate multiplication
386  seg_i = anchor_segments.begin();
387  CPairwiseAln::TAlnRngColl::const_iterator aln_rng_i = pairwises[dim - row - 1]->begin();
388  bool direct = aln_rng_i->IsDirect();
389  TSignedSeqPos left_delta = 0;
390  TSignedSeqPos right_delta = aln_rng_i->GetLength();
391  while (seg_i != anchor_segments.end()) {
392  _ASSERT(seg < numseg);
393  _ASSERT(matrix_row_pos == row + dim * seg);
394  if (aln_rng_i != pairwises[dim - row - 1]->end() &&
395  seg_i->GetFrom() >= aln_rng_i->GetFirstFrom()) {
396  _ASSERT(seg_i->GetToOpen() <= aln_rng_i->GetFirstToOpen());
397  if (seg_i->GetToOpen() > aln_rng_i->GetFirstToOpen()) {
398  NCBI_THROW(CAlnException, eInternalFailure,
399  "seg_i->GetToOpen() > aln_rng_i->GetFirstToOpen()");
400  }
401 
402  // dec right_delta
403  _ASSERT(right_delta >= seg_i->GetLength());
404  if (right_delta < seg_i->GetLength()) {
405  NCBI_THROW(CAlnException, eInternalFailure,
406  "right_delta < seg_i->GetLength()");
407  }
408  right_delta -= seg_i->GetLength();
409 
410  starts[matrix_row_pos] =
411  (direct ?
412  aln_rng_i->GetSecondFrom() + left_delta :
413  aln_rng_i->GetSecondFrom() + right_delta);
414 
415  // inc left_delta
416  left_delta += seg_i->GetLength();
417 
418  if (right_delta == 0) {
419  _ASSERT(left_delta == aln_rng_i->GetLength());
420  ++aln_rng_i;
421  if (aln_rng_i != pairwises[dim - row - 1]->end()) {
422  direct = aln_rng_i->IsDirect();
423  left_delta = 0;
424  right_delta = aln_rng_i->GetLength();
425  }
426  }
427  }
428  strands[matrix_row_pos] = (direct ? eNa_strand_plus : eNa_strand_minus);
429  ++seg_i;
430  ++seg;
431  matrix_row_pos += dim;
432  }
433  }
434 #if _DEBUG
435  ds->Validate(true);
436 #endif
437  return ds;
438 }
439 
440 
443  CScope* scope)
444 {
445  // Create a dense-seg
447 
448 
449  // Determine dimensions
450  CDense_seg::TNumseg& numseg = ds->SetNumseg();
451  numseg = CDense_seg::TNumseg(pairwise_aln.size());
452  ds->SetDim(2);
453  int matrix_size = 2 * numseg;
454 
455  CDense_seg::TLens& lens = ds->SetLens();
456  lens.resize(numseg);
457 
458  CDense_seg::TStarts& starts = ds->SetStarts();
459  starts.resize(matrix_size, -1);
460 
461  CDense_seg::TIds& ids = ds->SetIds();
462  ids.resize(2);
463 
464 
465  // Ids
466  ids[0].Reset(new CSeq_id);
467  SerialAssign<CSeq_id>(*ids[0], pairwise_aln.GetFirstId()->GetSeqId());
468  ids[1].Reset(new CSeq_id);
469  SerialAssign<CSeq_id>(*ids[1], pairwise_aln.GetSecondId()->GetSeqId());
470 
471 
472  // Tmp vars
473  CDense_seg::TNumseg seg = 0;
474  int matrix_pos = 0;
475 
476 
477  // Main loop to set all values
478  ITERATE(CPairwiseAln::TAlnRngColl, aln_rng_i, pairwise_aln) {
479  starts[matrix_pos++] = aln_rng_i->GetFirstFrom();
480  if ( !aln_rng_i->IsDirect() ) {
481  if ( !ds->IsSetStrands() ) {
482  ds->SetStrands().resize(matrix_size, eNa_strand_plus);
483  }
484  ds->SetStrands()[matrix_pos] = eNa_strand_minus;
485  }
486  starts[matrix_pos++] = aln_rng_i->GetSecondFrom();
487  lens[seg++] = aln_rng_i->GetLength();
488  }
489  _ASSERT(matrix_pos == matrix_size);
490  _ASSERT(seg == numseg);
491 
492 
493 #ifdef _DEBUG
494  ds->Validate(true);
495 #endif
496  return ds;
497 }
498 
499 
501 
503  const CPairwiseAln& pairwise_aln,
504  CScope* scope)
505 {
506  // Sort by product positions (if minus strand, then reverse).
507  // Make sure genomic positions are sorted in the corresponding direction too, no overlaps etc.
508  // Small one-row gap -> indel.
509  // Large genomic gap -> intron (start new exon).
510  // Other gaps -> intron, set 'partial' on both sides.
511  // If the product does not start/end at the sequence extreme, set 'partial' for the exon.
512 
513  // Check strands - one per row.
515  // Product is nuc or prot.
516  _ASSERT(pairwise_aln.GetFirstBaseWidth() == 1 ||
517  pairwise_aln.GetFirstBaseWidth() == 3);
518  bool prot = pairwise_aln.GetFirstBaseWidth() == 3;
519  // The other row is genomic.
520  _ASSERT(pairwise_aln.GetSecondBaseWidth() == 1);
521 
522  // Ids
523  CRef<CSeq_id> product_id(new CSeq_id);
524  product_id->Assign(pairwise_aln.GetFirstId()->GetSeqId());
525  spliced_seg.SetProduct_id(*product_id);
526  CRef<CSeq_id> genomic_id(new CSeq_id);
527  genomic_id->Assign(pairwise_aln.GetSecondId()->GetSeqId());
528  spliced_seg.SetGenomic_id(*genomic_id);
529 
530  // Product type
531  spliced_seg.SetProduct_type(prot ?
534 
535  // Exons
536  CSpliced_seg::TExons& exons = spliced_seg.SetExons();
537 
538  typedef TSignedSeqPos TPos;
539  typedef CRange<TPos> TRng;
540 
541  TPos last_prod_end = 0;
542  TPos last_gen_end = 0;
543  CRef<CSpliced_exon> exon;
544  CPairwiseAln::TAlnRngColl::const_iterator rg_it = pairwise_aln.begin();
545  bool gen_direct = rg_it == pairwise_aln.end() || rg_it->IsDirect();
546  bool prod_direct = prot ||
547  rg_it == pairwise_aln.end() || rg_it->IsFirstDirect();
548  // Adjust genomic strand - in CPairwiseAln it's relative to the first seq.
549  if ( !prod_direct ) {
550  gen_direct = !gen_direct;
551  }
552 
553  TRng ex_prod_rg;
554  TRng ex_gen_rg;
555 
556  // Main loop to set all values
557  ITERATE(CPairwiseAln::TAlnRngColl, rg_it, pairwise_aln) {
558  const CPairwiseAln::TAlnRng& rg = *rg_it;
559 
560  // Unaligned ranges.
561  TPos prod_skip, gen_skip;
562  if (rg_it == pairwise_aln.begin()) {
563  prod_skip = 0;
564  gen_skip = 0;
565  }
566  else {
567  prod_skip = rg.GetFirstFrom() - last_prod_end;
568  gen_skip = gen_direct == prod_direct ?
569  rg.GetSecondFrom() - last_gen_end
570  : last_gen_end - rg.GetSecondToOpen();
571  }
572 
573  // Break exon, ignore long gaps between exons.
574  if (!exon || prod_skip > kMaxSplicedExonIndelLength ||
575  gen_skip > kMaxSplicedExonIndelLength) {
576  if ( exon ) {
577  _ASSERT(exon->IsSetProduct_start());
578  _ASSERT(exon->IsSetGenomic_start());
579  _ASSERT(exon->IsSetProduct_end());
580  _ASSERT(exon->IsSetGenomic_end());
581  if ( prod_direct ) {
582  exons.push_back(exon);
583  }
584  else {
585  exons.push_front(exon);
586  }
587  exon.Reset();
588  ex_prod_rg = TRng::GetEmpty();
589  ex_gen_rg = TRng::GetEmpty();
590  }
591  prod_skip = 0;
592  gen_skip = 0;
593  }
594 
595  if (prod_skip > 0 || gen_skip > 0) {
596  _ASSERT(exon);
597  TSeqPos mismatch = min(prod_skip, gen_skip);
598  if (mismatch > 0) {
600  chunk->SetMismatch(mismatch);
601  if ( prod_direct ) {
602  exon->SetParts().push_back(chunk);
603  }
604  else {
605  exon->SetParts().push_front(chunk);
606  }
607  prod_skip -= mismatch;
608  gen_skip -= mismatch;
609  }
610  if (prod_skip > 0) {
612  chunk->SetProduct_ins(prod_skip);
613  if ( prod_direct ) {
614  exon->SetParts().push_back(chunk);
615  }
616  else {
617  exon->SetParts().push_front(chunk);
618  }
619  }
620  if (gen_skip > 0) {
622  chunk->SetGenomic_ins(gen_skip);
623  if ( prod_direct ) {
624  exon->SetParts().push_back(chunk);
625  }
626  else {
627  exon->SetParts().push_front(chunk);
628  }
629  }
630  prod_skip = 0;
631  gen_skip = 0;
632  }
633 
634  if ( !exon ) {
635  // Start new exon
636  exon.Reset(new CSpliced_exon);
637  // The first exon must start at 0 or be partial.
638  if (exons.empty() && rg.GetFirstFrom() > 0) {
639  exon->SetPartial(true);
640  }
641  if ( !prot ) {
642  exon->SetProduct_strand(prod_direct
644  }
645  exon->SetGenomic_strand(gen_direct
647  }
648  // Aligned chunk
650  chunk->SetMatch(rg.GetLength());
651  if ( prod_direct ) {
652  exon->SetParts().push_back(chunk);
653  }
654  else {
655  exon->SetParts().push_front(chunk);
656  }
657 
658  // Update exon extremes
659  ex_prod_rg.CombineWith(TRng(rg.GetFirstFrom(), rg.GetFirstTo()));
660  ex_gen_rg.CombineWith(TRng(rg.GetSecondFrom(), rg.GetSecondTo()));
661  if ( exon ) {
662  if (prot) {
663  exon->SetProduct_start().SetProtpos().SetAmin(ex_prod_rg.GetFrom() / 3);
664  exon->SetProduct_start().SetProtpos().SetFrame(ex_prod_rg.GetFrom() % 3 + 1);
665  exon->SetProduct_end().SetProtpos().SetAmin(ex_prod_rg.GetTo() / 3);
666  exon->SetProduct_end().SetProtpos().SetFrame(ex_prod_rg.GetTo() % 3 + 1);
667  } else {
668  exon->SetProduct_start().SetNucpos(ex_prod_rg.GetFrom());
669  exon->SetProduct_end().SetNucpos(ex_prod_rg.GetTo());
670  }
671  exon->SetGenomic_start(ex_gen_rg.GetFrom());
672  exon->SetGenomic_end(ex_gen_rg.GetTo());
673  }
674 
675  last_prod_end = rg.GetFirstToOpen();
676  last_gen_end = gen_direct == prod_direct ?
677  rg.GetSecondToOpen() : rg.GetSecondFrom();
678  }
679  if ( exon ) {
680  _ASSERT(exon->IsSetProduct_start());
681  _ASSERT(exon->IsSetGenomic_start());
682  _ASSERT(exon->IsSetProduct_end());
683  _ASSERT(exon->IsSetGenomic_end());
684  if ( prod_direct ) {
685  exons.push_back(exon);
686  }
687  else {
688  exons.push_front(exon);
689  }
690  }
691  else if ( !exons.empty() ) {
692  // Get the last added exon.
693  exon = prod_direct ? exons.front() : exons.back();
694  }
695 
696  // Check if the last exon ends at product end.
697  if (exon && scope) {
698  TSeqPos prod_end = 0;
699  if ( exon->GetProduct_end().IsNucpos() ) {
700  prod_end = exon->GetProduct_end().GetNucpos();
701  }
702  else {
703  prod_end = exon->GetProduct_end().GetProtpos().GetAmin();
704  }
705  CBioseq_Handle h = scope->GetBioseqHandle(*product_id);
706  if ( h ) {
707  TSeqPos prod_len = h.GetBioseqLength();
708  if (prod_len != kInvalidSeqPos && prod_len != prod_end + 1) {
709  exon->SetPartial(true);
710  }
711  }
712  }
713 
714 #ifdef _DEBUG
715  spliced_seg.Validate(true);
716 #endif
717 }
718 
719 
722  CScope* scope)
723 {
724  _ASSERT(anchored_aln.GetDim() == 2);
725 
726  // Sort by product positions (if minus strand, then reverse).
727  // Make sure genomic positions are sorted in the corresponding direction too, no overlaps etc.
728  // Small one-row gap -> indel.
729  // Large genomic gap -> intron (start new exon).
730  // Other gaps -> intron, set 'partial' on both sides.
731  // If the product does not start/end at the sequence extreme, set 'partial' for the exon.
732 
733  // Create a spliced_seg
734  CRef<CSpliced_seg> spliced_seg(new CSpliced_seg);
735  CAnchoredAln::TDim anchor_row = anchored_aln.GetAnchorRow();
736  const CPairwiseAln& pairwise = *anchored_aln.GetPairwiseAlns()[1 - anchor_row];
737  InitSplicedsegFromPairwiseAln(*spliced_seg, pairwise, scope);
738  return spliced_seg;
739 }
740 
741 
744  CScope* scope)
745 {
746  // Create a dense-seg
748  InitSplicedsegFromPairwiseAln(*ss, pairwise_aln, scope);
749  return ss;
750 }
751 
752 
754  CPairwiseAln& out_pw, // output pairwise (needs to be empty)
755  const CPairwiseAln& pw, // input pairwise to translate from
756  const CPairwiseAln& tr) // translating pairwise
757 {
758  ITERATE (CPairwiseAln, it, pw) {
759  CPairwiseAln::TAlnRng ar = *it;
761  if (ar.GetFirstFrom() < 0) continue; // skip unaligned ranges
762  out_pw.insert(ar);
763  }
764 }
765 
766 
768 
769 
771  const CAnchoredAln::TPairwiseAlnVector pairwises,
772  TDim anchor,
773  vector<CRef<CSeq_align> >& out_seqaligns,
775  CScope* scope)
776 {
777  out_seqaligns.resize(pairwises.size() - 1);
778  for (TDim row = 0, sa_idx = 0;
779  row < (TDim) pairwises.size();
780  ++row) {
781  if (row == anchor) continue;
784  sa->SetDim(2);
785 
786  const CPairwiseAln& pw = *pairwises[row];
787  CRef<CPairwiseAln> p(new CPairwiseAln(pairwises[anchor]->GetSecondId(),
788  pw.GetSecondId(),
789  pw.GetFlags()));
790  s_TranslatePairwise(*p, pw, *pairwises[anchor]);
791 
792  switch(choice) {
795  sa->SetSegs().SetDenseg(*ds);
796  break;
797  }
800  sa->SetSegs().SetDisc(*disc);
801  break;
802  }
805  sa->SetSegs().SetPacked(*ps);
806  break;
807  }
810  sa->SetSegs().SetSpliced(*ss);
811  break;
812  }
816  NCBI_THROW(CAlnException, eInvalidRequest,
817  "Unsupported CSeq_align::TSegs type.");
819  default:
820  NCBI_THROW(CAlnException, eInvalidRequest,
821  "Invalid CSeq_align::TSegs type.");
822  }
823  out_seqaligns[sa_idx++].Reset(sa);
824  }
825 }
826 
827 
830  CScope* scope)
831 {
833 
834  const CAnchoredAln::TPairwiseAlnVector& pairwises = anchored_aln.GetPairwiseAlns();
835 
836  typedef CSegmentedRangeCollection TAnchorSegments;
837  TAnchorSegments anchor_segments;
838  ITERATE(CAnchoredAln::TPairwiseAlnVector, pairwise_aln_i, pairwises) {
839  ITERATE (CPairwiseAln::TAlnRngColl, rng_i, **pairwise_aln_i) {
840  anchor_segments.insert(CPairwiseAln::TRng(rng_i->GetFirstFrom(), rng_i->GetFirstTo()));
841  }
842  }
843 
846 
847  // Determine dimensions
848  CDense_seg::TNumseg numseg = CDense_seg::TNumseg(anchor_segments.size());
849  CDense_seg::TDim dim = anchored_aln.GetDim();
850 
851  vector< CRef<CDense_seg> > dsegs;
852  dsegs.resize(numseg);
853  for (size_t i = 0; i < dsegs.size(); ++i) {
854  dsegs[i].Reset(new CDense_seg);
855  CDense_seg& dseg = *dsegs[i];
856  dseg.SetDim(dim);
857  dseg.SetNumseg(1);
858  // Ids
859  CDense_seg::TIds& ids = dseg.SetIds();
860  ids.resize(dim);
861  for (row = 0; row < dim; ++row) {
862  ids[row].Reset(new CSeq_id);
863  SerialAssign<CSeq_id>(*ids[row], anchored_aln.GetId(dim - row - 1)->GetSeqId());
864  }
865  // Lens, strands, starts - just prepare the storage
866  dseg.SetLens().resize(1);
867  dseg.SetStrands().resize(dim, eNa_strand_unknown);
868  dseg.SetStarts().resize(dim, -1);
869  }
870 
871  for (row = 0; row < dim; ++row) {
872  seg = 0;
873  TAnchorSegments::const_iterator seg_i = anchor_segments.begin();
874  CPairwiseAln::TAlnRngColl::const_iterator aln_rng_i = pairwises[dim - row - 1]->begin();
875  bool direct = aln_rng_i->IsDirect();
876  TSignedSeqPos left_delta = 0;
877  TSignedSeqPos right_delta = aln_rng_i->GetLength();
878  while (seg_i != anchor_segments.end()) {
879  _ASSERT(seg < numseg);
880  CDense_seg& dseg = *dsegs[seg];
881  dseg.SetLens()[0] = seg_i->GetLength();
882  CDense_seg::TStarts& starts = dseg.SetStarts();
883 
884  dseg.SetStrands()[row] = (direct ? eNa_strand_plus : eNa_strand_minus);
885  if (aln_rng_i != pairwises[dim - row - 1]->end() &&
886  seg_i->GetFrom() >= aln_rng_i->GetFirstFrom()) {
887  _ASSERT(seg_i->GetToOpen() <= aln_rng_i->GetFirstToOpen());
888  if (seg_i->GetToOpen() > aln_rng_i->GetFirstToOpen()) {
889  NCBI_THROW(CAlnException, eInternalFailure,
890  "seg_i->GetToOpen() > aln_rng_i->GetFirstToOpen()");
891  }
892 
893  // dec right_delta
894  _ASSERT(right_delta >= seg_i->GetLength());
895  if (right_delta < seg_i->GetLength()) {
896  NCBI_THROW(CAlnException, eInternalFailure,
897  "right_delta < seg_i->GetLength()");
898  }
899  right_delta -= seg_i->GetLength();
900 
901  starts[row] =
902  (direct ?
903  aln_rng_i->GetSecondFrom() + left_delta :
904  aln_rng_i->GetSecondFrom() + right_delta);
905 
906  // inc left_delta
907  left_delta += seg_i->GetLength();
908 
909  if (right_delta == 0) {
910  _ASSERT(left_delta == aln_rng_i->GetLength());
911  ++aln_rng_i;
912  if (aln_rng_i != pairwises[dim - row - 1]->end()) {
913  direct = aln_rng_i->IsDirect();
914  left_delta = 0;
915  right_delta = aln_rng_i->GetLength();
916  }
917  }
918  }
919  // Add only densegs with both rows non-empty
920  if (starts[0] >= 0 && starts[1] >= 0) {
921  CRef<CSeq_align> seg_aln(new CSeq_align);
923  seg_aln->SetDim(dim);
924  disc->Set().push_back(seg_aln);
925  seg_aln->SetSegs().SetDenseg(dseg);
926  }
927  ++seg_i;
928  ++seg;
929  }
930  }
931 
932  return disc;
933 }
934 
935 
938  CScope* scope)
939 {
941 
942  CDense_seg::TNumseg numseg = CDense_seg::TNumseg(pairwise_aln.size());
943 
944  vector< CRef<CDense_seg> > dsegs;
945  dsegs.resize(numseg);
946  for (size_t i = 0; i < dsegs.size(); ++i) {
947  CRef<CSeq_align> seg_aln(new CSeq_align);
949  seg_aln->SetDim(2);
950  disc->Set().push_back(seg_aln);
951  CDense_seg& dseg = seg_aln->SetSegs().SetDenseg();
952  dsegs[i].Reset(&dseg);
953  dseg.SetDim(2);
954  dseg.SetNumseg(1);
955  // Ids
956  CDense_seg::TIds& ids = dseg.SetIds();
957  ids.resize(2);
958  ids[0].Reset(new CSeq_id);
959  SerialAssign<CSeq_id>(*ids[0], pairwise_aln.GetFirstId()->GetSeqId());
960  ids[1].Reset(new CSeq_id);
961  SerialAssign<CSeq_id>(*ids[1], pairwise_aln.GetSecondId()->GetSeqId());
962  // Lens, strands, starts - just prepare the storage
963  dseg.SetLens().resize(1);
964  dseg.SetStrands().resize(2, eNa_strand_unknown);
965  dseg.SetStarts().resize(2, -1);
966  }
967 
968  // Main loop to set all values
969  CDense_seg::TNumseg seg = 0;
970  ITERATE(CPairwiseAln::TAlnRngColl, aln_rng_i, pairwise_aln) {
971  CDense_seg& dseg = *dsegs[seg];
972  dseg.SetStarts()[0] = aln_rng_i->GetFirstFrom();
973  if ( !aln_rng_i->IsDirect() ) {
974  if ( !dseg.IsSetStrands() ) {
975  dseg.SetStrands().resize(2, eNa_strand_plus);
976  }
977  dseg.SetStrands()[1] = eNa_strand_minus;
978  }
979  dseg.SetStarts()[1] = aln_rng_i->GetSecondFrom();
980  dseg.SetLens()[0] = aln_rng_i->GetLength();
981  seg++;
982  }
983 
984  return disc;
985 }
986 
987 
990  CScope* scope)
991 {
992  const CAnchoredAln::TPairwiseAlnVector& pairwises = anchored_aln.GetPairwiseAlns();
993 
994  typedef CSegmentedRangeCollection TAnchorSegments;
995  TAnchorSegments anchor_segments;
996  ITERATE(CAnchoredAln::TPairwiseAlnVector, pairwise_aln_i, pairwises) {
997  ITERATE (CPairwiseAln::TAlnRngColl, rng_i, **pairwise_aln_i) {
998  anchor_segments.insert(CPairwiseAln::TRng(rng_i->GetFirstFrom(), rng_i->GetFirstTo()));
999  }
1000  }
1001 
1002  // Create a packed-seg
1004 
1005  // Determine dimensions
1006  CPacked_seg::TNumseg& numseg = ps->SetNumseg();
1007  numseg = CDense_seg::TNumseg(anchor_segments.size());
1008  CPacked_seg::TDim& dim = ps->SetDim();
1009  dim = anchored_aln.GetDim();
1010 
1011  // Tmp vars
1014 
1015  // Ids
1016  CPacked_seg::TIds& ids = ps->SetIds();
1017  ids.resize(dim);
1018  for (row = 0; row < dim; ++row) {
1019  ids[row].Reset(new CSeq_id);
1020  SerialAssign<CSeq_id>(*ids[row], anchored_aln.GetId(dim - row - 1)->GetSeqId());
1021  }
1022 
1023  // Lens
1024  CPacked_seg::TLens& lens = ps->SetLens();
1025  lens.resize(numseg);
1026  TAnchorSegments::const_iterator seg_i = anchor_segments.begin();
1027  for (seg = 0; seg < numseg; ++seg, ++seg_i) {
1028  lens[seg] = seg_i->GetLength();
1029  }
1030 
1031  int matrix_size = dim * numseg;
1032 
1033  // Present
1034  CPacked_seg::TPresent& present = ps->SetPresent();
1035  present.resize(matrix_size);
1036 
1037  // Strands (just resize, will set while setting starts)
1038  CPacked_seg::TStrands& strands = ps->SetStrands();
1039  strands.resize(matrix_size, eNa_strand_unknown);
1040 
1041  // Starts and strands
1042  CPacked_seg::TStarts& starts = ps->SetStarts();
1043  starts.resize(matrix_size, 0);
1044  for (row = 0; row < dim; ++row) {
1045  seg = 0;
1046  int matrix_row_pos = row; // optimization to eliminate multiplication
1047  seg_i = anchor_segments.begin();
1048  CPairwiseAln::TAlnRngColl::const_iterator aln_rng_i = pairwises[dim - row - 1]->begin();
1049  bool direct = aln_rng_i->IsDirect();
1050  TSignedSeqPos left_delta = 0;
1051  TSignedSeqPos right_delta = aln_rng_i->GetLength();
1052  while (seg_i != anchor_segments.end()) {
1053  _ASSERT(seg < numseg);
1054  _ASSERT(matrix_row_pos == row + dim * seg);
1055  strands[matrix_row_pos] = (direct ? eNa_strand_plus : eNa_strand_minus);
1056  if (aln_rng_i != pairwises[dim - row - 1]->end() &&
1057  seg_i->GetFrom() >= aln_rng_i->GetFirstFrom()) {
1058  _ASSERT(seg_i->GetToOpen() <= aln_rng_i->GetFirstToOpen());
1059  if (seg_i->GetToOpen() > aln_rng_i->GetFirstToOpen()) {
1060  NCBI_THROW(CAlnException, eInternalFailure,
1061  "seg_i->GetToOpen() > aln_rng_i->GetFirstToOpen()");
1062  }
1063 
1064  // dec right_delta
1065  _ASSERT(right_delta >= seg_i->GetLength());
1066  if (right_delta < seg_i->GetLength()) {
1067  NCBI_THROW(CAlnException, eInternalFailure,
1068  "right_delta < seg_i->GetLength()");
1069  }
1070  right_delta -= seg_i->GetLength();
1071 
1072  CPacked_seg::TStarts::value_type start = (direct ?
1073  aln_rng_i->GetSecondFrom() + left_delta
1074  : aln_rng_i->GetSecondFrom() + right_delta);
1075  starts[matrix_row_pos] = start;
1076 
1077  present[matrix_row_pos] = (start != kInvalidSeqPos);
1078 
1079  // inc left_delta
1080  left_delta += seg_i->GetLength();
1081 
1082  if (right_delta == 0) {
1083  _ASSERT(left_delta == aln_rng_i->GetLength());
1084  ++aln_rng_i;
1085  if (aln_rng_i != pairwises[dim - row - 1]->end()) {
1086  direct = aln_rng_i->IsDirect();
1087  left_delta = 0;
1088  right_delta = aln_rng_i->GetLength();
1089  }
1090  }
1091  }
1092  ++seg_i;
1093  ++seg;
1094  matrix_row_pos += dim;
1095  }
1096  }
1097  return ps;
1098 }
1099 
1100 
1103  CScope* scope)
1104 {
1105  // Create a packed-seg
1107 
1108 
1109  // Determine dimensions
1110  CPacked_seg::TNumseg& numseg = ps->SetNumseg();
1111  numseg = CDense_seg::TNumseg(pairwise_aln.size());
1112  ps->SetDim(2);
1113  int matrix_size = 2 * numseg;
1114 
1115  CPacked_seg::TLens& lens = ps->SetLens();
1116  lens.resize(numseg);
1117 
1118  CPacked_seg::TStarts& starts = ps->SetStarts();
1119  starts.resize(matrix_size, 0);
1120 
1121  CPacked_seg::TPresent& present = ps->SetPresent();
1122  present.resize(matrix_size, 0);
1123 
1124  CPacked_seg::TIds& ids = ps->SetIds();
1125  ids.resize(2);
1126 
1127  // Ids
1128  ids[0].Reset(new CSeq_id);
1129  SerialAssign<CSeq_id>(*ids[0], pairwise_aln.GetFirstId()->GetSeqId());
1130  ids[1].Reset(new CSeq_id);
1131  SerialAssign<CSeq_id>(*ids[1], pairwise_aln.GetSecondId()->GetSeqId());
1132 
1133 
1134  // Tmp vars
1135  CPacked_seg::TNumseg seg = 0;
1136  int matrix_pos = 0;
1137 
1138  // Main loop to set all values
1139  ITERATE(CPairwiseAln::TAlnRngColl, aln_rng_i, pairwise_aln) {
1140  CPacked_seg::TStarts::value_type start = aln_rng_i->GetFirstFrom();
1141  present[matrix_pos] = (start != kInvalidSeqPos);
1142  starts[matrix_pos++] = start;
1143  if ( !aln_rng_i->IsDirect() ) {
1144  if ( !ps->IsSetStrands() ) {
1145  ps->SetStrands().resize(matrix_size, eNa_strand_plus);
1146  }
1147  ps->SetStrands()[matrix_pos] = eNa_strand_minus;
1148  }
1149  start = aln_rng_i->GetSecondFrom();
1150  present[matrix_pos] = (start != kInvalidSeqPos);
1151  starts[matrix_pos++] = start;
1152  lens[seg++] = aln_rng_i->GetLength();
1153  }
1154  _ASSERT(matrix_pos == matrix_size);
1155  _ASSERT(seg == numseg);
1156 
1157  return ps;
1158 }
1159 
1160 
1163  CSeq_align::TSegs::E_Choice dst_choice,
1164  CSeq_align::TDim anchor_row,
1165  CScope* scope)
1166 {
1167  TScopeAlnSeqIdConverter id_conv(scope);
1168  TScopeIdExtract id_extract(id_conv);
1169  TScopeAlnIdMap aln_id_map(id_extract, 1);
1170  TAlnSeqIdVec ids;
1171  id_extract(src, ids);
1172  aln_id_map.push_back(src);
1173 
1174  TScopeAlnStats aln_stats(aln_id_map);
1175  CAlnUserOptions aln_user_options;
1176  CRef<CAnchoredAln> anchored_aln =
1177  CreateAnchoredAlnFromAln(aln_stats, 0, aln_user_options, anchor_row);
1178 
1179  return CreateSeqAlignFromAnchoredAln(*anchored_aln, dst_choice, scope);
1180 }
1181 
1182 
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
User-defined methods of the data storage class.
CRef< CAnchoredAln > CreateAnchoredAlnFromAln(const _TAlnStats &aln_stats, size_t aln_idx, const CAlnUserOptions &options, objects::CSeq_align::TDim explicit_anchor_row=-1)
Create an anchored alignment from Seq-align using hints.
vector< TAlnSeqIdIRef > TAlnSeqIdVec
USING_SCOPE(objects)
void InitSplicedsegFromPairwiseAln(CSpliced_seg &spliced_seg, const CPairwiseAln &pairwise_aln, CScope *scope)
CRef< CSeq_align > CreateSeqAlignFromPairwiseAln(const CPairwiseAln &pairwise_aln, CSeq_align::TSegs::E_Choice choice, CScope *scope)
Convert CPairwiseAln to seq-align of the selected type.
CRef< CDense_seg > CreateDensegFromAnchoredAln(const CAnchoredAln &anchored_aln, CScope *scope)
CRef< CSpliced_seg > CreateSplicedsegFromPairwiseAln(const CPairwiseAln &pairwise_aln, CScope *scope)
CRef< CSeq_align > ConvertSeq_align(const CSeq_align &src, CSeq_align::TSegs::E_Choice dst_choice, CSeq_align::TDim anchor_row, CScope *scope)
Convert source alignment to a new type.
CRef< CPacked_seg > CreatePackedsegFromPairwiseAln(const CPairwiseAln &pairwise_aln, CScope *scope)
CRef< CPacked_seg > CreatePackedsegFromAnchoredAln(const CAnchoredAln &anchored_aln, CScope *scope)
void CreateDense_diagFromAnchoredAln(CSeq_align::TSegs::TDendiag &dd, const CAnchoredAln &anchored_aln, CScope *scope)
void s_TranslatePairwise(CPairwiseAln &out_pw, const CPairwiseAln &pw, const CPairwiseAln &tr)
CRef< CSpliced_seg > CreateSplicedsegFromAnchoredAln(const CAnchoredAln &anchored_aln, CScope *scope)
CRef< CSeq_align > CreateSeqAlignFromAnchoredAln(const CAnchoredAln &anchored_aln, CSeq_align::TSegs::E_Choice choice, CScope *scope)
Convert CAnchoredAln to seq-align of the selected type.
CAnchoredAln::TDim TDim
CRef< CSeq_align_set > CreateAlignSetFromPairwiseAln(const CPairwiseAln &pairwise_aln, CScope *scope)
void CreateSeqAlignFromEachPairwiseAln(const CAnchoredAln::TPairwiseAlnVector pairwises, TDim anchor, vector< CRef< CSeq_align > > &out_seqaligns, CSeq_align::TSegs::E_Choice choice, CScope *scope)
Create seq-align from each of the pairwise alignments vs the selected anchor row.
CRef< CSeq_align_set > CreateAlignSetFromAnchoredAln(const CAnchoredAln &anchored_aln, CScope *scope)
CRef< CDense_seg > CreateDensegFromPairwiseAln(const CPairwiseAln &pairwise_aln, CScope *scope)
static const TSignedSeqPos kMaxSplicedExonIndelLength
class CAlignRangeCollectionList<TAlignRange> represent a sorted collection of TAlignRange.
const_iterator begin() const
const_iterator insert(const TAlignRange &r)
TSignedSeqPos GetSecondPosByFirstPos(position_type pos, ESearchDirection dir=eNone) const
const_iterator end() const
CAlignRange Represents an element of pairwise alignment of two sequences.
Definition: align_range.hpp:63
Container mapping seq-aligns to vectors of participating seq-ids.
Definition: aln_tests.hpp:56
void push_back(const CSeq_align &aln)
Adding an alignment.
Definition: aln_tests.hpp:87
IAlnSeqId extracting functor.
Helper class which collects seq-align statistics: seq-ids participating in alignments and rows,...
Definition: aln_stats.hpp:57
Options for different alignment manager operations.
Query-anchored alignment can be 2 or multi-dimentional.
const TPairwiseAlnVector & GetPairwiseAlns(void) const
The vector of pairwise alns.
vector< CRef< CPairwiseAln > > TPairwiseAlnVector
const TAlnSeqIdIRef & GetId(TDim row) const
Seq ids of the rows.
TDim GetDim(void) const
How many rows.
TDim GetAnchorRow(void) const
Which is the anchor row?
CBioseq_Handle –.
void Validate() const
Definition: Dense_diag.cpp:58
void Validate(bool full_test=false) const
Definition: Dense_seg.cpp:274
CPacked_seg –.
Definition: Packed_seg.hpp:66
A pairwise aln is a collection of ranges for a pair of rows.
int GetSecondBaseWidth(void) const
Base width of the second row.
const TAlnSeqIdIRef & GetFirstId(void) const
Get first sequence id.
int GetFirstBaseWidth(void) const
Base width of the first row.
CRange< TPos > TRng
const TAlnSeqIdIRef & GetSecondId(void) const
Get second sequence id.
const_iterator end() const
Definition: range_set.hpp:88
iterator find_nc(position_type pos)
Definition: range_set.hpp:258
CPairwiseAln::TPos position_type
Definition: range_set.hpp:65
TThisType & CombineWithAndKeepAbutting(const TThisType &c)
Definition: range_set.hpp:217
TThisType & DivideAfter(const position_type &p)
If position is in middle of range, divide into two consecutive ranges after this position.
Definition: range_set.hpp:238
CRange –.
Definition: Range.hpp:68
Scope-aware seq-id converter.
CScope –.
Definition: scope.hpp:92
void insert(const TRange &r)
void CutAtPosition(position_type pos)
ncbi::CRangeSet< CPairwiseAln::TPos > TParent
CSpliced_exon_chunk –.
void Validate(bool full_test=false) const
Validators.
CNcbiOstream & operator<<(CNcbiOstream &out, const CEquivRange &range)
Definition: equiv_range.cpp:96
std::ofstream out("events_result.xml")
main entry point for tests
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
int TSignedSeqPos
Type for signed sequence position.
Definition: ncbimisc.hpp:887
#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
#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
virtual void Assign(const CSerialObject &source, ESerialRecursionMode how=eRecursive)
Optimized implementation of CSerialObject::Assign, which is not so efficient.
Definition: Seq_id.cpp:318
TSeqPos GetLength(const CSeq_id &id, CScope *scope)
Get sequence length if scope not null, else return max possible TSeqPos.
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
TSeqPos GetBioseqLength(void) const
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
position_type GetFirstToOpen(void) const
position_type GetFirstTo(void) const
position_type GetSecondFrom(void) const
TThisType & SetFirstFrom(position_type from)
position_type GetSecondTo(void) const
position_type GetFirstFrom(void) const
position_type GetSecondToOpen(void) const
position_type GetLength(void) const
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
TFrom GetFrom(void) const
Get the From member data.
Definition: Range_.hpp:222
vector< CRef< CSeq_id > > TIds
Definition: Packed_seg_.hpp:94
vector< char > TPresent
Definition: Packed_seg_.hpp:96
vector< TSeqPos > TStarts
Definition: Packed_seg_.hpp:95
Tdata & Set(void)
Assign a value to data member.
vector< ENa_strand > TStrands
Definition: Packed_seg_.hpp:98
TLens & SetLens(void)
Assign a value to Lens data member.
Definition: Dense_seg_.hpp:561
bool IsSetStrands(void) const
Check if a value has been assigned to Strands data member.
Definition: Dense_seg_.hpp:568
void SetProduct_id(TProduct_id &value)
Assign a value to Product_id data member.
E_Choice
Choice variants.
Definition: Seq_align_.hpp:131
vector< TSeqPos > TLens
Definition: Dense_seg_.hpp:108
void SetSegs(TSegs &value)
Assign a value to Segs data member.
Definition: Seq_align_.cpp:310
vector< ENa_strand > TStrands
Definition: Dense_seg_.hpp:109
TExons & SetExons(void)
Assign a value to Exons data member.
void SetDim(TDim value)
Assign a value to Dim data member.
TStrands & SetStrands(void)
Assign a value to Strands data member.
void SetDim(TDim value)
Assign a value to Dim data member.
Definition: Seq_align_.hpp:865
vector< TSignedSeqPos > TStarts
Definition: Dense_seg_.hpp:107
void SetDim(TDim value)
Assign a value to Dim data member.
Definition: Dense_seg_.hpp:427
vector< TSeqPos > TStarts
Definition: Dense_diag_.hpp:94
void SetType(TType value)
Assign a value to Type data member.
Definition: Seq_align_.hpp:818
vector< CRef< CSeq_id > > TIds
Definition: Dense_seg_.hpp:106
vector< CRef< CSeq_id > > TIds
Definition: Dense_diag_.hpp:93
TStarts & SetStarts(void)
Assign a value to Starts data member.
TStarts & SetStarts(void)
Assign a value to Starts data member.
Definition: Dense_seg_.hpp:536
void SetProduct_type(TProduct_type value)
Assign a value to Product_type data member.
TStrands & SetStrands(void)
Assign a value to Strands data member.
Definition: Dense_seg_.hpp:586
list< CRef< CSpliced_exon > > TExons
vector< ENa_strand > TStrands
Definition: Dense_diag_.hpp:96
void SetGenomic_id(TGenomic_id &value)
Assign a value to Genomic_id data member.
void SetNumseg(TNumseg value)
Assign a value to Numseg data member.
Definition: Dense_seg_.hpp:474
vector< TSeqPos > TLens
Definition: Packed_seg_.hpp:97
const TStarts & GetStarts(void) const
Get the Starts member data.
TIds & SetIds(void)
Assign a value to Ids data member.
Definition: Dense_seg_.hpp:511
list< CRef< CDense_diag > > TDendiag
Definition: Seq_align_.hpp:194
TIds & SetIds(void)
Assign a value to Ids data member.
@ e_not_set
No variant selected.
Definition: Seq_align_.hpp:132
@ eType_partial
mapping pieces together
Definition: Seq_align_.hpp:103
@ eNa_strand_plus
Definition: Na_strand_.hpp:66
@ eNa_strand_minus
Definition: Na_strand_.hpp:67
@ eNa_strand_unknown
Definition: Na_strand_.hpp:65
int i
double value_type
The numeric datatype used by the parser.
Definition: muParserDef.h:228
T min(T x_, T y_)
double r(size_t dimension_, const Int4 *score_, const double *prob_, double theta_)
#define row(bind, expected)
Definition: string_bind.c:73
#define _ASSERT
Modified on Sat May 25 14:22:32 2024 by modify_doxy.py rev. 669887