Example #1
0
 def ExtractAtomData ( self, dataBlock, blockCode ):
     """Extract atom data from a data block."""
     system = xyzC = xyzF = None
     table  = dataBlock.get ( "atom_site", None )
     if table is not None:
         # . Atom labels and symbols.
         labels  = table.ColumnValues ( "atom_site_label"       )
         symbols = table.ColumnValues ( "atom_site_type_symbol" )
         # . Make the symbols from the labels if necessary.
         if symbols is None:
             if labels is not None:
                 symbols = []
                 for label in labels:
                     characters = []
                     for c in label:
                         if c.isalpha ( ): characters.append ( c )
                         else:             break
                     symbols.append ( "".join ( characters ) )
         # . Make the basic system.
         if symbols is not None:
             system = System.FromAtoms ( symbols )
             system.label = blockCode
         # . Use the labels in the data block.
         if labels is not None:
             for ( atom, label ) in zip ( system.atoms, labels ):
                 atom.label = label
         # . Coordinates.
         xyzC = self.ExtractCoordinates ( table, "atom_site_Cartn" )
         xyzF = self.ExtractCoordinates ( table, "atom_site_fract" )
     return ( system, xyzC, xyzF )
Example #2
0
 def ToSystem(self):
     """Generate a system from the component."""
     # . Bonds.
     labelIndices = {}
     for (i, atom) in enumerate(self.atoms):
         labelIndices[atom.label] = i
     bonds = []
     for bond in self.bonds:
         bonds.append((labelIndices[bond.atomLabel1],
                       labelIndices[bond.atomLabel2], bond.bondType))
     # . System from atoms and bonds.
     system = System.FromAtoms(self.atoms, bonds=bonds, withSequence=True)
     # . Set additional atom data.
     for (pAtom, sAtom) in zip(self.atoms, system.atoms):
         sAtom.formalCharge = pAtom.formalCharge
         sAtom.label = pAtom.label
     # . Label.
     system.label = "PDB Component"
     if self.label is not None: system.label += " " + self.label
     # . Define component labels.
     for entity in system.sequence.children:
         for component in entity.children:
             component.label = self.label
     # . Finish up.
     return system
Example #3
0
 def ToSystem(self, QBEST=True):
     """Return a system constructed from the file data."""
     system = None
     if self.QPARSED and len(self.atomicNumbers > 0):
         system = System.FromAtoms(self.atomicNumbers)
         system.coordinates3 = self.ToCoordinates3(QBEST=QBEST)
         system.label = "System from Jaguar Output File"
     return system
Example #4
0
 def ToSystem(self):
     """Return a system."""
     system = None
     if self.QPARSED and hasattr(self, "atomicNumbers"):
         system = System.FromAtoms(self.atomicNumbers)
         system.label = self.title
         system.coordinates3 = self.ToCoordinates3()
     return system
Example #5
0
 def ToSystem ( self ):
     """Return a system."""
     system = None
     if self.QPARSED:
         system                 = System.FromAtoms ( self.atomicNumbers )
         system.label           = self.title
         system.coordinates3    = self.ToCoordinates3 ( )
         system.electronicState = ElectronicState ( charge = self.charge, multiplicity = self.multiplicity )
     return system
Example #6
0
 def ToSystem(self):
     """Return a system."""
     if self.QPARSED:
         system = System.FromAtoms(self.atomicNumbers)
         system.label = self.label
         system.coordinates3 = self.ToCoordinates3()
         return system
     else:
         return None
Example #7
0
 def ToSystem(self):
     """Return a system."""
     system = None
     if self.QPARSED and hasattr(self, "atomicNumbers"):
         system = System.FromAtoms(self.atomicNumbers)
         system.coordinates3 = self.ToCoordinates3()
         system.electronicState = self.ToElectronicState()
         if hasattr(self, "entryname"): system.label = self.entryname
     return system
Example #8
0
 def ToSystem(self):
     """Return a system from the CRD data but without sequence information."""
     if self.QPARSED:
         atoms = []
         for (aname, atomicNumber, x, y, z) in self.atoms:
             atoms.append(atomicNumber)
         system = System.FromAtoms(atoms)
         system.coordinates3 = self.ToCoordinates3()
         return system
     else:
         return None
 def ToSystem(self, frameIndex=-1):
     """Return a system."""
     system = None
     if self.QPARSED:
         frame = self.frames[frameIndex]
         atomicNumbers = frame.GetItem("Atomic Numbers")
         if atomicNumbers is not None:
             (head, tail) = os.path.split(self.name)
             system = System.FromAtoms(atomicNumbers)
             system.label = _DefaultSystemLabel + " " + tail
             system.coordinates3 = self.ToCoordinates3()
             system.electronicState = self.ToElectronicState()
     return system
Example #10
0
 def ToSystem(self):
     """Return a system."""
     system = None
     if self.QPARSED:
         try:
             system = System.FromAtoms(self.atomicNumbers,
                                       bonds=getattr(self, "bonds", None))
             system.label = self.label
             system.coordinates3 = self.xyz
             if hasattr(self, "crystalClass") and hasattr(
                     self, "symmetryParameters"):
                 definitions = self.crystalClass.GetUniqueSymmetryParameters(
                     self.symmetryParameters)
                 definitions["crystalClass"] = self.crystalClass
                 system.DefineSymmetry(**definitions)
         except:
             pass
     return system
 def ToSystem(self, index=0):
     """Return a system."""
     if self.QPARSED:
         if index in range(len(self.molrecords)):
             # . Get data.
             (label, atomicNumbers, bonds, charges, coordinates3, mchg,
              miso, mrad) = self.molrecords[index]
             # . Make atoms.
             atoms = self.ToAtoms(atomicNumbers, charges, mchg, miso, mrad)
             # . Make system.
             system = System.FromAtoms(atoms, bonds=bonds)
             system.label = label
             system.coordinates3 = coordinates3
             return system
         else:
             raise IndexError(
                 "MOL record index {:d} not in range [0,{:d}].".format(
                     index,
                     len(self.molrecords) - 1))
     else:
         return None
Example #12
0
    def ToSystem(self, **keywordArguments):
        """Return a system.

        Implicit hydrogens are added unless |QOMITIMPLICITHYDROGENS| is True.
        The hydrogens are placed after their host atom.
        """
        # . Options.
        QOMIT = keywordArguments.get("QOMITIMPLICITHYDROGENS", False)
        # . Atoms.
        if QOMIT:
            atoms = self.atoms
        else:
            atoms = []
            index = 0
            for atom in self.atoms:
                atom.index = index
                atoms.append(atom)
                for i in range(atom.implicithydrogens):
                    atoms.append(1)
                index += atom.implicithydrogens + 1
        # . Bonds.
        bonds = []
        for bond in self.bonds:
            bonds.append((bond.atom1.index, bond.atom2.index, bond.type))
        if not QOMIT:
            for atom in self.atoms:
                for i in range(atom.implicithydrogens):
                    bonds.append(
                        (atom.index, atom.index + i + 1, SingleBond()))
            self.IndexAtoms()
        # . Make the system.
        system = System.FromAtoms(atoms, bonds=bonds)
        # . Set the aromaticity and formalCharge of the new atoms.
        for atom in self.atoms:
            index = atom.index
            system.atoms[index].formalCharge = atom.formalCharge
            system.atoms[index].isAromatic = atom.isAromatic
        # . Finish up.
        return system