Selecting conserved residues in protein using PyMol script by importing residue list from a text file
Question: 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')
    
    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")
    


Answer: The `"resi i"` string does not know about your `i` variable.

Did you intend to do this?

    
    
    for i in array:
        cmd.select("residuedata", "resi {}".format(i))
    

