Filtering Sequences (entries) by headers ID from a Fasta file database First of all, sorry if this question has been posted previously (I could not found a solution accessing the previous Q&amp;A).
I have a fasta file as follow:
&gt;LNIV02000036.519060.520603 Pseudomonas aeruginosa
GAACTGAAGAGTTTGATCATGGCTCAGATTGAACGCTGGCGGCAGGCCTAA...

&gt;LDLH01000045.361.1876 Pseudomonas aeruginosa
AGAGTTTGATCATGGCTCAGATTGAACGCTGGCGGCAGGCCTAACACATG...

&gt;LNMQ01000087.5825.7394 Enterococcus faecium
TTTTTATGAGAGTTTGATCCTGGCTCAGGACGAACGCTGGCGGCGTGC...

...

I would like to filter sequences or extract entries for a specific species, let's say Pseudomonas (I have others in mind...). I tried a few things but I think the main problem is my skills associated with bioinformatics. I would like to create a file content Pseudomonas entries (~9k entries in the current database). Any suggestion or tip?
Thank you for your time.
Best,
Fabricio
Using Biopython:
from Bio import SeqIO

for record in SeqIO.parse(&quot;input.fa&quot;, &quot;fasta&quot;):
    if record.description.split()[-2:] == [&quot;Pseudomonas&quot;, &quot;aeruginosa&quot;]:
        print(record.format(&quot;fasta&quot;))