in reply to merge sequences with new sequence insertion

Hi,
You can read one line at a time (for I don't know how large the OP file is), chomp the line, then check if the lines meet your condition using a simply regex, and print it out with the string to insert at the end like so:

use warnings; use strict; my $str = 'nnnnncattccattcattaattaattaatgaatgaatgnnnnn'; while(<DATA>){ chomp; print $_,$str if !/^>|^$/; } __DATA__ >contig number 11 tttgctcggaggggatc >contig number 23 gaaaacacttccttattatacaggtaaaccgtatttggat >contig number 3 aaagctcggaggggatcccct
This works for me.

If you tell me, I'll forget.
If you show me, I'll remember.
if you involve me, I'll understand.
--- Author unknown to me

Replies are listed 'Best First'.
Re^2: merge sequences with new sequence insertion
by AnomalousMonk (Archbishop) on Nov 26, 2013 at 23:12 UTC
    ... print it out with the string to insert at the end ...

    Doesn't that leave you with a  'nnnnnwhatevernnnnn' "joiner" sequence pasted at the end of the last line of the file? My interpretation of the OP was that joiners should be pasted only between the "contig" sequences. (But I have done no testing of your code.)

      Hi AnomalousMonk,
      Awoshhh!!. My bad! You are right. I think I read wrong, the OP requirement. I think, rnaeye has a better implementation of that.

      If you tell me, I'll forget.
      If you show me, I'll remember.
      if you involve me, I'll understand.
      --- Author unknown to me