BioPHP - Find palindromic sequences
Original code submitted by josebaCode bellow is covered by GNU GPL v2 license.
Description
Last change: 2010/10/18 17:04 | Edit description | Recent Changes | Original descriptionSearches for palindromic sequences within a DNA sequence. Length of palindromic sequences to be searched will be between $min and $max values Will return an array with key = start position and val= palindromic sequence Requires function DNA_is_palindrome
Code
Last change: 2010/10/18 17:04 | Edit Code | Recent Changes | Download | Original codefunction find_palindromic_seqs ($seq,$min, $max){
$result="";
$seq_len=strlen($seq);
for($i=0;$i<$seq_len-$min+1;$i++){
$j=$min;
while($j<$max+1 and ($i+$j)<=$seq_len){
if (is_odd($j)==1){$j++;continue;}
$sub_seq=substr($seq,$i,$j);
if (DNA_is_palindrome($sub_seq)==1){
$results [$i]=$sub_seq;
}
$j++;
}
}
return $results;
}