예제 #1
0
		/**
		 * Prepare atom weights. Get all atom weights from the sum formula
		 * 
		 * @param mol the mol
		 */

		private bool prepareAtomWeights(IAtomContainer mol)
		{
			var molecularFormula = MolecularFormulaTools.GetMolecularFormula(mol);

			var elements = MolecularFormulaManipulator.elements(molecularFormula);
			foreach (var element in elements.ToWindowsEnumerable<IElement>())
			{
				IAtom a = new Atom(element);
				try
				{
					IsotopeFactory.getInstance(a.getBuilder()).configure(a);
				}
				catch (IllegalArgumentException)
				{
					// This means it failed to get the mass for this element, so its an unknown element like "R" for example
					return false;
				}

				//get mass and store in map
				atomMasses[element.getSymbol()] = a.getExactMass().doubleValue();
			}
			return true;
		}