Split fasta file using csplit

581 Views Asked by At

I need to split a big fasta file into smaller ones. I am trying the following command:

csplit -z input.fasta '/>/' '{*}'

but it is generating lots of files (for each ">"). Is there a way to ask to create only two smaller files?

Thank you

1

There are 1 best solutions below

0
On

According to it's manpage csplit splits a file at each occurence of the given pattern - thus it's generating one file for each sequence.

If you want to split the file by file size ignoring it's content, you might have a look at split with -C-parameter.

Nevertheless you might not get two valid fasta-files, because the sequence block in the middle of your file might be split.