code: def _write(
      data,
      filename=None,
      schema='fasta',
      id_col='uid',
      sequence_col='sequence',
      extra_data=None,
      alphabet=None,
      **kwargs):
      
      # Check Alphabet if given
      if alphabet is None:
          alphabet = Bio.Alphabet.Alphabet()
  
      elif alphabet in ['dna', 'rna', 'protein', 'nucleotide']:
          alphabet = getattr(Bio.Alphabet, 'generic_{}'.format(alphabet))
  
      else:
          raise Exception(
              "The alphabet is not recognized. Must be 'dna', 'rna', "
              "'nucleotide', or 'protein'.")
  
      # Build a list of records from a pandas DataFrame
      if type(data) is pd.DataFrame:
          seq_records = pandas_df_to_biopython_seqrecord(
              data,
              id_col=id_col,
              sequence_col=sequence_col,
              extra_data=extra_data,
              alphabet=alphabet,
          )
  
      # Build a record from a pandas Series
      elif type(data) is pd.Series:
          seq_records = pandas_series_to_biopython_seqrecord(
              data,
              id_col=id_col,
              sequence_col=sequence_col,
              extra_data=extra_data,
              alphabet=alphabet,
          )
  
      # Write to disk or return string
      if filename is not None:
          SeqIO.write(seq_records, filename, format=schema, **kwargs)
  
      else:
          return "".join([s.format(schema) for s in seq_records])
docs: General write function. Write phylopanda data to biopython format.
  
      Parameters
      ----------
      filename : str
          File to write string to. If no filename is given, a string
          will be returned.
  
      sequence_col : str (default='sequence')
          Sequence column name in DataFrame.
  
      id_col : str (default='id')
          ID column name in DataFrame
  
      id_only : bool (default=False)
          If True, use only the ID column to label sequences in fasta.