~ubuntu-branches/ubuntu/trusty/cdk/trusty-proposed

« back to all changes in this revision

Viewing changes to src/org/openscience/cdk/qsar/descriptors/bond/BondPartialSigmaChargeDescriptor.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: egonw $
 
4
 *  $Date: 2006-03-29 10:27:08 +0200 (Wed, 29 Mar 2006) $
 
5
 *  $Revision: 5855 $
 
6
 *
 
7
 *  Copyright (C) 2004-2007  Miguel Rojas <miguel.rojas@uni-koeln.de>
 
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.bond;
 
26
 
 
27
import org.openscience.cdk.Molecule;
 
28
import org.openscience.cdk.exception.CDKException;
 
29
import org.openscience.cdk.interfaces.IAtom;
 
30
import org.openscience.cdk.interfaces.IAtomContainer;
 
31
import org.openscience.cdk.interfaces.IBond;
 
32
import org.openscience.cdk.qsar.DescriptorSpecification;
 
33
import org.openscience.cdk.qsar.DescriptorValue;
 
34
import org.openscience.cdk.qsar.IBondDescriptor;
 
35
import org.openscience.cdk.qsar.descriptors.atomic.PartialSigmaChargeDescriptor;
 
36
import org.openscience.cdk.qsar.result.DoubleResult;
 
37
import org.openscience.cdk.tools.manipulator.BondManipulator;
 
38
 
 
39
/**
 
40
 *  The calculation of bond-sigma Partial charge is calculated 
 
41
 *  determining the difference the Partial Sigma Charge on atoms 
 
42
 *  A and B of a bond. Based in Gasteiger Charge.
 
43
 *  <p>This descriptor uses these parameters:
 
44
 * <table border="1">
 
45
 *   <tr>
 
46
 *     <td>Name</td>
 
47
 *     <td>Default</td>
 
48
 *     <td>Description</td>
 
49
 *   </tr>
 
50
 *   <tr>
 
51
 *     <td>bondPosition</td>
 
52
 *     <td>0</td>
 
53
 *     <td>The position of the target bond</td>
 
54
 *   </tr>
 
55
 * </table>
 
56
 *
 
57
 *
 
58
 * @author      Miguel Rojas
 
59
 * @cdk.created 2006-05-08
 
60
 * @cdk.module  qsar
 
61
 * @cdk.set     qsar-descriptors
 
62
 * @cdk.dictref qsar-descriptors:bondPartialSigmaCharge
 
63
 * @see PartialSigmaChargeDescriptor
 
64
 */
 
65
public class BondPartialSigmaChargeDescriptor implements IBondDescriptor {
 
66
 
 
67
        private PartialSigmaChargeDescriptor  descriptor;
 
68
 
 
69
 
 
70
    /**
 
71
     *  Constructor for the BondPartialSigmaChargeDescriptor object
 
72
     */
 
73
    public BondPartialSigmaChargeDescriptor() {  
 
74
        descriptor  = new PartialSigmaChargeDescriptor() ;
 
75
    }
 
76
 
 
77
 
 
78
    /**
 
79
     *  Gets the specification attribute of the BondPartialSigmaChargeDescriptor
 
80
     *  object
 
81
     *
 
82
     *@return    The specification value
 
83
     */
 
84
    public DescriptorSpecification getSpecification() {
 
85
        return new DescriptorSpecification(
 
86
            "http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#bondPartialSigmaCharge",
 
87
            this.getClass().getName(),
 
88
            "$Id: BondPartialSigmaChargeDescriptor.java 5855 2006-03-29 10:27:08 +0200 (Wed, 29 Mar 2006) egonw $",
 
89
            "The Chemistry Development Kit");
 
90
    }
 
91
 
 
92
    /**
 
93
     * This descriptor does have any parameter.
 
94
     */
 
95
    public void setParameters(Object[] params) throws CDKException {
 
96
    }
 
97
 
 
98
 
 
99
    /**
 
100
     *  Gets the parameters attribute of the BondPartialSigmaChargeDescriptor object.
 
101
     *
 
102
     *@return    The parameters value
 
103
     * @see #setParameters
 
104
     */
 
105
    public Object[] getParameters() {
 
106
        return null;
 
107
    }
 
108
 
 
109
 
 
110
    /**
 
111
     *  The method calculates the bond-sigma Partial charge of a given bond
 
112
     *  It is needed to call the addExplicitHydrogensToSatisfyValency method from the class tools.HydrogenAdder.
 
113
     *
 
114
     *@param  ac                AtomContainer
 
115
     *@return                   return the sigma electronegativity
 
116
     *@exception  CDKException  Possible Exceptions
 
117
     */
 
118
    public DescriptorValue calculate(IBond bond, IAtomContainer ac) throws CDKException {
 
119
        Molecule mol = new Molecule(ac);
 
120
        IAtom[] atoms = BondManipulator.getAtomArray(bond);
 
121
        double[] results = new double[2];
 
122
        
 
123
        Integer[] params = new Integer[1];
 
124
        for(int i = 0 ; i < 2 ; i++){
 
125
                params[0] = new Integer(6);
 
126
                descriptor.setParameters(params);
 
127
                results[i] = ((DoubleResult)descriptor.calculate(atoms[i],mol).getValue()).doubleValue();
 
128
        }
 
129
        
 
130
        double result = Math.abs(results[0] - results[1]);
 
131
        
 
132
        return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult(result));
 
133
    }
 
134
 
 
135
         /**
 
136
    * Gets the parameterNames attribute of the BondPartialSigmaChargeDescriptor object.
 
137
    *
 
138
    * @return    The parameterNames value
 
139
    */
 
140
   public String[] getParameterNames() {
 
141
       return new String[0];
 
142
   }
 
143
 
 
144
 
 
145
   /**
 
146
    * Gets the parameterType attribute of the BondPartialSigmaChargeDescriptor object.
 
147
    *
 
148
    * @param  name  Description of the Parameter
 
149
    * @return       An Object of class equal to that of the parameter being requested
 
150
    */
 
151
   public Object getParameterType(String name) {
 
152
       return null;
 
153
   }
 
154
}
 
155