[Chimera-users] Buried_area python function
Tom Goddard
goddard at sonic.net
Thu Aug 29 14:23:42 PDT 2019
Hi Kevin,
The Chimera buried_area() function does not return a value, it prints its various buried area results to the reply log, so that isn't going to work in your script. But here is how to call it.
>>> from chimera.specifier import evalSpec
>>> a1 = evalSpec(':899-1230').atoms()
>>> a2 = evalSpec(':286-596').atoms()
>>> from Measure.measure import buried_area
>>> buried_area('', a1, a2)
The first argument "operation" is just a string, I think it says "buriedArea" but is not used by the code. You can see the code in chimera/share/Measure/measure.py or online
http://plato.cgl.ucsf.edu/trac/chimera/browser/trunk/libs/Measure/measure.py <http://plato.cgl.ucsf.edu/trac/chimera/browser/trunk/libs/Measure/measure.py>
The second and third arguments are lists of atoms, obtained above by the evalSpec() function. You could copy the buried_area() function to your script and modify it to return the values you need. The routine logs 12 different values. Also this routine computes the surface areas -- you do not need the lines in your script to compute surfaces runCommand('surface :286-596') ..., those will not be used.
Chimera uses MSMS (a third-party surface library) to compute molecular surfaces and it is known to fail often, especially for large structures (> 10000 atoms). So if you plan to run this on lots of files you should expect it to fail a lot. You would be much better off using our newer ChimeraX program which will never fail computing buried area, as it uses new reliable code. The Python to get the two sets of atoms would be different -- if you want to use this, ask and I can give an example.
https://www.rbvi.ucsf.edu/chimerax/docs/devel/core/commands/user_commands.html#measure <https://www.rbvi.ucsf.edu/chimerax/docs/devel/core/commands/user_commands.html#measure>
Tom
> On Aug 29, 2019, at 8:49 AM, Kevin Wang <kevinkw.wang at mail.utoronto.ca> wrote:
>
> Hi,
>
> I am trying to use the buried_area function below. What are the arguments that I need to pass in?
>
> def buried_area(operation, atoms1, atoms2,
> probeRadius = 1.4, vertexDensity = 2.0):
>
> My current code is as follows:
>
> #calculate buried area
>
> import os
> import chimera
> import xlsxwriter
> from Measure import measure
> from chimera import *
> workbook = xlsxwriter.Workbook('contactArea.xlsx')
> worksheet = workbook.add_worksheet()
> Path = "/Users/kevinwang/desktop/VEGFR_NO_LIGAND/results/clustering/pdbfit/split"
>
> i = 0
>
> filelist = os.listdir(Path)
> for x in filelist:
> if x.startswith("trp.pdb."):
> #if (x == "trp.pdb.00001"):
> opened = chimera.openModels.open(x, type ="PDB")
> chimera.update.checkForChanges()
> try:
> runCommand('surface :286-596')
> runCommand('surface :899-1230')
>
> y = measure.buried_area()
> worksheet.write(i,0,x)
> worksheet.write(i,1,y)
> except:
> worksheet.write(i,0,x)
> worksheet.write(i,1,"ERROR")
> i = i + 1
> print("Processed: " + x)
> print("Total #: " + str(i))
> runCommand('close all')
> chimera.update.checkForChanges()
>
> workbook.close()
>
>
>
>
> Best,
> Kevin
> _______________________________________________
> Chimera-users mailing list: Chimera-users at cgl.ucsf.edu <mailto:Chimera-users at cgl.ucsf.edu>
> Manage subscription: http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users <http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://plato.cgl.ucsf.edu/pipermail/chimera-users/attachments/20190829/df69d1e6/attachment.html>
More information about the Chimera-users
mailing list