Python Script to Find Contact Area Between 2 Proteins
Hi,
I am writing a python script to find the area between 2 proteins using the contact_area python command below.
def contact_area(p1, p2, d, color = None, offset = None, slab = None,
smooth = False, optimize = True):
Is there a specific object for p1 and p2 and if so how do I get it?
My current code is as follows:
import os
import chimera
from Measure import contactarea
from chimera import *
Path = "/Users/kevinwang/desktop/VEGFR_NO_LIGAND/results/clustering/pdbfit/split"
filelist = os.listdir(Path)
for x in filelist:
#if x.startswith("trp.pdb."):
if (x == "trp.pdb.00001"):
print x
opened = chimera.openModels.open(x, type ="PDB")
runCommand('surface')
y = contactarea.contact_area('0.1', '0.2', 2.5)
text_file = open("buriedArea.txt", "w")
text_file.write(y)
text_file.close()
The error message I am getting is as follows:
AttributeError: 'str' object has no attribute 'geometry'
File "/Applications/Chimera.app/Contents/Resources/share/Measure/contactarea.py", line 8, in contact_area v1, t1 = p1.geometry
How should I be passing in my arguments?
Best, Kevin
Hi Kevin, Those arguments are “surface pieces”. Each molecular surface has only one “piece” (despite possibly looking like multiple disjoint pieces). Once you run the “surface” command (generating two molecular surfaces) you can get the p1/p2 arguments with this code fragment:
p1, p2 = [s.surface_piece for s in openModels.list(modelTypes=[MSMSModel])]
Both openModels and MSMSModel are in the “chimera” module, but since your code does a “from chimera import *” you can get away with just the above.
—Eric
Eric Pettersen UCSF Computer Graphics Lab
On Aug 27, 2019, at 1:03 PM, Kevin Wang kevinkw.wang@mail.utoronto.ca wrote:
Hi,
I am writing a python script to find the area between 2 proteins using the contact_area python command below.
def contact_area(p1, p2, d, color = None, offset = None, slab = None, smooth = False, optimize = True):
Is there a specific object for p1 and p2 and if so how do I get it?
My current code is as follows:
import os import chimera from Measure import contactarea from chimera import *
Path = "/Users/kevinwang/desktop/VEGFR_NO_LIGAND/results/clustering/pdbfit/split"
filelist = os.listdir(Path) for x in filelist: #if x.startswith("trp.pdb."): if (x == "trp.pdb.00001"): print x opened = chimera.openModels.open(x, type ="PDB") runCommand('surface') y = contactarea.contact_area('0.1', '0.2', 2.5) text_file = open("buriedArea.txt", "w") text_file.write(y) text_file.close()
The error message I am getting is as follows:
AttributeError: 'str' object has no attribute 'geometry'
File "/Applications/Chimera.app/Contents/Resources/share/Measure/contactarea.py", line 8, in contact_area v1, t1 = p1.geometry
How should I be passing in my arguments?
Best, Kevin _______________________________________________ Chimera-users mailing list: Chimera-users@cgl.ucsf.edu mailto:Chimera-users@cgl.ucsf.edu Manage subscription: http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users
Hi Eric,
Thank you, code is working as intended now. However, I am using this code to analyze a trajectory so it takes a while to run it for each frame. Is there any way I can optimize it to run faster?
Best, Kevin ________________________________ From: Eric Pettersen pett@cgl.ucsf.edu Sent: Tuesday, August 27, 2019 6:30 PM To: Kevin Wang kevinkw.wang@mail.utoronto.ca Cc: chimera-users@cgl.ucsf.edu chimera-users@cgl.ucsf.edu Subject: Re: [Chimera-users] Python Script to Find Contact Area Between 2 Proteins
Hi Kevin, Those arguments are “surface pieces”. Each molecular surface has only one “piece” (despite possibly looking like multiple disjoint pieces). Once you run the “surface” command (generating two molecular surfaces) you can get the p1/p2 arguments with this code fragment:
p1, p2 = [s.surface_piece for s in openModels.list(modelTypes=[MSMSModel])]
Both openModels and MSMSModel are in the “chimera” module, but since your code does a “from chimera import *” you can get away with just the above.
—Eric
Eric Pettersen UCSF Computer Graphics Lab
On Aug 27, 2019, at 1:03 PM, Kevin Wang <kevinkw.wang@mail.utoronto.camailto:kevinkw.wang@mail.utoronto.ca> wrote:
Hi,
I am writing a python script to find the area between 2 proteins using the contact_area python command below.
def contact_area(p1, p2, d, color = None, offset = None, slab = None, smooth = False, optimize = True):
Is there a specific object for p1 and p2 and if so how do I get it?
My current code is as follows:
import os import chimera from Measure import contactarea from chimera import *
Path = "/Users/kevinwang/desktop/VEGFR_NO_LIGAND/results/clustering/pdbfit/split"
filelist = os.listdir(Path) for x in filelist: #if x.startswith("trp.pdb."): if (x == "trp.pdb.00001"): print x opened = chimera.openModels.open(x, type ="PDB") runCommand('surface') y = contactarea.contact_area('0.1', '0.2', 2.5) text_file = open("buriedArea.txt", "w") text_file.write(y) text_file.close()
The error message I am getting is as follows:
AttributeError: 'str' object has no attribute 'geometry'
File "/Applications/Chimera.app/Contents/Resources/share/Measure/contactarea.py", line 8, in contact_area v1, t1 = p1.geometry
How should I be passing in my arguments?
Best, Kevin _______________________________________________ Chimera-users mailing list: Chimera-users@cgl.ucsf.edumailto:Chimera-users@cgl.ucsf.edu Manage subscription: http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users
Generating surfaces is just not a fast process — I don’t really have any suggestions for speeding it up. Sorry.
—Eric
On Aug 28, 2019, at 8:06 AM, Kevin Wang kevinkw.wang@mail.utoronto.ca wrote:
Hi Eric,
Thank you, code is working as intended now. However, I am using this code to analyze a trajectory so it takes a while to run it for each frame. Is there any way I can optimize it to run faster?
Best, Kevin From: Eric Pettersen pett@cgl.ucsf.edu Sent: Tuesday, August 27, 2019 6:30 PM To: Kevin Wang kevinkw.wang@mail.utoronto.ca Cc: chimera-users@cgl.ucsf.edu chimera-users@cgl.ucsf.edu Subject: Re: [Chimera-users] Python Script to Find Contact Area Between 2 Proteins
Hi Kevin, Those arguments are “surface pieces”. Each molecular surface has only one “piece” (despite possibly looking like multiple disjoint pieces). Once you run the “surface” command (generating two molecular surfaces) you can get the p1/p2 arguments with this code fragment:
p1, p2 = [s.surface_piece for s in openModels.list(modelTypes=[MSMSModel])]
Both openModels and MSMSModel are in the “chimera” module, but since your code does a “from chimera import *” you can get away with just the above.
—Eric
Eric Pettersen UCSF Computer Graphics Lab
On Aug 27, 2019, at 1:03 PM, Kevin Wang <kevinkw.wang@mail.utoronto.ca mailto:kevinkw.wang@mail.utoronto.ca> wrote:
Hi,
I am writing a python script to find the area between 2 proteins using the contact_area python command below.
def contact_area(p1, p2, d, color = None, offset = None, slab = None, smooth = False, optimize = True):
Is there a specific object for p1 and p2 and if so how do I get it?
My current code is as follows:
import os import chimera from Measure import contactarea from chimera import *
Path = "/Users/kevinwang/desktop/VEGFR_NO_LIGAND/results/clustering/pdbfit/split"
filelist = os.listdir(Path) for x in filelist: #if x.startswith("trp.pdb."): if (x == "trp.pdb.00001"): print x opened = chimera.openModels.open(x, type ="PDB") runCommand('surface') y = contactarea.contact_area('0.1', '0.2', 2.5) text_file = open("buriedArea.txt", "w") text_file.write(y) text_file.close()
The error message I am getting is as follows:
AttributeError: 'str' object has no attribute 'geometry'
File "/Applications/Chimera.app/Contents/Resources/share/Measure/contactarea.py", line 8, in contact_area v1, t1 = p1.geometry
How should I be passing in my arguments?
Best, Kevin _______________________________________________ Chimera-users mailing list: Chimera-users@cgl.ucsf.edu mailto:Chimera-users@cgl.ucsf.edu Manage subscription: http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users
Chimera-users mailing list: Chimera-users@cgl.ucsf.edu mailto:Chimera-users@cgl.ucsf.edu Manage subscription: http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users http://plato.cgl.ucsf.edu/mailman/listinfo/chimera-users
participants (2)
-
Eric Pettersen
-
Kevin Wang