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

Go to the SVN repository for this file.

1 /* $Id: cdd_ibis_annot_dialog.cpp 97608 2022-08-03 16:00:58Z lanczyck $
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: Chris Lanczycki
27 *
28 * File Description:
29 * dialogs for annotating CDD's with interactions from IBIS
30 *
31 * ===========================================================================
32 */
33 
34 #include <ncbi_pch.hpp>
35 
36 #include <algorithm>
37 
38 #include <corelib/ncbistd.hpp>
39 
49 
51 #include "structure_set.hpp"
52 #include "messenger.hpp"
53 #include "alignment_manager.hpp"
55 #include "sequence_set.hpp"
56 #include "cn3d_tools.hpp"
57 //#include "chemical_graph.hpp"
58 //#include "opengl_renderer.hpp"
59 //#include "show_hide_manager.hpp"
60 #include "asn_reader.hpp"
61 
62 
63 ////////////////////////////////////////////////////////////////////////////////////////////////
64 // The following is taken unmodified from wxDesigner's C++ header from cdd_ibis_annot_dialog.wdr
65 ////////////////////////////////////////////////////////////////////////////////////////////////
66 
67 #include <wx/artprov.h>
68 #include <wx/image.h>
69 #include <wx/imaglist.h>
70 #include <wx/statline.h>
71 #include <wx/spinbutt.h>
72 #include <wx/spinctrl.h>
73 #include <wx/splitter.h>
74 #include <wx/listctrl.h>
75 #include <wx/treectrl.h>
76 #include <wx/notebook.h>
77 #include <wx/grid.h>
78 #include <wx/toolbar.h>
79 #include <wx/tglbtn.h>
80 
81 // Declare window functions
82 
83 extern wxSizer *ibisIntStaticBoxSizer;
84 #define ID_TEXT_INT 10000
85 #define ID_C_TYPE 10001
86 #define ID_LC_INT 10002
87 #define ID_B_ADD_INT 10003
88 #define ID_B_LAUNCH_INT 10004
89 #define ID_B_HIGHLIGHT_INT 10005
90 #define ID_LB_ANNOT 10006
91 #define ID_B_DELETE_ANNOT 10007
92 #define ID_B_HIGHLIGHT_ANNOT 10008
93 #define ID_B_HIGHLIGHT_OLAP 10009
94 #define ID_B_HIGHLIGHT_NONOLAP_ANNOT 10010
95 #define ID_B_HIGHLIGHT_NONOLAP_INTN 10011
96 wxSizer *SetupIbisAnnotationDialog( wxWindow *parent, bool call_fit = TRUE, bool set_sizer = TRUE );
97 
98 ////////////////////////////////////////////////////////////////////////////////////////////////
99 
102 
103 
104 BEGIN_SCOPE(Cn3D)
105 
106 static const string IBIS_EVIDENCE_COMMENT = "Interaction site inferred from IBIS";
107 
108 
109 // IBISInteraction members and methods
110 
111 const Sequence* IBISInteraction::m_querySequence = NULL;
112 const MoleculeIdentifier* IBISInteraction::m_queryMolecule = NULL;
113 const int IBISInteraction::NOT_ASSIGNED = -1;
114 const TGi IBISInteraction::GI_NOT_ASSIGNED = -1;
115 
116 void IBISInteraction::SetQuerySequence(const Sequence* querySequence) {
117  m_queryMolecule = NULL;
118  m_querySequence = querySequence;
119  if (m_querySequence) m_queryMolecule = m_querySequence->identifier;
120 }
121 
123 {
124  bool result = false;
125  if (m_queryMolecule) {
126  result = (!m_queryMolecule->pdbChain.empty() && m_queryMolecule->pdbChain != " ");
127  }
128  return result;
129 }
130 
132 {
133  bool result = true;
135 
136  switch (integer) {
137  case eIbisNoTypeAssigned:
139  break;
140  case eIbisProteinDNA:
142  break;
143  case eIbisProteinRNA:
145  break;
148  break;
149  case eIbisProteinProtein:
151  break;
152  case eIbisProteinPeptide:
154  break;
155  case eIbisProteinIon:
157  break;
160  break;
161  default:
162  INFOMSG("type " << integer << " is not a valid Ibis interaction type");
163  result = false;
164  break;
165  };
166 
167  if (result && ibisType) {
168  *ibisType = type;
169  }
170 
171  return result;
172 }
173 
175 {
176  string result = "Unknown";
177  switch (ibisType) {
178  case eIbisNoTypeAssigned:
179  result = "Unassigned";
180  break;
181  case eIbisProteinDNA:
182  case eIbisProteinRNA:
184  result = "NucAcid";
185  break;
186  case eIbisProteinProtein:
187  result = "Protein";
188  break;
189  case eIbisProteinPeptide:
190  result = "Peptide";
191  break;
192  case eIbisProteinIon:
193  result = "Ion";
194  break;
196  result = "Chemical";
197  break;
198 // case ???:
199 // cddType = eCddPosttransMod;
200 // break;
201  default:
202  break;
203  };
204  return result;
205 }
206 
208 {
209  eCddInteractionType cddType = eCddOther;
210  switch (ibisType) {
211  case eIbisNoTypeAssigned:
212  cddType = eCddNoTypeAssigned;
213  break;
214  case eIbisProteinDNA:
215  case eIbisProteinRNA:
217  cddType = eCddNABinding;
218  break;
219  case eIbisProteinProtein:
220  case eIbisProteinPeptide:
221  cddType = eCddPolypeptideBinding;
222  break;
223  case eIbisProteinIon:
224  cddType = eCddIonBinding;
225  break;
227  cddType = eCddChemicalBinding;
228  break;
229 // case ???:
230 // cddType = eCddPosttransMod;
231 // break;
232  default:
233  INFOMSG("IBIS interaction type " << ibisType << " not mapped to a Cdd interaction type");
234  break;
235  };
236  return cddType;
237 }
238 
240 {
241  eIbisInteractionType ibisType = eIbisOther;
242  switch (cddType) {
243  case eCddNoTypeAssigned:
244  ibisType = eIbisNoTypeAssigned;
245  break;
247  ibisType = eIbisProteinProtein;
248  break;
249  case eCddNABinding:
250  ibisType = eIbisProteinCombo_DNA_RNA;
251  break;
252  case eCddIonBinding:
253  ibisType = eIbisProteinIon;
254  break;
255  case eCddChemicalBinding:
256  ibisType = eIbisProteinChemical;
257  break;
258 // case eCddPosttransMod:
259 // ibisType = ???;
260 // break;
261  default:
262  INFOMSG("Cdd interaction type " << cddType << " not mapped to an IBIS interaction type");
263  break;
264  };
265  return ibisType;
266 }
267 
268 
269 IBISInteraction::IBISInteraction(const ncbi::objects::CSeq_feat& seqfeat)
270 {
271  m_seqfeat.Assign(seqfeat);
272  Initialize();
273 }
274 
276 {
277  int intValue;
278  string label;
279 
281  if (m_seqfeat.IsSetId() && m_seqfeat.GetId().IsLocal() && m_seqfeat.GetId().GetLocal().IsId()) {
282  m_rowId = m_seqfeat.GetId().GetLocal().GetId();
283  }
284 
285  m_desc = kEmptyStr;
286  if (m_seqfeat.GetData().IsRegion()) {
287  m_desc = m_seqfeat.GetData().GetRegion();
288  }
289 
290  // The IBIS seqfeat by convention has zero-based positions.
291  // Also, to ensure the use of consistent identifiers, because
292  // IBIS may have a GI different than in the CD for the query
293  // structure, switch to the Seq-id found in the query sequence
294  // [if the query actually worked, then we should end up w/ the PDB accession].
295  bool inRange = true;
296  TSeqPos from, to;
297  CSeq_loc& location = m_seqfeat.SetLocation();
298  if (location.IsInt()) {
299  from = location.SetInt().SetFrom();
300  to = location.SetInt().SetTo();
301  location.SetInt().SetFrom(from);
302  location.SetInt().SetTo(to);
303  if (m_querySequence)
304  m_querySequence->FillOutSeqId(&(location.SetInt().SetId()));
305 
306  } else if (location.IsPacked_int()) {
307  CPacked_seqint::Tdata::iterator s, se = location.SetPacked_int().Set().end();
308  for (s = location.SetPacked_int().Set().begin(); s!=se; ++s) {
309  from = (**s).SetFrom();
310  to = (**s).SetTo();
311  (**s).SetFrom(from);
312  (**s).SetTo(to);
313  if (m_querySequence)
314  m_querySequence->FillOutSeqId(&((**s).SetId()));
315  }
316  } else {
317  ERRORMSG("interaction '" << m_desc << "' has unexpected location type");
318  }
319 
320  if (!inRange) {
321  ERRORMSG("interaction '" << m_desc << "' has out-of-range positions");
322  }
323 
324 
333  m_pid = (double) NOT_ASSIGNED;
334  m_isObs = false;
335  m_isFilt = false;
336  m_isSing = false;
337 
338  if (m_seqfeat.IsSetExcept()) {
339  m_isFilt = !(m_seqfeat.GetExcept());
340  }
341 
342  if (m_seqfeat.IsSetExt()) {
343 
344  int intType = m_seqfeat.GetExt().GetType().GetId();
346  switch (intType) {
347  case 1:
349  break;
350  case 2:
352  break;
353  case 3:
355  break;
356  case 6:
358  break;
359  case 7:
361  break;
362  case 8:
364  break;
365  case 12:
367  break;
368  default:
369  WARNINGMSG("IBIS feature data with unexpected type " << intType);
370  break;
371  };
372 
373  const CSeq_feat::TExt::TData& userObjectData = m_seqfeat.GetExt().GetData();
374  CSeq_feat::TExt::TData::const_iterator uoCit = userObjectData.begin();
375  CSeq_feat::TExt::TData::const_iterator uoEnd = userObjectData.end();
376  for (; uoCit != uoEnd; ++uoCit) {
377 
378  if ((*uoCit)->GetLabel().IsStr()) {
379  label = (*uoCit)->GetLabel().GetStr();
380  } else {
381  ERRORMSG("IBIS feature data with non-string label is skipped");
382  continue;
383  }
384 
385  if ((*uoCit)->GetData().IsInt()) {
386  intValue = (*uoCit)->GetData().GetInt();
387  } else {
388  ERRORMSG("IBIS feature data with non-integral type and label '" << label << "' is skipped");
389  continue;
390  }
391 
392  if (label == "mmdbId") {
393  m_mmdbId = intValue;
394  } else if (label == "sdiId") {
395  m_sdiId = intValue;
396  } else if (label == "nMembers") {
397  m_nMembers = intValue;
398  } else if (label == "nInterfaceRes") {
399  m_nIntRes = intValue;
400  } else if (label == "nUniqueChemicals") {
401  m_nUnqChem = intValue;
402  } else if (label == "nUniqueIons") {
403  m_nUnqIons = intValue;
404  } else if (label == "comb_scr") {
405  m_score = intValue;
406  } else if (label == "avgIdent") {
407  m_pid = (double) intValue/1000000.0;
408  } else if (label == "isObserverd") {
409  m_isObs = (intValue != 0);
410  } else {
411  ERRORMSG("IBIS feature data with unexpected label '" << label << "' is skipped");
412  }
413  }
414  }
415 }
416 
417 ncbi::CRef < ncbi::objects::CAlign_annot > IBISInteraction::ToAlignAnnot(void) const
418 {
419  bool isLocOK = false;
420  string commentEvid;
421  CRef < CAlign_annot > annot(new CAlign_annot());
422  annot->SetType(IbisIntTypeToCddIntType(m_type));
423  annot->SetDescription(m_desc);
424 
425  // fill out location; isLocOK = true means it was a packed-int
426  const ncbi::objects::CSeq_loc& loc = GetLocation(isLocOK);
427  if (isLocOK) {
428  CRef< CPacked_seqint > packedInt(new CPacked_seqint());
429  packedInt->Assign(loc.GetPacked_int());
430  annot->SetLocation().SetPacked_int(*packedInt);
431 
432  // add a boilerplate comment as evidence
433  CAlign_annot::TEvidence& evidence = annot->SetEvidence();
434  CRef < CFeature_evidence > boilerplateEvidence(new CFeature_evidence());
435  if (m_queryMolecule) {
436  commentEvid = IBIS_EVIDENCE_COMMENT + " for query ";
437  commentEvid += m_queryMolecule->ToString();
438  } else {
439  commentEvid = IBIS_EVIDENCE_COMMENT + " for an unspecified query structure";
440  }
441 
443  commentEvid += " [created " + CTime(CTime::eCurrent).AsString(timeFormat) + "]";
444  boilerplateEvidence->SetComment(commentEvid);
445  evidence.push_back(boilerplateEvidence);
446 
447  // keep the IBIS id for convenience of the GUI, although it
448  // is *not* a robust identifier for this interaction and may
449  // not be valid next time the IBIS query is made.
450  /*
451  CRef < CFeature_evidence > idEvidence(new CFeature_evidence());
452  CObject_id& localFeatId = idEvidence->SetSeqfeat().SetId().SetLocal();
453  localFeatId.SetId(m_rowId);
454  evidence.push_back(idEvidence);
455  */
456 
457  } else {
458  ERRORMSG("error converting interaction '" << m_desc << "' to an annotation!");
459  annot.Reset();
460  }
461 
462  return annot;
463 }
464 
465 const ncbi::objects::CSeq_loc& IBISInteraction::GetLocation(bool& isOK) const
466 {
467  bool result = m_seqfeat.IsSetLocation();
468  if (result) {
469  if (!m_seqfeat.GetLocation().IsPacked_int()) {
470  result = false;
471  ERRORMSG("IBIS feature has unexpected location type");
472  }
473  } else {
474  ERRORMSG("could not extract IBIS feature location");
475  }
476  isOK = result;
477  return m_seqfeat.GetLocation();
478 }
479 
481 {
482  // Lazy-initialize the positions.
483  if (m_positions.empty()) {
484  bool isOK = false;
485  TSeqPos pos, from, to;
486  const CSeq_loc& location = GetLocation(isOK);
487  if (isOK && location.IsInt()) {
488  from = location.GetInt().GetFrom();
489  to = location.GetInt().GetTo();
490  for (pos = from; pos <= to; ++pos) {
491  m_positions.insert(pos);
492  }
493  } else if (isOK && location.IsPacked_int()) {
494  CPacked_seqint::Tdata::const_iterator s, se = location.GetPacked_int().Get().end();
495  for (s = location.GetPacked_int().Get().begin(); s!=se; ++s) {
496  from = (**s).GetFrom();
497  to = (**s).GetTo();
498  for (pos = from; pos <= to; ++pos) {
499  m_positions.insert(pos);
500  }
501  }
502  }
503  }
504  return m_positions;
505 }
506 
507 bool IBISInteraction::GetFootprint(int& from, int& to) const
508 {
509  bool result;
510  const CSeq_loc& seqloc = GetLocation(result);
511 
512  from = NOT_ASSIGNED;
513  to = NOT_ASSIGNED;
514  if (result) {
515  const CPacked_seqint::Tdata& intervals = seqloc.GetPacked_int().Get();
516  if (intervals.size() > 0) {
517  from = (int) intervals.front()->GetFrom();
518  to = (int) intervals.back()->GetTo();
519  } else {
520  result = false;
521  ERRORMSG("IBIS feature has no defined intervals");
522  }
523  }
524  return result;
525 }
526 
528 {
529  bool result, idsMatch;
530  const CSeq_loc& seqloc = GetLocation(result);
531 
532  gi = GI_NOT_ASSIGNED;
533  if (result) {
534  const CPacked_seqint::Tdata& intervals = seqloc.GetPacked_int().Get();
535  CPacked_seqint::Tdata::const_iterator it = intervals.begin(), itEnd = intervals.end();
536  if (it != itEnd) {
537 
538  const CSeq_id& firstId = (*it)->GetId();
539  ++it;
540 
541  // Validate that each interval has the same 'id'.
542  idsMatch = true;
543  for (; idsMatch && it != itEnd; ++it) {
544  idsMatch = firstId.Match((*it)->GetId());
545  }
546 
547  if (idsMatch) {
548  if (firstId.IsGi()) {
549  gi = firstId.GetGi();
550  } else {
551  result = false;
552  ERRORMSG("unexpected sequence identifier used for IBIS feature location (expected a GI)");
553  }
554  } else {
555  result = false;
556  ERRORMSG("inconsistent sequence ids used to give IBIS feature location");
557  }
558  } else {
559  result = false;
560  ERRORMSG("IBIS feature has no defined intervals");
561  }
562  }
563  return result;
564 }
565 
566 // end IBISInteraction methods
567 ///////////////////////////////
568 
569 
570 #define DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(var, id, type) \
571  type *var; \
572  var = wxDynamicCast(FindWindow(id), type); \
573  if (!var) { \
574  ERRORMSG("Can't find window with id " << id); \
575  return; \
576  }
577 
578 #define DECLARE_AND_FIND_WINDOW_RETURN_FALSE_ON_ERR(var, id, type) \
579  type *var; \
580  var = wxDynamicCast(FindWindow(id), type); \
581  if (!var) { \
582  ERRORMSG("Can't find window with id " << id); \
583  return false; \
584  }
585 
586 BEGIN_EVENT_TABLE(IBISAnnotateDialog, wxDialog)
587  EVT_BUTTON (-1, IBISAnnotateDialog::OnButton)
588  EVT_CHOICE (-1, IBISAnnotateDialog::OnChoice)
589  EVT_LIST_ITEM_SELECTED (-1, IBISAnnotateDialog::OnListCtrlSelection)
593 
595  wxDialog(parent, -1, "IBIS Annotations", wxPoint(400, 100), wxDefaultSize, wxDEFAULT_DIALOG_STYLE),
596  dialogHandle(handle), structureSet(set), annotSet(set->GetCDDAnnotSet()), m_images(NULL)
597 {
598  if (annotSet.Empty()) {
599  Destroy();
600  return;
601  }
602 
603  // get interaction data from IBIS
604  PopulateInteractionData();
605 
606  // construct the panel; put the query ID in the static box title.
607  wxSizer *topSizer = SetupIbisAnnotationDialog(this, false);
609  wxString buf;
610  buf.Printf("IBIS Interactions for query %s", IBISInteraction::GetQueryMolecule()->ToString().c_str());
611  try {
612  wxStaticBoxSizer* sbs = dynamic_cast<wxStaticBoxSizer*>(ibisIntStaticBoxSizer);
613  if (sbs) sbs->GetStaticBox()->SetLabel(buf);
614  } catch (...) {
615  }
616  }
617 
618 
619  // call sizer stuff
620  topSizer->Fit(this);
621  topSizer->SetSizeHints(this);
622  SetClientSize(topSizer->GetMinSize());
623 
624  // Dynamically configure the possible choices based on
625  // the available interactions. Start off with 'All' selected
626  // unless there are no interactions.
627  int choiceId;
628  DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(intTypeFilter, ID_C_TYPE, wxChoice)
629  if (vecIbisInteractions.size() > 0) {
630  if (!HasInteractionData(IBISInteraction::eIbisProteinProtein)) {
631  choiceId = intTypeFilter->FindString(wxT("Protein-Protein"));
632  if (choiceId != wxNOT_FOUND) {
633  intTypeFilter->Delete(choiceId);
634  }
635  }
636  if (!HasInteractionData(IBISInteraction::eIbisProteinDNA) &&
637  !HasInteractionData(IBISInteraction::eIbisProteinRNA) &&
638  !HasInteractionData(IBISInteraction::eIbisProteinCombo_DNA_RNA)) {
639  choiceId = intTypeFilter->FindString(wxT("Protein-NucAcid"));
640  if (choiceId != wxNOT_FOUND) {
641  intTypeFilter->Delete(choiceId);
642  }
643  }
644  if (!HasInteractionData(IBISInteraction::eIbisProteinChemical)) {
645  choiceId = intTypeFilter->FindString(wxT("Protein-Chemical"));
646  if (choiceId != wxNOT_FOUND) {
647  intTypeFilter->Delete(choiceId);
648  }
649  }
650  if (!HasInteractionData(IBISInteraction::eIbisProteinPeptide)) {
651  choiceId = intTypeFilter->FindString(wxT("Protein-Peptide"));
652  if (choiceId != wxNOT_FOUND) {
653  intTypeFilter->Delete(choiceId);
654  }
655  }
656  if (!HasInteractionData(IBISInteraction::eIbisProteinIon)) {
657  choiceId = intTypeFilter->FindString(wxT("Protein-Ion"));
658  if (choiceId != wxNOT_FOUND) {
659  intTypeFilter->Delete(choiceId);
660  }
661  }
662 
663  }
664  intTypeFilter->SetSelection(0);
665 
666 
667  // initialize the image list
668  DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(interactions, ID_LC_INT, wxListCtrl)
669  wxIcon infoIcon = wxArtProvider::GetIcon(wxART_INFORMATION); //, wxART_FRAME_ICON, wxSize(16, 16));
670  wxIcon warnIcon = wxArtProvider::GetIcon(wxART_WARNING);
671  wxIcon questionIcon = wxArtProvider::GetIcon(wxART_QUESTION);
672  wxIcon bookmarkIcon = wxArtProvider::GetIcon(wxART_ADD_BOOKMARK);
673  wxIcon tickMarkIcon = wxArtProvider::GetIcon(wxART_TICK_MARK); //, wxART_FRAME_ICON, wxSize(16, 16));
674  if (tickMarkIcon.Ok()) {
675  m_images = new wxImageList(16, 16, true);
676  /*int imageIndex =*/ m_images->Add(infoIcon);
677  m_images->Add(warnIcon);
678  m_images->Add(questionIcon);
679  m_images->Add(bookmarkIcon);
680  m_images->Add(tickMarkIcon);
681  interactions->SetImageList(m_images, wxIMAGE_LIST_SMALL);
682  }
683 
684  // initialize the column headings in the list control
685  if (interactions->GetWindowStyleFlag() & wxLC_REPORT) {
686  wxListItem itemCol;
687  itemCol.SetText(wxT("Annot Overlap?"));
688  itemCol.SetAlign(wxLIST_FORMAT_LEFT);
689  interactions->InsertColumn(0, itemCol);
690 
691  itemCol.SetText(wxT("Type"));
692  itemCol.SetAlign(wxLIST_FORMAT_LEFT);
693  interactions->InsertColumn(1, itemCol);
694 
695  itemCol.SetText(wxT("Observed?"));
696  itemCol.SetAlign(wxLIST_FORMAT_RIGHT);
697  interactions->InsertColumn(2, itemCol);
698 
699  itemCol.SetText(wxT("Filtered on Web?"));
700  itemCol.SetAlign(wxLIST_FORMAT_RIGHT);
701  interactions->InsertColumn(3, itemCol);
702 
703  itemCol.SetText(wxT("Description"));
704  itemCol.SetAlign(wxLIST_FORMAT_LEFT);
705  interactions->InsertColumn(4, itemCol);
706 
707  itemCol.SetText(wxT("# Res. on Query"));
708  itemCol.SetAlign(wxLIST_FORMAT_CENTER);
709  interactions->InsertColumn(5, itemCol);
710 
711  itemCol.SetText(wxT("Clust. Size"));
712  itemCol.SetAlign(wxLIST_FORMAT_CENTER);
713  interactions->InsertColumn(6, itemCol);
714 
715  itemCol.SetText(wxT("Avg. Clust. %Id"));
716  itemCol.SetAlign(wxLIST_FORMAT_CENTER);
717  interactions->InsertColumn(7, itemCol);
718 
719  itemCol.SetText(wxT("IBIS Score"));
720  itemCol.SetAlign(wxLIST_FORMAT_CENTER);
721  interactions->InsertColumn(8, itemCol);
722  }
723 
724 
725  // set initial GUI state, with no selections
726  SetupGUIControls(-1, -1);
727 }
728 
729 
731 {
732  delete m_images;
733 
734  // reset the query sequence and molecule to NULL
736 
737  // so owner knows that this dialog has been destroyed
739  TRACEMSG("destroyed IBISAnnotateDialog");
740 }
741 
742 void IBISAnnotateDialog::OnCloseWindow(wxCloseEvent& event)
743 {
744  Destroy();
745 }
746 
747 // Returns -1 if there are no selected items
748 // (instead of this method, can use wxListCtrl::GetSelectedItemCount()
749 // directly to test if a selection exists)
750 long GetFirstSelectedListCtrlItemId(const wxListCtrl& listCtrl)
751 {
752  return listCtrl.GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
753 }
754 
755 // Returns the number of selections, and the selected ids.
756 // Needed only if the listCtrl allows multiple selections.
757 unsigned int GetAllSelectedListCtrlItemIds(const wxListCtrl& listCtrl, vector<long>& ids)
758 {
759  long item = listCtrl.GetNextItem(-1, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
760 
761  ids.clear();
762  while ( item != -1 ) {
763  ids.push_back(item);
764  item = listCtrl.GetNextItem(item, wxLIST_NEXT_ALL, wxLIST_STATE_SELECTED);
765  }
766  return ids.size();
767 }
768 
769 /* Conventions/formatting of ibis.cgi calls:
770 
771 https://www.ncbi.nlm.nih.gov/Structure/ibis/ibis.cgi?sqat&range=1,332&mmdbid=51257&molid=1&asc=1&web=1
772 
773 Arguments:
774 sqat: trigger output SeqAnnot Asn1 data
775 range: residue range from, to (requires ones-based positions)
776 mmdbid: query Mmdb Id
777 molid: molecule Id, (default value: 1) ** no general mapping to Chain ID of the structure!!! **
778 asc: ascii output (default is binary)
779 web: for web display (default is text output without web content header)
780 
781 If no interaction found, the cgi should return a SeqAnnot with an
782 empty ftable:
783 
784 Seq-annot ::= {
785  data ftable {
786  }
787 }
788 */
789 typedef struct {
790  int mmdbId;
791  int molId; // warning: molId doesn't map easily onto pdb chain code (e.g., 1rzr, molId=1 --> chain G)
792  TSeqPos from, to;
793  string pdb;
794 } IbisQuery;
795 
797 {
798  bool result = false;
799 
800  if (query.from > query.to) {
801  ERRORMSG("Error calling ibis.cgi: from (" << query.from << ") > to (" << query.to << ").");
802  return result;
803  } else if (query.mmdbId == MoleculeIdentifier::VALUE_NOT_SET) {
804  ERRORMSG("Error calling ibis.cgi: mmdbId not set.");
805  return result;
806  } else if (query.molId == MoleculeIdentifier::VALUE_NOT_SET) {
807  ERRORMSG("Error calling ibis.cgi: molId not set..");
808  return result;
809  }
810 
811  // set up URL
812  string args, err,
813  host = "www.ncbi.nlm.nih.gov",
814  path = "/Structure/ibis/ibis.cgi";
815  CNcbiOstrstream argstr;
816  argstr << "sqat&range=" << (query.from+1) << ',' << (query.to+1) << "&mmdbid=" << query.mmdbId
817  << "&molid=" << query.molId
818  << "&asc=1&web=1";
819  args = (string) CNcbiOstrstreamToString(argstr);
820 
821  // connect to ibis.cgi
822  // 1) try to get interaction data using the mmdb-id; if the mmdb-id is obsolete,
823  // ibis.cgi will return an empty seq-annot.
824  // 2) in case of empty seq-annot, re-query with the pdb accession
825  // [the second query corresponds to the *current* mmdb-id for that pdb, and
826  // runs the risk that the returned interactions are mapped onto an updated
827  // version of the sequence, not the sequence referenced by the mmdb-id in the CD].
828  INFOMSG("try to load IBIS alignment data by mmdb-id from " << host << path << '?' << args);
829  result = GetAsnDataViaHTTPS(host, path, args, &ibisSeqAnnot, &err, false);
830  if (!result) {
831  ERRORMSG("Error getting interaction data from ibis.cgi:\n" << err);
832  } else {
833  if (!ibisSeqAnnot.GetData().IsFtable() || ibisSeqAnnot.GetData().GetFtable().empty()) {
834  ibisSeqAnnot.Reset();
835  if (query.pdb.length() > 0) {
836 
837  CNcbiOstrstream argstrPdb;
838  argstrPdb << "sqat&range=" << (query.from+1) << ',' << (query.to+1) << "&search=" << query.pdb
839  << "&asc=1&web=1";
840  args = (string) CNcbiOstrstreamToString(argstrPdb);
841 
842  INFOMSG("try to load IBIS alignment data by pdb accession from " << host << path << '?' << args);
843  err.erase();
844  result = GetAsnDataViaHTTPS(host, path, args, &ibisSeqAnnot, &err, false);
845  if (!result) {
846  ERRORMSG("Error getting interaction data by pdb accession from ibis.cgi:\n" << err);
847  } else {
848  if (!ibisSeqAnnot.GetData().IsFtable() || ibisSeqAnnot.GetData().GetFtable().empty()) {
849  ibisSeqAnnot.Reset();
850  INFOMSG(" ibis.cgi has no interaction data for MMDB-ID " << query.mmdbId << ", molecule " << query.molId << " or PDB accession " << query.pdb);
851  } else {
852  INFOMSG(" successfully loaded interaction data from ibis.cgi for PDB accession " << query.pdb);
853  }
854  }
855  } else {
856  INFOMSG(" ibis.cgi has no interaction data for MMDB-ID " << query.mmdbId << ", molecule " << query.molId << " (no known PDB accession)");
857  }
858  } else {
859  INFOMSG(" successfully loaded interaction data from ibis.cgi for MMDB-ID " << query.mmdbId);
860  }
861  }
862 /*
863 #ifdef _DEBUG
864  WriteASNToFile("ibisannot.dat.txt", ibisSeqAnnot, false, &err);
865 #endif
866 */
867  return result;
868 }
869 
870 
872 {
874 
875  // get Sequence object for master, and pull info out of MoleculeIdentifier
877  const Sequence *master = alignment->GetMaster();
878 
879  vecIbisInteractions.clear();
880  if (master->identifier && master->identifier->HasStructure()) {
881 
882  ncbi::CRef< ncbi::objects::CSeq_annot > ibisInteractions(new CSeq_annot);
883  if (ibisInteractions.NotEmpty()) {
884 
885  // Set the static query variables in the IBISInteraction class
887 
888  query.mmdbId = master->identifier->mmdbID;
889  query.molId = master->identifier->moleculeID;
890 
891  query.pdb = kEmptyStr;
892  if (master->identifier->pdbID.size() > 0) {
893  query.pdb = master->identifier->pdbID;
894  if (IBISInteraction::QueryMoleculeHasChain()) {//master->identifier->pdbChain != MoleculeIdentifier::VALUE_NOT_SET && master->identifier->pdbChain != ' ')
895  query.pdb += master->identifier->pdbChain;
896  }
897  }
898 
899  // find first aligned residue
900  query.from = 0;
901  while (query.from < master->Length() && !alignment->IsAligned(0U, query.from))
902  ++query.from;
903 
904  // find last aligned residue
905  query.to = master->Length() -1;
906  while (query.to >= query.from && !alignment->IsAligned(0U, query.to))
907  --query.to;
908 
909  // no extra message; errors are posted from inside the function.
910  if (!GetInteractionDataFromIbis(*ibisInteractions, query)) {
911  ibisInteractions.Reset();
912  } else if (ibisInteractions.NotEmpty()&& ibisInteractions->GetData().IsFtable() && (ibisInteractions->GetData().GetFtable().size() > 0)) {
913 
914  const CSeq_annot::TData::TFtable& seqfeats = ibisInteractions->GetData().GetFtable();
915  CSeq_annot::TData::TFtable::const_iterator fit = seqfeats.begin(), fend = seqfeats.end();
916  for (; fit != fend; ++fit) {
917  if (fit->NotEmpty()) {
918  CRef< IBISInteraction > ibisInt(new IBISInteraction(**fit));
919  vecIbisInteractions.push_back(ibisInt);
920  }
921  }
922 
923  }
924  } else {
925  ERRORMSG("Error: allocation failure before trying to contact ibis.cgi.");
926  }
927  }
928 
929 }
930 
932 {
933  return (vecIbisInteractions.size() > 0);
934 }
935 
937 {
938  bool result = false;
939  unsigned int num = vecIbisInteractions.size();
940  for (unsigned i = 0; i < num && !result; ++i) {
941  if (vecIbisInteractions[i]->GetType() == type) {
942  result = true;
943  }
944  }
945  return result;
946 }
947 
948 unsigned int IBISAnnotateDialog::GetIntervalsForSet(const SeqPosSet& positions, IntervalList& intervals)
949 {
950  intervals.clear();
951  if (positions.size() == 0) return 0;
952 
954  SeqPosSet::const_iterator pcit = positions.begin(), pend = positions.end();
955  TSeqPos first = *pcit;
956  TSeqPos last = first;
957 
958  while (pcit != pend) {
959  ++pcit;
960  // find last in contiguous stretch
961  if (pcit != pend && (*pcit == last + 1)) {
962  ++last;
963  } else {
964  // create Seq-interval
965  CRef < CSeq_interval > interval(new CSeq_interval());
966  interval->SetFrom(first);
967  interval->SetTo(last);
968  master->FillOutSeqId(&(interval->SetId()));
969  intervals.push_back(interval);
970  if (pcit != pend) {
971  first = *pcit;
972  last = first;
973  }
974  }
975 
976  }
977  return positions.size();
978 }
979 
980 
981 void IBISAnnotateDialog::OnButton(wxCommandEvent& event)
982 {
983  int eventId = event.GetId();
984  switch (eventId) {
985 
986  // IBIS interaction buttons
987  case ID_B_ADD_INT:
989  break;
990  case ID_B_HIGHLIGHT_INT:
992  break;
993  case ID_B_LAUNCH_INT:
995  break;
996 
997  // annotation buttons
998  case ID_B_DELETE_ANNOT:
1000  break;
1001  case ID_B_HIGHLIGHT_ANNOT:
1002  case ID_B_HIGHLIGHT_OLAP:
1005  HighlightAnnotation(eventId);
1006  break;
1007  default:
1008  event.Skip();
1009  }
1010 }
1011 
1012 void IBISAnnotateDialog::OnChoice(wxCommandEvent& event)
1013 {
1014  DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(interactions, ID_LC_INT, wxListCtrl)
1016 
1017  long item = GetFirstSelectedListCtrlItemId(*interactions);
1018 
1019  SetupGUIControls((int) item, annots->GetSelection());
1021 }
1022 
1024 {
1025  DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(interactions, ID_LC_INT, wxListCtrl)
1027 
1028  wxString eventText = event.GetText();
1029  //long eventData = event.GetData();
1030  //const wxListItem& eventItem = event.GetItem();
1031 
1032  SetupGUIControls(event.GetIndex(), annots->GetSelection(), eRemakeListBox);
1034 }
1035 void IBISAnnotateDialog::OnListBoxSelection(wxCommandEvent& event)
1036 {
1037  DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(interactions, ID_LC_INT, wxListCtrl)
1039 
1040  int intSel = GetFirstSelectedListCtrlItemId(*interactions);
1041  SetupGUIControls(intSel, annots->GetSelection(), eDontRemakeControls);
1043 }
1044 
1045 void InsertItemInListView(int vecIndex, const CRef<IBISInteraction>& ibisInt, wxListCtrl& listCtrl)
1046 {
1047  if (ibisInt.Empty()) return;
1048 
1049  long itemIndex;
1050  wxString buf;
1051  buf.Printf(wxT("(%d) %s [%d in cluster (%4.1f %%id); %d residues]"), (int) ibisInt->GetType(),
1052  ibisInt->GetDesc().c_str(), ibisInt->GetNumMembers(), ibisInt->GetAverageIdentity(), ibisInt->GetNumInterfaceResidues());
1053  itemIndex = listCtrl.InsertItem(vecIndex, buf, -1);
1054  if (itemIndex >= 0) {
1055  listCtrl.SetItemData(itemIndex, vecIndex);
1056  }
1057 }
1058 
1059 void InsertItemInReportView(int vecIndex, const CRef<IBISInteraction>& ibisInt, wxListCtrl& listCtrl)
1060 {
1061  if (ibisInt.Empty()) return;
1062 
1063  // column order: annotOverlap/IBIStype/observed/filtered/descr/# res/clust size/avg ident/score
1064 
1065  wxString buf;
1066  buf.Printf(wxT("%s "), IBISInteraction::IbisIntTypeToString(ibisInt->GetType()).c_str());
1067 
1068  long itemIndex = listCtrl.InsertItem(vecIndex, "", -1);
1069  if (itemIndex >= 0) {
1070  listCtrl.SetItemData(itemIndex, vecIndex);
1071 
1072  listCtrl.SetItem(itemIndex, 1, buf, -1);
1073 
1074  if (ibisInt->IsObserved()) {
1075  listCtrl.SetItem(itemIndex, 2, "", 3);
1076  }
1077  if (ibisInt->IsFiltered()) {
1078  listCtrl.SetItem(itemIndex, 3, "", 2);
1079  }
1080 
1081  buf.Printf(wxT("%s"), ibisInt->GetDesc().c_str());
1082  listCtrl.SetItem(itemIndex, 4, buf);
1083 
1084  // GetNumInterfaceResidues() refers to all residues in the
1085  // IBIS-defined interaction that the query hit.
1086  // GetPositions.size() gets the number of interface residues that
1087  // were found to overlap the query and are in the Seq-loc.
1088  // GetPositions.size() <= GetNumInterfaceResidues()
1089 // buf.Printf(wxT("%d"), ibisInt->GetNumInterfaceResidues());
1090  buf.Printf(wxT("%d"), (int) ibisInt->GetPositions().size());
1091  listCtrl.SetItem(itemIndex, 5, buf);
1092 
1093  buf.Printf(wxT("%d"), ibisInt->GetNumMembers());
1094  listCtrl.SetItem(itemIndex, 6, buf);
1095  buf.Printf(wxT("%4.1f"), ibisInt->GetAverageIdentity());
1096  listCtrl.SetItem(itemIndex, 7, buf);
1097  if (ibisInt->GetScore() != IBISInteraction::NOT_ASSIGNED) {
1098  buf.Printf(wxT("%4.1f"), (double) ibisInt->GetScore()/10000.0);
1099  } else {
1100  buf = wxT("n/a");
1101  }
1102  listCtrl.SetItem(itemIndex, 8, buf);
1103  }
1104 }
1105 
1106 bool DoesInteractionMatchChoice(const wxString& choiceStr, IBISInteraction::eIbisInteractionType ibisIntType)
1107 {
1108  bool result = false;
1109  if (choiceStr == wxT("All")) {
1110  result = (ibisIntType != IBISInteraction::eIbisNoTypeAssigned &&
1111  ibisIntType != IBISInteraction::eIbisOther);
1112  } else if (choiceStr.Contains(wxT("Protein-Protein"))) {
1113  result = (ibisIntType == IBISInteraction::eIbisProteinProtein);
1114  } else if (choiceStr.Contains(wxT("Protein-NucAcid"))) {
1115  result = ((ibisIntType == IBISInteraction::eIbisProteinDNA) ||
1116  (ibisIntType == IBISInteraction::eIbisProteinRNA) ||
1118  } else if (choiceStr.Contains(wxT("Protein-Chemical"))) {
1119  result = (ibisIntType == IBISInteraction::eIbisProteinChemical);
1120  } else if (choiceStr.Contains(wxT("Protein-Peptide"))) {
1121  result = (ibisIntType == IBISInteraction::eIbisProteinPeptide);
1122  } else if (choiceStr.Contains(wxT("Protein-Ion"))) {
1123  result = (ibisIntType == IBISInteraction::eIbisProteinIon);
1124  }
1125  return result;
1126 }
1127 
1128 void GetPositionsForAlignAnnot(const CAlign_annot& annot, SeqPosSet& positions, bool zeroBased)
1129 {
1130  positions.clear();
1131 
1132  TSeqPos offset, pos, from, to;
1133  const CSeq_loc& annotSeqLoc = annot.GetLocation();
1134  CPacked_seqint::Tdata::const_iterator s, se;
1135 
1136  offset = (zeroBased) ? 0 : 1;
1137 
1138  if (annotSeqLoc.IsInt()) {
1139  from = annotSeqLoc.GetInt().GetFrom() + offset;
1140  to = annotSeqLoc.GetInt().GetTo() + offset;
1141  for (pos = from; pos <= to; ++pos) {
1142  positions.insert(pos);
1143  }
1144  } else if (annotSeqLoc.IsPacked_int()) {
1145  se = annotSeqLoc.GetPacked_int().Get().end();
1146  for (s = annotSeqLoc.GetPacked_int().Get().begin(); s!=se; ++s) {
1147  from = (**s).GetFrom() + offset;
1148  to = (**s).GetTo() + offset;
1149  for (pos = from; pos <= to; ++pos) {
1150  positions.insert(pos);
1151  }
1152  }
1153  }
1154 
1155 }
1156 
1157 static unsigned int GetSetIntersection(const SeqPosSet& set1, const SeqPosSet& set2, SeqPosSet& intersection)
1158 {
1159  intersection.clear();
1160  if (set1.empty() || set2.empty()) return 0;
1161 
1162  set_intersection(set1.begin(), set1.end(),
1163  set2.begin(), set2.end(),
1164  inserter(intersection, intersection.begin()));
1165 
1166  return intersection.size();
1167 }
1168 
1170 {
1171  unsigned int i;
1172  unsigned int nInteractions = vecIbisInteractions.size();
1173  if (nInteractions == 0) return;
1174 
1175  SeqPosSet annotPositions, overlapPositions;
1176  AlignAnnotInfo annotInfo;
1177  vector< SeqPosSet >& overlaps = annotInfo.overlaps;
1178  CAlign_annot_set::Tdata::const_iterator a, ae = annotSet->Get().end();
1179 
1180  aioMap.clear();
1181  overlaps.resize(nInteractions);
1182  for (a=annotSet->Get().begin(); a!=ae; ++a) {
1183 
1184  annotInfo.ptr = (void *) a->GetPointer();
1185 
1186  annotPositions.clear();
1187  if (a->NotEmpty()) {
1188  GetPositionsForAlignAnnot(**a, annotPositions, true);
1189  }
1190  annotInfo.nRes = annotPositions.size();
1191 
1192  for (i = 0; i < nInteractions; ++i) {
1193  const SeqPosSet& interactionPositions = vecIbisInteractions[i]->GetPositions();
1194  GetSetIntersection(interactionPositions, annotPositions, overlapPositions);
1195  overlaps[i] = overlapPositions;
1196  }
1197 
1198  aioMap.insert(AnnotIbisOverlapMap::value_type((unsigned long) annotInfo.ptr, annotInfo));
1199  }
1200 }
1201 
1202 void IBISAnnotateDialog::GetAnnotIbisOverlaps(const IBISInteraction& interaction, const CAlign_annot& annot, SeqPosSet& overlaps) const
1203 {
1204  SeqPosSet annotPositions;
1205  const SeqPosSet& interactionPositions = interaction.GetPositions();
1206 
1207  overlaps.clear();
1208  GetPositionsForAlignAnnot(annot, annotPositions, true);
1209  GetSetIntersection(interactionPositions, annotPositions, overlaps);
1210 }
1211 
1212 void IBISAnnotateDialog::GetAnnotIbisNonOverlaps(const IBISInteraction& interaction, const CAlign_annot& annot, SeqPosSet& nonOverlaps, bool onAnnotation) const
1213 {
1214  SeqPosSet annotPositions, annotPositionOverlaps;
1215  SeqPosSet::iterator setIt, setEnd;
1216  const SeqPosSet& interactionPositions = interaction.GetPositions();
1217 
1218  nonOverlaps.clear();
1219  GetPositionsForAlignAnnot(annot, annotPositions, true);
1220  GetSetIntersection(interactionPositions, annotPositions, annotPositionOverlaps);
1221 
1222  // Now, find those positions in the appropriate set not in 'annotPositionOverlaps'
1223  if (onAnnotation) {
1224  nonOverlaps.insert(annotPositions.begin(), annotPositions.end());
1225  } else {
1226  nonOverlaps.insert(interactionPositions.begin(), interactionPositions.end());
1227  }
1228 
1229  setEnd = annotPositionOverlaps.end();
1230  for (setIt = annotPositionOverlaps.begin(); setIt != setEnd; ++setIt) {
1231  nonOverlaps.erase(*setIt);
1232  }
1233 }
1234 
1235 void IBISAnnotateDialog::SetupGUIControls(int selectInteraction, int selectAnnot, unsigned int updateFlags)
1236 {
1237  static const double overlapThreshold = 99.0;
1238 
1239  // get GUI control pointers
1240  DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(intTypeFilter, ID_C_TYPE, wxChoice)
1241 
1242  DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(interactions, ID_LC_INT, wxListCtrl)
1246 
1253 
1254  bool readOnly, isIbisAnnot, isFullInteractionAnnotated;
1255  double overlapPercentage;
1256  unsigned int i, ibisIndex, nInteractions, nItems, nOverlaps, nRes, nResIntn;
1257  int selectedVecIndex = -1;
1258 
1259  CAlign_annot *annotPtr = NULL;
1260  //IBISInteraction::eIbisInteractionType ibisType = IBISInteraction::eIbisOther;
1261  wxString annotDescStr, choiceSelectionStr;
1262  set<unsigned int> ibisIndexWithOverlap;
1263  set<unsigned int>::iterator ibisIndexEnd;
1264  AnnotIbisOverlapMap overlapMap;
1265  AnnotIbisOverlapMap::iterator olapIt, olapEnd;
1266 
1267  nInteractions = vecIbisInteractions.size();
1268  choiceSelectionStr = intTypeFilter->GetStringSelection();
1269 
1270  // Find out which user annotations overlap IBIS interactions,
1271  // and which of of the IBIS interactions overlap some user annotation.
1272  GetAnnotIbisOverlaps(overlapMap);
1273  olapEnd = overlapMap.end();
1274  for (olapIt = overlapMap.begin(); olapIt != olapEnd; ++olapIt) {
1275 
1276  if (olapIt->second.nRes == 0) continue;
1277 
1278  vector< SeqPosSet >& olaps = olapIt->second.overlaps;
1279  for (i = 0; i < olaps.size(); ++i) {
1280  if (olaps[i].size() > 0) {
1281  ibisIndexWithOverlap.insert(i);
1282  }
1283  }
1284  }
1285  ibisIndexEnd = ibisIndexWithOverlap.end();
1286 
1287  // Don't select 'selectInteraction' unless it matches the choice selection;
1288  // since item index need not equal the vector index, get the selected vector index.
1289  if (selectInteraction >= 0) {
1290  selectedVecIndex = interactions->GetItemData(selectInteraction);
1291  if (selectedVecIndex < 0 || selectedVecIndex >= (int) nInteractions) {
1292  selectedVecIndex = -1;
1293  selectInteraction = -1;
1294  } else if (!DoesInteractionMatchChoice(choiceSelectionStr, vecIbisInteractions[selectedVecIndex]->GetType())) {
1295  selectedVecIndex = -1;
1296  selectInteraction = -1;
1297  }
1298  }
1299 
1300  // If remaking a control, a select index into it may be obsolete so reset it.
1301  if (updateFlags & eRemakeListCtrl) {
1302  selectInteraction = -1;
1303  selectAnnot = -1;
1304  } else if (updateFlags & eRemakeListBox) {
1305  selectAnnot = -1;
1306  }
1307 
1308  // If there's no selected interaction, there will be no selected annotation.
1309  nResIntn = 0;
1310  if (selectedVecIndex < 0) {
1311  selectAnnot = -1;
1312  } else {
1313  nResIntn = vecIbisInteractions[selectedVecIndex]->GetPositions().size();
1314  }
1315 
1316  //
1317  // Setup the wxListCtrl to display the possibly-filtered interactions.
1318  //
1319 
1320  interactions->Hide();
1321 
1322  if (updateFlags & eRemakeListCtrl) {
1323  interactions->DeleteAllItems(); // columns are retained
1324  if (interactions->GetWindowStyleFlag() & wxLC_LIST) {
1325  for (i = 0; i < nInteractions; ++i) {
1326  if (DoesInteractionMatchChoice(choiceSelectionStr, vecIbisInteractions[i]->GetType())) {
1327  InsertItemInListView(i, vecIbisInteractions[i], *interactions);
1328  }
1329  }
1330  } else if (interactions->GetWindowStyleFlag() & wxLC_REPORT) {
1331 
1332  for (i = 0; i < nInteractions; ++i) {
1333  if (DoesInteractionMatchChoice(choiceSelectionStr, vecIbisInteractions[i]->GetType())) {
1334  InsertItemInReportView(i, vecIbisInteractions[i], *interactions);
1335  }
1336  }
1337  }
1338 
1339  // *** using SetItemState generates a selection event
1340  // so be careful about remaking the viewer and then select
1341  // an item in this method due to event recursion possible
1342  // w/ OnListCtrlSelection
1343  // ***
1344  // To set the selection after remaking the list control, need to
1345  // find which new item index corresponds to the selectedVecIndex.
1346  if (selectedVecIndex >= 0) {
1347  this->SetEvtHandlerEnabled(false);
1348  nItems = interactions->GetItemCount();
1349  for (i = 0; i < nItems; ++i) {
1350  if ((int) interactions->GetItemData(i) == selectedVecIndex) {
1351  selectInteraction = i;
1352  interactions->SetItemState(i, wxLIST_STATE_SELECTED, wxLIST_STATE_SELECTED);
1353  break;
1354  }
1355  }
1356  this->SetEvtHandlerEnabled(true);
1357  }
1358  }
1359 
1360  // Turn on image for images with overlapping annotations.
1361  nItems = interactions->GetItemCount();
1362  for (i = 0; i < nItems; ++i) {
1363  ibisIndex = (unsigned int) interactions->GetItemData(i);
1364  if (ibisIndexWithOverlap.find(ibisIndex) != ibisIndexEnd) {
1365  interactions->SetItemImage(i, 4);
1366  }
1367  }
1368 
1369  for (i = 0; i < (unsigned int) interactions->GetColumnCount(); ++i) {
1370  if (i <= 4) {
1371  interactions->SetColumnWidth(i, wxLIST_AUTOSIZE); // type/annotOverlap/observed/filtered/description
1372  } else {
1373  interactions->SetColumnWidth(i, wxLIST_AUTOSIZE_USEHEADER);
1374  }
1375  }
1376 
1377  interactions->Show();
1378 
1379  if (selectInteraction >= 0) {
1380  interactions->EnsureVisible(selectInteraction);
1381  }
1382 
1383  //
1384  // Set up wxListBox with only those annotations that overlap IBIS selection
1385  //
1386 
1387  isFullInteractionAnnotated = false;
1388  if (updateFlags & eRemakeListBox || selectedVecIndex < 0)
1389  annots->Clear();
1390 
1391  if (selectedVecIndex >= 0 && (ibisIndexWithOverlap.find(selectedVecIndex) != ibisIndexEnd)) {
1392 
1393  for (olapIt = overlapMap.begin(); olapIt != olapEnd; ++olapIt) {
1394  nOverlaps = olapIt->second.overlaps[selectedVecIndex].size();
1395  nRes = olapIt->second.nRes;
1396  annotPtr = reinterpret_cast<CAlign_annot*>(olapIt->second.ptr);
1397  if (nOverlaps > 0 && annotPtr) {
1398 
1399  overlapPercentage = (nRes > 0) ? (100.0*nOverlaps)/((double) nRes) : 0.0;
1400  isFullInteractionAnnotated = (overlapPercentage >= overlapThreshold);
1401 
1402  if (updateFlags & eRemakeListBox) {
1403  if (annotPtr->IsSetDescription()) {
1404  annotDescStr.Printf("%s (%d residues; %4.1f%% are overlapped)", annotPtr->GetDescription().c_str(), nRes, overlapPercentage);
1405  } else {
1406  annotDescStr.Printf("<no description> (%d residues; %4.1f%% are overlapped)", nRes, overlapPercentage);
1407  }
1408  annots->Append(annotDescStr, olapIt->second.ptr);
1409  }
1410  }
1411  }
1412  }
1413 
1414  if (annots->GetCount() == 0) {
1415  selectAnnot = -1;
1416  }
1417 
1418  nOverlaps = 0;
1419  nRes = 0; // number of residues in selected annotation
1420  isIbisAnnot = false;
1421  if (selectAnnot >= 0) {
1422  annots->SetSelection(selectAnnot);
1423  annotPtr = reinterpret_cast<CAlign_annot*>(annots->GetClientData(selectAnnot));
1424  if (annotPtr) {
1425  isIbisAnnot = annotPtr->IsSetType();
1426  olapIt = overlapMap.find((unsigned long) annotPtr);
1427  if (selectedVecIndex >= 0 && olapIt != olapEnd) {
1428  nOverlaps = olapIt->second.overlaps[selectedVecIndex].size();
1429  nRes = olapIt->second.nRes;
1430  }
1431  }
1432  } else
1433  annots->SetSelection(wxNOT_FOUND);
1434 
1435  /* probably not required
1436  if (annots->GetCount() > 0) {
1437  annotPtr = reinterpret_cast<CAlign_annot*>(annots->GetClientData(annots->GetSelection()));
1438  annots->SetFirstItem(pos);
1439  }
1440  */
1441 
1442  // set button states
1444 
1445  bAddInt->Enable(selectInteraction >= 0 && !isFullInteractionAnnotated && !readOnly);
1446  bLaunchInt->Enable(selectInteraction >= 0);
1447  bHighlightInt->Enable(selectInteraction >= 0);
1448 
1449  bDelAnnot->Enable(selectAnnot >= 0 && isIbisAnnot && !readOnly);
1450  bHighlightAnnot->Enable(selectAnnot >= 0);
1451  bHighlightOlap->Enable(selectAnnot >= 0 && nOverlaps > 0 && (nOverlaps < nRes));
1452 
1453  // enable only if there are residues not overlapped in the annotation/interaction
1454  bHighlightNoOlapA->Enable(selectAnnot >= 0 && nRes > 0 && (nOverlaps < nRes));
1455  bHighlightNoOlapI->Enable(selectAnnot >= 0 && nResIntn > 0 && (nOverlaps < nResIntn));
1456 
1457  interactions->SetFocus();
1458 }
1459 
1461 {
1462  DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(interactions, ID_LC_INT, wxListCtrl)
1463 
1464  bool launchGeneralUrl = false;
1465  long selectedItem = GetFirstSelectedListCtrlItemId(*interactions);
1466  wxString url, pdbQuery;
1467 
1468  // get selected interaction
1469  int index = interactions->GetItemData(selectedItem);
1470  if (index < 0 || index >= (int) vecIbisInteractions.size()) {
1471  ERRORMSG("IBISAnnotateDialog::LaunchIbisWebPage() - error getting IBIS interaction with index " << index);
1472  return;
1473  }
1474 
1475  const CRef<IBISInteraction>& ibisInt = vecIbisInteractions[index];
1476 
1477  // if only want a general page for a given pdb id:
1478  // https://www.ncbi.nlm.nih.gov/Structure/ibis/ibis.cgi?search=1y7oa
1479  //
1480  // but to open a page on the exact selected interaction, use something like this:
1481  // https://www.ncbi.nlm.nih.gov/Structure/ibis/ibis.cgi?id=131080&type=7&rowid=116103
1482 
1483  if (ibisInt.NotEmpty()) {
1484 
1485  // If we can't build a specific URL for the selected interaction, open the general page.
1486  if (ibisInt->GetType() == IBISInteraction::eIbisOther || ibisInt->GetType() == IBISInteraction::eIbisNoTypeAssigned) {
1487  launchGeneralUrl = true;
1488  } else if (ibisInt->GetSdiId() == IBISInteraction::NOT_ASSIGNED || ibisInt->GetRowId() == IBISInteraction::NOT_ASSIGNED) {
1489  launchGeneralUrl = true;
1490  }
1491 
1492  if (launchGeneralUrl) {
1495  pdbQuery.Printf("%s%s", IBISInteraction::GetQueryMolecule()->pdbID.c_str(), IBISInteraction::GetQueryMolecule()->pdbChain.c_str());
1496  } else {
1497  pdbQuery.Printf("%s", IBISInteraction::GetQueryMolecule()->pdbID.c_str());
1498  }
1499  url.Printf("https://www.ncbi.nlm.nih.gov/Structure/ibis/ibis.cgi?search=%s", pdbQuery.c_str());
1500  }
1501  } else {
1502  url.Printf("https://www.ncbi.nlm.nih.gov/Structure/ibis/ibis.cgi?id=%d&type=%d&rowid=%d", ibisInt->GetSdiId(), (int) ibisInt->GetType(), ibisInt->GetRowId());
1503  }
1504  }
1505 
1506  if (url.length() > 0) {
1507  LaunchWebPage(url.c_str());
1508  } else {
1509  ERRORMSG("IBISAnnotateDialog::LaunchIbisWebPage() - problem building URL for IBIS interaction with index " << index);
1510  }
1511 }
1512 
1514 {
1515  DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(interactions, ID_LC_INT, wxListCtrl)
1516 
1517  bool okay = true, isLocationOK = false;
1518  long selectedItem = GetFirstSelectedListCtrlItemId(*interactions);
1519 
1520  // If there are no interactions, leave any existing highlighting.
1521  // If interactions exist, clear any existing highlighting to avoid
1522  // confusion that it may belong to some interaction in the list.
1523  if (interactions->GetItemCount() == 0) {
1524  return;
1525  } else if (selectedItem < 0) {
1527  return;
1528  }
1529 
1530  // get selection
1531  int index = interactions->GetItemData(selectedItem);
1532  if (index < 0 || index >= (int) vecIbisInteractions.size()) {
1533  ERRORMSG("IBISAnnotateDialog::HighlightAnnotation() - error getting IBIS interaction with index " << index);
1534  return;
1535  }
1536 
1537  const CRef<IBISInteraction>& ibisInt = vecIbisInteractions[index];
1538  const CSeq_loc& location = ibisInt->GetLocation(isLocationOK);
1539 
1540  // if isLocationOK is true, 'location' will be of packed-int type.
1541  if (isLocationOK) {
1542 
1543  // highlight annotation's intervals
1545  if (location.IsInt()) {
1546  okay = HighlightInterval(location.GetInt());
1547  } else if (location.IsPacked_int()) {
1548  CPacked_seqint::Tdata::const_iterator s,
1549  se = location.GetPacked_int().Get().end();
1550  for (s=location.GetPacked_int().Get().begin(); s!=se; ++s) {
1551  if (!HighlightInterval(**s))
1552  okay = false;
1553  }
1554  }
1555 
1556  // No way to tell if HighlightInterval failed due to out-of-range or seqid mismatch
1557  if (!okay) {
1558  wxMessageBox("This interaction specifies master residues outside the aligned blocks;"
1559  " see the message log for details.", "IBIS Annotation Warning",
1560  wxOK | wxCENTRE | wxICON_WARNING, this);
1561  }
1562  }
1563 
1564 }
1565 
1567 {
1568  DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(interactions, ID_LC_INT, wxListCtrl)
1570 
1571  // to start, ignore highlights and just use the location
1572  // found in the interaction object
1573 /*
1574  IntervalList intervals;
1575  GetCurrentHighlightedIntervals(&intervals);
1576  if (intervals.size() == 0) {
1577  ERRORMSG("No aligned+highlighted master residues!");
1578  return;
1579  }
1580  */
1581 
1582  long itemId = GetFirstSelectedListCtrlItemId(*interactions);
1583  if (itemId == -1) return;
1584 
1585  // get description from user
1586  CRef< IBISInteraction >& selectedInt = vecIbisInteractions[interactions->GetItemData(itemId)];
1587  wxString defText = selectedInt->GetDesc().c_str(); //interactions->GetItemText(itemId);
1588  wxString descr = wxGetTextFromUser(
1589  "Enter a description for the new annotation:", "Description", defText);
1590  if (descr.size() == 0) return;
1591 
1592  // create a new annotation
1593  CRef< CAlign_annot > annot(new CAlign_annot());
1594  annot = selectedInt->ToAlignAnnot();
1595  annot->SetDescription(WX_TO_STD(descr));
1596 
1597  // fill out location ONLY IF USING THE Cn3D HIGHLIGHTS
1598  /*
1599  if (intervals.size() == 1) {
1600  annot->SetLocation().SetInt(*(intervals.front()));
1601  } else {
1602  CPacked_seqint *packed = new CPacked_seqint();
1603  packed->Set() = intervals; // copy list
1604  annot->SetLocation().SetPacked_int(*packed);
1605  }
1606  */
1607 
1608  // add to annotation list
1609  annotSet->Set().push_back(annot);
1611 
1612  // update GUI
1613  SetupGUIControls(itemId, annotSet->Get().size() - 1, eRemakeListBox);
1614 }
1615 
1617 {
1618  // get selection
1620  if (annots->GetCount() == 0 || annots->GetSelection() < 0) return;
1621 
1622  CAlign_annot *selectedAnnot =
1623  reinterpret_cast<CAlign_annot*>(annots->GetClientData(annots->GetSelection()));
1624  if (!selectedAnnot) {
1625  ERRORMSG("IBISAnnotateDialog::DeleteAnnotation() - error getting annotation pointer");
1626  return;
1627  }
1628 
1629  // confirm with user
1630  int confirm = wxMessageBox("This will remove the selected (putatively IBIS-derived) annotation\n"
1631  "and all evidence associated with it.\nIs this correct?", "Confirm", wxOK | wxCANCEL | wxCENTRE, this);
1632  if (confirm != wxOK) return;
1633 
1634  // actually delete the annotation
1635  CAlign_annot_set::Tdata::iterator a, ae = annotSet->Set().end();
1636  for (a=annotSet->Set().begin(); a!=ae; ++a) {
1637  if (*a == selectedAnnot) {
1638  annotSet->Set().erase(a);
1640  break;
1641  }
1642  }
1643 
1644  // update GUI
1645  DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(interactions, ID_LC_INT, wxListCtrl)
1646  int selectedItem = (int) GetFirstSelectedListCtrlItemId(*interactions);
1647 
1648  SetupGUIControls(selectedItem, -1, eRemakeListBox);
1649 }
1650 
1651 
1652 bool IBISAnnotateDialog::HighlightInterval(const ncbi::objects::CSeq_interval& interval)
1653 {
1655 // return alignment->HighlightAlignedColumnsOfMasterRange(interval.GetFrom(), interval.GetTo());
1656 
1657  // make sure annotation sequence matches master sequence
1658  bool highlightResult;
1659  bool idMatchResult = true;
1660  const Sequence *master = alignment->GetMaster();
1661  if (!master->identifier->MatchesSeqId(interval.GetId())) {
1662  WARNINGMSG("interval Seq-id " << interval.GetId().GetSeqIdString() << " does not match master Seq-id");
1663  idMatchResult = false;
1664  }
1665 
1666  highlightResult = alignment->HighlightAlignedColumnsOfMasterRange(interval.GetFrom(), interval.GetTo());
1667  return (idMatchResult && highlightResult);
1668 }
1669 
1671 {
1672  DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(interactions, ID_LC_INT, wxListCtrl)
1674 
1675  // get selection
1676  if (annots->GetCount() == 0 || annots->GetSelection() < 0) return;
1677  CAlign_annot *selectedAnnot =
1678  reinterpret_cast<CAlign_annot*>(annots->GetClientData(annots->GetSelection()));
1679  if (!selectedAnnot) {
1680  ERRORMSG("IBISAnnotateDialog::HighlightAnnotation() - error getting annotation pointer");
1681  return;
1682  }
1683 
1684  bool okay = true;
1685  if (eventId == ID_B_HIGHLIGHT_ANNOT) {
1686  // highlight annotation's complete set of intervals
1688  if (selectedAnnot->GetLocation().IsInt()) {
1689  okay = HighlightInterval(selectedAnnot->GetLocation().GetInt());
1690  } else if (selectedAnnot->GetLocation().IsPacked_int()) {
1691  CPacked_seqint::Tdata::iterator s,
1692  se = selectedAnnot->SetLocation().SetPacked_int().Set().end();
1693  for (s=selectedAnnot->SetLocation().SetPacked_int().Set().begin(); s!=se; ++s) {
1694  if (!HighlightInterval(**s))
1695  okay = false;
1696  }
1697  }
1698  } else if (eventId >= ID_B_HIGHLIGHT_OLAP && eventId <= ID_B_HIGHLIGHT_NONOLAP_INTN) {
1699 
1700  // Highlight that subset of the annotation which overlaps the selected interaction
1701  // Even if there's no selected item, or it isn't mapped properly to
1702  // a known interaction, clear existing highlighting to avoid confusion.
1703  long selectedItem = GetFirstSelectedListCtrlItemId(*interactions);
1704  int index = interactions->GetItemData(selectedItem);
1706  if (selectedItem < 0) {
1707  return;
1708  } else if (index < 0 || index >= (int) vecIbisInteractions.size()) {
1709  ERRORMSG("IBISAnnotateDialog::HighlightAnnotation() - error getting IBIS interaction " << index << " for overlap calculation");
1710  return;
1711  }
1712 
1713  SeqPosSet overlaps;
1714  IntervalList intervals;
1715  IntervalList::iterator intIt, intEnd;
1716  if (eventId == ID_B_HIGHLIGHT_OLAP) {
1717  GetAnnotIbisOverlaps(*vecIbisInteractions[index], *selectedAnnot, overlaps);
1718  } else {
1719  GetAnnotIbisNonOverlaps(*vecIbisInteractions[index], *selectedAnnot, overlaps, (eventId == ID_B_HIGHLIGHT_NONOLAP_ANNOT));
1720  }
1721  GetIntervalsForSet(overlaps, intervals);
1722  intEnd = intervals.end();
1723  for (intIt = intervals.begin(); intIt != intEnd; ++intIt) {
1724  if (!HighlightInterval(**intIt))
1725  okay = false;
1726  }
1727  } else {
1728  ERRORMSG("IBISAnnotateDialog::HighlightAnnotation() - invalid event id " << eventId);
1729  }
1730 
1731  if (!okay)
1732  wxMessageBox("WARNING: this annotation specifies master residues outside the aligned blocks;"
1733  " see the message log for details.", "Annotation Error",
1734  wxOK | wxCENTRE | wxICON_ERROR, this);
1735 }
1736 
1737 END_SCOPE(Cn3D)
1738 
1739 
1740 ////////////////////////////////////////////////////////////////////////////////////////////////
1741 // The following is taken unmodified from wxDesigner's C++ code from cdd_ibis_annot_dialog.wdr
1742 ////////////////////////////////////////////////////////////////////////////////////////////////
1743 
1745 wxSizer *SetupIbisAnnotationDialog( wxWindow *parent, bool call_fit, bool set_sizer )
1746 {
1747  wxBoxSizer *item0 = new wxBoxSizer( wxVERTICAL );
1748 
1749  wxFlexGridSizer *item1 = new wxFlexGridSizer( 1, 0, 0, 0 );
1750  item1->AddGrowableCol( 1 );
1751 
1752  wxStaticBox *item3 = new wxStaticBox( parent, -1, wxT("IBIS Interactions") );
1753  wxStaticBoxSizer *item2 = new wxStaticBoxSizer( item3, wxVERTICAL );
1754  ibisIntStaticBoxSizer = item2;
1755 
1756  wxFlexGridSizer *item4 = new wxFlexGridSizer( 1, 0, 0, 0 );
1757 
1758  wxStaticText *item5 = new wxStaticText( parent, ID_TEXT_INT, wxT("Interaction Type Filter"), wxDefaultPosition, wxDefaultSize, 0 );
1759  item4->Add( item5, 0, wxALIGN_CENTER|wxALL, 5 );
1760 
1761  wxString strs6[] =
1762  {
1763  wxT("All"),
1764  wxT("Protein-Protein"),
1765  wxT("Protein-NucAcid"),
1766  wxT("Protein-Chemical"),
1767  wxT("Protein-Peptide"),
1768  wxT("Protein-Ion")
1769  };
1770  wxChoice *item6 = new wxChoice( parent, ID_C_TYPE, wxDefaultPosition, wxSize(100,-1), 6, strs6, 0 );
1771  item4->Add( item6, 0, wxALIGN_CENTER|wxALL, 5 );
1772 
1773  item2->Add( item4, 0, wxALIGN_CENTER|wxALL, 5 );
1774 
1775  wxListCtrl *item7 = new wxListCtrl( parent, ID_LC_INT, wxDefaultPosition, wxSize(450,150), wxLC_REPORT|wxLC_SINGLE_SEL|wxSUNKEN_BORDER );
1776  item2->Add( item7, 0, wxALIGN_CENTER|wxALL, 5 );
1777 
1778  wxFlexGridSizer *item8 = new wxFlexGridSizer( 3, 0, 0 );
1779 
1780  wxButton *item9 = new wxButton( parent, ID_B_ADD_INT, wxT("Make IBIS Annotation"), wxDefaultPosition, wxDefaultSize, 0 );
1781  item8->Add( item9, 0, wxALIGN_CENTER|wxALL, 5 );
1782 
1783  wxButton *item10 = new wxButton( parent, ID_B_LAUNCH_INT, wxT("Launch"), wxDefaultPosition, wxDefaultSize, 0 );
1784  item8->Add( item10, 0, wxALIGN_CENTER|wxALL, 5 );
1785 
1786  wxButton *item11 = new wxButton( parent, ID_B_HIGHLIGHT_INT, wxT("Highlight"), wxDefaultPosition, wxDefaultSize, 0 );
1787  item8->Add( item11, 0, wxALIGN_CENTER|wxALL, 5 );
1788 
1789  item2->Add( item8, 0, wxALIGN_CENTER|wxALL, 5 );
1790 
1791  item1->Add( item2, 0, wxALIGN_CENTER|wxALL, 5 );
1792 
1793  wxStaticBox *item13 = new wxStaticBox( parent, -1, wxT("Overlapping Annotations") );
1794  wxStaticBoxSizer *item12 = new wxStaticBoxSizer( item13, wxVERTICAL );
1795 
1796  item12->Add( 20, 10, 0, wxALIGN_CENTER|wxALL, 5 );
1797 
1798  wxString strs14[] =
1799  {
1800  wxT("ListItem")
1801  };
1802  wxListBox *item14 = new wxListBox( parent, ID_LB_ANNOT, wxDefaultPosition, wxSize(275,100), 1, strs14, wxLB_SINGLE );
1803  item12->Add( item14, 0, wxALIGN_CENTER|wxALL, 5 );
1804 
1805  wxFlexGridSizer *item15 = new wxFlexGridSizer( 3, 0, 0 );
1806 
1807  wxButton *item16 = new wxButton( parent, ID_B_DELETE_ANNOT,
1808  wxT("Delete \n")
1809  wxT("IBIS Annotation"),
1810  wxDefaultPosition, wxDefaultSize, 0 );
1811  item15->Add( item16, 0, wxALIGN_CENTER|wxALL, 5 );
1812 
1813  wxButton *item17 = new wxButton( parent, ID_B_HIGHLIGHT_ANNOT,
1814  wxT("Highlight\n")
1815  wxT("Annotation"),
1816  wxDefaultPosition, wxDefaultSize, 0 );
1817  item15->Add( item17, 0, wxALIGN_CENTER|wxALL, 5 );
1818 
1819  wxButton *item18 = new wxButton( parent, ID_B_HIGHLIGHT_OLAP,
1820  wxT("Highlight\n")
1821  wxT("Overlap"),
1822  wxDefaultPosition, wxDefaultSize, 0 );
1823  item15->Add( item18, 0, wxALIGN_CENTER|wxALL, 5 );
1824 
1825  item12->Add( item15, 0, wxALIGN_CENTER|wxALL, 5 );
1826 
1827  wxFlexGridSizer *item19 = new wxFlexGridSizer( 2, 0, 0 );
1828 
1829  wxButton *item20 = new wxButton( parent, ID_B_HIGHLIGHT_NONOLAP_ANNOT,
1830  wxT("Highlight Non-Overlap\n")
1831  wxT("of Annotation"),
1832  wxDefaultPosition, wxDefaultSize, 0 );
1833  item19->Add( item20, 0, wxALIGN_CENTER|wxALL, 5 );
1834 
1835  wxButton *item21 = new wxButton( parent, ID_B_HIGHLIGHT_NONOLAP_INTN,
1836  wxT("Highlight Non-Overlap\n")
1837  wxT("of Interaction"),
1838  wxDefaultPosition, wxDefaultSize, 0 );
1839  item19->Add( item21, 0, wxALIGN_CENTER|wxALL, 5 );
1840 
1841  item12->Add( item19, 0, wxALIGN_CENTER|wxALL, 5 );
1842 
1843  item1->Add( item12, 0, wxGROW|wxALIGN_CENTER_VERTICAL|wxALL, 5 );
1844 
1845  item0->Add( item1, 0, wxALIGN_CENTER|wxALL, 5 );
1846 
1847  if (set_sizer)
1848  {
1849  parent->SetSizer( item0 );
1850  if (call_fit)
1851  item0->SetSizeHints( parent );
1852  }
1853 
1854  return item0;
1855 }
User-defined methods of the data storage class.
User-defined methods of the data storage class.
#define static
bool GetAsnDataViaHTTPS(const std::string &host, const std::string &path, const std::string &args, ASNClass *asnObject, std::string *err, bool binaryData=true)
Definition: asn_reader.hpp:182
#define ID_C_TYPE
USING_SCOPE(objects)
#define ID_LC_INT
wxSizer * SetupIbisAnnotationDialog(wxWindow *parent, bool call_fit=TRUE, bool set_sizer=TRUE)
#define ID_B_HIGHLIGHT_NONOLAP_ANNOT
#define DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(var, id, type)
bool DoesInteractionMatchChoice(const wxString &choiceStr, IBISInteraction::eIbisInteractionType ibisIntType)
static const string IBIS_EVIDENCE_COMMENT
long GetFirstSelectedListCtrlItemId(const wxListCtrl &listCtrl)
#define ID_TEXT_INT
static unsigned int GetSetIntersection(const SeqPosSet &set1, const SeqPosSet &set2, SeqPosSet &intersection)
void GetPositionsForAlignAnnot(const CAlign_annot &annot, SeqPosSet &positions, bool zeroBased)
#define ID_B_LAUNCH_INT
#define ID_B_HIGHLIGHT_INT
#define ID_B_DELETE_ANNOT
void InsertItemInListView(int vecIndex, const CRef< IBISInteraction > &ibisInt, wxListCtrl &listCtrl)
wxSizer * ibisIntStaticBoxSizer
#define ID_LB_ANNOT
static bool GetInteractionDataFromIbis(CSeq_annot &ibisSeqAnnot, IbisQuery &query)
unsigned int GetAllSelectedListCtrlItemIds(const wxListCtrl &listCtrl, vector< long > &ids)
void InsertItemInReportView(int vecIndex, const CRef< IBISInteraction > &ibisInt, wxListCtrl &listCtrl)
#define ID_B_HIGHLIGHT_OLAP
#define ID_B_ADD_INT
#define ID_B_HIGHLIGHT_NONOLAP_INTN
#define ID_B_HIGHLIGHT_ANNOT
std::set< ncbi::TSeqPos > SeqPosSet
const BlockMultipleAlignment * GetCurrentMultipleAlignment(void) const
const Sequence * GetMaster(void) const
bool HighlightAlignedColumnsOfMasterRange(unsigned int from, unsigned int to) const
bool IsAligned(unsigned int row, unsigned int seqIndex) const
CAlign_annot –.
Definition: Align_annot.hpp:66
CFeature_evidence –.
CNcbiOstrstreamToString class helps convert CNcbiOstrstream to a string Sample usage:
Definition: ncbistre.hpp:802
CRef –.
Definition: ncbiobj.hpp:618
CTimeFormat –.
Definition: ncbitime.hpp:131
CTime –.
Definition: ncbitime.hpp:296
void HighlightAnnotation(int eventId)
void OnListCtrlSelection(wxListEvent &event)
void OnListBoxSelection(wxCommandEvent &event)
void GetAnnotIbisNonOverlaps(const IBISInteraction &interaction, const ncbi::objects::CAlign_annot &annot, SeqPosSet &nonOverlaps, bool onAnnotation) const
std::list< ncbi::CRef< ncbi::objects::CSeq_interval > > IntervalList
void GetAnnotIbisOverlaps(AnnotIbisOverlapMap &aioMap) const
IBISAnnotateDialog ** dialogHandle
void OnButton(wxCommandEvent &event)
std::vector< ncbi::CRef< IBISInteraction > > vecIbisInteractions
void SetupGUIControls(int selectInteraction, int selectAnnot, unsigned int updateFlags=eRemakeListCtrl|eRemakeListBox)
bool HighlightInterval(const ncbi::objects::CSeq_interval &interval)
bool HasInteractionData(void) const
std::map< unsigned long, AlignAnnotInfo > AnnotIbisOverlapMap
unsigned int GetIntervalsForSet(const SeqPosSet &positions, IntervalList &intervals)
ncbi::CRef< ncbi::objects::CAlign_annot_set > annotSet
void OnChoice(wxCommandEvent &event)
void OnCloseWindow(wxCloseEvent &event)
static const MoleculeIdentifier * GetQueryMolecule()
IBISInteraction(const ncbi::objects::CSeq_feat &seqfeat)
eIbisInteractionType m_type
bool GetGi(TGi &gi) const
static std::string IbisIntTypeToString(eIbisInteractionType ibisType)
static bool QueryMoleculeHasChain()
static const Sequence * m_querySequence
static const MoleculeIdentifier * m_queryMolecule
static void SetQuerySequence(const Sequence *querySequence)
ncbi::objects::CSeq_feat m_seqfeat
const ncbi::objects::CSeq_loc & GetLocation(bool &isOK) const
static eIbisInteractionType CddIntTypeToIbisIntType(eCddInteractionType cddType)
static const int NOT_ASSIGNED
ncbi::CRef< ncbi::objects::CAlign_annot > ToAlignAnnot(void) const
static bool IsIbisIntType(int integer, eIbisInteractionType *ibisType=NULL)
const SeqPosSet & GetPositions(void) const
bool GetFootprint(int &from, int &to) const
static const TGi GI_NOT_ASSIGNED
static eCddInteractionType IbisIntTypeToCddIntType(eIbisInteractionType ibisType)
bool RemoveAllHighlights(bool postRedraws)
Definition: messenger.cpp:393
bool MatchesSeqId(const ncbi::objects::CSeq_id &sid) const
static const int VALUE_NOT_SET
bool HasStructure(void) const
std::string ToString(void) const
void FillOutSeqId(ncbi::objects::CSeq_id *sid) const
const MoleculeIdentifier * identifier
unsigned int Length(void) const
static const unsigned int eUserAnnotationData
AlignmentManager * alignmentManager
void SetDataChanged(unsigned int what) const
Definition: set.hpp:45
iterator_bool insert(const value_type &val)
Definition: set.hpp:149
const_iterator find(const key_type &key) const
Definition: set.hpp:137
const_iterator end() const
Definition: set.hpp:136
bool RegistryGetBoolean(const string &section, const string &name, bool *value)
Definition: cn3d_tools.cpp:250
void LaunchWebPage(const char *url)
Definition: cn3d_tools.cpp:432
#define TRACEMSG(stream)
Definition: cn3d_tools.hpp:83
#define INFOMSG(stream)
Definition: cn3d_tools.hpp:84
#define WARNINGMSG(stream)
Definition: cn3d_tools.hpp:85
static const std::string REG_ADVANCED_SECTION
Definition: cn3d_tools.hpp:191
static const std::string REG_CDD_ANNOT_READONLY
Definition: cn3d_tools.hpp:192
#define WX_TO_STD(wxstring)
Definition: cn3d_tools.hpp:285
#define ERRORMSG(stream)
Definition: cn3d_tools.hpp:86
Include a standard set of the NCBI C++ Toolkit most basic headers.
static DLIST_TYPE *DLIST_NAME() first(DLIST_LIST_TYPE *list)
Definition: dlist.tmpl.h:46
static DLIST_TYPE *DLIST_NAME() last(DLIST_LIST_TYPE *list)
Definition: dlist.tmpl.h:51
static int type
Definition: getdata.c:31
int offset
Definition: replacements.h:160
static const char location[]
Definition: config.c:97
unsigned int TSeqPos
Type for sequence locations and lengths.
Definition: ncbimisc.hpp:875
string
Definition: cgiapp.hpp:690
#define NULL
Definition: ncbistd.hpp:225
bool Match(const CSeq_id &sid2) const
Match() - TRUE if SeqIds are equivalent.
Definition: Seq_id.hpp:1065
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
bool Empty(void) const THROWS_NONE
Check if CRef is empty – not pointing to any object, which means having a null value.
Definition: ncbiobj.hpp:719
#define END_SCOPE(ns)
End the previously defined scope.
Definition: ncbistl.hpp:75
#define BEGIN_SCOPE(ns)
Define a new scope.
Definition: ncbistl.hpp:72
#define kEmptyStr
Definition: ncbistr.hpp:123
string AsString(const CTimeFormat &format=kEmptyStr, TSeconds out_tz=eCurrentTimeZone) const
Transform time to string.
Definition: ncbitime.cpp:1512
static CTimeFormat GetPredefined(EPredefined fmt, TFlags flags=fDefault)
Get predefined format.
Definition: ncbitime.cpp:389
@ eCurrent
Use current time. See also CCurrentTime.
Definition: ncbitime.hpp:300
@ eISO8601_DateTimeMin
Y-M-DTh:m (eg 1997-07-16T19:20)
Definition: ncbitime.hpp:195
static const char label[]
const TDescription & GetDescription(void) const
Get the Description member data.
list< CRef< CFeature_evidence > > TEvidence
bool IsSetType(void) const
for typing annotated features 0 .
void SetLocation(TLocation &value)
Assign a value to Location data member.
const TLocation & GetLocation(void) const
Get the Location member data.
bool IsSetDescription(void) const
to hold descriptions/names like "Heme binding site" or "catalytic triad" etc., something that should ...
vector< CRef< CUser_field > > TData
void SetTo(TTo value)
Assign a value to To data member.
list< CRef< CSeq_interval > > Tdata
const Tdata & Get(void) const
Get the member data.
void SetId(TId &value)
Assign a value to Id data member.
TFrom GetFrom(void) const
Get the From member data.
void SetFrom(TFrom value)
Assign a value to From data member.
TGi GetGi(void) const
Get the variant data.
Definition: Seq_id_.hpp:889
bool IsPacked_int(void) const
Check if variant Packed_int is selected.
Definition: Seq_loc_.hpp:534
bool IsGi(void) const
Check if variant Gi is selected.
Definition: Seq_id_.hpp:883
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
const TPacked_int & GetPacked_int(void) const
Get the variant data.
Definition: Seq_loc_.cpp:216
virtual void Reset(void)
Reset the whole object.
Definition: Seq_annot_.cpp:249
const TFtable & GetFtable(void) const
Get the variant data.
Definition: Seq_annot_.hpp:621
list< CRef< CSeq_feat > > TFtable
Definition: Seq_annot_.hpp:193
bool IsFtable(void) const
Check if variant Ftable is selected.
Definition: Seq_annot_.hpp:615
const TData & GetData(void) const
Get the Data member data.
Definition: Seq_annot_.hpp:873
unsigned int
A callback function used to compare two keys in a database.
Definition: types.hpp:1210
END_EVENT_TABLE()
char * buf
int i
Messenger * GlobalMessenger(void)
Definition: messenger.cpp:73
#define wxT(x)
Definition: muParser.cpp:41
double value_type
The numeric datatype used by the parser.
Definition: muParserDef.h:228
const struct ncbi::grid::netcache::search::fields::SIZE size
unsigned int a
Definition: ncbi_localip.c:102
ESERV_Site site
#define TRUE
bool replacment for C indicating true.
Definition: ncbi_std.h:97
#define U
static string query
Definition: type.c:6
else result
Definition: token2.c:20
string ToString(const wxRect &rc)
Definition: wx_utils.cpp:773
#define const
Definition: zconf.h:232
Modified on Fri Sep 20 14:58:18 2024 by modify_doxy.py rev. 669887