示例#1
0
def makeAtom(index, xyz, vdw, name='AV', q=1.0):
    atom = chempy.Atom()
    atom.index = index
    atom.name = name
    atom.symbol = 'He'
    atom.resn = 'AV'
    atom.chain = 'A'
    atom.resi = 1
    atom.resi_number = 1
    atom.coord = xyz
    atom.vdw=vdw
    atom.hetatm = False
    atom.b = 100
    atom.q = q
    return atom
示例#2
0
    def get_implicit_mass(self):
        # mass calculation for implicit models

        valence = [0] * len(self.atom)

        for a in self.bond:
            v = 1.5 if a.order == 4 else a.order
            valence[a.index[0]] += v
            valence[a.index[1]] += v

        h_count = sum(
            a.get_free_valence(v) for (a, v) in zip(self.atom, valence))

        hydrogen = chempy.Atom()
        hydrogen.symbol = 'H'
        return self.get_mass() + hydrogen.get_mass() * h_count
示例#3
0
 def from_molobj(self, molobj):
     self.reset()
     mol = self.molecule
     if len(molobj.title):
         mol.title = molobj.title
     if len(molobj.comments):
         mol.comments = molobj.comments
     mol.chiral = molobj.chiral
     mol.dim_code = molobj.dimcode
     for a in molobj.atom:
         at = chempy.Atom()
         at.symbol = a.symbol
         at.name = a.name
         if a.resn != chempy.Atom.defaults['resn']:
             at.resn = a.resn
         if a.resn_code != chempy.Atom.defaults['resn_code']:
             at.resn_code = a.resn_code
         at.resi = a.resi
         at.resi_number = a.resi_number
         at.b = a.b
         at.q = a.q
         at.alt = a.alt
         at.hetatm = a.hetatm
         if a.segi != chempy.Atom.defaults['segi']:
             at.segi = a.segi
         if a.chain != chempy.Atom.defaults['chain']:
             at.chain = a.chain
         at.color_code = a.color_code
         at.coord = a.coord
         at.formal_charge = a.formal_charge
         at.partial_charge = a.partial_charge
         if a.numeric_type != -99:
             at.numeric_type = a.numeric_type
         if a.text_type != 'UNKNOWN':
             at.text_type = a.text_type
         at.stereo = a.stereo
         if hasattr(a, 'flags'):
             at.flags = a.flags
         if hasattr(a, 'vdw'):
             at.vdw = a.vdw
         self.atom.append(at)
     for b in molobj.bond:
         bnd = chempy.Bond()
         bnd.index = [b.atom[0], b.atom[1]]
         bnd.order = b.order
         bnd.stereo = b.stereo
         self.bond.append(bnd)
示例#4
0
    def get_implicit_mass(self):
        # mass calculation for implicit models

        valence = [0] * len(self.atom)
        implicit = [0] * len(self.atom)

        for a in self.bond:
            ai0 = a.index[0]
            ai1 = a.index[1]
            valence[ai0] = valence[ai0] + a.order
            valence[ai1] = valence[ai1] + a.order
        c = 0
        for a in self.atom:
            valence[c] = valence[c] - a.formal_charge
            implicit[c] = a.get_implicit_valence()[valence[c]]
            c = c + 1
        h_count = reduce(operator.__add__, implicit)
        hydrogen = chempy.Atom()
        hydrogen.symbol = 'H'
        return self.get_mass() + hydrogen.get_mass() * h_count
示例#5
0
    def convert_to_indexed(self):

        model = Indexed()
        model.molecule = copy.deepcopy(self.molecule)

        for c in xrange(self.nAtom):
            at = chempy.Atom()
            txta = self.txta[c]

            for attrib in ('name', 'symbol', 'resn', 'resn_code', 'resi',
                           'alt', 'chain', 'segi', 'text_type'):
                ll = as_[attrib]
                setattr(at, attrib,
                        string.strip(string.join(txta[ll[0]:ll[1]], '')))

            inta = self.inta[c]
            for attrib in ('resi_number', 'hetatm', 'formal_charge', 'flags',
                           'color_code', 'stereo', 'numeric_type'):
                setattr(at, attrib, inta[ai[attrib]])

            flta = self.flta[c]
            for attrib in ('b', 'q', 'partial_charge'):
                setattr(at, attrib, flta[af[attrib]])

            crda = self.crda[c]
            at.coord = [crda[0], crda[1], crda[2]]

            # probably need to add some checking here to eliminate values
            # which come back as defaults

            model.atom.append(at)

        for c in xrange(self.nBond):
            bnd = chempy.Bond()
            bnda = self.bnda[c]
            bnd.index = [bnda[bi_index0], bnda[bi_index1]]
            bnd.order = bnda[bi_order]
            bnd.stereo = bnda[bi_stereo]
            model.bond.append(bnd)

        return model