PDBe¶
Download and filter PDB files.
Environment setup¶
Run the next cell once per fresh kernel to install notebook dependencies. If you install packages in the active kernel, restart the kernel and rerun all cells.
In [ ]:
Copied!
# Cloud and local notebooks: install required runtime dependencies.
%pip install -q protein-quest[nb]
# Cloud and local notebooks: install required runtime dependencies.
%pip install -q protein-quest[nb]
Download PDB files from PDBe¶
In [1]:
Copied!
from pathlib import Path
from protein_quest.pdbe.fetch import fetch
from pathlib import Path
from protein_quest.pdbe.fetch import fetch
In [2]:
Copied!
ids = [
"4NDY", # structure of uniprot A8MT69
"4DRA", # structure of uniprot A8MT69
"1XWH", # structure of uniprot O43918
"8WAS", # structure for which there is no single pdb file
]
ids = [
"4NDY", # structure of uniprot A8MT69
"4DRA", # structure of uniprot A8MT69
"1XWH", # structure of uniprot O43918
"8WAS", # structure for which there is no single pdb file
]
In [3]:
Copied!
save_dir = Path("pdb_files")
save_dir = Path("pdb_files")
In [4]:
Copied!
files = await fetch(ids, save_dir)
files
files = await fetch(ids, save_dir)
files
Downloading PDBe mmCIF files: 100%|█████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████| 4/4 [00:00<00:00, 8.16it/s]
Out[4]:
{'4NDY': PosixPath('pdb_files/4ndy_updated.cif.gz'),
'4DRA': PosixPath('pdb_files/4dra_updated.cif.gz'),
'1XWH': PosixPath('pdb_files/1xwh_updated.cif.gz'),
'8WAS': PosixPath('pdb_files/8was_updated.cif.gz')}
In [5]:
Copied!
!ls pdb_files
!ls pdb_files
1xwh_updated.cif.gz 4ndy_updated.cif.gz 4dra_updated.cif.gz 8was_updated.cif.gz
Prepare pdb file for haddock3 or powerfit¶
Haddock3 and powerfit like to have a file with a single protein in it called chain "A". The protein-quest package can help to create such a file.
In [6]:
Copied!
from protein_quest.structure.chains import write_single_chain_structure_file
from protein_quest.structure.chains import write_single_chain_structure_file
In [11]:
Copied!
# A8MT69 4NDY B/D/H/L/M/N/U/V/W/X=8-81
# above is the identifier, chain and position info for the structure from https://www.uniprot.org/uniprotkb/A8MT69/entry#structure
output_4dny_file = write_single_chain_structure_file(
input_file=save_dir / "4ndy_updated.cif.gz", chain2keep="B", output_dir=save_dir
)
output_4dny_file
# A8MT69 4NDY B/D/H/L/M/N/U/V/W/X=8-81
# above is the identifier, chain and position info for the structure from https://www.uniprot.org/uniprotkb/A8MT69/entry#structure
output_4dny_file = write_single_chain_structure_file(
input_file=save_dir / "4ndy_updated.cif.gz", chain2keep="B", output_dir=save_dir
)
output_4dny_file
Out[11]:
PosixPath('pdb_files/4ndy_updated_B2A.cif.gz')
In [12]:
Copied!
# A8MT69 4DRA E/F/G/H=1-81
output_4dra_file = write_single_chain_structure_file(
input_file=save_dir / "4dra_updated.cif.gz", chain2keep="E", output_dir=save_dir
)
output_4dra_file
# A8MT69 4DRA E/F/G/H=1-81
output_4dra_file = write_single_chain_structure_file(
input_file=save_dir / "4dra_updated.cif.gz", chain2keep="E", output_dir=save_dir
)
output_4dra_file
Out[12]:
PosixPath('pdb_files/4dra_updated_E2A.cif.gz')
In [13]:
Copied!
output_1xwh_file = write_single_chain_structure_file(
input_file=save_dir / "1xwh_updated.cif.gz",
chain2keep="A",
output_dir=save_dir,
)
output_1xwh_file
output_1xwh_file = write_single_chain_structure_file(
input_file=save_dir / "1xwh_updated.cif.gz",
chain2keep="A",
output_dir=save_dir,
)
output_1xwh_file
Out[13]:
PosixPath('pdb_files/1xwh_updated_A2A.cif.gz')
In [14]:
Copied!
# O00268 │ 8WAS │ D/d=1-1085
output_8was_file = write_single_chain_structure_file(
input_file=save_dir / "8was_updated.cif.gz",
chain2keep="D",
output_dir=save_dir,
)
output_8was_file
# O00268 │ 8WAS │ D/d=1-1085
output_8was_file = write_single_chain_structure_file(
input_file=save_dir / "8was_updated.cif.gz",
chain2keep="D",
output_dir=save_dir,
)
output_8was_file
Out[14]:
PosixPath('pdb_files/8was_updated_D2A.cif.gz')
In [15]:
Copied!
!ls -sh -1 pdb_files/
!ls -sh -1 pdb_files/
total 4.8M 388K 1xwh_updated.cif.gz 388K 1xwh_updated_A2A.cif.gz 284K 4dra_updated.cif.gz 28K 4dra_updated_E2A.cif.gz 836K 4ndy_updated.cif.gz 32K 4ndy_updated_B2A.cif.gz 28K 4ndy_updated_E2A.cif.gz 2.9M 8was_updated.cif.gz 32K 8was_updated_D2A.cif.gz
Visualize a structure with Mol*¶
Use molviewspec to visualize one of the structures.
Cell output is absent to keep notebook size small, please run yourself to see visualization.
In [ ]:
Copied!
from molviewspec import create_builder, molstar_notebook
structure_file = Path("pdb_files/8was_updated_D2A.cif.gz")
builder = create_builder()
builder.download(url=structure_file.name).parse(format="mmcif").model_structure().component().representation().color(
color="blue"
)
molstar_notebook(state=builder.get_state(), data={structure_file.name: structure_file.read_bytes()})
from molviewspec import create_builder, molstar_notebook
structure_file = Path("pdb_files/8was_updated_D2A.cif.gz")
builder = create_builder()
builder.download(url=structure_file.name).parse(format="mmcif").model_structure().component().representation().color(
color="blue"
)
molstar_notebook(state=builder.get_state(), data={structure_file.name: structure_file.read_bytes()})
In [ ]:
Copied!