Debian Codegraph @

jna-inchi-api/src/main/java/io/github/dan2097/jnainchi/InchiAtom.java

raw
1 /**
2 * JNA-InChI - Library for calling InChI from Java
3 * Copyright © 2018 Daniel Lowe
4 *
5 * This library is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU Lesser General Public
7 * License as published by the Free Software Foundation; either
8 * version 2.1 of the License, or (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Lesser General Public License for more details.
14 *
15 * You should have received a copy of the GNU Lesser General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18 package io.github.dan2097.jnainchi;
19
20 public class InchiAtom {
21
22 private String elName;
23 private double x = 0;
24 private double y = 0;
25 private double z = 0;
26
27 //array positions for hydrogen (i.e. isotope not specified), protium, deuterium, tritium
28 private int[] implicitHydrogen = new int[4];
29 private int isotopicMass = 0;
30 private InchiRadical radical = InchiRadical.NONE;
31 private int charge = 0;
32
33 public InchiAtom(String elName) {
34 this.elName = elName;
35 }
36
37 public InchiAtom(String elName, double x, double y, double z) {
38 this.elName = elName;
39 this.x = x;
40 this.y = y;
41 this.z = z;
42 }
43
44 public String getElName() {
45 return elName;
46 }
47
48 public void setElName(String elName) {
49 this.elName = elName;
50 }
51
52 public double getX() {
53 return x;
54 }
55
56 public void setX(double x) {
57 this.x = x;
58 }
59
60 public double getY() {
61 return y;
62 }
63
64 public void setY(double y) {
65 this.y = y;
66 }
67
68 public double getZ() {
69 return z;
70 }
71
72 public void setZ(double z) {
73 this.z = z;
74 }
75
76 public int getImplicitHydrogen() {
77 return implicitHydrogen[0];
78 }
79
80 /**
81 * Used for specifying implicit hydrogen of natural isotopic abundance.
82 * If the hydrogen is known to be protium/deuterium/tritium this can be either specified
83 * using {@link #setImplicitProtium(int)}, {@link #setImplicitDeuterium(int)}, {@link #setImplicitTritium(int)}
84 * or using explicit atoms
85 *
86 * -1 has the special meaning of deduce hydrogen count from valency
87 * @param implicitHydrogen
88 */
89 public void setImplicitHydrogen(int implicitHydrogen) {
90 if (implicitHydrogen > Byte.MAX_VALUE || implicitHydrogen < -1) {
91 throw new IllegalArgumentException("Unacceptable implicitHydrogen:" + implicitHydrogen);
92 }
93 this.implicitHydrogen[0] = implicitHydrogen;
94 }
95
96 public void setImplicitProtium(int implicitProtium) {
97 if (implicitProtium > Byte.MAX_VALUE || implicitProtium < 0) {
98 throw new IllegalArgumentException("Unacceptable implicitProtium:" + implicitProtium);
99 }
100 this.implicitHydrogen[1] = implicitProtium;
101 }
102
103 public int getImplicitProtium() {
104 return implicitHydrogen[1];
105 }
106
107 public void setImplicitDeuterium(int implicitDeuterium) {
108 if (implicitDeuterium > Byte.MAX_VALUE || implicitDeuterium < 0) {
109 throw new IllegalArgumentException("Unacceptable implicitDeuterium:" + implicitDeuterium);
110 }
111 this.implicitHydrogen[2] = implicitDeuterium;
112 }
113
114 public int getImplicitDeuterium() {
115 return implicitHydrogen[2];
116 }
117
118 public void setImplicitTritium(int implicitTritium) {
119 if (implicitTritium > Byte.MAX_VALUE || implicitTritium < 0) {
120 throw new IllegalArgumentException("Unacceptable implicitTritium:" + implicitTritium);
121 }
122 this.implicitHydrogen[3] = implicitTritium;
123 }
124
125 public int getImplicitTritium() {
126 return implicitHydrogen[3];
127 }
128
129 public int getIsotopicMass() {
130 return isotopicMass;
131 }
132
133 public void setIsotopicMass(int isotopicMass) {
134 if (isotopicMass > Short.MAX_VALUE || isotopicMass < 0) {
135 throw new IllegalArgumentException("Unacceptable isotopicMass:" + isotopicMass);
136 }
137 this.isotopicMass = isotopicMass;
138 }
139
140 public InchiRadical getRadical() {
141 return radical;
142 }
143
144 public void setRadical(InchiRadical radical) {
145 this.radical = radical;
146 }
147
148 public int getCharge() {
149 return charge;
150 }
151
152 public void setCharge(int charge) {
153 if (charge > Byte.MAX_VALUE || charge < Byte.MIN_VALUE) {
154 throw new IllegalArgumentException("Unacceptable charge:" + charge);
155 }
156 this.charge = charge;
157 }
158 }