How to remove duplicates from a fasta file using python I am using the following command:
from Bio import SeqIO
import sys
import re 


    fasta_file = (sys.argv[1])
    for myfile in SeqIO.parse(fasta_file, &quot;fasta&quot;):
      if len(myfile) &gt; 250:
       gene_id = myfile.id
       mylist = re.match(r&quot;H149xcV_[^\W_]+_[^\W_]+_[^\W_])_[^\W_]+&quot;, gene_id)
       print (&quot;&gt;&quot;+list.group(1)) 

And this is providing me with duplicates of the same gene:
&gt;H149xcV_Fge342_r3_h2
&gt;H149xcV_bTr423_r3_h2
&gt;H149xcV_kN893_r3_h2
&gt;H149xcV_DNp021_r3_h2
&gt;H149xcV_JEP3324_r3_h2
&gt;H149xcV_JEP3324_r3_h2
&gt;H149xcV_JEP3324_r3_h2
&gt;H149xcV_SRt424234_r3_h2
&gt;H149xcV_Fge342_r3_h2
&gt;H149xcV_Fge342_r3_h2

How can I reformat my command so that I only receive unique gene id's:
&gt;H149xcV_Fge342_r3_h2
&gt;H149xcV_bTr423_r3_h2
&gt;H149xcV_kN893_r3_h2
&gt;H149xcV_DNp021_r3_h2
&gt;H149xcV_JEP3324_r3_h2
&gt;H149xcV_SRt424234_r3_h2
from Bio import SeqIO
import sys
import re 

unique = []
fasta_file = (sys.argv[1])
for myfile in SeqIO.parse(fasta_file, &quot;fasta&quot;):
    if len(myfile) &gt; 250:
        gene_id = myfile.id
        if gene.id not in unique:
            unique.append(gene.id)
            mylist = re.match(r&quot;H149xcV_[^\W_]+_[^\W_]+_[^\W_])_[^\W_]+&quot;, gene_id)
            print (&quot;&gt;&quot;+mylist.group(1)) 

```