Safely access the reaction role of an atom, returns {@link ReactionRole#None} if null.

@param atom atom
@return mapidx, None if undefined
426942
private ReactionRole role(IAtom atom) {
        ReactionRole role = atom.getProperty(CDKConstants.REACTION_ROLE);
        if (role != null)
            return role;
        return ReactionRole.None;
    }
214776
public ResidueNumber getResidue(int positionInRange, AtomPositionMap map) {
		if (map == null) throw new NullPointerException("The AtomPositionMap must be non-null");
		int i = 0;
		for (Map.Entry<ResidueNumber, Integer> entry : map.getNavMap().entrySet()) {
			if (i == positionInRange) return entry.getKey();
			if (contains(entry.getKey(), map)) {
				i++;
			}
		}
		return null;
	}
779519
IAtom newCDKAtom(Atom atom) {
        Element element = atom.element();
        boolean unknown = element == Element.Unknown;
        if (unknown) {
            IPseudoAtom pseudoAtom = builder.newInstance(IPseudoAtom.class, element.symbol());
            pseudoAtom.setSymbol(element.symbol());
            pseudoAtom.setLabel(atom.label());
            return pseudoAtom;
        }
        return createAtom(element);
    }
1350411
def add_atom(self, atom, _map=None):
        
        if _map is None:
            _map = max(self, default=0) + 1
        elif _map in self._node:
            raise KeyError('atom with same number exists')

        attr_dict = self.node_attr_dict_factory()
        if isinstance(atom, str):
            attr_dict.element = atom
        elif isinstance(atom, int):
            attr_dict.element = elements_list[atom - 1]
        else:
            attr_dict.update(atom)

        self._adj[_map] = self.adjlist_inner_dict_factory()
        self._node[_map] = attr_dict
        self.flush_cache()
        return _map
523122
private DistinctVariableOnlyDataAtom transformProjectionAtom(DistinctVariableOnlyDataAtom atom) {
        ImmutableList<Variable> newArguments = atom.getArguments().stream()
                .map(renamingSubstitution::applyToVariable)
                .collect(ImmutableCollectors.toList());

        return atomFactory.getDistinctVariableOnlyDataAtom(atom.getPredicate(), newArguments);
    }
61874
IAtom getUnplacedHeavyAtom(IAtomContainer molecule) {
        for (IAtom atom : molecule.atoms()) {
            if (isUnplacedHeavyAtom(atom))
                return atom;
        }
        return null;
    }
1008568
public static final Atom getCentroid(Atom[] atomSet){

		// if we don't catch this case, the centroid returned is (NaN,NaN,NaN), which can cause lots of problems down the line
		if (atomSet.length==0)
			throw new IllegalArgumentException("Atom array has length 0, can't calculate centroid!");


		double[] coords = new double[3];

		coords[0] = 0;
		coords[1] = 0;
		coords[2] = 0 ;

		for (Atom a : atomSet) {
			coords[0] += a.getX();
			coords[1] += a.getY();
			coords[2] += a.getZ();
		}

		int n = atomSet.length;
		coords[0] = coords[0] / n;
		coords[1] = coords[1] / n;
		coords[2] = coords[2] / n;

		Atom vec = new AtomImpl();
		vec.setCoords(coords);
		return vec;

	}
380415
public static IAtomContainer getRelevantAtomContainer(IChemModel chemModel, IAtom atom) {
        IAtomContainer result = null;
        if (chemModel.getMoleculeSet() != null) {
            IAtomContainerSet moleculeSet = chemModel.getMoleculeSet();
            result = MoleculeSetManipulator.getRelevantAtomContainer(moleculeSet, atom);
            if (result != null) {
                return result;
            }
        }
        if (chemModel.getReactionSet() != null) {
            IReactionSet reactionSet = chemModel.getReactionSet();
            return ReactionSetManipulator.getRelevantAtomContainer(reactionSet, atom);
        }
        if (chemModel.getCrystal() != null && chemModel.getCrystal().contains(atom)) {
            return chemModel.getCrystal();
        }
        if (chemModel.getRingSet() != null) {
            return AtomContainerSetManipulator.getRelevantAtomContainer(chemModel.getRingSet(), atom);
        }
        throw new IllegalArgumentException("The provided atom is not part of this IChemModel.");
    }
870427
public static Atom getTranslationVector(Matrix4d transform){

		Atom transl = new AtomImpl();
		double[] coords = {transform.m03, transform.m13, transform.m23};
		transl.setCoords(coords);
		return transl;
	}
306902
private IAtom findHydrogen(final IAtom[] atoms) {
        for (final IAtom a : atoms) {
            if (Integer.valueOf(1).equals(a.getAtomicNumber())) return a;
        }
        return null;
    }
1080116
private IAtom findAtomByPosition(IAtomContainer container, int position) {
        String pos = String.valueOf(position);
        for (IAtom atom : container.atoms()) {
            if (atom.getID().equals(pos)) return atom;
        }
        return null;
    }
333944
private IAtom setAtom(IAtom atom, String ID) throws NoSuchAtomTypeException {
        IAtomType at = null;
        String key = "";
        List<?> data = null;
        Double value = null;

        at = getAtomType(ID);
        if (atom.getSymbol() == null) {
            atom.setSymbol(at.getSymbol());
        }
        atom.setAtomTypeName(at.getAtomTypeName());
        atom.setFormalNeighbourCount(at.getFormalNeighbourCount());
        key = "vdw" + ID;
        data = (List) parameterSet.get(key);
        value = (Double) data.get(0);
        key = "charge" + ID;
        if (parameterSet.containsKey(key)) {
            data = (List) parameterSet.get(key);
            value = (Double) data.get(0);
            atom.setCharge(value.doubleValue());
        }
        Object color = at.getProperty("org.openscience.cdk.renderer.color");
        if (color != null) {
            atom.setProperty("org.openscience.cdk.renderer.color", color);
        }
        if (at.getAtomicNumber() != 0) {
            atom.setAtomicNumber(at.getAtomicNumber());
        }
        if (at.getExactMass() > 0.0) {
            atom.setExactMass(at.getExactMass());
        }
        return atom;
    }
322141
private IAtomContainer getUnplacedAtoms(IAtom atom) {
        IAtomContainer unplacedAtoms = atom.getBuilder().newInstance(IAtomContainer.class);
        List bonds = molecule.getConnectedBondsList(atom);
        IAtom connectedAtom;
        for (int f = 0; f < bonds.size(); f++) {
            connectedAtom = ((IBond) bonds.get(f)).getOther(atom);
            if (!connectedAtom.getFlag(CDKConstants.ISPLACED)) {
                unplacedAtoms.addAtom(connectedAtom);
            }
        }
        return unplacedAtoms;
    }
30396
public static final Atom[] centerAtoms(Atom[] atomSet)
			throws StructureException {

		Atom centroid = getCentroid(atomSet);
		return centerAtoms(atomSet, centroid);
	}
1157570
private IRingSet getRingSetOfAtom(List ringSystems, IAtom atom) {
        IRingSet ringSetOfAtom = null;
        for (int i = 0; i < ringSystems.size(); i++) {
            if (((IRingSet) ringSystems.get(i)).contains(atom)) {
                return (IRingSet) ringSystems.get(i);
            }
        }
        return ringSetOfAtom;
    }
239500
private double getElectrostaticPotentialN(IAtomContainer ac, int atom1, double[] ds) {

        //		double CoulombForceConstant = 1/(4*Math.PI*8.81/*Math.pow(10, -12)*/);
        double CoulombForceConstant = 0.048;
        double sum = 0.0;
        try {
            if (factory == null)
                factory = AtomTypeFactory.getInstance("org/openscience/cdk/config/data/jmol_atomtypes.txt",
                        ac.getBuilder());

            List<IAtom> atoms = ac.getConnectedAtomsList(ac.getAtom(atom1));
            for (IAtom atom : atoms) {
                double covalentradius = 0;
                String symbol = atom.getSymbol();
                IAtomType type = factory.getAtomType(symbol);
                covalentradius = type.getCovalentRadius();

                double charge = ds[STEP_SIZE * atom1 + atom1 + 5];
                logger.debug("sum_(" + sum + ") = CFC(" + CoulombForceConstant + ")*charge(" + charge + "/ret("
                        + covalentradius);
                sum += CoulombForceConstant * charge / (covalentradius * covalentradius);
            }
        } catch (CDKException e) {
            logger.debug(e);
        }

        return sum;
    }
624907
public AtomContact getContact(Atom atom1, Atom atom2) {
		return contacts.get(new Pair<AtomIdentifier>(
				new AtomIdentifier(atom1.getPDBserial(),atom1.getGroup().getChainId()),
				new AtomIdentifier(atom2.getPDBserial(),atom2.getGroup().getChainId()) ));
	}