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

« back to all changes in this revision

Viewing changes to src/org/openscience/cdk/qsar/descriptors/atomic/IPAtomicDescriptor.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
/* $Revision: 6228 $ $Author: egonw $ $Date: 2006-05-11 18:34:42 +0200 (Thu, 11 May 2006) $
 
2
 *
 
3
 * Copyright (C) 2006-2007  Miguel Rojas <miguel.rojas@uni-koeln.de>
 
4
 * 
 
5
 * Contact: cdk-devel@lists.sourceforge.net
 
6
 *
 
7
 * This program is free software; you can redistribute it and/or modify
 
8
 * it under the terms of the GNU General Public License as published by
 
9
 * the Free Software Foundation; either version 2 of the License, or
 
10
 * (at your option) any later version.
 
11
 *
 
12
 * This program is distributed in the hope that it will be useful,
 
13
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 
14
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 
15
 * GNU General Public License for more details.
 
16
 *
 
17
 * You should have received a copy of the GNU General Public License along
 
18
 * with this program; if not, write to the Free Software Foundation, Inc.,
 
19
 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 
20
 */
 
21
package org.openscience.cdk.qsar.descriptors.atomic;
 
22
 
 
23
import java.util.Iterator;
 
24
import java.util.List;
 
25
 
 
26
import org.openscience.cdk.AtomContainerSet;
 
27
import org.openscience.cdk.CDKConstants;
 
28
import org.openscience.cdk.aromaticity.HueckelAromaticityDetector;
 
29
import org.openscience.cdk.exception.CDKException;
 
30
import org.openscience.cdk.graph.invariant.ConjugatedPiSystemsDetector;
 
31
import org.openscience.cdk.interfaces.IAtom;
 
32
import org.openscience.cdk.interfaces.IAtomContainer;
 
33
import org.openscience.cdk.interfaces.IBond;
 
34
import org.openscience.cdk.interfaces.IMolecule;
 
35
import org.openscience.cdk.interfaces.IMoleculeSet;
 
36
import org.openscience.cdk.interfaces.IReaction;
 
37
import org.openscience.cdk.interfaces.IReactionSet;
 
38
import org.openscience.cdk.qsar.DescriptorSpecification;
 
39
import org.openscience.cdk.qsar.DescriptorValue;
 
40
import org.openscience.cdk.qsar.IAtomicDescriptor;
 
41
import org.openscience.cdk.qsar.descriptors.bond.BondPartialSigmaChargeDescriptor;
 
42
import org.openscience.cdk.qsar.descriptors.bond.ResonancePositiveChargeDescriptor;
 
43
import org.openscience.cdk.qsar.result.DoubleArrayResult;
 
44
import org.openscience.cdk.qsar.result.DoubleResult;
 
45
import org.openscience.cdk.reaction.IReactionProcess;
 
46
import org.openscience.cdk.reaction.type.ElectronImpactNBEReaction;
 
47
 
 
48
/**
 
49
 *  This class returns the ionization potential of an atom containg lone 
 
50
 *  pair electrons. It is
 
51
 *  based on a decision tree which is extracted from Weka(J48) from 
 
52
 *  experimental values. Up to now is only possible predict for 
 
53
 *  Cl,Br,I,N,P,O,S Atoms and they are not belong to
 
54
 *  conjugated system or not adjacent to an double bond.
 
55
 *
 
56
 * <p>This descriptor uses these parameters:
 
57
 * <table border="1">
 
58
 *   <tr>
 
59
 *     <td>Name</td>
 
60
 *     <td>Default</td>
 
61
 *     <td>Description</td>
 
62
 *   </tr>
 
63
 *   <tr>
 
64
 *     <td></td>
 
65
 *     <td></td>
 
66
 *     <td>no parameters</td>
 
67
 *   </tr>
 
68
 * </table>
 
69
 *
 
70
 * @author           Miguel Rojas
 
71
 * @cdk.created      2006-05-26
 
72
 * @cdk.module       qsar
 
73
 * @cdk.set          qsar-descriptors
 
74
 * @cdk.dictref      qsar-descriptors:ionizationPotential
 
75
 * 
 
76
 */
 
77
public class IPAtomicDescriptor implements IAtomicDescriptor {
 
78
 
 
79
        private IReactionSet reactionSet;
 
80
        
 
81
        /**
 
82
         *  Constructor for the IPAtomicDescriptor object
 
83
         */
 
84
        public IPAtomicDescriptor() {
 
85
        }
 
86
        /**
 
87
         *  Gets the specification attribute of the IPAtomicDescriptor object
 
88
         *
 
89
         *@return    The specification value
 
90
         */
 
91
        public DescriptorSpecification getSpecification() {
 
92
                return new DescriptorSpecification(
 
93
                                "http://www.blueobelisk.org/ontologies/chemoinformatics-algorithms/#ionizationPotential",
 
94
                                this.getClass().getName(),
 
95
                                "$Id: IPAtomicDescriptor.java 6171 2006-5-22 19:29:58Z egonw $",
 
96
                                "The Chemistry Development Kit");
 
97
        }
 
98
    /**
 
99
     * This descriptor does have any parameter.
 
100
     */
 
101
    public void setParameters(Object[] params) throws CDKException {
 
102
    }
 
103
 
 
104
 
 
105
    /**
 
106
     *  Gets the parameters attribute of the IPAtomicDescriptor object.
 
107
     *
 
108
     *@return    The parameters value
 
109
     * @see #setParameters
 
110
     */
 
111
    public Object[] getParameters() {
 
112
        return null;
 
113
    }
 
114
        /**
 
115
         *  This method calculates the ionization potential of an atom.
 
116
         *
 
117
         *@param  chemObj           The IAtom to ionize.
 
118
         *@param  container         Parameter is the IAtomContainer.
 
119
         *@return                   The ionization potential. Not possible the ionization.
 
120
         *@exception  CDKException  Description of the Exception
 
121
         */
 
122
        public DescriptorValue calculate(IAtom atom, IAtomContainer atomContainer) throws CDKException{
 
123
        IAtomContainer localClone;
 
124
        try {
 
125
            localClone= (IAtomContainer) atomContainer.clone();
 
126
        } catch (CloneNotSupportedException e) {
 
127
            throw new CDKException("Error during clone");
 
128
        }
 
129
        IAtom clonedAtom = localClone.getAtom(atomContainer.getAtomNumber(atom));
 
130
        
 
131
        reactionSet = localClone.getBuilder().newReactionSet();
 
132
        
 
133
                double resultD = -1.0;
 
134
                boolean isTarget = false;
 
135
                boolean isConjugated = false;
 
136
                double[] resultsH = null;
 
137
 
 
138
                /*control if it is into an aromatic or conjugated system*/
 
139
                HueckelAromaticityDetector.detectAromaticity(localClone,true);
 
140
                AtomContainerSet conjugatedPi = ConjugatedPiSystemsDetector.detect(localClone);
 
141
                Iterator acI = conjugatedPi.atomContainers();
 
142
                while(acI.hasNext()){
 
143
                        IAtomContainer ac = (IAtomContainer) acI.next();
 
144
                        if(ac.contains(clonedAtom)){
 
145
                                isConjugated = true;
 
146
                                if(localClone.getMaximumBondOrder(clonedAtom) == 1 && localClone.getConnectedLonePairsCount(clonedAtom) > 0){
 
147
                                        resultsH = calculateHeteroAtomConjugatedDescriptor(clonedAtom, localClone,ac);
 
148
                                        resultD = getTreeHeteroConjAtom(resultsH);
 
149
                                        resultD += 0.05;
 
150
                                        isTarget = true;
 
151
                                }
 
152
                        }
 
153
                }
 
154
                
 
155
                if(atom.getFlag(CDKConstants.ISAROMATIC))
 
156
                        return null;
 
157
                
 
158
                int count = localClone.getConnectedLonePairsCount(clonedAtom);
 
159
                
 
160
                if(localClone.getMaximumBondOrder(clonedAtom) > 1 && localClone.getConnectedLonePairsCount(clonedAtom) > 0){
 
161
                        resultsH = calculateCarbonylDescriptor(clonedAtom, localClone);
 
162
                        resultD = getTreeDoubleHetero(resultsH);
 
163
                        resultD += 0.05;
 
164
                        isTarget = true;
 
165
                }else if(localClone.getConnectedLonePairsCount(clonedAtom) > 0 && !isConjugated){
 
166
                        resultsH = calculateHeteroAtomDescriptor(clonedAtom, localClone);
 
167
                        resultD = getTreeHeteroAtom(resultsH);
 
168
                        resultD += 0.05;
 
169
                        isTarget = true;
 
170
                }
 
171
                        
 
172
                        
 
173
                if(isTarget){
 
174
                        /* inizate reaction*/
 
175
                        if(localClone.getConnectedLonePairsCount(clonedAtom) > 0){
 
176
                                
 
177
                                IMoleculeSet setOfReactants = localClone.getBuilder().newMoleculeSet();
 
178
                                setOfReactants.addMolecule((IMolecule) localClone);
 
179
                                IReactionProcess type  = new ElectronImpactNBEReaction();
 
180
                                atom.setFlag(CDKConstants.REACTIVE_CENTER,true);
 
181
                        Object[] params = {Boolean.TRUE};
 
182
                        type.setParameters(params);
 
183
                        IReactionSet nbe = type.initiate(setOfReactants, null);
 
184
                        Iterator it = nbe.reactions();
 
185
                        while(it.hasNext()){
 
186
                                IReaction reaction = (IReaction)it.next();
 
187
                                reaction.setProperty("IonizationEnergy", new Double(resultD));
 
188
                                reactionSet.addReaction(reaction);
 
189
                        }
 
190
                        }
 
191
                }
 
192
                return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new DoubleResult(resultD));
 
193
        }
 
194
        /**
 
195
         * tree desicion for the carbonyl atoms
 
196
         * 
 
197
         * @param resultsH Array which contains the results of each descriptor
 
198
         * @return the result
 
199
         */
 
200
        private double getTreeHeteroConjAtom(double[] resultsH) {
 
201
                double result = 0.0;
 
202
                double SE_1 = resultsH[0];
 
203
                double SE_2 = resultsH[1];
 
204
                double EE_1  = resultsH[2];
 
205
                double RES_c2 = resultsH[3];
 
206
        
 
207
                if (SE_1 <= -0.069065)
 
208
                {
 
209
                  if (SE_1 <= -0.138994)
 
210
                  {
 
211
                    if (EE_1 <= 0.676304)
 
212
                    {
 
213
                      if (SE_1 <= -2.022267) { result = 07.7; /* 2.0 */}
 
214
                      else if (SE_1 > -2.022267) { result = 08.2; /* 4.0/2.0 */}
 
215
                    }
 
216
                    if (EE_1 > 0.676304)
 
217
                    {
 
218
                      if (SE_1 <= -2.514435) { result = 08.0; /* 3.0/1.0 */}
 
219
                      else if (SE_1 > -2.514435) { result = 09.5; /* 4.0/2.0 */}
 
220
                    }
 
221
                  }
 
222
                  if (SE_1 > -0.138994)
 
223
                  {
 
224
                    if (EE_1 <= 0.032157)
 
225
                    {
 
226
                      if (EE_1 <= 0.026958)
 
227
                      {
 
228
                        if (EE_1 <= 0.023022) { result = 08.1; /* 2.0/1.0 */}
 
229
                        else if (EE_1 > 0.023022)
 
230
                        {
 
231
                          if (SE_1 <= -0.074747) { result = 08.6; /* 3.0/1.0 */}
 
232
                          else if (SE_1 > -0.074747) { result = 08.9; /* 3.0 */}
 
233
                        }
 
234
                      }
 
235
                      if (EE_1 > 0.026958)
 
236
                      {
 
237
                        if (SE_2 <= 0.081676) { result = 08.3; /* 2.0/1.0 */}
 
238
                        else if (SE_2 > 0.081676) { result = 08.0; /* 6.0/1.0 */}
 
239
                      }
 
240
                    }
 
241
                    if (EE_1 > 0.032157)
 
242
                    {
 
243
                      if (EE_1 <= 0.045671) { result = 08.6; /* 5.0/2.0 */}
 
244
                      else if (EE_1 > 0.045671)
 
245
                      {
 
246
                        if (SE_1 <= -0.137681) { result = 08.1; /* 2.0/1.0 */}
 
247
                        else if (SE_1 > -0.137681) { result = 08.4; /* 5.0/2.0 */}
 
248
                      }
 
249
                    }
 
250
                  }
 
251
                }
 
252
                if (SE_1 > -0.069065)
 
253
                {
 
254
                  if (SE_1 <= -0.061906)
 
255
                  {
 
256
                    if (RES_c2 <= 0.006978) { result = 07.4; /* 15.0/10.0 */}
 
257
                    else if (RES_c2 > 0.006978)
 
258
                    {
 
259
                      if (SE_1 <= -0.063064) { result = 07.5; /* 8.0/5.0 */}
 
260
                      else if (SE_1 > -0.063064) { result = 07.3; /* 2.0/1.0 */}
 
261
                    }
 
262
                  }
 
263
                  if (SE_1 > -0.061906)
 
264
                  {
 
265
                    if (RES_c2 <= 0.003398)
 
266
                    {
 
267
                      if (SE_1 <= 0.051565)
 
268
                      {
 
269
                        if (EE_1 <= 0.007932)
 
270
                        {
 
271
                          if (SE_1 <= -0.023796) { result = 08.7; /* 4.0/2.0 */}
 
272
                          else if (SE_1 > -0.023796)
 
273
                          {
 
274
                            if (EE_1 <= -0.003129) { result = 07.3; /* 2.0/1.0 */}
 
275
                            else if (EE_1 > -0.003129) { result = 07.4; /* 4.0/2.0 */}
 
276
                          }
 
277
                        }
 
278
                        if (EE_1 > 0.007932)
 
279
                        {
 
280
                          if (SE_1 <= -0.0252)
 
281
                          {
 
282
                            if (SE_1 <= -0.02952) { result = 08.0; /* 2.0/1.0 */}
 
283
                            else if (SE_1 > -0.02952) { result = 07.8; /* 2.0/1.0 */}
 
284
                          }
 
285
                          if (SE_1 > -0.0252) { result = 07.7; /* 4.0/1.0 */}
 
286
                        }
 
287
                      }
 
288
                      if (SE_1 > 0.051565)
 
289
                      {
 
290
                        if (RES_c2 <= -0.003572) { result = 08.5; /* 4.0/2.0 */}
 
291
                        else if (RES_c2 > -0.003572)
 
292
                        {
 
293
                          if (SE_1 <= 0.126992) { result = 07.6; /* 2.0/1.0 */}
 
294
                          else if (SE_1 > 0.126992) { result = 08.2; /* 2.0/1.0 */}
 
295
                        }
 
296
                      }
 
297
                    }
 
298
                    if (RES_c2 > 0.003398)
 
299
                    {
 
300
                      if (SE_1 <= -0.031039)
 
301
                      {
 
302
                        if (RES_c2 <= 0.005076) { result = 08.1; /* 9.0/5.0 */}
 
303
                        else if (RES_c2 > 0.005076)
 
304
                        {
 
305
                          if (SE_1 <= -0.061705) { result = 08.2; /* 2.0 */}
 
306
                          else if (SE_1 > -0.061705)
 
307
                          {
 
308
                            if (SE_1 <= -0.060998) { result = 08.3; /* 2.0 */}
 
309
                            else if (SE_1 > -0.060998) { result = 08.0; /* 2.0/1.0 */}
 
310
                          }
 
311
                        }
 
312
                      }
 
313
                      if (SE_1 > -0.031039)
 
314
                      {
 
315
                        if (SE_1 <= -0.023566)
 
316
                        {
 
317
                          if (SE_1 <= -0.028788) { result = 07.9; /* 2.0 */}
 
318
                          else if (SE_1 > -0.028788) { result = 09.3; /* 2.0/1.0 */}
 
319
                        }
 
320
                        if (SE_1 > -0.023566)
 
321
                        {
 
322
                          if (RES_c2 <= 0.004518) { result = 08.2; /* 2.0/1.0 */}
 
323
                          else if (RES_c2 > 0.004518) { result = 08.7; /* 4.0/2.0 */}
 
324
                        }
 
325
                      }
 
326
                    }
 
327
                  }
 
328
                }
 
329
                
 
330
                return result;
 
331
        }
 
332
        /**
 
333
         * tree desicion for the carbonyl atoms
 
334
         * 
 
335
         * @param resultsH Array which contains the results of each descriptor
 
336
         * @return the result
 
337
         */
 
338
        private double getTreeDoubleHetero(double[] resultsH) {
 
339
                double result = 0.0;
 
340
                double SE_c = resultsH[0];
 
341
                double PCH_c = resultsH[1];
 
342
                double SB  = resultsH[2];
 
343
                double SE_x = resultsH[3];
 
344
                double PCH_x = resultsH[4];
 
345
                double RES_c = resultsH[5];
 
346
                
 
347
                if (PCH_c <= 0.045111)
 
348
                {
 
349
                  if (PCH_x <= -0.041368)
 
350
                  {
 
351
                    if (SE_c <= 7.471265)
 
352
                    {
 
353
                      if (RES_c <= 0.182146)
 
354
                      {
 
355
                        if (SB <= 0.448987)
 
356
                        {
 
357
                          if (RES_c <= 0.181878) { result = 08.4; /* 3.0/1.0 */}
 
358
                          else if (RES_c > 0.181878) { result = 09.2; /* 4.0/1.0 */}
 
359
                        }
 
360
                        if (SB > 0.448987)
 
361
                        {
 
362
                          if (SE_c <= 6.758953) { result = 09.0; /* 2.0 */}
 
363
                          else if (SE_c > 6.758953) { result = 09.6; /* 2.0/1.0 */}
 
364
                        }
 
365
                      }
 
366
                      if (RES_c > 0.182146)
 
367
                      {
 
368
                        if (RES_c <= 0.371342)
 
369
                        {
 
370
                          if (PCH_c <= 0.019491) { result = 09.3; /* 9.0/3.0 */}
 
371
                          else if (PCH_c > 0.019491)
 
372
                          {
 
373
                            if (SE_c <= 6.683097) { result = 09.7; /* 3.0 */}
 
374
                            else if (SE_c > 6.683097) { result = 09.6; /* 4.0/2.0 */}
 
375
                          }
 
376
                        }
 
377
                        if (RES_c > 0.371342)
 
378
                        {
 
379
                          if (PCH_c <= 0.019061) { result = 08.7; /* 3.0/1.0 */}
 
380
                          else if (PCH_c > 0.019061)
 
381
                          {
 
382
                            if (SE_c <= 6.689165) { result = 09.9; /* 2.0/1.0 */}
 
383
                            else if (SE_c > 6.689165) { result = 09.5; /* 4.0/1.0 */}
 
384
                          }
 
385
                        }
 
386
                      }
 
387
                    }
 
388
                    if (SE_c > 7.471265)
 
389
                    {
 
390
                      if (SE_x <= 13.191725)
 
391
                      {
 
392
                        if (SB <= 0.479515)
 
393
                        {
 
394
                          if (PCH_x <= -0.045111) { result = 10.2; /* 4.0/2.0 */}
 
395
                          else if (PCH_x > -0.045111) { result = 09.8; /* 2.0/1.0 */}
 
396
                        }
 
397
                        if (SB > 0.479515)
 
398
                        {
 
399
                          if (SE_c <= 7.571876) { result = 10.0; /* 4.0/2.0 */}
 
400
                          else if (SE_c > 7.571876) { result = 09.6; /* 4.0/1.0 */}
 
401
                        }
 
402
                      }
 
403
                      if (SE_x > 13.191725)
 
404
                      {
 
405
                        if (PCH_c <= 0.010584) { result = 09.5; /* 3.0/1.0 */}
 
406
                        else if (PCH_c > 0.010584) { result = 09.4; /* 2.0/1.0 */}
 
407
                      }
 
408
                    }
 
409
                  }
 
410
                  if (PCH_x > -0.041368)
 
411
                  {
 
412
                    if (PCH_c <= 0.029565)
 
413
                    {
 
414
                      if (SB <= 0.028396)
 
415
                      {
 
416
                        if (PCH_c <= 0.02228) { result = 08.6; /* 3.0/1.0 */}
 
417
                        else if (PCH_c > 0.02228) { result = 07.4; /* 2.0/1.0 */}
 
418
                      }
 
419
                      if (SB > 0.028396)
 
420
                      {
 
421
                        if (SE_x <= 9.633713)
 
422
                        {
 
423
                          if (SE_c <= 8.750164) { result = 08.4; /* 2.0/1.0 */}
 
424
                          else if (SE_c > 8.750164) { result = 09.4; /* 3.0/1.0 */}
 
425
                        }
 
426
                        if (SE_x > 9.633713)
 
427
                        {
 
428
                          if (PCH_c <= 0)
 
429
                          {
 
430
                            if (SE_c <= 7.010887) { result = 09.1; /* 2.0/1.0 */}
 
431
                            else if (SE_c > 7.010887) { result = 08.6; /* 3.0/2.0 */}
 
432
                          }
 
433
                          if (PCH_c > 0)
 
434
                          {
 
435
                            if (SE_c <= 8.852704)
 
436
                            {
 
437
                              if (SB <= 0.473847)
 
438
                              {
 
439
                                if (PCH_c <= 0.000059) { result = 08.5; /* 2.0 */}
 
440
                                else if (PCH_c > 0.000059)
 
441
                                {
 
442
                                  if (SE_c <= 8.779599) { result = 08.6; /* 4.0/1.0 */}
 
443
                                  else if (SE_c > 8.779599) { result = 08.5; /* 2.0/1.0 */}
 
444
                                }
 
445
                              }
 
446
                              if (SB > 0.473847) { result = 08.2; /* 2.0/1.0 */}
 
447
                            }
 
448
                            if (SE_c > 8.852704) { result = 08.2; /* 3.0/2.0 */}
 
449
                          }
 
450
                        }
 
451
                      }
 
452
                    }
 
453
                    if (PCH_c > 0.029565)
 
454
                    {
 
455
                      if (SE_x <= 12.990697)
 
456
                      {
 
457
                        if (PCH_c <= 0.039387)
 
458
                        {
 
459
                          if (RES_c <= 1.086882)
 
460
                          {
 
461
                            if (SE_x <= 9.519079) { result = 10.0; /* 2.0 */}
 
462
                            else if (SE_x > 9.519079)
 
463
                            {
 
464
                              if (SE_c <= 8.798893) { result = 09.8; /* 3.0/1.0 */}
 
465
                              else if (SE_c > 8.798893) { result = 09.2; /* 3.0/2.0 */}
 
466
                            }
 
467
                          }
 
468
                          if (RES_c > 1.086882) { result = 08.9; /* 3.0/1.0 */}
 
469
                        }
 
470
                        if (PCH_c > 0.039387)
 
471
                        {
 
472
                          if (SE_c <= 10.049963) { result = 09.3; /* 13.0/7.0 */}
 
473
                          else if (SE_c > 10.049963)
 
474
                          {
 
475
                            if (PCH_c <= 0.039719) { result = 09.1; /* 25.0/13.0 */}
 
476
                            else if (PCH_c > 0.039719)
 
477
                            {
 
478
                              if (SE_c <= 10.079873) { result = 09.3; /* 2.0/1.0 */}
 
479
                              else if (SE_c > 10.079873) { result = 08.9; /* 2.0/1.0 */}
 
480
                            }
 
481
                          }
 
482
                        }
 
483
                      }
 
484
                      if (SE_x > 12.990697)
 
485
                      {
 
486
                        if (PCH_c <= 0.039882)
 
487
                        {
 
488
                          if (RES_c <= 0.913891)
 
489
                          {
 
490
                            if (SE_x <= 12.995039)
 
491
                            {
 
492
                              if (SE_c <= 10.112309) { result = 09.0; /* 8.0/4.0 */}
 
493
                              else if (SE_c > 10.112309) { result = 08.8; /* 3.0/1.0 */}
 
494
                            }
 
495
                            if (SE_x > 12.995039)
 
496
                            {
 
497
                              if (SE_c <= 10.117785) { result = 08.7; /* 2.0/1.0 */}
 
498
                              else if (SE_c > 10.117785) { result = 09.0; /* 2.0/1.0 */}
 
499
                            }
 
500
                          }
 
501
                          if (RES_c > 0.913891) { result = 08.9; /* 3.0/1.0 */}
 
502
                        }
 
503
                        if (PCH_c > 0.039882) { result = 08.8; /* 7.0/4.0 */}
 
504
                      }
 
505
                    }
 
506
                  }
 
507
                }
 
508
                if (PCH_c > 0.045111)
 
509
                {
 
510
                  if (SE_c <= 7.915887)
 
511
                  {
 
512
                    if (RES_c <= 0.699389)
 
513
                    {
 
514
                      if (PCH_c <= 1.979715) { result = 11.1; /* 4.0/2.0 */}
 
515
                      else if (PCH_c > 1.979715) { result = 08.9; /* 3.0/2.0 */}
 
516
                    }
 
517
                    if (RES_c > 0.699389) { result = 08.5; /* 2.0 */}
 
518
                  }
 
519
                  if (SE_c > 7.915887)
 
520
                  {
 
521
                    if (SB <= 0.325594)
 
522
                    {
 
523
                      if (PCH_c <= 0.582583)
 
524
                      {
 
525
                        if (PCH_c <= 0.576351) { result = 08.3; /* 3.0/1.0 */}
 
526
                        else if (PCH_c > 0.576351) { result = 07.5; /* 2.0/1.0 */}
 
527
                      }
 
528
                      if (PCH_c > 0.582583)
 
529
                      {
 
530
                        if (PCH_c <= 1.296286) { result = 08.4; /* 2.0/1.0 */}
 
531
                        else if (PCH_c > 1.296286) { result = 09.4; /* 3.0/2.0 */}
 
532
                      }
 
533
                    }
 
534
                    if (SB > 0.325594)
 
535
                    {
 
536
                      if (SE_x <= 12.940799)
 
537
                      {
 
538
                        if (SB <= 0.421092) { result = 09.9; /* 2.0 */}
 
539
                        else if (SB > 0.421092)
 
540
                        {
 
541
                          if (PCH_c <= 0.045325) { result = 09.7; /* 5.0/3.0 */}
 
542
                          else if (PCH_c > 0.045325) { result = 09.6; /* 4.0/2.0 */}
 
543
                        }
 
544
                      }
 
545
                      if (SE_x > 12.940799) { result = 09.5; /* 6.0/3.0 */}
 
546
                    }
 
547
                  }
 
548
                }
 
549
                return result;
 
550
        }
 
551
 
 
552
        /**
 
553
         * tree desicion for the Heteroatom
 
554
         * 
 
555
         * @param resultsH Array which contains the results of each descriptor
 
556
         * @return the result
 
557
         */
 
558
        private double getTreeHeteroAtom(double[] resultsH) {
 
559
                double result = 0.0;
 
560
                double SE = resultsH[0];
 
561
                double SCH = resultsH[1];
 
562
                double EE  = resultsH[2];
 
563
                double PE  = resultsH[3];
 
564
                
 
565
                if (SE <= 8.80606)
 
566
                {
 
567
                  if (EE <= 6.489)
 
568
                  {
 
569
                    if (SCH <= -0.315373)
 
570
                    {
 
571
                      if (EE <= 5.422063)
 
572
                      {
 
573
                        if (EE <= 4.608813)
 
574
                        {
 
575
                          if (SCH <= -0.330239) { result = 06.2; /* 3.0/2.0 */}
 
576
                          else if (SCH > -0.330239)
 
577
                          {
 
578
                            if (SE <= 8.120134) { result = 08.5; /* 2.0/1.0 */}
 
579
                            else if (SE > 8.120134) { result = 09.0; /* 2.0/1.0 */}
 
580
                          }
 
581
                        }
 
582
                        if (EE > 4.608813)
 
583
                        {
 
584
                          if (SCH <= -0.32534)
 
585
                          {
 
586
                            if (EE <= 5.00775) { result = 08.6; /* 7.0/3.0 */}
 
587
                            else if (EE > 5.00775) { result = 08.5; /* 4.0/1.0 */}
 
588
                          }
 
589
                          if (SCH > -0.32534) { result = 08.1; /* 3.0/2.0 */}
 
590
                        }
 
591
                      }
 
592
                      if (EE > 5.422063)
 
593
                      {
 
594
                        if (SCH <= -0.321973)
 
595
                        {
 
596
                          if (SE <= 8.1475) { result = 08.4; /* 3.0/1.0 */}
 
597
                          else if (SE > 8.1475) { result = 08.5; /* 2.0/1.0 */}
 
598
                        }
 
599
                        if (SCH > -0.321973)
 
600
                        {
 
601
                          if (EE <= 6.102) { result = 07.9; /* 2.0/1.0 */}
 
602
                          else if (EE > 6.102) { result = 08.0; /* 3.0/1.0 */}
 
603
                        }
 
604
                      }
 
605
                    }
 
606
                    if (SCH > -0.315373)
 
607
                    {
 
608
                      if (PE <= 4.873452) { result = 09.2; /* 15.0/10.0 */}
 
609
                      else if (PE > 4.873452)
 
610
                      {
 
611
                        if (SCH <= -0.139567)
 
612
                        {
 
613
                          if (EE <= 1.438) { result = 09.8; /* 3.0/1.0 */}
 
614
                          else if (EE > 1.438)
 
615
                          {
 
616
                            if (SE <= 8.60319) { result = 09.1; /* 6.0/2.0 */}
 
617
                            else if (SE > 8.60319) { result = 08.6; /* 2.0/1.0 */}
 
618
                          }
 
619
                        }
 
620
                        if (SCH > -0.139567)
 
621
                        {
 
622
                          if (SE <= 7.833611) { result = 09.3; /* 3.0/2.0 */}
 
623
                          else if (SE > 7.833611) { result = 08.5; /* 3.0/1.0 */}
 
624
                        }
 
625
                      }
 
626
                    }
 
627
                  }
 
628
                  if (EE > 6.489)
 
629
                  {
 
630
                    if (SE <= 8.42798)
 
631
                    {
 
632
                      if (EE <= 8.234438)
 
633
                      {
 
634
                        if (EE <= 7.813)
 
635
                        {
 
636
                          if (SE <= 8.274057)
 
637
                          {
 
638
                            if (EE <= 6.8275)
 
639
                            {
 
640
                              if (SCH <= -0.315888) { result = 07.8; /* 2.0/1.0 */}
 
641
                              else if (SCH > -0.315888) { result = 08.0; /* 3.0 */}
 
642
                            }
 
643
                            if (EE > 6.8275)
 
644
                            {
 
645
                              if (SCH <= -0.315373) { result = 07.6; /* 2.0/1.0 */}
 
646
                              else if (SCH > -0.315373) { result = 08.3; /* 3.0/1.0 */}
 
647
                            }
 
648
                          }
 
649
                          if (SE > 8.274057)
 
650
                          {
 
651
                            if (SCH <= -0.310518)
 
652
                            {
 
653
                              if (SCH <= -0.310845) { result = 07.9; /* 5.0/3.0 */}
 
654
                              else if (SCH > -0.310845) { result = 08.5; /* 2.0/1.0 */}
 
655
                            }
 
656
                            if (SCH > -0.310518)
 
657
                            {
 
658
                              if (SCH <= -0.305857)
 
659
                              {
 
660
                                if (EE <= 7.07075) { result = 07.6; /* 2.0/1.0 */}
 
661
                                else if (EE > 7.07075)
 
662
                                {
 
663
                                  if (SE <= 8.357012) { result = 08.3; /* 6.0/3.0 */}
 
664
                                  else if (SE > 8.357012) { result = 07.8; /* 3.0/2.0 */}
 
665
                                }
 
666
                              }
 
667
                              if (SCH > -0.305857)
 
668
                              {
 
669
                                if (SE <= 8.360428) { result = 07.7; /* 3.0 */}
 
670
                                else if (SE > 8.360428) { result = 07.9; /* 2.0/1.0 */}
 
671
                              }
 
672
                            }
 
673
                          }
 
674
                        }
 
675
                        if (EE > 7.813)
 
676
                        {
 
677
                          if (EE <= 8.079)
 
678
                          {
 
679
                            if (EE <= 7.994375)
 
680
                            {
 
681
                              if (SE <= 8.376288) { result = 08.0; /* 4.0/1.0 */}
 
682
                              else if (SE > 8.376288) { result = 07.5; /* 2.0 */}
 
683
                            }
 
684
                            if (EE > 7.994375) { result = 07.6; /* 3.0 */}
 
685
                          }
 
686
                          if (EE > 8.079)
 
687
                          {
 
688
                            if (SCH <= -0.303186) { result = 07.7; /* 2.0/1.0 */}
 
689
                            else if (SCH > -0.303186) { result = 08.0; /* 4.0 */}
 
690
                          }
 
691
                        }
 
692
                      }
 
693
                      if (EE > 8.234438)
 
694
                      {
 
695
                        if (EE <= 8.70775)
 
696
                        {
 
697
                          if (EE <= 8.326844) { result = 07.9; /* 5.0/1.0 */}
 
698
                          else if (EE > 8.326844)
 
699
                          {
 
700
                            if (SCH <= -0.301277) { result = 08.1; /* 5.0/2.0 */}
 
701
                            else if (SCH > -0.301277) { result = 07.7; /* 2.0/1.0 */}
 
702
                          }
 
703
                        }
 
704
                        if (EE > 8.70775)
 
705
                        {
 
706
                          if (SCH <= -0.299978)
 
707
                          {
 
708
                            if (SE <= 8.391832) { result = 07.0; /* 4.0/2.0 */}
 
709
                            else if (SE > 8.391832) { result = 07.8; /* 2.0 */}
 
710
                          }
 
711
                          if (SCH > -0.299978)
 
712
                          {
 
713
                            if (SE <= 8.289405) { result = 07.7; /* 2.0 */}
 
714
                            else if (SE > 8.289405) { result = 07.9; /* 3.0 */}
 
715
                          }
 
716
                        }
 
717
                      }
 
718
                    }
 
719
                    if (SE > 8.42798)
 
720
                    {
 
721
                      if (EE <= 8.732)
 
722
                      {
 
723
                        if (EE <= 7.673875)
 
724
                        {
 
725
                          if (EE <= 6.99075) { result = 08.6; /* 5.0/2.0 */}
 
726
                          else if (EE > 6.99075)
 
727
                          {
 
728
                            if (SE <= 8.672826) { result = 08.5; /* 4.0/2.0 */}
 
729
                            else if (SE > 8.672826)
 
730
                            {
 
731
                              if (SE <= 8.724731) { result = 08.6; /* 3.0/1.0 */}
 
732
                              else if (SE > 8.724731) { result = 08.4; /* 2.0/1.0 */}
 
733
                            }
 
734
                          }
 
735
                        }
 
736
                        if (EE > 7.673875)
 
737
                        {
 
738
                          if (SCH <= -0.1603)
 
739
                          {
 
740
                            if (SCH <= -0.16701) { result = 08.7; /* 4.0/2.0 */}
 
741
                            else if (SCH > -0.16701) { result = 08.4; /* 9.0/2.0 */}
 
742
                          }
 
743
                          if (SCH > -0.1603)
 
744
                          {
 
745
                            if (EE <= 8.4175)
 
746
                            {
 
747
                              if (SE <= 8.75386) { result = 08.3; /* 2.0 */}
 
748
                              else if (SE > 8.75386) { result = 08.1; /* 2.0/1.0 */}
 
749
                            }
 
750
                            if (EE > 8.4175) { result = 07.9; /* 3.0/2.0 */}
 
751
                          }
 
752
                        }
 
753
                      }
 
754
                      if (EE > 8.732)
 
755
                      {
 
756
                        if (SE <= 8.707362)
 
757
                        {
 
758
                          if (SE <= 8.460227) { result = 07.7; /* 3.0/1.0 */}
 
759
                          else if (SE > 8.460227) { result = 08.3; /* 4.0/2.0 */}
 
760
                        }
 
761
                        if (SE > 8.707362)
 
762
                        {
 
763
                          if (EE <= 9.536)
 
764
                          {
 
765
                            if (EE <= 9.24575) { result = 08.2; /* 2.0/1.0 */}
 
766
                            else if (EE > 9.24575) { result = 08.1; /* 3.0/1.0 */}
 
767
                          }
 
768
                          if (EE > 9.536) { result = 07.8; /* 6.0/3.0 */}
 
769
                        }
 
770
                      }
 
771
                    }
 
772
                  }
 
773
                }
 
774
                if (SE > 8.80606)
 
775
                {
 
776
                  if (PE <= 4.260194)
 
777
                  {
 
778
                    if (EE <= 4.862859)
 
779
                    {
 
780
                      if (EE <= 4.0805)
 
781
                      {
 
782
                        if (SCH <= -0.395706)
 
783
                        {
 
784
                          if (SCH <= -0.398947) { result = 12.6; /* 3.0/1.0 */}
 
785
                          else if (SCH > -0.398947)
 
786
                          {
 
787
                            if (SCH <= -0.395985) { result = 09.1; /* 2.0/1.0 */}
 
788
                            else if (SCH > -0.395985)
 
789
                            {
 
790
                              if (EE <= 3.795813) { result = 09.2; /* 4.0/2.0 */}
 
791
                              else if (EE > 3.795813) { result = 10.4; /* 3.0/1.0 */}
 
792
                            }
 
793
                          }
 
794
                        }
 
795
                        if (SCH > -0.395706)
 
796
                        {
 
797
                          if (EE <= 3.566) { result = 07.5; /* 3.0/2.0 */}
 
798
                          else if (EE > 3.566)
 
799
                          {
 
800
                            if (EE <= 3.795813) { result = 09.3; /* 2.0/1.0 */}
 
801
                            else if (EE > 3.795813) { result = 10.0; /* 5.0/3.0 */}
 
802
                          }
 
803
                        }
 
804
                      }
 
805
                      if (EE > 4.0805)
 
806
                      {
 
807
                        if (SCH <= -0.382949)
 
808
                        {
 
809
                          if (PE <= 3.172064)
 
810
                          {
 
811
                            if (EE <= 4.509125) { result = 09.8; /* 5.0/2.0 */}
 
812
                            else if (EE > 4.509125) { result = 09.7; /* 3.0 */}
 
813
                          }
 
814
                          if (PE > 3.172064)
 
815
                          {
 
816
                            if (SCH <= -0.388693)
 
817
                            {
 
818
                              if (SE <= 9.323245) { result = 09.6; /* 2.0 */}
 
819
                              else if (SE > 9.323245)
 
820
                              {
 
821
                                if (EE <= 4.509125) { result = 09.5; /* 2.0 */}
 
822
                                else if (EE > 4.509125) { result = 09.9; /* 4.0/2.0 */}
 
823
                              }
 
824
                            }
 
825
                            if (SCH > -0.388693) { result = 09.7; /* 2.0 */}
 
826
                          }
 
827
                        }
 
828
                        if (SCH > -0.382949)
 
829
                        {
 
830
                          if (SCH <= -0.371513) { result = 09.6; /* 4.0/2.0 */}
 
831
                          else if (SCH > -0.371513) { result = 09.4; /* 3.0/2.0 */}
 
832
                        }
 
833
                      }
 
834
                    }
 
835
                    if (EE > 4.862859)
 
836
                    {
 
837
                      if (SE <= 9.561631)
 
838
                      {
 
839
                        if (EE <= 6.120359)
 
840
                        {
 
841
                          if (SCH <= -0.389218)
 
842
                          {
 
843
                            if (EE <= 5.2105)
 
844
                            {
 
845
                              if (SE <= 9.325385) { result = 09.2; /* 2.0/1.0 */}
 
846
                              else if (SE > 9.325385) { result = 09.1; /* 5.0/3.0 */}
 
847
                            }
 
848
                            if (EE > 5.2105)
 
849
                            {
 
850
                              if (EE <= 5.422063) { result = 09.0; /* 2.0/1.0 */}
 
851
                              else if (EE > 5.422063)
 
852
                              {
 
853
                                if (EE <= 5.559375) { result = 09.6; /* 3.0/1.0 */}
 
854
                                else if (EE > 5.559375) { result = 09.0; /* 2.0/1.0 */}
 
855
                              }
 
856
                            }
 
857
                          }
 
858
                          if (SCH > -0.389218)
 
859
                          {
 
860
                            if (EE <= 5.64575)
 
861
                            {
 
862
                              if (EE <= 5.295125) { result = 09.4; /* 9.0/5.0 */}
 
863
                              else if (EE > 5.295125) { result = 09.2; /* 6.0/3.0 */}
 
864
                            }
 
865
                            if (EE > 5.64575)
 
866
                            {
 
867
                              if (EE <= 5.87375)
 
868
                              {
 
869
                                if (SCH <= -0.38064) { result = 09.3; /* 5.0/1.0 */}
 
870
                                else if (SCH > -0.38064) { result = 09.4; /* 4.0/2.0 */}
 
871
                              }
 
872
                              if (EE > 5.87375)
 
873
                              {
 
874
                                if (EE <= 6.050813) { result = 09.2; /* 2.0 */}
 
875
                                else if (EE > 6.050813) { result = 09.3; /* 3.0/1.0 */}
 
876
                              }
 
877
                            }
 
878
                          }
 
879
                        }
 
880
                        if (EE > 6.120359)
 
881
                        {
 
882
                          if (SCH <= -0.387072) { result = 09.4; /* 2.0 */}
 
883
                          else if (SCH > -0.387072)
 
884
                          {
 
885
                            if (SE <= 9.208068) { result = 09.3; /* 2.0/1.0 */}
 
886
                            else if (SE > 9.208068)
 
887
                            {
 
888
                              if (EE <= 8.617)
 
889
                              {
 
890
                                if (SCH <= -0.374181)
 
891
                                {
 
892
                                  if (EE <= 6.764188) { result = 09.2; /* 11.0/4.0 */}
 
893
                                  else if (EE > 6.764188) { result = 09.1; /* 7.0/2.0 */}
 
894
                                }
 
895
                                if (SCH > -0.374181) { result = 09.2; /* 4.0 */}
 
896
                              }
 
897
                              if (EE > 8.617) { result = 09.1; /* 5.0 */}
 
898
                            }
 
899
                          }
 
900
                        }
 
901
                      }
 
902
                      if (SE > 9.561631)
 
903
                      {
 
904
                        if (EE <= 7.141875)
 
905
                        {
 
906
                          if (SCH <= -0.143549)
 
907
                          {
 
908
                            if (EE <= 5.479375) { result = 09.8; /* 3.0/2.0 */}
 
909
                            else if (EE > 5.479375)
 
910
                            {
 
911
                              if (EE <= 5.709125) { result = 09.0; /* 2.0 */}
 
912
                              else if (EE > 5.709125) { result = 09.3; /* 2.0/1.0 */}
 
913
                            }
 
914
                          }
 
915
                          if (SCH > -0.143549)
 
916
                          {
 
917
                            if (SCH <= -0.139872)
 
918
                            {
 
919
                              if (EE <= 6.331813) { result = 10.1; /* 4.0/1.0 */}
 
920
                              else if (EE > 6.331813) { result = 10.0; /* 7.0/3.0 */}
 
921
                            }
 
922
                            if (SCH > -0.139872) { result = 09.9; /* 4.0/1.0 */}
 
923
                          }
 
924
                        }
 
925
                        if (EE > 7.141875)
 
926
                        {
 
927
                          if (SE <= 10.155788)
 
928
                          {
 
929
                            if (SE <= 10.12694) { result = 08.8; /* 2.0/1.0 */}
 
930
                            else if (SE > 10.12694) { result = 09.7; /* 3.0/1.0 */}
 
931
                          }
 
932
                          if (SE > 10.155788) { result = 09.2; /* 4.0/2.0 */}
 
933
                        }
 
934
                      }
 
935
                    }
 
936
                  }
 
937
                  if (PE > 4.260194)
 
938
                  {
 
939
                    if (EE <= 6.19275)
 
940
                    {
 
941
                      if (EE <= 5.2105)
 
942
                      {
 
943
                        if (SE <= 10.475336) { result = 10.8; /* 3.0/1.0 */}
 
944
                        else if (SE > 10.475336) { result = 10.2; /* 4.0/2.0 */}
 
945
                      }
 
946
                      if (EE > 5.2105)
 
947
                      {
 
948
                        if (EE <= 5.39475)
 
949
                        {
 
950
                          if (SE <= 10.47544) { result = 10.1; /* 2.0 */}
 
951
                          else if (SE > 10.47544) { result = 10.7; /* 2.0 */}
 
952
                        }
 
953
                        if (EE > 5.39475)
 
954
                        {
 
955
                          if (SE <= 10.510052) { result = 09.7; /* 2.0/1.0 */}
 
956
                          else if (SE > 10.510052) { result = 10.1; /* 2.0/1.0 */}
 
957
                        }
 
958
                      }
 
959
                    }
 
960
                    if (EE > 6.19275)
 
961
                    {
 
962
                      if (SCH <= -0.080603) { result = 09.0; /* 6.0/1.0 */}
 
963
                      else if (SCH > -0.080603)
 
964
                      {
 
965
                        if (SE <= 9.271976) { result = 08.9; /* 6.0/1.0 */}
 
966
                        else if (SE > 9.271976) { result = 08.7; /* 3.0 */}
 
967
                      }
 
968
                    }
 
969
                  }
 
970
                }
 
971
                return result;
 
972
        }
 
973
        /**
 
974
         * Get the reactions obtained with ionization.
 
975
         * The energy is set as property
 
976
         * 
 
977
         * @return The IReactionSet value
 
978
         */
 
979
        public IReactionSet getReactionSet() throws CDKException{
 
980
                return reactionSet;
 
981
        }
 
982
        /**
 
983
         * Calculate the necessary descriptors for Heteratom atoms
 
984
         * @param atomContainer The IAtomContainer
 
985
         * @return     Array with the values of the descriptors.
 
986
         * @throws CDKException 
 
987
         */
 
988
        private double[] calculateHeteroAtomConjugatedDescriptor(IAtom atom, IAtomContainer atomContainer, IAtomContainer conjugatedSys) throws CDKException {
 
989
                double[] results = new double[4];
 
990
                results[0] = -10.0;
 
991
                results[1] = 0.0;
 
992
                results[2] = 0.0;
 
993
                results[3] = 0.0;
 
994
                
 
995
                /*calculation of the atomic descriptors*/
 
996
                Iterator atomIt = conjugatedSys.atoms();
 
997
                while(atomIt.hasNext()){
 
998
                        IAtom atomsss = (IAtom) atomIt.next();
 
999
                        
 
1000
                        if(atomContainer.getConnectedLonePairsCount(atomsss) == 0){
 
1001
                                PartialPiChargeDescriptor descriptor1 = new PartialPiChargeDescriptor();
 
1002
                                double result1;
 
1003
                                        result1 = ((DoubleResult)descriptor1.calculate(atomsss,atomContainer).getValue()).doubleValue();
 
1004
                                
 
1005
                                if(result1 != 0.0)
 
1006
                                if(result1 > results[0])
 
1007
                                        results[0] = result1;
 
1008
                        }else{
 
1009
                                
 
1010
                                PartialPiChargeDescriptor descriptor1 = new PartialPiChargeDescriptor();
 
1011
                                double result1 = ((DoubleResult)descriptor1.calculate(atomsss,atomContainer).getValue()).doubleValue();
 
1012
                                results[1] = result1;
 
1013
                        }
 
1014
                        
 
1015
                        SigmaElectronegativityDescriptor descriptor2 = new SigmaElectronegativityDescriptor();
 
1016
                        double result2 = ((DoubleResult)descriptor2.calculate(atomsss,atomContainer).getValue()).doubleValue();
 
1017
                        results[3] += result2;
 
1018
                        
 
1019
                }
 
1020
                /*calculation of the bond descriptors*/
 
1021
                Iterator bondIt = conjugatedSys.bonds();
 
1022
                while(bondIt.hasNext()){
 
1023
                        IBond bondsss = (IBond) bondIt.next();
 
1024
                        
 
1025
                        ResonancePositiveChargeDescriptor descriptor5 = new ResonancePositiveChargeDescriptor();
 
1026
                        DoubleArrayResult dar;
 
1027
                        
 
1028
                        dar = ((DoubleArrayResult)descriptor5.calculate(bondsss,atomContainer).getValue());
 
1029
                        double result1 = dar.get(0);
 
1030
                        double resutt2 = dar.get(1);
 
1031
                        double result12 = (result1+resutt2);
 
1032
                        
 
1033
                        double resultT = 0;
 
1034
                        if(result12 != 0)
 
1035
                                resultT = result12/2;
 
1036
                        
 
1037
                        results[2] += resultT;
 
1038
                        
 
1039
                }
 
1040
                if(results[2] != 0)
 
1041
                        results[2] = results[1]/conjugatedSys.getAtomCount();
 
1042
                
 
1043
                if(results[3] != 0)
 
1044
                        results[3] = results[2]/conjugatedSys.getAtomCount();
 
1045
                
 
1046
                
 
1047
                return results;
 
1048
        
 
1049
        }
 
1050
        /**
 
1051
         * Calculate the necessary descriptors for Heteratom atoms
 
1052
         * @param atomContainer The IAtomContainer
 
1053
         * @return     Array with the values of the descriptors.
 
1054
         * @throws CDKException 
 
1055
         */
 
1056
        private double[] calculateHeteroAtomDescriptor(IAtom atom, IAtomContainer atomContainer) throws CDKException {
 
1057
                double[] results = new double[4];
 
1058
                SigmaElectronegativityDescriptor descriptor1 = new SigmaElectronegativityDescriptor();
 
1059
                PartialSigmaChargeDescriptor descriptor2 = new PartialSigmaChargeDescriptor();
 
1060
                EffectiveAtomPolarizabilityDescriptor descriptor3 = new EffectiveAtomPolarizabilityDescriptor();
 
1061
                PiElectronegativityDescriptor descriptor4 = new PiElectronegativityDescriptor();
 
1062
 
 
1063
                results[0]= ((DoubleResult)descriptor1.calculate(atom,atomContainer).getValue()).doubleValue();
 
1064
                results[1]= ((DoubleResult)descriptor2.calculate(atom,atomContainer).getValue()).doubleValue();
 
1065
                results[2]= ((DoubleResult)descriptor3.calculate(atom,atomContainer).getValue()).doubleValue();
 
1066
                results[3]= ((DoubleResult)descriptor4.calculate(atom,atomContainer).getValue()).doubleValue();
 
1067
        
 
1068
                return results;
 
1069
        }
 
1070
        /**
 
1071
         * Calculate the necessary descriptors for Carbonyl group
 
1072
         * @param atomContainer The IAtomContainer
 
1073
         * @return     Array with the values of the descriptors.
 
1074
         */
 
1075
        private double[] calculateCarbonylDescriptor(IAtom atom, IAtomContainer atomContainer) {
 
1076
                
 
1077
                double[] results = new double[6];
 
1078
                IAtom positionX = atom;
 
1079
                IAtom positionC = null; 
 
1080
                List listAtoms = atomContainer.getConnectedAtomsList(atom);
 
1081
                for(Iterator it = listAtoms.iterator(); it.hasNext();){
 
1082
                        IAtom atom2 = (IAtom)it.next();
 
1083
                        if(((IBond)atomContainer.getBond(atom, atom2)).getOrder() > 1)
 
1084
                                positionC = atom2;
 
1085
                }
 
1086
 
 
1087
                IBond bond = atomContainer.getBond(positionX, positionC);
 
1088
                try {
 
1089
                        AtomContainerSet conjugatedPi = ConjugatedPiSystemsDetector.detect(atomContainer);
 
1090
                        
 
1091
                        if(conjugatedPi.getAtomContainerCount() == 1){
 
1092
                                IAtomContainer conjugatedSy = conjugatedPi.getAtomContainer(0);
 
1093
                                Iterator atomIt = conjugatedSy.atoms();
 
1094
                                while(atomIt.hasNext()){
 
1095
                                        IAtom atomsss = (IAtom) atomIt.next();
 
1096
                                        if(atomsss.getSymbol().equals("C")){
 
1097
                                                PartialPiChargeDescriptor descriptor1 = new PartialPiChargeDescriptor();
 
1098
                                                double result1 = ((DoubleResult)descriptor1.calculate(atomsss,atomContainer).getValue()).doubleValue();
 
1099
 
 
1100
                                                if(result1 > results[1])
 
1101
                                                        results[1] = result1;
 
1102
                                                
 
1103
                                                SigmaElectronegativityDescriptor descriptor2 = new SigmaElectronegativityDescriptor();
 
1104
                                                double result2 = ((DoubleResult)descriptor2.calculate(atomsss,atomContainer).getValue()).doubleValue();
 
1105
                                                results[0] += result2;
 
1106
                                        }
 
1107
                                }
 
1108
                                if(results[0] != 0)
 
1109
                                        results[0] = results[0]/conjugatedSy.getAtomCount();
 
1110
                                
 
1111
                                if(results[1] != 0)
 
1112
                                        results[1] = results[1]/conjugatedSy.getAtomCount();
 
1113
                        }else{
 
1114
                                /* 1 */
 
1115
                                try{
 
1116
                                SigmaElectronegativityDescriptor descriptor1 = new SigmaElectronegativityDescriptor();
 
1117
                                results[0] = ((DoubleResult)descriptor1.calculate(positionC,(IAtomContainer) atomContainer).getValue()).doubleValue();
 
1118
 
 
1119
                                }catch(Exception e){
 
1120
                                        results[0] = 0.0;
 
1121
                                }
 
1122
//                              System.out.println("symbolC: "+atomContainer.getAtom(positionC).getSymbol());
 
1123
//                              System.out.println("symbolX: "+atomContainer.getAtom(positionX).getSymbol());
 
1124
                                
 
1125
                                /* 2 */
 
1126
                                try{
 
1127
                                PartialPiChargeDescriptor descriptor2 = new PartialPiChargeDescriptor();
 
1128
                                results[1] = ((DoubleResult)descriptor2.calculate(positionC,(IAtomContainer) atomContainer).getValue()).doubleValue();
 
1129
                                }catch(Exception e){
 
1130
                                        results[1] = 0.0;
 
1131
                                }
 
1132
                        }
 
1133
                        /* 3 */
 
1134
                        try{
 
1135
                        BondPartialSigmaChargeDescriptor descriptor3 = new BondPartialSigmaChargeDescriptor();
 
1136
                        results[2] = ((DoubleResult)descriptor3.calculate(bond,(IAtomContainer) atomContainer).getValue()).doubleValue();
 
1137
                        }catch(Exception e){
 
1138
                                results[2] = 0.0;
 
1139
                        }
 
1140
                        /* 4 */
 
1141
                        try{
 
1142
                        SigmaElectronegativityDescriptor descriptor4 = new SigmaElectronegativityDescriptor();
 
1143
                        results[3] = ((DoubleResult)descriptor4.calculate(positionX,(IAtomContainer) atomContainer).getValue()).doubleValue();
 
1144
                        }catch(Exception e){
 
1145
                                results[3] = 0.0;
 
1146
                        }
 
1147
                        /* 5 */
 
1148
                        try{
 
1149
                        PartialPiChargeDescriptor descriptor5 = new PartialPiChargeDescriptor();
 
1150
                        results[4] = ((DoubleResult)descriptor5.calculate(positionX,(IAtomContainer) atomContainer).getValue()).doubleValue();
 
1151
                        }catch(Exception e){
 
1152
                                results[4] = 0.0;
 
1153
                        }
 
1154
                        /* 6 */
 
1155
                        try{
 
1156
                        ResonancePositiveChargeDescriptor descriptor6 = new ResonancePositiveChargeDescriptor();
 
1157
                        DoubleArrayResult dar = ((DoubleArrayResult)descriptor6.calculate(bond,atomContainer).getValue());
 
1158
                        double datT =0.0;
 
1159
                        if((new Double(dar.get(0))).toString().equals("Infinity")||
 
1160
                                        (new Double(dar.get(1))).toString().equals("Infinity")){}
 
1161
                        else if(dar.get(0) == 0 && dar.get(1) == 0){}
 
1162
                        else
 
1163
                                datT = (dar.get(0)+dar.get(1))/2;
 
1164
                        results[5] = datT;
 
1165
                        }catch(Exception e){
 
1166
                                results[5] = 0.0;
 
1167
                        }
 
1168
 
 
1169
                } catch (CDKException e) {
 
1170
                        e.printStackTrace();
 
1171
                }
 
1172
                return results;
 
1173
        }
 
1174
         /**
 
1175
     * Gets the parameterNames attribute of the IPAtomicDescriptor object.
 
1176
     *
 
1177
     * @return    The parameterNames value
 
1178
     */
 
1179
    public String[] getParameterNames() {
 
1180
        return new String[0];
 
1181
    }
 
1182
 
 
1183
 
 
1184
    /**
 
1185
     * Gets the parameterType attribute of the IPAtomicDescriptor object.
 
1186
     *
 
1187
     * @param  name  Description of the Parameter
 
1188
     * @return       An Object of class equal to that of the parameter being requested
 
1189
     */
 
1190
    public Object getParameterType(String name) {
 
1191
        return null;
 
1192
    }
 
1193
}
 
1194