There is a perl function that finds and prints all the overlapping k-mers of the input string.
#!/pkg/bin/perl -w
print "Input the string\n";
$dna = <>;
chomp $dna;
print "Input the length of the window\n";
$k = <>;
chomp $k;
while (length($dna) >= $k) {
$dna =~ m/(.{$k})/;
print "$1 \n";
$dna = substr($dna, 1, length($dna) -1);;
}
I would like to make it a function so instead of a string it receives a list of strings and get all k-mers, so I am trying something like:
//first try with defined string and k to see if it works
string dna="ATTTGGC\nTGCCTTA\nCGGTATC\nGAAAATT";
dna.Replace("\n", ""); //instead of chomp
int k=3;
while(dna.Length >= k){
//here I do not know how to traslate $dna =~ m/(.{$k})/;
//print "$1 \n";
//$dna = substr($dna, 1, length($dna) -1);;
}
what would be the best way to translate that function from perl to c#?