-
Notifications
You must be signed in to change notification settings - Fork 0
Feature/main menu (Sourcery refactored) #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: feature/main_menu
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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(" ", "") | ||
| pdb_line_terms["ATOM SERIAL NUMBER"] = ( | ||
| int(pdb_line[6:11].replace(" ", "")) | ||
| if pdb_line[6:11].replace(" ", "") != "" | ||
|
|
@@ -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(" ", "") | ||
|
|
@@ -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") | ||
|
|
||
|
|
@@ -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"]: | ||
|
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| for key in [ | ||
| "X COORDINATE", | ||
| "Y COORDINATE", | ||
|
|
@@ -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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| if pdb_line_terms[key] == "" and key in important_columns | ||
| ] | ||
|
|
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
| complex_lines.insert(0, protein_lines[0]) | ||
| complex_lines.insert(1, f"{len(complex_lines) - 1}\n") | ||
| complex_lines.append(protein_lines[-1]) | ||
|
|
@@ -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
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Function
|
||
|
|
||
| return {} | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Function
get_pdb_line_componentsrefactored with the following changes:inoperator (merge-comparisons)remove-redundant-slice-index)