~ubuntu-branches/ubuntu/maverick/cdk/maverick

« back to all changes in this revision

Viewing changes to src/org/openscience/cdk/qsar/descriptors/molecular/VAdjMaDescriptor.java

  • Committer: Bazaar Package Importer
  • Author(s): Paul Cager
  • Date: 2008-04-09 21:17:53 UTC
  • Revision ID: james.westby@ubuntu.com-20080409211753-46lmjw5z8mx5pd8d
Tags: upstream-1.0.2
ImportĀ upstreamĀ versionĀ 1.0.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 *  $RCSfile$
 
3
 *  $Author: rajarshi $
 
4
 *  $Date: 2007-02-01 20:46:29 +0100 (Thu, 01 Feb 2007) $
 
5
 *  $Revision: 7844 $
 
6
 *
 
7
 *  Copyright (C) 2004-2007  The Chemistry Development Kit (CDK) project
 
8
 *
 
9
 *  Contact: cdk-devel@lists.sourceforge.net
 
10
 *
 
11
 *  This program is free software; you can redistribute it and/or
 
12
 *  modify it under the terms of the GNU Lesser General Public License
 
13
 *  as published by the Free Software Foundation; either version 2.1
 
14
 *  of the License, or (at your option) any later version.
 
15
 *
 
16
 *  This program is distributed in the hope that it will be useful,
 
17
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 
18
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
19
 *  GNU Lesser General Public License for more details.
 
20
 *
 
21
 *  You should have received a copy of the GNU Lesser General Public License
 
22
 *  along with this program; if not, write to the Free Software
 
23
 *  Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
 
24
 */
 
25
package org.openscience.cdk.qsar.descriptors.molecular;
 
26
 
 
27
import org.openscience.cdk.exception.CDKException;
 
28
import org.openscience.cdk.interfaces.IAtomContainer;
 
29
import org.openscience.cdk.qsar.DescriptorSpecification;
 
30
import org.openscience.cdk.qsar.DescriptorValue;
 
31
import org.openscience.cdk.qsar.IMolecularDescriptor;
 
32
import org.openscience.cdk.qsar.result.DoubleResult;
 
33
import org.openscience.cdk.qsar.result.IDescriptorResult;
 
34
import org.openscience.cdk.tools.MFAnalyser;
 
35
 
 
36
/**
 
37
 *   Vertex adjacency information (magnitude): 
 
38
 *   1 + log2 m where m is the number of heavy-heavy bonds. If m is zero, then zero is returned.
 
39
 *   (definition from MOE tutorial on line) 
 
40
 *
 
41
 * <p>This descriptor uses these parameters:
 
42
 * <table border="1">
 
43
 *   <tr>
 
44
 *     <td>Name</td>
 
45
 *     <td>Default</td>
 
46
 *     <td>Description</td>
 
47
 *   </tr>
 
48
 *   <tr>
 
49
 *     <td></td>
 
50
 *     <td></td>
 
51
 *     <td>no parameters</td>
 
52
 *   </tr>
 
53
 * </table>
 
54
 *
 
55
 * Returns a single value named <i>vAdjMat</i>.
 
56
 *
 
57
 * @author      mfe4
 
58
 * @cdk.created 2004-11-03
 
59
 * @cdk.module  qsar
 
60
 * @cdk.set     qsar-descriptors
 
61
 * @cdk.dictref qsar-descriptors:vAdjMa
 
62
 */
 
63
public class VAdjMaDescriptor implements IMolecularDescriptor {
 
64
 
 
65
        /**
 
66
         *  Constructor for the VAdjMaDescriptor object
 
67
         */
 
68
        public VAdjMaDescriptor() { }
 
69
 
 
70
 
 
71
        /**
 
72
         *  Gets the specification attribute of the VAdjMaDescriptor object
 
73
         *
 
74
         *@return    The specification value
 
75
         */
 
76
        public DescriptorSpecification getSpecification() {
 
77
        return new DescriptorSpecification(
 
78
            "http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#vAdjMa",
 
79
                    this.getClass().getName(),
 
80
                    "$Id: VAdjMaDescriptor.java 7844 2007-02-01 19:46:29Z rajarshi $",
 
81
            "The Chemistry Development Kit");
 
82
        }
 
83
 
 
84
 
 
85
        /**
 
86
         *  Sets the parameters attribute of the VAdjMaDescriptor object
 
87
         *
 
88
         *@param  params            The new parameters value
 
89
         *@exception  CDKException  Description of the Exception
 
90
         */
 
91
        public void setParameters(Object[] params) throws CDKException {
 
92
                // no parameters for this descriptor
 
93
        }
 
94
 
 
95
 
 
96
        /**
 
97
         *  Gets the parameters attribute of the VAdjMaDescriptor object
 
98
         *
 
99
         *@return    The parameters value
 
100
         */
 
101
        public Object[] getParameters() {
 
102
                // no parameters to return
 
103
                return (null);
 
104
        }
 
105
 
 
106
 
 
107
        /**
 
108
         *  calculates the VAdjMa descriptor for an atom container
 
109
         *
 
110
         *@param  atomContainer                AtomContainer
 
111
         *@return                   VAdjMa
 
112
         *@exception  CDKException  Possible Exceptions
 
113
         */
 
114
        public DescriptorValue calculate(IAtomContainer atomContainer) throws CDKException {
 
115
                MFAnalyser formula = new MFAnalyser(atomContainer);
 
116
                int magnitude = formula.getHeavyAtoms().size();
 
117
                double vadjMa = 0;
 
118
                if (magnitude > 0) {
 
119
                        vadjMa += (Math.log(magnitude) / Math.log(2)) + 1;
 
120
                }
 
121
                return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(),
 
122
                new DoubleResult(vadjMa), new String[] {"vAdjMat"});
 
123
        }
 
124
 
 
125
    /**
 
126
     * Returns the specific type of the DescriptorResult object.
 
127
     * <p/>
 
128
     * The return value from this method really indicates what type of result will
 
129
     * be obtained from the {@link org.openscience.cdk.qsar.DescriptorValue} object. Note that the same result
 
130
     * can be achieved by interrogating the {@link org.openscience.cdk.qsar.DescriptorValue} object; this method
 
131
     * allows you to do the same thing, without actually calculating the descriptor.
 
132
     *
 
133
     * @return an object that implements the {@link org.openscience.cdk.qsar.result.IDescriptorResult} interface indicating
 
134
     *         the actual type of values returned by the descriptor in the {@link org.openscience.cdk.qsar.DescriptorValue} object
 
135
     */
 
136
    public IDescriptorResult getDescriptorResultType() {
 
137
        return new DoubleResult(0.0); 
 
138
    }
 
139
 
 
140
 
 
141
    /**
 
142
     *  Gets the parameterNames attribute of the VAdjMaDescriptor object
 
143
     *
 
144
     *@return    The parameterNames value
 
145
     */
 
146
    public String[] getParameterNames() {
 
147
        // no param names to return
 
148
        return (null);
 
149
    }
 
150
 
 
151
 
 
152
 
 
153
        /**
 
154
         *  Gets the parameterType attribute of the VAdjMaDescriptor object
 
155
         *
 
156
         *@param  name  Description of the Parameter
 
157
         *@return       The parameterType value
 
158
         */
 
159
        public Object getParameterType(String name) {
 
160
                return (null);
 
161
        }
 
162
}
 
163