Obtain the MMFF symbolic types to the atoms of the provided structure.

@param container structure representation
@return MMFF symbolic types for each atom index
500816
String[] symbolicTypes(final IAtomContainer container) {
        EdgeToBondMap bonds = EdgeToBondMap.withSpaceFor(container);
        int[][] graph = GraphUtil.toAdjList(container, bonds);
        return symbolicTypes(container, graph, bonds, new HashSet<IBond>());
    }
990254
public static MmtfSummaryDataBean getStructureInfo(Structure structure) {
		MmtfSummaryDataBean mmtfSummaryDataBean = new MmtfSummaryDataBean();
		// Get all the atoms
		List<Atom> theseAtoms = new ArrayList<>();
		List<Chain> allChains = new ArrayList<>();
		Map<String, Integer> chainIdToIndexMap = new LinkedHashMap<>();
		int chainCounter = 0;
		int bondCount = 0;
		mmtfSummaryDataBean.setAllAtoms(theseAtoms);
		mmtfSummaryDataBean.setAllChains(allChains);
		mmtfSummaryDataBean.setChainIdToIndexMap(chainIdToIndexMap);
		for (int i=0; i<structure.nrModels(); i++){
			List<Chain> chains = structure.getModel(i);
			allChains.addAll(chains);
			for (Chain chain : chains) {
				String idOne = chain.getId();
				if (!chainIdToIndexMap.containsKey(idOne)) {
					chainIdToIndexMap.put(idOne, chainCounter);
				}
				chainCounter++;
				for (Group g : chain.getAtomGroups()) {
					for(Atom atom: getAtomsForGroup(g)){
						theseAtoms.add(atom);
						// If both atoms are in the group
						if (atom.getBonds()!=null){
							bondCount+=atom.getBonds().size();
						}
					}
				}
			}
		}
		// Assumes all bonds are referenced twice
		mmtfSummaryDataBean.setNumBonds(bondCount/2);
		return mmtfSummaryDataBean;

	}
270822
public static Atom[] getAtomCAArray(Structure s) {

		List<Atom> atoms = new ArrayList<Atom>();

		for (Chain c : s.getChains()) {
			for (Group g : c.getAtomGroups()) {
				if (g.hasAtom(CA_ATOM_NAME)
						&& g.getAtom(CA_ATOM_NAME).getElement() == Element.C) {
					atoms.add(g.getAtom(CA_ATOM_NAME));
				}
			}
		}

		return atoms.toArray(new Atom[atoms.size()]);
	}
317844
public IsotopePattern getIsotopes(IMolecularFormula molFor) {

        if (builder == null) {
            try {
                isoFactory = Isotopes.getInstance();
                builder = molFor.getBuilder();
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        String mf = MolecularFormulaManipulator.getString(molFor, true);

        IMolecularFormula molecularFormula = MolecularFormulaManipulator.getMajorIsotopeMolecularFormula(mf, builder);

        IsotopePattern abundance_Mass = null;

        for (IIsotope isos : molecularFormula.isotopes()) {
            String elementSymbol = isos.getSymbol();
            int atomCount = molecularFormula.getIsotopeCount(isos);

            // Generate possible isotope containers for the current atom's
            // these will then me 'multiplied' with the existing patten
            List<IsotopeContainer> additional = new ArrayList<>();
            for (IIsotope isotope : isoFactory.getIsotopes(elementSymbol)) {
                double mass      = isotope.getExactMass();
                double abundance = isotope.getNaturalAbundance();
                if (abundance <= 0.000000001)
                    continue;
                IsotopeContainer container = new IsotopeContainer(mass, abundance);
                if (storeFormula)
                    container.setFormula(asFormula(isotope));
                additional.add(container);
            }

            for (int i = 0; i < atomCount; i++)
                abundance_Mass = calculateAbundanceAndMass(abundance_Mass, additional);
        }

        IsotopePattern isoP = IsotopePatternManipulator.sortAndNormalizedByIntensity(abundance_Mass);
        isoP = cleanAbundance(isoP, minIntensity);
        IsotopePattern isoPattern = IsotopePatternManipulator.sortByMass(isoP);
        return isoPattern;

    }
319797
public static IAtom[] getAtomArray(IAtomContainer container) {
        IAtom[] ret = new IAtom[container.getAtomCount()];
        for (int i = 0; i < ret.length; ++i)
            ret[i] = container.getAtom(i);
        return ret;
    }
276900
public static int getMolecularGraphRadius(IAtomContainer atomContainer) {
        int natom = atomContainer.getAtomCount();

        int[][] admat = AdjacencyMatrix.getMatrix(atomContainer);
        int[][] distanceMatrix = computeFloydAPSP(admat);

        int[] eta = new int[natom];
        for (int i = 0; i < natom; i++) {
            int max = -99999;
            for (int j = 0; j < natom; j++) {
                if (distanceMatrix[i][j] > max) max = distanceMatrix[i][j];
            }
            eta[i] = max;
        }
        int min = 999999;
        for (int anEta : eta) {
            if (anEta < min) min = anEta;
        }
        return min;
    }
380880
public Container ixor(Container x) {
    if (x instanceof ArrayContainer) {
      return ixor((ArrayContainer) x);
    } else if (x instanceof BitmapContainer) {
      return ixor((BitmapContainer) x);
    }
    return ixor((RunContainer) x);
  }
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;
    }
972305
@Override
    public DescriptorValue calculate(IAtomContainer atomContainer) {
        int hBondAcceptors = 0;

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

        // aromaticity is detected prior to descriptor calculation if the respective parameter is set to true

        if (checkAromaticity) {
            try {
                AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(ac);
                Aromaticity.cdkLegacy().apply(ac);
            } catch (CDKException e) {
                return getDummyDescriptorValue(e);
            }
        }

        //org.openscience.cdk.interfaces.IAtom[] atoms = ac.getAtoms();
        // labelled for loop to allow for labelled continue statements within the loop
        atomloop: for (IAtom atom : ac.atoms()) {
            // looking for suitable nitrogen atoms
            if (atom.getSymbol().equals("N") && atom.getFormalCharge() <= 0) {

                // excluding nitrogens that are adjacent to an oxygen
                List<IBond> bonds = ac.getConnectedBondsList(atom);
                int nPiBonds = 0;
                for (IBond bond : bonds) {
                    if (bond.getOther(atom).getSymbol().equals("O")) continue atomloop;
                    if (IBond.Order.DOUBLE.equals(bond.getOrder())) nPiBonds++;
                }

                // if the nitrogen is aromatic and there are no pi bonds then it's
                // lone pair cannot accept any hydrogen bonds
                if (atom.getFlag(CDKConstants.ISAROMATIC) && nPiBonds == 0) continue;

                hBondAcceptors++;
            }
            // looking for suitable oxygen atoms
            else if (atom.getSymbol().equals("O") && atom.getFormalCharge() <= 0) {
                //excluding oxygens that are adjacent to a nitrogen or to an aromatic carbon
                List<IBond> neighbours = ac.getConnectedBondsList(atom);
                for (IBond bond : neighbours) {
                    IAtom neighbor = bond.getOther(atom);
                    if (neighbor.getSymbol().equals("N") ||
                        (neighbor.getSymbol().equals("C") &&
                         neighbor.isAromatic() &&
                         bond.getOrder() != IBond.Order.DOUBLE))
                        continue atomloop;;
                }
                hBondAcceptors++;
            }
        }

        return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new IntegerResult(
                hBondAcceptors), getDescriptorNames());
    }
938575
public static final Atom[] getAtomArray(Atom[] ca,List<Group> hetatms ) throws StructureException{
		List<Atom> atoms = new ArrayList<Atom>();
		Collections.addAll(atoms, ca);

		logger.debug("got {} hetatoms", hetatms.size());

		// we only add atom nr 1, since the getAlignedStructure method actually adds the parent group, and not the atoms...
		for (Group g : hetatms){
			if (g.size() < 1)
				continue;
			//if (debug)
			//   System.out.println("adding group " + g);
			Atom a = g.getAtom(0);
			//if (debug)
			//  System.out.println(a);
			a.setGroup(g);
			atoms.add(a);
		}

		Atom[] arr = atoms.toArray(new Atom[atoms.size()]);

		return arr;
	}
1366819
public IAtomContainer assignMMFF94PartialCharges(IAtomContainer ac) throws CDKException {
        if (!mmff.assignAtomTypes(ac))
            throw new CDKException("Molecule had an atom of unknown MMFF type");
        mmff.partialCharges(ac);
        mmff.clearProps(ac);
        for (IAtom atom : ac.atoms())
            atom.setProperty(MMFF_94_CHARGE, atom.getCharge());
        return ac;
    }
173393
@Override
    public DescriptorValue calculate(IAtomContainer container) {
        IAtomContainer local = AtomContainerManipulator.removeHydrogens(container);

        int tradius = PathTools.getMolecularGraphRadius(local);
        int tdiameter = PathTools.getMolecularGraphDiameter(local);

        DoubleArrayResult retval = new DoubleArrayResult();
        retval.add((double) (tdiameter - tradius) / (double) tradius);

        // get the 3D distance matrix
        if (GeometryUtil.has3DCoordinates(container)) {
            int natom = container.getAtomCount();
            double[][] distanceMatrix = new double[natom][natom];
            for (int i = 0; i < natom; i++) {
                for (int j = 0; j < natom; j++) {
                    if (i == j) {
                        distanceMatrix[i][j] = 0.0;
                        continue;
                    }

                    Point3d a = container.getAtom(i).getPoint3d();
                    Point3d b = container.getAtom(j).getPoint3d();
                    distanceMatrix[i][j] = Math.sqrt((a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y)
                            + (a.z - b.z) * (a.z - b.z));
                }
            }
            double gradius = 999999;
            double gdiameter = -999999;
            double[] geta = new double[natom];
            for (int i = 0; i < natom; i++) {
                double max = -99999;
                for (int j = 0; j < natom; j++) {
                    if (distanceMatrix[i][j] > max) max = distanceMatrix[i][j];
                }
                geta[i] = max;
            }
            for (int i = 0; i < natom; i++) {
                if (geta[i] < gradius) gradius = geta[i];
                if (geta[i] > gdiameter) gdiameter = geta[i];
            }
            retval.add((gdiameter - gradius) / gradius);
        } else {
            retval.add(Double.NaN);
        }

        return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), retval,
                getDescriptorNames());
    }
278004
private Set<IChemObject> getAromatics(IAtomContainer mol) {
        Set<IChemObject> oldArom = new HashSet<>();
        for (IAtom atom : mol.atoms())
            if (atom.getFlag(CDKConstants.ISAROMATIC))
                oldArom.add(atom);
        for (IBond bond : mol.bonds())
            if (bond.getFlag(CDKConstants.ISAROMATIC))
                oldArom.add(bond);
        return oldArom;
    }
537834
IRenderingElement generateSgroups(IAtomContainer container, AtomSymbol[] symbols) {

        ElementGroup result = new ElementGroup();
        List<Sgroup> sgroups = container.getProperty(CDKConstants.CTAB_SGROUPS);

        if (sgroups == null || sgroups.isEmpty())
            return result;

        Map<IAtom, AtomSymbol> symbolMap = new HashMap<>();
        for (int i = 0; i < symbols.length; i++) {
            if (symbols[i] != null)
                symbolMap.put(container.getAtom(i), symbols[i]);
        }

        for (Sgroup sgroup : sgroups) {

            switch (sgroup.getType()) {
                case CtabAbbreviation:
                    result.add(generateAbbreviationSgroup(container, sgroup));
                    break;
                case CtabMultipleGroup:
                    result.add(generateMultipleSgroup(sgroup, symbolMap));
                    break;
                case CtabAnyPolymer:
                case CtabMonomer:
                case CtabCrossLink:
                case CtabCopolymer:
                case CtabStructureRepeatUnit:
                case CtabMer:
                case CtabGraft:
                case CtabModified:
                    result.add(generatePolymerSgroup(sgroup, symbolMap));
                    break;
                case CtabComponent:
                case CtabMixture:
                case CtabFormulation:
                    result.add(generateMixtureSgroup(sgroup));
                    break;
                case CtabGeneric:
                    // not strictly a polymer but okay to draw as one
                    result.add(generatePolymerSgroup(sgroup, null));
                    break;
            }
        }

        return result;
    }
162160
public static List<AtomSite> convertStructureToAtomSites(Structure s) {
		List<AtomSite> list = new ArrayList<AtomSite>();

		for (int m=0;m<s.nrModels();m++) {
			for (Chain c:s.getChains(m)) {
				list.addAll(convertChainToAtomSites(c, m+1, c.getName(), c.getId()));
			}
		}
		return list;
	}
66489
@Override
    public DescriptorValue calculate(IAtomContainer atomContainer) {
        double zagreb = 0;
        for (IAtom atom : atomContainer.atoms()) {
            if (atom.getSymbol().equals("H")) continue;
            int atomDegree = 0;
            List<IAtom> neighbours = atomContainer.getConnectedAtomsList(atom);
            for (IAtom neighbour : neighbours) {
                if (!neighbour.getSymbol().equals("H")) {
                    atomDegree += 1;
                }
            }
            zagreb += (atomDegree * atomDegree);
        }
        return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult(zagreb),
                getDescriptorNames());
    }
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;
    }