Skip to content

Commit 608d991

Browse files
committed
post black PDBParser.py
1 parent 577ac9d commit 608d991

File tree

1 file changed

+30
-19
lines changed

1 file changed

+30
-19
lines changed

package/MDAnalysis/topology/PDBParser.py

Lines changed: 30 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -516,27 +516,27 @@ def _parse_conect(conect):
516516
range(n_bond_atoms))
517517
return atom_id, bond_atoms
518518

519-
def fetch_pdb(PDB_IDS=None,
520-
cache_path=None,
521-
progressbar=False,
522-
file_format="pdb.gz",
523-
):
524-
519+
def fetch_pdb(
520+
PDB_IDS=None,
521+
cache_path=None,
522+
progressbar=False,
523+
file_format="pdb.gz",
524+
):
525525
"""
526526
Download one or more PDB files from the RCSB Protein Data Bank and cache them locally.
527527
528528
Given one or multiple PDB IDs, downloads the corresponding structure files in the specified
529529
format and stores them in a local cache directory. If files are cached on disk, fetch_pdb() will skip the download and use
530530
the cached version instead.
531-
531+
532532
Returns the path(s) as a string to the downloaded files.
533533
534534
Parameters
535535
----------
536536
PDB_IDS : str or sequence of str
537537
A single PDB ID as a string, or a sequence of PDB IDs to fetch.
538538
cache_path : str or pathlib.Path
539-
Directory where downloaded file(s) will be cached.
539+
Directory where downloaded file(s) will be cached.
540540
file_format : str
541541
The file extension/format to download (e.g., "cif", "pdb")
542542
progressbar : bool, optional
@@ -552,7 +552,7 @@ def fetch_pdb(PDB_IDS=None,
552552
------
553553
requests.exceptions.HTTPError
554554
If an invalid PDB code or file format is specified.
555-
555+
556556
Notes
557557
-----
558558
This function downloads using the API established here at https://www.rcsb.org/docs/programmatic-access/file-download-services.
@@ -580,29 +580,40 @@ def fetch_pdb(PDB_IDS=None,
580580
[<Universe with 3816 atoms>, <Universe with 2824 atoms>]
581581
582582
"""
583-
584-
583+
585584
try:
586585
import pooch
587586
except ModuleNotFoundError:
588-
raise ModuleNotFoundError('pooch is needed as a dependency for fetch_pdb()')
587+
raise ModuleNotFoundError(
588+
"pooch is needed as a dependency for fetch_pdb()"
589+
)
589590

590591
if isinstance(PDB_IDS, str):
591592
PDB_IDS = (PDB_IDS,)
592593

593594
if cache_path is None:
594-
cache_path = pooch.os_cache('pdb_cache')
595+
cache_path = pooch.os_cache("pdb_cache")
596+
597+
# Have to do this dictionary approach instead of using Pooch.retrieve in order to prevent the hardcoded known_hash warning from showing up.
598+
registry_dictionary = {
599+
f"{PDB_ID}.{file_format}": None for PDB_ID in PDB_IDS
600+
}
595601

596-
# Have to do this dictionary approach instead of using Pooch.retrieve in order to prevent the hardcoded known_hash warning from showing up
597-
registry_dictionary = {f'{PDB_ID}.{file_format}': None for PDB_ID in PDB_IDS}
598-
599602
downloader = pooch.create(
600603
path=cache_path,
601604
base_url="https://files.wwpdb.org/download/",
602-
registry=registry_dictionary
605+
registry=registry_dictionary,
603606
)
604607

605608
if len(PDB_IDS) == 1:
606-
return str(downloader.fetch(fname=tuple(registry_dictionary.keys())[0], progressbar=progressbar))
609+
return str(
610+
downloader.fetch(
611+
fname=tuple(registry_dictionary.keys())[0],
612+
progressbar=progressbar,
613+
)
614+
)
607615
else:
608-
return [downloader.fetch(fname=file_name, progressbar=progressbar) for file_name in registry_dictionary.keys()]
616+
return [
617+
downloader.fetch(fname=file_name, progressbar=progressbar)
618+
for file_name in registry_dictionary.keys()
619+
]

0 commit comments

Comments
 (0)