Source code: joelib/desc/types/RotatableBonds.java
1 ///////////////////////////////////////////////////////////////////////////////
2 // Filename: $RCSfile: RotatableBonds.java,v $
3 // Purpose: Number of rotatable bonds.
4 // Language: Java
5 // Compiler: JDK 1.4
6 // Authors: Joerg K. Wegner
7 // Version: $Revision: 1.8 $
8 // $Date: 2003/08/22 15:56:16 $
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 rotatable bonds.
50 *
51 * @author wegnerj
52 * @license GPL
53 * @cvsversion $Revision: 1.8 $, $Date: 2003/08/22 15:56:16 $
54 */
55 public class RotatableBonds extends SimpleIntDesc
56 {
57 //~ Static fields/initializers /////////////////////////////////////////////
58
59 /*-------------------------------------------------------------------------*
60 * public static member variables
61 *-------------------------------------------------------------------------*/
62
63 /**
64 * Obtain a suitable logger.
65 */
66 private static Category logger = Category.getInstance(
67 "joelib.desc.types.RotatableBonds");
68 public static final String DESC_KEY = "Number_of_rotatable_bonds";
69
70 //~ Constructors ///////////////////////////////////////////////////////////
71
72 /*-------------------------------------------------------------------------*
73 * constructor
74 *-------------------------------------------------------------------------*/
75
76 /**
77 * Constructor for the KierShape1 object
78 */
79 public RotatableBonds()
80 {
81 if (logger.isDebugEnabled())
82 {
83 logger.debug("Initialize " + this.getClass().getName());
84 }
85
86 descInfo = DescriptorHelper.generateDescInfo(DESC_KEY, this.getClass(),
87 DescriptorInfo.TYPE_NO_COORDINATES, null,
88 "joelib.desc.result.IntResult");
89 }
90
91 //~ Methods ////////////////////////////////////////////////////////////////
92
93 /*-------------------------------------------------------------------------*
94 * public methods
95 *-------------------------------------------------------------------------*/
96
97 /**
98 * Gets the doubleValue attribute of the KierShape1 object
99 *
100 * @param mol Description of the Parameter
101 * @return The doubleValue value
102 */
103 public int getIntValue(JOEMol mol)
104 {
105 int heavyBonds = 0;
106 int rotatableBonds = 0;
107
108 BondIterator bit = mol.bondIterator();
109 JOEBond bond;
110
111 while (bit.hasNext())
112 {
113 //Molecule graph must be H-Atom depleted
114 bond = bit.nextBond();
115
116 if (!bond.getBeginAtom().isHydrogen() &&
117 !bond.getEndAtom().isHydrogen())
118 {
119 heavyBonds++;
120
121 if (bond.isRotor())
122 {
123 rotatableBonds++;
124 }
125 }
126 }
127
128 if (heavyBonds == 0)
129 {
130 return 0;
131 }
132 else
133 {
134 return rotatableBonds;
135 }
136 }
137 }
138 ///////////////////////////////////////////////////////////////////////////////
139 // END OF FILE.
140 ///////////////////////////////////////////////////////////////////////////////