Class: Rubabel::Atom
Instance Attribute Summary collapse
-
#ob ⇒ Object
the OpenBabel::OBAtom object.
Class Method Summary collapse
-
.[](el_sym = :h, id = nil) ⇒ Object
takes an element symbol and creates that atom.
Instance Method Summary collapse
-
#add_atom!(other) ⇒ Object
creates a bond and adds it to both atoms.
- #amide_nitrogen? ⇒ Boolean
- #anti_clockwise? ⇒ Boolean
- #aromatic? ⇒ Boolean
- #aromatic_noxide? ⇒ Boolean
- #atomic_mass ⇒ Object
- #atomic_num ⇒ Object
-
#atoms ⇒ Object
returns the neighboring atoms.
- #axial? ⇒ Boolean
-
#bonds ⇒ Object
returns the bonds.
- #carbon? ⇒ Boolean
- #carboxyl_carbon? ⇒ Boolean
- #carboxyl_oxygen? ⇒ Boolean
- #chiral? ⇒ Boolean
- #chiral_volume? ⇒ Boolean
- #chirality_specified? ⇒ Boolean
- #clockwise? ⇒ Boolean
- #connected? ⇒ Boolean
-
#coords ⇒ Object
# does this carbon hold a primary alcohol def primary_alcohol_carbon? end.
-
#each_atom(&block) ⇒ Object
iterates through each neighboring atom.
- #each_bond(&block) ⇒ Object (also: #each)
-
#el ⇒ Object
abbreviated name, all lowercase as a Symbol.
-
#element ⇒ Object
abbreviated name, properly capitalized and as a String.
- #exact_mass ⇒ Object
- #formal_charge ⇒ Object (also: #charge)
- #formal_charge=(val) ⇒ Object (also: #charge=)
-
#get_bond(atom) ⇒ Object
retrieves the bond.
- #hbond_acceptor? ⇒ Boolean
- #hbond_donor? ⇒ Boolean
- #hbond_donor_h? ⇒ Boolean
- #heavy_valence ⇒ Object
- #hetero_valence ⇒ Object
- #heteroatom? ⇒ Boolean
- #hyb ⇒ Object
- #hydrogen? ⇒ Boolean
- #id ⇒ Object
- #id=(val) ⇒ Object
-
#idx ⇒ Object
index of the atom (begins with 1).
- #implicit_valence ⇒ Object
- #in_ring? ⇒ Boolean
- #in_ring_size? ⇒ Boolean
-
#initialize(obatom) ⇒ Atom
constructor
A new instance of Atom.
- #inspect ⇒ Object
- #isotope ⇒ Object
-
#mol ⇒ Object
returns the molecule that is parent of this atom.
- #negative_stereo? ⇒ Boolean
- #nitro_oxygen? ⇒ Boolean
- #nitrogen? ⇒ Boolean
- #non_polar_hydrogen? ⇒ Boolean
- #not_c_or_h? ⇒ Boolean
- #one_four? ⇒ Boolean
- #one_three? ⇒ Boolean
- #oxygen? ⇒ Boolean
- #partial_charge ⇒ Object
- #phosphate_oxygen? ⇒ Boolean
- #phosphorus? ⇒ Boolean
- #polar_hydrogen? ⇒ Boolean
- #positive_stereo? ⇒ Boolean
- #spin ⇒ Object
- #sulfate_oxygen? ⇒ Boolean
- #sulfur? ⇒ Boolean
- #type ⇒ Object
- #valence ⇒ Object
- #vector ⇒ Object
Methods included from Enumerable
Constructor Details
#initialize(obatom) ⇒ Atom
Returns a new instance of Atom.
35 36 37 |
# File 'lib/rubabel/atom.rb', line 35 def initialize(obatom) @ob = obatom end |
Instance Attribute Details
#ob ⇒ Object
the OpenBabel::OBAtom object
33 34 35 |
# File 'lib/rubabel/atom.rb', line 33 def ob @ob end |
Class Method Details
.[](el_sym = :h, id = nil) ⇒ Object
takes an element symbol and creates that atom. If el_sym is set to nil or 0, then an atom of atomic number 0 is used
19 20 21 22 23 24 |
# File 'lib/rubabel/atom.rb', line 19 def [](el_sym=:h, id=nil) ob_atom = OpenBabel::OBAtom.new ob_atom.set_id(id) if id ob_atom.set_atomic_num(Rubabel::EL_TO_NUM[el_sym] || 0) self.new(ob_atom) end |
Instance Method Details
#add_atom!(other) ⇒ Object
creates a bond and adds it to both atoms
63 64 65 66 67 68 69 70 |
# File 'lib/rubabel/atom.rb', line 63 def add_atom!(other) obbond = OpenBabel::OBBond.new obbond.set_begin(self.ob) obbond.set_end(other.ob) @ob.add_bond(obbond) other.ob.add_bond(obbond) self end |
#amide_nitrogen? ⇒ Boolean
190 |
# File 'lib/rubabel/atom.rb', line 190 def amide_nitrogen?() @ob.is_amide_nitrogen end |
#anti_clockwise? ⇒ Boolean
197 |
# File 'lib/rubabel/atom.rb', line 197 def anti_clockwise?() @ob.is_anti_clockwise end |
#aromatic? ⇒ Boolean
178 |
# File 'lib/rubabel/atom.rb', line 178 def aromatic?() @ob.is_aromatic end |
#aromatic_noxide? ⇒ Boolean
193 |
# File 'lib/rubabel/atom.rb', line 193 def aromatic_noxide?() @ob.is_aromatic_noxide end |
#atomic_mass ⇒ Object
110 111 112 |
# File 'lib/rubabel/atom.rb', line 110 def atomic_mass @ob.get_atomic_mass end |
#atomic_num ⇒ Object
114 115 116 |
# File 'lib/rubabel/atom.rb', line 114 def atomic_num @ob.get_atomic_num end |
#atoms ⇒ Object
returns the neighboring atoms. Consider using each_atom.
106 107 108 |
# File 'lib/rubabel/atom.rb', line 106 def atoms each_atom.map.to_a end |
#axial? ⇒ Boolean
195 |
# File 'lib/rubabel/atom.rb', line 195 def axial?() @ob.is_axial end |
#bonds ⇒ Object
returns the bonds. Consider using each_bond.
90 91 92 |
# File 'lib/rubabel/atom.rb', line 90 def bonds each_bond.map.to_a end |
#carbon? ⇒ Boolean
173 |
# File 'lib/rubabel/atom.rb', line 173 def carbon?() @ob.is_carbon end |
#carboxyl_carbon? ⇒ Boolean
206 207 208 |
# File 'lib/rubabel/atom.rb', line 206 def carboxyl_carbon? atoms.any?(&:carboxyl_oxygen?) end |
#carboxyl_oxygen? ⇒ Boolean
186 |
# File 'lib/rubabel/atom.rb', line 186 def carboxyl_oxygen?() @ob.is_carboxyl_oxygen end |
#chiral? ⇒ Boolean
194 |
# File 'lib/rubabel/atom.rb', line 194 def chiral?() @ob.is_chiral end |
#chiral_volume? ⇒ Boolean
201 |
# File 'lib/rubabel/atom.rb', line 201 def chiral_volume?() @ob.has_chiral_volume end |
#chirality_specified? ⇒ Boolean
200 |
# File 'lib/rubabel/atom.rb', line 200 def chirality_specified?() @ob.has_chirality_specified end |
#clockwise? ⇒ Boolean
196 |
# File 'lib/rubabel/atom.rb', line 196 def clockwise?() @ob.is_clockwise end |
#connected? ⇒ Boolean
183 |
# File 'lib/rubabel/atom.rb', line 183 def connected?() @ob.is_connected end |
#coords ⇒ Object
# does this carbon hold a primary alcohol
def primary_alcohol_carbon?
end
214 215 216 |
# File 'lib/rubabel/atom.rb', line 214 def coords Vector[@ob.x, @ob.y, @ob.z] end |
#each_atom(&block) ⇒ Object
iterates through each neighboring atom
95 96 97 98 99 100 101 102 103 |
# File 'lib/rubabel/atom.rb', line 95 def each_atom(&block) block or return enum_for(__method__) iter = @ob.begin_bonds _atom = @ob.begin_nbr_atom(iter) while _atom block.call _atom.upcast _atom = @ob.next_nbr_atom(iter) end end |
#each_bond(&block) ⇒ Object Also known as: each
72 73 74 75 76 77 78 79 80 |
# File 'lib/rubabel/atom.rb', line 72 def each_bond(&block) block or return enum_for(__method__) iter = @ob.begin_bonds _bond = @ob.begin_bond(iter) while _bond block.call _bond.upcast _bond = @ob.next_bond(iter) end end |
#el ⇒ Object
abbreviated name, all lowercase as a Symbol
53 54 55 |
# File 'lib/rubabel/atom.rb', line 53 def el NUM_TO_EL[atomic_num] end |
#element ⇒ Object
abbreviated name, properly capitalized and as a String
58 59 60 |
# File 'lib/rubabel/atom.rb', line 58 def element NUM_TO_ELEMENT[atomic_num] end |
#exact_mass ⇒ Object
118 119 120 |
# File 'lib/rubabel/atom.rb', line 118 def exact_mass @ob.get_exact_mass end |
#formal_charge ⇒ Object Also known as: charge
122 123 124 |
# File 'lib/rubabel/atom.rb', line 122 def formal_charge @ob.get_formal_charge end |
#formal_charge=(val) ⇒ Object Also known as: charge=
127 128 129 |
# File 'lib/rubabel/atom.rb', line 127 def formal_charge=(val) @ob.set_formal_charge(val) end |
#get_bond(atom) ⇒ Object
retrieves the bond
85 86 87 |
# File 'lib/rubabel/atom.rb', line 85 def get_bond(atom) @ob.get_bond(atom.ob).andand.upcast end |
#hbond_acceptor? ⇒ Boolean
202 |
# File 'lib/rubabel/atom.rb', line 202 def hbond_acceptor?() @ob.is_hbond_acceptor end |
#hbond_donor? ⇒ Boolean
203 |
# File 'lib/rubabel/atom.rb', line 203 def hbond_donor?() @ob.is_hbond_donor end |
#hbond_donor_h? ⇒ Boolean
204 |
# File 'lib/rubabel/atom.rb', line 204 def hbond_donor_h?() @ob.is_hbond_donor_h end |
#heavy_valence ⇒ Object
132 133 134 |
# File 'lib/rubabel/atom.rb', line 132 def heavy_valence @ob.get_heavy_valence end |
#hetero_valence ⇒ Object
136 137 138 |
# File 'lib/rubabel/atom.rb', line 136 def hetero_valence @ob.get_hetero_valence end |
#heteroatom? ⇒ Boolean
181 |
# File 'lib/rubabel/atom.rb', line 181 def heteroatom?() @ob.is_heteroatom end |
#hyb ⇒ Object
140 141 142 |
# File 'lib/rubabel/atom.rb', line 140 def hyb @ob.get_hybridization end |
#hydrogen? ⇒ Boolean
172 |
# File 'lib/rubabel/atom.rb', line 172 def hydrogen?() @ob.is_hydrogen end |
#id ⇒ Object
39 40 41 |
# File 'lib/rubabel/atom.rb', line 39 def id @ob.get_id end |
#id=(val) ⇒ Object
43 44 45 |
# File 'lib/rubabel/atom.rb', line 43 def id=(val) @ob.set_id(val) end |
#idx ⇒ Object
index of the atom (begins with 1)
48 49 50 |
# File 'lib/rubabel/atom.rb', line 48 def idx @ob.get_idx end |
#implicit_valence ⇒ Object
144 145 146 |
# File 'lib/rubabel/atom.rb', line 144 def implicit_valence @ob.get_implicit_valence end |
#in_ring? ⇒ Boolean
179 |
# File 'lib/rubabel/atom.rb', line 179 def in_ring?() @ob.is_in_ring end |
#in_ring_size? ⇒ Boolean
180 |
# File 'lib/rubabel/atom.rb', line 180 def in_ring_size?() @ob.is_in_ring_size end |
#inspect ⇒ Object
218 219 220 |
# File 'lib/rubabel/atom.rb', line 218 def inspect "<#{type} id:#{id}>" end |
#isotope ⇒ Object
148 149 150 |
# File 'lib/rubabel/atom.rb', line 148 def isotope @ob.get_isotope end |
#mol ⇒ Object
returns the molecule that is parent of this atom
28 29 30 |
# File 'lib/rubabel/atom.rb', line 28 def mol @ob.get_parent.andand.upcast end |
#negative_stereo? ⇒ Boolean
199 |
# File 'lib/rubabel/atom.rb', line 199 def negative_stereo?() @ob.is_negative_stereo end |
#nitro_oxygen? ⇒ Boolean
189 |
# File 'lib/rubabel/atom.rb', line 189 def nitro_oxygen?() @ob.is_nitro_oxygen end |
#nitrogen? ⇒ Boolean
174 |
# File 'lib/rubabel/atom.rb', line 174 def nitrogen?() @ob.is_nitrogen end |
#non_polar_hydrogen? ⇒ Boolean
192 |
# File 'lib/rubabel/atom.rb', line 192 def non_polar_hydrogen?() @ob.is_non_polar_hydrogen end |
#not_c_or_h? ⇒ Boolean
182 |
# File 'lib/rubabel/atom.rb', line 182 def not_c_or_h?() @ob.is_not_cor_h end |
#one_four? ⇒ Boolean
185 |
# File 'lib/rubabel/atom.rb', line 185 def one_four?() @ob.is_one_four end |
#one_three? ⇒ Boolean
184 |
# File 'lib/rubabel/atom.rb', line 184 def one_three?() @ob.is_one_three end |
#oxygen? ⇒ Boolean
175 |
# File 'lib/rubabel/atom.rb', line 175 def oxygen?() @ob.is_oxygen end |
#partial_charge ⇒ Object
152 153 154 |
# File 'lib/rubabel/atom.rb', line 152 def partial_charge @ob.get_partial_charge end |
#phosphate_oxygen? ⇒ Boolean
187 |
# File 'lib/rubabel/atom.rb', line 187 def phosphate_oxygen?() @ob.is_phosphate_oxygen end |
#phosphorus? ⇒ Boolean
177 |
# File 'lib/rubabel/atom.rb', line 177 def phosphorus?() @ob.is_phosphorus end |
#polar_hydrogen? ⇒ Boolean
191 |
# File 'lib/rubabel/atom.rb', line 191 def polar_hydrogen?() @ob.is_polar_hydrogen end |
#positive_stereo? ⇒ Boolean
198 |
# File 'lib/rubabel/atom.rb', line 198 def positive_stereo?() @ob.is_positive_stereo end |
#spin ⇒ Object
156 157 158 |
# File 'lib/rubabel/atom.rb', line 156 def spin @ob.get_spin_multiplicity end |
#sulfate_oxygen? ⇒ Boolean
188 |
# File 'lib/rubabel/atom.rb', line 188 def sulfate_oxygen?() @ob.is_sulfate_oxygen end |
#sulfur? ⇒ Boolean
176 |
# File 'lib/rubabel/atom.rb', line 176 def sulfur?() @ob.is_sulfur end |
#type ⇒ Object
160 161 162 |
# File 'lib/rubabel/atom.rb', line 160 def type @ob.get_type end |
#valence ⇒ Object
164 165 166 |
# File 'lib/rubabel/atom.rb', line 164 def valence @ob.get_valence end |
#vector ⇒ Object
168 169 170 |
# File 'lib/rubabel/atom.rb', line 168 def vector @ob.get_vector end |