Answers.Body: <p>Quickly ...</p>
  <pre><code>from Bio.Alphabet import generic_protein
  from Bio.Seq import Seq
  </code></pre>
  <p>then ..</p>
  <pre><code>myprot = Seq('EXAMPLEPROT', alphabet=generic_protein)
      
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-10-27T20:55:20.600Z
Answers.Text: Thanks, I tried without setting the alphabet but `Seq` needs that parameter. Let me try another way of importing the `Alphabet`
Answers.UserDisplayName: El Dude
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-10-27T20:56:43.393Z
Answers.Text: Using `generic_alphabet` tells me this: `ValueError: Need a Nucleotide or Protein alphabet`
Answers.UserDisplayName: El Dude
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-10-27T20:58:55.510Z
Answers.Text: I was wrong, `generic_protein` does the trick, not `generic_alphabet`
Answers.UserDisplayName: El Dude
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-10-27T20:59:42.320Z
Answers.Text: Thanks @ElDude done .. many thanks.
Answers.UserDisplayName: M__
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-10-27T20:53:26.817Z
Answers.LastActivityDate: 2023-10-27T20:59:10.280Z
Answers.LastEditDate: 2023-10-27T20:59:10.280Z
Answers.UserDisplayName: M__
Body: <p>I am trying to store a GenBank file that could be read by Geneious later.
  I found an example how to create the GenBank file <a href="https://stackoverflow.com/questions/65216225/writing-and-saving-genbank-files-with-biobython-seqio-module">here</a></p>
  <p>But now I run into <code>Alphabet</code> issues.
  I tried all protein classes from the <a href="https://biopython.org/docs/1.75/api/Bio.Alphabet.IUPAC.html" rel="nofollow noreferrer">documentation</a>, but all fail with the same error:</p>
  <p><code>TypeError: Invalid alphabet found, &lt;class 'Bio.Alphabet.ProteinAlphabet'&gt;.</code></p>
  <p>I dont know what else to do here? Using <code>biopython==1.73</code></p>
  <pre><code>    record = SeqRecord.SeqRecord(
          Seq.Seq(&quot;MIRQALAVAALLLAGTAQADGLIDN&quot;, alphabet=Alphabet.ProteinAlphabet),
          id=&quot;FooBar&quot;,
      )
  
      with NamedTemporaryFile(mode=&quot;w&quot;) as genbank:
          SeqIO.write(record, genbank, &quot;genbank&quot;)
          pass
  </code></pre>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-10-29T07:30:57.867Z
Comments.Text: If possible, please show a minimum reproducible chunk of code. The code shown here does not include any library imports, so will not work as-is.
Comments.UserDisplayName: gringer
Tags: <python><genbank><biopython>
Title: BioPython SeqIO fails with Invalid Alphabet found
ThreadText: # BioPython SeqIO fails with Invalid Alphabet found
  
  (Asked by: username_0 on 2023-10-27)
  
  I am trying to store a GenBank file that could be read by Geneious later.
  I found an example how to create the GenBank file [here](https://stackoverflow.com/questions/65216225/writing-and-saving-genbank-files-with-biobython-seqio-module)
  
  But now I run into `Alphabet` issues.
  I tried all protein classes from the [documentation](https://biopython.org/docs/1.75/api/Bio.Alphabet.IUPAC.html), but all fail with the same error:
  
  `TypeError: Invalid alphabet found, <class 'Bio.Alphabet.ProteinAlphabet'>.`
  
  I dont know what else to do here? Using `biopython==1.73`
  
  ```
      record = SeqRecord.SeqRecord(
          Seq.Seq("MIRQALAVAALLLAGTAQADGLIDN", alphabet=Alphabet.ProteinAlphabet),
          id="FooBar",
      )
  
      with NamedTemporaryFile(mode="w") as genbank:
          SeqIO.write(record, genbank, "genbank")
          pass
  
  ```
  
  **Tags:** python, genbank, biopython
  
  > **Comments:**
  > **username_1**: If possible, please show a minimum reproducible chunk of code. The code shown here does not include any library imports, so will not work as-is.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2023-10-27. Score: 1 | Accepted answer
  
  Quickly ...
  
  ```
  from Bio.Alphabet import generic_protein
  from Bio.Seq import Seq
  
  ```
  
  then ..
  
  ```
  myprot = Seq('EXAMPLEPROT', alphabet=generic_protein)
      
  
  ```
  
  > **Comments:**
  > **username_0**: Thanks, I tried without setting the alphabet but `Seq` needs that parameter. Let me try another way of importing the `Alphabet`  
  > **username_0**: Using `generic_alphabet` tells me this: `ValueError: Need a Nucleotide or Protein alphabet`  
  > **username_0**: I was wrong, `generic_protein` does the trick, not `generic_alphabet`  
  > **username_2**: Thanks @username_0 done .. many thanks.  
  
  ---
  
  