#!/usr/bin/env python3
# Creator: Kshitij Tandon
#Usage: python FASTAfile Contig_ids_file >outputfilename.fasta
      from Bio import SeqIO
      import sys

      ffile = SeqIO.parse(sys.argv[1], "fasta")
      header_set = set(line.strip() for line in open(sys.argv[2]))

      for seq_record in ffile:
          try:
              header_set.remove(seq_record.name)
          except KeyError:
              print(seq_record.format("fasta"))
              continue
      if len(header_set) != 0:
          print(len(header_set),'of the headers from list were not identified in the input fasta file.', file=sys.stderr)