Most meaningful for bond critical points,
        can be physically interpreted as e.g. degree
        of pi-bonding in organic molecules. Consult
        literature for more information.
        :return:
542790
def ellipticity(self):
        '''
        
        '''
        eig = np.linalg.eig(self.field_hessian)
        eig.sort()
        return eig[0]/eig[1] - 1
153115
def chival(self, bonds):
        """"""
        # XXX I'm not sure how this works?
        order = [bond.xatom(self) for bond in bonds]
        return self._chirality(order)
2425
public double getBondLength() {
        double epsilon = 1e-3;
        PharmacophoreAtom atom1 = (PharmacophoreAtom) getAtom(0);
        PharmacophoreAtom atom2 = (PharmacophoreAtom) getAtom(1);
        PharmacophoreAtom atom3 = (PharmacophoreAtom) getAtom(2);

        double a2 = atom3.getPoint3d().distanceSquared(atom1.getPoint3d());
        double b2 = atom3.getPoint3d().distanceSquared(atom2.getPoint3d());
        double c2 = atom2.getPoint3d().distanceSquared(atom1.getPoint3d());

        double cosangle = (b2 + c2 - a2) / (2 * Math.sqrt(b2) * Math.sqrt(c2));
        if (-1.0 - epsilon < cosangle && -1.0 + epsilon > cosangle) return 180.0;
        if (1.0 - epsilon < cosangle && 1.0 + epsilon > cosangle) return 0.0;

        return Math.acos(cosangle) * 180.0 / Math.PI;
    }
82730
private static int parity(IAtom[] atoms) {
        return parity(atoms[0].getPoint2d(), atoms[1].getPoint2d(), atoms[2].getPoint2d());
    }
1033654
def ground_state_term_symbol(self):
        
        L_symbols = 'SPDFGHIKLMNOQRTUVWXYZ'

        term_symbols = self.term_symbols
        term_symbol_flat = {term: {"multiplicity": int(term[0]),
                                   "L": L_symbols.index(term[1]),
                                   "J": float(term[2:])}
                            for term in sum(term_symbols, [])}

        multi = [int(item['multiplicity'])
                 for terms, item in term_symbol_flat.items()]
        max_multi_terms = {symbol: item
                           for symbol, item in term_symbol_flat.items()
                           if item['multiplicity'] == max(multi)}

        Ls = [item['L'] for terms, item in max_multi_terms.items()]
        max_L_terms = {symbol: item
                       for symbol, item in term_symbol_flat.items()
                       if item['L'] == max(Ls)}

        J_sorted_terms = sorted(max_L_terms.items(),
                                key=lambda k: k[1]['J'])
        L, v_e = self.valence
        if v_e <= (2 * L + 1):
            return J_sorted_terms[0][0]
        else:
            return J_sorted_terms[-1][0]
809629
private void bondAtom(IAtomContainer container, IAtom atom) {
        double myCovalentRadius = atom.getCovalentRadius();
        double searchRadius = myCovalentRadius + maxCovalentRadius + bondTolerance;
        Point tupleAtom = new Point(atom.getPoint3d().x, atom.getPoint3d().y, atom.getPoint3d().z);
        for (Bspt.EnumerateSphere e = bspt.enumHemiSphere(tupleAtom, searchRadius); e.hasMoreElements();) {
            IAtom atomNear = ((TupleAtom) e.nextElement()).getAtom();
            if (!atomNear.equals(atom) && container.getBond(atom, atomNear) == null) {
                boolean bonded = isBonded(myCovalentRadius, atomNear.getCovalentRadius(), e.foundDistance2());
                if (bonded) {
                    IBond bond = atom.getBuilder().newInstance(IBond.class, atom, atomNear, IBond.Order.SINGLE);
                    container.addBond(bond);
                }
            }
        }
    }
590659
private boolean isBonded(double covalentRadiusA, double covalentRadiusB, double distance2) {
        double maxAcceptable = covalentRadiusA + covalentRadiusB + bondTolerance;
        double maxAcceptable2 = maxAcceptable * maxAcceptable;
        double minBondDistance2 = this.minBondDistance * this.minBondDistance;
        if (distance2 < minBondDistance2) return false;
        return distance2 <= maxAcceptable2;
    }
224893
def show_cationpi(self):
        """"""
        for i, p in enumerate(self.plcomplex.pication):
            cmd.pseudoatom('ps-picat-1-%i' % i, pos=p.ring_center)
            cmd.pseudoatom('ps-picat-2-%i' % i, pos=p.charge_center)
            if p.protcharged:
                cmd.pseudoatom('Chargecenter-P', pos=p.charge_center)
                cmd.pseudoatom('Centroids-L', pos=p.ring_center)
                pilig_ids = '+'.join(map(str, p.ring_atoms))
                cmd.select('PiCatRing-L', 'PiCatRing-L or (id %s & %s)' % (pilig_ids, self.ligname))
                for a in p.charge_atoms:
                    cmd.select('PosCharge-P', 'PosCharge-P or (id %i & %s)' % (a, self.protname))
            else:
                cmd.pseudoatom('Chargecenter-L', pos=p.charge_center)
                cmd.pseudoatom('Centroids-P', pos=p.ring_center)
                pires_ids = '+'.join(map(str, p.ring_atoms))
                cmd.select('PiCatRing-P', 'PiCatRing-P or (id %s & %s)' % (pires_ids, self.protname))
                for a in p.charge_atoms:
                    cmd.select('PosCharge-L', 'PosCharge-L or (id %i & %s)' % (a, self.ligname))
            cmd.distance('PiCation', 'ps-picat-1-%i' % i, 'ps-picat-2-%i' % i)
        if self.object_exists('PiCation'):
            cmd.set('dash_color', 'orange', 'PiCation')
            cmd.set('dash_gap', 0.3, 'PiCation')
            cmd.set('dash_length', 0.6, 'PiCation')
973040
def get_bond_symmetry(site_symmetry,
                      lattice,
                      positions,
                      atom_center,
                      atom_disp,
                      symprec=1e-5):
    
    bond_sym = []
    pos = positions
    for rot in site_symmetry:
        rot_pos = (np.dot(pos[atom_disp] - pos[atom_center], rot.T) +
                   pos[atom_center])
        diff = pos[atom_disp] - rot_pos
        diff -= np.rint(diff)
        dist = np.linalg.norm(np.dot(lattice, diff))
        if dist < symprec:
            bond_sym.append(rot)

    return np.array(bond_sym)
1240068
private double getTopologicalFactors(IAtomContainer atomContainer, IAtomContainer ac) {
        /* factor for separation of charge */
        int totalNCharge1 = AtomContainerManipulator.getTotalNegativeFormalCharge(atomContainer);
        int totalPCharge1 = AtomContainerManipulator.getTotalPositiveFormalCharge(atomContainer);

        double fQ = 1.0;
        if (totalNCharge1 != 0.0) {
            fQ = 0.5;
            for (int i = 0; i < atomContainer.getBondCount(); i++) {
                IBond bond = atomContainer.getBond(i);
                if (bond.getBegin().getFormalCharge() != 0.0 && bond.getEnd().getFormalCharge() != 0.0) {
                    fQ = 0.25;
                    break;
                }
            }
        }
        /* factor, if the number of covalents bonds is decreased */
        double fB = 1.0;

        int numBond1 = 0;
        int numBond2 = 0;
        for (int i = 0; i < atomContainer.getBondCount(); i++) {
            if (atomContainer.getBond(i).getOrder() == IBond.Order.DOUBLE) numBond1 += 1;
            if (ac.getBond(i).getOrder() == IBond.Order.DOUBLE) numBond2 += 1;
        }

        if (numBond1 < /* > */numBond2) fB = 0.8;

        double fPlus = 1.0;
        if (totalNCharge1 == 0.0 && totalPCharge1 == 0.0) fPlus = 0.1;

        /* aromatic */
        double fA = 1.0;
        try {
            if (Aromaticity.cdkLegacy().apply(ac)) if (!Aromaticity.cdkLegacy().apply(atomContainer)) fA = 0.3;
        } catch (CDKException e) {
            e.printStackTrace();
        }
        logger.debug("return " + fQ * fB * fPlus * fA + "= sp:" + fQ + ", dc:" + fB + ", fPlus:" + fPlus + ", fA:" + fA);

        return fQ * fB * fPlus * fA;
    }
323016
private void initIOSettings() {
        forceWriteAs2DCoords = addSetting(new BooleanIOSetting(OptForceWriteAs2DCoordinates, IOSetting.Importance.LOW,
                                                               "Should coordinates always be written as 2D?", "false"));
        writeMajorIsotopes = addSetting(new BooleanIOSetting(OptWriteMajorIsotopes, IOSetting.Importance.LOW,
                                                             "Write atomic mass of any non-null atomic mass including major isotopes (e.g. [12]C)", "true"));
        writeAromaticBondTypes = addSetting(new BooleanIOSetting(OptWriteAromaticBondTypes, IOSetting.Importance.LOW,
                                                                 "Should aromatic bonds be written as bond type 4?", "false"));
        writeQueryFormatValencies = addSetting(new BooleanIOSetting(OptWriteQueryFormatValencies,
                                                                    IOSetting.Importance.LOW, "Should valencies be written in the MDL Query format? (deprecated)", "false"));
        writeDefaultProps = addSetting(new BooleanIOSetting(OptWriteDefaultProperties,
                                                            IOSetting.Importance.LOW,
                                                            "Write trailing zero's on atom/bond property blocks even if they're not used.",
                                                            "true"));
        programNameOpt = addSetting(new StringIOSetting(OptProgramName,
                                                        IOSetting.Importance.LOW,
                                                        "Program name to write at the top of the molfile header, should be exactly 8 characters long",
                                                        "CDK"));
    }
342825
private IAtom getRingAtom(IBond bond) {
        if (bond.getBegin().getFlag(CDKConstants.ISINRING) && !bond.getBegin().getFlag(CDKConstants.ISPLACED)) {
            return bond.getBegin();
        }
        if (bond.getEnd().getFlag(CDKConstants.ISINRING) && !bond.getEnd().getFlag(CDKConstants.ISPLACED)) {
            return bond.getEnd();
        }
        return null;
    }
1105619
def _jit_give_bond_array(pos, bond_radii, self_bonding_allowed=False):
        
        n = pos.shape[0]
        bond_array = np.empty((n, n), dtype=nb.boolean)

        for i in range(n):
            for j in range(i, n):
                D = 0
                for h in range(3):
                    D += (pos[i, h] - pos[j, h])**2
                B = (bond_radii[i] + bond_radii[j])**2
                bond_array[i, j] = (B - D) >= 0
                bond_array[j, i] = bond_array[i, j]
        if not self_bonding_allowed:
            for i in range(n):
                bond_array[i, i] = False
        return bond_array
699708
@Override
    public DescriptorValue calculate(IAtomContainer mol) {
        mol = clone(mol); // don't mod original
        int lipinskifailures = 0;

        IMolecularDescriptor xlogP = new XLogPDescriptor();
        Object[] xlogPparams = {checkAromaticity, Boolean.TRUE,};

        try {
            xlogP.setParameters(xlogPparams);
            double xlogPvalue = ((DoubleResult) xlogP.calculate(mol).getValue()).doubleValue();

            IMolecularDescriptor acc = new HBondAcceptorCountDescriptor();
            Object[] hBondparams = {checkAromaticity};
            acc.setParameters(hBondparams);
            int acceptors = ((IntegerResult) acc.calculate(mol).getValue()).intValue();

            IMolecularDescriptor don = new HBondDonorCountDescriptor();
            don.setParameters(hBondparams);
            int donors = ((IntegerResult) don.calculate(mol).getValue()).intValue();

            IMolecularDescriptor mw = new WeightDescriptor();
            Object[] mwparams = {"*"};
            mw.setParameters(mwparams);
            double mwvalue = ((DoubleResult) mw.calculate(mol).getValue()).doubleValue();

            // exclude (heavy atom) terminal bonds
            // exclude amide C-N bonds because of their high rotational barrier
            // see Veber, D.F. et al., 2002, 45(12), pp.2615–23.
            IMolecularDescriptor rotata = new RotatableBondsCountDescriptor();
            Object[] rotatableBondsParams = {false, true};
            rotata.setParameters(rotatableBondsParams);
            int rotatablebonds = ((IntegerResult) rotata.calculate(mol).getValue()).intValue();

            if (xlogPvalue > 5.0) {
                lipinskifailures += 1;
            }
            if (acceptors > 10) {
                lipinskifailures += 1;
            }
            if (donors > 5) {
                lipinskifailures += 1;
            }
            if (mwvalue > 500.0) {
                lipinskifailures += 1;
            }
            if (rotatablebonds > 10.0) {
                lipinskifailures += 1;
            }
        } catch (CDKException e) {
            new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new IntegerResult(
                    (int) Double.NaN), getDescriptorNames(), e);
        }

        return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new IntegerResult(
                lipinskifailures), getDescriptorNames());
    }
1329912
def center_bonds(self):
        
        return [(n, m) for n, m, bond in self.bonds() if bond._reactant != bond._product]
424402
def term_symbols(self):
        
        L_symbols = 'SPDFGHIKLMNOQRTUVWXYZ'

        L, v_e = self.valence

        # for one electron in subshell L
        ml = list(range(-L, L + 1))
        ms = [1 / 2, -1 / 2]
        # all possible configurations of ml,ms for one e in subshell L
        ml_ms = list(product(ml, ms))

        # Number of possible configurations for r electrons in subshell L.
        n = (2 * L + 1) * 2
        # the combination of n_e electrons configurations
        # C^{n}_{n_e}
        e_config_combs = list(combinations(range(n), v_e))

        # Total ML = sum(ml1, ml2), Total MS = sum(ms1, ms2)
        TL = [sum([ml_ms[comb[e]][0] for e in range(v_e)])
              for comb in e_config_combs]
        TS = [sum([ml_ms[comb[e]][1] for e in range(v_e)])
              for comb in e_config_combs]
        comb_counter = Counter([r for r in zip(TL, TS)])

        term_symbols = []
        while sum(comb_counter.values()) > 0:
            # Start from the lowest freq combination,
            # which corresponds to largest abs(L) and smallest abs(S)
            L, S = min(comb_counter)

            J = list(np.arange(abs(L - S), abs(L) + abs(S) + 1))
            term_symbols.append([str(int(2 * (abs(S)) + 1))
                                 + L_symbols[abs(L)]
                                 + str(j) for j in J])
            # Without J
            # term_symbols.append(str(int(2 * (abs(S)) + 1)) \
            #                     + L_symbols[abs(L)])

            # Delete all configurations included in this term
            for ML in range(-L, L - 1, -1):
                for MS in np.arange(S, -S + 1, 1):
                    if (ML, MS) in comb_counter:

                        comb_counter[(ML, MS)] -= 1
                        if comb_counter[(ML, MS)] == 0:
                            del comb_counter[(ML, MS)]
        return term_symbols
1269781
def get_centered_molecule(self):
        
        center = self.center_of_mass
        new_coords = np.array(self.cart_coords) - center
        return self.__class__(self.species_and_occu, new_coords,
                              charge=self._charge,
                              spin_multiplicity=self._spin_multiplicity,
                              site_properties=self.site_properties)