Skip to content
Snippets Groups Projects
Commit 884a473e authored by Studer Gabriel's avatar Studer Gabriel
Browse files

make distance constraints useful

parent ff0dc917
No related branches found
No related tags found
No related merge requests found
...@@ -53,6 +53,7 @@ def _GetWeights(): ...@@ -53,6 +53,7 @@ def _GetWeights():
weights["reduced"] = 2.13535565 weights["reduced"] = 2.13535565
weights["cbeta"] = 3.59177335 weights["cbeta"] = 3.59177335
weights["cb_packing"] = 1.17280667 weights["cb_packing"] = 1.17280667
weights["constraint"] = -0.7
return weights return weights
def _CloseLoopFrame(mhandle, scorer, gap_orig, actual_candidates, def _CloseLoopFrame(mhandle, scorer, gap_orig, actual_candidates,
......
...@@ -403,7 +403,7 @@ def CheckFinalModel(mhandle): ...@@ -403,7 +403,7 @@ def CheckFinalModel(mhandle):
ost.LogInfo("Stereo-chemical problem in sidechain " + \ ost.LogInfo("Stereo-chemical problem in sidechain " + \
"of residue " + str(res)) "of residue " + str(res))
def BuildFromRawModel(mhandle, use_amber_ff=False, extra_force_fields=list()): def BuildFromRawModel(mhandle, scorer = None, use_amber_ff=False, extra_force_fields=list()):
'''Build a model starting with a raw model (see :func:`BuildRawModel`). '''Build a model starting with a raw model (see :func:`BuildRawModel`).
This function implements a recommended pipeline to generate complete models This function implements a recommended pipeline to generate complete models
...@@ -453,7 +453,8 @@ def BuildFromRawModel(mhandle, use_amber_ff=False, extra_force_fields=list()): ...@@ -453,7 +453,8 @@ def BuildFromRawModel(mhandle, use_amber_ff=False, extra_force_fields=list()):
torsion_sampler = loop.LoadTorsionSamplerCoil() torsion_sampler = loop.LoadTorsionSamplerCoil()
merge_distance = 4 merge_distance = 4
scorer = SetupBackboneScorer(mhandle) if scorer == None:
scorer = SetupBackboneScorer(mhandle)
# remove terminal gaps and close small deletions # remove terminal gaps and close small deletions
RemoveTerminalGaps(mhandle) RemoveTerminalGaps(mhandle)
......
...@@ -114,7 +114,8 @@ void ExtractPositions(const ost::seq::AlignmentHandle& aln, ...@@ -114,7 +114,8 @@ void ExtractPositions(const ost::seq::AlignmentHandle& aln,
ost::seq::ConstSequenceHandle seqres = aln.GetSequence(0); ost::seq::ConstSequenceHandle seqres = aln.GetSequence(0);
ost::seq::ConstSequenceHandle seq; ost::seq::ConstSequenceHandle seq;
ost::mol::ResidueView res; ost::mol::ResidueView res;
ost::mol::AtomView ca; ost::mol::AtomView cb;
geom::Vec3 pos;
for(int seq_idx = 1; seq_idx < aln.GetCount(); ++seq_idx){ for(int seq_idx = 1; seq_idx < aln.GetCount(); ++seq_idx){
...@@ -133,15 +134,24 @@ void ExtractPositions(const ost::seq::AlignmentHandle& aln, ...@@ -133,15 +134,24 @@ void ExtractPositions(const ost::seq::AlignmentHandle& aln,
continue; continue;
} }
ca = res.FindAtom("CA"); cb = res.FindAtom("CB");
if(!ca.IsValid()){ if(cb.IsValid()){
positions[seq_idx-1].push_back(geom::Vec3()); pos = cb.GetPos();
valid_residues[seq_idx-1].push_back(false); }
continue; else{
ost::mol::AtomView n = res.FindAtom("N");
ost::mol::AtomView ca = res.FindAtom("CA");
ost::mol::AtomView c = res.FindAtom("C");
if(! (n.IsValid() && ca.IsValid() && c.IsValid())){
positions[seq_idx-1].push_back(geom::Vec3());
valid_residues[seq_idx-1].push_back(false);
continue;
}
promod3::core::ConstructCBetaPos(n.GetPos(),ca.GetPos(),c.GetPos(),pos);
} }
positions[seq_idx-1].push_back(ca.GetPos()); positions[seq_idx-1].push_back(pos);
valid_residues[seq_idx-1].push_back(true); valid_residues[seq_idx-1].push_back(true);
} }
} }
...@@ -154,7 +164,7 @@ bool GenerateDisCo(const std::vector<std::vector<bool> >& valid_residues, ...@@ -154,7 +164,7 @@ bool GenerateDisCo(const std::vector<std::vector<bool> >& valid_residues,
uint resnum_one, uint resnum_two, uint resnum_one, uint resnum_two,
std::vector<Real>& disco){ std::vector<Real>& disco){
disco.assign(15, 0.0); disco.assign(17, 0.0);
int idx_one = resnum_one - 1; int idx_one = resnum_one - 1;
int idx_two = resnum_two - 1; int idx_two = resnum_two - 1;
...@@ -168,7 +178,7 @@ bool GenerateDisCo(const std::vector<std::vector<bool> >& valid_residues, ...@@ -168,7 +178,7 @@ bool GenerateDisCo(const std::vector<std::vector<bool> >& valid_residues,
for(uint cluster_idx = 0; cluster_idx < clusters.size(); ++cluster_idx){ for(uint cluster_idx = 0; cluster_idx < clusters.size(); ++cluster_idx){
std::vector<Real> cluster_function(15, 0.0); std::vector<Real> cluster_function(17, 0.0);
int num_gaussians = 0; int num_gaussians = 0;
for(uint cluster_ele_idx = 0; cluster_ele_idx < clusters[cluster_idx].size(); for(uint cluster_ele_idx = 0; cluster_ele_idx < clusters[cluster_idx].size();
...@@ -186,7 +196,7 @@ bool GenerateDisCo(const std::vector<std::vector<bool> >& valid_residues, ...@@ -186,7 +196,7 @@ bool GenerateDisCo(const std::vector<std::vector<bool> >& valid_residues,
//check, whether positions are close in space //check, whether positions are close in space
// (closer than 17 Angstrom) // (closer than 17 Angstrom)
if(distance > Real(289.0)) continue; if(distance > Real(225.0)) continue;
distance = std::sqrt(distance); distance = std::sqrt(distance);
...@@ -194,7 +204,7 @@ bool GenerateDisCo(const std::vector<std::vector<bool> >& valid_residues, ...@@ -194,7 +204,7 @@ bool GenerateDisCo(const std::vector<std::vector<bool> >& valid_residues,
//Let's add a gausssian function at this position! //Let's add a gausssian function at this position!
Real function_pos = 0.5; Real function_pos = 0.5;
Real temp; Real temp;
for(int i = 0; i < 15; ++i, function_pos += 1.0){ for(int i = 0; i < 17; ++i, function_pos += 1.0){
temp = function_pos - distance; temp = function_pos - distance;
cluster_function[i] += std::exp(-Real(0.5) * temp * temp); cluster_function[i] += std::exp(-Real(0.5) * temp * temp);
} }
...@@ -205,7 +215,7 @@ bool GenerateDisCo(const std::vector<std::vector<bool> >& valid_residues, ...@@ -205,7 +215,7 @@ bool GenerateDisCo(const std::vector<std::vector<bool> >& valid_residues,
if(num_gaussians == 0) continue; // no signal for this cluster... if(num_gaussians == 0) continue; // no signal for this cluster...
Real factor = Real(1.0) / num_gaussians; Real factor = Real(1.0) / num_gaussians;
for(uint i = 0; i < 15; ++i){ for(uint i = 0; i < 17; ++i){
cluster_function[i] *= factor; cluster_function[i] *= factor;
} }
...@@ -228,7 +238,7 @@ bool GenerateDisCo(const std::vector<std::vector<bool> >& valid_residues, ...@@ -228,7 +238,7 @@ bool GenerateDisCo(const std::vector<std::vector<bool> >& valid_residues,
//let's smash everything together... //let's smash everything together...
for(uint i = 0; i < cluster_functions.size(); ++i){ for(uint i = 0; i < cluster_functions.size(); ++i){
for(uint j = 0; j < 15; ++j){ for(uint j = 0; j < 17; ++j){
disco[j] += (weights[i] * cluster_functions[i][j]); disco[j] += (weights[i] * cluster_functions[i][j]);
} }
} }
...@@ -273,6 +283,8 @@ void AttachDistanceConstraints(promod3::loop::BackboneLoopScorerPtr scorer, ...@@ -273,6 +283,8 @@ void AttachDistanceConstraints(promod3::loop::BackboneLoopScorerPtr scorer,
blosum62->AssignPreset(ost::seq::alg::SubstWeightMatrix::BLOSUM62); blosum62->AssignPreset(ost::seq::alg::SubstWeightMatrix::BLOSUM62);
ClusterSequences(aln, blosum62, promod3::core::AVG_DIST_METRIC, cluster_thresh, clusters); ClusterSequences(aln, blosum62, promod3::core::AVG_DIST_METRIC, cluster_thresh, clusters);
std::cout<<"num clusters:"<<clusters.size()<<std::endl;
//let's generate the cluster weights //let's generate the cluster weights
std::vector<Real> cluster_weights; std::vector<Real> cluster_weights;
GenerateClusterWeights(aln, clusters, blosum62, gamma, cluster_weights); GenerateClusterWeights(aln, clusters, blosum62, gamma, cluster_weights);
...@@ -291,7 +303,12 @@ void AttachDistanceConstraints(promod3::loop::BackboneLoopScorerPtr scorer, ...@@ -291,7 +303,12 @@ void AttachDistanceConstraints(promod3::loop::BackboneLoopScorerPtr scorer,
clusters, cluster_weights, clusters, cluster_weights,
i + 1, j + 1, disco); i + 1, j + 1, disco);
if(contains_info){ if(contains_info){
uint f_idx = scorer->AddConstraintFunction(0.0, 15.0, disco); std::cout<<"disco between "<< i+1 <<" and "<< j+1<<std::endl;
for(int pos = 0; pos < 17; ++pos){
std::cout<<disco[pos]<<" ";
}
std::cout<<std::endl;
uint f_idx = scorer->AddConstraintFunction(0.0, 17.0, disco);
for(std::vector<int>::const_iterator ch_it = indices.begin(); for(std::vector<int>::const_iterator ch_it = indices.begin();
ch_it != indices.end(); ++ch_it){ ch_it != indices.end(); ++ch_it){
scorer->AddConstraint(*ch_it, i + 1, *ch_it, j + 1, f_idx); scorer->AddConstraint(*ch_it, i + 1, *ch_it, j + 1, f_idx);
......
...@@ -9,6 +9,7 @@ ...@@ -9,6 +9,7 @@
#include <promod3/modelling/model.hh> #include <promod3/modelling/model.hh>
#include <promod3/core/runtime_profiling.hh> #include <promod3/core/runtime_profiling.hh>
#include <promod3/core/cluster.hh> #include <promod3/core/cluster.hh>
#include <promod3/core/geom_base.hh>
#include <vector> #include <vector>
#include <map> #include <map>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment