Skip to content

Commit

Permalink
Merge pull request #60 from peterjc/no_alpha
Browse files Browse the repository at this point in the history
Cope without Bio.Alphabet for Biopython 1.78 onwards
  • Loading branch information
prihoda authored Sep 20, 2021
2 parents 3194cbc + 7aa4fd8 commit c836f08
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 8 deletions.
9 changes: 4 additions & 5 deletions deepbgc/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@

import six
from Bio import SeqIO
from Bio.Alphabet import SingleLetterAlphabet, generic_dna
from appdirs import user_data_dir
try:
from urllib.request import urlretrieve
Expand Down Expand Up @@ -509,10 +508,10 @@ def fix_duplicate_cds(record):


def fix_dna_alphabet(record):
if type(record.seq.alphabet) == SingleLetterAlphabet:
logging.warning('Updating record alphabet to generic_dna')
record.seq.alphabet = generic_dna
record.seq.alphabet = generic_dna
"""Explicitly label a SeqRecord as DNA (e.g. for GenBank output)."""
if "DNA" != record.annotations.get("molecule_type", ""):
logging.warning('Updating record molecule type to DNA')
record.annotations['molecule_type'] = 'DNA'


def read_compatible_csv(path):
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

install_requires = [
'argparse',
'biopython==1.76', # support for structured comments from version 1.70, removed Alphabet in version 1.78
'biopython>=1.78', # Bio.Alphabet was removed then
'scikit-learn==0.21.3', # sklearn with random forest compatibility
'pandas==0.24.1',
'numpy==1.16.1',
Expand Down
4 changes: 2 additions & 2 deletions test/unit/output/test_unit_writers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@
from Bio.Seq import Seq
from Bio.SeqRecord import SeqRecord
from Bio.SeqFeature import SeqFeature, FeatureLocation
from Bio.Alphabet import generic_dna
import os
import pytest

Expand Down Expand Up @@ -45,7 +44,8 @@ def __repr__(self):
@pytest.fixture
def processed_record(detector_name='deepbgc', detector_label='deepbgc', score_threshold=0.5):
comment_key = util.format_detector_meta_key(detector_label)
record = SeqRecord(Seq('ACTGCTCGACTGATT', alphabet=generic_dna))
record = SeqRecord(Seq('ACTGCTCGACTGATT'))
record.annotations['molecule_type'] = 'DNA'
record.annotations['structured_comment'] = collections.OrderedDict()
record.annotations['structured_comment'][comment_key] = collections.OrderedDict(
name=detector_name,
Expand Down

0 comments on commit c836f08

Please sign in to comment.