code: def pandas_df_to_biopython_seqrecord(
      df,
      id_col='uid',
      sequence_col='sequence',
      extra_data=None,
      alphabet=None,
      ):
      
      seq_records = []
  
      for i, row in df.iterrows():
          # Tries getting sequence data. If a TypeError at the seqrecord
          # creation is thrown, it is assumed that this row does not contain
          # sequence data and therefore the row is ignored.
          try:
              # Get sequence
              seq = Seq(row[sequence_col], alphabet=alphabet)
  
              # Get id
              id = row[id_col]
  
              # Build a description
              description = ""
              if extra_data is not None:
                  description = " ".join([row[key] for key in extra_data])
  
              # Build a record
              record = SeqRecord(
                  seq=seq,
                  id=id,
                  description=description,
              )
              seq_records.append(record)
          except TypeError:
              pass
  
      return seq_records
docs: Convert pandas dataframe to biopython seqrecord for easy writing.
  
      Parameters
      ----------
      df : Dataframe
          Pandas dataframe to convert
  
      id_col : str
          column in dataframe to use as sequence label
  
      sequence_col str:
          column in dataframe to use as sequence data
  
      extra_data : list
          extra columns to use in sequence description line
  
      alphabet :
          biopython Alphabet object
  
      Returns
      -------
      seq_records :
          List of biopython seqrecords.