Exemplo n.º 1
0
 def parse_mol2(job):
     """Callback to complete the job"""
     atom_info = utils.DotDict(job=job)
     lines = iter(job.get_output('out.mol2').read().split('\n'))
     while True:
         line = lines.next()
         fields = line.split()
         if fields[0] == 'ATOM':
             idx = int(fields[1]) - 1
             name = fields[2]
             assert mol.atoms[idx].name == name
             atom_info[mol.atoms[idx]] = utils.DotDict(partialcharge=u.q_e *
                                                       float(fields[-2]),
                                                       atomtype=fields[-1])
     return atom_info
Exemplo n.º 2
0
 def properties(self):
     """ moldesign.utils.DotDict: Returns any calculated properties for this atom
     """
     props = utils.DotDict()
     for name, p in self.molecule.properties.iteritems():
         if hasattr(p, 'type') and p.type == 'atomic':
             props[name] = p[self]
     return props
Exemplo n.º 3
0
    def __init__(self, atomcontainer,
                 name=None, bond_graph=None,
                 copy_atoms=False,
                 pdbname=None,
                 charge=None,
                 metadata=None):
        super(Molecule, self).__init__()

        atoms, name = self._get_initializing_atoms(atomcontainer, name, copy_atoms)

        if metadata is None:
            metadata = getattr(atomcontainer, 'metadata', utils.DotDict())

        self.atoms = atoms
        self.time = getattr(atomcontainer, 'time', 0.0 * u.default.time)
        self.name = 'uninitialized molecule'
        self._defres = None
        self._defchain = None
        self.pdbname = pdbname
        self.constraints = utils.ExclusiveList(key=utils.methodcaller('_constraintsig'))
        self.energy_model = None
        self.integrator = None
        self.metadata = metadata

        if charge is not None:
            self.charge = charge
            if not hasattr(charge, 'units'):  # assume fundamental charge units if not explicitly set
                self.charge *= u.q_e
        else:
            self.charge = getattr(atomcontainer, 'charge',
                                  sum(atom.formal_charge for atom in self.atoms))

        # Builds the internal memory structures
        self.chains = Instance(molecule=self)
        self.residues = []
        self._rebuild_topology(bond_graph=bond_graph)

        if name is not None:
            self.name = name
        elif not self.is_small_molecule:
            self.name = 'unnamed macromolecule'
        else:
            self.name = self.get_stoichiometry()

        self._properties = MolecularProperties(self)
        self.ff = utils.DotDict()
Exemplo n.º 4
0
    def __init__(self,
                 atomcontainer,
                 name=None,
                 bond_graph=None,
                 copy_atoms=False,
                 pdbname=None,
                 charge=0):
        # NEW_FEATURE: deal with random number generators per-geometry
        # NEW_FEATURE: per-geometry output logging
        super(Molecule, self).__init__()

        # copy atoms from another object (i.e., a molecule)
        oldatoms = helpers.get_all_atoms(atomcontainer)

        if copy_atoms or (oldatoms[0].molecule is not None):
            #print 'INFO: Copying atoms into new molecule'
            atoms = oldatoms.copy()
            if name is None:  # Figure out a reasonable name
                if oldatoms[0].molecule is not None:
                    name = oldatoms[0].molecule.name + ' copy'
                elif hasattr(atomcontainer, 'name') and isinstance(
                        atomcontainer.name, str):
                    name = utils.if_not_none(name,
                                             atomcontainer.name + ' copy')
                else:
                    name = 'unnamed'
        else:
            atoms = oldatoms

        self.atoms = atoms
        self.time = 0.0 * u.default.time
        self.name = 'uninitialized molecule'
        self._defres = None
        self._defchain = None
        self.pdbname = pdbname
        self.charge = charge
        self.constraints = []
        self.energy_model = None
        self.integrator = None

        # Builds the internal memory structures
        self.chains = Instance(molecule=self)
        self.residues = []
        self._rebuild_topology(bond_graph=bond_graph)

        if name is not None:
            self.name = name
        elif not self.is_small_molecule:
            self.name = 'unnamed macromolecule'
        else:
            self.name = self.get_stoichiometry()

        self._properties = MolecularProperties(self)
        self.ff = utils.DotDict()
Exemplo n.º 5
0
    def ff(self):
        """ moldesign.utils.DotDict: This atom's force field parameters, if available (``None``
        otherwise)
        """
        try:
            ff = self.molecule.energy_model.mdtforcefield
        except AttributeError:
            return None
        if ff is None: return None

        return utils.DotDict(partialcharge=ff.partial_charges[self],
                             lj=ff.lennard_jones[self])
 def __init__(self, mol, unit_system=None, first_frame=False, name=None):
     self._init = True
     self.info = "Trajectory"
     self.frames = []
     self.mol = mol
     self.unit_system = utils.if_not_none(unit_system, mdt.units.default)
     self.properties = utils.DotDict()
     self._tempmol = mdt.Molecule(self.mol.atoms, copy_atoms=True)
     self._tempmol.dynamic_dof = self.mol.dynamic_dof
     self._viz = None
     self._atoms = None
     self.name = utils.if_not_none(name, 'untitled')
     if first_frame: self.new_frame()
Exemplo n.º 7
0
    def finish_job(job):
        """Callback to complete the job"""
        lines = iter(job.get_output('out.mol2').read().split('\n'))
        charges = utils.DotDict(type='atomic')

        line = lines.next()
        while line.strip()[:len('@<TRIPOS>ATOM')] != '@<TRIPOS>ATOM':
            line = lines.next()

        line = lines.next()
        while line.strip()[:len('@<TRIPOS>BOND')] != '@<TRIPOS>BOND':
            fields = line.split()
            idx = int(fields[0]) - 1
            assert mol.atoms[idx].name == fields[1]
            charges[mol.atoms[idx]] = u.q_e * float(fields[-1])
            line = lines.next()

        mol.properties[chargename] = charges
        return charges
def _get_pdb_metadata(pmdmol):
    metadata = utils.DotDict(description=pmdmol.title)

    authors = getattr(pmdmol, 'journal_authors', None)
    if authors:
        metadata.pdb_authors = authors

    experimental = getattr(pmdmol, 'experimental', None)
    if experimental:
        metadata.pdb_experimental = experimental

    box_vectors = getattr(pmdmol, 'box_vectors', None)
    if box_vectors:
        metadata.pdb_box_vectors = box_vectors

    doi = getattr(pmdmol, 'doi', None)
    if doi:
        metadata.pdb_doi = doi
        metadata.url = "http://dx.doi.org/%s" % doi

    return metadata
FREE_COMPUTE_CANNON = 'cloudcomputecannon.bionano.autodesk.com:9000'

RUNNING_ON_WORKER = (os.environ.get('IS_PYCCC_JOB', '0') == '1')

COMPUTE_CONNECTION_WARNING = """
WARNING: Failed to connect to a computational engine - MDT won't be able to run anything outside of Python.

You can fix this either:
  1) interactively, in a notebook, by running `moldesign.configure()`, or,
  2) by modifying the configuration dictionary `moldesign.compute.config`, then
     running `moldesign.compute.reset_compute_engine()` to try again."""

# TODO: *write* configuration plus initial install default; sensible defaults

config = utils.DotDict()
""" dict: dictionary of parameters (read from user's moldesign.yml at startup)

This dictionary configures how MDT interacts with "computational engines" - the systems that run
jobs, usually using docker images.


Notes:
    Values in this dictionary can be configured at runtime; however, after changing them,
    you should update the compute configuration by running
    ``moldesign.compute.reset_compute_engine()``

Configuration is specified using the following keys:

Args:
    engine_type (str): The computational job engine to use. Default: 'ccc'. Currently supported:
Exemplo n.º 10
0
    def __init__(self, mol):
        super(GeometryBuilder, self).__init__(mol)

        # All numbers here are assumed angstroms and radians for now ...
        self._selection = utils.DotDict(blank=True, type=None)
        self._highlighted_bonds = []
        self._highlighted_atoms = []

        self.original_position = self.mol.positions.copy()

        self.clear_button = ipy.Button(description='Clear selection')
        self.clear_button.on_click(self.clear_selection)

        self.label_box = ipy.Checkbox(description='Label atoms', value=False)
        self.label_box.observe(self.label_atoms, 'value')

        # Viewer
        self.viewer.atom_callbacks.append(self.atom_click)
        self.viewer.bond_callbacks.append(self.bond_click)

        self.selection_description = ipy.HTML()

        self.subtools.children = (ipy.HBox([self.clear_button, self.label_box]),
                                  self.selection_description)

        # Atom manipulation tools
        self.x_slider = ReadoutFloatSlider(min=-self.MAXDIST, max=self.MAXDIST,
                                           description='<b>x</b>', format=self.POSFMT)
        self.x_slider.observe(self.set_atom_x, 'value')
        self.y_slider = ReadoutFloatSlider(min=-self.MAXDIST, max=self.MAXDIST,
                                           description='<b>y</b>', format=self.POSFMT)
        self.y_slider.observe(self.set_atom_y, 'value')

        self.z_slider = ReadoutFloatSlider(min=-self.MAXDIST, max=self.MAXDIST,
                                           description='<b>z</b>', format=self.POSFMT)
        self.z_slider.observe(self.set_atom_z, 'value')

        # Bond manipulation tools
        self.adjust_button = ipy.Checkbox(description='Adjust entire molecule', align='end', value=True)

        self.length_slider = ReadoutFloatSlider(min=0.1, max=self.MAXDIST, format=self.POSFMT)
        self.length_slider.observe(self.set_distance, 'value')
        self.angle_slider = ReadoutFloatSlider(min=1.0, max=179.0, step=2.0, format=self.DEGFMT)
        self.angle_slider.observe(self.set_angle, 'value')
        self.dihedral_slider = ReadoutFloatSlider(min=-90.0, max=360.0, step=4.0, format=self.DEGFMT)
        self.dihedral_slider.observe(self.set_dihedral, 'value')

        self.bond_tools = ipy.VBox((self.adjust_button,
                                    self.length_slider,
                                    self.angle_slider,
                                    self.dihedral_slider))

        self.atom_tools = ipy.VBox((self.adjust_button,
                                    self.x_slider,
                                    self.y_slider,
                                    self.z_slider))

        self.reset_button = ipy.Button(description='Reset geometry')
        self.reset_button.on_click(self.reset_geometry)

        self.tool_holder = ipy.VBox()
        self.toolpane.children = (self.tool_holder,
                                  self.reset_button)
Exemplo n.º 11
0
 def clear_selection(self, render=True, *args):
     self._selection = utils.DotDict(blank=True, type=None)
     self.selection_description.value = ""
     if render: self._redraw_selection()