3
* $Date: 2006-05-04 19:29:58 +0000 (Thu, 04 May 2006) $
6
* Copyright (C) 2006-2007 Todd Martin (Environmental Protection Agency)
8
* Contact: cdk-devel@lists.sourceforge.net
10
* This program is free software; you can redistribute it and/or
11
* modify it under the terms of the GNU Lesser General Public License
12
* as published by the Free Software Foundation; either version 2.1
13
* of the License, or (at your option) any later version.
15
* This program is distributed in the hope that it will be useful,
16
* but WITHOUT ANY WARRANTY; without even the implied warranty of
17
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
* GNU Lesser General Public License for more details.
20
* You should have received a copy of the GNU Lesser General Public License
21
* along with this program; if not, write to the Free Software
22
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
24
package org.openscience.cdk.tools;
26
import java.io.BufferedReader;
27
import java.io.IOException;
28
import java.io.InputStream;
29
import java.io.InputStreamReader;
30
import java.util.Hashtable;
31
import java.util.LinkedList;
33
public class AtomicProperties {
35
private LoggingTool logger;
37
private static AtomicProperties ap=null;
39
private Hashtable htMass=new Hashtable();
40
private Hashtable htVdWVolume=new Hashtable();
41
private Hashtable htElectronegativity=new Hashtable();
42
private Hashtable htPolarizability=new Hashtable();
45
private AtomicProperties() throws IOException {
47
logger = new LoggingTool(this);
49
String configFile = "src/org/openscience/cdk/config/data/whim_weights.txt";
50
InputStream ins = this.getClass().getClassLoader().getResourceAsStream(configFile);
52
BufferedReader br = new BufferedReader(new InputStreamReader(ins));
54
String Header= br.readLine(); // header
59
if (!(Line instanceof String)) {
63
LinkedList l = parseStringIntoList(Line,"\t");
65
String symbol=(String)l.get(0);
66
htMass.put(symbol,l.get(1));
67
htVdWVolume.put(symbol,l.get(2));
68
htElectronegativity.put(symbol,l.get(3));
69
htPolarizability.put(symbol,l.get(4));
76
public static LinkedList parseStringIntoList(String Line, String Delimiter) {
77
// parses a delimited string into a list
79
LinkedList myList = new LinkedList();
84
tabpos = Line.indexOf(Delimiter);
87
myList.add(Line.substring(0, tabpos));
88
Line = Line.substring(tabpos + 1, Line.length());
89
} else if (tabpos == 0) {
91
Line = Line.substring(tabpos + 1, Line.length());
93
myList.add(Line.trim());
101
public double getVdWVolume(String symbol) {
102
double VdWVolume=-99;
104
String strVdWVolume=(String)htVdWVolume.get(symbol);
107
VdWVolume=Double.parseDouble(strVdWVolume);
108
} catch (Exception e) {
109
logger.error("Error while parsing the Vanderwaals volume: " + e.getMessage());
118
public double getNormalizedVdWVolume(String symbol) {
119
double VdWVolume=-99;
121
VdWVolume=this.getVdWVolume(symbol)/this.getVdWVolume("C");
127
public double getElectronegativity(String symbol) {
128
double Electronegativity=-99;
130
String strElectronegativity=(String)htElectronegativity.get(symbol);
133
Electronegativity=Double.parseDouble(strElectronegativity);
134
} catch (Exception e) {
135
logger.error("Error while parsing the electronegativity: " + e.getMessage());
140
return Electronegativity;
144
public double getNormalizedElectronegativity(String symbol) {
145
double Electronegativity=-99;
147
Electronegativity=this.getElectronegativity(symbol)/this.getElectronegativity("C");
149
return Electronegativity;
152
public double getPolarizability(String symbol) {
153
double Polarizability=-99;
155
String strPolarizability=(String)htPolarizability.get(symbol);
158
Polarizability=Double.parseDouble(strPolarizability);
159
} catch (Exception e) {
160
logger.error("Error while parsing the polarizability: " + e.getMessage());
165
return Polarizability;
169
public double getNormalizedPolarizability(String symbol) {
170
double Polarizability=-99;
172
Polarizability=this.getPolarizability(symbol)/this.getPolarizability("C");
174
return Polarizability;
177
public double getMass(String symbol) {
180
String strMass=(String)htMass.get(symbol);
183
mass=Double.parseDouble(strMass);
185
} catch (Exception e) {
186
logger.error("Error while parsing the mass: " + e.getMessage());
195
public double getNormalizedMass(String symbol) {
198
mass=this.getMass(symbol)/this.getMass("C");
206
public static AtomicProperties getInstance() throws IOException
209
ap = new AtomicProperties();