Hi,
I wanted to select certain highly conserved residues in a protein (computed by a scoring mechanism and listed in a text file - each residue in a single line) using a PyMol script. The PyMol script below that I am using is not working. I will be very grateful to you if someone could help me out.
Parts of the script work perfectly fine when run separately - the Pymol script when a residue number is mentioned in the script without importing the list from the text file and just the python script for loading numbers from a file into an array also works fine when run separately. But the problem is seen when it is combined as in my script below - when residue number needs to be taken from the array as I after importing the list from the text file. Any help is appreciated. Thanks!
#!/usr/bin/python
from pymol import cmd
import string
cmd.load("/home/xyz/proteinA.pdb", 'protein')
cmd.hide()
cmd.bg_color("white")
cmd.show("mesh")
cmd.color("blue")
f=open('/home/xyz/residuedata.txt','r')
array = []
filecontents = f.read().split()
for val in filecontents:
array.append(int(val))
f.close()
for I in array:
cmd.select("residuedata", "resi i")
cmd.show('sphere', "residuedata")
cmd.color ('red', "residuedata")
I've never actually used a script interface to PyMol so don't know about the cmd functions you're using, but
cmd.select("residuedata", "resi i")
isn't using the integer stored ini
- it's just passing the string"resi i"
. I guess instead you want"resi " + str(i)
Thank you Ben. That was a very important clue for me.