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

📄 structure_set.cpp

📁 ncbi源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
/* * =========================================================================== * PRODUCTION $Log: structure_set.cpp,v $ * PRODUCTION Revision 1000.2  2004/06/01 18:29:28  gouriano * PRODUCTION PRODUCTION: UPGRADED [GCC34_MSVC7] Dev-tree R1.141 * PRODUCTION * =========================================================================== *//*  $Id: structure_set.cpp,v 1000.2 2004/06/01 18:29:28 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:*      Classes to hold sets of structure data** ===========================================================================*/#ifdef _MSC_VER#pragma warning(disable:4018)   // disable signed/unsigned mismatch warning in MSVC#endif#include <ncbi_pch.hpp>#include <corelib/ncbistd.hpp>#include <corelib/ncbistre.hpp>#include <corelib/ncbi_limits.h>#include <corelib/ncbistl.hpp>#include <deque>#include <objects/ncbimime/Biostruc_seq.hpp>#include <objects/ncbimime/Biostruc_seqs.hpp>#include <objects/ncbimime/Biostruc_align.hpp>#include <objects/ncbimime/Entrez_general.hpp>#include <objects/mmdb1/Biostruc_id.hpp>#include <objects/mmdb1/Mmdb_id.hpp>#include <objects/mmdb1/Biostruc_descr.hpp>#include <objects/mmdb2/Biostruc_model.hpp>#include <objects/mmdb2/Model_type.hpp>#include <objects/mmdb3/Biostruc_feature.hpp>#include <objects/mmdb3/Biostruc_feature_id.hpp>#include <objects/mmdb3/Chem_graph_alignment.hpp>#include <objects/mmdb3/Transform.hpp>#include <objects/mmdb3/Move.hpp>#include <objects/mmdb3/Trans_matrix.hpp>#include <objects/mmdb3/Rot_matrix.hpp>#include <objects/mmdb3/Chem_graph_pntrs.hpp>#include <objects/mmdb3/Residue_pntrs.hpp>#include <objects/mmdb3/Residue_interval_pntr.hpp>#include <objects/seqset/Bioseq_set.hpp>#include <objects/cn3d/Cn3d_style_dictionary.hpp>#include <objects/cn3d/Cn3d_user_annotations.hpp>#include <objects/seqalign/Dense_diag.hpp>#include <objects/seqalign/Dense_seg.hpp>#include <objects/mmdb3/Biostruc_feature_set_id.hpp>#include <objects/mmdb1/Molecule_id.hpp>#include <objects/mmdb1/Residue_id.hpp>#include <objects/cdd/Reject_id.hpp>#include <objects/cdd/Update_comment.hpp>#include "structure_set.hpp"#include "data_manager.hpp"#include "coord_set.hpp"#include "chemical_graph.hpp"#include "atom_set.hpp"#include "opengl_renderer.hpp"#include "show_hide_manager.hpp"#include "style_manager.hpp"#include "sequence_set.hpp"#include "alignment_set.hpp"#include "alignment_manager.hpp"#include "messenger.hpp"#include "asn_converter.hpp"#include "block_multiple_alignment.hpp"#include "cn3d_tools.hpp"#include "molecule_identifier.hpp"#include "cn3d_cache.hpp"#include "molecule.hpp"#include "residue.hpp"#include "show_hide_dialog.hpp"#include <objseq.h>USING_NCBI_SCOPE;USING_SCOPE(objects);BEGIN_SCOPE(Cn3D)const unsigned int    StructureSet::ePSSMData                   = 0x01,    StructureSet::eRowOrderData               = 0x02,    StructureSet::eAnyAlignmentData           = 0x04,    StructureSet::eStructureAlignmentData     = 0x08,    StructureSet::eSequenceData               = 0x10,    StructureSet::eUpdateData                 = 0x20,    StructureSet::eStyleData                  = 0x40,    StructureSet::eUserAnnotationData         = 0x80,    StructureSet::eCDDData                    = 0x100,    StructureSet::eOtherData                  = 0x200;StructureSet::StructureSet(CNcbi_mime_asn1 *mime, int structureLimit, OpenGLRenderer *r) :    StructureBase(NULL), renderer(r){    dataManager = new ASNDataManager(mime);    Load(structureLimit);}StructureSet::StructureSet(CCdd *cdd, int structureLimit, OpenGLRenderer *r) :    StructureBase(NULL), renderer(r){    dataManager = new ASNDataManager(cdd);    Load(structureLimit);}void StructureSet::LoadSequencesForSingleStructure(void){    sequenceSet = new SequenceSet(this, *(dataManager->GetSequences()));    if (objects.size() > 1)        ERRORMSG("LoadSequencesForSingleStructure() called, but there is > 1 structure");    if (objects.size() != 1) return;    // look for biopolymer molecules    ChemicalGraph::MoleculeMap::const_iterator m, me = objects.front()->graph->molecules.end();    SequenceSet::SequenceList::const_iterator s, se = sequenceSet->sequences.end();    for (m=objects.front()->graph->molecules.begin(); m!=me; ++m) {        if (!m->second->IsProtein() && !m->second->IsNucleotide()) continue;        // find matching sequence for each biopolymer        for (s=sequenceSet->sequences.begin(); s!=se; ++s) {            if ((*s)->molecule != NULL) continue; // skip already-matched sequences            if (m->second->identifier == (*s)->identifier) {                // verify length                if (m->second->residues.size() != (*s)->Length()) {                    ERRORMSG(                        "LoadSequencesForSingleStructure() - length mismatch between sequence gi "                        << "and matching molecule " << m->second->identifier->ToString());                    continue;                }                TRACEMSG("matched sequence " << " gi " << (*s)->identifier->gi << " with object "                    << objects.front()->pdbID << " moleculeID " << m->second->id);                (const_cast<Molecule*>(m->second))->sequence = *s;                (const_cast<Sequence*>(*s))->molecule = m->second;                break;            }        }        if (s == se)            ERRORMSG("LoadSequencesForSingleStructure() - can't find sequence for molecule "                << m->second->identifier->ToString());    }}bool StructureSet::LoadMaster(int masterMMDBID){    if (objects.size() > 0) return false;    TRACEMSG("loading master " << masterMMDBID);    if (dataManager->GetMasterStructure()) {        objects.push_back(new StructureObject(this, *(dataManager->GetMasterStructure()), true));        if (masterMMDBID != MoleculeIdentifier::VALUE_NOT_SET && objects.front()->mmdbID != masterMMDBID)            ERRORMSG("StructureSet::LoadMaster() - mismatched master MMDB ID");    } else if (masterMMDBID != MoleculeIdentifier::VALUE_NOT_SET && dataManager->GetStructureList()) {        ASNDataManager::BiostrucList::const_iterator b, be = dataManager->GetStructureList()->end();        for (b=dataManager->GetStructureList()->begin(); b!=be; ++b) {            if ((*b)->GetId().front()->IsMmdb_id() &&                (*b)->GetId().front()->GetMmdb_id().Get() == masterMMDBID) {                objects.push_back(new StructureObject(this, **b, true));                usedStructures[b->GetPointer()] = true;                break;            }        }    }    if (masterMMDBID != MoleculeIdentifier::VALUE_NOT_SET && objects.size() == 0) {        CRef < CBiostruc > biostruc;        wxString id;        id.Printf("%i", masterMMDBID);        if (LoadStructureViaCache(id.c_str(), dataManager->GetBiostrucModelType(), biostruc, NULL))            objects.push_back(new StructureObject(this, *biostruc, true));    }    return (objects.size() > 0);}bool StructureSet::MatchSequenceToMoleculeInObject(const Sequence *seq,    const StructureObject *obj, const Sequence **seqHandle){    ChemicalGraph::MoleculeMap::const_iterator m, me = obj->graph->molecules.end();    for (m=obj->graph->molecules.begin(); m!=me; ++m) {        if (!(m->second->IsProtein() || m->second->IsNucleotide())) continue;        if (m->second->identifier == seq->identifier) {            // verify length            if (m->second->residues.size() != seq->Length()) {                ERRORMSG(                    "MatchSequenceToMoleculeInObject() - length mismatch between sequence gi "                    << "and matching molecule " << m->second->identifier->ToString());                continue;            }            TRACEMSG("matched sequence " << " gi " << seq->identifier->gi << " with object "                << obj->pdbID << " moleculeID " << m->second->id);            // sanity check            if (m->second->sequence) {                ERRORMSG("Molecule " << m->second->identifier->ToString()                    << " already has an associated sequence");                continue;            }            // automatically duplicate Sequence if it's already associated with a molecule            if (seq->molecule) {                TRACEMSG("duplicating sequence " << seq->identifier->ToString());				SequenceSet *seqSetMod = const_cast<SequenceSet*>(sequenceSet);                CBioseq& bioseqMod = const_cast<CBioseq&>(seq->bioseqASN.GetObject());                seq = new Sequence(seqSetMod, bioseqMod);                seqSetMod->sequences.push_back(seq);                // update Sequence handle, which should be a handle to a MasterSlaveAlignment slave,                // so that this new Sequence* is correctly loaded into the BlockMultipleAlignment                if (seqHandle) *seqHandle = seq;            }            // do the cross-match            (const_cast<Molecule*>(m->second))->sequence = seq;            (const_cast<Sequence*>(seq))->molecule = m->second;            break;        }    }    return (m != me);}static void SetStructureRowFlags(const AlignmentSet *alignmentSet, int *structureLimit,    vector < bool > *dontLoadRowStructure){    vector < string > titles;    vector < int > rows;    // find slave rows with associated structure    AlignmentSet::AlignmentList::const_iterator l, le = alignmentSet->alignments.end();    int row;    for (l=alignmentSet->alignments.begin(), row=0; l!=le; ++l, ++row) {        if ((*l)->slave->identifier->mmdbID != MoleculeIdentifier::VALUE_NOT_SET) {            titles.push_back((*l)->slave->identifier->ToString());            rows.push_back(row);        }    }    if (*structureLimit - 1 >= titles.size()) return;    // let user select which slaves to load    wxString *items = new wxString[titles.size()];    vector < bool > itemsOn(titles.size(), false);    for (row=0; row<titles.size(); ++row) {        items[row] = titles[row].c_str();        if (row < *structureLimit - 1)      // by default, first N-1 are selected            itemsOn[row] = true;    }    ShowHideDialog dialog(items, &itemsOn, NULL, true, NULL, -1, "Choose structures:");    if (dialog.ShowModal() == wxOK) {        // figure out which rows the user selected, and adjust structureLimit accordingly        *structureLimit = 1;     // master always visible        for (row=0; row<itemsOn.size(); ++row) {            if (itemsOn[row])                (*structureLimit)++;                        // structure should be loaded            else                (*dontLoadRowStructure)[rows[row]] = true;  // structure should not be loaded        }    }    delete[] items;}void StructureSet::LoadAlignmentsAndStructures(int structureLimit)

⌨️ 快捷键说明

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