Check to see if a bond is a stereo bond.

@param bond the bond to check
@return true if the bond has stero information
162430
private boolean isStereoBond(IBond bond) {
        return bond.getStereo() != IBond.Stereo.NONE && bond.getStereo() != (IBond.Stereo) CDKConstants.UNSET
                && bond.getStereo() != IBond.Stereo.E_Z_BY_COORDINATES;
    }
802872
@Override
    public List<IBond> getConnectedBondsList(IAtom atom) {
        List<IBond> bondsList = new ArrayList<IBond>();
        for (int i = 0; i < bondCount; i++) {
            if (bonds[i].contains(atom)) bondsList.add(bonds[i]);
        }
        return bondsList;
    }
1367916
@Override
    public DescriptorValue calculate(IBond bond, IAtomContainer atomContainer) {
        double value = 0;
        // FIXME: for now I'll cache a few modified atomic properties, and restore them at the end of this method
        String originalAtomtypeName1 = bond.getBegin().getAtomTypeName();
        Integer originalNeighborCount1 = bond.getBegin().getFormalNeighbourCount();
        IAtomType.Hybridization originalHybridization1 = bond.getBegin().getHybridization();
        Integer originalValency1 = bond.getBegin().getValency();
        String originalAtomtypeName2 = bond.getEnd().getAtomTypeName();
        Integer originalNeighborCount2 = bond.getEnd().getFormalNeighbourCount();
        IAtomType.Hybridization originalHybridization2 = bond.getEnd().getHybridization();
        Integer originalValency2 = bond.getEnd().getValency();
        Double originalBondOrderSum1 = bond.getBegin().getBondOrderSum();
        Order originalMaxBondOrder1 = bond.getBegin().getMaxBondOrder();
        Double originalBondOrderSum2 = bond.getEnd().getBondOrderSum();
        Order originalMaxBondOrder2 = bond.getEnd().getMaxBondOrder();

        if (!isCachedAtomContainer(atomContainer)) {
            try {
                AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(atomContainer);
                LonePairElectronChecker lpcheck = new LonePairElectronChecker();
                lpcheck.saturate(atomContainer);
            } catch (CDKException e) {
                return getDummyDescriptorValue(e);
            }

        }
        if (!bond.getOrder().equals(IBond.Order.SINGLE)) {
            try {
                value = IonizationPotentialTool.predictIP(atomContainer, bond);
            } catch (CDKException e) {
                return getDummyDescriptorValue(e);
            }
        }
        bond.getBegin().setAtomTypeName(originalAtomtypeName1);
        bond.getBegin().setHybridization(originalHybridization1);
        bond.getBegin().setValency(originalValency1);
        bond.getBegin().setFormalNeighbourCount(originalNeighborCount1);
        bond.getEnd().setAtomTypeName(originalAtomtypeName2);
        bond.getEnd().setHybridization(originalHybridization2);
        bond.getEnd().setValency(originalValency2);
        bond.getEnd().setFormalNeighbourCount(originalNeighborCount2);
        bond.getBegin().setMaxBondOrder(originalMaxBondOrder1);
        bond.getBegin().setBondOrderSum(originalBondOrderSum1);
        bond.getEnd().setMaxBondOrder(originalMaxBondOrder2);
        bond.getEnd().setBondOrderSum(originalBondOrderSum2);

        return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult(value),
                DESCRIPTOR_NAMES);
    }
113628
static boolean isWedged(IBond bond) {
        return (bond.getStereo() == IBond.Stereo.UP || bond.getStereo() == IBond.Stereo.DOWN
                || bond.getStereo() == IBond.Stereo.UP_INVERTED || bond.getStereo() == IBond.Stereo.DOWN_INVERTED);
    }
1312611
private boolean getPresenceOfSulfat(IAtomContainer ac, IAtom atom) {
        List<IAtom> neighbours = ac.getConnectedAtomsList(atom);
        //org.openscience.cdk.interfaces.IAtom[] second = null;
        //IBond bond = null;
        //int counter = 0;
        for (IAtom neighbour : neighbours) {
            if (neighbour.getSymbol().equals("S") && getOxygenCount(ac, neighbour) >= 2
                    && ac.getConnectedBondsCount(neighbour) == 4) {
                return true;
            }
        }
        return false;
    }
710816
@Override
    public boolean matches(IBond bond) {
        if (bond.isAromatic() ^ isAromatic()) return false;

        // we check for both bonds being aromatic - but the query will
        // never come in as aromatic (since there is a separate aromatic
        // query bond). But no harm in checking
        return bond.isAromatic() || bond.getOrder() == getOrder();
    }
158295
@SuppressWarnings("UnusedReturnValue")
    boolean removeBond() {
		final BluetoothDevice device = mGatt.getDevice();
		if (device.getBondState() == BluetoothDevice.BOND_NONE)
			return true;

		mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_VERBOSE, "Removing bond information...");
		boolean result = false;
		/*
		 * There is a removeBond() method in BluetoothDevice class but for now it's hidden. We will call it using reflections.
		 */
		try {
            //noinspection JavaReflectionMemberAccess
            final Method removeBond = device.getClass().getMethod("removeBond");
            mRequestCompleted = false;
            mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_DEBUG, "gatt.getDevice().removeBond() (hidden)");
            result = (Boolean) removeBond.invoke(device);

            // We have to wait until device is unbounded
            try {
                synchronized (mLock) {
                    while (!mRequestCompleted && !mAborted)
                        mLock.wait();
                }
            } catch (final InterruptedException e) {
                loge("Sleeping interrupted", e);
            }
		} catch (final Exception e) {
			Log.w(TAG, "An exception occurred while removing bond information", e);
		}
		return result;
	}
108242
@SuppressWarnings("UnusedReturnValue")
	boolean createBond() {
		final BluetoothDevice device = mGatt.getDevice();
		if (device.getBondState() == BluetoothDevice.BOND_BONDED)
			return true;

		boolean result;
		mRequestCompleted = false;

		mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_VERBOSE, "Starting pairing...");
		if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
			mService.sendLogBroadcast(DfuBaseService.LOG_LEVEL_DEBUG, "gatt.getDevice().createBond()");
			result = device.createBond();
		} else {
			result = createBondApi18(device);
		}

		// We have to wait until device is bounded
		try {
			synchronized (mLock) {
				while (!mRequestCompleted && !mAborted)
					mLock.wait();
			}
		} catch (final InterruptedException e) {
			loge("Sleeping interrupted", e);
		}
		return result;
	}
681709
private static boolean isRingSystemSproutedWithNonRingDoubleBonds(IAtomContainer fullContainer,
            IAtomContainer isolatedRingSystem) {
        Iterator<IAtom> atoms = isolatedRingSystem.atoms().iterator();
        while (atoms.hasNext()) {
            IAtom atom = atoms.next();
            Iterator<IBond> neighborBonds = fullContainer.getConnectedBondsList(atom).iterator();
            while (neighborBonds.hasNext()) {
                IBond neighborBond = neighborBonds.next();
                if (!neighborBond.getFlag(CDKConstants.ISINRING)
                        && neighborBond.getOrder() == Order.DOUBLE
                        || neighborBond.getOrder() == Order.TRIPLE) {
                    if (!("N.sp2.3".equals(atom.getAtomTypeName()) && "O.sp2".equals(neighborBond
                                                                                         .getOther(atom).getAtomTypeName()))) return true;
                }
            }
        }
        return false;
    }
519626
public static boolean isIanaRel(String relation) {

		Assert.notNull(relation, "Link relation must not be null!");

		return LINK_RELATIONS.stream() //
				.anyMatch(it -> it.value().equalsIgnoreCase(relation));
	}
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;
    }
814888
private boolean matches(Type type, IAtom atom, int stereo) {
        switch (type) {
            // predicates
            case TRUE:
                return true;
            case FALSE:
                return false;
            case IS_AROMATIC:
                return atom.isAromatic();
            case IS_ALIPHATIC:
                return !atom.isAromatic();
            case IS_IN_RING:
                return atom.isInRing();
            case IS_IN_CHAIN:
                return !atom.isInRing();
            case IS_HETERO:
                return !eq(atom.getAtomicNumber(), 6) &&
                       !eq(atom.getAtomicNumber(), 1);
            case HAS_IMPLICIT_HYDROGEN:
                return atom.getImplicitHydrogenCount() != null &&
                       atom.getImplicitHydrogenCount() > 0;
            case HAS_ISOTOPE:
                return atom.getMassNumber() != null;
            case HAS_UNSPEC_ISOTOPE:
                return atom.getMassNumber() == null;
            case UNSATURATED:
                for (IBond bond : atom.bonds())
                    if (bond.getOrder() == IBond.Order.DOUBLE)
                        return true;
                return false;
            // value primitives
            case ELEMENT:
                return eq(atom.getAtomicNumber(), value);
            case ALIPHATIC_ELEMENT:
                return !atom.isAromatic() &&
                       eq(atom.getAtomicNumber(), value);
            case AROMATIC_ELEMENT:
                return atom.isAromatic() &&
                       eq(atom.getAtomicNumber(), value);
            case IMPL_H_COUNT:
                return eq(atom.getImplicitHydrogenCount(), value);
            case TOTAL_H_COUNT:
                if (atom.getImplicitHydrogenCount() != null
                    && atom.getImplicitHydrogenCount() > value)
                    return false;
                return getTotalHCount(atom) == value;
            case DEGREE:
                return atom.getBondCount() == value;
            case HEAVY_DEGREE: // XXX: CDK quirk
                return atom.getBondCount() - (getTotalHCount(atom) - atom.getImplicitHydrogenCount()) == value;
            case TOTAL_DEGREE:
                int x = atom.getBondCount() + unbox(atom.getImplicitHydrogenCount());
                return x == value;
            case VALENCE:
                int v = unbox(atom.getImplicitHydrogenCount());
                if (v > value)
                    return false;
                for (IBond bond : atom.bonds()) {
                    if (bond.getOrder() != null)
                        v += bond.getOrder().numeric();
                }
                return v == value;
            case ISOTOPE:
                return eq(atom.getMassNumber(), value);
            case FORMAL_CHARGE:
                return eq(atom.getFormalCharge(), value);
            case RING_BOND_COUNT:
                if (!atom.isInRing() || atom.getBondCount() < value)
                    return false;
                int rbonds = 0;
                for (IBond bond : atom.bonds())
                    rbonds += bond.isInRing() ? 1 : 0;
                return rbonds == value;
            case RING_COUNT:
                return atom.isInRing() && getRingCount(atom) == value;
            case RING_SMALLEST:
                return atom.isInRing() && isInSmallRingSize(atom, value);
            case RING_SIZE:
                return atom.isInRing() && isInRingSize(atom, value);
            case HETERO_SUBSTITUENT_COUNT:
                if (atom.getBondCount() < value)
                    return false;
                int q = 0;
                for (IBond bond : atom.bonds())
                    q += matches(Type.IS_HETERO, bond.getOther(atom), stereo) ? 1 : 0;
                return q == value;
            case INSATURATION:
                int db = 0;
                for (IBond bond : atom.bonds())
                    if (bond.getOrder() == IBond.Order.DOUBLE)
                        db++;
                return db == value;
            case HYBRIDISATION_NUMBER:
                IAtomType.Hybridization hyb = atom.getHybridization();
                if (hyb == null)
                    return false;
                switch (value) {
                    case 1:
                        return hyb == IAtomType.Hybridization.SP1;
                    case 2:
                        return hyb == IAtomType.Hybridization.SP2;
                    case 3:
                        return hyb == IAtomType.Hybridization.SP3;
                    case 4:
                        return hyb == IAtomType.Hybridization.SP3D1;
                    case 5:
                        return hyb == IAtomType.Hybridization.SP3D2;
                    case 6:
                        return hyb == IAtomType.Hybridization.SP3D3;
                    case 7:
                        return hyb == IAtomType.Hybridization.SP3D4;
                    case 8:
                        return hyb == IAtomType.Hybridization.SP3D5;
                    default:
                        return false;
                }
            case PERIODIC_GROUP:
                return atom.getAtomicNumber() != null &&
                       Elements.ofNumber(atom.getAtomicNumber()).group() == value;
            case STEREOCHEMISTRY:
                return stereo == UNKNOWN_STEREO || stereo == value;
            case REACTION_ROLE:
                ReactionRole role = atom.getProperty(CDKConstants.REACTION_ROLE);
                return role != null && role.ordinal() == value;
            case AND:
                return left.matches(left.type, atom, stereo) &&
                       right.matches(right.type, atom, stereo);
            case OR:
                return left.matches(left.type, atom, stereo) ||
                       right.matches(right.type, atom, stereo);
            case NOT:
                return !left.matches(left.type, atom, stereo) ||
                       // XXX: ugly but needed, when matching stereo
                       (stereo == UNKNOWN_STEREO &&
                        (left.type == STEREOCHEMISTRY ||
                         left.type == OR && left.left.type == STEREOCHEMISTRY));
            case RECURSIVE:
                if (ptrn == null)
                    ptrn = DfPattern.findSubstructure(query);
                return ptrn.matchesRoot(atom);
            default:
                throw new IllegalArgumentException("Cannot match AtomExpr, type=" + type);
        }
    }
452598
def bonds(lines, atoms):
    
    # Convert sdf style stereobond (see chem.model.bond.Bond)
    conv_stereo_table = {0: 0, 1: 1, 3: 3, 4: 3, 6: 2}
    results = {a: {} for a in atoms}
    for line in lines:
        bond = Bond()
        first = int(line[0:3])
        second = int(line[3:6])
        if first > second:
            bond.is_lower_first = 0
        order = int(line[6:9])
        if order < 4:
            bond.order = order
        bond.type = conv_stereo_table[int(line[9:12])]
        results[first][second] = {"bond": bond}
        results[second][first] = {"bond": bond}
    return results
782154
private StereoBond findStereoBond(IAtom atom) {
        for (IBond bond : stereoBonds)
            if (bond.contains(atom)) return (StereoBond) bond;
        return null;
    }
636068
public boolean couldMatchAtomType(IAtomContainer container, IAtom atom, IAtomType type) {
        double bondOrderSum = container.getBondOrderSum(atom);
        IBond.Order maxBondOrder = container.getMaximumBondOrder(atom);
        return couldMatchAtomType(atom, bondOrderSum, maxBondOrder, type);
    }
1320921
def is_anion_cation_bond(valences, ii, jj):
    
    if valences == 'undefined':
        return True
    if valences[ii] == 0 or valences[jj] == 0:
        return True
    return (valences[ii] > 0 > valences[jj]) or (valences[jj] > 0 > valences[ii])
462915
public static boolean hasGraphRepresentation(IAtomContainer molecule) {
        for (IBond bond : molecule.bonds())
            if (bond.getAtomCount() != 2) return false;
        return true;
    }