chundruv / GFF-to-GenBank

Convert GFF file to GenBank file format while extracting the sequences between the annotated regions
7 stars 2 forks source link

Alphabet no longer supported #1

Closed glichtenstein closed 1 year ago

glichtenstein commented 3 years ago

Hi @chundruv

I am in the need of using your tool, but after installing BCBio and biopython I have encountered an error:

Traceback (most recent call last): File "/home/lgabriel/apps/GFF-to-GenBank/gff_to_genbank_edit.py", line 16, in from Bio.Alphabet import generic_dna File "/home/lgabriel/miniconda3/envs/emboss/lib/python3.9/site-packages/Bio/Alphabet/init.py", line 20, in raise ImportError( ImportError: Bio.Alphabet has been removed from Biopython. In many cases, the alphabet can simply be ignored and removed from scripts. In a few cases, you may need to specify the molecule_type as an annotation on a SeqRecord for your script to work correctly. Please see https://biopython.org/wiki/Alphabet for more information.

I have found a workaround in the above mentioned site: https://biopython.org/wiki/Alphabet and applied it here:

import sys
import os

try:
    from Bio.Alphabet import generic_dna
except ImportError:
    generic_dna = "DNA"

from Bio import SeqIO
from Bio import Seq
from Bio import SeqFeature

from BCBio import GFF

def main(gff_file, fasta_file):
    out_file = "%s.gb" % os.path.splitext(gff_file)[0]
    fasta_input = SeqIO.to_dict(SeqIO.parse(fasta_file, "fasta", generic_dna))

But I was not successful, it returned a smaller error though:

Traceback (most recent call last): File "/home/lgabriel/apps/GFF-to-GenBank-BAK/gff_to_genbank_edit.py", line 94, in main(*sys.argv[1:]) File "/home/lgabriel/apps/GFF-to-GenBank-BAK/gff_to_genbank_edit.py", line 28, in main fasta_input = SeqIO.to_dict(SeqIO.parse(fasta_file, "fasta", "DNA")) File "/home/lgabriel/miniconda3/envs/emboss/lib/python3.9/site-packages/Bio/SeqIO/init.py", line 601, in parse raise ValueError("The alphabet argument is no longer supported") ValueError: The alphabet argument is no longer supported

Do you think you could find a workaround? or will you suggest me a different tool or approach? Thank you very much, Best wishes glicht

renyi2517 commented 1 year ago

Meet the same problem

I had solved it by downgrade Biopython to v1.77