in reply to Re: String character replacement based on position
in thread String character replacement based on position

@"The case of converting the ninth character from the left of a string to upper case is probably not the problem you're having trouble solving, is it?"

Yes, the problem I'm having is how to develop a general solution for changing the case of specific letters in a DNA sequence. So, I have many variable sequence positions where the letter case needs to be changed. Furthermore, letter case changes must sometimes occur more than once per DNA sequence.
  • Comment on Re^2: String character replacement based on position

Replies are listed 'Best First'.
Re^3: String character replacement based on position
by AnomalousMonk (Archbishop) on Feb 23, 2011 at 23:53 UTC
    ... more than once per DNA sequence.

    Maybe:

    >perl -wMstrict -le "my $seq = 'atcgcgtacatcgatac'; my $rule = '01234567890123456'; my @uc_offsets = (0, 8, 15); ;; print qq{$rule}; print qq{$seq}; for my $offset (@uc_offsets) { substr($seq, $offset, 1) = uc substr $seq, $offset, 1; } print qq{$seq}; " 01234567890123456 atcgcgtacatcgatac AtcgcgtaCatcgatAc

    Easy to put that into a function.

    Update: Looking back, I see that BrowserUk essentially gave this solution already, so... Never mind.