in reply to How to write a perl script to grab the first 100 sequences to a 227,000 sequence file?

change the 99 to 1 less than the number of sequences you want:

perl -e"BEGIN{$/=qq[\n>]}" -ple"$. == 99 && last;" yourfile.fasta >new +file.fasta

With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.

The start of some sanity?

  • Comment on Re: How to write a perl script to grab the first 100 sequences to a 227,000 sequence file?
  • Download Code

Replies are listed 'Best First'.
Re^2: How to write a perl script to grab the first 100 sequences to a 227,000 sequence file?
by Anonymous Monk on Apr 11, 2013 at 13:18 UTC
    That's nice, but all > except the first one are missing...
      I meant that all sequences are starting with a > inside a fasta file. The code above works perfectly, but somehow it doesn't put the > back, except the first one...
        I would suggest reading about "$\" in perlvar.