VisLoad: Difference between revisions

From PyMOLWiki
Jump to navigation Jump to search
(Created page with 'visLoad will load an object and show it in your desired representation. PyMOL by default loads things as lines (or spheres, a setting you may change), but not others. = Usa…')
 
mNo edit summary
 
(3 intermediate revisions by 3 users not shown)
Line 1: Line 1:
{{Infobox script-repo
|type      = Python Module
|filename  =
|author    = [[User:Inchoate|Jason Vertrees]]
|license  = [http://www.opensource.org/licenses/BSD-2-Clause BSD]
}}
[[visLoad]] will load an object and show it in your desired representation.  PyMOL by default loads things as lines (or spheres, a setting you may change), but not others.
[[visLoad]] will load an object and show it in your desired representation.  PyMOL by default loads things as lines (or spheres, a setting you may change), but not others.


Line 9: Line 16:
= The Code =
= The Code =
<source lang="python">
<source lang="python">
import string
import os
import os
from os import path
from os import path
from pymol import cmd


def visLoad(filename, object=None, *args, **kwargs):
def visLoad(filename, object=None, *args, **kwargs):
         if object==None:
         if object==None:
                 object = string.split(os.path.basename(filename),".")[0]
                 object = os.path.basename(filename).split(".")[0]
         cmd.set("suspend_updates")
         cmd.set("suspend_updates")
         try:
         try:
Line 28: Line 35:
= See Also =
= See Also =
[[Load]], [[Save]], [[Show_as]]
[[Load]], [[Save]], [[Show_as]]
Settings: [[auto_show_lines]], [[auto_show_nonbonded]], [[auto_show_spheres]]


[[Category:Script_Library]]
[[Category:Script_Library]]
[[Category:UI_Scripts]]
[[Category:UI_Scripts]]

Latest revision as of 09:52, 9 December 2011

Type Python Module
Download
Author(s) Jason Vertrees
License BSD

visLoad will load an object and show it in your desired representation. PyMOL by default loads things as lines (or spheres, a setting you may change), but not others.

Usage

  • Save the code to "visLoad.py".
  • Run the code from PyMOL or put it in your .pymolrc
  • Use visLoad whenever you would use load
  • To change representations, update "cartoon" to something else, or add more intermediate commands.

The Code

import os
from os import path
from pymol import cmd

def visLoad(filename, object=None, *args, **kwargs):
        if object==None:
                object = os.path.basename(filename).split(".")[0]
        cmd.set("suspend_updates")
        try:
                cmd.load(filename, object, *args, **kwargs)
                cmd.show_as("cartoon", object)
        finally:
                cmd.set("suspend_updates", "off")

cmd.extend("visLoad", visLoad)

See Also

Load, Save, Show_as

Settings: auto_show_lines, auto_show_nonbonded, auto_show_spheres