Chemistry-Bond-Find
view release on metacpan or search on metacpan
if ($grid->{$neigh_n}) {
find_bonds_n2_two_sets($mol, $atoms, $grid->{$neigh_n}, $opts);
}
}
}
}
# used by both find_bonds variants to figure out the maximum cutoff
sub guess_margin {
my ($mol, $opts) = @_;
my $formula = $mol->formula_hash;
my $max = 0;
for my $elem (keys %$formula) {
$max = $Covalent_Radius{$elem} if $Covalent_Radius{$elem} > $max;
}
$max *= 2 * $opts->{tolerance};
#printf "MARGIN guessed at (%.2f)\n", $max;
$max;
}
# brute-force N^2 algorithm
sub find_bonds_n2_one_set {
my ($mol, $atoms, $opts) = @_;
unsatisfied valences. This option is true by default.
=back
=item baber
A bond order assignment algorithm based on Baber, J. C.; Hodgkin, E. E.
J. Chem. Inf. Comp. Sci. 1992, 32, 401-406 (with some interpretation).
This algorithm uses the 3D coordinates along with various cutoffs and
confidence formulas to guess the bond orders. It then tries to resolve
conflicts by looping through the atoms (but is not recursive or backtracking).
It does not require explicit hydrogens (although it's better when they are
available) because it was designed for use with real crystallographic data
which often doesn't have hydrogen atoms.
This method doesn't always give a good answer, especially for conjugated and
aromatic systems. The variation used in this module adds some random numbers to
resolve some ambiguities and break loops, so the results are not even entirely
deterministic (the 'itub' method is deterministic but the result may depend on
the input order of the atoms).
return 0; # max. valence satisfied
}
}
############
# Bond order assignment algorithm based on Baber, J. C.; Hodgkin, E. E.
# J. Chem. Inf. Comp. Sci. 1992, 32, 401-406
# this algorithm uses the 3D coordinates along with various cutoffs and
# confidence formulas to assign the bond orders. It does not require all
# explicit hydrogens (although it's better when they are available) because
# it's design for use with real crystallographic data which often doesn't
# have hydrogen.
my %Valences = (
C => [4], N => [3,4], O => [2],
P => [4, 5], S => [2, 4, 6], As => [4, 5], Se => [2, 4, 6],
Te => [2, 4, 6],
F => [1], Cl => [1, 3], Br => [1, 3, 5], I => [1, 3, 5, 7],
H => [1],
( run in 0.534 second using v1.01-cache-2.11-cpan-3cd7ad12f66 )