Initiate the reaction ElectronImpactNBE.

@param container The IAtomContainer
@param atom      The IAtom to ionize
@return          The product resultant
@throws CDKException
968440
private static IAtomContainer initiateIonization(IAtomContainer container, IAtom atom) throws CDKException {
        IReactionProcess reactionNBE = new ElectronImpactNBEReaction();

        IAtomContainerSet setOfReactants = container.getBuilder().newInstance(IAtomContainerSet.class);
        setOfReactants.addAtomContainer(container);

        atom.setFlag(CDKConstants.REACTIVE_CENTER, true);
        List<IParameterReact> paramList = new ArrayList<IParameterReact>();
        IParameterReact param = new SetReactionCenter();
        param.setParameter(Boolean.TRUE);
        paramList.add(param);
        reactionNBE.setParameterList(paramList);

        /* initiate */
        IReactionSet setOfReactions = reactionNBE.initiate(setOfReactants, null);
        atom.setFlag(CDKConstants.REACTIVE_CENTER, false);
        if (setOfReactions != null && setOfReactions.getReactionCount() == 1
                && setOfReactions.getReaction(0).getProducts().getAtomContainerCount() == 1)
            return setOfReactions.getReaction(0).getProducts().getAtomContainer(0);
        else
            return null;
    }
278663
public boolean saturateByIncreasingBondOrder(IBond bond, IAtomContainer atomContainer) throws CDKException {
        IAtom[] atoms = BondManipulator.getAtomArray(bond);
        IAtom atom = atoms[0];
        IAtom partner = atoms[1];
        logger.debug("  saturating bond: ", atom.getSymbol(), "-", partner.getSymbol());
        IAtomType[] atomTypes1 = getAtomTypeFactory(bond.getBuilder()).getAtomTypes(atom.getSymbol());
        IAtomType[] atomTypes2 = getAtomTypeFactory(bond.getBuilder()).getAtomTypes(partner.getSymbol());
        for (int atCounter1 = 0; atCounter1 < atomTypes1.length; atCounter1++) {
            IAtomType aType1 = atomTypes1[atCounter1];
            logger.debug("  condidering atom type: ", aType1);
            if (couldMatchAtomType(atomContainer, atom, aType1)) {
                logger.debug("  trying atom type: ", aType1);
                for (int atCounter2 = 0; atCounter2 < atomTypes2.length; atCounter2++) {
                    IAtomType aType2 = atomTypes2[atCounter2];
                    logger.debug("  condidering partner type: ", aType1);
                    if (couldMatchAtomType(atomContainer, partner, atomTypes2[atCounter2])) {
                        logger.debug("    with atom type: ", aType2);
                        if (BondManipulator.isLowerOrder(bond.getOrder(), aType2.getMaxBondOrder())
                                && BondManipulator.isLowerOrder(bond.getOrder(), aType1.getMaxBondOrder())) {
                            bond.setOrder(BondManipulator.increaseBondOrder(bond.getOrder()));
                            logger.debug("Bond order now ", bond.getOrder());
                            return true;
                        }
                    }
                }
            }
        }
        return false;
    }
1051020
@Override
    public DescriptorValue calculate(IAtomContainer container) {
        if (!GeometryUtil.has3DCoordinates(container))
            return getDummyDescriptorValue(new CDKException("Molecule must have 3D coordinates"));

        IsotopeFactory factory = null;
        double mass1;
        double mass2;
        try {
            factory = Isotopes.getInstance();
        } catch (Exception e) {
            logger.debug(e);
        }

        double sum = 0;
        for (int i = 0; i < container.getBondCount(); i++) {
            IBond bond = container.getBond(i);

            if (bond.getAtomCount() != 2) {
                return getDummyDescriptorValue(new CDKException("GravitationalIndex: Only handles 2 center bonds"));
            }

            mass1 = factory.getMajorIsotope(bond.getBegin().getSymbol()).getMassNumber();
            mass2 = factory.getMajorIsotope(bond.getEnd().getSymbol()).getMassNumber();

            Point3d p1 = bond.getBegin().getPoint3d();
            Point3d p2 = bond.getEnd().getPoint3d();

            double x1 = p1.x;
            double y1 = p1.y;
            double z1 = p1.z;
            double x2 = p2.x;
            double y2 = p2.y;
            double z2 = p2.z;

            double dist = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2);
            sum += (mass1 * mass2) / dist;
        }

        // heavy atoms only
        double heavysum = 0;
        for (int i = 0; i < container.getBondCount(); i++) {
            IBond b = container.getBond(i);

            if (b.getAtomCount() != 2) {
                return getDummyDescriptorValue(new CDKException("GravitationalIndex: Only handles 2 center bonds"));
            }

            if (b.getBegin().getSymbol().equals("H") || b.getEnd().getSymbol().equals("H")) continue;

            mass1 = factory.getMajorIsotope(b.getBegin().getSymbol()).getMassNumber();
            mass2 = factory.getMajorIsotope(b.getEnd().getSymbol()).getMassNumber();

            Point3d point0 = b.getBegin().getPoint3d();
            Point3d point1 = b.getEnd().getPoint3d();

            double x1 = point0.x;
            double y1 = point0.y;
            double z1 = point0.z;
            double x2 = point1.x;
            double y2 = point1.y;
            double z2 = point1.z;

            double dist = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2);
            heavysum += (mass1 * mass2) / dist;
        }

        // all pairs
        ArrayList<Integer> x = new ArrayList<Integer>();
        for (int i = 0; i < container.getAtomCount(); i++) {
            if (!container.getAtom(i).getSymbol().equals("H")) x.add(i);
        }
        int npair = x.size() * (x.size() - 1) / 2;
        pair[] p = new pair[npair];
        for (int i = 0; i < npair; i++)
            p[i] = new pair();
        int pcount = 0;
        for (int i = 0; i < x.size() - 1; i++) {
            for (int j = i + 1; j < x.size(); j++) {
                int present = 0;
                int a = x.get(i);
                int b = x.get(j);
                for (int k = 0; k < pcount; k++) {
                    if ((p[k].x == a && p[k].y == b) || (p[k].y == a && p[k].x == b)) present = 1;
                }
                if (present == 1) continue;
                p[pcount].x = a;
                p[pcount].y = b;
                pcount += 1;
            }
        }
        double allheavysum = 0;
        for (pair aP : p) {
            int atomNumber1 = aP.x;
            int atomNumber2 = aP.y;

            mass1 = factory.getMajorIsotope(container.getAtom(atomNumber1).getSymbol()).getMassNumber();
            mass2 = factory.getMajorIsotope(container.getAtom(atomNumber2).getSymbol()).getMassNumber();

            double x1 = container.getAtom(atomNumber1).getPoint3d().x;
            double y1 = container.getAtom(atomNumber1).getPoint3d().y;
            double z1 = container.getAtom(atomNumber1).getPoint3d().z;
            double x2 = container.getAtom(atomNumber2).getPoint3d().x;
            double y2 = container.getAtom(atomNumber2).getPoint3d().y;
            double z2 = container.getAtom(atomNumber2).getPoint3d().z;

            double dist = (x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2) + (z1 - z2) * (z1 - z2);
            allheavysum += (mass1 * mass2) / dist;
        }

        DoubleArrayResult retval = new DoubleArrayResult(9);
        retval.add(heavysum);
        retval.add(Math.sqrt(heavysum));
        retval.add(Math.pow(heavysum, 1.0 / 3.0));

        retval.add(sum);
        retval.add(Math.sqrt(sum));
        retval.add(Math.pow(sum, 1.0 / 3.0));

        retval.add(allheavysum);
        retval.add(Math.sqrt(allheavysum));
        retval.add(Math.pow(allheavysum, 1.0 / 3.0));

        return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), retval,
                getDescriptorNames());
    }
785512
@Override
    public DescriptorValue calculate(IAtom atom, IAtomContainer container) {
        IAtomType atomType;
        try {
            atomType = CDKAtomTypeMatcher.getInstance(atom.getBuilder()).findMatchingAtomType(container, atom);
        } catch (CDKException e) {
            return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new IntegerResult(
                    (int) Double.NaN), // does that work??
                    getDescriptorNames(), new CDKException("Atom type was null"));
        }
        if (atomType == null) {
            return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new IntegerResult(
                    (int) Double.NaN), // does that work??
                    getDescriptorNames(), new CDKException("Atom type was null"));

        }

        if (atomType.getHybridization() == null) {
            return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new IntegerResult(
                    (int) Double.NaN), // does that work??
                    getDescriptorNames(), new CDKException("Hybridization was null"));
        }
        int hybridizationCDK = atomType.getHybridization().ordinal();

        return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new IntegerResult(
                hybridizationCDK), getDescriptorNames());
    }
895169
private IQueryAtom matchExact(final IAtomContainer mol, final IAtom atom) {
        final IChemObjectBuilder bldr = atom.getBuilder();

        int elem = atom.getAtomicNumber();

        // attach atom skipped
        if (elem == 0)
            return null;

        int hcnt = atom.getImplicitHydrogenCount();
        int val = hcnt;
        int con = hcnt;

        for (IBond bond : mol.getConnectedBondsList(atom)) {
            val += bond.getOrder().numeric();
            con++;
            if (bond.getOther(atom).getAtomicNumber() == 1)
                hcnt++;
        }

        Expr expr = new Expr(Expr.Type.ELEMENT, elem)
                .and(new Expr(Expr.Type.TOTAL_DEGREE, con))
                .and(new Expr(Expr.Type.TOTAL_H_COUNT, hcnt))
                .and(new Expr(Expr.Type.VALENCE, val));
        return new QueryAtom(expr);
    }
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);
                }
            }
        }
    }
122467
public static IReaction getRelevantReaction(IChemModel chemModel, IAtom atom) {
        IReaction reaction = null;
        if (chemModel.getReactionSet() != null) {
            IReactionSet reactionSet = chemModel.getReactionSet();
            reaction = ReactionSetManipulator.getRelevantReaction(reactionSet, atom);
        }
        return reaction;
    }
994493
@Override
    public DescriptorValue calculate(IAtomContainer atomContainer) {
        int hBondDonors = 0;

        IAtomContainer ac;
        try {
            ac = (IAtomContainer) atomContainer.clone();
        } catch (CloneNotSupportedException e) {
            return getDummyDescriptorValue(e);
        }

        //org.openscience.cdk.interfaces.IAtom[] atoms = ac.getAtoms();
        // iterate over all atoms of this AtomContainer; use label atomloop to allow for labelled continue
        atomloop: for (int atomIndex = 0; atomIndex < ac.getAtomCount(); atomIndex++) {
            IAtom atom = (IAtom) ac.getAtom(atomIndex);
            // checking for O and N atoms where the formal charge is >= 0
            if ((atom.getSymbol().equals("O") || atom.getSymbol().equals("N")) && atom.getFormalCharge() >= 0) {
                // implicit hydrogens
                Integer implicitH = atom.getImplicitHydrogenCount();
                if (implicitH == CDKConstants.UNSET) implicitH = 0;
                if (implicitH > 0) {
                    hBondDonors++;
                    continue atomloop; // we skip the explicit hydrogens part cause we found implicit hydrogens
                }
                // explicit hydrogens
                java.util.List neighbours = ac.getConnectedAtomsList(atom);
                for (Object neighbour : neighbours) {
                    if (((IAtom) neighbour).getSymbol().equals("H")) {
                        hBondDonors++;
                        continue atomloop;
                    }
                }
            }
        }

        return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new IntegerResult(
                hBondDonors), getDescriptorNames());
    }
1304941
public double getCurrentMaxBondOrder(IAtom atom, IAtomContainer ac) throws CDKException {
        IAtomType[] atomTypes = getAtomTypeFactory(atom.getBuilder()).getAtomTypes(atom.getSymbol());
        if (atomTypes.length == 0) return 0;
        double bondOrderSum = ac.getBondOrderSum(atom);
        Integer hcount = atom.getImplicitHydrogenCount() == CDKConstants.UNSET ? 0 : atom.getImplicitHydrogenCount();
        double max = 0;
        double current = 0;
        for (int f = 0; f < atomTypes.length; f++) {
            current = hcount + bondOrderSum;
            if (atomTypes[f].getBondOrderSum() - current > max) {
                max = atomTypes[f].getBondOrderSum() - current;
            }
        }
        return max;
    }
362415
public void saturate(IAtom atom, IAtomContainer ac) throws CDKException {
        logger.info("Saturating atom by adjusting lone pair electrons...");
        IAtomType atomType = factory.getAtomType(atom.getAtomTypeName());
        int lpCount = (Integer) atomType.getProperty(CDKConstants.LONE_PAIR_COUNT);
        int missingLPs = lpCount - ac.getConnectedLonePairsCount(atom);

        for (int j = 0; j < missingLPs; j++) {
            ILonePair lp = atom.getBuilder().newInstance(ILonePair.class, atom);
            ac.addLonePair(lp);
        }
    }
1306054
private void setAtomsToPlace(IAtomContainer ac) {
        for (int i = 0; i < ac.getAtomCount(); i++) {
            ac.getAtom(i).setFlag(CDKConstants.ISPLACED, true);
        }
    }
40418
private void setActiveCenters(IAtomContainer reactant) throws CDKException {
        if (AtomContainerManipulator.getTotalCharge(reactant) > 0) return;

        Iterator<IAtom> atoms = reactant.atoms().iterator();
        while (atoms.hasNext()) {
            IAtom atomi = atoms.next(); // Atom pos 1
            if ((atomi.getFormalCharge() == CDKConstants.UNSET ? 0 : atomi.getFormalCharge()) <= 0
                    && reactant.getConnectedLonePairsCount(atomi) > 0
                    && reactant.getConnectedSingleElectronsCount(atomi) == 0) {
                atomi.setFlag(CDKConstants.REACTIVE_CENTER, true);

            }
        }
    }
842888
public IAtomContainer generate3DCoordinates(IAtomContainer molecule, boolean clone) throws CDKException,
            NoSuchAtomTypeException, CloneNotSupportedException, IOException {
        String[] originalAtomTypeNames = new String[molecule.getAtomCount()];
        for (int i = 0; i < originalAtomTypeNames.length; i++) {
            originalAtomTypeNames[i] = molecule.getAtom(i).getAtomTypeName();
        }

        logger.debug("******** GENERATE COORDINATES ********");
        for (int i = 0; i < molecule.getAtomCount(); i++) {
            molecule.getAtom(i).setFlag(CDKConstants.ISPLACED, false);
            molecule.getAtom(i).setFlag(CDKConstants.VISITED, false);
        }
        //CHECK FOR CONNECTIVITY!
        logger.debug("#atoms>" + molecule.getAtomCount());
        if (!ConnectivityChecker.isConnected(molecule)) {
            throw new CDKException("Molecule is NOT connected, could not layout.");
        }

        // setup helper classes
        AtomPlacer atomPlacer = new AtomPlacer();
        AtomPlacer3D ap3d = new AtomPlacer3D();
        AtomTetrahedralLigandPlacer3D atlp3d = new AtomTetrahedralLigandPlacer3D();
        ap3d.initilize(parameterSet);
        atlp3d.setParameterSet(parameterSet);

        if (clone) molecule = (IAtomContainer) molecule.clone();
        atomPlacer.setMolecule(molecule);

        if (ap3d.numberOfUnplacedHeavyAtoms(molecule) == 1) {
            logger.debug("Only one Heavy Atom");
            ap3d.getUnplacedHeavyAtom(molecule).setPoint3d(new Point3d(0.0, 0.0, 0.0));
            try {
                atlp3d.add3DCoordinatesForSinglyBondedLigands(molecule);
            } catch (CDKException ex3) {
                logger.error("PlaceSubstitutensERROR: Cannot place substitutents due to:" + ex3.getMessage());
                logger.debug(ex3);
                throw new CDKException("PlaceSubstitutensERROR: Cannot place substitutents due to:" + ex3.getMessage(),
                        ex3);
            }
            return molecule;
        }
        //Assing Atoms to Rings,Aliphatic and Atomtype
        IRingSet ringSetMolecule = ffc.assignAtomTyps(molecule);
        List ringSystems = null;
        IRingSet largestRingSet = null;
        int numberOfRingAtoms = 0;

        if (ringSetMolecule.getAtomContainerCount() > 0) {
            if (templateHandler == null) {
                throw new CDKException(
                        "You are trying to generate coordinates for a molecule with rings, but you have no template handler set. Please do setTemplateHandler() before generation!");
            }
            ringSystems = RingPartitioner.partitionRings(ringSetMolecule);
            largestRingSet = RingSetManipulator.getLargestRingSet(ringSystems);
            IAtomContainer largestRingSetContainer = RingSetManipulator.getAllInOneContainer(largestRingSet);
            numberOfRingAtoms = largestRingSetContainer.getAtomCount();
            templateHandler.mapTemplates(largestRingSetContainer, numberOfRingAtoms);
            if (!checkAllRingAtomsHasCoordinates(largestRingSetContainer)) {
                throw new CDKException("RingAtomLayoutError: Not every ring atom is placed! Molecule cannot be layout.");
            }

            setAtomsToPlace(largestRingSetContainer);
            searchAndPlaceBranches(molecule, largestRingSetContainer, ap3d, atlp3d, atomPlacer);
            largestRingSet = null;
        } else {
            //logger.debug("****** Start of handling aliphatic molecule ******");
            IAtomContainer ac = null;

            ac = atomPlacer.getInitialLongestChain(molecule);
            setAtomsToUnVisited(molecule);
            setAtomsToUnPlaced(molecule);
            ap3d.placeAliphaticHeavyChain(molecule, ac);
            //ZMatrixApproach
            ap3d.zmatrixChainToCartesian(molecule, false);
            searchAndPlaceBranches(molecule, ac, ap3d, atlp3d, atomPlacer);
        }
        layoutMolecule(ringSystems, molecule, ap3d, atlp3d, atomPlacer);
        //logger.debug("******* PLACE SUBSTITUENTS ******");
        try {
            atlp3d.add3DCoordinatesForSinglyBondedLigands(molecule);
        } catch (CDKException ex3) {
            logger.error("PlaceSubstitutensERROR: Cannot place substitutents due to:" + ex3.getMessage());
            logger.debug(ex3);
            throw new CDKException("PlaceSubstitutensERROR: Cannot place substitutents due to:" + ex3.getMessage(), ex3);
        }
        // restore the original atom type names
        for (int i = 0; i < originalAtomTypeNames.length; i++) {
            molecule.getAtom(i).setAtomTypeName(originalAtomTypeNames[i]);
        }

        return molecule;
    }
430876
public void readAtomBlock(IAtomContainer readData) throws CDKException {
        logger.info("Reading ATOM block");
        IsotopeFactory isotopeFactory;
        try {
            isotopeFactory = Isotopes.getInstance();
        } catch (IOException exception) {
            throw new CDKException("Could not initiate the IsotopeFactory.", exception);
        }

        int RGroupCounter = 1;
        int Rnumber = 0;
        String[] rGroup = null;

        boolean foundEND = false;
        while (isReady() && !foundEND) {
            String command = readCommand(readLine());
            if ("END ATOM".equals(command)) {
                // FIXME: should check whether 3D is really 2D
                foundEND = true;
            } else {
                logger.debug("Parsing atom from: " + command);
                IAtom atom = readData.getBuilder().newAtom();
                StringTokenizer tokenizer = new StringTokenizer(command);
                // parse the index
                try {
                    atom.setID(tokenizer.nextToken());
                } catch (Exception exception) {
                    String error = "Error while parsing atom index";
                    logger.error(error);
                    logger.debug(exception);
                    throw new CDKException(error, exception);
                }
                // parse the element
                String element = tokenizer.nextToken();
                if (isotopeFactory.isElement(element)) {
                    atom.setSymbol(element);
                    isotopeFactory.configure(atom); // ?
                } else if ("A".equals(element)) {
                    atom = readData.getBuilder().newInstance(IPseudoAtom.class, element);
                } else if ("Q".equals(element)) {
                    atom = readData.getBuilder().newInstance(IPseudoAtom.class, element);
                } else if ("*".equals(element)) {
                    atom = readData.getBuilder().newInstance(IPseudoAtom.class, element);
                } else if ("LP".equals(element)) {
                    atom = readData.getBuilder().newInstance(IPseudoAtom.class, element);
                } else if ("L".equals(element)) {
                    atom = readData.getBuilder().newInstance(IPseudoAtom.class, element);
                } else if (element.length() > 0 && element.charAt(0) == 'R') {
                    logger.debug("Atom ", element, " is not an regular element. Creating a PseudoAtom.");
                    //check if the element is R
                    rGroup = element.split("^R");
                    if (rGroup.length > 1) {
                        try {
                            Rnumber = Integer.valueOf(rGroup[(rGroup.length - 1)]).intValue();
                            RGroupCounter = Rnumber;
                        } catch (Exception ex) {
                            Rnumber = RGroupCounter;
                            RGroupCounter++;
                        }
                        element = "R" + Rnumber;
                    }
                    atom = readData.getBuilder().newInstance(IPseudoAtom.class, element);
                } else {
                    if (mode == ISimpleChemObjectReader.Mode.STRICT) {
                        throw new CDKException(
                                "Invalid element type. Must be an existing element, or one in: A, Q, L, LP, *.");
                    }
                    atom = readData.getBuilder().newInstance(IPseudoAtom.class, element);
                    atom.setSymbol(element);
                }

                // parse atom coordinates (in Angstrom)
                try {
                    String xString = tokenizer.nextToken();
                    String yString = tokenizer.nextToken();
                    String zString = tokenizer.nextToken();
                    double x = Double.parseDouble(xString);
                    double y = Double.parseDouble(yString);
                    double z = Double.parseDouble(zString);
                    atom.setPoint3d(new Point3d(x, y, z));
                    atom.setPoint2d(new Point2d(x, y)); // FIXME: dirty!
                } catch (Exception exception) {
                    String error = "Error while parsing atom coordinates";
                    logger.error(error);
                    logger.debug(exception);
                    throw new CDKException(error, exception);
                }
                // atom-atom mapping
                String mapping = tokenizer.nextToken();
                if (!mapping.equals("0")) {
                    logger.warn("Skipping atom-atom mapping: " + mapping);
                } // else: default 0 is no mapping defined

                // the rest are key value things
                if (command.indexOf('=') != -1) {
                    Map<String, String> options = parseOptions(exhaustStringTokenizer(tokenizer));
                    Iterator<String> keys = options.keySet().iterator();
                    while (keys.hasNext()) {
                        String key = keys.next();
                        String value = options.get(key);
                        try {
                            switch (key) {
                                case "CHG":
                                    int charge = Integer.parseInt(value);
                                    if (charge != 0) { // zero is no charge specified
                                        atom.setFormalCharge(charge);
                                    }
                                    break;
                                case "RAD":
                                    int numElectons = MDLV2000Writer.SPIN_MULTIPLICITY.ofValue(Integer.parseInt(value))
                                                                                      .getSingleElectrons();
                                    while (numElectons-- > 0) {
                                        readData.addSingleElectron(readData.getBuilder().newInstance(ISingleElectron.class, atom));
                                    }
                                    break;
                                case "VAL":
                                    if (!(atom instanceof IPseudoAtom)) {
                                        try {
                                            int valence = Integer.parseInt(value);
                                            if (valence != 0) {
                                                //15 is defined as 0 in mol files
                                                if (valence == 15)
                                                    atom.setValency(0);
                                                else
                                                    atom.setValency(valence);
                                            }
                                        } catch (Exception exception) {
                                            handleError("Could not parse valence information field", lineNumber, 0, 0, exception);
                                        }
                                    } else {
                                        logger.error("Cannot set valence information for a non-element!");
                                    }
                                    break;
                                default:
                                    logger.warn("Not parsing key: " + key);
                                    break;
                            }
                        } catch (Exception exception) {
                            String error = "Error while parsing key/value " + key + "=" + value + ": "
                                    + exception.getMessage();
                            logger.error(error);
                            logger.debug(exception);
                            throw new CDKException(error, exception);
                        }
                    }
                }

                // store atom
                readData.addAtom(atom);
                logger.debug("Added atom: " + atom);
            }
        }
    }
497000
public static List<IAtom> getHeavyAtoms(IAtomContainer container) {
        List<IAtom> newAc = new ArrayList<IAtom>();
        for (int f = 0; f < container.getAtomCount(); f++) {
            if (!container.getAtom(f).getSymbol().equals("H")) {
                newAc.add(container.getAtom(f));
            }
        }
        return newAc;
    }
148599
private IAtomContainer setFlags(IAtomContainer container, IAtomContainer ac, boolean b) {
        for (Iterator<IAtom> it = container.atoms().iterator(); it.hasNext();) {
            int positionA = ac.indexOf(it.next());
            ac.getAtom(positionA).setFlag(CDKConstants.REACTIVE_CENTER, b);
        }
        for (Iterator<IBond> it = container.bonds().iterator(); it.hasNext();) {
            int positionB = ac.indexOf(it.next());
            ac.getBond(positionB).setFlag(CDKConstants.REACTIVE_CENTER, b);

        }
        return ac;
    }
597660
IAtom toCDKAtom(Atom beamAtom, int hCount) {

        IAtom cdkAtom = newCDKAtom(beamAtom);

        cdkAtom.setImplicitHydrogenCount(hCount);
        cdkAtom.setFormalCharge(beamAtom.charge());

        if (beamAtom.isotope() >= 0) cdkAtom.setMassNumber(beamAtom.isotope());

        if (beamAtom.aromatic()) cdkAtom.setIsAromatic(true);

        if (beamAtom.atomClass() > 0) cdkAtom.setProperty(ATOM_ATOM_MAPPING, beamAtom.atomClass());

        return cdkAtom;
    }