I have a fasta file with several 120-concatenation protein sequences. I also have a data frame with 120 names of proteins in column 1 and their length in column 2. Using this dataframe I want to create a new fasta file per sequence in which I get each protein independent with the name of the protein and the bacteria.
Here my fasta file.
Bacteria_1
Seq('GRRKAAVARAYMTAGKGNVTVNKKDYKDFFPVPTLQYKITQPFAITETLGQYDV...IEE', SingleLetterAlphabet())
Bacteria_2
Seq('GRRKDSVARVYLRPGKGEIVVNKRPVEDYFGRETLKMVLRQPLELTESLDKFDI...YK-', SingleLetterAlphabet())
Here my dataframe
Names LEN
0 Ribosomal_S9: 121
1 Ribosomal_S8: 129
2 Ribosomal_L10: 100
3 GrpE: 166
4 DUF150: 141
.. ... ...
115 TIGR03632: 117
116 TIGR03654: 175
117 TIGR03723: 314
118 TIGR03725: 212
119 TIGR03953: 188
[120 rows x 2 columns]
The name of the genes and their length is the same for all my bacteria so this df is applicable for all sequences in my fasta file.
I am trying to get new fasta files like this:
>Bacteria_1 Ribosomal_S9:
GRRKAAVARAYMTAGKGNVTVNKKDYKDFFPVPTLQYKITQPFAITETLGQYDV...
>Bacteria_1 Ribosomal_S8:
KDYKDFFPVPTLAAVARAYMTAGKGNLGQYDVGRRKAAVARAYMTAGKGN...
...
>Bacteria_1 TIGR03953:
AJEFISUBEVFCVALSKDMCFPADNSCF0AISCIABNSCNAISCN...
The second fasta file
>Bacteria_2 Ribosomal_S9:
GRRKAAVARAYMTAGKGNVTVNKKDYKDFFPVPTLQYKITQPFAITETLGQYDV...
>Bacteria_2 Ribosomal_S8:
KDYKDFFPVPTLAAVARAYMTAGKGNLGQYDVGRRKAAVARAYMTAGKGN...
...
>Bacteria_2 TIGR03953:
AJEFISUBEVFCVALSKDMCFPADNSCF0AISCIABNSCNAISCN...