I have eight fasta files, one per gene, with 106 fasta entries per file, like this:
gene1.fasta:
>sample1_434564
GATCTCGTAGATGTGA
>sample2_2346764
GATCTCGTAGATGTGA
gene2.fasta:
>sample1_532345
ATGCTGTGAAGTA
>sample2_6040103
ATGCTGTGAAGTA
What I want to do is create one fasta file per sample so that I get all gene sequences for that sample in one file. As you can see, the sample ID is the same before the _
in the fasta headers, but the rest is unique for each fasta file.
Is there any way to do this with awk
or other command-line tools?
Desired output:
Sample1.fasta
>gene1
GATCTCGTAGATGTGA
>gene2
ATGCTGTGAAGTA
Sample2.fasta
>gene1
GATCTCGTAGATGTGA
>gene2
ATGCTGTGAAGTA