sub find-ssrs(Str $sequence) {
my @ssrs;
for 2..$sequence.chars -> $min-repeats {
for $sequence.chars...$min-repeats -> $max-repeat {
my $repeat = $sequence.substr($min-repeats - 1, $max-repeat - $min-repeats + 1);
my $repeat-length = $max-repeat - $min-repeats + 1;
if $sequence.substr($max-repeat).index($repeat) == 0 {
push @ssrs, {
start => $min-repeats,
end => $max-repeat,
length => $repeat-length,
sequence => $repeat
};
}
}
}
return @ssrs;
}
sub process-fastq-file(Str $filename) {
my $fh = open $filename, :r;
my $line-number = 0;
while $fh.readline -> $header {
$line-number++;
my $sequence = $fh.readline.chomp;
# Skipping the next two lines (comment and quality lines)
$fh.readline;
$fh.readline;
my @ssrs = find-ssrs($sequence);
if @ssrs {
say "SSRs found in sequence at line $line-number:";
for @ssrs -> $ssr {
say " Start: $ssr<start>, End: $ssr<end>, Length: $ssr<length>, Sequence: $ssr<sequence>";
}
}
}
$fh.close;
}
# Replace 'your_fastq_file.fastq' with the path to your FASTQ file
process-fastq-file('your_fastq_file.fastq');