mailRe: Pymol macro script.


Others Months | Index by Date | Thread Index
>>   [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Header


Content

Posted by Michael Bieri on October 23, 2009 - 00:05:
Hi Tiago

Here is the final_data_extraction.py script. Run it using the command 'relax final_data_extraction.py' in the directory of your final analysis (copy the pdb file in the same directory).

Cheers
Michael

Tiago Pais schrieb:
Hi Michael,
Could you send me your script for final_data_extraction.py since I didn’t
get it attached.
Thank you
TiagoP

-----Original Message-----
From: relax-users-bounces@xxxxxxx [mailto:relax-users-bounces@xxxxxxx] On
Behalf Of Edward d'Auvergne
Sent: segunda-feira, 5 de Outubro de 2009 10:52
To: Michael Bieri
Cc: relax-users@xxxxxxx
Subject: Pymol macro script.

Hi Michael,

That script is quite useful, I need to get a few of these into the
sample scripts directory.  Note that the results that Boaz has are not
those of a complete analysis and should not be presented (the
diffusion tensor is not optimised so the results will be full of
artifacts).  One point with this script, I would recommend abstracting
the model.  In model-free analysis, the model which has been selected
is not really important, rather the motions that are reported.  For
example model m2 can nicely approximate model m5 and if noise makes
the slower motion statistically insignificant, that does not mean that
the motion is not there.  I have added my script for Molmol macros to
the relax sample_scripts directory
(http://svn.gna.org/viewcvs/relax/1.3/sample_scripts/mf_molmol_plot.py?rev=9
566&view=log)
which shows this.

I was wondering if you would like to try to get your script into
relax?  It could be quite useful to have, but there are a few things
that would need to be done.  For example the Pymol macros would be
better implemented directly in relax rather than in the script.  I.e.
there is the pymol.write() user function which currently does nothing.
 This could be implemented so the user types something like:

relax> pymol.write(data_type='amp_fast', style='bieri',
colour_start='red', colour_end='blue', force=True)
relax> pymol.write(data_type='time_slow', style='bieri',
colour_start='red', colour_end='blue', force=True)

This could simply mimic the current molmol code but replacing the
contents with what you have in your script.  I could add the script as
is, if it passes the code validator in 'scripts/code_validator', and
then this idea for incorporating your code into the core of relax
explored later.  What do you think?

Regards,

Edward


2009/9/17 Michael Bieri <michael.bieri@xxxxxx>:
Hi Boaz

There are many data present in the result file obtained by relax (final
run
of full_analysis.py).

To extract the data I am interested, I'm created the following script:
final_data_extraction.py (see attachment).

Just navigate to your final run directory, where the file results.bz2 is
located, and copy your pdb file and this script into it. Then run the
script
using the command "relax final_data_extraction.py".

This will create a table with Residue Numer - Model - S2 - Rex as well as
single data files and grace plots. Furtermore, it calculates the diffucion
tensor pdb and generates PyMol macros to visualize the S2 and Rex values
in
PyMol (just run the macros in PyMol terminal by the command "@s2.pml").

The script works with relax 1.3.4 (not tested with 1.3.3).

I hope this script may help you! There is more that can be incorporated.

Cheers
Michael


Michael Bieri, PhD
Department of Biochemistry and Molecular Biology
Bio21 Molecular Science and Biotechnology Institute
The University of Melbourne, 30 Flemington Road
Parkville, Victoria 3010, Australia

Tel.: +61 3 8334 2256

http://www.biochemistry.unimelb.edu.au



Boaz Shapira wrote:
Hi,

I just installed relax and tried to figure out how it works (couldn't).
I have no idea about python and I don't mind to keep it that way unless i
have no other choice.
Still, I tried to play with the examples and couldn't make it work (the
relax --text-suite didn't give me error)


I tried to run model-free.py from the relax prompt but it gives me error.
" Traceback (most recent call last):
 File "<console>", line 1, in <module>
NameError: name 'model' is not defined "

Then I copied line by line and it did work.
It save it in a .bz2 format.
Now If I want to read the data what format should I use?
It looks like a source html file.


In general I collected data on two fields and want to analyze the data
with a black box (the full_analysis.py ?)
I have the input files in the right format as in the examples
I have the pdb file

Is it possible to simply run a black-box that will give me an output:
List of the residues with the best model for each, the values for this
model (S2, tau ...), the goodness of the fitting, and
the overall diffusion tensor?
This black box will also reject "bad" relaxation data.
and all of that will be given in a text file?

It is too much to ask?

Thank you,

Boaz


------------------------------------------------
Boaz Shapira PhD
Complex Carbohydrate Research Center
University of Georgia
315 Riverbend Rd
Athens, GA 30602-4712
706-542-6286
bshapira@xxxxxxxxxxxx
------------------------------------------------------------------------

_______________________________________________
relax (http://nmr-relax.com)

This is the relax-users mailing list
relax-users@xxxxxxx

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-users

_______________________________________________
relax (http://nmr-relax.com)

This is the relax-users mailing list
relax-users@xxxxxxx

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-users



_______________________________________________
relax (http://nmr-relax.com)

This is the relax-users mailing list
relax-users@xxxxxxx

To unsubscribe from this list, get a password
reminder, or change your subscription options,
visit the list information page at
https://mail.gna.org/listinfo/relax-users


#####################################################################################
#          Script for Final Data Extraction after Model-free Analysis         
      #
#                                Michael Bieri                                
      #
#                                  16.9.2009                                  
      #
#####################################################################################


# Extract Data to Table

#create a table file

# Python module imports.
from string import replace

# relax module imports.
from generic_fns.mol_res_spin import spin_loop
from generic_fns import pipes


pipe.create('Data_extraction','mf')
results.read()

#create file

self.file = open('Model-free_Results.txt', 'w')

self.file.write('Data Extraction by Michael Bieri')
self.file.write("\n")
self.file.write("\n")
self.file.write("Residue                Model   S2                      Rex 
[1/s]               Te                      Relaxation Parameters\n")
self.file.write("\n")


for spin, spin_id in spin_loop(return_id=True):
            # The spin ID string.
            spin_no = spin_id[spin_id.index(':')+1:spin_id.index('&')]
            spin_res = spin_id[spin_id.index('&')+2:spin_id.index('@')]
            self.file.write((spin_res) + " " + (spin_no))
            # The spin is not selected.
            if not spin.select:
                self.file.write("\n")
                continue


# The model-free model.
            if hasattr(spin, 'model'):
                spin.model = spin.model[1:2]
                self.file.write("               " + spin.model)


# S2.
            if  hasattr(spin, 's2'):
                s2 = str(spin.s2)
                s2_err = str(spin.s2_err)
                if spin.s2 == None:
                        self.file.write("")
                else:
                        self.file.write("       " + s2[0:5]+ " +/- " + 
s2_err[0:4])


# Rex.
            if hasattr(spin, 'rex'):
                rex = str(spin.rex)
                rex_err = str(spin.rex_err)
                if spin.rex == None:
                        self.file.write("                       ")
                else:
                        rex_eff = spin.rex * (int(spin.frq_labels[1]) * 
1000000 * 2 * 3.14159)**2
                        rex = str(rex_eff)
                        rex_err_eff = spin.rex_err * (int(spin.frq_labels[1]) 
* 1000000 * 2 * 3.14159)**2
                        rex_err = str(rex_err_eff)
                        self.file.write("               " + rex[0:5]+ " +/- " 
+ rex_err[0:4])


# Te
            if  hasattr(spin, 'te'):
                if spin.te == None:
                        self.file.write("               ")
                else:
                        te_ps = spin.te * 1e-12
                        te = str(te_ps)
                        te_err = str(spin.te_err)
                        self.file.write("               " + te[0:5]+ " +/- " 
+ te_err[0:4])



# Parameters.
            if hasattr(spin, 'params'):
                self.file.write("                       " + 
str(spin.params[0:len(spin.params)]))
            else:
                self.file.write("\\n")
                continue



# Start a new line.
            self.file.write("\n")


##################################################################################################

#Create Single Data Files


value.write(param='rex', file='rex.txt', dir='final_results', force=True)
value.write(param='s2', file='s2.txt', dir='final_results', force=True)
value.write(param='s2f', file='s2f.txt', dir='final_results', force=True)
value.write(param='s2s', file='s2s.txt', dir='final_results', force=True)
value.write(param='te', file='te.txt', dir='final_results', force=True)
value.write(param='tf', file='tf.txt', dir='final_results',  force=True)
value.write(param='ts', file='ts.txt', dir='final_results', force=True)
value.write(param='rex', file='rex.txt', dir='final_results', force=True)
value.write(param='r', file='r.txt', dir='final_results', force=True)
value.write(param='rex', file='rex.txt', dir='final_results', force=True)
value.write(param='csa', file='csa.txt', dir='final_results', force=True)
value.write(param='rex', file='rex.txt', dir='final_results', force=True)
value.write(param='local_tm', file='local_tm.txt', dir='final_results', 
force=True)

##################################################################################################

#Create Grace Plots

grace.write(x_data_type='spin', y_data_type='s2', file='s2.agr', force=True)
grace.write(x_data_type='spin', y_data_type='te', file='te.agr', force=True)
grace.write(x_data_type='spin', y_data_type='s2f', file='s2f.agr', force=True)
grace.write(x_data_type='spin', y_data_type='s2s', file='s2s.agr', force=True)
grace.write(x_data_type='spin', y_data_type='ts', file='ts.agr', force=True)
grace.write(x_data_type='spin', y_data_type='tf', file='tf.agr', force=True)
grace.write(x_data_type='spin', y_data_type='csa', file='csa.agr', force=True)
grace.write(x_data_type='te', y_data_type='s2', file='s2-te.agr', force=True)

##################################################################################################

#Create Diffusion Tensor

# Display the diffusion tensor.
diffusion_tensor.display()

# Create the tensor PDB file.
tensor_file = 'tensor.pdb'
structure.create_diff_tensor_pdb(file=tensor_file, force=True)

##################################################################################################

# Create S2 Macro for PyMol 

# Python module imports.
from string import replace

# relax module imports.
from generic_fns.mol_res_spin import spin_loop
from generic_fns import pipes

#create file

self.file = open('s2.pml', 'w')

self.file.write("bg_color white\n")
self.file.write("color gray90\n")
self.file.write("hide all\n")
self.file.write("show ribbon\n")

for spin, spin_id in spin_loop(return_id=True):

#select residue
            spin_no = spin_id[spin_id.index(':')+1:spin_id.index('&')]


#ribbon color
            if  hasattr(spin, 's2'):
                s2 = str(spin.s2)
                if spin.s2 == None:
                        self.file.write("")
                else:
                        width = ((1-spin.s2) * 2)
                        green = 1 - ((spin.s2)**3) 
                        green = green * green * green #* green * green
                        green = 1 - green
                        self.file.write("set_color resicolor" + spin_no + ", 
[1," + str(green) + ",0]\n")
                        self.file.write("color resicolor" + spin_no + ", resi 
" + spin_no + "\n")
                        self.file.write("set_bond stick_radius, " + 
str(width) + ", resi " + spin_no + "\n")



self.file.write("hide all\n")
self.file.write("show sticks, name C+N+CA\n")
self.file.write("set stick_quality, 10\n")
self.file.write("ray\n")


##################################################################################################

# Create Rex Macro for PyMol 

#create file

self.file = open('rex.pml', 'w')

self.file.write("bg_color white\n")
self.file.write("color gray90\n")
self.file.write("hide all\n")
self.file.write("show ribbon\n")

max_rex = 0

#find max Rex
for spin, spin_id in spin_loop(return_id=True):

            if  hasattr(spin, 'rex'):

                  if not spin.rex == None:
                       if spin.rex > max_rex:
                             max_rex = spin.rex 


for spin, spin_id in spin_loop(return_id=True):

#select residue
            spin_no = spin_id[spin_id.index(':')+1:spin_id.index('&')]
#ribbon color
            if  hasattr(spin, 'rex'):
                rex = str(spin.rex)
                if spin.rex == None:
                        self.file.write("")
                else:
                        rel_rex = spin.rex / max_rex
                        width = ((rel_rex) * 2)
                        green = ((rel_rex)) 
                        green = green * green * green #* green * green
                        green = 1 - green
                        self.file.write("set_color resicolor" + spin_no + ", 
[1," + str(green) + ",0]\n")
                        self.file.write("color resicolor" + spin_no + ", resi 
" + spin_no + "\n")
                        self.file.write("set_bond stick_radius, " + 
str(width) + ", resi " + spin_no + "\n")



self.file.write("hide all\n")
self.file.write("show sticks, name C+N+CA\n")
self.file.write("set stick_quality, 10\n")
self.file.write("ray\n")



##################################################################################################


print ""
print ""
print " ---------- done ----------------"
print ""
print ""
print "Grace Plots are in Folder /grace/"
print ""
print "Signle Text Files for Relaxation Parameters are in Folder 
/final_results/"
print ""
print "Diffusion Tensor is in current Folder"
print ""
print "PyMol Macros are in current Folder - execute in PyMol with Command:"
print "@rex.pml and @s2.pml"






Related Messages


Powered by MHonArc, Updated Tue Oct 27 11:20:16 2009