Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 6 additions & 9 deletions src/check_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ def get_pdb_line_components(pdb_line: str) -> Dict[str, Union[int, float, str]]:
pdb_line_terms: Dict[str, Union[int, float, str]] = {}

if pdb_line:
if (pdb_line.split())[0] == "ATOM" or (pdb_line.split())[0] == "HETATM":
pdb_line_terms["RECORD TYPE"] = pdb_line[0:6].replace(" ", "")
if (pdb_line.split())[0] in ["ATOM", "HETATM"]:
pdb_line_terms["RECORD TYPE"] = pdb_line[:6].replace(" ", "")
Comment on lines -36 to +37
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_pdb_line_components refactored with the following changes:

pdb_line_terms["ATOM SERIAL NUMBER"] = (
int(pdb_line[6:11].replace(" ", ""))
if pdb_line[6:11].replace(" ", "") != ""
Expand Down Expand Up @@ -82,7 +82,7 @@ def get_pdb_line_components(pdb_line: str) -> Dict[str, Union[int, float, str]]:
pdb_line_terms["SEGMENT ID"] = pdb_line[72:76].replace(" ", "")
pdb_line_terms["ELEMENT SYMBOL"] = pdb_line[76:78].replace(" ", "")
elif (pdb_line.split())[0] == "TER":
pdb_line_terms["RECORD TYPE"] = pdb_line[0:6].replace(" ", "")
pdb_line_terms["RECORD TYPE"] = pdb_line[:6].replace(" ", "")
try:
pdb_line_terms["ATOM SERIAL NUMBER"] = int(
pdb_line[6:11].replace(" ", "")
Expand All @@ -100,7 +100,7 @@ def get_pdb_line_components(pdb_line: str) -> Dict[str, Union[int, float, str]]:
except ValueError:
pass
elif (pdb_line.split())[0] == "CONECT":
pdb_line_terms["RECORD TYPE"] = pdb_line[0:6].replace(" ", "")
pdb_line_terms["RECORD TYPE"] = pdb_line[:6].replace(" ", "")
pdb_line_terms["ATOM SERIAL NUMBER"] = pdb_line[6:11].replace(" ", "")
pdb_line_terms["BONDED ATOM SERIAL NUMBER"] = pdb_line[12:].strip("\n")

Expand All @@ -111,10 +111,7 @@ def assemble_pdb_line_components(
pdb_line_components: Dict[str, Union[int, float, str]]
) -> Optional[str]:
# Length of an ATOM line should have 78 characters
if (
pdb_line_components["RECORD TYPE"] == "ATOM"
or pdb_line_components["RECORD TYPE"] == "HETATM"
):
if pdb_line_components["RECORD TYPE"] in ["ATOM", "HETATM"]:
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function assemble_pdb_line_components refactored with the following changes:

for key in [
"X COORDINATE",
"Y COORDINATE",
Expand Down Expand Up @@ -170,7 +167,7 @@ def get_missing_terms(pdb_line_terms: Dict[str, Union[int, float, str]]) -> List

return [
key
for key in pdb_line_terms.keys()
for key in pdb_line_terms
Comment on lines -173 to +170
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function get_missing_terms refactored with the following changes:

if pdb_line_terms[key] == "" and key in important_columns
]

Expand Down
185 changes: 91 additions & 94 deletions src/gmx_ops.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,14 @@ def combine_prot_lig_gro(
root_dir: str, ligand_id: str, protein_pdb: str = "PROTEIN"
) -> List[str]:

complex_lines: list[str] = []
with open(f"{root_dir}/{protein_pdb}_processed.gro", "r") as protein_f:
protein_lines = protein_f.readlines()
with open(
f"{root_dir}/{ligand_id}_fix.acpype/{ligand_id}_fix_GMX.gro", "r"
) as ligand_f:
ligand_lines = ligand_f.readlines()
for line in protein_lines[2:-1]:
complex_lines.append(line)
for line in ligand_lines[2:-1]:
complex_lines.append(line)
complex_lines: list[str] = list(protein_lines[2:-1])
complex_lines.extend(iter(ligand_lines[2:-1]))
Comment on lines -74 to +81
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function combine_prot_lig_gro refactored with the following changes:

complex_lines.insert(0, protein_lines[0])
complex_lines.insert(1, f"{len(complex_lines) - 1}\n")
complex_lines.append(protein_lines[-1])
Expand Down Expand Up @@ -190,100 +187,100 @@ def write_mdp_file(self) -> Dict[str, Any]:

sim_types = ["ions", "em", "nvt", "npt", "md"]

default_params_for_ions_and_em: Dict[str, Any] = {
"integrator": self.integrator,
"nsteps": self.nsteps,
"emtol": self.emtol,
"emstep": self.emstep,
"cutoff_scheme": self.cutoff_scheme,
"nstlist": self.nstlist,
"pbc": self.pbc,
"ns_type": self.ns_type,
"rlist": self.rlist,
"coulombtype": self.coulombtype,
"rcoulomb": self.rcoulomb,
"rvdw": self.rvdw,
}

default_params_for_nvt_npt_md: Dict[str, Any] = {
"integrator": self.integrator,
"dt": self.dt,
"nsteps": self.nsteps,
"nstlog": self.nstlog,
"nstenergy": self.nstenergy,
"nstxout_compressed": self.nstxout_compressed,
"cutoff_scheme": self.cutoff_scheme,
"nstlist": self.nstlist,
"pbc": self.pbc,
"ns_type": self.ns_type,
"rlist": self.rlist,
"coulombtype": self.coulombtype,
"rcoulomb": self.rcoulomb,
"vdwtype": self.vdwtype,
"vdw_modifier": self.vdw_modifier,
"rvdw_switch": self.rvdw_switch,
"rvdw": self.rvdw,
"DispCorr": self.DispCorr,
"fourierspacing": self.fourierspacing,
"pme_order": self.pme_order,
"tcoupl": self.tcoupl,
"tc_grps": self.tc_grps,
"tau_t": self.tau_t,
"ref_t": self.ref_t,
"pcoupl": self.pcoupl,
"gen_vel": self.gen_vel,
"constraints": self.constraints,
"constraint_algorithm": self.constraint_algorithm,
"continuation": self.continuation,
"lincs_order": self.lincs_order,
"lincs_iter": self.lincs_iter,
}

if self.sim_type in sim_types and self.sim_type == "ions":
return default_params_for_ions_and_em

elif self.sim_type in sim_types and self.sim_type == "em":

additional_params: Dict[str, Any] = {
if self.sim_type in sim_types:
default_params_for_ions_and_em: Dict[str, Any] = {
"integrator": self.integrator,
"nsteps": self.nsteps,
"emtol": self.emtol,
"emstep": self.emstep,
"cutoff_scheme": self.cutoff_scheme,
"nstlist": self.nstlist,
"pbc": self.pbc,
"ns_type": self.ns_type,
"rlist": self.rlist,
"coulombtype": self.coulombtype,
"rcoulomb": self.rcoulomb,
"rvdw": self.rvdw,
}

default_params_for_nvt_npt_md: Dict[str, Any] = {
"integrator": self.integrator,
"dt": self.dt,
"nsteps": self.nsteps,
"nstlog": self.nstlog,
"nstenergy": self.nstenergy,
"nstxout_compressed": self.nstxout_compressed,
"cutoff_scheme": self.cutoff_scheme,
"nstlist": self.nstlist,
"pbc": self.pbc,
"ns_type": self.ns_type,
"rlist": self.rlist,
"coulombtype": self.coulombtype,
"rcoulomb": self.rcoulomb,
"vdwtype": self.vdwtype,
"vdw_modifier": self.vdw_modifier,
"rvdw_switch": self.rvdw_switch,
"rvdw": self.rvdw,
"DispCorr": self.DispCorr,
"fourierspacing": self.fourierspacing,
"pme_order": self.pme_order,
"tcoupl": self.tcoupl,
"tc_grps": self.tc_grps,
"tau_t": self.tau_t,
"ref_t": self.ref_t,
"pcoupl": self.pcoupl,
"gen_vel": self.gen_vel,
"constraints": self.constraints,
"constraint_algorithm": self.constraint_algorithm,
"continuation": self.continuation,
"lincs_order": self.lincs_order,
"lincs_iter": self.lincs_iter,
}

return default_params_for_ions_and_em | additional_params # type: ignore

elif self.sim_type in sim_types and self.sim_type == "nvt":
additional_params: Dict[str, Any] = {
"define": self.define,
"gen_temp": self.gen_temp,
"gen_seed": self.gen_seed,
}

return default_params_for_nvt_npt_md | additional_params # type: ignore

elif self.sim_type in sim_types and self.sim_type == "npt":
additional_params: Dict[str, Any] = {
"define": self.define,
"pcoupltype": self.pcoupltype,
"tau_p": self.tau_p,
"compressibility": self.compressibility,
"ref_p": self.ref_p,
"refcoord_scaling": self.refcoord_scaling,
}

return default_params_for_nvt_npt_md | additional_params # type: ignore

elif self.sim_type in sim_types and self.sim_type == "md":
additional_params: Dict[str, Any] = {
"pcoupltype": self.pcoupltype,
"tau_p": self.tau_p,
"compressibility": self.compressibility,
"ref_p": self.ref_p,
# "freezegrps": self.freezegrps,
# "freezedim": self.freezedim,
}

return default_params_for_nvt_npt_md | additional_params # type: ignore
if self.sim_type == "em":
additional_params: Dict[str, Any] = {
"vdwtype": self.vdwtype,
"vdw_modifier": self.vdw_modifier,
"rvdw_switch": self.rvdw_switch,
"DispCorr": self.DispCorr,
}

return default_params_for_ions_and_em | additional_params # type: ignore

elif self.sim_type == "ions":
return default_params_for_ions_and_em

elif self.sim_type == "md":
additional_params: Dict[str, Any] = {
"pcoupltype": self.pcoupltype,
"tau_p": self.tau_p,
"compressibility": self.compressibility,
"ref_p": self.ref_p,
# "freezegrps": self.freezegrps,
# "freezedim": self.freezedim,
}

return default_params_for_nvt_npt_md | additional_params # type: ignore

elif self.sim_type == "npt":
additional_params: Dict[str, Any] = {
"define": self.define,
"pcoupltype": self.pcoupltype,
"tau_p": self.tau_p,
"compressibility": self.compressibility,
"ref_p": self.ref_p,
"refcoord_scaling": self.refcoord_scaling,
}

return default_params_for_nvt_npt_md | additional_params # type: ignore

elif self.sim_type == "nvt":
additional_params: Dict[str, Any] = {
"define": self.define,
"gen_temp": self.gen_temp,
"gen_seed": self.gen_seed,
}

return default_params_for_nvt_npt_md | additional_params # type: ignore
Comment on lines -193 to +284
Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Function MDP.write_mdp_file refactored with the following changes:


return {}
Loading