Returns the other atom of the bond.
Expects bond to have only two atoms.
Returns null if the given atom is not part of the given bond.

@param atom the atom we already have
@param bond the bond
@return the other atom of the bond
341700
public IAtom getOtherBondAtom(IAtom atom, IBond bond) {
        if (!bond.contains(atom)) return null;
        if (bond.getBegin().equals(atom))
            return bond.getEnd();
        else
            return bond.getBegin();
    }
404842
private static int checkAtom(IAtomContainer ac, IAtom currentAtom) {
        int check = -1;
        List<IAtom> atoms = ac.getConnectedAtomsList(currentAtom);
        List<IBond> bonds = ac.getConnectedBondsList(currentAtom);
        if (currentAtom.getFlag(CDKConstants.ISAROMATIC)) {
            check = 0;
        } else if (currentAtom.getFormalCharge() == 1 /*
                                                       * &&
                                                       * currentAtom.getSymbol
                                                       * ().equals("C")
                                                       */) {
            check = 0;
        } else if (currentAtom.getFormalCharge() == -1) {
            //// NEGATIVE CHARGES WITH A NEIGHBOOR PI BOND //////////////
            int counterOfPi = 0;
            for (IAtom atom : atoms) {
                if (ac.getMaximumBondOrder(atom) != IBond.Order.SINGLE) {
                    counterOfPi++;
                }
            }
            if (counterOfPi > 0) check = 0;
        } else {
            int se = ac.getConnectedSingleElectronsCount(currentAtom);
            if (se == 1) {
                check = 0; //// DETECTION of radicals
            } else if (ac.getConnectedLonePairsCount(currentAtom) > 0
            /* && (currentAtom.getSymbol().equals("N") */) {
                check = 0; //// DETECTION of  lone pair
            } else {
                int highOrderBondCount = 0;
                for (int j = 0; j < atoms.size(); j++) {
                    IBond bond = bonds.get(j);
                    if (bond == null || bond.getOrder() != IBond.Order.SINGLE) {
                        highOrderBondCount++;
                    } else {
                    }
                }
                if (highOrderBondCount == 1) {
                    check = 0;
                } else if (highOrderBondCount > 1) {
                    check = 1;
                }
            }
        }
        return check;
    }
135636
def xatom(self, atom):
        """"""
        handle = atom.handle
        
        if handle == self.atoms[0].handle:
            return self.atoms[1]
        elif handle == self.atoms[1].handle:
            return self.atoms[0]
        return None
1330720
public static int countExplicitHydrogens(IAtomContainer atomContainer, IAtom atom) {
        if (atomContainer == null || atom == null)
            throw new IllegalArgumentException("null container or atom provided");
        int hCount = 0;
        for (IAtom connected : atomContainer.getConnectedAtomsList(atom)) {
            if (Elements.HYDROGEN.getSymbol().equals(connected.getSymbol())) {
                hCount++;
            }
        }
        return hCount;
    }
564510
static Vector2d newUnitVector(final IAtom atom, final IBond bond) {
        return newUnitVector(atom.getPoint2d(), bond.getOther(atom).getPoint2d());
    }
1120796
protected static IAtomContainer makeAtomContainer(IAtom atom, List<IBond> parts, IAtom excludedAtom) {
        IAtomContainer partContainer = atom.getBuilder().newInstance(IAtomContainer.class);
        partContainer.addAtom(atom);
        for (IBond aBond : parts) {
            for (IAtom bondedAtom : aBond.atoms()) {
                if (!bondedAtom.equals(excludedAtom) && !partContainer.contains(bondedAtom))
                    partContainer.addAtom(bondedAtom);
            }
            if (!aBond.contains(excludedAtom)) partContainer.addBond(aBond);
        }
        return partContainer;
    }
160961
@Override
    public DescriptorValue calculate(IAtomContainer atomContainer) {

        int n = 0; // count all heavy atom - heavy atom bonds
        for (IBond bond : atomContainer.bonds()) {
            if (bond.getBegin().getAtomicNumber() != 1 && bond.getEnd().getAtomicNumber() != 1) {
                n++;
            }
        }

        double vadjMa = 0;
        if (n > 0) {
            vadjMa += (Math.log(n) / Math.log(2)) + 1;
        }
        return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult(vadjMa),
                getDescriptorNames());
    }
431351
public int getEnergies(IAtom sourceAtom, IAtom targetAtom, Order bondOrder) {
        int dKJPerMol = -1;

        for (Map.Entry<Integer, BondEnergy> entry : bondEngergies.entrySet()) {
            BondEnergy bondEnergy = entry.getValue();
            String atom1 = bondEnergy.getSymbolFirstAtom();
            String atom2 = bondEnergy.getSymbolSecondAtom();
            if ((atom1.equalsIgnoreCase(sourceAtom.getSymbol()) && atom2.equalsIgnoreCase(targetAtom.getSymbol()))
                    || (atom2.equalsIgnoreCase(sourceAtom.getSymbol()) && atom1
                            .equalsIgnoreCase(targetAtom.getSymbol()))) {

                Order order = bondEnergy.getBondOrder();
                if (order.compareTo(bondOrder) == 0) {
                    dKJPerMol = bondEnergy.getEnergy();
                }
            }
        }
        return dKJPerMol;
    }
1276166
@Override
    public void addAtom(IAtom atom) {
        if (contains(atom)) {
            return;
        }

        if (atomCount + 1 >= atoms.length) {
            growAtomArray();
        }
        atom.addListener(this);
        atoms[atomCount] = atom;
        atomCount++;
        notifyChanged();
    }
434232
public static double getBondLengthAverage3D(IAtomContainer container) {
        double bondLengthSum = 0;
        int bondCounter = 0;
        for (IBond bond : container.bonds()) {
            IAtom atom1 = bond.getBegin();
            IAtom atom2 = bond.getEnd();
            if (atom1.getPoint3d() != null && atom2.getPoint3d() != null) {
                bondCounter++;
                bondLengthSum += atom1.getPoint3d().distance(atom2.getPoint3d());
            }
        }
        return bondLengthSum / bondCounter;
    }
1105198
private int getNumberOfHydrogen(IAtomContainer atomContainer, IAtom atom) {
        java.util.List<IBond> bonds = atomContainer.getConnectedBondsList(atom);
        IAtom connectedAtom;
        int hCounter = 0;
        for (IBond bond : bonds) {
            connectedAtom = bond.getOther(atom);
            if (connectedAtom.getSymbol().equals("H")) {
                hCounter += 1;
            }
        }
        return hCounter;
    }
440520
public Pair<Chain> getParentChains() {
		Atom[] firstMol = this.molecules.getFirst();
		Atom[] secondMol = this.molecules.getSecond();
		if (firstMol.length==0 || secondMol.length==0) {
			logger.warn("No atoms found in first or second molecule, can't get parent Chains");
			return null;
		}

		return new Pair<Chain>(firstMol[0].getGroup().getChain(), secondMol[0].getGroup().getChain());
	}
1327400
function() {
    // check if we have at least one atom, if not return null
    if (this._currChain === null) {
      return null;
    }
    var chain = null;
    var i;
    for (i = 0; i < this._sheets.length; ++i) {
      var sheet = this._sheets[i];
      chain = this._structure.chain(sheet.chainName);
      if (chain) {
        chain.assignSS(sheet.first, sheet.last, 'E');
      }
    }
    for (i = 0; i < this._helices.length; ++i) {
      var helix = this._helices[i];
      chain = this._structure.chain(helix.chainName);
      if (chain) {
        chain.assignSS(helix.first, helix.last, 'H');
      }
    }
    this._structure.setAssemblies(this._remark350Reader.assemblies());
    if (this._options.conectRecords) {
      this._assignBondsFromConectRecords(this._structure);
    }
    this._structure.deriveConnectivity();
    console.log('imported', this._structure.chains().length, 'chain(s),',
                this._structure.residueCount(), 'residue(s)');
    var result = this._structure;
    this._structure = new mol.Mol();
    this._currChain =  null;
    this._currRes = null;
    this._currAtom = null;
    this._rosettaMode = false;
    return result;
  }
1313677
protected boolean bindsHydrogen(IBond bond) {
        for (int i = 0; i < bond.getAtomCount(); i++) {
            IAtom atom = bond.getAtom(i);
            if ("H".equals(atom.getSymbol())) return true;
        }
        return false;
    }
810488
private static IAtom findPiBondedOxygen(IAtomContainer container, IAtom atom) {
        for (IBond bond : container.getConnectedBondsList(atom)) {
            if (bond.getOrder() == IBond.Order.DOUBLE) {
                IAtom neighbor = bond.getOther(atom);
                int charge = neighbor.getFormalCharge() == null ? 0 : neighbor.getFormalCharge();
                if (neighbor.getAtomicNumber() == 8 && charge == 0) return neighbor;
            }
        }
        return null;
    }
1143590
@Override
    public boolean matches(IAtom atom) {
        return Preconditions.checkNotNull(atom.getAtomicNumber(), "Atomic number is not set.").equals(
                this.getAtomicNumber());
    }
1338833
public static double getBondLengthMedian(final IAtomContainer container) {
        if (container.getBondCount() == 0) throw new IllegalArgumentException("Container has no bonds.");
        int nBonds = 0;
        double[] lengths = new double[container.getBondCount()];
        for (int i = 0; i < container.getBondCount(); i++) {
            final IBond bond = container.getBond(i);
            final IAtom atom1 = bond.getBegin();
            final IAtom atom2 = bond.getEnd();
            Point2d p1 = atom1.getPoint2d();
            Point2d p2 = atom2.getPoint2d();
            if (p1 == null || p2 == null)
                throw new IllegalArgumentException("An atom has no 2D coordinates.");
            if (p1.x != p2.x || p1.y != p2.y)
                lengths[nBonds++] = p1.distance(p2);
        }
        Arrays.sort(lengths, 0, nBonds);
        return lengths[nBonds / 2];
    }