Icon representing a recipe

Recipe: HNetwork Probe 1.0

created by spvincent

Profile


Name
HNetwork Probe 1.0
ID
102977
Shared with
Public
Parent
None
Children
None
Created on
January 01, 2019 at 02:34 AM UTC
Updated on
January 01, 2019 at 02:34 AM UTC
Description

See first comment

Best for


Code


polar_aas = "stnqdekrhyw" n_polar_aas = 0 n_residues = 0 first_qs_slot = 13 next_qs_slot = 0 start_slot = 1 select_unfrozen = false filter_threshold = 40 n_it = 0 mutate_list_ui = {} -- will be a list of 1's & 0's for each residue. 1 means can mutate. 0 means don't mutate. mutable_list = {} filter_list = {} init_filter_score = 0 function r3 ( x ) -- Round to 3 decimal places t = 10 ^ 3 return math.floor ( x*t + 0.5 ) / t end function GetFilterScore () filter_bonus = filter.GetBonus ( "Hydrogen Bond Network" ) return filter_bonus end function GetListOfMutablesUnfrozen () for i = 1 , n_residues do seg_backbone_frozen, seg_sidechain_frozen = freeze.IsFrozen ( i ) if ( ( seg_sidechain_frozen == false ) and ( seg_backbone_frozen == false ) and ( structure.IsMutable ( i ) == true ) ) then table.insert ( mutable_list , i ) end end end function GetListOfMutablesSelected () for i = 1 , n_residues do seg_backbone_frozen, seg_sidechain_frozen = freeze.IsFrozen ( i ) if ( ( seg_sidechain_frozen == false ) and ( mutate_list_ui [ i ] == 1 ) and ( structure.IsMutable ( i ) == true ) ) then table.insert ( mutable_list , i ) end end end -- getlist pinched from Loop Rebuild 9.0 -- http://www.lua.org/manual/5.2/manual.html#6.4 -- helped make this function 11/16/17 function getlist(liststr) local newlist={} local i,ilo,ihi,idir,substr for i=1,n_residues do newlist[i]=0 end -- for i -- below reads from liststr a series of substr's -- where each substr contains an integer -- followed by one or more '-' signs -- followed by an integer for substr in string.gmatch(liststr,"(%d+%-+%d+)") do -- substr includes one or more '-' characters in a row -- below gets ilo & ihi from substr ilo=string.gsub(substr,"(%d+)%-+(%d+)","%1")+0 ihi=string.gsub(substr,"(%d+)%-+(%d+)","%2")+0 -- above gets ilo & ihi from substr idir=1 -- the increment to use from ilo to ihi if ilo>ihi then idir= -1 end -- if ilo for i=ilo,ihi,idir do -- for i=ilo to ihi step idir if i>=1 and i<=n_residues then newlist[i]=1 end -- if i end -- for i end -- for substr -- below reads from liststr a series of substr's -- where each substr contains an integer for substr in string.gmatch(liststr,"(%d+)") do i=substr+0 -- converts substr into the number i if i>=1 and i<=n_residues then newlist[i]=1 end -- if i end -- for substr return newlist end function Init () save.Quickload ( start_slot ) for i = 1 , #mutable_list do k = math.random ( n_polar_aas ) structure.SetAminoAcid ( mutable_list [ i ] , string.sub ( polar_aas , k , k ) ) end selection.SelectAll () structure.WiggleSelected ( 2 , false , true ) -- sidechains init_filter_score = GetFilterScore () end function PrintParameters () print ( " n mutables " .. #mutable_list ) print ( "Amino acids to use : " .. polar_aas ) end function GetParameters () local dlog = dialog.CreateDialog ( "HNetworkProbe 1.0" ) dlog.use_unfrozen = dialog.AddCheckbox ( "Select unfrozen" , select_unfrozen ) dlog.mutate_list = dialog.AddTextbox ( "Mutate segments" , "" ) dlog.mlabela = dialog.AddLabel('List segs to mutate like 1-3,6,19-30,45-62') dlog.aa_list = dialog.AddTextbox ( "Amino acids" , polar_aas ) dlog.filter_threshold = dialog.AddSlider ( "Filter threshold" , filter_threshold , 1 , 200 , 0 ) dlog.ok = dialog.AddButton ( "OK" , 1 ) dlog.cancel = dialog.AddButton ( "Cancel" , 0 ) if ( dialog.Show ( dlog ) > 0 ) then select_unfrozen = dlog.use_unfrozen.value mutate_list_ui = getlist(dlog.mutate_list.value) polar_aas = dlog.aa_list.value filter_threshold = dlog.filter_threshold.value return true else return false end end function main () n_residues = structure.GetCount () save.Quicksave ( start_slot ) if ( GetParameters () == false ) then return -- graceful exit end n_polar_aas = string.len ( polar_aas ) if ( select_unfrozen == true ) then GetListOfMutablesUnfrozen () else GetListOfMutablesSelected () end PrintParameters () if ( #mutable_list == 0 ) then print ( "No mutable residues found" ) exit (0) end filter_list = filter.GetNames () print ( "Filters" ) print ( "" ) for i = 1 , #filter_list do if ( filter_list [ i ] == "Hydrogen Bond Network" ) then filter.Enable ( filter_list [ i ] ) print ( "Enabling " .. filter_list [ i ] ) else filter.Disable ( filter_list [ i ] ) print ( "Disabling " .. filter_list [ i ] ) end end band.DisableAll () undo.SetUndo ( false ) init_filter_score = GetFilterScore () math.randomseed ( os.time () ) next_qs_slot = first_qs_slot Init () while next_qs_slot < 100 do -- basically forever n_it = n_it + 1 i = math.random ( #mutable_list ) k = math.random ( n_polar_aas ) structure.SetAminoAcid ( mutable_list [ i ] , string.sub ( polar_aas , k , k ) ) selection.SelectAll () --structure.ShakeSidechainsSelected ( 1 ) structure.WiggleSelected ( 2 , false , true ) -- sidechains filter_score = GetFilterScore () if ( filter_score > init_filter_score + filter_threshold ) then print ( "Found network ( gain " .. r3 ( filter_score - init_filter_score ) .. " ) storing in qs " .. next_qs_slot ) save.Quicksave ( next_qs_slot ) next_qs_slot = next_qs_slot + 1 Init () end end cleanup () end function cleanup () print ( "Cleaning up" ) print ( "n_it " .. n_it ) undo.SetUndo ( true ) if ( next_qs_slot > first_qs_slot ) then print ( "Loading quick saves " .. first_qs_slot .. " to " .. next_qs_slot - 1 ) for i = first_qs_slot , next_qs_slot - 1 do save.Quickload ( i ) end end band.EnableAll () filter.EnableAll () end --main () xpcall ( main , cleanup )

Comments


spvincent Lv 1

This is a script that's intended to help with creating Hydrogen Bond Networks. It's something of a blunt instrument but the resultant poses can help serve as a starting point for future work.

The idea is to make a limited selection of residues in an area where networks might plausibly form, randomly mutate them to amino acids that have either hydrogen bond donors or acceptors, wiggle the sidechains, and then, if any hydrogen bond networks form, store them in quicksave slots.

Selecting the residues to mutate.

Two ways this can be done: select unfrozen residues only or explicitly list the residues to mutate. Because of the fairly inefficient nature of this script, it's desirable to limit this number: I've found 20 or so to be a reasonable maximum but your mileage may vary. If you have existing networks; you can freeze them and use either of the methods below, but I occasionally see the script throw up false positives under these circumstances.

Select unfrozen

If checked, use the first option described above. For the purposes of this script it doesn't matter if the backbone or side chain is frozen.

Mutate segments

Relevant iff Select unfrozen above is not selected (I find this the more useful way of doing things). List the residues to mutate (ranges are allowed) separated by commas in a way already used by many other scripts; e.g. 34,36,41-44, etc.

Amino acids

The list of possible replacements. All amino acids that contain a donor or acceptor are included; however it might be wise to prune this list a bit depending on circumstances: for example if you are looking for networks in the core of the complex you might want to omit lysine (k) and arginine (r). While you may well get more networks the hiding and sidechain score penalties will likely to be too great to make them worthwhile.

Filter threshold

Of questionable utility: this can probably be ignored. Only gains in the HNet filter greater than this value will be recorded.

The script chugs away: any networks found will be saved in quicksave slots (13+) and a suitable message printed out in the Recipe Output window. It's recommended that you kill the script when you've got a few networks and take a look (enable all the filters; show networks; freeze the residues that make up the network; mutate and wiggle)