Exemplo n.º 1
0
def generateNewTrajectory(top_file_path, traj_file_path, output_traj_file_name):
	trajid = loadTopology(top_file_path)
	input_traj_file_type = getFileType(traj_file_path)
	molecule.read(trajid, input_traj_file_type, traj_file_path, beg=start, end=stop, skip=stride, waitfor=-1)
	output_traj_file_type = getFileType(output_traj_file_name)
	selection = atomsel.atomsel(query, molid=trajid)
	molecule.write(trajid, output_traj_file_type, output_traj_file_name, beg=1, end=-1, selection=selection)
Exemplo n.º 2
0
  def save(self, filename, filetype=None, first=0, last=-1, step=1, waitfor=-1, sel=None):
    """
    Save timesteps to the given file.  The filetype will be guessed from
    the filename extension; this can be overridden by setting the filetype
    option.  first, last, and step control which timesteps to save.  Returns
    the number of frames written before the command completes.
    """
    if filetype is None:
      filetype = self._guessFiletype(filename)
####################################################
# XXX AtomSel is no longer imported automatically,
#     so the following piece of code will fail when 
#     using the save() method with a selection.
#     if the selection is an atomsel builtin type, it
#     can be passed on directly. otherwise we get a
#     reasonable error message. so this chunk is no
#     longer needed.  AK. 2009/07/21
####################################################
#    if sel:
#      if isinstance(sel, VMD.AtomSel.AtomSel):
#        sel=sel.list()
#      else:
#        try:
#          sel=tuple(sel)
#        except:
#          sel=None
####################################################
    nframes = molecule.write(self.id, filetype, filename, first, last, step, waitfor, selection=sel)
    if nframes < 0:
      raise IOError, "Unable to save file: %s" % filename
    return nframes
Exemplo n.º 3
0
 def write(self, filename, filetype=None):
   """Write the atoms in the selection to filename.  Filetype is guessed
   from the filename, or can be specified with filetype."""
   if filetype is None:
     filetype = 'pdb'
     ind=filename.rfind('.')
     if ind >= 0:
       filetype = filename[ind+1:]
   if molecule.write(self.__molid, filetype, filename, self.__frame, \
       self.__frame, 1, -1, selection=self.__list) != 1:
     raise IOError, "Unable to write selection to file '%s'." % filename
   return self
Exemplo n.º 4
0
 def write(self, filename, filetype=None):
     """Write the atoms in the selection to filename.  Filetype is guessed
 from the filename, or can be specified with filetype."""
     if filetype is None:
         filetype = 'pdb'
         ind = filename.rfind('.')
         if ind >= 0:
             filetype = filename[ind + 1:]
     if molecule.write(self.__molid, filetype, filename, self.__frame, \
         self.__frame, 1, -1, selection=self.__list) != 1:
         raise IOError, "Unable to write selection to file '%s'." % filename
     return self
Exemplo n.º 5
0
    def save(self,
             filename,
             filetype=None,
             first=0,
             last=-1,
             step=1,
             waitfor=-1,
             sel=None):
        """
    Save timesteps to the given file.  The filetype will be guessed from
    the filename extension; this can be overridden by setting the filetype
    option.  first, last, and step control which timesteps to save.  Returns
    the number of frames written before the command completes.
    """
        if filetype is None:
            filetype = self._guessFiletype(filename)


####################################################
# XXX AtomSel is no longer imported automatically,
#     so the following piece of code will fail when
#     using the save() method with a selection.
#     if the selection is an atomsel builtin type, it
#     can be passed on directly. otherwise we get a
#     reasonable error message. so this chunk is no
#     longer needed.  AK. 2009/07/21
####################################################
#    if sel:
#      if isinstance(sel, VMD.AtomSel.AtomSel):
#        sel=sel.list()
#      else:
#        try:
#          sel=tuple(sel)
#        except:
#          sel=None
####################################################
        nframes = molecule.write(self.id,
                                 filetype,
                                 filename,
                                 first,
                                 last,
                                 step,
                                 waitfor,
                                 selection=sel)
        if nframes < 0:
            raise IOError, "Unable to save file: %s" % filename
        return nframes
Exemplo n.º 6
0
 def save(self, filename, filetype=None, first=0, last=-1, step=1, waitfor=-1, sel=None):
   """
   Save timesteps to the given file.  The filetype will be guessed from
   the filename extension; this can be overridden by setting the filetype
   option.  first, last, and step control which timesteps to save.  Returns
   the number of frames written before the command completes.
   """
   if filetype is None:
     filetype = self._guessFiletype(filename)
   if sel:
     if isinstance(sel, VMD.AtomSel.AtomSel):
       sel=sel.list()
     else:
       try:
         sel=tuple(sel)
       except:
         sel=None
   nframes = molecule.write(self.id, filetype, filename, first, last, step, waitfor, selection=sel)
   if nframes < 0:
     raise IOError, "Unable to save file: %s" % filename
   return nframes
Exemplo n.º 7
0
def maeToPdb(input_mae_path, output_pdb_file_path):
    molid = molecule.load('mae', input_mae_path)
    molecule.write(molid, 'pdb', output_pdb_file_path)
    print("Finished Conversion for: " + str(input_mae_path))
Exemplo n.º 8
0
    #### Read in input topology, trajectory files, outTraj file
    top_file = sys.argv[1]
    traj_file = sys.argv[2]
    out_traj_file = sys.argv[3]
    if ("-crys" in sys.argv):
        include_crys = True
    else:
        include_crys = False

    #### load topology and trajectories
    traj_molid = molecule.load('pdb', top_file)
    molecule.read(traj_molid, 'netcdf', traj_file, beg=0, end=-1, waitfor=-1)

    #### align all frames
    refsel = atomsel("protein", molid=traj_molid, frame=0)
    for i in range(molecule.numframes(traj_molid)):
        molecule.set_frame(traj_molid, i)
        b = atomsel("protein", molid=traj_molid, frame=i)
        T = b.fit(refsel)
        atomsel("all", molid=traj_molid, frame=i).move(T)

    #### Read out file
    if (include_crys == True):
        molecule.write(traj_molid, 'dcd', out_traj_file, beg=0, end=-1)
    else:
        molecule.write(traj_molid, 'dcd', out_traj_file, beg=1, end=-1)

    toc = time.clock()
    print("Time for wrapAlign.py = " + str(toc - tic))
Exemplo n.º 9
0
def generateNewTopology(top_file_path, output_top_file_name):
	trajid = loadTopology(top_file_path)
	output_top_file_type = getFileType(output_top_file_name)
	selection = atomsel.atomsel(query, molid=trajid)
	molecule.write(trajid, output_top_file_type, output_top_file_name, selection=selection)
    for index, traj_fragment_file in enumerate(traj_fragments_list):
        print("Fragment Index " + str(index) + " : " + traj_fragment_file)
        molecule.read(traj_molid,
                      getFileType(traj_fragment_file),
                      traj_fragment_file,
                      beg=0,
                      end=-1,
                      skip=100,
                      waitfor=-1)

    if (traj_file_type == "dcd"):
        evaltcl('package require pbctools')
        evaltcl(
            'pbc wrap -compound residue -center com -centersel "protein" -all')

    #### align all frames
    refsel = atomsel("protein", molid=traj_molid, frame=0)
    for i in range(molecule.numframes(traj_molid)):
        molecule.set_frame(traj_molid, i)
        b = atomsel("protein", molid=traj_molid, frame=i)
        T = b.fit(refsel)
        atomsel("all", molid=traj_molid, frame=i).move(T)

    #### Read out file
    molecule.write(traj_molid,
                   getFileType(out_traj_file),
                   out_traj_file,
                   beg=0,
                   end=-1)