ImportError: No module named pymol (Windows)
1
0
Entering edit mode
6.3 years ago
po9.don • 0

Hi. I found this script online:

"""
Pymol python script to add a function to color atoms by residues.
syntaxe in Pymol :
color_by_resname selection
"""

__author__      = "Thibault Tubiana"
__copyright__   = "Copyleft"

color_code = {
  'ALA' : 'lemon', 
  'CYS' : 'yellow', 
  'ASP' : 'red', 
  'GLU' : 'violet2', 
  'PHE' : 'emerald', 
  'GLY' : 'orange', 
  'HIS' : 'peacock', 
  'ILE' : 'lime2', 
  'LYS' : 'indigo', 
  'LEU' : 'grass', 
  'MET' : 'green', 
  'ASN' : 'purple2', 
  'PRO' : 'tangerine', 
  'GLN' : 'magenta2', 
  'ARG' : 'blue', 
  'SER' : 'scarlet', 
  'THR' : 'vermillion', 
  'VAL' : 'lemon-lime', 
  'TRP' : 'cyan', 
  'TYR' : 'turquoise',
}

def create_color():
    """
    Create missing color in pymol
    """
    cmd.set_color("scarlet",[1.0,0.2,0.0])
    cmd.set_color("vermillion",[1.0,0.4,0.0])
    cmd.set_color("tangerine",[1.0,0.8,0.0])
    cmd.set_color("lemon",[0.8,1.0,0.0])
    cmd.set_color("lemon-lime",[0.6,1.0,0.0])
    cmd.set_color("lime2",[0.4,1.0,0.0])
    cmd.set_color("grass",[0.2,1.0,0.0])
    cmd.set_color("emerald",[0.0,1.0,0.4])
    cmd.set_color("turquoise",[0.0,1.0,0.8])
    cmd.set_color("peacock",[0.0,0.4,1.0])
    cmd.set_color("indigo",[0.4,0.0,1.0])
    cmd.set_color("purple2",[0.8,0.0,1.0])
    cmd.set_color("magenta2",[1.0,0.0,0.8])
    cmd.set_color("violet2",[1.0,0.0,0.4])



def color_by_resname(selection="all"):
    """
    this function aims to color residues. The color of each residues is from
    this article : 
    Taylor, W. R. (1997). Residual colours: a proposal for aminochromography.
    Protein Engineering, 10(7), 743-6.
    usage on pymol : 
    color_by_resname selection.
    > eg: color by resname on chain A.
      color_by_resname chain A
    > eg: color by resname on chain A and only on ALA and LYS.
      color_by_resname chain A and resname ALA+LYS
    > eg: color all by resname
      color_by_resname all
    """
    create_color()
    for res in color_code:
        sel = selection + " and resname %s" % res
        cmd.color(color_code[res], sel)

cmd.extend("color_by_resname",color_by_resname)

and I am trying to add to it. I want to make my script fetch the proteins instead of me having to use the fetch command in the PyMOL console. How can I import PyMOL propertly into Python so I can use the fetch command. Every time I try to import it, I get this error : ImportError: No module named pymol. I am a beginner with Python and I do not really know how to change any paths, so a simple explanation to this problem would be very helpful!

Thanks in advance!

software error PyMOL scripting coding Python • 4.1k views
ADD COMMENT
0
Entering edit mode
6.3 years ago

You first need to install the module, see for example this page: http://www.pymol.org/install

ADD COMMENT
0
Entering edit mode

I already downloaded PyMOL from the website and have the PyMOL Console and GUI on my computer. Do I need to reinstall them?

ADD REPLY
0
Entering edit mode

I don't work on Windows, but do you have multiple versions of Python installed perhaps?

ADD REPLY
0
Entering edit mode

Nope. I just tried pymol.cmd.fetch and it works. Thanks though!

ADD REPLY

Login before adding your answer.

Traffic: 2901 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6