Back to Recipes Homepage
recipe picture
Recipe: isPhobic V1.1
2.333335
Your rating: None Average: 2.3 (3 votes)
Used 88 times with an average impact of -1978 points.

Profile

Name: isPhobic V1.1
ID: 5945
Created on: Tue, 07/20/2010 - 12:05
Updated on: Tue, 07/20/2010 - 19:05
Description:

removed a typo in script. See script for details.



Best For


Comments

Joined: 09/18/2009
Groups: SETI.Germany
Code

-- IsPhobic and IsPhilic function by Crashguard303, inspired by Tlaloc
-- Now, as the get_aa() function does work again, I wrote this for informational purposes.
-- IsPhobic(x) / not(IsPhilic(x)) checks if segment x is hydrophobic, and returns true, if it is
-- IsPhilic(x) / not(IsPhobic(x)) checks if segment x is hydrophilic, and returns true, if it is

-- The functions get the sidechain-one-letter-name, and compare it with a table content
-- As IsPhilic has to check for only 9 letters
-- in contrast to IsPhobic, which has to check for 11 letters,
-- it is done a little bit earlier.

function IsPhobic(segNr)
PhobicLetter={"a";"c";"g";"i";"l";"m";"f";"p";"w";"y";"v"}
SegLetter=get_aa(segNr)

PhobicBool=false
exit_condition=false
k=1
repeat
if SegLetter==PhobicLetter[k] then
PhobicBool=true
exit_condition=true
end -- if
k=k+1
if k==11 then exit_condition=true end
until exit_condition==true
return PhobicBool
end -- function

function IsPhilic(segNr)
PhilicLetter={"r";"n";"d";"e";"q";"h";"k";"s";"t"}
SegLetter=get_aa(segNr)

PhilicBool=false
exit_condition=false
k=1
repeat
if SegLetter==PhilicLetter[k] then
PhilicBool=true
exit_condition=true
end -- if
k=k+1
if k==9 then exit_condition=true end
until exit_condition==true
return PhilicBool
end -- function

function CC2(OS,SPC,AS,E,ME)
OS2=OS
E2=E+1
if E2>1 then
OS2=OS2..SPC
end -- if E2
OS2=OS2..AS
if E2>=ME then
E2=0
OS2=OS2.."\n"
end -- if E2
return OS2,E2
end -- function

NumSegs=get_segment_count()

print("Hydrophobic segments:")
OS=""
Elements=0
for k=1,NumSegs do
if IsPhilic(k)==false then
-- if IsPhobic(k)==true then
OS,Elements=CC2(OS," ",k,Elements,15)
end -- if
end -- k
print(OS)

print()
print("Hydrophilic segments:")
OS=""
Elements=0
for k=1,NumSegs do
if IsPhilic(k)==true then
OS,Elements=CC2(OS," ",k,Elements,15)
end -- if
end -- k
print(OS)

Joined: 09/18/2009
Groups: SETI.Germany
More...

The code only makes sense, if there are not too many segments to check, as everytime you call the function, a table is defined and searched through.

Fortunately, lua also allows us to access array values not only by numeric but by string indices.

If you want to do it faster in your own scripts, simulate a pseudo-function by a table, for isPhilic it could look like this:

IsPhilic={} -- initiate isPhilic field
IsPhilic["r"]=true
IsPhilic["n"]=true
IsPhilic["d"]=true
IsPhilic["e"]=true
IsPhilic["q"]=true
IsPhilic["h"]=true
IsPhilic["k"]=true
IsPhilic["s"]=true
IsPhilic["t"]=true
IsPhilic["a"]=false
IsPhilic["c"]=false
IsPhilic["g"]=false
IsPhilic["i"]=false
IsPhilic["l"]=false
IsPhilic["m"]=false
IsPhilic["f"]=false
IsPhilic["p"]=false
IsPhilic["w"]=false
IsPhilic["y"]=false
IsPhilic["v"]=false

Now, to get an answer, if segment x is hydropilic, use check=IsPhilic[get_aa(x)], and "check" will now have a false or true content.

Joined: 09/18/2009
Groups: SETI.Germany
multiple assignment of table contents

If you know an easier way to assign a value to multiple tables, let me know.

Want to try?
Add to Cookbook!
To download recipes to your cookbook, you need to have the game client running.
Parent

none

Children

none

Authors
Sitemap

Developed by: UW Center for Game Science, UW Institute for Protein Design, Northeastern University, Vanderbilt University Meiler Lab, UC Davis
Supported by: DARPA, NSF, NIH, HHMI, Amazon, Microsoft, Adobe, RosettaCommons