Reset repository and upload final project (part 7)
Browse filesThis view is limited to 50 files because it contains too many changes. See raw diff
- .venv_haddock/lib/python3.12/site-packages/haddock/clis/restraints/z_surface_restraints.py +745 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/clis/wrapper_haddock_restraints.py +20 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/._bin +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/._toppar +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/bin/._aarch64-linux.bin +3 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/bin/._arm64-darwin.bin +3 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/bin/._x86_64-darwin.bin +3 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/bin/._x86_64-linux.bin +3 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/bin/aarch64-linux.bin +3 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/bin/arm64-darwin.bin +3 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/bin/x86_64-darwin.bin +3 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/bin/x86_64-linux.bin +3 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._boxtyp20.pdb +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._carbohydrate.param +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._carbohydrate.top +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._cofactors.param +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._cofactors.pep +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._cofactors.top +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._dmso.pdb +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._dna-rna-1.3.link +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._dna-rna-CG-MARTINI-2-1p-break.top +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._dna-rna-CG-MARTINI-2-1p.link +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._dna-rna-CG-MARTINI-2-1p.param +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._dna-rna-CG-MARTINI-2-1p.top +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._dna-rna-allatom-hj-opls-1.3.param +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._dna-rna-allatom-hj-opls-1.3.top +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._dna-rna-pho-1.3.link +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._dna_break.top +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._fragment_probes.param +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._fragment_probes.top +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._heme.pdb +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._heme.psf +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._hemeB.pdb +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._hemeB.psf +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._hemes-allhdg.param +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._hemes-allhdg.top +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._hemes.pep +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._initial_positions +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._ion.param +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._ion.top +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._metalcenter.tbl +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._par_axis.pro +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._par_axis_dani.pro +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._protein-CG-Martini-2-2.link +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._protein-CG-Martini-2-2.param +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._protein-CG-Martini-2-2.top +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._protein-CG-Martini.link +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._protein-CG-Martini.param +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._protein-CG-Martini.top +0 -0
- .venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._protein-allhdg5-4-noCter.link +0 -0
.venv_haddock/lib/python3.12/site-packages/haddock/clis/restraints/z_surface_restraints.py
ADDED
|
@@ -0,0 +1,745 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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 |
+
input pdb structure and residue selection.
|
| 5 |
+
|
| 6 |
+
Usage:
|
| 7 |
+
haddock3-restraints z-surface-restraints
|
| 8 |
+
--pdb <path/to/the/structure.pdb>
|
| 9 |
+
--residues <list of coma separated residue index>
|
| 10 |
+
--output <base/path/where/to/output/data>
|
| 11 |
+
--spacing <spacing_between_two_beads>
|
| 12 |
+
--x-size <size_in_x_dim>
|
| 13 |
+
--y-size <size_in_y_dim>
|
| 14 |
+
--z-padding <additional_z_padding_between_two_extrema_plans>
|
| 15 |
+
|
| 16 |
+
e.g:
|
| 17 |
+
haddock3-restraints z-surface-restraints
|
| 18 |
+
--pdb mystructure.pdb
|
| 19 |
+
--residues 1,2,3 7,8,9
|
| 20 |
+
--spacing 20
|
| 21 |
+
--x-size 200
|
| 22 |
+
--y-size 200
|
| 23 |
+
--z-padding 5
|
| 24 |
+
--output myZrestaints
|
| 25 |
+
"""
|
| 26 |
+
|
| 27 |
+
import logging
|
| 28 |
+
import os
|
| 29 |
+
from pathlib import Path
|
| 30 |
+
|
| 31 |
+
from haddock.core.typing import Generator, Optional, Union
|
| 32 |
+
from haddock.libs.librestraints import read_structure, calc_euclidean
|
| 33 |
+
|
| 34 |
+
|
| 35 |
+
# As this script is a subcommand of the `haddock3-restraints` cli,
|
| 36 |
+
# it requires its own options and arguments that are managed here.
|
| 37 |
+
def add_z_surf_restraints_arguments(z_surf_restraints_subcommand):
|
| 38 |
+
"""Add arguments to the z_plan subcommand."""
|
| 39 |
+
z_surf_restraints_subcommand.add_argument(
|
| 40 |
+
"--pdb", "-p",
|
| 41 |
+
help="Path to a pdb file.",
|
| 42 |
+
required=True,
|
| 43 |
+
default='',
|
| 44 |
+
type=str,
|
| 45 |
+
)
|
| 46 |
+
|
| 47 |
+
z_surf_restraints_subcommand.add_argument(
|
| 48 |
+
"--residues", "-r",
|
| 49 |
+
help=(
|
| 50 |
+
"List of comma separated residues (can be multiple selections). "
|
| 51 |
+
"Example 1,2,3 7,8,9 for two selections."
|
| 52 |
+
),
|
| 53 |
+
required=False,
|
| 54 |
+
default=[],
|
| 55 |
+
nargs='+',
|
| 56 |
+
type=str,
|
| 57 |
+
)
|
| 58 |
+
|
| 59 |
+
z_surf_restraints_subcommand.add_argument(
|
| 60 |
+
"--output", "-o",
|
| 61 |
+
help=(
|
| 62 |
+
"Base output path. This script will generate two files, "
|
| 63 |
+
"therefore no extention needed here"
|
| 64 |
+
),
|
| 65 |
+
required=False,
|
| 66 |
+
default=None,
|
| 67 |
+
type=str,
|
| 68 |
+
)
|
| 69 |
+
|
| 70 |
+
z_surf_restraints_subcommand.add_argument(
|
| 71 |
+
"--spacing", "-s",
|
| 72 |
+
type=float,
|
| 73 |
+
help="Spacing between two beads (A)",
|
| 74 |
+
required=False,
|
| 75 |
+
default=20,
|
| 76 |
+
)
|
| 77 |
+
|
| 78 |
+
z_surf_restraints_subcommand.add_argument(
|
| 79 |
+
"--x-size",
|
| 80 |
+
"-x",
|
| 81 |
+
help="Size of the plan in X dimension (A)",
|
| 82 |
+
required=False,
|
| 83 |
+
default=100,
|
| 84 |
+
type=float,
|
| 85 |
+
)
|
| 86 |
+
|
| 87 |
+
z_surf_restraints_subcommand.add_argument(
|
| 88 |
+
"--y-size",
|
| 89 |
+
"-y",
|
| 90 |
+
help="Size of the plan in Y dimension",
|
| 91 |
+
required=False,
|
| 92 |
+
default=100,
|
| 93 |
+
type=float,
|
| 94 |
+
)
|
| 95 |
+
|
| 96 |
+
z_surf_restraints_subcommand.add_argument(
|
| 97 |
+
"--z-padding",
|
| 98 |
+
"-z",
|
| 99 |
+
help="Additional padding between two external plans.",
|
| 100 |
+
required=False,
|
| 101 |
+
default=5.0,
|
| 102 |
+
type=float,
|
| 103 |
+
)
|
| 104 |
+
|
| 105 |
+
z_surf_restraints_subcommand.add_argument(
|
| 106 |
+
"--log_level",
|
| 107 |
+
default='INFO',
|
| 108 |
+
choices=('DEBUG', 'INFO', 'WARNING', 'ERROR', 'CRITICAL'),
|
| 109 |
+
help="Logging level",
|
| 110 |
+
required=False,
|
| 111 |
+
)
|
| 112 |
+
|
| 113 |
+
return z_surf_restraints_subcommand
|
| 114 |
+
|
| 115 |
+
|
| 116 |
+
def setup_logging(log_level: str = "INFO") -> None:
|
| 117 |
+
"""Set log level and format."""
|
| 118 |
+
logging.basicConfig(
|
| 119 |
+
level=log_level,
|
| 120 |
+
format='%(asctime)s L%(lineno)d %(levelname)s - %(message)s',
|
| 121 |
+
datefmt='%d/%m/%Y %H:%M:%S',
|
| 122 |
+
)
|
| 123 |
+
|
| 124 |
+
|
| 125 |
+
############################
|
| 126 |
+
# SET OF USEFULL FUNCTIONS #
|
| 127 |
+
############################
|
| 128 |
+
def load_selected_resiudes_coords(
|
| 129 |
+
pdb_fpath: Union[str, Path],
|
| 130 |
+
selections: dict[str, list[int]],
|
| 131 |
+
) -> tuple[dict[str, list[tuple[float, float, float]]], list[str], list[str]]:
|
| 132 |
+
"""Load coordinates of selected residues.
|
| 133 |
+
|
| 134 |
+
Parameters
|
| 135 |
+
----------
|
| 136 |
+
pdb_fpath : Union[str, Path]
|
| 137 |
+
Path to the PDB file to be parsed.
|
| 138 |
+
selections : dict[str, list[int]]
|
| 139 |
+
Dictionary holding the various residues indices for each selection.
|
| 140 |
+
|
| 141 |
+
Returns
|
| 142 |
+
-------
|
| 143 |
+
selection_coords: dict[str, list[tuple[float, float, float]]]
|
| 144 |
+
Dictionary holding the various Calpha coordinates for each selection.
|
| 145 |
+
"""
|
| 146 |
+
# Load structures atom coordinates
|
| 147 |
+
pdb_atoms = read_structure(pdb_fpath)
|
| 148 |
+
# Set paring variables
|
| 149 |
+
selection_coords: dict[str, list[tuple[float, float, float]]] = {}
|
| 150 |
+
selected_chains: list[str] = []
|
| 151 |
+
selected_atoms: list[str] = []
|
| 152 |
+
# Loop over atoms
|
| 153 |
+
for chain, resi, atname, coords in pdb_atoms:
|
| 154 |
+
# Simplify the probleme to Calpha/Phosphates/BackBone atoms only
|
| 155 |
+
# FIXME: maybe change P to C1 or C9 ?
|
| 156 |
+
if not atname in ("CA", "P", "BB", ):
|
| 157 |
+
continue
|
| 158 |
+
# Loop over selections
|
| 159 |
+
for selection, sele_resis in selections.items():
|
| 160 |
+
# Check if residue of interest
|
| 161 |
+
if resi in sele_resis:
|
| 162 |
+
# Make sure the key is created
|
| 163 |
+
selection_coords.setdefault(selection, [])
|
| 164 |
+
# Hold this coordinates
|
| 165 |
+
selection_coords[selection].append(coords)
|
| 166 |
+
# Also add chain and atom type
|
| 167 |
+
selected_chains.append(chain)
|
| 168 |
+
selected_atoms.append(atname)
|
| 169 |
+
set_selected_chains = list(set(selected_chains))
|
| 170 |
+
set_selected_atoms = list(set(selected_atoms))
|
| 171 |
+
return selection_coords, set_selected_chains, set_selected_atoms
|
| 172 |
+
|
| 173 |
+
|
| 174 |
+
def compute_barycenter(
|
| 175 |
+
resi_coords: list[tuple[float, float, float]],
|
| 176 |
+
) -> tuple[float, float, float]:
|
| 177 |
+
"""Compute center of mass of multiple resiudes coordinates.
|
| 178 |
+
|
| 179 |
+
Parameters
|
| 180 |
+
----------
|
| 181 |
+
resi_coords : list[tuple[float, float, float]]
|
| 182 |
+
List of Calpha coordinates.
|
| 183 |
+
|
| 184 |
+
Returns
|
| 185 |
+
-------
|
| 186 |
+
barycenter : tuple[float, float, float]
|
| 187 |
+
Corrdinates of the center of mass.
|
| 188 |
+
"""
|
| 189 |
+
# Combine coordinates
|
| 190 |
+
xs, ys, zs = [], [], []
|
| 191 |
+
for coords in resi_coords:
|
| 192 |
+
xs.append(coords[0])
|
| 193 |
+
ys.append(coords[1])
|
| 194 |
+
zs.append(coords[2])
|
| 195 |
+
# Compute average
|
| 196 |
+
x_avg = sum(xs) / len(xs)
|
| 197 |
+
y_avg = sum(ys) / len(ys)
|
| 198 |
+
z_avg = sum(zs) / len(zs)
|
| 199 |
+
# Return barycenter
|
| 200 |
+
barycenter = (x_avg, y_avg, z_avg)
|
| 201 |
+
return barycenter
|
| 202 |
+
|
| 203 |
+
|
| 204 |
+
def load_selections(residues_lists: list[str]) -> dict[str, list[int]]:
|
| 205 |
+
"""Split and cast residues from an initial string to list.
|
| 206 |
+
|
| 207 |
+
Parameters
|
| 208 |
+
----------
|
| 209 |
+
residues_lists : list[str]
|
| 210 |
+
List of strings containing coma separated resiudes indices.
|
| 211 |
+
|
| 212 |
+
Returns
|
| 213 |
+
-------
|
| 214 |
+
selections: dict[str, list[int]]
|
| 215 |
+
Dictionary of resiudes indices.
|
| 216 |
+
"""
|
| 217 |
+
selections: dict[str, list[int]] = {}
|
| 218 |
+
for listid, str_resiudes in enumerate(residues_lists, start=1):
|
| 219 |
+
resid_indices: list[int] = []
|
| 220 |
+
selection_key = f"selection_{listid}"
|
| 221 |
+
for strresid in str_resiudes.split(','):
|
| 222 |
+
try:
|
| 223 |
+
resid = int(strresid)
|
| 224 |
+
except Exception as _e:
|
| 225 |
+
msg = f"Could not cast residue {strresid} from {selection_key}"
|
| 226 |
+
logging.warning(msg)
|
| 227 |
+
else:
|
| 228 |
+
resid_indices.append(resid)
|
| 229 |
+
if resid_indices == []:
|
| 230 |
+
err_msg = f"Not considering {selection_key} as it is empty !"
|
| 231 |
+
logging.error(err_msg)
|
| 232 |
+
else:
|
| 233 |
+
selections[selection_key] = resid_indices
|
| 234 |
+
return selections
|
| 235 |
+
|
| 236 |
+
|
| 237 |
+
def get_z_coords(
|
| 238 |
+
select_coords: dict[str, list[tuple[float, float, float]]],
|
| 239 |
+
padding: float = 5.0,
|
| 240 |
+
) -> dict[str, float]:
|
| 241 |
+
"""Generate z-coordinates from selection of residues.
|
| 242 |
+
|
| 243 |
+
Here the idea is to find the most distant points between selections,
|
| 244 |
+
and project it on a Z axis to be able to later orient the protein.
|
| 245 |
+
|
| 246 |
+
Parameters
|
| 247 |
+
----------
|
| 248 |
+
selection_coords: dict[str, list[tuple[float, float, float]]]
|
| 249 |
+
Dictionary holding the various Calpha coordinates for each selection.
|
| 250 |
+
padding : float, optional
|
| 251 |
+
Extra padding (in Angstrom) of z-coordinate, by default 10
|
| 252 |
+
|
| 253 |
+
Returns
|
| 254 |
+
-------
|
| 255 |
+
selection_z : dict[str, float]
|
| 256 |
+
Z coodrinate for each selection.
|
| 257 |
+
"""
|
| 258 |
+
# Default when less than 1 selection was made
|
| 259 |
+
if select_coords == {}:
|
| 260 |
+
return {"z_1": 0}
|
| 261 |
+
elif len(select_coords.keys()) == 1:
|
| 262 |
+
return {s: 0 for s in select_coords.keys()}
|
| 263 |
+
|
| 264 |
+
# Compute geometrical center
|
| 265 |
+
select_centers = {
|
| 266 |
+
select: compute_barycenter(select_resids_coords)
|
| 267 |
+
for select, select_resids_coords in select_coords.items()
|
| 268 |
+
}
|
| 269 |
+
# Compute distances
|
| 270 |
+
dists: dict[str, dict[str, float]] = {s: {} for s in select_centers.keys()}
|
| 271 |
+
max_dist: float = -1
|
| 272 |
+
max_dist_keys: list[str] = []
|
| 273 |
+
for select, center in select_centers.items():
|
| 274 |
+
for select2, center2 in select_centers.items():
|
| 275 |
+
if select == select2:
|
| 276 |
+
continue
|
| 277 |
+
# Compute dist
|
| 278 |
+
dist = calc_euclidean(center, center2)
|
| 279 |
+
# Hold data
|
| 280 |
+
dists[select][select2] = dist
|
| 281 |
+
dists[select2][select] = dist
|
| 282 |
+
# Define max
|
| 283 |
+
if max_dist < dist:
|
| 284 |
+
max_dist = dist
|
| 285 |
+
max_dist_keys = [select, select2]
|
| 286 |
+
# Initiate z-coords boundaries
|
| 287 |
+
max_z = (padding + max_dist) / 2
|
| 288 |
+
# Compute Z coords for external surfaces
|
| 289 |
+
selection_z = {
|
| 290 |
+
max_dist_keys[0]: max_z,
|
| 291 |
+
max_dist_keys[1]: -max_z,
|
| 292 |
+
}
|
| 293 |
+
# Compute Z coords for internal surfaces (when nb. selections >= 3)
|
| 294 |
+
for select, dist in dists.items():
|
| 295 |
+
# If the selection is part of the external surfaces
|
| 296 |
+
if select in max_dist_keys:
|
| 297 |
+
continue
|
| 298 |
+
# Compute location of z coordinate
|
| 299 |
+
dist_to_upper = max_z - dist[max_dist_keys[0]]
|
| 300 |
+
dist_to_lower = dist[max_dist_keys[1]] - max_z
|
| 301 |
+
select_z_coord = (dist_to_upper + dist_to_lower) / 2
|
| 302 |
+
# Hold data
|
| 303 |
+
selection_z[select] = select_z_coord
|
| 304 |
+
|
| 305 |
+
return selection_z
|
| 306 |
+
|
| 307 |
+
|
| 308 |
+
def gen_z_restraints(
|
| 309 |
+
res_select: dict[str, list[int]],
|
| 310 |
+
selection_z: dict[str, float],
|
| 311 |
+
rest_dist: float = 7.5,
|
| 312 |
+
segids: list[str] = ["A"],
|
| 313 |
+
atome_types: list[str] = ["CA"],
|
| 314 |
+
) -> str:
|
| 315 |
+
"""Generate set of z ambiguous restraints according to residue selections.
|
| 316 |
+
|
| 317 |
+
Parameters
|
| 318 |
+
----------
|
| 319 |
+
res_select : dict[str, list[int]]
|
| 320 |
+
Dictionary holding the various residues indices for each selection.
|
| 321 |
+
selection_z : dict[str, float]
|
| 322 |
+
Z coodrinate for each selection.
|
| 323 |
+
rest_dist : float, optional
|
| 324 |
+
Upper boundary (in Angstrom) of satisfied restraints, by default 7.5
|
| 325 |
+
|
| 326 |
+
Returns
|
| 327 |
+
-------
|
| 328 |
+
all_restraints : str
|
| 329 |
+
A string containing the AIR restraints.
|
| 330 |
+
"""
|
| 331 |
+
# Gather all coordinates
|
| 332 |
+
all_z_coords = [zcoord for zcoord in selection_z.values()]
|
| 333 |
+
# Point min and max values
|
| 334 |
+
minz = min(all_z_coords)
|
| 335 |
+
maxz = max(all_z_coords)
|
| 336 |
+
# Initiate restraints holder
|
| 337 |
+
restraints: list[str] = []
|
| 338 |
+
# z_padding variable is used as a padding for the Z beads selection.
|
| 339 |
+
# This is meant for the CNS selection method using lt(lower than)
|
| 340 |
+
# and gt (geater than) rather than equal to.
|
| 341 |
+
z_padding: float = 0.1
|
| 342 |
+
# Compile chain selection
|
| 343 |
+
chain_selection_string = _compile_multiple_cns_selections(
|
| 344 |
+
"segid", segids,
|
| 345 |
+
)
|
| 346 |
+
# Compile atome selection
|
| 347 |
+
atom_selection_string = _compile_multiple_cns_selections(
|
| 348 |
+
"name", atome_types,
|
| 349 |
+
)
|
| 350 |
+
# Loop over selections
|
| 351 |
+
for select in res_select.keys():
|
| 352 |
+
# Point data
|
| 353 |
+
residues = res_select[select]
|
| 354 |
+
z_coord = selection_z[select]
|
| 355 |
+
# Add comment
|
| 356 |
+
list_residues = ",".join([str(r) for r in residues])
|
| 357 |
+
restraints.append(f"! z restraints for {select}: {list_residues}")
|
| 358 |
+
# Loop over residues selection
|
| 359 |
+
for resid in residues:
|
| 360 |
+
# Compute lower/greater than z-coord
|
| 361 |
+
lt_coord = z_coord + z_padding
|
| 362 |
+
gt_coord = z_coord - z_padding
|
| 363 |
+
# If the lower Z coordinate plan
|
| 364 |
+
if z_coord == minz:
|
| 365 |
+
rest = (
|
| 366 |
+
f"assign (resid {resid:>7d} and "
|
| 367 |
+
f"{atom_selection_string} and {chain_selection_string}) "
|
| 368 |
+
f"(name SHA and attr z lt {lt_coord:>-8.2f}) "
|
| 369 |
+
f"{rest_dist:.1f} {rest_dist:.1f} 0.0"
|
| 370 |
+
)
|
| 371 |
+
# If the upper Z coordinate plan
|
| 372 |
+
elif z_coord == maxz:
|
| 373 |
+
rest = (
|
| 374 |
+
f"assign (resid {resid:>7d} and "
|
| 375 |
+
f"{atom_selection_string} and {chain_selection_string}) "
|
| 376 |
+
f"(name SHA and attr z gt {gt_coord:>-8.2f}) "
|
| 377 |
+
f"{rest_dist:.1f} {rest_dist:.1f} 0.0"
|
| 378 |
+
)
|
| 379 |
+
# If in between lower and upper plans (when nb. plans >= 3)
|
| 380 |
+
else:
|
| 381 |
+
rest = (
|
| 382 |
+
f"assign (resid {resid:>7d} and "
|
| 383 |
+
f"{atom_selection_string} and {chain_selection_string}) "
|
| 384 |
+
f"(name SHA and attr z lt {lt_coord:>-8.2f} "
|
| 385 |
+
f"and attr z gt {gt_coord:>-8.2f}) "
|
| 386 |
+
f"{rest_dist:.1f} {rest_dist:.1f} 0.0"
|
| 387 |
+
)
|
| 388 |
+
restraints.append(rest)
|
| 389 |
+
all_restraints = os.linesep.join(restraints)
|
| 390 |
+
return all_restraints
|
| 391 |
+
|
| 392 |
+
|
| 393 |
+
def _compile_multiple_cns_selections(
|
| 394 |
+
selection_key: str,
|
| 395 |
+
selections: list[str],
|
| 396 |
+
logical_operator: str = 'OR',
|
| 397 |
+
) -> str:
|
| 398 |
+
"""Generate a selection from multiple ones using logical operator.
|
| 399 |
+
|
| 400 |
+
Parameters
|
| 401 |
+
----------
|
| 402 |
+
selection_key : str
|
| 403 |
+
Name of the selection key. (e.g.: segid, name, resid, ...)
|
| 404 |
+
selections : list[str]
|
| 405 |
+
List of selections.
|
| 406 |
+
|
| 407 |
+
Returns
|
| 408 |
+
-------
|
| 409 |
+
combined_selection : str
|
| 410 |
+
The combined selection.
|
| 411 |
+
"""
|
| 412 |
+
assert len(selections) >= 1
|
| 413 |
+
if len(selections) == 1:
|
| 414 |
+
return f"{selection_key} {selections[0]}"
|
| 415 |
+
compiled_selections = [
|
| 416 |
+
f"{selection_key} {select}"
|
| 417 |
+
for select in selections
|
| 418 |
+
]
|
| 419 |
+
joined_selections = f" {logical_operator} ".join(compiled_selections)
|
| 420 |
+
combined_selection = f"({joined_selections})"
|
| 421 |
+
return combined_selection
|
| 422 |
+
|
| 423 |
+
|
| 424 |
+
def output_data(
|
| 425 |
+
restraints: str,
|
| 426 |
+
plans: str,
|
| 427 |
+
output: Optional[Union[str, Path]] = None,
|
| 428 |
+
) -> tuple[str, str]:
|
| 429 |
+
"""Write output files.
|
| 430 |
+
|
| 431 |
+
Parameters
|
| 432 |
+
----------
|
| 433 |
+
restraints : str
|
| 434 |
+
String containing the ambiguous restraints.
|
| 435 |
+
plans : str
|
| 436 |
+
String containing shape beads coordinates as PDB file.
|
| 437 |
+
output : Optional[Union[str, Path]], optional
|
| 438 |
+
Base output path, by default None
|
| 439 |
+
|
| 440 |
+
Returns
|
| 441 |
+
-------
|
| 442 |
+
restraints_fpath: str
|
| 443 |
+
Path to the generated AIRs.
|
| 444 |
+
beadplans_fpath : str
|
| 445 |
+
Path to the generated PDB file containing beads.
|
| 446 |
+
"""
|
| 447 |
+
# Define base output path if not given
|
| 448 |
+
if not output:
|
| 449 |
+
output = 'Zrestraints'
|
| 450 |
+
# Write restraints
|
| 451 |
+
restraints_fpath = f"{output}.tbl"
|
| 452 |
+
with open(restraints_fpath, 'w') as filout:
|
| 453 |
+
filout.write(restraints)
|
| 454 |
+
# Write restraints
|
| 455 |
+
beadplans_fpath = f"{output}_beads.pdb"
|
| 456 |
+
with open(beadplans_fpath, 'w') as filout:
|
| 457 |
+
filout.write(plans)
|
| 458 |
+
# Return filepaths
|
| 459 |
+
return restraints_fpath, beadplans_fpath
|
| 460 |
+
|
| 461 |
+
|
| 462 |
+
def gen_bead_plans(
|
| 463 |
+
spacing: float = 40,
|
| 464 |
+
x_size: float = 200,
|
| 465 |
+
y_size: float = 200,
|
| 466 |
+
z_coords: Optional[list[float]] = None,
|
| 467 |
+
) -> str:
|
| 468 |
+
"""Generate multiple bead plans.
|
| 469 |
+
|
| 470 |
+
Parameters
|
| 471 |
+
----------
|
| 472 |
+
spacing : float, optional
|
| 473 |
+
Spacing (in Angstrom) between beads in same dimension, by default 40
|
| 474 |
+
x_size : float, optional
|
| 475 |
+
Width (in Angstrom) of the plan, by default 200
|
| 476 |
+
y_size : float, optional
|
| 477 |
+
Height (in Angstrom) of the plan, by default 200
|
| 478 |
+
z_coords : Optional[list[float]], optional
|
| 479 |
+
List of z-coordinates where to generate plans, by default None
|
| 480 |
+
|
| 481 |
+
Returns
|
| 482 |
+
-------
|
| 483 |
+
bead_plans : str
|
| 484 |
+
A PDB file containing multiple plans.
|
| 485 |
+
"""
|
| 486 |
+
# Presets
|
| 487 |
+
bead_plans: str = ''
|
| 488 |
+
resindex: int = 0
|
| 489 |
+
if not z_coords:
|
| 490 |
+
z_coords = [0]
|
| 491 |
+
# Loop over z-coords
|
| 492 |
+
for z in z_coords:
|
| 493 |
+
plan, resindex = bead_plan(
|
| 494 |
+
spacing=spacing,
|
| 495 |
+
x_size=x_size,
|
| 496 |
+
y_size=y_size,
|
| 497 |
+
z_coord=z,
|
| 498 |
+
resindex=resindex,
|
| 499 |
+
)
|
| 500 |
+
bead_plans += plan
|
| 501 |
+
return bead_plans
|
| 502 |
+
|
| 503 |
+
|
| 504 |
+
def bead_plan(
|
| 505 |
+
spacing: float = 40,
|
| 506 |
+
x_size: float = 200,
|
| 507 |
+
y_size: float = 200,
|
| 508 |
+
z_coord: float = 0,
|
| 509 |
+
resindex: int = 0,
|
| 510 |
+
) -> tuple[str, int]:
|
| 511 |
+
"""Generate a PDB plan made of beads.
|
| 512 |
+
|
| 513 |
+
Parameters
|
| 514 |
+
----------
|
| 515 |
+
spacing : float, optional
|
| 516 |
+
Spacing (in Angstrom) between beads in same dimension, by default 40
|
| 517 |
+
x_size : float, optional
|
| 518 |
+
Width (in Angstrom) of the plan, by default 200
|
| 519 |
+
y_size : float, optional
|
| 520 |
+
Height (in Angstrom) of the plan, by default 200
|
| 521 |
+
z_coord : float, optional
|
| 522 |
+
Z-coordinate where to generate the plan, by default 0
|
| 523 |
+
resindex : int, optional
|
| 524 |
+
From which resiude to start the , by default 0
|
| 525 |
+
|
| 526 |
+
Returns
|
| 527 |
+
-------
|
| 528 |
+
plan : str
|
| 529 |
+
The PDB plan made of beads.
|
| 530 |
+
resindex : int
|
| 531 |
+
Index of the last residue index added.
|
| 532 |
+
"""
|
| 533 |
+
plan_beads: list[str] = []
|
| 534 |
+
# Loop over x coords
|
| 535 |
+
for x_coord in step_coords(x_size, spacing):
|
| 536 |
+
# Loop over y coords
|
| 537 |
+
for y_coord in step_coords(y_size, spacing):
|
| 538 |
+
resindex += 1
|
| 539 |
+
# Generate new bead
|
| 540 |
+
bead = shape_bead(x_coord, y_coord, z_coord, resindex)
|
| 541 |
+
plan_beads.append(bead)
|
| 542 |
+
# Finalize plan
|
| 543 |
+
plan = ''.join(plan_beads)
|
| 544 |
+
return plan, resindex
|
| 545 |
+
|
| 546 |
+
|
| 547 |
+
def step_coords(_size: float, _spacing: float) -> Generator[float, None, None]:
|
| 548 |
+
"""Generate set of evenly spaced coordinates between of defined size.
|
| 549 |
+
|
| 550 |
+
Parameters
|
| 551 |
+
----------
|
| 552 |
+
size : float
|
| 553 |
+
Size (in Angstrom) to be sampled
|
| 554 |
+
spacing : float
|
| 555 |
+
Spacing between each coordinate
|
| 556 |
+
|
| 557 |
+
Return
|
| 558 |
+
------
|
| 559 |
+
Generator[float, None, None]
|
| 560 |
+
1D coodinate of current position.
|
| 561 |
+
"""
|
| 562 |
+
# Convert to absolute value
|
| 563 |
+
size = abs(_size)
|
| 564 |
+
spacing = abs(_spacing)
|
| 565 |
+
# Check if size is indeed greater than spacing
|
| 566 |
+
if spacing > size:
|
| 567 |
+
logging.error("Size must be greater than spacing!")
|
| 568 |
+
raise ValueError
|
| 569 |
+
return _step_coords(size, spacing)
|
| 570 |
+
|
| 571 |
+
|
| 572 |
+
def _step_coords(size: float, spacing: float) -> Generator[float, None, None]:
|
| 573 |
+
"""Generate set of evenly spaced coordinates between of defined size.
|
| 574 |
+
|
| 575 |
+
Parameters
|
| 576 |
+
----------
|
| 577 |
+
size : float
|
| 578 |
+
Size (in Angstrom) to be sampled
|
| 579 |
+
spacing : float
|
| 580 |
+
Spacing between each coordinate
|
| 581 |
+
|
| 582 |
+
Yields
|
| 583 |
+
------
|
| 584 |
+
float
|
| 585 |
+
1D coodinate of current position.
|
| 586 |
+
"""
|
| 587 |
+
# Define initial position
|
| 588 |
+
coord = - (size / 2)
|
| 589 |
+
# Define oversized position
|
| 590 |
+
oversized = (size + spacing) / 2
|
| 591 |
+
# Loop until oversized
|
| 592 |
+
while coord <= oversized:
|
| 593 |
+
yield coord
|
| 594 |
+
coord += spacing
|
| 595 |
+
|
| 596 |
+
|
| 597 |
+
def shape_bead(
|
| 598 |
+
x: float,
|
| 599 |
+
y: float,
|
| 600 |
+
z: float,
|
| 601 |
+
resindex: int,
|
| 602 |
+
chain: str = "S",
|
| 603 |
+
atindex: int = 1,
|
| 604 |
+
bfactor: float = 1.00,
|
| 605 |
+
) -> str:
|
| 606 |
+
"""Generate a PDB shape bead.
|
| 607 |
+
|
| 608 |
+
Parameters
|
| 609 |
+
----------
|
| 610 |
+
x : float
|
| 611 |
+
x coordinate of the bead
|
| 612 |
+
y : float
|
| 613 |
+
y coordinate of the bead
|
| 614 |
+
z : float
|
| 615 |
+
z coordinate of the bead
|
| 616 |
+
resindex : int
|
| 617 |
+
Residue index
|
| 618 |
+
chain : str, optional
|
| 619 |
+
Chain id, by default "S"
|
| 620 |
+
atindex : int, optional
|
| 621 |
+
Atome index, by default 1
|
| 622 |
+
bfactor : float, optional
|
| 623 |
+
B-factor of the bead, by default 1.00
|
| 624 |
+
|
| 625 |
+
Returns
|
| 626 |
+
-------
|
| 627 |
+
bead : str
|
| 628 |
+
A valid PDB shape bead.
|
| 629 |
+
"""
|
| 630 |
+
bead = f"ATOM {atindex:>5d} SHA SHA {chain}{resindex:>4d} {x:-8.3f}{y:-8.3f}{z:-8.3f} 1.00{bfactor:6.2f} SHA {os.linesep}" # noqa : E501
|
| 631 |
+
return bead
|
| 632 |
+
|
| 633 |
+
|
| 634 |
+
def _get_ideal_restraint_dist(spacing: float) -> float:
|
| 635 |
+
"""Computes ideal restraint distance based on spacing.
|
| 636 |
+
|
| 637 |
+
Basically, want to return (spacing / 2) - 2
|
| 638 |
+
|
| 639 |
+
Parameters
|
| 640 |
+
----------
|
| 641 |
+
spacing : int
|
| 642 |
+
Spacing between beads.
|
| 643 |
+
|
| 644 |
+
Returns
|
| 645 |
+
-------
|
| 646 |
+
float
|
| 647 |
+
Effective distance restraint.
|
| 648 |
+
"""
|
| 649 |
+
# Compute de distance
|
| 650 |
+
effective_distance_restraint: float = (spacing / 2) - 2
|
| 651 |
+
# Make sure it is not out of allowed boundaries
|
| 652 |
+
bounded_distance_restraint = max(effective_distance_restraint, 2.0)
|
| 653 |
+
return bounded_distance_restraint
|
| 654 |
+
|
| 655 |
+
|
| 656 |
+
def main(
|
| 657 |
+
pdb: Union[str, Path],
|
| 658 |
+
residues: Optional[list[str]] = None,
|
| 659 |
+
output: Optional[str] = None,
|
| 660 |
+
spacing: float = 40,
|
| 661 |
+
x_size: float = 200,
|
| 662 |
+
y_size: float = 200,
|
| 663 |
+
z_padding: float = 5.0,
|
| 664 |
+
log_level: str = "INFO",
|
| 665 |
+
) -> tuple[str, str]:
|
| 666 |
+
"""Generate both z-restraints and z-surface beads from residue selection.
|
| 667 |
+
|
| 668 |
+
Parameters
|
| 669 |
+
----------
|
| 670 |
+
pdb : Union[str, Path]
|
| 671 |
+
Path to the PDB file to be parsed.
|
| 672 |
+
residues : list[str]
|
| 673 |
+
List of strings containing coma separated resids, by default None
|
| 674 |
+
spacing : float, optional
|
| 675 |
+
Spacing (in Angstrom) between beads in same dimension, by default 40
|
| 676 |
+
x_size : float, optional
|
| 677 |
+
Width (in Angstrom) of the plan, by default 200
|
| 678 |
+
y_size : float, optional
|
| 679 |
+
Height (in Angstrom) of the plan, by default 200
|
| 680 |
+
|
| 681 |
+
Returns
|
| 682 |
+
-------
|
| 683 |
+
tuple[Union[str, Path], Union[str, Path]]
|
| 684 |
+
Paths to the Z_restraints.tbl and Z_surface.pdb
|
| 685 |
+
"""
|
| 686 |
+
# Load residue selection
|
| 687 |
+
res_select = load_selections(residues)
|
| 688 |
+
# Load corresponding coordinates
|
| 689 |
+
select_coords, chainids, atomtypes = load_selected_resiudes_coords(
|
| 690 |
+
pdb, res_select
|
| 691 |
+
)
|
| 692 |
+
# Compute z-coordinates for each selection
|
| 693 |
+
selection_z = get_z_coords(select_coords, padding=z_padding)
|
| 694 |
+
# Generate corresponding z-surfaces
|
| 695 |
+
plans = gen_bead_plans(
|
| 696 |
+
spacing=spacing,
|
| 697 |
+
x_size=x_size,
|
| 698 |
+
y_size=y_size,
|
| 699 |
+
z_coords=[zcoord for zcoord in selection_z.values()],
|
| 700 |
+
)
|
| 701 |
+
# Compute ideal restraint distance based on spacing
|
| 702 |
+
restraint_distance = _get_ideal_restraint_dist(spacing)
|
| 703 |
+
# Generate corresponding z-surface restraints
|
| 704 |
+
restraints = gen_z_restraints(
|
| 705 |
+
res_select,
|
| 706 |
+
selection_z,
|
| 707 |
+
rest_dist=restraint_distance,
|
| 708 |
+
segids=chainids,
|
| 709 |
+
atome_types=atomtypes,
|
| 710 |
+
)
|
| 711 |
+
# Output data
|
| 712 |
+
restraints_tbl, plans_pdb = output_data(restraints, plans, output=output)
|
| 713 |
+
return restraints_tbl, plans_pdb
|
| 714 |
+
|
| 715 |
+
|
| 716 |
+
gen_z_surface_restraints = main
|
| 717 |
+
|
| 718 |
+
|
| 719 |
+
############################
|
| 720 |
+
# COMMAND LINE ENTRY POINT #
|
| 721 |
+
############################
|
| 722 |
+
if __name__ == "__main__":
|
| 723 |
+
import argparse
|
| 724 |
+
# Command line interface parser
|
| 725 |
+
ap = argparse.ArgumentParser(
|
| 726 |
+
prog="haddock3-restraints",
|
| 727 |
+
description=__doc__,
|
| 728 |
+
formatter_class=argparse.RawDescriptionHelpFormatter,
|
| 729 |
+
)
|
| 730 |
+
add_z_surf_restraints_arguments(ap)
|
| 731 |
+
args = vars(ap.parse_args())
|
| 732 |
+
setup_logging(log_level=args['log_level'])
|
| 733 |
+
# Launch main
|
| 734 |
+
restraints_fpath, plan_s_fpath = gen_z_surface_restraints(
|
| 735 |
+
args['residues'],
|
| 736 |
+
residues=args['residues'],
|
| 737 |
+
output=args['output'],
|
| 738 |
+
spacing=args['spacing'],
|
| 739 |
+
x_size=args['x_size'],
|
| 740 |
+
y_size=args['y_size'],
|
| 741 |
+
z_padding=args['z_padding'],
|
| 742 |
+
log_level=args["log_level"],
|
| 743 |
+
)
|
| 744 |
+
logging.info(restraints_fpath)
|
| 745 |
+
logging.info(plan_s_fpath)
|
.venv_haddock/lib/python3.12/site-packages/haddock/clis/wrapper_haddock_restraints.py
ADDED
|
@@ -0,0 +1,20 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/usr/bin/env python3
|
| 2 |
+
import sys
|
| 3 |
+
from pathlib import Path
|
| 4 |
+
|
| 5 |
+
from importlib.resources import files
|
| 6 |
+
|
| 7 |
+
|
| 8 |
+
def main():
|
| 9 |
+
|
| 10 |
+
binary = Path(files("haddock").joinpath("bin/haddock-restraints")) # type: ignore
|
| 11 |
+
sys.argv[0] = str(binary) # Replace argv[0] with actual binary path
|
| 12 |
+
|
| 13 |
+
# Execute the binary
|
| 14 |
+
import subprocess
|
| 15 |
+
|
| 16 |
+
sys.exit(subprocess.run([str(binary)] + sys.argv[1:]).returncode)
|
| 17 |
+
|
| 18 |
+
|
| 19 |
+
if __name__ == "__main__":
|
| 20 |
+
main()
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/._bin
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/._toppar
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/bin/._aarch64-linux.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fbd1f4c19356c9f782c0fce50a927d08f5a7a89ae88cc56fe8e671aeba8ef15d
|
| 3 |
+
size 4096
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/bin/._arm64-darwin.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fbd1f4c19356c9f782c0fce50a927d08f5a7a89ae88cc56fe8e671aeba8ef15d
|
| 3 |
+
size 4096
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/bin/._x86_64-darwin.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fbd1f4c19356c9f782c0fce50a927d08f5a7a89ae88cc56fe8e671aeba8ef15d
|
| 3 |
+
size 4096
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/bin/._x86_64-linux.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:fbd1f4c19356c9f782c0fce50a927d08f5a7a89ae88cc56fe8e671aeba8ef15d
|
| 3 |
+
size 4096
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/bin/aarch64-linux.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:72088dd5c83af64e576cd9693fbb7a01bad9534192efe292890c8ad7bbbbb974
|
| 3 |
+
size 3947816
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/bin/arm64-darwin.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:e6febf74eccb740f8bc5d49955cc8fc202025d5d642e129e7738e7280ad95a88
|
| 3 |
+
size 4171768
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/bin/x86_64-darwin.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:511d163492f8878be88e74033fbf8f9f31c97515bbf16a38762f3fcd0c0ff31d
|
| 3 |
+
size 4089832
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/bin/x86_64-linux.bin
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:ce6b0c6b9d38e09991fb15431402e92cb38c723544b2dcca7a8dc28b66643927
|
| 3 |
+
size 6363048
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._boxtyp20.pdb
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._carbohydrate.param
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._carbohydrate.top
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._cofactors.param
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._cofactors.pep
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._cofactors.top
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._dmso.pdb
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._dna-rna-1.3.link
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._dna-rna-CG-MARTINI-2-1p-break.top
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._dna-rna-CG-MARTINI-2-1p.link
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._dna-rna-CG-MARTINI-2-1p.param
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._dna-rna-CG-MARTINI-2-1p.top
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._dna-rna-allatom-hj-opls-1.3.param
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._dna-rna-allatom-hj-opls-1.3.top
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._dna-rna-pho-1.3.link
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._dna_break.top
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._fragment_probes.param
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._fragment_probes.top
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._heme.pdb
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._heme.psf
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._hemeB.pdb
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._hemeB.psf
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._hemes-allhdg.param
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._hemes-allhdg.top
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._hemes.pep
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._initial_positions
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._ion.param
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._ion.top
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._metalcenter.tbl
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._par_axis.pro
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._par_axis_dani.pro
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._protein-CG-Martini-2-2.link
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._protein-CG-Martini-2-2.param
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._protein-CG-Martini-2-2.top
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._protein-CG-Martini.link
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._protein-CG-Martini.param
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._protein-CG-Martini.top
ADDED
|
Binary file (4.1 kB). View file
|
|
|
.venv_haddock/lib/python3.12/site-packages/haddock/cns/toppar/._protein-allhdg5-4-noCter.link
ADDED
|
Binary file (4.1 kB). View file
|
|
|