Skip to content

Commit

Permalink
Updated javadocs and added extra unit test
Browse files Browse the repository at this point in the history
Signed-off-by: Egon Willighagen <egonw@users.sourceforge.net>
  • Loading branch information
rajarshi authored and egonw committed Sep 7, 2010
1 parent bd9fb4f commit ac211ce
Show file tree
Hide file tree
Showing 3 changed files with 35 additions and 31 deletions.
Expand Up @@ -2493,7 +2493,7 @@
<dc:contributor rdf:resource="#rguha"/>
<dc:date>2010-08-31</dc:date>
<definition rdf:parseType='Literal'>
Characterizes molecular complexity in terms of carbon hybridization states
Characterizes molecular complexity in terms of carbon hybridization states.
</definition>
<description rdf:parseType='Literal'>
This descriptor is designed to give a simple characterization of molecular
Expand Down
@@ -1,10 +1,7 @@
/*
* $RCSfile$
* $Author$
* $Date$
* $Revision$
*
* Copyright (C) 2004-2007 The Chemistry Development Kit (CDK) project
*
* Copyright (C) 2010 Rajarshi Guha <rajarshi.guha@gmail.com>
*
* Contact: cdk-devel@lists.sourceforge.net
*
Expand Down Expand Up @@ -38,7 +35,7 @@
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;

/**
* IDescriptor that reports the fraction of sp3 carbons to sp2 carbons.
* {@link IDescriptor} that reports the fraction of sp3 carbons to sp2 carbons.
* <p/>
* Note that it only considers carbon atoms and rather than use a simple ratio
* it reports the value of N<sub>sp3</sub>/ (N<sub>sp3</sub> + N<sub>sp2</sub>).
Expand All @@ -56,23 +53,15 @@
public class HybridizationRatioDescriptor implements IMolecularDescriptor {

/**
* Constructor for the WeightDescriptor object.
* Constructor for the HybridizationRatioDescriptor object.
*/
public HybridizationRatioDescriptor() {
}

/**
* Returns a <code>Map</code> which specifies which descriptor is implemented by this class.
* <p/>
* These fields are used in the map:
* <ul>
* <li>Specification-Reference: refers to an entry in a unique dictionary
* <li>Implementation-Title: anything
* <li>Implementation-Identifier: a unique identifier for this version of
* this class
* <li>Implementation-Vendor: CDK, JOELib, or anything else
* </ul>
* Returns a {@link Map} which specifies which descriptor is implemented by this class.
*
* @inheritDoc
* @return An object containing the descriptor specification
*/
@TestMethod("testGetSpecification")
Expand All @@ -85,7 +74,7 @@ public DescriptorSpecification getSpecification() {
}

/**
* Sets the parameters attribute of the WeightDescriptor object.
* Sets the parameters attribute of the HybridizationRatioDescriptor object.
*
* @param params The new parameters value
* @throws org.openscience.cdk.exception.CDKException
Expand All @@ -99,7 +88,9 @@ public void setParameters(Object[] params) throws CDKException {


/**
* Gets the parameters attribute of the WeightDescriptor object.
* Gets the parameters attribute of the HybridizationRatioDescriptor object.
*
* This descriptor takes no parameters
*
* @return The parameters value
* @see #setParameters
Expand All @@ -114,17 +105,23 @@ public String[] getDescriptorNames() {
return new String[]{"HybRatio"};
}

/**
* @inheritDoc
*
* @param e
* @return
*/
private DescriptorValue getDummyDescriptorValue(Exception e) {
return new DescriptorValue(getSpecification(), getParameterNames(),
getParameters(), new DoubleResult(Double.NaN), getDescriptorNames(), e);
}


/**
* Calculate the weight of specified element type in the supplied {@link org.openscience.cdk.interfaces.IAtomContainer}.
* Calculate sp3/sp2 hybridization ratio in the supplied {@link org.openscience.cdk.interfaces.IAtomContainer}.
*
* @param container The AtomContainer for which this descriptor is to be calculated.
* @return The total weight of atoms of the specified element type
* @return The ratio of sp3 to sp2 carbons
*/
@TestMethod("testCalculate_IAtomContainer")
public DescriptorValue calculate(IAtomContainer container) {
Expand Down Expand Up @@ -166,7 +163,9 @@ public IDescriptorResult getDescriptorResultType() {


/**
* Gets the parameterNames attribute of the WeightDescriptor object.
* Gets the parameterNames attribute of the HybridizationRatioDescriptor object.
*
* This descriptor takes no parameters
*
* @return The parameterNames value
*/
Expand All @@ -179,7 +178,9 @@ public String[] getParameterNames() {
/**
* Gets the parameterType attribute of the HybridizationRatioDescriptor object.
*
* @param name Description of the Parameter
* This descriptor takes no parameters
*
* @param name the parameter name
* @return An Object whose class is that of the parameter requested
*/
@TestMethod("testGetParameterType_String")
Expand Down
@@ -1,9 +1,5 @@
/* $RCSfile$
* $Author$
* $Date$
* $Revision$
*
* Copyright (C) 2004-2007 The Chemistry Development Kit (CDK) project
/*
* Copyright (C) 2010 Rajarshi Guha <rajarshi.guha@gmail.com>
*
* Contact: cdk-devel@lists.sourceforge.net
*
Expand Down Expand Up @@ -32,7 +28,7 @@
import org.openscience.cdk.smiles.SmilesParser;

/**
* TestSuite that runs a test for the HybridizationRatioDescriptor.
* TestSuite that runs a test for the {@link HybridizationRatioDescriptor}.
*
* @cdk.module test-qsarmolecular
*/
Expand All @@ -59,4 +55,11 @@ public void testHybRatioDescriptor2() throws Exception {
IAtomContainer mol = sp.parseSmiles("c1ccccc1");
Assert.assertEquals(0.0, ((DoubleResult) descriptor.calculate(mol).getValue()).doubleValue(), 0.1);
}

@Test
public void testHybRatioDescriptor3() throws Exception {
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IAtomContainer mol = sp.parseSmiles("[H]C#N");
Assert.assertEquals(Double.NaN, ((DoubleResult) descriptor.calculate(mol).getValue()).doubleValue(), 0.1);
}
}

0 comments on commit ac211ce

Please sign in to comment.