Skip to content
Snippets Groups Projects
Commit 35d8ef84 authored by Gerardo Tauriello's avatar Gerardo Tauriello
Browse files

Bugfix: ring-punch-fix was struggling with unclosed gaps.

parent c5224b22
No related branches found
No related tags found
No related merge requests found
......@@ -387,6 +387,9 @@ def MergeGapsByDistance(mhandle, distance):
stretch of original gaps and the deleted region. Original gaps will be
removed. Stem residues count to the gap, so **A-A-A** has a distance of 0.
IMPORTANT: we assume here that *mhandle* stores gaps sequentially.
An exception can be raised otherwise!
.. literalinclude:: ../../../tests/doc/scripts/modelling_merge_gaps_by_distance.py
:param mhandle: Modelling handle on which to apply change.
......@@ -395,8 +398,6 @@ def MergeGapsByDistance(mhandle, distance):
merge happens.
:type distance: :class:`int`
'''
# IMPORTANT: the assumption is that ModellingHandle stores gaps
# sequentially
if len(mhandle.gaps) > 1:
ost.LogInfo("Trying to merge %d gap(s) with distance %d." % \
......@@ -838,8 +839,7 @@ def ModelTermini(mhandle, scorer, torsion_sampler, fragger_handle=None,
for g in terminal_gaps:
# work on copy of gap
gap_orig = g.Copy()
actual_gap = gap_orig
actual_gap = g.Copy()
# extract info
if actual_gap.IsNTerminal():
......@@ -911,7 +911,7 @@ def ModelTermini(mhandle, scorer, torsion_sampler, fragger_handle=None,
min_score = score
ost.LogVerbose("Gap %s - %d candidates, best (min) score %g" %
(str(gap_orig), len(candidates), min_score))
(str(actual_gap), len(candidates), min_score))
# finally resolve loop
if optimal_candidate is not None:
......@@ -920,11 +920,11 @@ def ModelTermini(mhandle, scorer, torsion_sampler, fragger_handle=None,
bb_list.InsertInto(actual_chain, start_resnum)
# update scorer
scorer.SetEnvironment(bb_list, start_resnum, actual_chain_idx)
ost.LogInfo("Resolved %s by filling %s (%d candidates)" % \
(str(gap_orig), str(actual_gap), len(candidates)))
ost.LogInfo("Resolved terminal gap %s (%d candidates)" % \
(str(actual_gap), len(candidates)))
ClearGaps(mhandle, actual_gap)
else:
ost.LogInfo("Failed at loop insertion (%s)" % str(actual_gap))
ost.LogInfo("Failed to model terminal gap (%s)" % str(actual_gap))
def CloseLargeDeletions(mhandle, scorer, structure_db, linker_length = 8,
......
......@@ -52,13 +52,16 @@ def BuildSidechains(mhandle, merge_distance=4, scorer=None, fragment_db=None,
# check for ring punches
rings = GetRings(mhandle.model)
ring_punches = GetRingPunches(rings, mhandle.model)
# add gaps to mhandle
for res in ring_punches:
mygap = StructuralGap(res.prev, res.next, res.one_letter_code)
mhandle.gaps.append(mygap)
# try to fix them
if len(ring_punches) > 0:
ost.LogInfo("Trying to fix %d ring punch(es)." % len(ring_punches))
# backup old gaps
old_gaps = [g.Copy() for g in mhandle.gaps]
# new gaps for mhandle
mhandle.gaps = StructuralGapList()
for res in ring_punches:
mygap = StructuralGap(res.prev, res.next, res.one_letter_code)
mhandle.gaps.append(mygap)
# load stuff if needed
if scorer is None:
scorer = SetupBackboneScorer(mhandle)
......@@ -74,6 +77,10 @@ def BuildSidechains(mhandle, merge_distance=4, scorer=None, fragment_db=None,
torsion_sampler, ring_punch_detection=2)
# re-build sidechains
sidechain.Reconstruct(mhandle.model, keep_sidechains=True)
# restore gaps
mhandle.gaps = StructuralGapList()
for g in old_gaps:
mhandle.gaps.append(g)
def MinimizeModelEnergy(mhandle, max_iterations=3, max_iter_sd=30,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please to comment