Branch Coverage

blib/lib/Chemistry/OpenSMILES/Writer.pm
Criterion Covered Total %
branch 180 204 88.2


line true false branch
74 0 245 defined $options && ref $options eq 'CODE' ? :
75 35 210 unless defined $options and ref $options eq "HASH"
85 228 17 unless exists $options->{'explicit_aromatic_bonds'}
95 213 32 unless exists $options->{'explicit_parentheses'}
106 238 7 unless exists $options->{'immediately_reuse_ring_numbers'}
116 202 43 unless exists $options->{'remove_implicit_hydrogens'}
127 198 47 unless exists $options->{'unsprout_hydrogens'}
140 56 189 if $options->{'order_sub'}
153 0 245 $options->{'write_atom_sub'} ? :
161 20 225 if ref $what eq "HASH"
163 200 25 ref $what eq 'ARRAY' ? :
173 0 1328 if $seen{$v}
193 1 244 if (@order != $graph->vertices)
197 0 245 unless @order
199 219 26 if ($options->{'unsprout_hydrogens'})
217 1146 90 unless &is_chiral($atom)
218 2 13 unless &is_chiral_tetrahedral($atom) or &is_chiral_planar($atom) or &is_chiral_trigonal_bipyramidal($atom) or &is_chiral_octahedral($atom)
225 75 13 if ($atom->{'chirality'} =~ /^@(\@?|SP[123])$/)
226 0 75 if (scalar @neighbours < 3 or scalar @neighbours > 4)
235 8 80 if ($atom->{'chirality'} =~ /^\@TB..?$/)
236 0 8 if (scalar @neighbours < 4 or scalar @neighbours > 5)
245 5 83 if ($atom->{'chirality'} =~ /^\@OH..?$/)
246 0 5 if (scalar @neighbours < 5 or scalar @neighbours > 6)
256 0 88 unless exists $atom->{'chirality_neighbours'}
260 0 88 if (@neighbours != @chirality_neighbours)
269 8 80 if ($has_lone_pair)
287 88 0 if ($$rings{&$order_by_vertex($atom)})
301 71 17 if ($options->{'unsprout_hydrogens'})
302 194 16 if defined $_
57 14 if (&any(sub { $_ < $order if defined $_; } , map({&$order_by_vertex($_);} @neighbours))) { }
312 8 80 if ($has_lone_pair)
319 69 19 if ($atom->{'chirality'} =~ /^\@\@?$/) { }
6 13 elsif ($atom->{'chirality'} =~ /^\@SP[123]$/) { }
8 5 elsif ($atom->{'chirality'} =~ /^\@TB..?$/) { }
321 12 57 if (join("", _permutation_order(@permutation)) ne "0123")
322 10 2 $chirality_now eq '@' ? :
342 995 241 if ($discovered_from{$vertex})
343 385 610 if ($options->{'explicit_parentheses'} or _has_more_unseen_children($discovered_from{$vertex}, $i, $order_by_vertex, $graph, $rings))
349 88 1148 if ($chirality{$vertex}) { }
360 233 1003 if ($rings->{$i})
363 77 77 if ($i < $j) { }
364 0 77 unless (@ring_ids)
373 77 0 $rings->{$i}{$j}{'ring'} < 10 ? :
376 77 0 $rings->{$i}{$j}{'ring'} < 10 ? :
377 71 6 if ($options->{'immediately_reuse_ring_numbers'}) { }
379 0 71 unless ($a == 0) - ($b == 0)
386 11 222 unless ($options->{'immediately_reuse_ring_numbers'})
387 0 11 unless ($a == 0) - ($b == 0)
391 991 245 $i < $#order ? :
393 385 606 if ($options->{'explicit_parentheses'} or _has_more_unseen_children($discovered_from{$vertex}, $i, $order_by_vertex, $graph, $rings))
414 0 88 unless @$A == @$B
426 0 1256 unless $options
436 3 1253 if (exists $vertex->{'isotope'})
441 1236 20 if (exists $options->{'chirality'}) { }
0 20 elsif (&is_chiral($vertex)) { }
442 88 1148 if ($options->{'chirality'})
451 6 1250 $vertex->{'hcount'} ? :
452 998 238 if ($graph and $options->{'unsprout_hydrogens'} and $atom ne "H")
458 429 28 if ($is_simple and $graph and not $raw and $Chemistry::OpenSMILES::Writer::normal_valence{ucfirst $atom} and not $vertex->{'charge'} and not $vertex->{'class'})
461 407 22 if (_has_unambiguous_normal_valence($graph, $vertex, $hcount)) { }
463 366 41 if $options->{'remove_implicit_hydrogens'}
470 49 1207 if ($hcount)
471 31 18 $hcount == 1 ? :
474 84 590 if $raw and exists $vertex->{'hcount'}
476 12 1244 if ($vertex->{'charge'})
477 4 8 $vertex->{'charge'} > 0 ? :
482 26 1230 if ($vertex->{'class'})
487 934 322 $is_simple ? :
498 823 326 unless ($graph->has_edge_attribute($u, $v, "bond"))
499 5 818 $n_aromatic == 2 ? :
503 144 0 if $bond eq ":" and $n_aromatic and not $options->{'explicit_aromatic_bonds'}
504 158 24 if $u->{'number'} < $v->{'number'}
515 654 1088 if (defined &$order_by_vertex($vertex) and $$rings{&$order_by_vertex($vertex)})
526 0 429 unless exists $Chemistry::OpenSMILES::Writer::normal_valence{$element}
530 21 408 unless $normal_valence
544 3 89 if (scalar @_ != 4 or &any(sub { not defined $_ && /^[0-3]$/; } , @_) or join(",", sort(@_)) ne "0,1,2,3")
555 42 47 if ($_[0] != 0)
570 0 6 if (join(",", sort(@_)) ne "0,1,2,3")
582 3 3 if ($source[3] == $target[1])
588 3 3 if ($source[2] == $target[1])
594 3 3 if ($source[3] == $target[2])
608 0 4810 if (join(",", sort(@target)) ne "0,1,2,3,4")
621 19240 4810 if $_ != $axis[0]
626 19240 4810 if $_ != $axis[0]
629 2402 2408 if ($axis_location[0] > $axis_location[1])
639 1203 1202 $order eq '@' ? :
2405 2405 unless $sides[1] == $target[1]
643 9614 40892 if $Chemistry::OpenSMILES::Writer::TB[$_]{'order'} eq $order and $Chemistry::OpenSMILES::Writer::TB[$_]{'axis'}[0] == $axis_location[0] + 1
653 0 43205 if (join(",", sort(@target)) ne "0,1,2,3,4,5")
664 216025 43205 if $_ != $axis[0]
666 14401 28804 if ($Chemistry::OpenSMILES::Writer::OH[$chirality - 1]{'shape'} eq "Z")
670 14401 28804 if ($Chemistry::OpenSMILES::Writer::OH[$chirality - 1]{'shape'} eq 4)
675 21604 21601 if $Chemistry::OpenSMILES::Writer::OH[$chirality - 1]{'order'} eq "\@"
678 7201 36004 if ($axis[0] == $target[0]) { }
7201 28803 elsif ($axis[1] == $target[0]) { }
703 7201 36004 if ($target[0] == $sides[0] and $target[1] == $sides[1]) { }
7201 28803 elsif ($target[0] == $sides[0] and $target[1] == $sides[2]) { }
7200 21603 elsif ($target[0] == $sides[1] and $target[1] == $sides[0]) { }
7202 14401 elsif ($target[0] == $sides[1] and $target[1] == $sides[2]) { }
7200 7201 elsif ($target[0] == $sides[2] and $target[1] == $sides[0]) { }
7201 0 elsif ($target[0] == $sides[2] and $target[1] == $sides[1]) { }
720 129611 540043 if $Chemistry::OpenSMILES::Writer::OH[$_]{'shape'} eq $shape and $Chemistry::OpenSMILES::Writer::OH[$_]{'order'} eq $order