Profile
- Name
- PutAllContactMapBands
- ID
- 49545
- Shared with
- Public
- Parent
- None
- Children
- None
- Created on
- July 26, 2014 at 13:08 PM UTC
- Updated on
- July 26, 2014 at 13:08 PM UTC
- Description
Puts bands between all the contact map points.
Best for
Code
----------------------------- Constants to change as desired ------------------------------
defaultStrength = 1.0
doTip1 = false
doTip2 = false
UseSetLengthForAlreadyContactedSegs = false
UseCompressionAndStrengthGame = true
--------------------------- Boring constants ------------------------------
heatThreshold = 0.96
segCt = structure.GetCount()
-----------------------------------------------------
-- THE BANDER
-----------------------------------------------------
function PutAllContactMapBands( heatThreshold, strength, doTip1, doTip2 )
print( "AllCMBands" )
changeSucceeded = false
for i = 1, segCt-2 do
for j = i+2, segCt do
if contactmap.GetHeat(i, j) >= heatThreshold then
local goalLength = nil
if UseCompressionAndStrengthGame then
if contactmap.IsContact( i, j ) then
goalLength = 0.9 * structure.GetDistance( i , j )
strength = 0.5 * defaultStrength
else
goalLength = 0.7 * structure.GetDistance( i , j )
strength = 1.5 * defaultStrength
end
elseif UseSetLengthForAlreadyContactedSegs and contactmap.IsContact( i, j ) then
goalLength = structure.GetDistance( i, j )
strength = defaultStrength
end
changeSucceeded = BandBetweenSegsWithParameters(
i, j, strength, goalLength,
doTip1, doTip2 )
or changeSucceeded
end
end
end
if not changeSucceeded then print "ContactMap Failed" end
return changeSucceeded
end
-----------------------------------------------------
-- BOILERPLATE STUFF
-----------------------------------------------------
function BandBetweenSegsWithParameters( seg1, seg2, strength, goalLength, fromTip1, fromTip2 )
-- caller can set goalLength without setting strength by providing strength = 0.0
if not ( IsMovableSeg( seg1) or IsMovableSeg( seg2) ) then return false end
if fromTip1 == nil then fromTip1 = false end
if fromTip2 == nil then fromTip2 = false end
if fromTip1 then tip1 = GetTipAtomOfSeg(seg1) else tip1 = 0 end
if fromTip2 then tip2 = GetTipAtomOfSeg(seg2) else tip2 = 0 end
local bIdx = band.AddBetweenSegments( seg1, seg2, tip1, tip2 )
if bIdx ~= band.GetCount( ) then
DebugPrint( "failed to add band from "..seg1.." to "..seg2)
return false
end
if goalLength ~= nil then
band.SetGoalLength( bIdx, goalLength )
end
if strength ~= nil and strength > 0.0 then
band.SetStrength( bIdx, strength )
end
return true
end
function IsMovableSeg( seg1 )
if seg1 == nil or seg1 < 1 or seg1 > segCt then return false end
local BB, SC = freeze.IsFrozen( seg1 )
local sl = structure.IsLocked( seg1 )
return not (BB or SC or sl)
end
-- for branched aas, simply picks one (longer, one with donor/acceptor tip, or if no difference then either)
function GetAtomOfTip( aa )
if aa == "a" then return 10
elseif aa == "c" then return 11
elseif aa == "d" then return 8
elseif aa == "e" then return 9
elseif aa == "f" then return 20
elseif aa == "g" then return 0 -- glycine has no tip. just use a backbone atom
elseif aa == "h" then return 17
elseif aa == "i" then return 18
elseif aa == "k" then return 9
elseif aa == "l" then return 16
elseif aa == "m" then return 17
elseif aa == "n" then return 14
elseif aa == "p" then return 13
elseif aa == "q" then return 9
elseif aa == "r" then return 22
elseif aa == "s" then return 11
elseif aa == "t" then return 6
elseif aa == "v" then return 13
elseif aa == "w" then return 24
elseif aa == "y" then return 12
else return 0
end
end
function GetTipAtomOfSeg( idx )
return GetAtomOfTip( structure.GetAminoAcid( idx ))
end
-----------------------------------------------------
-- THE CALL
-----------------------------------------------------
PutAllContactMapBands( heatThreshold, defaultStrength, doTip1, doTip2 )