From 4c2bbded5295d9969c23dc221261d7e4befefeaa Mon Sep 17 00:00:00 2001 From: Jon Palmer Date: Sun, 25 Feb 2024 14:08:57 -0800 Subject: [PATCH] fix biopython GC change in recent versions #1000 --- funannotate/library.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/funannotate/library.py b/funannotate/library.py index 9dc7b81..7df3688 100755 --- a/funannotate/library.py +++ b/funannotate/library.py @@ -2740,7 +2740,15 @@ def dict2nucleotides2(input, prots, trans, cdstrans): def simpleFastaStats(fasta): - from Bio.SeqUtils import GC + try: + from Bio.SeqUtils import gc_fraction + + def GC(sequence): + return 100 * gc_fraction(sequence, ambiguous="ignore") + + except ImportError: + # Older versions have this: + from Bio.SeqUtils import GC from Bio.SeqIO.FastaIO import SimpleFastaParser contigs = [] @@ -9184,7 +9192,15 @@ def splitFASTA(input, outputdir): def genomeStats(input): - from Bio.SeqUtils import GC + try: + from Bio.SeqUtils import gc_fraction + + def GC(sequence): + return 100 * gc_fraction(sequence, ambiguous="ignore") + + except ImportError: + # Older versions have this: + from Bio.SeqUtils import GC lengths = [] GeeCee = []