Filtering Sequences (entries) by headers ID from a Fasta file database
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;))