⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 cdd_annot_dialog.cpp

📁 ncbi源码
💻 CPP
📖 第 1 页 / 共 4 页
字号:
                    (*e)->GetBsannot().GetFeatures().front()->GetDescr().front()->GetName().c_str());            else                evidTitle = "(unknown type)";            evids->Append(evidTitle, e->GetPointer());        }        if (selectEvidence < evids->GetCount())            evids->SetSelection(selectEvidence);        else if (evids->GetCount() > 0)            evids->SetSelection(0);        if (evids->GetCount() > 0)            selectedEvid = reinterpret_cast<CFeature_evidence*>(evids->GetClientData(evids->GetSelection()));    }    // set button states    bNewAnnot->Enable(!readOnly);    bDelAnnot->Enable(selectedAnnot != NULL && !readOnly);    bEditAnnot->Enable(selectedAnnot != NULL && !readOnly);    bHighlight->Enable(selectedAnnot != NULL);    bAnnotUp->Enable(annots->GetSelection() > 0 && !readOnly);    bAnnotDown->Enable(annots->GetSelection() < annots->GetCount() - 1 && !readOnly);    bNewEvid->Enable(selectedAnnot != NULL && !readOnly);    bDelEvid->Enable(selectedEvid != NULL && !readOnly);    bEditEvid->Enable(selectedEvid != NULL && !readOnly);    bShow->Enable(selectedEvid != NULL &&        ((selectedEvid->IsReference() && selectedEvid->GetReference().IsPmid()) ||         IS_STRUCTURE_EVIDENCE_BSANNOT(*selectedEvid) || selectedEvid->IsComment()));    bEvidUp->Enable(evids->GetSelection() > 0 && !readOnly);    bEvidDown->Enable(evids->GetSelection() < evids->GetCount() - 1 && !readOnly);}void CDDAnnotateDialog::NewAnnotation(void){    IntervalList intervals;    GetCurrentHighlightedIntervals(&intervals);    if (intervals.size() == 0) {        ERRORMSG("No aligned+highlighted master residues!");        return;    }    // get description from user    wxString descr = wxGetTextFromUser(        "Enter a description for the new annotation:", "Description");    if (descr.size() == 0) return;    // create a new annotation    CRef < CAlign_annot > annot(new CAlign_annot());    annot->SetDescription(descr.c_str());    // fill out location    if (intervals.size() == 1) {        annot->SetLocation().SetInt(*(intervals.front()));    } else {        CPacked_seqint *packed = new CPacked_seqint();        packed->Set() = intervals;  // copy list        annot->SetLocation().SetPacked_int(*packed);    }    // add to annotation list    annotSet->Set().push_back(annot);    structureSet->SetDataChanged(StructureSet::eUserAnnotationData);    // update GUI    SetupGUIControls(annotSet->Get().size() - 1, 0);}void CDDAnnotateDialog::DeleteAnnotation(void){    // get selection    DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(annots, ID_L_ANNOT, wxListBox)    if (annots->GetCount() == 0 || annots->GetSelection() < 0) return;    CAlign_annot *selectedAnnot =        reinterpret_cast<CAlign_annot*>(annots->GetClientData(annots->GetSelection()));    if (!selectedAnnot) {        ERRORMSG("CDDAnnotateDialog::DeleteAnnotation() - error getting annotation pointer");        return;    }    // confirm with user    int confirm = wxMessageBox("This will remove the selected annotation and all the\n"        "evidence associated with it. Is this correct?", "Confirm", wxOK | wxCANCEL | wxCENTRE, this);    if (confirm != wxOK) return;    // actually delete the annotation    CAlign_annot_set::Tdata::iterator a, ae = annotSet->Set().end();    for (a=annotSet->Set().begin(); a!=ae; ++a) {        if (*a == selectedAnnot) {            annotSet->Set().erase(a);            structureSet->SetDataChanged(StructureSet::eUserAnnotationData);            break;        }    }    // update GUI    SetupGUIControls(0, 0);}void CDDAnnotateDialog::EditAnnotation(void){    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 selection    if (annots->GetCount() == 0 || annots->GetSelection() < 0) return;    CAlign_annot *selectedAnnot =        reinterpret_cast<CAlign_annot*>(annots->GetClientData(annots->GetSelection()));    if (!selectedAnnot) {        ERRORMSG("CDDAnnotateDialog::EditAnnotation() - error getting annotation pointer");        return;    }    IntervalList intervals;    GetCurrentHighlightedIntervals(&intervals);    if (intervals.size() > 0) {        // move the annotation?        int move = wxMessageBox("Do you want to move the annotation to the currently\n"            "highlighted and aligned residues?", "Move?", wxYES_NO | wxCANCEL | wxCENTRE, this);        if (move == wxCANCEL)            return;        else if (move == wxYES) {            // change location            if (intervals.size() == 1) {                selectedAnnot->SetLocation().SetInt(*(intervals.front()));            } else {                CPacked_seqint *packed = new CPacked_seqint();                packed->Set() = intervals;  // copy list                selectedAnnot->SetLocation().SetPacked_int(*packed);            }            structureSet->SetDataChanged(StructureSet::eUserAnnotationData);        }    }    // edit description    wxString initial;    if (selectedAnnot->IsSetDescription()) initial = selectedAnnot->GetDescription().c_str();    wxString descr = wxGetTextFromUser(        "Enter a description for the new annotation:", "Description", initial);    if (descr.size() > 0 && descr != selectedAnnot->GetDescription().c_str()) {        selectedAnnot->SetDescription(descr.c_str());        structureSet->SetDataChanged(StructureSet::eUserAnnotationData);    }    // update GUI    SetupGUIControls(annots->GetSelection(), evids->GetSelection());}bool CDDAnnotateDialog::HighlightInterval(const ncbi::objects::CSeq_interval& interval){    const BlockMultipleAlignment *alignment = structureSet->alignmentManager->GetCurrentMultipleAlignment();    const Sequence *master = alignment->GetMaster();    // make sure annotation sequence matches master sequence    if (!master->identifier->MatchesSeqId(interval.GetId())) {        ERRORMSG("CDDAnnotateDialog::HighlightInterval() - interval Seq-id/master sequence mismatch");        return false;    }    // do the highlighting    return alignment->HighlightAlignedColumnsOfMasterRange(interval.GetFrom(), interval.GetTo());}void CDDAnnotateDialog::HighlightAnnotation(void){    DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(annots, ID_L_ANNOT, wxListBox)    // get selection    if (annots->GetCount() == 0 || annots->GetSelection() < 0) return;    CAlign_annot *selectedAnnot =        reinterpret_cast<CAlign_annot*>(annots->GetClientData(annots->GetSelection()));    if (!selectedAnnot) {        ERRORMSG("CDDAnnotateDialog::HighlightAnnotation() - error getting annotation pointer");        return;    }    // highlight annotation's intervals    GlobalMessenger()->RemoveAllHighlights(true);    bool okay = true;    if (selectedAnnot->GetLocation().IsInt()) {        okay = HighlightInterval(selectedAnnot->GetLocation().GetInt());    } else if (selectedAnnot->GetLocation().IsPacked_int()) {        CPacked_seqint::Tdata::iterator s,            se = selectedAnnot->SetLocation().SetPacked_int().Set().end();        for (s=selectedAnnot->SetLocation().SetPacked_int().Set().begin(); s!=se; ++s) {            if (!HighlightInterval(**s))                okay = false;        }    }    if (!okay)        wxMessageBox("WARNING: this annotation specifies master residues outside the aligned blocks;"            " see the message log for details.", "Annotation Error",            wxOK | wxCENTRE | wxICON_ERROR, this);}void CDDAnnotateDialog::MoveAnnotation(bool moveUp){    // get selection    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 (annots->GetCount() == 0 || annots->GetSelection() < 0) return;    CAlign_annot *selectedAnnot =        reinterpret_cast<CAlign_annot*>(annots->GetClientData(annots->GetSelection()));    if (!selectedAnnot) {        ERRORMSG("CDDAnnotateDialog::MoveAnnotation() - error getting annotation pointer");        return;    }    CAlign_annot_set::Tdata::iterator a, ae = annotSet->Set().end(), aPrev = ae, aSwap = ae;    CRef < CAlign_annot > tmp;    for (a=annotSet->Set().begin(); a!=ae; ++a) {        if (*a == selectedAnnot) {            // figure out which (prev or next) annot field to swap with            if (moveUp && aPrev != ae)                aSwap = aPrev;            else if (!moveUp && (++(aSwap = a)) != ae)                ;            else                return;            // do the swap and update GUI            tmp = *aSwap;            *aSwap = *a;            *a = tmp;            structureSet->SetDataChanged(StructureSet::eUserAnnotationData);            SetupGUIControls(annots->GetSelection() + (moveUp ? -1 : 1), evids->GetSelection());            return;        }        aPrev = a;    }    ERRORMSG("CDDAnnotateDialog::MoveAnnotation() - error finding selected annotation");}void CDDAnnotateDialog::NewEvidence(void){    DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(annots, ID_L_ANNOT, 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::NewEvidence() - error getting annotation pointer");        return;    }    // create default comment evidence    CRef < CFeature_evidence > newEvidence(new CFeature_evidence());    newEvidence->SetComment("");    // bring up evidence editor    CDDEvidenceDialog dialog(this, *newEvidence);    int result = dialog.ShowModal();    // add new evidence    if (result == wxOK) {        if (dialog.GetData(newEvidence.GetPointer())) {            selectedAnnot->SetEvidence().push_back(newEvidence);            SetupGUIControls(annots->GetSelection(), selectedAnnot->GetEvidence().size() - 1);            structureSet->SetDataChanged(StructureSet::eUserAnnotationData);        } else            ERRORMSG("CDDAnnotateDialog::NewEvidence() - error getting dialog data");    }}void CDDAnnotateDialog::DeleteEvidence(void){    // get selected annotation    DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(annots, ID_L_ANNOT, wxListBox)    if (annots->GetCount() == 0 || annots->GetSelection() < 0) return;    CAlign_annot *selectedAnnot =        reinterpret_cast<CAlign_annot*>(annots->GetClientData(annots->GetSelection()));    if (!selectedAnnot) {        ERRORMSG("CDDAnnotateDialog::DeleteEvidence() - error getting annotation pointer");        return;    }    // 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::DeleteEvidence() - error getting evidence pointer");        return;    }    // confirm with user    int confirm = wxMessageBox("This will remove the selected evidence from\n"        "the selected annotation. Is this correct?", "Confirm", wxOK | wxCANCEL | wxCENTRE, this);    if (confirm != wxOK) return;    // delete evidence from annotation's list    CAlign_annot::TEvidence::iterator e, ee = selectedAnnot->SetEvidence().end();    for (e=selectedAnnot->SetEvidence().begin(); e!=ee; ++e) {        if (*e == selectedEvidence) {            selectedAnnot->SetEvidence().erase(e);            structureSet->SetDataChanged(StructureSet::eUserAnnotationData);            break;        }    }    if (e == ee) {        ERRORMSG("CDDAnnotateDialog::DeleteEvidence() - evidence pointer not found in annotation");        return;    }    // update GUI    SetupGUIControls(annots->GetSelection(), 0);}void CDDAnnotateDialog::EditEvidence(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::DeleteEvidence() - error getting evidence pointer");        return;    }    // bring up evidence editor    CDDEvidenceDialog dialog(this, *selectedEvidence);    int result = dialog.ShowModal();    // update evidence    if (result == wxOK && dialog.HasDataChanged()) {        if (dialog.GetData(selectedEvidence)) {            DECLARE_AND_FIND_WINDOW_RETURN_ON_ERR(annots, ID_L_ANNOT, wxListBox)            structureSet->SetDataChanged(StructureSet::eUserAnnotationData);            SetupGUIControls(annots->GetSelection(), evids->GetSelection());        } else            ERRORMSG("CDDAnnotateDialog::EditEvidence() - error getting dialog data");    }}typedef struct {    int alignedMoleculeID;    int from, to;    int hits;} ChainInfo;static const StructureObject * HighlightResidues(const StructureSet *set, const CBiostruc_annot_set& annot){    try {        if (!annot.IsSetId() || annot.GetId().size() == 0 || !annot.GetId().front()->IsMmdb_id())

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -