def initialize(self):
        """
        Initialize the input parameters and analysis self variables
        """

        self.configuration["dcd_file"]["instance"] = DCDFile(self.configuration["dcd_file"]['filename'])

        # The number of steps of the analysis.
        self.numberOfSteps = self.configuration['dcd_file']['instance']['n_frames']
 
        # Create all objects from the PDB file.  
        conf = PDBConfiguration(self.configuration['pdb_file']['filename'])

        # Creates a collection of all the chemical objects stored in the PDB file
        molecules = conf.createAll()
                        
        # If the input trajectory has PBC create a periodic universe.
        if self.configuration['dcd_file']['instance']['has_pbc_data']:
            self._universe = ParallelepipedicPeriodicUniverse()
            
        # Otherwise create an infinite universe.
        else:
            self._universe = InfiniteUniverse()
                    
        # The chemical objects found in the PDB file introduced into the universe.
        self._universe.addObject(molecules)

        resolve_undefined_molecules_name(self._universe)
        
        # A MMTK trajectory is opened for writing.
        self._trajectory = Trajectory(self._universe, self.configuration['output_file']['files'][0], mode='w')
        
        # A frame generator is created.        
        self._snapshot = SnapshotGenerator(self._universe, actions=[TrajectoryOutput(self._trajectory, ["all"], 0, None, 1)])
    from MMTK import Units
    import sys

    target_filename = sys.argv[2]
    pdb_conf1 = PDBConfiguration(target_filename)
    if sys.argv[1][:2] == '-f':
        chains = pdb_conf1.createNucleotideChains()
        molecule_names = []
        if len(chains) >= 2:
            clist = findContacts(chains[0], chains[1])
        else:
            molecule_names = []
            for (key, mol) in pdb_conf1.molecules.items():
                for o in mol:
                    molecule_names.append(o.name)
            targets = pdb_conf1.createAll(molecule_names = molecule_names)
            if len(molecule_names) > 1:
                clist = findContacts(targets[0], targets[1])
            else:
                atoms = targets.atomList()
                mid = len(atoms)/2
                clist = findContacts(Collection(atoms[:mid]),
                                     Collection(atoms[mid:]))
        print len(clist), 'contacts'
        for c in clist[:8]:
            print '%-64s %6.2f' % (c, c.dist/Units.Ang)
    else:
        target = pdb_conf1.createAll()
        if sys.argv[1][:2] == '-v':
            (a, v) = target.surfaceAndVolume()
            print 'surface area %.2f volume %.2f' \
# This example shows how a universe can be built from a PDB file in such
# a way that all objects in the PDB file are represented as well as
# possible, using AtomCluster objects when nothing more specific can
# be constructed.
#
# This procedure is the only way to construct a universe that uses the
# same internal atom order as the PDB file, which is important for
# data exchange with other programs.

from MMTK import *
from MMTK.PDB import PDBConfiguration

configuration = PDBConfiguration('some_file.pdb')
universe = InfiniteUniverse()
universe.addObject(configuration.createAll(None, 1))
Exemple #4
0
    from MMTK import Units
    import sys

    target_filename = sys.argv[2]
    pdb_conf1 = PDBConfiguration(target_filename)
    if sys.argv[1][:2] == '-f':
        chains = pdb_conf1.createNucleotideChains()
        molecule_names = []
        if len(chains) >= 2:
            clist = findContacts(chains[0], chains[1])
        else:
            molecule_names = []
            for (key, mol) in pdb_conf1.molecules.items():
                for o in mol:
                    molecule_names.append(o.name)
            targets = pdb_conf1.createAll(molecule_names=molecule_names)
            if len(molecule_names) > 1:
                clist = findContacts(targets[0], targets[1])
            else:
                atoms = targets.atomList()
                mid = len(atoms) / 2
                clist = findContacts(Collection(atoms[:mid]),
                                     Collection(atoms[mid:]))
        print len(clist), 'contacts'
        for c in clist[:8]:
            print '%-64s %6.2f' % (c, c.dist / Units.Ang)
    else:
        target = pdb_conf1.createAll()
        if sys.argv[1][:2] == '-v':
            (a, v) = target.surfaceAndVolume()
            print 'surface area %.2f volume %.2f' \
def _get_molecules(pdb_file):
    configuration = PDBConfiguration(pdb_file)
    molecules = configuration.createAll()
    return molecules