code: def filter_genome(genome_in, threshold=500, list_records=None):
      
  
      if list_records is None:
  
          def truth(*args):
              del args
              return True
  
          is_a_record_to_keep = truth
  
      else:
          try:
              with open(list_records) as records_handle:
                  records_to_keep = records_handle.readlines()
          except OSError:
              if not hasattr(list_records, "__contains__"):
                  raise
              else:
                  records_to_keep = list_records
  
          is_a_record_to_keep = records_to_keep.__contains__
  
      records_to_write = (
          record
          for record in SeqIO.parse(genome_in, "fasta")
          if (len(record.seq) >= threshold and is_a_record_to_keep(record.id))
      )
  
      return records_to_write
docs: Filter fasta file according to various parameters.
  
      Filter a fasta file according to size and/or an explicit list of records
      to keep.
  
      Parameters
      ----------
      genome_in: file, str or pathlib.Path
          The input genome in FASTA format.
      threshold: int, optional
          The size below which genome records are discarded. Default is the
          default minimum chunk size, i.e. 500.
      list_records: array_like, optional
          A list of record ids to keep. If not None, records that don't belong
          to that list are discarded. Default is None, i.e. all records are
          kept.
  
      Returns
      -------
      records_to_write: generator
          Filtered records that were kept.