Ejemplo n.º 1
0
def run(pdbfile,prmtopfile,crdfile):
#	coords=raf.pdb(pdbfile).Get_Coords()
	#~ coords=jiggle(coords)

	U=ext.uform(prmtopfile, crdfile)

	gradients=flex.double(150)
	print gradients
	gradients_flex=ext.ExtractVec(gradients)

	n=list(coords.flatten())
	sites_cart_c=ext.ExtractVec2(n)
        nowendithere
	gradients_c=ext.ExtractVec(gradients)
	target_c=ext.ExtractVec(target)
	ext.callMdgx(sites_cart_c, gradients_c, target_c, U)
	gradients=flex.vec3_double(gradients_c)*-1
	target= flex.double(target_c)	
Ejemplo n.º 2
0
def run(pdbfile,prmtopfile,crdfile):
  #READ PDB FILE
  apdb=raf.pdb(pdbfile)
  box=apdb.Get_Box()
  coords=apdb.Get_Coords()
  natoms=natoms= len(apdb.ATOMlines)

  #JIGGLE COORDINATES
  coords=jiggle(coords)

  #INSTATIATE MDGX STRUCTS AND ARRAYS
  U=ext.uform(prmtopfile, crdfile)
  sites_cart=coords.flatten()
  gradients=np.zeros(len(sites_cart))
  target=np.zeros(10)

  #GET INITIAL GRADIENTS AND ENERGIES
  old_gradients,old_target=get_gradients_and_target(sites_cart, gradients, target, U) 

  #STEEPEST DESCENT ITERATIONS
  i=0
  while i<100:
    sites_cart=steepest_descent(sites_cart, old_gradients)

    new_gradients, new_target= get_gradients_and_target(sites_cart, gradients, target, U)     

    target_diff=old_target[0]-new_target[0]
    delta_gradient_rms=old_target[9]-new_target[9]
    print("%7.3f   %7.3f   %7.3f" %(new_target[0], target_diff, delta_gradient_rms))
    if delta_gradient_rms<0.001 or target_diff<0.001:
      break
    
    old_gradients, old_target=new_gradients, new_target
    
    i+=1        

  print("Minimization termination condition reached after %d steps." %i)

  #CALCULATE RMSD
  newcoords=np.reshape(sites_cart, (-1,3))
  newcoords=raf.KabschAlign(coords, newcoords)
  rmsd=raf.RMSD(coords,newcoords)
  print("RMSD between original and minimized structure: %7.4f" %rmsd)
Ejemplo n.º 3
0
def run(pdb,prmtop, crd):

  #===================================================================#
  #                                                                   #
  #  BEFORE C++                                                       #
  #                                                                   #
  #===================================================================#

  #file i/o
  pdb_file = os.path.abspath(pdb)
  pdb_inp = iotbx.pdb.input(file_name=pdb_file)
  pdb_atoms = pdb_inp.atoms_with_labels()
  symm = pdb_inp.crystal_symmetry()
  xray_structure = pdb_inp.xray_structure_simple(enable_scattering_type_unknown=True)


  #     initiate flex arrays for coordinates, gradients, energy
  sites_cart=xray_structure.sites_cart()
  gradients=flex.double(len(sites_cart)*3)
  target=flex.double([6.7,1.0,2.0,3.0,4.0,5.0,0.0,0.0,0.0,0.0])
  print "Number of atom sites: %d " %sites_cart.size()
  print "\nGradients and target BEFORE C call:"
  print list(gradients[1:10])
  print target[0]

  #===================================================================#
  #                                                                   #
  #  CALL C++                                                         #
  #                                                                   #
  #===================================================================#

  U=ext.uform(prmtop, crd)

  #Convert flex arrays to C arrays
  sites_cart_c=ext.ExtractVec(sites_cart.as_double())
  gradients_c=ext.ExtractVec(gradients)
  target_c=ext.ExtractVec(target)

  # Call c++ interface to call mdgx to calculate new gradients and target
  ext.callMdgx(sites_cart_c, gradients_c, target_c, U)

  # Convert back into python types (eg. into flex arrays for phenix to use)
  gradients=flex.vec3_double(gradients_c)*-1

  target= flex.double(target_c)

  #===================================================================#
  #                                                                   #
  #  AFTER C++                                                        #
  #                                                                   #
  #===================================================================#


  print "\nGradients and target AFTER C call:"
  print list(gradients[0:10])
  print target[0]
  print target[9]

  print "\n"
  print "Amber_total_energy: %7.6f"             %(target[0])
  print "  bonds (n= ): %7.6f"                  %(target[1])
  print "  angles (n= ): %7.6f"                         %(target[2])
  print "  dihedrals (n= ): %7.6f"              %(target[3])
  print "  electrostatics: %7.6f"               %(target[4])
  print "  vanderWaals: %7.6f"                  %(target[5])
  print "\n\n"

  return 0
Ejemplo n.º 4
0
def get_amber_structs (prmtop, ambcrd):
        return ext.uform(prmtop, ambcrd)