lib/rubabel/atom.rb in rubabel-0.2.1 vs lib/rubabel/atom.rb in rubabel-0.2.2
- old
+ new
@@ -1,5 +1,7 @@
+#encoding: utf-8
+
require 'matrix'
require 'andand'
require 'rubabel/bond'
@@ -182,11 +184,11 @@
when 0 then 2
when 2 then 3
end
@ob.set_spin_multiplicity(new_spin)
atoms.each do |atom|
- if atom.atomic_num == 1
+ if atom.hydrogen?
self.mol.delete_atom(atom)
break
end
end
# add the charge
@@ -244,10 +246,14 @@
def spin
@ob.get_spin_multiplicity
end
+ def spin=(val)
+ @ob.set_spin_multiplicity(val)
+ end
+
def type
@ob.get_type
end
def valence
@@ -289,9 +295,16 @@
def chirality_specified?() @ob.has_chirality_specified end
def chiral_volume?() @ob.has_chiral_volume end
def hbond_acceptor?() @ob.is_hbond_acceptor end
def hbond_donor?() @ob.is_hbond_donor end
def hbond_donor_h?() @ob.is_hbond_donor_h end
+
+ # the total number of hydrogens bonded to the atom (implicit + explicit)
+ def hydrogen_count
+ @ob.implicit_hydrogen_count + @ob.explicit_hydrogen_count
+ end
+
+ alias_method :num_h, :hydrogen_count
def double_bond?
each_bond.any? {|bond| bond.bond_order == 2 }
end