Skip to content

Commit

Permalink
redefine prody.queryUniprot() to check for no internet connection
Browse files Browse the repository at this point in the history
  • Loading branch information
luponzo86 committed Feb 29, 2020
1 parent 802a8ba commit 04bd2fd
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 5 deletions.
3 changes: 2 additions & 1 deletion rhapsody/features/PolyPhen2.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,11 @@
import requests
import datetime
import numpy as np
from prody import LOGGER, queryUniprot
from prody import LOGGER
from requests.adapters import HTTPAdapter
from requests.packages.urllib3.util.retry import Retry
from math import log
from .Uniprot import queryUniprot

__author__ = "Luca Ponzoni"
__date__ = "December 2019"
Expand Down
18 changes: 14 additions & 4 deletions rhapsody/features/Uniprot.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import numpy as np
import prody as pd
from prody import LOGGER, SETTINGS
from prody.utilities import openURL
from tqdm import tqdm
from Bio.pairwise2 import align as bioalign
from Bio.pairwise2 import format_alignment
Expand All @@ -20,7 +21,16 @@
__email__ = "[email protected]"
__status__ = "Production"

__all__ = ['UniprotMapping', 'mapSAVs2PDB', 'seqScanning', 'printSAVlist']
__all__ = ['queryUniprot', 'UniprotMapping', 'mapSAVs2PDB',
'seqScanning', 'printSAVlist']


def queryUniprot(*args, **kwargs):
"""
Redefine prody function to check for no internet connection
"""
_ = openURL('http://www.uniprot.org/')
return pd.queryUniprot(*args, **kwargs)


class UniprotMapping:
Expand Down Expand Up @@ -52,7 +62,7 @@ def refresh(self):
delete precomputed alignments.
"""
# import Uniprot record and official accession number
self.fullRecord = pd.queryUniprot(self.acc)
self.fullRecord = queryUniprot(self.acc)
self.uniq_acc = self.fullRecord['accession 0']
# import main sequence and PDB records
rec = self.fullRecord
Expand Down Expand Up @@ -393,7 +403,7 @@ def recoverPickle(self, filename=None, folder=None, days=30, **kwargs):
pickle_path = os.path.join(folder, filename)
if not os.path.isfile(pickle_path):
# import unique accession number
acc = pd.queryUniprot(self.acc)['accession 0']
acc = queryUniprot(self.acc)['accession 0']
filename = 'UniprotMap-' + acc + '.pkl'
pickle_path = os.path.join(folder, filename)
else:
Expand Down Expand Up @@ -878,7 +888,7 @@ def seqScanning(Uniprot_coord, sequence=None):
assert len(coord) < 3, "Invalid format. Examples: 'Q9BW27' or 'Q9BW27 10'."
aa_list = 'ACDEFGHIKLMNPQRSTVWY'
if sequence is None:
Uniprot_record = pd.queryUniprot(coord[0])
Uniprot_record = queryUniprot(coord[0])
sequence = Uniprot_record['sequence 0'].replace("\n", "")
else:
assert isinstance(sequence, str), "Must be a string."
Expand Down

0 comments on commit 04bd2fd

Please sign in to comment.