http://www.perlmonks.org?node_id=1037468


in reply to Removing nucleotide frm sequence

You probably want something more refined than this, but something similar to:
while (<>) { # $ denotes end of string s/AAAAA$//; s/>CC\@B$//; print; }
Not quite sure if your sequence is on one line or multiple lines, so the above will need some tweaking. If you need some more help, please amend your question, putting a complete sequence in code blocks
If you spot any bugs in my solutions, it's because I've deliberately left them in as an exercise for the reader! :-)

Replies are listed 'Best First'.
Re^2: Removing nucleotide frm sequence
by bingalee (Acolyte) on Jun 06, 2013 at 14:47 UTC
    Hey, thanks for that..but the quality and the last five nucleotides aren't the same in every sequence. It can also be like AAACT in another sequence..:(

      Please can you put a complete sequence or two in the comment, with a short explanation of what needs removing. Many of us aren't chemists (I only got a low grade at Chem A level 30 years ago :-)

      If you spot any bugs in my solutions, it's because I've deliberately left them in as an exercise for the reader! :-)
Re^2: Removing nucleotide frm sequence
by space_monk (Chaplain) on Jun 07, 2013 at 07:42 UTC
    local $/ = ""; while (<>) { # should have a whole record # split up 4 line record my (@line) = split( "\n"); # change if necessary to check we have a valid record if ($line[0] =~ /^@/) { $line[1] =~ s/([ACGT]{5})$//; $line[3] =~ s/(\w{5})$//; print join("\n", @line); } }
    If you spot any bugs in my solutions, it's because I've deliberately left them in as an exercise for the reader! :-)