Ejemplo n.º 1
0
def run(parm_file_name,
      traj_file_name,
      asu_prmtop_file_name,
      asu_rst7_file_name,
      prop_a, prob_b, prop_c,
      target_unit_cell,
      atoms_per_uc,
      wrap,
      buffer,
      spacegroup = ' '):
  print "loading prmtop %s" %parm_file_name
  parm = AmberParm(parm_file_name)
  print "loading trajec %s" %traj_file_name
  traj = NetCDFTraj.open_old(traj_file_name)
  n_frames = traj.frame
  U, invU, UCbox = get_U_invU(asu_rst7_file_name)
  start_atm, end_atm = calc_start_end_atm(atoms_per_uc, target_unit_cell,
                                          prop_a, prop_b, prop_c)

  for frame in range(n_frames):
  # for frame in range(0,1):
    coords = traj.coordinates(frame)
    frac_crds = get_frac_crds(coords, traj, U)
    cntred_frac_crds = center_frac_coords(frac_crds, parm, start_atm, end_atm)
    print frame
    if wrap:
      wrap_coords(parm, frac_crds, cntred_frac_crds, prop_a, prop_b, prop_c, buffer, solvent=True)
    atom_selection = select_atoms(cntred_frac_crds, parm, buffer, solvent=True)
    frac_crds = rev_translate_frac_crds(frac_crds, target_unit_cell, prop_a, prop_b, prop_c)
    coords = get_cart_crds(frac_crds, traj, invU).flatten()
    write_pdb(coords, parm, atom_selection, 'PDBDATA_UC%02d/%04d' %(target_unit_cell,frame), UCbox, spacegroup)
    # import code; code.interact(local=dict(globals(), **locals()))
  return atom_selection
Ejemplo n.º 2
0
 def testScientificPython(self):
     """ Test ScientificPython parsing """
     import chemistry.amber as amber
     if utils.has_scientific():
         amber.use('Scientific')
         from chemistry.amber.netcdffiles import NetCDFTraj, NetCDFRestart
         traj = NetCDFTraj.open_old(get_fn('tz2.truncoct.nc'))
         self._check_traj(traj)
         rst = NetCDFRestart.open_old(get_fn('ncinpcrd.rst7'))
         self._check_rst(rst)
     else:
         self.assertRaises(ImportError, lambda: amber.use('Scientific'))
Ejemplo n.º 3
0
 def testScientificPython(self):
     """ Test ScientificPython parsing """
     import chemistry.amber as amber
     if utils.has_scientific():
         amber.use('Scientific')
         from chemistry.amber.netcdffiles import NetCDFTraj, NetCDFRestart
         traj = NetCDFTraj.open_old(get_fn('tz2.truncoct.nc'))
         self._check_traj(traj)
         rst = NetCDFRestart.open_old(get_fn('ncinpcrd.rst7'))
         self._check_rst(rst)
     else:
         self.assertRaises(ImportError, lambda: amber.use('Scientific'))
Ejemplo n.º 4
0
    def report(self, simulation, state):
        """Generate a report.

        Parameters
        ----------
        simulation : :class:`app.Simulation`
            The Simulation to generate a report for
        state : :class:`mm.State`
            The current state of the simulation
        """
        global VELUNIT, FRCUNIT
        if self.crds:
            crds = state.getPositions().value_in_unit(u.angstrom)
        if self.vels:
            vels = state.getVelocities().value_in_unit(VELUNIT)
        if self.frcs:
            frcs = state.getForces().value_in_unit(FRCUNIT)
        if self._out is None:
            # This must be the first frame, so set up the trajectory now
            if self.crds:
                atom = len(crds)
            elif self.vels:
                atom = len(vels)
            elif self.frcs:
                atom = len(frcs)
            self.uses_pbc = simulation.topology.getUnitCellDimensions(
            ) is not None
            self._out = NetCDFTraj.open_new(
                self.fname,
                atom,
                self.uses_pbc,
                self.crds,
                self.vels,
                self.frcs,
                title="ParmEd-created trajectory using OpenMM")
        if self.uses_pbc:
            vecs = state.getPeriodicBoxVectors()
            lengths, angles = box_vectors_to_lengths_and_angles(*vecs)
            self._out.add_cell_lengths_angles(
                lengths.value_in_unit(u.angstrom),
                angles.value_in_unit(u.degree))

        # Add the coordinates, velocities, and/or forces as needed
        if self.crds:
            self._out.add_coordinates(crds)
        if self.vels:
            # The velocities get scaled right before writing
            self._out.add_velocities(vels)
        if self.frcs:
            self._out.add_forces(frcs)
        # Now it's time to add the time.
        self._out.add_time(state.getTime().value_in_unit(u.picosecond))
Ejemplo n.º 5
0
def run(parm_file_name,
        traj_file_name,
        asu_prmtop_file_name,
        asu_rst7_file_name,
        prop_a,
        prob_b,
        prop_c,
        target_unit_cell,
        atoms_per_uc,
        wrap,
        buffer,
        spacegroup=' '):
    parm = AmberParm(parm_file_name)
    traj = NetCDFTraj.open_old(traj_file_name)
    n_frames = traj.frame
    U, invU, UCbox = get_U_invU(asu_rst7_file_name)
    start_atm, end_atm = calc_start_end_atm(atoms_per_uc, target_unit_cell,
                                            prop_a, prop_b, prop_c)

    # for frame in range(n_frames):
    #   parm = AmberParm(parm_file_name)
    for frame in range(0, 1):
        coords = traj.coordinates(frame)
        frac_crds = get_frac_crds(coords, traj, U)
        cntred_frac_crds = center_frac_coords(frac_crds, parm, start_atm,
                                              end_atm)
        # atom_selection1 = select_atoms(cntred_frac_crds, parm, buffer, solvent=True)
        print frame
        # print atom_selection1
        # print frac_crds[9794]
        # print cntred_frac_crds[9794]
        # if wrap:
        #   wrap_coords(parm, frac_crds, cntred_frac_crds, prop_a, prop_b, prop_c, buffer, solvent=True)
        atom_selection = select_atoms(cntred_frac_crds,
                                      parm,
                                      buffer,
                                      solvent=True)
        frac_crds = rev_translate_frac_crds(frac_crds, target_unit_cell,
                                            prop_a, prop_b, prop_c)
        coords = get_cart_crds(frac_crds, traj, invU).flatten()
        # print atom_selection
        # print cntred_frac_crds[9794]
        write_pdb(coords, parm, atom_selection,
                  'uc%d_frame%d' % (target_unit_cell, frame), UCbox,
                  spacegroup)
        # write_pdb(coords, parm, atom_selection1, 'uc%d_frame%d_nowrap' %(target_unit_cell,frame))
        write_amber_files(coords, parm,
                          'uc%d_frame%d' % (target_unit_cell, frame),
                          atom_selection)
        # import code; code.interact(local=dict(globals(), **locals()))
    return atom_selection
Ejemplo n.º 6
0
    def report(self, simulation, state):
        """Generate a report.

        Parameters
        ----------
        simulation : :class:`app.Simulation`
            The Simulation to generate a report for
        state : :class:`mm.State`
            The current state of the simulation
        """
        global VELUNIT, FRCUNIT
        if self.crds:
            crds = state.getPositions().value_in_unit(u.angstrom)
        if self.vels:
            vels = state.getVelocities().value_in_unit(VELUNIT)
        if self.frcs:
            frcs = state.getForces().value_in_unit(FRCUNIT)
        if self._out is None:
            # This must be the first frame, so set up the trajectory now
            if self.crds:
                atom = len(crds)
            elif self.vels:
                atom = len(vels)
            elif self.frcs:
                atom = len(frcs)
            self.uses_pbc = simulation.topology.getUnitCellDimensions() is not None
            self._out = NetCDFTraj.open_new(
                    self.fname, atom, self.uses_pbc, self.crds, self.vels,
                    self.frcs, title="ParmEd-created trajectory using OpenMM"
            )
        if self.uses_pbc:
            vecs = state.getPeriodicBoxVectors()
            lengths, angles = box_vectors_to_lengths_and_angles(*vecs)
            self._out.add_cell_lengths_angles(lengths.value_in_unit(u.angstrom),
                                              angles.value_in_unit(u.degree))

        # Add the coordinates, velocities, and/or forces as needed
        if self.crds:
            self._out.add_coordinates(crds)
        if self.vels:
            # The velocities get scaled right before writing
            self._out.add_velocities(vels)
        if self.frcs:
            self._out.add_forces(frcs)
        # Now it's time to add the time.
        self._out.add_time(state.getTime().value_in_unit(u.picosecond))
Ejemplo n.º 7
0
def run(parm_file_name,
      traj_file_name,
      asu_prmtop_file_name,
      asu_rst7_file_name,
      prop_a, prob_b, prop_c,
      target_unit_cell,
      atoms_per_uc,
      wrap,
      buffer,
      spacegroup = ' '):
  parm = AmberParm(parm_file_name)
  traj = NetCDFTraj.open_old(traj_file_name)
  n_frames = traj.frame
  U, invU, UCbox = get_U_invU(asu_rst7_file_name)
  start_atm, end_atm = calc_start_end_atm(atoms_per_uc, target_unit_cell,
                                          prop_a, prop_b, prop_c)

  # for frame in range(n_frames):
  #   parm = AmberParm(parm_file_name)
  for frame in range(0,1):
    coords = traj.coordinates(frame)
    frac_crds = get_frac_crds(coords, traj, U)
    cntred_frac_crds = center_frac_coords(frac_crds, parm, start_atm, end_atm)
    # atom_selection1 = select_atoms(cntred_frac_crds, parm, buffer, solvent=True)
    print frame
    # print atom_selection1
    # print frac_crds[9794]
    # print cntred_frac_crds[9794]
    # if wrap:
    #   wrap_coords(parm, frac_crds, cntred_frac_crds, prop_a, prop_b, prop_c, buffer, solvent=True)
    atom_selection = select_atoms(cntred_frac_crds, parm, buffer, solvent=True)
    frac_crds = rev_translate_frac_crds(frac_crds, target_unit_cell, prop_a, prop_b, prop_c)
    coords = get_cart_crds(frac_crds, traj, invU).flatten()
    # print atom_selection
    # print cntred_frac_crds[9794]
    write_pdb(coords, parm, atom_selection, 'uc%d_frame%d' %(target_unit_cell,frame), UCbox, spacegroup)
    # write_pdb(coords, parm, atom_selection1, 'uc%d_frame%d_nowrap' %(target_unit_cell,frame))
    write_amber_files(coords, parm, 'uc%d_frame%d' %(target_unit_cell,frame), atom_selection)
    # import code; code.interact(local=dict(globals(), **locals()))
  return atom_selection
Ejemplo n.º 8
0
    def report(self, simulation, state):
        """Generate a report.

        Parameters:
            - simulation (Simulation) The Simulation to generate a report for
            - state (State) The current state of the simulation
        """
        global RADDEG, VELUNIT, FRCUNIT
        if self._out is None:
            # This must be the first frame, so set up the trajectory now
            self._out = NetCDFTraj.open_new(
                self.fname,
                self.atom,
                self.uses_pbc,
                self.crds,
                self.vels,
                self.frcs,
                title="ParmEd-created trajectory using OpenMM",
            )
        if self.uses_pbc:
            vecs = state.getPeriodicBoxVectors()
            lengths, angles = _process_box_vectors(*vecs)
            self._out.add_cell_lengths_angles(lengths, angles)

        # Add the coordinates, velocities, and/or forces as needed
        if self.crds:
            self._out.add_coordinates(state.getPositions().value_in_unit(u.angstrom))
        if self.vels:
            vels = state.getVelocities().value_in_unit(VELUNIT)
            # Divide by the scaling factor (works if vels is a list of Vec3's)
            vels = [v / self._out.velocity_scale for v in vels]
            self._out.add_velocities(vels)
        if self.frcs:
            frcs = state.getForces().value_in_unit(FRCUNIT)
            self._out.add_forces(frcs)
        # Now it's time to add the time.
        self._out.add_time(state.getTime().value_in_unit(u.picosecond))