title: How to run a python script as a loop for different files?
body: <p>I have a python script as follow:</p>
  
  <pre><code>#!/usr/bin/python
  from Bio import SeqIO
  
  fasta_file = "input.fa" # Input fasta file
  wanted_file = "A_ids.txt" # Input interesting sequence IDs, one per line
  result_file = "A.fasta" # Output fasta file
  
  wanted = set()
  with open(wanted_file) as f:
      for line in f:
          line = line.strip()
          if line != "":
              wanted.add(line)
  
  fasta_sequences = SeqIO.parse(open(fasta_file),'fasta')
  with open(result_file, "w") as f:
      for seq in fasta_sequences:
          if seq.id in wanted:
              SeqIO.write([seq], f, "fasta")
  </code></pre>
  
  <p>I would like to run the script above for the same input file, but for 40 different wanted_files - with different names - A_ids.txt, B_ids.txt, etc.
  And I would like to have their respective different outputs - A.fasta, B.fasta, etc.</p>
  
  <p>Do I need to change my python script or I need to create a loop to run it for all my wanted files?</p>
  
  <p>thanks</p>