Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: Help with rebol script in anticancer research
Pages: [1] Print
Author Topic: Help with rebol script in anticancer research  (Read 474 times)
raddoo
Newbie
*
Offline Offline

Posts: 6


View Profile
Help with rebol script in anticancer research
« on: April 22, 2008, 06:07:42 AM »

hello
I'm working on anti cancer drug rsearch on my university (using molecular modelling)
I need to create a loop in a rebol script which will allow me to read all the files in directory one by one.
(before it will go to another file it should measure distances of atoms which is the next step)
The idea is to dock all the molecules one byone to protein and calculate the interactions - this way we can choose potential active molecule.
could you help me with that?
i'm completly new with rebol, so if i missed any improtant info let me know

i'm trying to make some changes in script wich measures distances:

REBOL [
  Title:  "Distances"
  Date:   03-Sep-2006
  Author: "Alessandro Pedretti"
  Version: 1.2.0
  Usage: {
    This script measures all atoms distances.
  }
  History: [
    1.0.0 15-Jan-2003 "First release"
    1.1.0 19-Jun-2005 "Fix file path iussue"
    1.2.0 03-Sep-2006 "Calculation check"
  ]
  Email: alessandro.pedretti@vegazz.net
]

; Load the VEGA interface

do %..\Common\Vega.r

; Open the comunication port

VegaOpen VegaDefHost VegaDefPort VegaDefUser VegaDefPass

; Check if a calculation is already running

VegaCmd "PluginGet IsRunning"
if equal? VegaRes "1" [
  VegaCmd rejoin[{MessageBox "Calculation already running" "ERROR" 16}]
  VegaClose
  quit
]


; Change the mouse cursor

VegaCmd {Cursor Busy}

; Print into the VEGA console

VegaCmd {Text "" 1}
VegaCmd {Text "**** Interatomic distances ****" 1}
VegaCmd {Text "" 1}

; Clear all molecules

VegaCmd {New}

; Get the VEGA installation directory

VegaCmd {Get VegaDir}
MolPath: join VegaRes "Molecules\"

; Load the molecule

VegaCmd rejoin [{Open "} MolPath {a3.msf"}]
VegaCmd {mNormalize}
VegaCmd {mColorByAtom}

; Get the number of atoms

VegaCmd {Get TotAtm}
TotAtm: to-integer VegaRes


VegaCmd {Text "**** Rebol demo start ****" 1}
[b]VegaCmd {Open "C:\Documents and Settings\process\Desktop\Glue_files\Cyklopentane_ring\cbp_1fixed.pdb"}
VegaCmd {mMerge "C:\Documents and Settings\process\Desktop\Glue_files\Cyklopentane_ring\3D_mol_ris_0001\DCK_0001_cyklopentane1.mol2"}

[/b]
; Measure the distances

for i 1 10 1 [
  for j (i + 1) 10 1 [
    VegaCmd rejoin ["Distance " i " " j " 1"]
    VegaCmd rejoin [{Text "} i {<->} j { } VegaRes {" 1}]
  ] ; End of for (j)
  VegaCmd {mPickRemMon}
] ; End of for (i)

; Change the mouse cursor to default

VegaCmd {Cursor Default}

; Close the comunication port

VegaClose



I'm usiing vega zz software, the manual: http://159.149.163.21:8080/manual/printable/vegazz.htm

thanks in advance
Logged
notchent
Newbie
*
Offline Offline

Posts: 39


View Profile WWW
Re: Help with rebol script in anticancer research
« Reply #1 on: April 23, 2008, 01:36:46 AM »

You can loop through each of the files in a folder using "foreach".   Here are some other basics you may need:

Code:
; Convert Windows file/folder format to Rebol format with "to-rebol-file".
; Use "change-dir" to go to a different folder.
; Get the current directory with "what-dir".
; Convert Rebol file/folder format to Windows format with "to-local-file":

change-dir to-rebol-file "C:\Documents and Settings\process\Desktop\Glue_files\Cyklopentane_ring\"
current-dir: to-local-file what-dir

; You can get the list of files in a folder using "read".
; For the current folder use:

current-files: read %./

foreach file current-files [
    print rejoin [current-dir "\" file]
]

Your Vega commands could be built, for example:

Code:
current-dir: to-local-file what-dir
current-files: read %./
foreach file current-files [
    VegaCmd rejoin [{Open "} current-dir "\" file {"}]
]

Or if you just want to work with .pdb files in a specified folder, for example:

Code:
current-dir: "C:\Documents and Settings\process\Desktop\Glue_files\Cyklopentane_ring\"
current-files: read to-rebol-file current-dir
foreach file current-files [
    if find file ".pdb" [
        VegaCmd rejoin [{Open "} current-dir file {"}]
    ]
]

Put the code to measure distances of atoms inside the foreach loop. 

Does that help?

- Nick
« Last Edit: April 23, 2008, 08:27:25 AM by notchent » Logged

raddoo
Newbie
*
Offline Offline

Posts: 6


View Profile
Re: Help with rebol script in anticancer research
« Reply #2 on: April 23, 2008, 06:27:16 PM »

thannks NIck for your help

i'm trying to implement your ideas, it will take me a while...
that's why i answer so late - i'm trying to ask if i really don't know the solution.

i have a problem as well with:
VegaCmd {Open "C:\Documents and Settings\process\Desktop\Glue_files\Cyklopentane_ring\3D_mol_ris_0001\DCK_0001_cyklopentane13.mol2"}
VegaCmd "PluginGet TotAtm"
VegaCmd rejoin[{Text "atoms: } VegaRes {" 1}]
; here i would like to asign a word to the results of above phrase (i didn't find a solution today:)

The above phrase will give me number of atoms in molecule
then i want to add this number to number of protein atoms, this way i will know numbers (numeration) of atoms of molecule which will be docked with protein, and i can use it to measure distances;
i'm trying to figure out sth with info that you have provided me


the loop should read in one of molecules (mol2 format) in directory, it should check the number of atoms, asaign the number to some word, then read in (merge) protein (pdb) and add number of protein atoms and molecule atoms;
then it should find the new numeration of molecule and use it to calculete distances between atoms of this molecule and selected atoms of protein (i will have to figure out how to select these atoms); than it should print
the results with distances less than 5 angstroms, and go to another molecule (mol2) from directory...

i think it is complicated....
thanx one more time, any clues will be helpful
Logged
notchent
Newbie
*
Offline Offline

Posts: 39


View Profile WWW
Re: Help with rebol script in anticancer research
« Reply #3 on: April 23, 2008, 10:53:51 PM »

Hey Raddoo,

I haven't looked at the VegaZZ api, but it appears that results of "VegaCmd"s are stored temporarily in "VegaRes" (until another VegaCmd that returns a result is executed).   If that's the case, just assign your own word to the value that's stored in VegaRes before it changes, i.e., like this in your code:

Code:
VegaCmd "PluginGet TotAtm"
your-variable: copy VegaRes 
; or perhaps just
; your-variable: VegaRes
VegaCmd rejoin[{Text "atoms: } VegaRes {" 1}]

Then you can use "your-variable" later to refer to the total number of atoms.  In your first example, that appears to be the purpose of this code:

Code:
VegaCmd {Get TotAtm}
TotAtm: to-integer VegaRes
; the variable "TotAtm" now holds the number of atoms

What VegaCmd is used to obtain the number of protein atoms, or how do you choose the files that contain that information?  What's the difference between the "Get TotAtm" and "PluginGet TotAtm" Vega Commands?  That's not clear to me.   Also, what info do .msf files provide?

If you post an example listing of real file names in your folder, and exactly how you need them processed, maybe I can help more.  The Vega API looks fairly straightforward from what you've posted so far, and although I don't know anything about molecular modeling, you appear to have most of the Vega code you need already together.   Is the "for i 1 10 1" loop something you wrote to measure distances exactly the way you need, or was that just generic example code to demonstrate how Vega return values could potentially be manipulated?

If you post a more specific example, with file names that you're using - enough to see a repeated pattern in the order in which they need to be processed, and some more about the distance measuring calculation - it should be pretty straightforward to help you write the Rebol code you need.  Please write everything you've got so far, with comments and questions wherever you're not sure, and I'll see how much I can help...

So far, it looks like you need something like this:

Code:
current-dir: "C:\Documents and Settings\process\Desktop\Glue_files\Cyklopentane_ring\"
current-files: read to-rebol-file current-dir
foreach file current-files [
    if find file ".mol2" [
        VegaCmd rejoin [{Open "} current-dir file {"}]
        VegaCmd {PluginGet TotAtm}
        TotAtm: to-integer VegaRes
        VegaCmd rejoin[{Text "atoms: } VegaRes {" 1}]

        ;  code to "read in (merge) protein (pdb) count number of protein atoms" goes here.
        ;  (I don't understand this process yet...)

        ;  Then add that number to TotAtm

        ;  code to "find the new numeration of molecule and use it to calculete distances
        ;  between atoms of this molecule and selected atoms of protein" goes here.
        ;  (I also don't understand this process yet - sounds like another loop...)

        ;  code to "print the results with distances less than 5 angstroms" goes here.       
    ]
]
« Last Edit: April 23, 2008, 11:42:12 PM by notchent » Logged

raddoo
Newbie
*
Offline Offline

Posts: 6


View Profile
Re: Help with rebol script in anticancer research
« Reply #4 on: April 24, 2008, 05:29:43 AM »

thanks Nick, i hope  i've answered your questions and i'm going back to
work with info that you have proviede to me;

the first question: "foreach" opens all the molecules with mol2 extension almost at once, is that correct? i mean if it will change when i add other lines of the script? that way it will insert one mol2 molecule, it will follow the process of inserting protein and measuring distances and then it will read second mol2 molecule, insert protein, measure distances ...etc.? (which is what i want to do)

the  information i found is:
"If you want obtain a value of a VEGA ZZ environment variable, you must use the Get or PluginGet VEGA ZZ commands" so i assume there is no significant difference...

-the command  "TotAtm" gives total number of atoms of the current loaded molecule, it is a standard command in Vega ZZ.

-.msf files  contain info about molecules (properties), it is a Quanta MSF chemical modeller input file.

-the loop "for i 1 10 1" is just an example ( 10 - to save the time when i run experimental calculations),
in the end it should measure the distances between all the atoms of the molecule and selected atoms of protein (as i've mentioned before i will think about selecting later, as it will be in my opinion small problem when i wil have the rest);


this is the example code to measure distances in vega:
REBOL [
  Title:  "Distances"
  Date:   03-Sep-2006
  Author: "Alessandro Pedretti"
  Version: 1.2.0
  Usage: {
    This script measures all atoms distances.
  }
  History: [
    1.0.0 15-Jan-2003 "First release"
    1.1.0 19-Jun-2005 "Fix file path iussue"
    1.2.0 03-Sep-2006 "Calculation check"
  ]
  Email: alessandro.pedretti@vegazz.net
]

; Load the VEGA interface

do %..\Common\Vega.r

; Open the comunication port

VegaOpen VegaDefHost VegaDefPort VegaDefUser VegaDefPass

; Check if a calculation is already running

VegaCmd "PluginGet IsRunning"
if equal? VegaRes "1" [
  VegaCmd rejoin[{MessageBox "Calculation already running" "ERROR" 16}]
  VegaClose
  quit
]


; Change the mouse cursor

VegaCmd {Cursor Busy}

; Print into the VEGA console

VegaCmd {Text "" 1}
VegaCmd {Text "**** Interatomic distances ****" 1}
VegaCmd {Text "" 1}

; Clear all molecules

VegaCmd {New}

; Get the VEGA installation directory

VegaCmd {Get VegaDir}
MolPath: join VegaRes "Molecules\"

; Load the molecule

VegaCmd rejoin [{Open "} MolPath {a3.msf"}]
VegaCmd {mNormalize}
VegaCmd {mColorByAtom}

; Get the number of atoms

VegaCmd {Get TotAtm}
TotAtm: to-integer VegaRes


VegaCmd {Text "**** Rebol demo start ****" 1}

; Measure the distances
;this one measures distances between all atoms of only one molecule

for i 1 TotAtm 1 [ ; it gives first atom in pair to measure distance; starting with atom nr 1, stops with the last atom (TotAtm) in step of 1, so if there will be "for i 2 10 2" it will measure starting from atom number 2 ending with no. 10, in step of 2 (every second atom)
  for j (i + 1) TotAtm 1 [ ; it gives the second atom in pair - so distance is being measured between atoms chosen above, and atoms chosen it this command
    VegaCmd rejoin ["Distance " i " " j " 1"]
    VegaCmd rejoin [{Text "} i {<->} j { } VegaRes {" 1}]
  ] ; End of for (j)
  VegaCmd {mPickRemMon}
] ; End of for (i)

; Change the mouse cursor to default

VegaCmd {Cursor Default}

; Close the comunication port

VegaClose

this is the folder screenshot
http://s2.screenshots.cc/thumb/thumb_c3b22a00.jpg

http://s2.screenshots.cc/upload/c3b22a00.jpg

;  code to "read in (merge) protein (pdb) count number of protein atoms" goes here.
        ;  (I don't understand this process yet...)
;to merge them -  it is enough to open the molecule file first (mol2) and protein file as a second one in the same window, to count atoms: VegaCmd "PluginGet TotAtm" or VegaCmd {Get TotAtm};
« Last Edit: April 24, 2008, 06:16:39 AM by raddoo » Logged
raddoo
Newbie
*
Offline Offline

Posts: 6


View Profile
Re: Help with rebol script in anticancer research
« Reply #5 on: April 24, 2008, 06:25:05 AM »

this is my main part of the script which works Smiley, without the loop so far:

it opens the molecule, counts the number of it's atoms and inserts the protein

;load ligand molecule
VegaCmd {Open "C:\Documents and Settings\process\Desktop\Glue_files\Cyklopentane_ring\3D_mol_ris_0001\DCK_0001_cyklopentane13.mol2"}
VegaCmd "Get TotAtm"
;TotLig: copy VegaRes
;TotLig: copy TotAtm
TotLig: to-integer VegaRes
VegaCmd rejoin[{Text "atoms: } TotLig {" 1}]

;load cbp (protein)
VegaCmd {Open "C:\Documents and Settings\process\Desktop\Glue_files\Cyklopentane_ring\cbp_1fixed.pdb"}
VegaCmd {mNormalize}
VegaCmd {mColorByAtom}
a:  to-integer 1377
b: TotLig + a
VegaCmd rejoin[{Text "atoms: } b {" 1}]
;VegaCmd [{Text TotAtm}]

it is just an exmple to develope

« Last Edit: April 25, 2008, 04:40:37 AM by raddoo » Logged
notchent
Newbie
*
Offline Offline

Posts: 39


View Profile WWW
Re: Help with rebol script in anticancer research
« Reply #6 on: April 25, 2008, 05:53:25 AM »

Foreach will do all of the things that you put inside the loop, once for each of the items in the list which it is looping through, consecutively.   So, you can put all of your working code inside the foreach loop, and have it do all those things with/to each of the mol2 files in your folder.

What's got me confused is how you're choosing the .pdb file to use with each .mol2 file.  In your screen shots, it looks like there's one .pdb file for every .mol2 file, but in your code example you're using "DCK_0001_cyklopentane13.mol2" together with "cbp_1fixed.pdb".  How do you choose which .pdb file to use for each .mol2 file?

Code:
foreach file current-files [
    if find file ".mol2" [
        VegaCmd rejoin [{Open "} current-dir file {"}]

        ; THE LINE ABOVE TAKES THE PLACE OF THE LINE BELOW IN YOUR WORKING CODE.
        ; IT WILL OPEN A DIFFERENT FILE EACH TIME THROUGH THIS FOREACH LOOP.

        ; VegaCmd {Open "C:\Documents and Settings\process\Desktop\Glue_files\Cyklopentane_ring\3D_mol_ris_0001\DCK_0001_cyklopentane13.mol2"}
        VegaCmd "Get TotAtm"
        TotLig: to-integer VegaRes
        VegaCmd rejoin[{Text "atoms: } TotLig {" 1}]

        ; YOU NEED TO REPLACE THE FOLLOWING LINE WITH A FILE TO USE EACH TIME THROUGH THE LOOP. 
        ; HOW ARE YOU CHOOSING THIS FILE?

        VegaCmd {Open "C:\Documents and Settings\process\Desktop\Glue_files\Cyklopentane_ring\cbp_1fixed.pdb"}
        VegaCmd {mNormalize}
        VegaCmd {mColorByAtom}
        a:  to-integer 1377
        b: TotLig + a
        VegaCmd rejoin[{Text "atoms: } b {" 1}]
    ]
]

If you want to open a .pdb file with the same name as each .mol2 file, use the following code.  The first line changes the ".mol2" extension to ".pdb" in the file name:

Code:
change/part find file ".mol2" ".pdb" 5
VegaCmd rejoin [{Open "} current-dir file {"}]

So here's an example, using your working code, that will open each .mol2 file in the folder, together with each .pdb file of the same name:

Code:
foreach file current-files [
    if find file ".mol2" [
        VegaCmd rejoin [{Open "} current-dir file {"}]
        VegaCmd "Get TotAtm"
        TotLig: to-integer VegaRes
        VegaCmd rejoin[{Text "atoms: } TotLig {" 1}]

        change/part find file ".mol2" ".pdb" 5
        VegaCmd rejoin [{Open "} current-dir file {"}]
        VegaCmd {mNormalize}
        VegaCmd {mColorByAtom}
        a:  to-integer 1377
        b: TotLig + a
        VegaCmd rejoin[{Text "atoms: } b {" 1}]
    ]
]
« Last Edit: April 25, 2008, 06:36:20 AM by notchent » Logged

raddoo
Newbie
*
Offline Offline

Posts: 6


View Profile
Re: Help with rebol script in anticancer research
« Reply #7 on: April 25, 2008, 09:30:27 AM »

There is only one target protein, so there is only one pdb file.

my working code after today's job:

;load ligand molecule
VegaCmd {Open "C:\Documents and Settings\process\Desktop\Glue_files\Cyklopentane_ring\3D_mol_ris_0001\DCK_0001_cyklopentane13.mol2"}
VegaCmd "Get TotAtm"
TotLig: to-integer VegaRes
VegaCmd rejoin[{Text "atoms: } TotLig {" 1}]
; so this one is inserting the ligand molecule


;load cbp (protein)
VegaCmd {Open "C:\Documents and Settings\process\Desktop\Glue_files\Cyklopentane_ring\cbp_1fixed.pdb"}
;insert pdb file with target protein
VegaCmd {mNormalize}
VegaCmd {mColorByAtom}
a:  to-integer 1377 ; numbers of atoms of potential interest , chosen manually from protein structure
b: to-integer 145
c: to-integer 1199
A: TotLig + a ; calculated new numbers of the same atoms as above, after inserting protein which resulted in new numeration of atoms.
B: TotLig + b
C: TotLig + c
VegaCmd rejoin[{Text "atom 1 no: } A {" 1}]
VegaCmd rejoin[{Text "atom 2 no: } B {" 1}]
VegaCmd rejoin[{Text "atom 3 no: } C {" 1}]
;VegaCmd [{Text TotAtm}]

;Mesure distances
max: to-decimal 12

for i 1 TotLig 1 [
          VegaCmd rejoin ["Distance " i " " A " 1"]
           distA: to-decimal VegaRes
          if distA < max [
          VegaCmd rejoin [{Text "Distance1: }  i {<->} A { } VegaRes {" 1}] ; calculation of distances between all the atoms of ligand molecule and specified atom (number 1377 + TotLig) of target protein
           ]
          VegaCmd rejoin ["Distance " i " " B " 1"]
           distB: to-decimal VegaRes
           if distB < max [
          VegaCmd rejoin [{Text "Distance2: }  i {<->} B { } VegaRes {" 1}]
           ]
          VegaCmd rejoin ["Distance " i " " C " 1"]
           distC: to-decimal VegaRes
           if distC < max [
          VegaCmd rejoin [{Text "Distance3: }  i {<->} C { } VegaRes {" 1}]
           ]
  VegaCmd {mPickRemMon}
] ; End of for (i)


« Last Edit: April 25, 2008, 09:59:53 AM by raddoo » Logged
raddoo
Newbie
*
Offline Offline

Posts: 6


View Profile
Re: Help with rebol script in anticancer research
« Reply #8 on: April 25, 2008, 10:05:09 AM »

I did sth like this:

it seems to be working, i have to check if there are no mistakes Smiley


VegaCmd {Text "**** Rebol demo start ****" 1}
change-dir to-rebol-file "C:\Documents and Settings\process\Desktop\Glue_files\Cyklopentane_ring\3D_mol_ris_0001\"
current-dir: to-local-file what-dir


current-dir: "C:\Documents and Settings\process\Desktop\Glue_files\Cyklopentane_ring\3D_mol_ris_0001\"
current-files: read to-rebol-file current-dir

foreach file current-files [
    if find file ".mol2" [
        VegaCmd rejoin [{Open "} current-dir file {"}]
        VegaCmd "Get TotAtm"
        TotLig: to-integer VegaRes
        VegaCmd rejoin[{Text "atoms: } TotLig {" 1}]
]



;load cbp (protein)
VegaCmd {Open "C:\Documents and Settings\process\Desktop\Glue_files\Cyklopentane_ring\cbp_1fixed.pdb"}
VegaCmd {mNormalize}
VegaCmd {mColorByAtom}
a:  to-integer 1377
b: to-integer 145
c: to-integer 1199
A: TotLig + a
B: TotLig + b
C: TotLig + c
VegaCmd rejoin[{Text "atom 1 no: } A {" 1}]
VegaCmd rejoin[{Text "atom 2 no: } B {" 1}]
VegaCmd rejoin[{Text "atom 3 no: } C {" 1}]
;VegaCmd [{Text TotAtm}]

;Mesure distances
max: to-decimal 5

for i 1 TotLig 1 [
          VegaCmd rejoin ["Distance " i " " A " 1"]
           distA: to-decimal VegaRes
          if distA < max [
          VegaCmd rejoin [{Text "Distance1: }  i {<->} A { } VegaRes {" 1}]
           ]
          VegaCmd rejoin ["Distance " i " " B " 1"]
           distB: to-decimal VegaRes
           if distB < max [
          VegaCmd rejoin [{Text "Distance2: }  i {<->} B { } VegaRes {" 1}]
           ]
          VegaCmd rejoin ["Distance " i " " C " 1"]
           distC: to-decimal VegaRes
           if distC < max [
          VegaCmd rejoin [{Text "Distance3: }  i {<->} C { } VegaRes {" 1}]
           ]
  VegaCmd {mPickRemMon}
] ; End of for (i)
]

thanks one more time Nick, you are brilliant,
so far  you saved me weeks of time and countless amount of stress:D
« Last Edit: April 25, 2008, 10:31:07 AM by raddoo » Logged
notchent
Newbie
*
Offline Offline

Posts: 39


View Profile WWW
Re: Help with rebol script in anticancer research
« Reply #9 on: April 25, 2008, 11:18:18 AM »

It's great to see it coming along Smiley   

The replace dialogue appears to be coming from within VegaZZ's "open" command.  The manual says:

Quote
If a molecule is already present in the workspace, a dialog is shown in order to select the placing mode (append, replace and new workspace)

I didn't see any option/refinement of the open command in their docs that allows this to be disabled (but I only did a quick skim).  You may want to check with someone who knows VegaZZ intimately, and see if there's such an option. 

Also, wouldn't running the Vega command "new" clear the workspace, so that this wouldn't happen?  I.e., put the following code before running the open loop:

Code:
VegaCmd {New}

Otherwise, a quick script in AutoIt could check for the appearance of the "replace" dialogue and repeatedly/automatically click the appropriate button every time it appears.  Lemme know if you need help with that Smiley
« Last Edit: April 25, 2008, 11:47:09 AM by notchent » Logged

Pages: [1] Print 
Rebol Talk Forum  |  Getting Started  |  Newbie Help  |  Topic: Help with rebol script in anticancer research
Jump to:  

  
Quick Search...

Advanced search
  
Welcome, Guest. Please login or register.
Did you miss your activation email?
August 21, 2008, 04:17:40 PM
Username: Password: Session Length:
  

News: 01-09-08

Alpha version of REBOL 3 has been released!


  
2225 Posts in 578 Topics by 1651 Members
Latest Member: Prebrotte

  Rebol Talk Forum | Powered by SMF 1.0.9.
© 2001-2005, Lewis Media. All Rights Reserved.

RT design by Defiant Pc