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

Go to the SVN repository for this file.

1 /* $Id: annot_compare_ds.cpp 40280 2018-01-19 17:54:35Z katargir $
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: Mike DiCuccio
27  *
28  * File Description:
29  *
30  */
31 
32 #include <ncbi_pch.hpp>
34 #include <gui/objutils/utils.hpp>
35 #include <gui/objutils/label.hpp>
36 //#include <gui/widgets/fl/text_report_dlg.hpp>
37 
41 #include <objmgr/util/sequence.hpp>
42 #include <objmgr/seq_vector.hpp>
43 #include <objmgr/feat_ci.hpp>
44 #include <serial/iterator.hpp>
45 
46 #include <gui/utils/view_event.hpp>
47 #include <gui/utils/app_job.hpp>
50 
51 #include <corelib/ncbi_system.hpp>
54 
55 
58 
59 /////////////////////////////////////////////////////////////////////////////
60 ///
61 /// AppJobs for background loading and preparation
62 ///
63 
65 {
66 public:
67  /// row represents a pair of compared features
69 };
70 
71 
72 /////////////////////////////////////////////////////////////////////////////
73 
74 
76  : m_Scope(&scope)
77  , m_ActiveJob(-1)
78  , m_Listener(NULL)
79 {
80 }
81 
82 
83 /// return progress indicator
85 {
88  return ref->GetNormDone();
89 }
90 
92 {
94  m_Rows.clear();
95 }
96 
97 
99 {
100  m_Listener = listener;
101 }
102 
103 
105 {
106  /// keep sets of statistics
107 
108  /// count of identical locations
109  size_t identical_locs = 0;
110 
111  /// count of identical sequences (genomic)
112  size_t identical_seqs = 0;
113 
114  /// count of identical products
115  size_t identical_prods = 0;
116 
117  /// count of identical loc + seq
118  size_t identical_locs_seqs = 0;
119 
120  /// count of identical loc + prod
121  size_t identical_locs_prods = 0;
122 
123  /// count of identical seq + prod
124  size_t identical_seqs_prods = 0;
125 
126  /// count of identical loc + seq + prod
127  size_t identical_locs_seqs_prods = 0;
128 
129  /// counts of feature subtypes with match counts
131  typedef map<string, TCountMap> TFeatCountMap;
132  TFeatCountMap feat_counts;
133 
134  typedef map<CSeq_id_Handle, TFeatCountMap> TCountNotFound;
135  TCountNotFound count_not_found;
136 
137  /// first set: comparison
138  ITERATE (TRows, iter, m_Rows) {
139 
140  /// register counts per feature type
141  string subtype;
142  if (iter->feat1) {
143  subtype = iter->feat1->GetData().GetKey();
144  } else if (iter->feat2) {
145  subtype = iter->feat2->GetData().GetKey();
146  }
147 
148  ///
149  /// keep a count per subtype of the features present
150  ///
151  {{
152  TFeatCountMap::iterator it =
153  feat_counts.insert(make_pair(subtype, TCountMap())).first;
154  TCountMap::value_type elt(iter->loc_state, 0);
155  TCountMap::iterator count_it = it->second.insert(elt).first;
156  ++count_it->second;
157  }}
158 
159  CAnnotCompare::TCompareFlags seq_match = iter->loc_state & CAnnotCompare::eSequenceMask;
161  ++identical_seqs_prods;
162  }
163  if (seq_match & CAnnotCompare::eSequence_SameSeq) {
164  ++identical_seqs;
165  }
166  if (seq_match & CAnnotCompare::eSequence_SameProduct) {
167  ++identical_prods;
168  }
169 
170  CAnnotCompare::TCompareFlags loc_match = iter->loc_state & CAnnotCompare::eLocationMask;
171  if (loc_match == CAnnotCompare::eLocation_Same) {
172  ++identical_locs;
173 
175  ++identical_locs_seqs_prods;
176  }
177  if (seq_match & CAnnotCompare::eSequence_SameSeq) {
178  ++identical_locs_seqs;
179  }
180  if (seq_match & CAnnotCompare::eSequence_SameProduct) {
181  ++identical_locs_prods;
182  }
183  }
184  if (loc_match == CAnnotCompare::eLocation_Missing) {
185  const CSeq_id_Handle& h =
186  iter->feat1 ? iter->feat1_seq : iter->feat2_seq;
187  const CSeq_feat& feat =
188  iter->feat1 ? *iter->feat1 : *iter->feat2;
189 
190  _ASSERT(h && h.GetSeqId());
191 
192  TCountNotFound::value_type v1(h, TFeatCountMap());
193  TCountNotFound::iterator i1 = count_not_found.insert(v1).first;
194 
195  TFeatCountMap::value_type v2(feat.GetData().GetKey(), TCountMap());
196  TFeatCountMap::iterator i2 = i1->second.insert(v2).first;
197 
199  TCountMap::iterator i3 = i2->second.insert(v3).first;
200  ++i3->second;
201  }
202  }
203 
204  ostr << "Evaluated " << m_Rows.size() << " total comparisons.\n\n";
205 
206  ostr << setw(10) << identical_locs << " Identical location\n";
207  ostr << setw(10) << identical_seqs << " Identical sequence\n";
208  ostr << setw(10) << identical_prods << " Identical product\n";
209  ostr << setw(10) << identical_locs_seqs << " Identical location + sequence\n";
210  ostr << setw(10) << identical_locs_prods << " Identical location + product\n";
211  ostr << setw(10) << identical_seqs_prods << " Identical sequence + product\n";
212  ostr << setw(10) << identical_locs_seqs_prods << " Identical location + sequence + product\n";
213 
214  /// note features not found
215  ostr << "\nFeatures Not Found:\n";
216  ostr << "-------------------\n";
217  ITERATE (TCountNotFound, iter, count_not_found) {
218  string s;
219  CLabel::GetLabel(*iter->first.GetSeqId(), &s, CLabel::eDefault, m_Scope);
220 
221  size_t total_feats = 0;
222  ITERATE (TFeatCountMap, it, iter->second) {
223  ITERATE (TCountMap, i, it->second) {
224  total_feats += i->second;
225  }
226  }
227  ostr << setw(10) << total_feats << " Not found on " << s << "\n";
228  ITERATE (TFeatCountMap, it, iter->second) {
229  size_t count = 0;
230  ITERATE (TCountMap, i, it->second) {
231  count += i->second;
232  }
233  ostr << setw(14) << count << " " << it->first;
234  if (count != 1) {
235  ostr << "s";
236  }
237  ostr << " not found\n";
238  }
239  ostr << "\n";
240  }
241 
242  /// note counts per feature subtype, with emphasis on
243  /// particular feature subtypes
244  ostr << "\nFeature Comparisons by Feature Type:\n";
245  ostr << "------------------------------------\n";
246  ITERATE (TFeatCountMap, iter, feat_counts) {
247  /// first, dump a stat on total comparisons for this feature type
248  size_t total_feats = 0;
249  ITERATE (TCountMap, it, iter->second) {
250  total_feats += it->second;
251  }
252 
253  ostr << setw(10) << total_feats << " " << iter->first;
254  if (total_feats != 1) {
255  ostr << "s";
256  }
257  ostr << "\n";
258 
259  ITERATE (TCountMap, it, iter->second) {
260  ostr << setw(14) << it->second << " ";
261 
262  /**
263  ostr << iter->first;
264  if (it->second != 1) {
265  ostr << "s";
266  }
267  ostr << " ";
268  **/
269 
270  CAnnotCompare::TCompareFlags loc_state =
271  it->first & CAnnotCompare::eLocationMask;
272  CAnnotCompare::TCompareFlags seq_state =
273  it->first & CAnnotCompare::eSequenceMask;
274  switch (loc_state) {
276  ostr << "not found";
277  break;
279  ostr << "identical location";
280  break;
282  ostr << "missing exons";
283  break;
285  ostr << "5' extension";
286  break;
288  ostr << "3' extension";
289  break;
291  ostr << "5' extra exons";
292  break;
294  ostr << "3' extra exons";
295  break;
297  ostr << "overlap, shared intervals";
298  break;
300  ostr << "complex location comparison";
301  break;
303  ostr << "subset";
304  break;
306  ostr << "overlap, no shared intervals";
307  break;
309  ostr << "different strand";
310  break;
311 
312  default:
313  ostr << "comparison unknown";
314  break;
315  }
316 
317  if (seq_state & CAnnotCompare::eSequence_SameSeq) {
318  ostr << ", same sequence";
319  }
320  if (seq_state & CAnnotCompare::eSequence_SameProduct) {
321  ostr << ", same product sequence";
322  }
323 
324  ostr << "\n";
325  }
326  ostr << "\n";
327  }
328 }
329 
330 
332 {
334  try {
335  m_ActiveJob = disp.StartJob(*job, "ObjManagerEngine",
336  *this, -1, true);
337  } catch(CAppJobException& e) {
338  LOG_POST(Error << "CAnnotCompareDS::x_BackgroundJob(): "
339  "Failed to start job: " << e.GetMsg());
340  LOG_POST(e.ReportAll());
341  }
342 }
343 
344 
346 {
348  try {
349  disp.DeleteJob(m_ActiveJob);
350  }
351  catch (CAppJobException& e) {
352  switch (e.GetErrCode()) {
355  /// this is fine - job probably already finished
356  break;
357 
358  default:
359  // something wrong
360  LOG_POST(Error << "CAnnotCompareDS::x_DeleteAllJobs(): "
361  "Error canceling job: " << e);
362  LOG_POST(e.ReportAll());
363  }
364  }
365 
366  m_ActiveJob = -1;
367 }
368 
369 
372  &CAnnotCompareDS::OnAJNotification)
374 
375 
376 void CAnnotCompareDS::OnAJNotification(CEvent* evt)
377 {
378  x_OnAppJobNotification(evt);
379 }
380 
382 {
383  CAppJobNotification* notn = dynamic_cast<CAppJobNotification*>(evt);
384  _ASSERT(notn);
385 
386  if (notn) {
387  int job_id = notn->GetJobID();
388  if (job_id != -1 && job_id != m_ActiveJob) {
389  return;
390  }
391 
392  switch (notn->GetState()) {
393  case IAppJob::eCompleted:
394  {{
395  m_ActiveJob = -1;
396  CRef<CObject> res_obj = notn->GetResult();
398  dynamic_cast<CFeatCompare_Result*>(&*res_obj);
399  if (result) {
400  m_Rows.swap(result->m_Rows);
401 
403  Send(&evt, ePool_Parent);
404  }
405  }}
406  break;
407 
408  case IAppJob::eFailed:
409  case IAppJob::eCanceled:
410  m_ActiveJob = -1;
411  break;
412 
413  default:
414  break;
415  }
416  }
417 }
418 
419 
421 {
422  return *m_Scope;
423 }
424 
425 
427 {
428  return m_Rows;
429 }
430 
431 
432 size_t CAnnotCompareDS::GetRows(void) const
433 {
434  return m_Rows.size();
435 }
436 
437 
438 const CAnnotCompareDS::SRow& CAnnotCompareDS::GetRow(size_t row_idx) const
439 {
440  _ASSERT(row_idx < m_Rows.size());
441  return m_Rows[row_idx];
442 }
443 
444 
445 /////////////////////////////////////////////////////////////////////////////
446 ///
447 /// Alignment-based data source
448 ///
449 
451 {
452 public:
453  CFeatCompareJob(CScope& scope);
454 
455 
456  /// @name IAppJob implementation
457  /// @{
459  virtual CRef<CObject> GetResult();
461  virtual string GetDescr() const;
462  /// @}
463 
464 protected:
465 
467 
468  /// for status reporting
471 
472  // for job results/status
475 };
476 
477 
478 /////////////////////////////////////////////////////////////////////////////
479 
481  : m_Scope(&scope)
482 {
483 }
484 
485 
487 {
491 }
492 
493 
495 {
497 }
498 
499 
501 {
503 }
504 
505 
507 {
508  return string("CFeatCompareJob");
509 }
510 
511 /////////////////////////////////////////////////////////////////////////////
512 
514 {
515 public:
516  CFeatCompareJob_Align(CScope& scope, const CSeq_align& alignment);
517 
518  /// @name IAppJob implementation
519  /// @{
520  virtual EJobState Run();
521  /// @}
522 
523 protected:
525 };
526 
527 
529  const CSeq_align& alignment)
530  : CFeatCompareJob(scope)
531  , m_Align(&alignment)
532 {
533 }
534 
535 
537 {
538  m_Error.Reset(NULL);
540 
541  ///
542  /// don't merge our alignments!
543  /// rather, we use them as-is and rely on the user supplying us with a
544  /// curated alignment
545  ///
546 
548  sel.ExcludeNamedAnnots("SNP");
549 
550  /// first, we collect all features in all sequences represented in
551  /// the alignment. Each feature must be accounted for.
552  typedef map<CConstRef<CSeq_feat>, CMappedFeat> TFeats;
553  typedef map<CSeq_id_Handle, TFeats> TFeatMap;
554 
555  m_TotalComparisons = 0;
557 
558  TFeatMap fmap;
559  list<CSeq_id_Handle> ids;
560 
561  size_t rows = m_Align->CheckNumRows();
562  for (size_t i = 0; i < rows; ++i) {
563  const CSeq_id& id = m_Align->GetSeq_id((int)i);
565  ids.push_back(sih);
566 
567  CBioseq_Handle handle = m_Scope->GetBioseqHandle(sih);
568  CFeat_CI feat_iter(handle, m_Align->GetSeqRange((int)i), m_Align->GetSeqStrand((int)i));
569  TFeats& feats = fmap[sih];
570  for ( ; feat_iter; ++feat_iter) {
571  CConstRef<CSeq_feat> ref(&feat_iter->GetOriginalFeature());
572  feats[ref] = *feat_iter;
573  }
574 
575  m_TotalComparisons += feats.size();
576  }
577 
578  /// next, we scan for the best matches across all sequences
579  /// the goal is to represent each feature in each sequence, and report
580  /// if the feature is missing
581 
582  /// for each sequence
583  ITERATE (list<CSeq_id_Handle>, idh_iter1, ids) {
584 
585  /// find the best matching feature in each additional sequence
586  ITERATE (list<CSeq_id_Handle>, idh_iter2, ids) {
587  if (idh_iter1 == idh_iter2) {
588  continue;
589  }
590 
591  bool do_swap = (*idh_iter2 < *idh_iter1);
592 
593  CSeq_id_Handle sih1 = (do_swap ? *idh_iter2 : *idh_iter1);
594  CSeq_id_Handle sih2 = (do_swap ? *idh_iter1 : *idh_iter2);
595 
596  /// we plan to delete out of set 2 if we find an exact match
597  const TFeats& feat_set1 = (do_swap ? fmap[sih2] : fmap[sih1]);
598  TFeats& feat_set2 = (do_swap ? fmap[sih1] : fmap[sih2]);
600 
601  /// build or seq-loc mapper
602  /// NB: optimize this out of this loop!
603  CSeq_loc_Mapper mapper(*m_Align, *sih2.GetSeqId(), m_Scope);
604  mapper.SetMergeAbutting();
605 
606  /// for each feature in feature set 1
607  ITERATE (TFeats, fiter1, feat_set1) {
608  if (IsCanceled()) {
609  NCBI_THROW(CException, eUnknown, "Job cancelled");
610  }
611  CMappedFeat f1 = fiter1->second;
612  sel.SetFeatSubtype(f1.GetData().GetSubtype());
613 
614  CRef<CSeq_loc> mapped_loc = mapper.Map(f1.GetLocation());
615 
616  /// find all possible overlaps
618  TCompMap comp_map;
619  CFeat_CI iter(*m_Scope, *mapped_loc, sel);
620  if (iter.GetSize()) {
621  for ( ; iter; ++iter) {
622  if (IsCanceled()) {
623  NCBI_THROW(CException, eUnknown, "Job cancelled");
624  }
625  CMappedFeat f2 = *iter;
626 
627  CAnnotCompare annot_comp;
629  annot_comp.CompareFeats(f1.GetOriginalFeature(),
630  *mapped_loc, *m_Scope,
631  f2.GetOriginalFeature(),
632  f2.GetLocation(), *m_Scope,
633  NULL, NULL);
635  /// exact match
636  comp_map.clear();
637  comp_map.insert(TCompMap::value_type(comp, f2));
638 
639  /// we also strip the feature from feature set 2
641  TFeats::iterator fi2 = feat_set2.find(ref2);
642  if (fi2 != feat_set2.end()) {
643  feat_set2.erase(fi2);
645  }
646  break;
648  comp_map.insert(TCompMap::value_type(comp, f2));
649  }
650  }
651 
652  /// save any categorizations we've got
653  ITERATE (TCompMap, cmiter, comp_map) {
655  row.scope = m_Scope;
656 
657  row.feat1.Reset(&f1.GetOriginalFeature());
658  row.feat1_loc.Reset(&f1.GetLocation());
659  row.feat2.Reset(&cmiter->second.GetOriginalFeature());
660  row.feat2_loc.Reset(&cmiter->second.GetLocation());
661 
662  /**
663  if (do_swap) {
664  swap(row.feat1, row.feat2);
665  swap(row.feat1_loc, row.feat2_loc);
666  }
667  **/
668 
669  row.loc_state = cmiter->first;
670  m_Result->m_Rows.push_back(row);
671  }
672  } else {
673  /// missing!
674  /// we always save at least the mapped location
676  row.scope = m_Scope;
677 
678  row.feat1.Reset(&f1.GetOriginalFeature());
679  row.feat1_loc.Reset(&f1.GetLocation());
680 
681  if (mapped_loc->Which() != CSeq_loc::e_Null) {
682  row.feat2_loc = mapped_loc;
683  }
684 
685  /**
686  if (do_swap) {
687  swap(row.feat1, row.feat2);
688  swap(row.feat1_loc, row.feat2_loc);
689  }
690  **/
691 
693  m_Result->m_Rows.push_back(row);
694  }
695 
697  }
698  }
699  }
700 
701  /// finalize our data
702  size_t count = 0;
704  CAnnotCompareDS::SRow& data = *iter;
705  data.row_idx = count++;
706  if ( data.feat1 && !data.feat1_loc ) {
707  data.feat1_loc.Reset(&data.feat1->GetLocation());
708  }
709  if ( data.feat2 && !data.feat2_loc ) {
710  data.feat2_loc.Reset(&data.feat2->GetLocation());
711  }
712 
713  if (data.feat1_loc) {
714  data.feat1_seq = sequence::GetIdHandle(*data.feat1_loc, m_Scope);
715  }
716  if (data.feat2_loc) {
717  data.feat2_seq = sequence::GetIdHandle(*data.feat2_loc, m_Scope);
718  }
719  }
720  return eCompleted;
721 }
722 
723 
724 /////////////////////////////////////////////////////////////////////////////
725 
726 
728  const CSeq_annot& annot)
729  : CAnnotCompareDS(scope)
730 {
732  std::copy(annot.GetData().GetAlign().begin(),
733  annot.GetData().GetAlign().end(),
734  back_inserter(m_Alignments));
735  x_Init();
736 }
737 
738 
740  const CSeq_align& align)
741  : CAnnotCompareDS(scope)
742 {
743  m_Alignments.push_back(CConstRef<CSeq_align>(&align));
744  x_Init();
745 }
746 
747 
749  const CSeq_align_set& align_set)
750  : CAnnotCompareDS(scope)
751 {
752  /// save the original alignments as well
753  std::copy(align_set.Get().begin(),
754  align_set.Get().end(),
755  back_inserter(m_Alignments));
756 
757  x_Init();
758 }
759 
760 
762  const list< CConstRef<CSeq_align> >& aligns)
763  : CAnnotCompareDS(scope),
764  m_Alignments(aligns)
765 {
766  x_Init();
767 }
768 
769 
771 {
772 }
773 
774 
776 {
777  CAlnMix mix(*m_Scope);
778  ITERATE (list< CConstRef<CSeq_align> >, iter, m_Alignments) {
779  mix.Add(**iter);
780  }
782 
783  m_Align.Reset(&mix.GetSeqAlign());
784 }
785 
786 
788 {
789  Clear();
790 
791  ///
792  /// launch a backgroun job for our data
793  ///
795  x_BackgroundJob(job);
796 }
797 
798 
799 /////////////////////////////////////////////////////////////////////////////
800 ///
801 /// Annotation Comparison by location alone
802 /// This is done by checking a few constraints
803 ///
804 
805 /////////////////////////////////////////////////////////////////////////////
806 
808 {
809 public:
810  CFeatCompareJob_Location(CScope& scope, const CSeq_loc& loc);
811 
812  /// @name IAppJob implementation
813  /// @{
814  virtual EJobState Run();
815  /// @}
816 
817 protected:
818 
820 };
821 
822 
824  const CSeq_loc& loc)
825  : CFeatCompareJob(scope)
826  , m_Loc(&loc)
827 {
828 }
829 
830 
832 {
833  m_Error.Reset(NULL);
835 
837 
838  /// iterate all features on our sequence
839  CFeat_CI feat_iter(*m_Scope, *m_Loc, sel);
840  m_TotalComparisons = feat_iter.GetSize();
841  for ( ; feat_iter; ++feat_iter) {
842  if (IsCanceled()) {
843  NCBI_THROW(CException, eUnknown, "Job cancelled");
844  }
845  CMappedFeat f1 = *feat_iter;
846  string annot_name;
847  if (f1.GetSeq_feat_Handle().GetAnnot().IsNamed()) {
848  annot_name = f1.GetSeq_feat_Handle().GetAnnot().GetName();
849  }
850 
851  /// scan for additional features not on the same annotation
852  SAnnotSelector sel2(sel);
853  sel2.SetFeatSubtype(f1.GetData().GetSubtype());
854 
856  TCompMap comp_map;
857  CFeat_CI feat_iter2(*m_Scope, f1.GetLocation(), sel2);
858  for ( ; feat_iter2; ++feat_iter2) {
859  if (IsCanceled()) {
860  NCBI_THROW(CException, eUnknown, "Job cancelled");
861  }
862  CMappedFeat f2 = *feat_iter2;
863  if (f2.GetSeq_feat_Handle().GetAnnot().IsNamed()) {
864  if (f2.GetSeq_feat_Handle().GetAnnot().GetName() == annot_name) {
865  continue;
866  }
867  } else if (annot_name.empty()) {
868  continue;
869  }
870 
871  CAnnotCompare annot_comp;
873  annot_comp.CompareFeats(f1, *m_Scope, f2, *m_Scope,
874  NULL, NULL);
876  comp_map.clear();
877  comp_map.insert(TCompMap::value_type(comp, f2));
878  break;
880  comp_map.insert(TCompMap::value_type(comp, f2));
881  }
882  }
883 
884  if (comp_map.size()) {
885  /// save any additional categorizations we've got
886  ITERATE (TCompMap, cmiter, comp_map) {
888  row.scope = m_Scope;
889 
890  row.feat1.Reset(&f1.GetOriginalFeature());
891  row.feat1_loc.Reset(&f1.GetLocation());
892  row.feat1_seq = sequence::GetIdHandle(*row.feat1_loc, m_Scope);
893  row.feat2.Reset(&cmiter->second.GetOriginalFeature());
894  row.feat2_loc.Reset(&cmiter->second.GetLocation());
895  row.feat2_seq = sequence::GetIdHandle(*row.feat2_loc, m_Scope);
896 
897  row.loc_state = cmiter->first;
898  m_Result->m_Rows.push_back(row);
899  }
900  } else {
901  /// missing!
903  row.scope = m_Scope;
904 
905  row.feat1.Reset(&f1.GetOriginalFeature());
906  row.feat1_loc.Reset(&f1.GetLocation());
907  row.feat1_seq = sequence::GetIdHandle(*row.feat1_loc, m_Scope);
908 
910  m_Result->m_Rows.push_back(row);
911  }
912 
914  }
915  return eCompleted;
916 }
917 
918 /////////////////////////////////////////////////////////////////////////////
919 
921  const CSeq_loc& loc)
922  : CAnnotCompareDS(scope)
923  , m_Loc(&loc)
924 {
925 }
926 
927 
929 {
930 }
931 
932 
934 {
935  Clear();
936 
937  ///
938  /// launch a backgroun job for our data
939  ///
942  x_BackgroundJob(job);
943 }
944 
945 
static CRef< CScope > m_Scope
USING_SCOPE(objects)
ON_EVENT(CAppJobNotification, CAppJobNotification::eStateChanged, &CAnnotCompareDS::OnAJNotification) void CAnnotCompareDS
void Add(const CDense_seg &ds, TAddFlags flags=0)
Definition: alnmix.cpp:120
@ fGapJoin
Definition: alnmix.hpp:103
void Merge(TMergeFlags flags=0)
Definition: alnmix.cpp:273
const CSeq_align & GetSeqAlign(void) const
Definition: alnmix.cpp:302
CAnnotCompareDS.
objects::CScope & GetScope() const
CAppJobDispatcher::TJobID m_ActiveJob
control of background loading
size_t GetRows(void) const
void RegisterListener(CEventHandler *listener)
register a listener to respond to background job completion events
vector< SRow > TRows
CEventHandler * m_Listener
const SRow & GetRow(size_t row_idx) const
CRef< objects::CScope > m_Scope
virtual void x_OnAppJobNotification(CEvent *evt)
float GetProgress() const
return progress indicator
void DumpTextReport(CNcbiOstream &ostr) const
dump a text report of the comparisons
const TRows & GetData() const
void x_BackgroundJob(IAppJob *job)
CAnnotCompare_AlignDS(objects::CScope &scope, const objects::CSeq_annot &annot)
list< CConstRef< objects::CSeq_align > > m_Alignments
our original alignments
CConstRef< objects::CSeq_align > m_Align
merged alignment from the above
CConstRef< objects::CSeq_loc > m_Loc
CAnnotCompare_LocationDS(objects::CScope &scope, const objects::CSeq_loc &loc)
TCompareFlags CompareFeats(const CSeq_feat &feat1, CScope &scope1, const CSeq_feat &feat2, CScope &scope2, vector< ECompareFlags > *complex_flags, list< string > *comments)
compare two different features, possibly living in different scopes.
@ eLocation_RegionOverlap
locations exhibit a non-shared-exon overlap of total range
@ eLocation_MissingExon
missing an exon, either 5', 3', or internal
@ eLocation_5PrimeExtension
5', 3' extended exon
@ eLocation_Overlap
locations overlap without sharing exon boundaries
@ eSequence_SameSeq
sequence categories (genomic and product)
@ eLocation_Complex
complex relation - results may be returned as a set of the above
@ eLocationMask
masks for the above
@ eLocation_Subset
one location is a subset of another
@ eLocation_DifferentStrand
locations annotated on different strands
@ eSequence_SameProduct
locations have the same product sequence
@ eLocation_Missing
genomic location categories
@ eLocation_Same
no difference in lcoation
@ eLocation_5PrimeExtraExon
5', 3' extra exons
size_t GetSize(void) const
CAppJobDispatcher.
IAppJobListener Interface for components that need to be notified about changes in Jobs.
CAppJobNotification Notification send by CAppJobEventTranslator.
CAppJobProgress Default implementation for IAppJobProgress - the class encapsulates a text message an...
CBioseq_Handle –.
CEventHandler.
CEvent - generic event implementation TODO TODO - Attachments.
Definition: event.hpp:86
virtual EJobState Run()
Function that does all the useful work, called by the Engine.
CFeatCompareJob_Align(CScope &scope, const CSeq_align &alignment)
CConstRef< CSeq_align > m_Align
Annotation Comparison by location alone This is done by checking a few constraints.
CFeatCompareJob_Location(CScope &scope, const CSeq_loc &loc)
CConstRef< CSeq_loc > m_Loc
virtual EJobState Run()
Function that does all the useful work, called by the Engine.
Alignment-based data source.
CRef< CScope > m_Scope
virtual CConstIRef< IAppJobProgress > GetProgress()
return progress object, the function shall be synchronized internally.
CFeatCompareJob(CScope &scope)
CRef< CAppJobError > m_Error
size_t m_TotalComparisons
for status reporting
virtual CRef< CObject > GetResult()
Returns the Job Result.
CRef< CFeatCompare_Result > m_Result
virtual CConstIRef< IAppJobError > GetError()
Returns IAppJobError object describing internal error that caused the Job to fail.
virtual string GetDescr() const
Returns a human readable description of the Job (optional)
AppJobs for background loading and preparation.
CAnnotCompareDS::TRows m_Rows
row represents a pair of compared features
CFeat_CI –.
Definition: feat_ci.hpp:64
Base class to build jobs with cancel functionality.
CMappedFeat –.
Definition: mapped_feat.hpp:59
CObject –.
Definition: ncbiobj.hpp:180
CScope –.
Definition: scope.hpp:92
ESubtype GetSubtype(void) const
string GetKey(EVocabulary vocab=eVocabulary_full) const
CRange< TSeqPos > GetSeqRange(TDim row) const
GetSeqRange NB: On a Spliced-seg, in case the product-type is protein, these only return the amin par...
Definition: Seq_align.cpp:153
TDim CheckNumRows(void) const
Validatiors.
Definition: Seq_align.cpp:73
const CSeq_id & GetSeq_id(TDim row) const
Get seq-id (the first one if segments have different ids).
Definition: Seq_align.cpp:317
ENa_strand GetSeqStrand(TDim row) const
Get strand (the first one if segments have different strands).
Definition: Seq_align.cpp:294
namespace ncbi::objects::
Definition: Seq_feat.hpp:58
CSeq_loc_Mapper –.
@ eWidgetDataChanged
notification from child to parent that the underlying data has changed
Definition: view_event.hpp:61
IAppJob.
Definition: app_job.hpp:82
Definition: map.hpp:338
char data[12]
Definition: iconv.c:80
#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
string
Definition: cgiapp.hpp:687
#define NULL
Definition: ncbistd.hpp:225
#define LOG_POST(message)
This macro is deprecated and it's strongly recomended to move in all projects (except tests) to macro...
Definition: ncbidiag.hpp:226
void Error(CExceptionArgs_Base &args)
Definition: ncbiexpt.hpp:1197
#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 CVect2< U > & v2
Definition: globals.hpp:440
static objects::SAnnotSelector GetAnnotSelector(TAnnotFlags flags=0)
request an annotation selector for a given type
Definition: utils.cpp:167
static void GetLabel(const CObject &obj, string *label, ELabelType type=eDefault)
Definition: label.cpp:140
static CAppJobDispatcher & GetInstance()
CRef< CObject > GetResult() const
returns non-null pointer only if Completed or Running and has temporary results available
virtual bool IsCanceled() const override
bool DeleteJob(TJobID job_id)
when a Job is deleted the listener is not notified
EJobState
Job states (describe FSM)
Definition: app_job.hpp:86
TJobID StartJob(IAppJob &job, const string &engine_name, IEngineParams *params=NULL)
Starts a Job on the specified engine in "passive mode" - no notifications or progress reports will be...
#define END_EVENT_MAP()
Ends definition of Command Map.
#define BEGIN_EVENT_MAP(thisClass, baseClass)
Begins definition of Command Map for CEventHandler-derived class.
CConstIRef< IAppJobProgress > GetJobProgress(TJobID job_id)
TJobState GetState() const
virtual bool Send(CEvent *evt, EDispatch disp_how=eDispatch_Default, int pool_name=ePool_Default)
Sends an event synchronously.
void SetNormDone(float done)
@ eEngine_UnknownJob
the job is not registered in the Engine
@ eUnknownJob
Job record lost.
@ eCanceled
Definition: app_job.hpp:91
@ eCompleted
Definition: app_job.hpp:89
@ eFailed
Definition: app_job.hpp:90
@ eDefault
Definition: label.hpp:73
CConstRef< CSeq_id > GetSeqId(void) const
static CSeq_id_Handle GetHandle(const CSeq_id &id)
Normal way of getting a handle, works for any seq-id.
CSeq_id_Handle GetIdHandle(const CSeq_loc &loc, CScope *scope)
CRef< CSeq_loc > Map(const CSeq_loc &src_loc)
Map seq-loc.
CBioseq_Handle GetBioseqHandle(const CSeq_id &id)
Get bioseq handle by seq-id.
Definition: scope.cpp:95
CSeq_loc_Mapper_Base & SetMergeAbutting(void)
Merge only abutting intervals, keep overlapping.
bool IsNamed(void) const
const CSeq_annot_Handle & GetAnnot(void) const
Get handle to seq-annot for this feature.
const CSeqFeatData & GetData(void) const
const string & GetName(void) const
const CSeq_loc & GetLocation(void) const
const CSeq_feat & GetOriginalFeature(void) const
Get original feature with unmapped location/product.
const CSeq_feat_Handle & GetSeq_feat_Handle(void) const
Get original feature handle.
Definition: mapped_feat.hpp:71
SAnnotSelector & SetFeatSubtype(TFeatSubtype subtype)
Set feature subtype (also set annotation and feat type)
SAnnotSelector & ExcludeNamedAnnots(const CAnnotName &name)
Add named annot to set of annots names to exclude.
TObjectType * GetPointer(void) THROWS_NONE
Get pointer,.
Definition: ncbiobj.hpp:998
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:1439
void Reset(void)
Reset reference object.
Definition: ncbiobj.hpp:773
#define END_NCBI_SCOPE
End previously defined NCBI scope.
Definition: ncbistl.hpp:103
#define BEGIN_NCBI_SCOPE
Define ncbi namespace.
Definition: ncbistl.hpp:100
IO_PREFIX::ostream CNcbiOstream
Portable alias for ostream.
Definition: ncbistre.hpp:149
const Tdata & Get(void) const
Get the member data.
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_feat_.hpp:925
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_loc_.hpp:475
@ e_Null
not placed
Definition: Seq_loc_.hpp:98
const TAlign & GetAlign(void) const
Get the variant data.
Definition: Seq_annot_.hpp:641
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_annot_.hpp:873
E_Choice Which(void) const
Which variant is currently selected.
Definition: Seq_annot_.hpp:586
int i
double value_type
The numeric datatype used by the parser.
Definition: muParserDef.h:228
void copy(Njn::Matrix< S > *matrix_, const Njn::Matrix< T > &matrix0_)
Definition: njn_matrix.hpp:613
#define row(bind, expected)
Definition: string_bind.c:73
SAnnotSelector –.
#define _ASSERT
else result
Definition: token2.c:20
Modified on Tue Apr 23 07:40:10 2024 by modify_doxy.py rev. 669887