function MotifEnumeration($dna_kmers, $k, $d) { /* * Patterns ← an empty set for each k-mer Pattern in Dna for each k-mer Pattern’ differing from Pattern by at most d mismatches if Pattern' appears in each string from Dna with at most d mismatches add Pattern' to Patterns remove duplicates from Patterns return Patterns */ $Patterns = array(); foreach ($dna_kmers as $Pattern) { $kmers_prime = GenerateAllKMers($Pattern, $k); foreach ($kmers_prime as $Pattern_prime_x) { //ddd($Pattern_prime_x, FALSE); $Neighbours = Neighbors($Pattern_prime_x, $d); foreach ($Neighbours as $Pattern_prime) { //ddd($Neighbours); $score = 0; foreach ($dna_kmers as $Pattern_for_count) { if (ApproximatePatternCount($Pattern_for_count, $Pattern_prime, $d) > 0) { $score++; } } if ($score == count($dna_kmers)) { $Patterns[] = $Pattern_prime; } } } } return array_unique($Patterns); }
<?php require __DIR__ . '/../../_common.php'; echo ApproximatePatternCount('CTGTACCCGTAGAGCCCATTAACATCTGCATGAGCGTTCTGGGGCCTCTTAACGCGATTGTGAACTAAAATACTAATATATGATGTCAACGTTGGGGAAACCCACCTAATGTCAACACCTATGCTACACGACGCTACGAAAGTGTGTGCCCGTACCGGAAGGCACGGATCTGTGCGTCCCCATTGACCACAGTTTAGATCGCCGAACTGCACTATACGCTTTCGATTAGACAACCGATCGCACCAGGCCTGTAGTATACCAAAAGTGTTACACCGCGATACCGAGCAGGACAATGATTATCCGAATGCATGTCCCGGGGCGATAGTTTTTTAGACAGACCGCCTTTCCTCTACTCATGCATTGGGG', 'CATGTC', 3);