📄 cdd_annot_dialog.cpp
字号:
throw "no MMDB ID found in annotation"; int mmdbID = annot.GetId().front()->GetMmdb_id().Get(); // map object to aligned molecule ID and interval of alignment on that chain typedef map < const StructureObject * , ChainInfo > ObjectMap; ObjectMap annotObjects; // first find all objects with the annotation's mmdbID; fill out chain id and interval const BlockMultipleAlignment *alignment = set->alignmentManager->GetCurrentMultipleAlignment(); if (!alignment) throw "no alignment"; BlockMultipleAlignment::UngappedAlignedBlockList alignedBlocks; alignment->GetUngappedAlignedBlocks(&alignedBlocks); if (alignedBlocks.size() == 0) throw "no aligned blocks"; for (int row=0; row<alignment->NRows(); ++row) { const StructureObject *object; const Sequence *seq = alignment->GetSequenceOfRow(row); if (!seq->molecule || seq->molecule->identifier->mmdbID != mmdbID || !seq->molecule->GetParentOfType(&object)) continue; ChainInfo& ci = annotObjects[object]; ci.alignedMoleculeID = seq->molecule->id; ci.from = alignedBlocks.front()->GetRangeOfRow(row)->from; ci.to = alignedBlocks.back()->GetRangeOfRow(row)->to; ci.hits = 0; } if (annotObjects.size() == 0) throw "no chain of annotation's MMDB ID in the alignment"; GlobalMessenger()->RemoveAllHighlights(true); CCn3d_style_settings globalStyleSettings; set->styleManager->GetGlobalStyle().SaveSettingsToASN(&globalStyleSettings); // iterate over molecule/residue intervals if (annot.GetFeatures().size() > 0 && annot.GetFeatures().front()->GetFeatures().size() > 0 && annot.GetFeatures().front()->GetFeatures().front()->IsSetLocation() && annot.GetFeatures().front()->GetFeatures().front()->GetLocation().IsSubgraph() && annot.GetFeatures().front()->GetFeatures().front()->GetLocation(). GetSubgraph().IsResidues() && annot.GetFeatures().front()->GetFeatures().front()->GetLocation(). GetSubgraph().GetResidues().IsInterval() && annot.GetFeatures().front()->GetFeatures().front()->GetLocation(). GetSubgraph().GetResidues().GetInterval().size() > 0) { ObjectMap::iterator o, oe = annotObjects.end(); CResidue_pntrs::TInterval::const_iterator i, ie = annot.GetFeatures().front()->GetFeatures().front()->GetLocation(). GetSubgraph().GetResidues().GetInterval().end(); for (i=annot.GetFeatures().front()->GetFeatures().front()->GetLocation(). GetSubgraph().GetResidues().GetInterval().begin(); i!=ie; ++i) { // for each object for (o=annotObjects.begin(); o!=oe; ++o) { // find molecule with annotation's moleculeID ChemicalGraph::MoleculeMap::const_iterator m = o->first->graph->molecules.find((*i)->GetMolecule_id().Get()); if (m == o->first->graph->molecules.end()) throw "molecule with annotation's specified molecule ID not found in object"; // make sure this stuff is visible in global style if (m->second->IsProtein()) { if (globalStyleSettings.GetProtein_backbone().GetType() == eCn3d_backbone_type_off && !globalStyleSettings.GetProtein_sidechains().GetIs_on()) { globalStyleSettings.SetProtein_backbone().SetType(eCn3d_backbone_type_trace); } } else if (m->second->IsNucleotide()) { if (globalStyleSettings.GetNucleotide_backbone().GetType() == eCn3d_backbone_type_off && !globalStyleSettings.GetNucleotide_sidechains().GetIs_on()) { globalStyleSettings.SetNucleotide_backbone().SetType(eCn3d_backbone_type_trace); } } else if (m->second->IsSolvent()) { globalStyleSettings.SetSolvents().SetIs_on(true); } else if (m->second->IsHeterogen()) { globalStyleSettings.SetHeterogens().SetIs_on(true); } for (int r=(*i)->GetFrom().Get(); r<=(*i)->GetTo().Get(); ++r) { // highlight residues in interval if (o == annotObjects.begin()) { if (r >= 1 && r <= m->second->NResidues()) GlobalMessenger()->ToggleHighlight(m->second, r); else throw "annotation's residue ID out of molecule's residue range"; } // count hits of annotated residues in aligned chain+interval if (o->second.alignedMoleculeID == m->second->id && r >= o->second.from && r <= o->second.to) (o->second.hits)++; } } } set->styleManager->SetGlobalStyle(globalStyleSettings); // return object with most hits of annotation to aligned chain region const StructureObject *bestObject = NULL; for (o=annotObjects.begin(); o!=oe; ++o) if (!bestObject || o->second.hits > annotObjects[bestObject].hits) bestObject = o->first; return bestObject; } else throw "unrecognized annotation structure"; } catch (const char *err) { ERRORMSG("HighlightResidues() - " << err); } return NULL;}void CDDAnnotateDialog::ShowEvidence(void){ // get selected evidence DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(evids, ID_L_EVID, wxListBox) if (evids->GetCount() == 0 || evids->GetSelection() < 0) return; CFeature_evidence *selectedEvidence = reinterpret_cast<CFeature_evidence*>(evids->GetClientData(evids->GetSelection())); if (!selectedEvidence) { ERRORMSG("CDDAnnotateDialog::ShowEvidence() - error getting evidence pointer"); return; } // launch URL given PMID if (selectedEvidence->IsReference() && selectedEvidence->GetReference().IsPmid()) { wxString url; url.Printf("http://www.ncbi.nlm.nih.gov/entrez/query.fcgi?" "cmd=Retrieve&db=PubMed&dopt=Abstract&list_uids=%i", selectedEvidence->GetReference().GetPmid().Get()); LaunchWebPage(url); } // highlight residues if structure evidence else if (IS_STRUCTURE_EVIDENCE_BSANNOT(*selectedEvidence)) { const StructureObject *bestObject = HighlightResidues(structureSet, selectedEvidence->GetBsannot()); if (bestObject) { // first, set show/hide to make only objects of this mmdb id visible structureSet->showHideManager->MakeAllVisible(); StructureSet::ObjectList::const_iterator o, oe = structureSet->objects.end(); for (o=structureSet->objects.begin(); o!=oe; ++o) if ((*o)->mmdbID != bestObject->mmdbID) structureSet->showHideManager->Show(*o, false); // now force redrawing of structures, so the frames that contains // these objects aren't empty (otherwise, renderer won't show selected frame) GlobalMessenger()->ProcessRedraws(); // now show the frame containing the "best" object (get display list from first molecule) unsigned int displayList = bestObject->graph->molecules.find(1)->second->displayLists.front(); for (int frame=0; frame<structureSet->frameMap.size(); ++frame) { StructureSet::DisplayLists::const_iterator d, de = structureSet->frameMap[frame].end(); for (d=structureSet->frameMap[frame].begin(); d!=de; ++d) { if (*d == displayList) { // is display list in this frame? structureSet->renderer->ShowFrameNumber(frame); frame = structureSet->frameMap.size(); // to exit out of next-up loop break; } } } wxMessageBox( selectedEvidence->GetBsannot().GetFeatures().front()->GetDescr().front()->GetName().c_str(), "Structure Evidence", wxOK | wxCENTRE, this); } } else if (selectedEvidence->IsComment()) { wxMessageBox(selectedEvidence->GetComment().c_str(), "Comment", wxOK | wxCENTRE, this); } else { ERRORMSG("CDDAnnotateDialog::ShowEvidence() - can't show that evidence type"); }}void CDDAnnotateDialog::MoveEvidence(bool moveUp){ DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(annots, ID_L_ANNOT, wxListBox) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(evids, ID_L_EVID, wxListBox) // get selected annotation if (annots->GetCount() == 0 || annots->GetSelection() < 0) return; CAlign_annot *selectedAnnot = reinterpret_cast<CAlign_annot*>(annots->GetClientData(annots->GetSelection())); if (!selectedAnnot) { ERRORMSG("CDDAnnotateDialog::MoveEvidence() - error getting annotation pointer"); return; } // get selected evidence if (evids->GetCount() == 0 || evids->GetSelection() < 0) return; CFeature_evidence *selectedEvidence = reinterpret_cast<CFeature_evidence*>(evids->GetClientData(evids->GetSelection())); if (!selectedEvidence) { ERRORMSG("CDDAnnotateDialog::MoveEvidence() - error getting evidence pointer"); return; } CAlign_annot::TEvidence::iterator e, ee = selectedAnnot->SetEvidence().end(), ePrev = ee, eSwap = ee; CRef < CFeature_evidence > tmp; for (e=selectedAnnot->SetEvidence().begin(); e!=ee; ++e) { if (*e == selectedEvidence) { // figure out which (prev or next) evidence field to swap with if (moveUp && ePrev != ee) eSwap = ePrev; else if (!moveUp && (++(eSwap = e)) != ee) ; else return; // do the swap and update GUI tmp = *eSwap; *eSwap = *e; *e = tmp; structureSet->SetDataChanged(StructureSet::eUserAnnotationData); SetupGUIControls(annots->GetSelection(), evids->GetSelection() + (moveUp ? -1 : 1)); return; } ePrev = e; }}///// CDDEvidenceDialog stuff /////BEGIN_EVENT_TABLE(CDDEvidenceDialog, wxDialog) EVT_CLOSE ( CDDEvidenceDialog::OnCloseWindow) EVT_BUTTON (-1, CDDEvidenceDialog::OnButton) EVT_RADIOBUTTON (-1, CDDEvidenceDialog::OnChange) EVT_TEXT (-1, CDDEvidenceDialog::OnChange)END_EVENT_TABLE()CDDEvidenceDialog::CDDEvidenceDialog(wxWindow *parent, const ncbi::objects::CFeature_evidence& initial) : wxDialog(parent, -1, "CDD Annotations", wxPoint(400, 100), wxDefaultSize, wxCAPTION | wxSYSTEM_MENU), // not resizable changed(false), rerange(false){ // construct the panel wxPanel *panel = new wxPanel(this, -1); wxSizer *topSizer = SetupEvidenceDialog(panel, false); // call sizer stuff topSizer->Fit(this); topSizer->Fit(panel); topSizer->SetSizeHints(this); // set initial states if (initial.IsComment()) { DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(rComment, ID_R_COMMENT, wxRadioButton) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(tComment, ID_T_COMMENT, wxTextCtrl) rComment->SetValue(true); tComment->SetValue(initial.GetComment().c_str()); tComment->SetFocus(); } else if (initial.IsReference() && initial.GetReference().IsPmid()) { DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(rPMID, ID_R_PMID, wxRadioButton) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(tPMID, ID_T_PMID, wxTextCtrl) rPMID->SetValue(true); wxString pmid; pmid.Printf("%i", initial.GetReference().GetPmid().Get()); tPMID->SetValue(pmid); tPMID->SetFocus(); } else if (IS_STRUCTURE_EVIDENCE_BSANNOT(initial)) { DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(rSTRUCTURE, ID_R_STRUCTURE, wxRadioButton) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(tSTRUCTURE, ID_T_STRUCTURE, wxTextCtrl) rSTRUCTURE->SetValue(true); tSTRUCTURE->SetValue( initial.GetBsannot().GetFeatures().front()->GetDescr().front()->GetName().c_str()); } else { ERRORMSG("CDDEvidenceDialog::CDDEvidenceDialog() - " "don't (yet) know how to edit this evidence type"); } SetupGUIControls();}// same as hitting cancel buttonvoid CDDEvidenceDialog::OnCloseWindow(wxCloseEvent& event){ EndModal(wxCANCEL);}void CDDEvidenceDialog::OnButton(wxCommandEvent& event){ switch (event.GetId()) { case ID_B_EDIT_OK: { EndModal(wxOK); break; } case ID_B_EDIT_CANCEL: EndModal(wxCANCEL); break; case ID_B_RERANGE: rerange = changed = true; break; default: event.Skip(); }}void CDDEvidenceDialog::OnChange(wxCommandEvent& event){ changed = true; SetupGUIControls();}void CDDEvidenceDialog::SetupGUIControls(void){ DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(rComment, ID_R_COMMENT, wxRadioButton) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(stComment, ID_ST_COMMENT, wxStaticText) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(tComment, ID_T_COMMENT, wxTextCtrl) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(rPMID, ID_R_PMID, wxRadioButton) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(stPMID, ID_ST_PMID, wxStaticText) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(tPMID, ID_T_PMID, wxTextCtrl) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(rStructure, ID_R_STRUCTURE, wxRadioButton) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(stStructure, ID_ST_STRUCTURE, wxStaticText) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(tStructure, ID_T_STRUCTURE, wxTextCtrl) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(bStructure, ID_B_RERANGE, wxButton)// stComment->Enable(rComment->GetValue()); tComment->Enable(rComment->GetValue());// stPMID->Enable(rPMID->GetValue()); tPMID->Enable(rPMID->GetValue());// stStructure->Enable(rStructure->GetValue()); tStructure->Enable(rStructure->GetValue()); bStructure->Enable(rStructure->GetValue());}bool CDDEvidenceDialog::GetData(ncbi::objects::CFeature_evidence *evidence){ DECLARE_AND_FIND_WINDOW_RETURN_FALSE_ON_ERR(rComment, ID_R_COMMENT, wxRadioButton) DECLARE_AND_FIND_WINDOW_RETURN_FALSE_ON_ERR(rPMID, ID_R_PMID, wxRadioButton) DECLARE_AND_FIND_WINDOW_RETURN_FALSE_ON_ERR(rSTRUCTURE, ID_R_STRUCTURE, wxRadioButton) if (rComment->GetValue()) { DECLARE_AND_FIND_WINDOW_RETURN_FALSE_ON_ERR(tComment, ID_T_COMMENT, wxTextCtrl) if (tComment->GetValue().size() > 0) { evidence->SetComment(tComment->GetValue().c_str()); return true; } else { ERRORMSG("CDDEvidenceDialog::GetData() - comment must not be zero-length"); return false; }
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -