Sha256: f3ba73532c2710fcb9b3b8f1b23ae249ed26f06bada3938f0b79bf0624bb8e77
Contents?: true
Size: 585 Bytes
Versions: 384
Compression:
Stored size: 585 Bytes
Contents
<?php function nucleotideCount($dna) { $nucleotides = []; if (strlen($dna) > 0) { $nucleotides = str_split($dna); } $count = array_reduce($nucleotides, function ($count, $nucleotide) { if (! in_array(strtolower($nucleotide), ['a', 'c', 'g', 't'])) { throw new InvalidArgumentException(sprintf('The nucleotide %s does not exist in DNA', $nucleotide)); } $count[strtolower($nucleotide)]++; return $count; }, [ 'a' => 0, 'c' => 0, 't' => 0, 'g' => 0, ]); return $count; }
Version data entries
384 entries across 384 versions & 1 rubygems