📄 cdd_annot_dialog.cpp
字号:
/* * =========================================================================== * PRODUCTION $Log: cdd_annot_dialog.cpp,v $ * PRODUCTION Revision 1000.2 2004/06/01 18:27:54 gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.39 * PRODUCTION * =========================================================================== *//* $Id: cdd_annot_dialog.cpp,v 1000.2 2004/06/01 18:27:54 gouriano Exp $* ===========================================================================** PUBLIC DOMAIN NOTICE* National Center for Biotechnology Information** This software/database is a "United States Government Work" under the* terms of the United States Copyright Act. It was written as part of* the author's official duties as a United States Government employee and* thus cannot be copyrighted. This software/database is freely available* to the public for use. The National Library of Medicine and the U.S.* Government have not placed any restriction on its use or reproduction.** Although all reasonable efforts have been taken to ensure the accuracy* and reliability of the software and data, the NLM and the U.S.* Government do not and cannot warrant the performance or results that* may be obtained by using this software or data. The NLM and the U.S.* Government disclaim all warranties, express or implied, including* warranties of performance, merchantability or fitness for any particular* purpose.** Please cite the author in any work or product based on this material.** ===========================================================================** Authors: Paul Thiessen** File Description:* dialogs for annotating CDD's** ===========================================================================*/#ifdef _MSC_VER#pragma warning(disable:4018) // disable signed/unsigned mismatch warning in MSVC#endif#include <ncbi_pch.hpp>#include <corelib/ncbistd.hpp>#include <objects/cdd/Align_annot.hpp>#include <objects/seqloc/Seq_loc.hpp>#include <objects/seqloc/Seq_interval.hpp>#include <objects/seqloc/Packed_seqint.hpp>#include <objects/pub/Pub.hpp>#include <objects/biblio/PubMedId.hpp>#include <objects/mmdb1/Biostruc_annot_set.hpp>#include <objects/mmdb1/Biostruc_descr.hpp>#include <objects/mmdb1/Biostruc_id.hpp>#include <objects/mmdb1/Mmdb_id.hpp>#include <objects/mmdb3/Biostruc_feature_set.hpp>#include <objects/mmdb3/Biostruc_feature_set_descr.hpp>#include <objects/mmdb3/Biostruc_feature.hpp>#include <objects/mmdb3/Chem_graph_pntrs.hpp>#include <objects/mmdb3/Residue_pntrs.hpp>#include <objects/mmdb3/Residue_interval_pntr.hpp>#include <objects/mmdb1/Molecule_id.hpp>#include <objects/mmdb1/Residue_id.hpp>#include <objects/cn3d/Cn3d_backbone_type.hpp>#include <objects/cn3d/Cn3d_backbone_style.hpp>#include <objects/cn3d/Cn3d_general_style.hpp>#include <objects/cn3d/Cn3d_style_settings.hpp>#include "cdd_annot_dialog.hpp"#include "structure_set.hpp"#include "messenger.hpp"#include "alignment_manager.hpp"#include "block_multiple_alignment.hpp"#include "sequence_set.hpp"#include "cn3d_tools.hpp"#include "chemical_graph.hpp"#include "molecule_identifier.hpp"#include "opengl_renderer.hpp"#include "show_hide_manager.hpp"////////////////////////////////////////////////////////////////////////////////////////////////// The following is taken unmodified from wxDesigner's C++ header from cdd_annot_dialog.wdr////////////////////////////////////////////////////////////////////////////////////////////////#include <wx/image.h>#include <wx/statline.h>#include <wx/spinbutt.h>#include <wx/spinctrl.h>#include <wx/splitter.h>#include <wx/listctrl.h>#include <wx/treectrl.h>#include <wx/notebook.h>// Declare window functions#define ID_L_ANNOT 10000#define ID_B_NEW_ANNOT 10001#define ID_B_HIGHLIGHT 10002#define ID_B_ANNOT_UP 10003#define ID_B_EDIT_ANNOT 10004#define ID_B_DEL_ANNOT 10005#define ID_B_ANNOT_DOWN 10006#define ID_L_EVID 10007#define ID_B_NEW_EVID 10008#define ID_B_SHOW 10009#define ID_B_EVID_UP 10010#define ID_B_EDIT_EVID 10011#define ID_B_DEL_EVID 10012#define ID_B_EVID_DOWN 10013wxSizer *SetupCDDAnnotDialog( wxPanel *parent, bool call_fit = TRUE, bool set_sizer = TRUE );#define ID_R_COMMENT 10014#define ID_ST_COMMENT 10015#define ID_T_COMMENT 10016#define ID_LINE 10017#define ID_R_PMID 10018#define ID_ST_PMID 10019#define ID_T_PMID 10020#define ID_R_STRUCTURE 10021#define ID_ST_STRUCTURE 10022#define ID_T_STRUCTURE 10023#define ID_B_RERANGE 10024#define ID_B_EDIT_OK 10025#define ID_B_EDIT_CANCEL 10026wxSizer *SetupEvidenceDialog( wxPanel *parent, bool call_fit = TRUE, bool set_sizer = TRUE );////////////////////////////////////////////////////////////////////////////////////////////////USING_NCBI_SCOPE;USING_SCOPE(objects);BEGIN_SCOPE(Cn3D)// a "structure evidence" biostruc-annot-set has these qualities - basically, a specific// comment tag as the first entry in the set's description, and a 'name' descr in the feature setstatic const string STRUCTURE_EVIDENCE_COMMENT = "Used as Structure Evidence for CDD Annotation";#define IS_STRUCTURE_EVIDENCE_BSANNOT(evidence) \ ((evidence).IsBsannot() && \ (evidence).GetBsannot().IsSetDescr() && \ (evidence).GetBsannot().GetDescr().size() > 0 && \ (evidence).GetBsannot().GetDescr().front()->IsOther_comment() && \ (evidence).GetBsannot().GetDescr().front()->GetOther_comment() == STRUCTURE_EVIDENCE_COMMENT && \ (evidence).GetBsannot().GetFeatures().size() > 0 && \ (evidence).GetBsannot().GetFeatures().front()->IsSetDescr() && \ (evidence).GetBsannot().GetFeatures().front()->GetDescr().size() > 0 && \ (evidence).GetBsannot().GetFeatures().front()->GetDescr().front()->IsName())#define DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(var, id, type) \ type *var; \ var = wxDynamicCast(FindWindow(id), type); \ if (!var) { \ ERRORMSG("Can't find window with id " << id); \ return; \ }#define DECLARE_AND_FIND_WINDOW_RETURN_FALSE_ON_ERR(var, id, type) \ type *var; \ var = wxDynamicCast(FindWindow(id), type); \ if (!var) { \ ERRORMSG("Can't find window with id " << id); \ return false; \ }BEGIN_EVENT_TABLE(CDDAnnotateDialog, wxDialog) EVT_BUTTON (-1, CDDAnnotateDialog::OnButton) EVT_LISTBOX (-1, CDDAnnotateDialog::OnSelection) EVT_CLOSE ( CDDAnnotateDialog::OnCloseWindow)END_EVENT_TABLE()CDDAnnotateDialog::CDDAnnotateDialog(wxWindow *parent, CDDAnnotateDialog **handle, StructureSet *set) : wxDialog(parent, -1, "CDD Annotations", wxPoint(400, 100), wxDefaultSize, wxCAPTION | wxSYSTEM_MENU | wxDIALOG_MODELESS | wxFRAME_NO_TASKBAR), // not resizable dialogHandle(handle), structureSet(set), annotSet(set->GetCDDAnnotSet()){ if (annotSet.Empty()) { Destroy(); return; } // construct the panel wxPanel *panel = new wxPanel(this, -1); wxSizer *topSizer = SetupCDDAnnotDialog(panel, false); // call sizer stuff topSizer->Fit(panel); SetClientSize(topSizer->GetMinSize()); // set initial GUI state SetupGUIControls(0, 0);}CDDAnnotateDialog::~CDDAnnotateDialog(void){ // so owner knows that this dialog has been destroyed if (dialogHandle && *dialogHandle) *dialogHandle = NULL; TRACEMSG("destroyed CDDAnnotateDialog");}void CDDAnnotateDialog::OnCloseWindow(wxCloseEvent& event){ Destroy();}void CDDAnnotateDialog::GetCurrentHighlightedIntervals(IntervalList *intervals){ const BlockMultipleAlignment *alignment = structureSet->alignmentManager->GetCurrentMultipleAlignment(); const Sequence *master = alignment->GetMaster(); // find intervals of aligned residues of the master sequence that are currently highlighted intervals->clear(); int first = 0, last = 0; while (first < master->Length()) { // find first highlighted residue while (first < master->Length() && !(GlobalMessenger()->IsHighlighted(master, first) && alignment->IsAligned(0, first))) ++first; if (first >= master->Length()) break; // find last in contiguous stretch of highlighted residues last = first; while (last + 1 < master->Length() && GlobalMessenger()->IsHighlighted(master, last + 1) && alignment->IsAligned(0, last + 1)) ++last; // create Seq-interval CRef < CSeq_interval > interval(new CSeq_interval()); interval->SetFrom(first); interval->SetTo(last); master->FillOutSeqId(&(interval->SetId())); intervals->push_back(interval); first = last + 2; }}void CDDAnnotateDialog::OnButton(wxCommandEvent& event){ switch (event.GetId()) { // annotation buttons case ID_B_NEW_ANNOT: NewAnnotation(); break; case ID_B_DEL_ANNOT: DeleteAnnotation(); break; case ID_B_EDIT_ANNOT: EditAnnotation(); break; case ID_B_HIGHLIGHT: HighlightAnnotation(); break; case ID_B_ANNOT_UP: case ID_B_ANNOT_DOWN: MoveAnnotation(event.GetId() == ID_B_ANNOT_UP); break; // evidence buttons case ID_B_NEW_EVID: NewEvidence(); break; case ID_B_DEL_EVID: DeleteEvidence(); break; case ID_B_EDIT_EVID: EditEvidence(); break; case ID_B_SHOW: ShowEvidence(); break; case ID_B_EVID_UP: case ID_B_EVID_DOWN: MoveEvidence(event.GetId() == ID_B_EVID_UP); break; default: event.Skip(); }}void CDDAnnotateDialog::OnSelection(wxCommandEvent& event){ DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(annots, ID_L_ANNOT, wxListBox) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(evids, ID_L_EVID, wxListBox) if (event.GetEventObject() == annots) SetupGUIControls(annots->GetSelection(), 0); else SetupGUIControls(annots->GetSelection(), evids->GetSelection());}void CDDAnnotateDialog::SetupGUIControls(int selectAnnot, int selectEvidence){ // get GUI control pointers DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(annots, ID_L_ANNOT, wxListBox) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(evids, ID_L_EVID, wxListBox) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(bNewAnnot, ID_B_NEW_ANNOT, wxButton) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(bDelAnnot, ID_B_DEL_ANNOT, wxButton) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(bEditAnnot, ID_B_EDIT_ANNOT, wxButton) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(bHighlight, ID_B_HIGHLIGHT, wxButton) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(bAnnotUp, ID_B_ANNOT_UP, wxButton) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(bAnnotDown, ID_B_ANNOT_DOWN, wxButton) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(bNewEvid, ID_B_NEW_EVID, wxButton) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(bDelEvid, ID_B_DEL_EVID, wxButton) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(bEditEvid, ID_B_EDIT_EVID, wxButton) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(bShow, ID_B_SHOW, wxButton) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(bEvidUp, ID_B_EVID_UP, wxButton) DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(bEvidDown, ID_B_EVID_DOWN, wxButton) bool readOnly; RegistryGetBoolean(REG_ADVANCED_SECTION, REG_CDD_ANNOT_READONLY, &readOnly); // fill out annots listbox annots->Clear(); CAlign_annot *selectedAnnot = NULL; CAlign_annot_set::Tdata::iterator a, ae = annotSet->Set().end(); for (a=annotSet->Set().begin(); a!=ae; ++a) { if ((*a)->IsSetDescription()) annots->Append((*a)->GetDescription().c_str(), a->GetPointer()); else annots->Append("(no description)", a->GetPointer()); } if (selectAnnot < annots->GetCount()) annots->SetSelection(selectAnnot); else if (annots->GetCount() > 0) annots->SetSelection(0); if (annots->GetCount() > 0) selectedAnnot = reinterpret_cast<CAlign_annot*>(annots->GetClientData(annots->GetSelection())); // fill out evidence listbox evids->Clear(); CFeature_evidence *selectedEvid = NULL; if (selectedAnnot && selectedAnnot->IsSetEvidence()) { CAlign_annot::TEvidence::iterator e, ee = selectedAnnot->SetEvidence().end(); for (e=selectedAnnot->SetEvidence().begin(); e!=ee; ++e) { // get evidence "title" depending on type wxString evidTitle; if ((*e)->IsComment()) evidTitle.Printf("Comment: %s", (*e)->GetComment().c_str()); else if ((*e)->IsReference() && (*e)->GetReference().IsPmid()) evidTitle.Printf("PMID: %i", (*e)->GetReference().GetPmid().Get()); else if (IS_STRUCTURE_EVIDENCE_BSANNOT(**e)) evidTitle.Printf("Structure: %s",
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -