File size: 3,642 Bytes
8efb4bd
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#ifndef BB_H
#define BB_H

#include "BBGrid.h"
#include "TransformationAndScore.h"
#include "BitId.h"

#include <ChemMolecule.h>
#include <GeomScore.h>
#include <RigidTrans3.h>
#include <Surface.h>
#include <Vector3.h>

#include <vector>

class BBConstructor {
    // idea taken from
    // https://stackoverflow.com/questions/3220009/is-this-key-oriented-access-protection-pattern-a-known-idiom
  private:
    friend class BBContainer;
    BBConstructor() {}
};

class BB {
  public:
    friend class SuperBB;

    BB(int id, const std::string pdbFilename, int groupID, const ChemLib &lib, float gridResolution, float gridMargins,
       float minTempFactor);

    // access
    int getID() const { return id_; }
    BitId bitId() const { return BitId(id_); }
    int groupId() const { return groupId_; }
    std::string getPDBFileName() const { return pdbFileName_; }

    unsigned int getNumOfAtoms() const { return numOfAtoms_; }
    const Vector3 &getCM() const { return cm_; }
    const float getRadius() const { return maxRadius_; }

    const ChemAtom &getChemAtom(int atomIndex) const { return allAtoms_.getChemAtom(atomIndex); }
    const ChemAtom &getChemAtomByIndex(int atomIndex) const { return allAtoms_[atomIndex]; }
    const Atom &getAtomByResId(unsigned int resId) const { return resIndexToCAAtom.at(resId); }

    unsigned int getSurfaceSize() const { return surface_.size(); }
    float getDistFromSurface(const Vector3 &v) const { return grid_->getDist(v); }


    // This uses BBConstructor to make sure that only BBContainer can call this
    void putTransWith(int bbIndex, const std::shared_ptr<TransformationAndScore> &t1, const BBConstructor &) const {
        trans_[bbIndex].push_back(t1);
    }
    void initTrans(unsigned int numberOfBBs, const BBConstructor &) const {
        trans_.insert(trans_.begin(), numberOfBBs, std::vector<std::shared_ptr<TransformationAndScore>>());
    }

    // TODO: do we still need isPenetrating/maxPenetration ?
    bool isPenetrating(const RigidTrans3 &trans, const BB &other, float threshold) const;
    float maxPenetration(const RigidTrans3 &trans, const BB &other) const;

    void getChainConnectivityConstraints(const BB &bb,

                                         std::vector<std::pair<char, std::pair<int, int>>> &) const; // update

    const std::vector<std::shared_ptr<TransformationAndScore>> &getTransformations(int bbIndex) const {
        return trans_[bbIndex];
    }

    bool isIdent(const BB &otherBB) const;
    
  private:
    // after BB is initialized, compute chains and fragment ranges
    void computeFragments(float minTempFactor);

  private:
    // surface points
    // Different methods for computing collision
    Surface surface_;                  // shuo
    Surface msSurface_;                // connolly - dense

    // BB id
    unsigned int id_;

    // transformations to other BBs
    // This is the edge in a graph - The result of a patch dock calculation
    mutable std::vector<std::vector<std::shared_ptr<TransformationAndScore>>> trans_;

    int groupId_;
    std::string pdbFileName_;
    int numOfAtoms_;

    Vector3 cm_;
    float maxRadius_;

    // chain id and residue numbers for each chain fragment in BB
    typedef std::pair<int, int> ResidueRange;
    std::vector<std::pair<char, ResidueRange>> fragmentEndpoints_;

  public: // TODO
    BBGrid *grid_;
    ChemMolecule backBone_;
    ChemMolecule allAtoms_;
    Molecule<Atom> caAtoms_;
    std::map<unsigned int, Atom> resIndexToCAAtom;
};

#endif /* BB_H */