def _setupChain(self, circular, properties, conf): self.atoms = [] self.bonds = [] for g in self.groups: self.atoms.extend(g.atoms) self.bonds.extend(g.bonds) for i in range(len(self.groups)-1): link1 = self.groups[i].chain_links[1] link2 = self.groups[i+1].chain_links[0] self.bonds.append(Bonds.Bond((link1, link2))) if circular: link1 = self.groups[-1].chain_links[1] link2 = self.groups[0].chain_links[0] self.bonds.append(Bonds.Bond((link1, link2))) self.bonds = Bonds.BondList(self.bonds) self.parent = None self.type = None self.configurations = {} try: self.name = properties['name'] del properties['name'] except KeyError: self.name = '' if conf: conf.applyTo(self) try: self.translateTo(properties['position']) del properties['position'] except KeyError: pass self.addProperties(properties)
def __init__(self, chains=None): if chains is not None: self.chains = [] self.groups = [] self.atoms = [] self.bonds = Bonds.BondList([]) self.chain_names = [] self.model = chains[0].model version_spec = chains[0].version_spec for c in chains: if c.version_spec['model'] != version_spec['model']: raise ValueError("mixing chains of different model: " + c.version_spec['model'] + "/" + version_spec['model']) ng = len(self.groups) self.chains.append((c.name, ng, ng+len(c.groups), c.version_spec)) self.groups.extend(c.groups) self.atoms.extend(c.atoms) self.bonds.extend(c.bonds) try: name = c.name except AttributeError: name = '' self.chain_names.append(name) for g in self.groups: g.parent = self self.name = '' self.parent = None self.type = None self.configurations = {}
def __init__(self, m, ident, owner): from MMTK import Bonds self.chimeraMolecule = m self.needParmchk = set([]) self.frcmod = None self.atomMap = owner.atomMap self.name = m.name self.parent = None self.type = None self.groups = [] for r in m.residues: v = self._findStandardResidue(r) if v is None: self._makeNonStandardResidue(r) else: self._makeStandardResidue(r, *v) atoms = [] bonds = [] for g in self.groups: atoms.extend(g.atoms) bonds.extend(g.bonds) from chimera import Bond for b in m.bonds: if b.display == Bond.Never: continue a0, a1 = b.atoms if a0.residue is a1.residue: continue mb = Bonds.Bond((self.atomMap[a0], self.atomMap[a1])) bonds.append(mb) self.atoms = atoms self.bonds = Bonds.BondList(bonds) if self.needParmchk: self._runParmchk(ident, owner.getTempDir())
def __init__(self, chain, groups, name = ''): self.groups = groups self.atoms = [] self.bonds = [] for g in self.groups: self.atoms = self.atoms + g.atoms self.bonds = self.bonds + g.bonds for i in range(len(self.groups)-1): self.bonds.append(Bonds.Bond((self.groups[i].sugar.O_3, self.groups[i+1].phosphate.P))) self.bonds = Bonds.BondList(self.bonds) self.name = name self.parent = chain.parent self.type = None self.configurations = {} self.part_of = chain
def __init__(self, chain=None, groups=None, name = ''): if chain is not None: self.groups = groups self.atoms = [] self.bonds = [] for g in self.groups: self.atoms.extend(g.atoms) self.bonds.extend(g.bonds) for i in range(len(self.groups)-1): link1 = self.groups[i].chain_links[1] link2 = self.groups[i+1].chain_links[0] self.bonds.append(Bonds.Bond((link1, link2))) self.bonds = Bonds.BondList(self.bonds) self.name = name self.model = chain.model self.parent = chain.parent self.type = None self.configurations = {} self.part_of = chain
def makeChemicalObjects(self, template, top_level): self.groups[template.name].locked = True if top_level: if template.attributes.has_key('sequence'): object = ChemicalObjects.ChainMolecule(None) else: object = ChemicalObjects.Molecule(None) else: object = ChemicalObjects.Group(None) object.atoms = [] object.bonds = Bonds.BondList([]) object.groups = [] object.type = self.groups[template.name] object.parent = None child_objects = [] for child in template.children: if isinstance(child, GroupTemplate): group = self.makeChemicalObjects(child, False) object.groups.append(group) object.atoms.extend(group.atoms) object.bonds.extend(group.bonds) group.parent = object child_objects.append(group) else: atom = ChemicalObjects.Atom(child.element) object.atoms.append(atom) atom.parent = object child_objects.append(atom) for name, index in template.names.items(): setattr(object, name, child_objects[index]) child_objects[index].name = name for name, value in template.attributes.items(): path = name.split('.') setattr(self.namePath(object, path[:-1]), path[-1], value) for atom1, atom2 in template.bonds: atom1 = self.namePath(object, atom1) atom2 = self.namePath(object, atom2) object.bonds.append(Bonds.Bond((atom1, atom2))) for name, vector in template.positions.items(): path = name.split('.') self.namePath(object, path).setPosition(vector) return object
def __init__(self, atoms, **properties): """ :param atoms: a list of atoms in the cluster :type atoms: list :keyword position: the position of the center of mass of the cluster :type position: Scientific.Geometry.Vector :keyword name: a name given to the cluster :type name: str """ self.atoms = list(atoms) self.parent = None self.name = '' self.type = None for a in self.atoms: if a.parent is not None: raise ValueError(repr(a) + ' is part of ' + repr(a.parent)) a.parent = self if a.name != '': setattr(self, a.name, a) properties = copy.copy(properties) CompositeChemicalObject.__init__(self, properties) self.bonds = Bonds.BondList([])
def __init__(self, molecule_spec, _memo=None, **properties): """ :param molecule_spec: a string (not case sensitive) that specifies the molecule name in the chemical database :type molecule_spec: str :keyword position: the position of the center of mass of the molecule :type position: Scientific.Geometry.Vector :keyword name: a name given to the molecule :type name: str :keyword configuration: the name of a configuration listed in the database definition of the molecule, which is used to initialize the atom positions. If no configuration is specified, the configuration named "default" will be used, if it exists. Otherwise the atom positions are undefined. :type configuration: str """ if molecule_spec is not None: # molecule_spec is None when called from MoleculeFactory ChemicalObject.__init__(self, molecule_spec, _memo) properties = copy.copy(properties) CompositeChemicalObject.__init__(self, properties) self.bonds = Bonds.BondList(self.bonds)
def __init__(self, blueprint, _memo=None, **properties): ChemicalObject.__init__(self, blueprint, _memo) properties = copy.copy(properties) CompositeChemicalObject.__init__(self, properties) self.bonds = Bonds.BondList(self.bonds)