Beefy Boxes and Bandwidth Generously Provided by pair Networks
Just another Perl shrine
 
PerlMonks  

Re: merge sequences with new sequence insertion

by 2teez (Priest)
on Nov 26, 2013 at 21:28 UTC ( #1064481=note: print w/ replies, xml ) Need Help??


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


Comment on Re: merge sequences with new sequence insertion
Download Code
Re^2: merge sequences with new sequence insertion
by AnomalousMonk (Abbot) 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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1064481]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (4)
As of 2015-07-05 16:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (67 votes), past polls