コード例 #1
0
def test_read_pdb():
   """Tests that pdb files are read correctly."""

   with open(local("test.pos_0.pdb"), "r") as f:
      atoms, cell = io_pdb.read_pdb(f)
      assert(len(atoms) == 3)
      assert_equal(pos, atoms.q)
コード例 #2
0
ファイル: initializer.py プロジェクト: stanmoore1/lammps
def init_pdb(filename):
    """Reads an pdb file and returns the data contained in it.

   Args:
      filename: A string giving the name of the pdb file to be read from.

   Returns:
      A list of Atoms objects as read from each frame of the pdb file, and
      a Cell object as read from the final pdb frame.
   """

    rfile = open(filename, "r")
    ratoms = []
    while True:
        #while loop, so that more than one configuration can be given
        #so multiple beads can be initialized at once.
        try:
            myatoms, rcell = read_pdb(rfile)
        except EOFError:
            break
        ratoms.append(myatoms)
    return (ratoms, rcell)  # if multiple frames, the last cell is returned
コード例 #3
0
def init_pdb(filename):
   """Reads an pdb file and returns the data contained in it.

   Args:
      filename: A string giving the name of the pdb file to be read from.

   Returns:
      A list of Atoms objects as read from each frame of the pdb file, and
      a Cell object as read from the final pdb frame.
   """

   rfile = open(filename,"r")
   ratoms = []
   while True:
   #while loop, so that more than one configuration can be given
   #so multiple beads can be initialized at once.
      try:
         myatoms, rcell  = read_pdb(rfile)
      except EOFError:
         break
      ratoms.append(myatoms)
   return ( ratoms, rcell ) # if multiple frames, the last cell is returned
コード例 #4
0
ファイル: ensembles.py プロジェクト: stanmoore1/lammps
    def step(self):
        """Does one simulation time step."""

        self.ptime = self.ttime = 0
        self.qtime = -time.time()

        try:
            if (self.intraj.mode == "xyz"):
                for b in self.beads:
                    myatoms = read_xyz(self.rfile)
                    myatoms.q *= unit_to_internal("length", self.intraj.units,
                                                  1.0)
                    b.q[:] = myatoms.q
            elif (self.intraj.mode == "pdb"):
                for b in self.beads:
                    myatoms, mycell = read_pdb(self.rfile)
                    myatoms.q *= unit_to_internal("length", self.intraj.units,
                                                  1.0)
                    mycell.h *= unit_to_internal("length", self.intraj.units,
                                                 1.0)
                    b.q[:] = myatoms.q
                self.cell.h[:] = mycell.h
            elif (self.intraj.mode == "chk"
                  or self.intraj.mode == "checkpoint"):
                # reads configuration from a checkpoint file
                xmlchk = xml_parse_file(self.rfile)  # Parses the file.

                from ipi.inputs.simulation import InputSimulation
                simchk = InputSimulation()
                simchk.parse(xmlchk.fields[0][1])
                mycell = simchk.cell.fetch()
                mybeads = simchk.beads.fetch()
                self.cell.h[:] = mycell.h
                self.beads.q[:] = mybeads.q
                softexit.trigger(" # Read single checkpoint")
        except EOFError:
            softexit.trigger(" # Finished reading re-run trajectory")

        self.qtime += time.time()
コード例 #5
0
ファイル: ensembles.py プロジェクト: Clockwork-Sphinx/lammps
    def step(self):
        """Does one simulation time step."""

        self.ptime = self.ttime = 0
        self.qtime = -time.time()

        try:
            if self.intraj.mode == "xyz":
                for b in self.beads:
                    myatoms = read_xyz(self.rfile)
                    myatoms.q *= unit_to_internal("length", self.intraj.units, 1.0)
                    b.q[:] = myatoms.q
            elif self.intraj.mode == "pdb":
                for b in self.beads:
                    myatoms, mycell = read_pdb(self.rfile)
                    myatoms.q *= unit_to_internal("length", self.intraj.units, 1.0)
                    mycell.h *= unit_to_internal("length", self.intraj.units, 1.0)
                    b.q[:] = myatoms.q
                self.cell.h[:] = mycell.h
            elif self.intraj.mode == "chk" or self.intraj.mode == "checkpoint":
                # reads configuration from a checkpoint file
                xmlchk = xml_parse_file(self.rfile)  # Parses the file.

                from ipi.inputs.simulation import InputSimulation

                simchk = InputSimulation()
                simchk.parse(xmlchk.fields[0][1])
                mycell = simchk.cell.fetch()
                mybeads = simchk.beads.fetch()
                self.cell.h[:] = mycell.h
                self.beads.q[:] = mybeads.q
                softexit.trigger(" # Read single checkpoint")
        except EOFError:
            softexit.trigger(" # Finished reading re-run trajectory")

        self.qtime += time.time()