diff --git a/rhapsody/features/PolyPhen2.py b/rhapsody/features/PolyPhen2.py index 4991395..3d516eb 100644 --- a/rhapsody/features/PolyPhen2.py +++ b/rhapsody/features/PolyPhen2.py @@ -225,10 +225,17 @@ def parsePolyPhen2output(pph2_output): # discard invalid lines lines = [l for l in lines if l.strip() and l[0] != '#'] if not lines: - msg = ("PolyPhen-2's output is empty. Please make sure that: \n" - "1) variants' format is correct " - '(\"UniprotID pos wt_aa mut_aa\") \n' - "2) query contains *human* variants \n") + msg = ( + "PolyPhen-2's output is empty. Please check file 'pph2-log.txt' " + "in the output folder for error messages from PolyPhen-2. \n" + "Typical errors include: \n" + "1) query contains *non-human* variants \n" + "2) variants' format is incorrect (e.g. " + '"UniprotID pos wt_aa mut_aa") \n' + "3) wild-type amino acids are in the wrong position on the " + "sequence (please refer to Uniprot's canonical isoform) \n" + "4) Uniprot accession number is not recognized by PolyPhen-2. \n" + ) raise RuntimeError(msg) # define a structured array pl_dtype = np.dtype([(col, 'U25') for col in pph2_columns]) diff --git a/rhapsody/features/Uniprot.py b/rhapsody/features/Uniprot.py index a3f7f14..e2cb0d3 100644 --- a/rhapsody/features/Uniprot.py +++ b/rhapsody/features/Uniprot.py @@ -33,10 +33,11 @@ def queryUniprot(*args, n_attempts=3, dt=1, **kwargs): attempt = 0 while attempt < n_attempts: try: - print(f'attempt {attempt}') _ = openURL('http://www.uniprot.org/') break except: + LOGGER.info( + f'Attempt {attempt} to contact www.uniprot.org failed') attempt += 1 time.sleep((attempt+1)*dt) else: @@ -172,7 +173,12 @@ def alignCustomPDB(self, PDB, chain='all', title=None, recover=False): assert isinstance(title, str) or title is None # parse/import pdb and assign title if isinstance(PDB, str): - pdb = pd.parsePDB(PDB, subset='calpha') + try: + pdb = pd.parsePDB(PDB, subset='calpha') + except Exception as e: + msg = ('Invalid PDB structure: the file might be ' + f'corrupted or contain errors. Error message: {e}') + raise LOGGER.error(msg) if title is None: title = os.path.basename(PDB.strip()) title = title.replace(' ', '_') diff --git a/rhapsody/predict/core.py b/rhapsody/predict/core.py index 95b7de7..a6b9c88 100644 --- a/rhapsody/predict/core.py +++ b/rhapsody/predict/core.py @@ -383,7 +383,7 @@ def getUniqueSAVcoords(self): except Exception: LOGGER.warn( 'Invalid Uniprot coordinates at line {}: {}'.format( - i, SAV['unique SAV coords'])) + i, SAV['unique SAV coords'])) uSAVcoords[i] = tuple(['?', '?', '?', -999, '?', '?']) return uSAVcoords