Source code: joelib/desc/types/AromaticBonds.java
1 ///////////////////////////////////////////////////////////////////////////////
2 // Filename: $RCSfile: AromaticBonds.java,v $
3 // Purpose: Number of aromatic bonds.
4 // Language: Java
5 // Compiler: JDK 1.4
6 // Authors: Joerg K. Wegner
7 // Version: $Revision: 1.6 $
8 // $Date: 2003/08/19 13:11:25 $
9 // $Author: wegner $
10 //
11 // Copyright (c) Dept. Computer Architecture, University of Tuebingen, Germany
12 //
13 // This program is free software; you can redistribute it and/or modify
14 // it under the terms of the GNU General Public License as published by
15 // the Free Software Foundation version 2 of the License.
16 //
17 // This program is distributed in the hope that it will be useful,
18 // but WITHOUT ANY WARRANTY; without even the implied warranty of
19 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
20 // GNU General Public License for more details.
21 ///////////////////////////////////////////////////////////////////////////////
22 package joelib.desc.types;
23
24
25 /*
26 * ==========================================================================*
27 * IMPORTS
28 * ==========================================================================
29 */
30 import joelib.desc.DescriptorHelper;
31 import joelib.desc.DescriptorInfo;
32 import joelib.desc.SimpleIntDesc;
33
34 import joelib.molecule.JOEBond;
35 import joelib.molecule.JOEMol;
36
37 import joelib.util.iterator.BondIterator;
38
39 import org.apache.log4j.Category;
40
41
42 /*
43 * ==========================================================================*
44 * CLASS DECLARATION
45 * ==========================================================================
46 */
47
48 /**
49 * Number of aromatic bonds.
50 *
51 * @author wegnerj
52 * @license GPL
53 * @cvsversion $Revision: 1.6 $, $Date: 2003/08/19 13:11:25 $
54 */
55 public class AromaticBonds extends SimpleIntDesc
56 {
57 //~ Static fields/initializers /////////////////////////////////////////////
58
59 /*
60 * -------------------------------------------------------------------------*
61 * public static member variables
62 * -------------------------------------------------------------------------
63 */
64
65 /**
66 * Obtain a suitable logger.
67 */
68 private static Category logger = Category.getInstance(
69 "joelib.desc.types.AromaticBonds");
70 public static final String DESC_KEY = "Number_of_aromatic_bonds";
71
72 //~ Constructors ///////////////////////////////////////////////////////////
73
74 /*-------------------------------------------------------------------------*
75 * constructor
76 *-------------------------------------------------------------------------*/
77
78 /**
79 * Constructor for the KierShape1 object
80 */
81 public AromaticBonds()
82 {
83 if (logger.isDebugEnabled())
84 {
85 logger.debug("Initialize " + this.getClass().getName());
86 }
87
88 descInfo = DescriptorHelper.generateDescInfo(DESC_KEY, this.getClass(),
89 DescriptorInfo.TYPE_NO_COORDINATES, null,
90 "joelib.desc.result.IntResult");
91 }
92
93 //~ Methods ////////////////////////////////////////////////////////////////
94
95 /*-------------------------------------------------------------------------*
96 * public methods
97 *-------------------------------------------------------------------------*/
98
99 /**
100 * Gets the doubleValue attribute of the KierShape1 object
101 *
102 * @param mol Description of the Parameter
103 * @return The doubleValue value
104 */
105 public int getIntValue(JOEMol mol)
106 {
107 int aromaticBonds = 0;
108
109 BondIterator bit = mol.bondIterator();
110 JOEBond bond;
111
112 while (bit.hasNext())
113 {
114 //Molecule graph must be H-Atom depleted
115 bond = bit.nextBond();
116
117 if (!bond.getBeginAtom().isHydrogen() &&
118 !bond.getEndAtom().isHydrogen())
119 {
120 if (bond.isAromatic())
121 {
122 aromaticBonds++;
123 }
124 }
125 }
126
127 return aromaticBonds;
128 }
129 }
130 ///////////////////////////////////////////////////////////////////////////////
131 // END OF FILE.
132 ///////////////////////////////////////////////////////////////////////////////