Ejemplo n.º 1
0
  def energies_sites(self, compute_gradients=False):
    #Convert flex arrays to C arrays
    sites_cart_c=ext.ExtractVec(self.sites_cart.as_double())
    gradients_c=ext.ExtractVec(flex.double(self.sites_cart.size() * 3, 0))
    energy_components_c=ext.ExtractVec(self.energy_components)

    # Call c++ interface to call mdgx to calculate new gradients and target
    ext.callMdgx(sites_cart_c, gradients_c, energy_components_c, self.mdgx_structs)
    if (compute_gradients) :
      gradients = self.gradients_factory(gradients_c) * -1
    else :
      gradients = self.gradients_factory(
        flex.double(self.sites_cart.size() * 3,0))
    result = energies(
      compute_gradients=compute_gradients,
      gradients=gradients,
      gradients_size=None,
      gradients_factory=None,
      normalization=False)
    result.number_of_restraints = self.number_of_restraints
    result.residual_sum = float(energy_components_c[0])
    result.energy_components = list(energy_components_c)
    result.finalize_target_and_gradients()
    #result.show()
    return result
Ejemplo n.º 2
0
def get_gradients_and_target(sites_cart,gradients,target, U):
  sites_cart_c=ext.VectorOfDouble()
  sites_cart_c.extend(i for i in sites_cart)
  gradients_c=ext.VectorOfDouble()
  gradients_c.extend(i for i in gradients)
  target_c=ext.VectorOfDouble()
  target_c.extend(i for i in target)
  ext.callMdgx(sites_cart_c, gradients_c, target_c, U)
  gradients=np.array(gradients_c)
  target=np.array(target_c)

  return gradients, target
Ejemplo n.º 3
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.º 4
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