Hi I have a long string in which I want to substitute repeated AT regions with N, ie ATATATATATATATATATAT NNNNNNNNNNNNNNNNNNNN I am having a problem doing this i have tried with tr/// which seems to mask all AT no matter how many repeats there are, and also with the s/// which behaves oddly. Enclosed is my latest attempt which prints the NNN sequence but prints it BEFORE the substituted sequence.
I realise I could use a for loop but I want to use this substitution for a sequence which is VERY long and I am sure there must be a better way
I realise I could use a for loop but I want to use this substitution for a sequence which is VERY long and I am sure there must be a better way
Code:
#!/usr/local/bin/perl
$testsequence=" ATGACGACTTATAGCGATGCTAGCATCTAGACTATATATATATATATATATATATATATATATATATATATATATATATATATATATATATATATATCGCTAGTAACGTAGTAGCTGTAGTAGCTGACTGATGCTGTAGTGACTGATGC";
$testsequence=~s/([A,T]{9,})/for($i=0;$i<length($1);$i++){ printf "N";}/e;
print $testsequence;
print "testsure";