Friday, April 27, 2012

Public folder on Dropbox

http://dl.dropbox.com/u/65895350/

Thursday, April 26, 2012

Extracting coordinates of protein from a simulation

set dir [pwd]
mol new     ${dir}/ache.psf       type {psf}
mol addfile ${dir}/ache.pdb       type {pdb} waitfor all
mol addfile ${dir}/acheminnpt.dcd type {dcd} waitfor all

set molnum 0
set skip 1
set backframe0 [atomselect $molnum backbone frame 0]

for {set i 0} {$i < [molinfo $molnum get numframes]} {incr i $skip} {
set pro  [atomselect $molnum protein  frame $i]

# Change 'protein' to "resid N to Z" to suit your needs.
set back [atomselect $molnum backbone frame $i]
set trans_mat [measure fit $back $backframe0]
$pro move $trans_mat
set k [expr $i/$skip]
$pro writedcd ${dir}/dcd/project-pdb-$k.dcd
}

Now generate a protein-only psf file. At this stage you should have n number of dcd files. To join them all in to one dcd file,

mol new    ${dir}/ache_protein.psf
set pro_frames [expr [molinfo $molnum get numframes]/$skip ]
for {set j 0} {$j < $pro_frames} {incr j 1} {
mol addfile ${dir}/dcd/project-pdb-$j.dcd
}
set top [molinfo top]
animate write dcd {${dir}/dcd/project_protein.dcd} beg 0 end [expr $pro_frames - 1] skip 1 [molinfo top]

The last step is where the individual files are stitched together.

Monday, April 23, 2012

Installing Gimp on Ubuntu 11.1

Last month I installed Gimp on Ubuntu 11.1 which dropped Gimp since they deemed it too complex for new linux converts. Since this was last month I don't remember all the steps I took but I did copy the commands to a file and they might come handy in future. Here they are...

   69  sudo add-apt-repository ppa:matthaeus123/mrw-gimp-svn
   71  sudo apt-get install gimp gimp-data gimp-plugin-registry gimp-data-extras
   73  sudo add-apt-repository ppa:lucid-bleed/ppa
   74  sudo add-apt-repository ppa:matthaeus123/mrw-gimp-svn
   79  mkdir gimp
   80  cd gimp/
   81  wget ftp://ftp.gimp.org/pub/gimp/v2.7/gimp-2.7.2.tar.bz2
   82  tar xjf gimp-2.7.2.tar.bz2
   83  export PATH=/opt/gimp-2.7/bin:$PATH
   84  export PKG_CONFIG_PATH=/opt/gimp-2.7/lib/pkgconfig
   85  export LD_LIBRARY_PATH=/opt/gimp-2.7/lib
   86  cd gimp-2.7.2/
   87  ./configure —prefix=/opt/gimp-2.7
   89  ./configure
   90  cd ..
   92  sudo apt-get install git
   93  git clone git://git.gnome.org/babl
   94  cd gimp-2.7.2/
   95  ./configure --prefix=/opt/gimp-2.7
   96  cd ..
   97  ./autogen.sh --prefix=/opt/gimp-2.7
   99  cd babl/
  100  ./autogen.sh --prefix=/opt/gimp-2.7
  101  make -j5
  102  cd ../gimp-2.7.2/
  103  ./configure --prefix=/opt/gimp-2.7
  104  cd ../babl/
  105  cd ..
  106  git clone git://git.gnome.org/babl
  107  ./autogen.sh --prefix=/opt/gimp-2.7
  108  sudo apt-get install libtool
  109  ./autogen.sh --prefix=/opt/gimp-2.7
  110  cd babl/
  111  ./autogen.sh --prefix=/opt/gimp-2.7
  112  make -j5
  113  sudo make install
  114  cd ../gimp-2.7.2/
  115  ./configure --prefix=/opt/gimp-2.7
  116  cd ..
  117  wget ftp://ftp.gimp.org/pub/gegl/0.1/gegl-0.1.6.tar.bz2
  118  tar -xjf gegl-0.1.6.tar.bz2
  119  sudo apt-get install libjpeg62-dev libopenexr-dev librsvg2-dev
  120  cd gegl-0.1.6/
  121  ./configure --prefix=/opt/gimp-2.7
  122  sudo make install
  123  cd ..
  124  ls
  125  cd gimp-2.7.2/
  126  ./configure --prefix=/opt/gimp-2.7
  127  sudo apt-get install libtiff4-dev python-dev python-gtk2-dev
  128  ./configure --prefix=/opt/gimp-2.7
  129  which gimp
  130  sudo apt-get install libexif-dev liblcms1-dev
  131  ./configure --prefix=/opt/gimp-2.7
  132  make -j5
  133  make install -j5
  134  sudo make install -j5
  135  ls /opt/gimp-2.7/bin/gimp-2.7
  136  /opt/gimp-2.7/bin/gimp-2.7
  137  history > ~/gimpinstallcommands.dat

Making movies with VMD/PyMol


These two scripts help greatly in making and handling movies. I need scripts instead of the GUI because most of my data is on machines on the other coast and it gets rather cumbersome to pull a gigantic trajectory file just to see a quick snapshot of the system. I could make PDB (or better dcd) files of parts of trajectory I am interested in, but I will need to make movies at some point.

view_change_render.tcl
trajectory_movie.tcl
http://www.myofilament.org/documents/howto/modeling/VMD_Tcl.htm

PyMol uses get_view and "set view" commands to save and retrieve views of molecules. VMD handles things a little differently. It needs 4 parameters per view. They are [rotate/center/scale/global]_matrix. Saving and retrieving are done by processes below. They have been taken from view_change_render.tcl
I added the last part get_vp to see what the view point actually looks like (similar to get_view in PyMol).

proc save_vp {view_num} {
  global viewpoints
  if [info exists viewpoints($view_num)] {unset viewpoints($view_num)}
  # get the current matricies
  foreach mol [molinfo list] {
    set viewpoints($view_num,$mol,0) [molinfo $mol get rotate_matrix]
    set viewpoints($view_num,$mol,1) [molinfo $mol get center_matrix]
    set viewpoints($view_num,$mol,2) [molinfo $mol get scale_matrix]
    set viewpoints($view_num,$mol,3) [molinfo $mol get global_matrix]
  }
} 
  
 
 proc retrieve_vp {view_num} {
  global viewpoints
  foreach mol [molinfo list] {
    if [info exists viewpoints($view_num,$mol,0)] {
      molinfo $mol set rotate_matrix   $viewpoints($view_num,$mol,0)
      molinfo $mol set center_matrix   $viewpoints($view_num,$mol,1)
      molinfo $mol set scale_matrix   $viewpoints($view_num,$mol,2)
      molinfo $mol set global_matrix   $viewpoints($view_num,$mol,3)
    } else {
      puts "View $view_num was not saved"}
  }
}
 
 proc get_vp {view_num} {
  global viewpoints
  foreach mol [molinfo list] {
    if [info exists viewpoints($view_num,$mol,0)] {
puts "global viewpoints"
puts "molinfo $mol set rotate_matrix     \"$viewpoints($view_num,$mol,0)\""
puts "molinfo $mol set center_matrix     \"$viewpoints($view_num,$mol,1)\""
puts "molinfo $mol set scale_matrix      \"$viewpoints($view_num,$mol,2)\""
puts "molinfo $mol set global_matrix     \"$viewpoints($view_num,$mol,3)\""
    } else {
      puts "View $view_num was not saved"}
  }
}
 
 
Once you save this output (as a text file) it becomes very easy to retrieve the view even 
after closing down VMD. Simply copy and paste the output of get_vp.

Friday, April 20, 2012

Loops in Tcl/Tk

If loop

if { test1 } {
body1 
} elseif { test2 } {
body2 
} else {
bodyn
}


For loop

for { set i 1 } { $i <= 10 } { incr i } { # This will append all multiples of all numbers for the number n # into a variable called table set table "$table $i x $n = [expr $i \* $n]\n" }
 
 #Make the list
set list [list "Item 1" {Item 2} Last]
set text ""
foreach item $list {
 #Append the every item to $text
 set text "$text\n$item"
}
Foreach loop

#Make the list 
set list [list "Item 1" {Item 2} Last] 
set text "" 

foreach item $list { 
#Append the every item to $text 
 set text "$text\n$item"
 }