Biopython SeqRecord alphabet compatibility
1
0
Entering edit mode
3 months ago

Hello,

I am using Biopython v 1.76. I have collected a list of SeqFeatures (containing specific qualifiers and a SeqFeature.FeatureLocation only) and added these to a SeqRecord containing a Seq object:

seq_record = SeqRecord(seq_obj, 
                       id = 'my_id', 
                       annotations = {'extended_up':extended_up, 
                                      'extended_down':extended_down},
                       features = features_collected)

I am trying to write the SeqRecord to a .gbk file using:

SeqIO.write(seq_record, 'plswork.gbk', 'genbank')

This gives me the following error:

ValueError: Need a Nucleotide or Protein alphabet

Initially I did not specify an alphabet for the seq_obj object used in the SeqRecord, as it looks like the alphabet concept is getting dropped and is marked as obsolete in the docs (https://biopython.org/docs/1.75/api/Bio.Alphabet.html).

However, when I got the error above, I tried to set the seq_obj alphabet to SingleLetterAlphabet - this gave the error TypeError: Invalid alphabet found, <class 'Bio.Alphabet.SingleLetterAlphabet'>

I also tried DNAAlphabet - this gave the error TypeError: Invalid alphabet found, <class 'Bio.Alphabet.DNAAlphabet'>

I'm not sure why the alphabets are invalid - they still seem to feature in the Biopython version I am using (https://biopython.org/docs/1.76/api/Bio.Alphabet.html).

Has anyone got any pointers?

Cheers!

alphabet biopython • 173 views
ADD COMMENT
2
Entering edit mode
3 months ago

Looks like I wasn't instantiating my alphabet class. I was doing Seq(string, alphabet = Alphabet.DNAAlphabet) - it should be Seq(string, alphabet = Alphabet.DNAAlphabet()). Credit - Biopython Translation Error?. I'll leave up in case anyone else has a similar issue :P

ADD COMMENT

Login before adding your answer.

Traffic: 2682 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6