|
From: Pekka S. <pe...@ki...> - 2002-09-20 09:53:44
|
Trying to use getMolWt to calculate molecular weight.
The code below fails. I have no programming experience so any help would be
appreciated.
public abstract class MW extends SimpleDoubleDesc
{
/*
*
-------------------------------------------------------------------------*
* public static member variables
*
-------------------------------------------------------------------------
*/
* Obtain a suitable logger.
*/
private static Category logger =
Category.getInstance("joelib.desc.types.MW");
/*
*
-------------------------------------------------------------------------*
* constructor
*
-------------------------------------------------------------------------
*/
/*
* Constructor for the MW object
*/
public MW()
{
descInfo = DescriptorHelper.generateDescInfo("MW",
this.getClass(),
"topological",
2,
null,
"joelib.desc.result.AtomDoubleResult");
}
/*
*
-------------------------------------------------------------------------*
* public methods
*
-------------------------------------------------------------------------
*/
* Gets the molWt attribute of the <tt>JOEMol</tt> object
*
* @return The molWt value
*/
public double getMolWt(JOEMol mol)
{
double molwt = 0.0f;
JOEAtom atom;
AtomIterator ait = mol.atomIterator();
while (ait.hasNext())
{
atom = ait.nextAtom();
molwt += JOEElementTable.instance().getMass(atom.getAtomicNum());
}
return molwt;
}}
|