Default Representation/Drawing method in VMD

2.8k Views Asked by At

In VMD I want to load every new file with the drawing method CPK. This doesn't seem not to be an option in the .vmdrc file for some technical reasons.

How can I do this from the VMD command line (so that I can make a script)? Or is there some other solution/workaround/hack to make this work?

3

There are 3 best solutions below

6
On BEST ANSWER

There are several ways to achieve what you want:

(1) put the following line in the correct location of your .vmdrc

    mol default style CPK

(2) use the VMD Preferences Panel (last item in the Extensions menu of the main window) to generate a .vmdrc file that meets your expectations(s). The setting you're looking for is in the Representations tab.

(3) for more advanced settings (i.e. default settings applied to molecules already loaded when vmd read the startup .vmdrc file), you can use the following (works for me on VMD 1.9.2):

proc reset_viz {molid} {
  # operate only on existing molecules
  if {[lsearch [molinfo list] $molid] >= 0} {
    # delete all representations
    set numrep [molinfo $molid get numreps]
    for {set i 0} {$i < $numrep} {incr i} {
      mol delrep $i $molid
    }
    # add new representations
    mol representation CPK
    # add other representation stuff you want here
    mol addrep $molid
  } 
}

proc reset_viz_proxy {args} {
  foreach {fname molid rw} $args {}
  eval "after idle {reset_viz $molid}"
}

## put a trace on vmd_initialize_structure
trace variable vmd_initialize_structure w reset_viz_proxy

after idle {
  if { 1 } {
    foreach molid [molinfo list] {
      reset_viz $molid
    }
  }
}

This piece of code is adapted from this Axel Kohlmeyer website.

HTH,

0
On

I found a convenient solution. In .bashrc add:

vmda () {
    echo -e "
    mol default style CPK
    user add key Control-w quit
    " > /tmp/vmdstartup
    echo "mol new $1" > /tmp/vmdcommand
    vmd -e /tmp/vmdcommand -startup /tmp/vmdstartup
}

Look at a structure with

vmda file.pdb

and close the window (quit the application) with Ctrl+w, like other windows.

0
On

Following @Eiffel's 2nd solution and the discussion under the comment section:

@Steven C. Howell says:

I left the setting in and just realized that while it does not work when loading a structure directly from the command line, e.g., $> vmd my.pdb my.dcd, it does work when loading a structure after opening the application.

Here's what you can do.

First, follow @Eiffel's 2nd solution, and generate the .vmdrc file. Then, open .vmdrc file and under section

    # <representations>
    # state : active
    if { 1 } {
      mol default color Name
      mol default material Opaque
      mol default style CPK
      mol default selection {all}

add

      mol representation VDW 0.200000 12.000000
      mol color Name
      mol selection {all}
      mol material Opaque
      mol addrep top
      mol selupdate 0 top 0
      mol colupdate 0 top 0
      mol scaleminmax top 0 0.000000 0.000000
      mol smoothrep top 0 0
      mol drawframes top 0 {now}
      mol clipplane center 0 0 top {0.0 0.0 0.0}
      mol clipplane color  0 0 top {0.5 0.5 0.5 }
      mol clipplane normal 0 0 top {0.0 0.0 1.0}
      mol clipplane status 0 0 top {0}
      mol clipplane center 1 0 top {0.0 0.0 0.0}
      mol clipplane color  1 0 top {0.5 0.5 0.5 }
      mol clipplane normal 1 0 top {0.0 0.0 1.0}
      mol clipplane status 1 0 top {0}
      mol clipplane center 2 0 top {0.0 0.0 0.0}
      mol clipplane color  2 0 top {0.5 0.5 0.5 }
      mol clipplane normal 2 0 top {0.0 0.0 1.0}
      mol clipplane status 2 0 top {0}
      mol clipplane center 3 0 top {0.0 0.0 0.0}
      mol clipplane color  3 0 top {0.5 0.5 0.5 }
      mol clipplane normal 3 0 top {0.0 0.0 1.0}
      mol clipplane status 3 0 top {0}
      mol clipplane center 4 0 top {0.0 0.0 0.0}
      mol clipplane color  4 0 top {0.5 0.5 0.5 }
      mol clipplane normal 4 0 top {0.0 0.0 1.0}
      mol clipplane status 4 0 top {0}
      mol clipplane center 5 0 top {0.0 0.0 0.0}
      mol clipplane color  5 0 top {0.5 0.5 0.5 }
      mol clipplane normal 5 0 top {0.0 0.0 1.0}
      mol clipplane status 5 0 top {0}

Those lines will update the currently loaded molecules.

If you want to customize the start-up configuration further, A trick to get the correct command is to first set-up your representation manually, then go to File -> Save Visualization State, save it as "something.txt". Open the "something.txt" and identify the lines that resets the representations, then copy it to the corresponding lines in the correct location in ~/.vmdrc