Exemplo n.º 1
0
  def view_trajectory(self):
    """
    Output the trajectory as a DCD file and views it in VMD
    """
    if self.args['grid_LJr'].endswith('.nc') and (not os.path.isfile(self.args['grid_LJr'][:-2]+'dx')):
      import AlGDock.IO
      IO_Grid = AlGDock.IO.Grid()
      IO_Grid.read(self.args['grid_LJr'])
      IO_Grid.write(self.args['grid_LJr'][:-2]+'dx')
    
    scriptFN = 'script.vmd'

    script = ''
    script +=  'set ligand [mol new '+self.args['ligand_prmtop']+']\n'
    script += 'mol addfile '+self.args['output_dcd']+' type dcd waitfor all\n'
    script += 'mol new {%s} type {dx} first 0 last -1 step 1 waitfor 1\n'%(self.args['grid_LJr'][:-2]+'dx')
    script += 'mol modstyle 0 1 Isosurface 10.000000 0 2 0 1 1\n'

    scriptF = open(scriptFN,'w')
    scriptF.write(script)
    scriptF.close()

    import AlGDock
    vmdFN = AlGDock.findPaths(['vmd'])['vmd']
    vmd_args = [vmdFN] + ['-e', scriptFN]
    import subprocess
    p = subprocess.call(vmd_args)
Exemplo n.º 2
0
  def showMolecule(self, colorBy=None, label=False, dcdFN=None):
    """
    Opens the molecule in VMD
    :param colorBy: color atoms by 'Occupancy', or 'Beta'. None uses default colors.
    """
    # Write PDB file
    # To set Occupancy, change atom.occupancy
    # To set Beta, change atom.temperature_factor
    import os.path
    pdbFN = os.path.join(MMTK.Database.molecule_types.directory,
                         'showMolecule.pdb')
    outF = MMTK.PDB.PDBOutputFile(pdbFN)
    outF.write(self.molecule)
    outF.close()
    # Write VMD script
    script = 'set ligand [mol new ' + pdbFN + ']\n'
    if colorBy is not None:
      script += 'mol modcolor 0 $ligand ' + colorBy + '\n'
    script += 'mol modstyle 0 0 CPK 1.000000 0.300000 10.000000 10.000000\n'
    if label:
      script += """
proc label_atoms { molid seltext } {
  set sel [atomselect $molid $seltext] 
  set atomlist [$sel list] 
  foreach {atom} $atomlist { 
    set atomlabel [format "%d/%d" $molid $atom]
    label add Atoms $atomlabel 
  } 
  $sel delete 
} 
label_atoms 0 all
"""
    if dcdFN is not None:
      script += 'animate delete all $ligand\n'
      script += 'mol addfile ' + dcdFN + ' type dcd waitfor all\n'
    scriptF = open('showMolecule.vmd', 'w')
    scriptF.write(script)
    scriptF.close()
    # Find and run vmd
    import AlGDock
    vmdCommand = AlGDock.findPath(AlGDock.search_paths['vmd'])
    import subprocess
    subprocess.call([vmdCommand, '-e', 'showMolecule.vmd'])
    # Remove files
    os.remove(pdbFN)
    os.remove('showMolecule.vmd')
Exemplo n.º 3
0
  def showMolecule(self, colorBy=None, label=False, dcdFN=None):
    """
    Opens the molecule in VMD
    :param colorBy: color atoms by 'Occupancy', or 'Beta'. None uses default colors.
    """
    # Write PDB file
    # To set Occupancy, change atom.occupancy
    # To set Beta, change atom.temperature_factor
    import os.path
    pdbFN = os.path.join(MMTK.Database.molecule_types.directory,'showMolecule.pdb')
    outF = MMTK.PDB.PDBOutputFile(pdbFN)
    outF.write(self.molecule)
    outF.close()
    # Write VMD script
    script  = 'set ligand [mol new '+pdbFN+']\n'
    if colorBy is not None:
      script += 'mol modcolor 0 $ligand '+colorBy+'\n'
    script += 'mol modstyle 0 0 CPK 1.000000 0.300000 10.000000 10.000000\n'
    if label:
      script += """
proc label_atoms { molid seltext } {
  set sel [atomselect $molid $seltext] 
  set atomlist [$sel list] 
  foreach {atom} $atomlist { 
    set atomlabel [format "%d/%d" $molid $atom]
    label add Atoms $atomlabel 
  } 
  $sel delete 
} 

label_atoms 0 all
"""
    if dcdFN is not None:
      script += 'mol addfile '+dcdFN+' type dcd waitfor all\n'
    scriptF = open('showMolecule.vmd','w')
    scriptF.write(script)
    scriptF.close()
    # Find and run vmd
    import AlGDock
    vmdCommand = AlGDock.findPath(AlGDock.search_paths['vmd'])
    import subprocess
    subprocess.call([vmdCommand, '-e', 'showMolecule.vmd'])
    # Remove files
    os.remove(pdbFN)
    os.remove('showMolecule.vmd')