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

📄 structure_set.cpp

📁 ncbi源码
💻 CPP
📖 第 1 页 / 共 5 页
字号:
        if (!alignment->IsAligned(0, r->first - 1)) continue;        if (r->second->alphaID == Residue::NO_ALPHA_ID) continue;        AtomPntr ap(masterMolecule->id, r->first, r->second->alphaID);        const AtomCoord* atom = masterObject->coordSets.front()->atomSet->GetAtom(ap, true, true);        if (atom) coords.push_back(atom->site);    }    // calculate center    int i;    Vector alignedCenter;    for (i=0; i<coords.size(); ++i) alignedCenter += coords[i];    alignedCenter /= coords.size();    // find radius    double radius = 0.0, d;    for (i=0; i<coords.size(); ++i) {        d = (coords[i] - alignedCenter).length();        if (d > radius) radius = d;    }    // set view    renderer->CenterView(alignedCenter, radius);}bool StructureSet::Draw(const AtomSet *atomSet) const{    TRACEMSG("drawing StructureSet");    if (!styleManager->CheckGlobalStyleSettings()) return false;    return true;}unsigned int StructureSet::CreateName(const Residue *residue, int atomID){    ++lastAtomName;    nameMap[lastAtomName] = make_pair(residue, atomID);    return lastAtomName;}bool StructureSet::GetAtomFromName(unsigned int name, const Residue **residue, int *atomID) const{    NameMap::const_iterator i = nameMap.find(name);    if (i == nameMap.end()) return false;    *residue = i->second.first;    *atomID = i->second.second;	return true;}void StructureSet::SelectedAtom(unsigned int name, bool setCenter){    const Residue *residue;    int atomID;    if (name == OpenGLRenderer::NO_NAME || !GetAtomFromName(name, &residue, &atomID)) {        INFOMSG("nothing selected");        return;    }    // add highlight    const Molecule *molecule;    if (!residue->GetParentOfType(&molecule)) return;    GlobalMessenger()->ToggleHighlight(molecule, residue->id, true);    wxString molresid;    if (molecule->IsHeterogen() || molecule->IsSolvent()) {        const StructureObject *object;        if (molecule->GetParentOfType(&object)) {            // assume hets/solvents are single residue            if (object->pdbID.size() > 0)                molresid.Printf("%s heterogen/solvent molecule %i", object->pdbID.c_str(), molecule->id);            else                molresid = molecule->identifier->ToString().c_str();        }    } else        molresid.Printf("chain %s residue %i", molecule->identifier->ToString().c_str(), residue->id);    INFOMSG("selected " << molresid.c_str() << " (PDB: " << residue->nameGraph << ' ' << residue->namePDB        << ") atom " << atomID << " (PDB: " << residue->GetAtomInfo(atomID)->name << ')');    // get coordinate of picked atom, in coordinates of master frame    const StructureObject *object;    if (!molecule->GetParentOfType(&object)) return;    object->coordSets.front()->atomSet->SetActiveEnsemble(NULL);    // don't actually know which alternate...    Vector pickedAtomCoord = object->coordSets.front()->atomSet->        GetAtom(AtomPntr(molecule->id, residue->id, atomID)) ->site;    if (object->IsSlave() && object->transformToMaster)        ApplyTransformation(&pickedAtomCoord, *(object->transformToMaster));    // print out distance to previous picked atom    if (havePrevPickedAtomCoord)        INFOMSG("distance to previously selected atom: " << setprecision(3) <<            (pickedAtomCoord - prevPickedAtomCoord).length() << setprecision(6) << " A");    prevPickedAtomCoord = pickedAtomCoord;    havePrevPickedAtomCoord = true;    // if indicated, use atom site as rotation center; use coordinate from first CoordSet, default altConf    if (setCenter) {        INFOMSG("rotating about " << object->pdbID            << " molecule " << molecule->id << " residue " << residue->id << ", atom " << atomID);        rotationCenter = pickedAtomCoord;    }}void StructureSet::SelectByDistance(double cutoff, bool biopolymersOnly, bool otherMoleculesOnly) const{    StructureObject::ResidueMap residuesToHighlight;    // add residues to highlight to master list, based on proximities within objects    ObjectList::const_iterator o, oe = objects.end();    for (o=objects.begin(); o!=oe; ++o)        (*o)->SelectByDistance(cutoff, biopolymersOnly, otherMoleculesOnly, &residuesToHighlight);    // now actually add highlights for new selected residues    StructureObject::ResidueMap::const_iterator r, re = residuesToHighlight.end();    for (r=residuesToHighlight.begin(); r!=re; ++r)        if (!GlobalMessenger()->IsHighlighted(r->second, r->first->id))            GlobalMessenger()->ToggleHighlight(r->second, r->first->id, false);}const Sequence * StructureSet::CreateNewSequence(ncbi::objects::CBioseq& bioseq){    // add Sequence to SequenceSet    SequenceSet *modifiableSet = const_cast<SequenceSet*>(sequenceSet);    const Sequence *newSeq = new Sequence(modifiableSet, bioseq);    if (!newSeq->identifier) {        ERRORMSG("StructureSet::CreateNewSequence() - identifier conflict, no new sequence created");        delete newSeq;        return NULL;    }    modifiableSet->sequences.push_back(newSeq);    // add asn sequence to asn data    if (dataManager->GetSequences()) {        CSeq_entry *se = new CSeq_entry();        se->SetSeq(bioseq);        dataManager->GetSequences()->push_back(CRef<CSeq_entry>(se));    } else        ERRORMSG("StructureSet::CreateNewSequence() - no sequence list in asn data");    SetDataChanged(eSequenceData);    return newSeq;}void StructureSet::RejectAndPurgeSequence(const Sequence *reject, string reason, bool purge){    if (!dataManager->IsCDD() || !reject || reason.size() == 0) return;    CReject_id *rejectID = new CReject_id();    rejectID->SetIds() = reject->bioseqASN->GetId();    // copy Seq-id lists    CUpdate_comment *comment = new CUpdate_comment();    comment->SetComment(reason);    rejectID->SetDescription().push_back(CRef < CUpdate_comment > (comment));    dataManager->AddReject(rejectID);    if (purge)        alignmentManager->PurgeSequence(reject->identifier);}const StructureSet::RejectList * StructureSet::GetRejects(void) const{    return dataManager->GetRejects();}void StructureSet::ShowRejects(void) const{    const RejectList *rejects = GetRejects();    if (!rejects) {        INFOMSG("No rejects in this CD");        return;    }    INFOMSG("Rejects:");    RejectList::const_iterator r, re = rejects->end();    for (r=rejects->begin(); r!=re; ++r) {        string idstr;        CReject_id::TIds::const_iterator i, ie = (*r)->GetIds().end();        for (i=(*r)->GetIds().begin(); i!=ie; ++i)            idstr += (*i)->AsFastaString() + ", ";        INFOMSG(idstr << "Reason: " <<            (((*r)->IsSetDescription() && (*r)->GetDescription().front()->IsComment()) ?                (*r)->GetDescription().front()->GetComment() : string("none given")));    }}bool StructureSet::ConvertMimeDataToCDD(const std::string& cddName){    if (!dataManager->ConvertMimeDataToCDD(cddName))        return false;    // make sure all structured sequences have MMDB annot tags    SequenceSet::SequenceList::const_iterator s, se = sequenceSet->sequences.end();    for (s=sequenceSet->sequences.begin(); s!=se; ++s) {        if ((*s)->molecule) {            if ((*s)->identifier->mmdbID == MoleculeIdentifier::VALUE_NOT_SET) {                ERRORMSG("sequence " << (*s)->identifier->ToString()                    << " has associated molecule but no MMDB id");                return false;            }            (*s)->AddMMDBAnnotTag((*s)->identifier->mmdbID);        }    }    return true;}// trivial methods...bool StructureSet::IsMultiStructure(void) const { return !dataManager->IsSingleStructure(); }bool StructureSet::HasDataChanged(void) const { return dataManager->HasDataChanged(); }void StructureSet::SetDataChanged(unsigned int what) const { dataManager->SetDataChanged(what); }bool StructureSet::IsCDD(void) const { return dataManager->IsCDD(); }bool StructureSet::IsCDDInMime(void) const { return dataManager->IsCDDInMime(); }const string& StructureSet::GetCDDName(void) const { return dataManager->GetCDDName(); }bool StructureSet::SetCDDName(const string& name) { return dataManager->SetCDDName(name); }const string& StructureSet::GetCDDDescription(void) const { return dataManager->GetCDDDescription(); }bool StructureSet::SetCDDDescription(const string& descr) { return dataManager->SetCDDDescription(descr); }bool StructureSet::GetCDDNotes(StructureSet::TextLines *lines) const { return dataManager->GetCDDNotes(lines); }bool StructureSet::SetCDDNotes(const StructureSet::TextLines& lines) { return dataManager->SetCDDNotes(lines); }ncbi::objects::CCdd_descr_set * StructureSet::GetCDDDescrSet(void) { return dataManager->GetCDDDescrSet(); }ncbi::objects::CAlign_annot_set * StructureSet::GetCDDAnnotSet(void) { return dataManager->GetCDDAnnotSet(); }///// StructureObject stuff /////const int StructureObject::NO_MMDB_ID = -1;const double StructureObject::NO_TEMPERATURE = kMin_Double;StructureObject::StructureObject(StructureBase *parent, const CBiostruc& biostruc, bool master) :    StructureBase(parent), isMaster(master), mmdbID(NO_MMDB_ID), transformToMaster(NULL),    minTemperature(NO_TEMPERATURE), maxTemperature(NO_TEMPERATURE){    // set numerical id simply based on # objects in parentSet    id = parentSet->objects.size() + 1;    // get MMDB id    CBiostruc::TId::const_iterator j, je=biostruc.GetId().end();    for (j=biostruc.GetId().begin(); j!=je; ++j) {        if (j->GetObject().IsMmdb_id()) {            mmdbID = j->GetObject().GetMmdb_id().Get();            break;        }    }    TRACEMSG("MMDB id " << mmdbID);    // get PDB id    if (biostruc.IsSetDescr()) {        CBiostruc::TDescr::const_iterator k, ke=biostruc.GetDescr().end();        for (k=biostruc.GetDescr().begin(); k!=ke; ++k) {            if (k->GetObject().IsName()) {                pdbID = k->GetObject().GetName();                break;            }        }    }    TRACEMSG("PDB id " << pdbID);    // get atom and feature spatial coordinates    if (biostruc.IsSetModel()) {        // iterate SEQUENCE OF Biostruc-model        CBiostruc::TModel::const_iterator i, ie=biostruc.GetModel().end();        for (i=biostruc.GetModel().begin(); i!=ie; ++i) {            // don't know how to deal with these...            if (i->GetObject().GetType() == eModel_type_ncbi_vector ||                i->GetObject().GetType() == eModel_type_other) continue;//            // special case, typically for loading CDD's, when we're only interested in a single model type//            if (isRawBiostrucFromMMDB && i->GetObject().GetType() != eModel_type_ncbi_all_atom) continue;            // otherwise, assume all models in this set are of same type            if (i->GetObject().GetType() == eModel_type_ncbi_backbone)                parentSet->isAlphaOnly = true;            else                parentSet->isAlphaOnly = false;            // load each Biostruc-model into a CoordSet            if (i->GetObject().IsSetModel_coordinates()) {                CoordSet *coordSet =                    new CoordSet(this, i->GetObject().GetModel_coordinates());                coordSets.push_back(coordSet);            }        }    }    TRACEMSG("temperature range: " << minTemperature << " to " << maxTemperature);    // get graph - must be done after atom coordinates are loaded, so we can    // avoid storing graph nodes for atoms not present in the model    graph = new ChemicalGraph(this, biostruc.GetChemical_graph(), biostruc.GetFeatures());}bool StructureObject::SetTransformToMaster(const CBiostruc_annot_set& annot, int masterMMDBID){    CBiostruc_annot_set::TFeatures::const_iterator f1, f1e=annot.GetFeatures().end();    for (f1=annot.GetFeatures().begin(); f1!=f1e; ++f1) {        CBiostruc_feature_set::TFeatures::const_iterator f2, f2e=f1->GetObject().GetFeatures().end();        for (f2=f1->GetObject().GetFeatures().begin(); f2!=f2e; ++f2) {            // skip if already used            if (f2->GetObject().IsSetId() &&                    parentSet->usedFeatures.find(f2->GetObject().GetId().Get()) !=

⌨️ 快捷键说明

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