Skip to content

Commit

Permalink
[Typing](ALL): Update typing from python 3.8 style to python 3.9
Browse files Browse the repository at this point in the history
  • Loading branch information
PauAndrio committed Oct 17, 2024
1 parent 3bf6b4a commit 07d419a
Show file tree
Hide file tree
Showing 6 changed files with 22 additions and 20 deletions.
4 changes: 2 additions & 2 deletions .github/env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ channels:
- bioconda
- anaconda
dependencies:
- biobb_common ==4.2.0
- biobb_common ==5.0.0
- mdanalysis >=2.0.0
- biobb_structure_checking ==3.13.4
- biobb_structure_checking ==3.13.5
- cmip ==2.7.0
2 changes: 1 addition & 1 deletion biobb_cmip/cmip/cmip_ignore_residues.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ def launch(self) -> int:
chain, resnum = residue_code_list
self.residue_list[i] = chain.strip().upper()+":"+str(resnum).strip()

mark_residues(residue_list=self.residue_list, input_cmip_pdb_path=self.io_dict["in"]["input_cmip_pdb_path"], output_cmip_pdb_path=self.io_dict["out"]["output_cmip_pdb_path"], out_log=self.out_log, global_log=self.global_log)
mark_residues(residue_list=self.residue_list or [], input_cmip_pdb_path=self.io_dict["in"]["input_cmip_pdb_path"], output_cmip_pdb_path=self.io_dict["out"]["output_cmip_pdb_path"], out_log=self.out_log, global_log=self.global_log)

# remove temporary
self.remove_tmp_files()
Expand Down
2 changes: 1 addition & 1 deletion biobb_cmip/cmip/cmip_prepare_pdb.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ def launch(self) -> int:
self.copy_to_host()

# remove temporary folder(s)
self.tmp_files.extend([self.stage_io_dict.get("unique_dir")])
self.tmp_files.extend([self.stage_io_dict.get("unique_dir", "")])
self.remove_tmp_files()

self.check_arguments(output_files_created=True, raise_exception=False)
Expand Down
21 changes: 11 additions & 10 deletions biobb_cmip/cmip/cmip_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import json
import argparse
from typing import Optional
from typing import Any
import shutil
from pathlib import Path
from biobb_common.generic.biobb_object import BiobbObject
Expand Down Expand Up @@ -130,7 +131,7 @@ def launch(self) -> int:
raise ValueError(f"ERROR: output_pdb_path ({self.io_dict['out']['output_pdb_path']})"
f"name must end in .pdb and not contain underscores")

params_preset_dict = params_preset(execution_type=self.execution_type)
params_preset_dict: dict[str, Any] = params_preset(execution_type=self.execution_type)
if self.io_dict['in']["input_json_external_box_path"]:
params_preset_dict["readgrid0"] = 0
origin, size, grid_params = get_grid(self.io_dict['in']["input_json_external_box_path"])
Expand Down Expand Up @@ -159,7 +160,7 @@ def launch(self) -> int:

# Restart OUT
if self.io_dict["out"].get("output_rst_path"):
params_preset_dict['FULLRST'] = 1
params_preset_dict['FULLRST'] = 1 # type: ignore
params_preset_dict['OREST'] = 1

# Restart IN
Expand Down Expand Up @@ -187,7 +188,7 @@ def launch(self) -> int:
'-hs', self.stage_io_dict['in']['input_pdb_path']]

if self.stage_io_dict["in"].get("input_probe_pdb_path") and Path(
self.io_dict["in"].get("input_probe_pdb_path")).exists():
self.io_dict["in"].get("input_probe_pdb_path", "")).exists():
self.cmd.append('-pr')
self.cmd.append(self.stage_io_dict["in"].get("input_probe_pdb_path"))

Expand Down Expand Up @@ -225,17 +226,17 @@ def launch(self) -> int:
# CMIP removes or adds a .pdb extension from pdb output name
# manual copy_to_host or unstage
if self.io_dict['out'].get('output_pdb_path'):
output_pdb_path = str(Path(self.stage_io_dict["unique_dir"]).joinpath(Path(self.io_dict['out'].get('output_pdb_path')).name))
output_pdb_path = str(Path(self.stage_io_dict["unique_dir"]).joinpath(Path(self.io_dict['out'].get('output_pdb_path', '')).name))
if Path(output_pdb_path[:-4]).exists():
shutil.move(output_pdb_path[:-4], self.io_dict['out'].get('output_pdb_path'))
shutil.move(output_pdb_path[:-4], self.io_dict['out'].get('output_pdb_path', ''))
elif Path(output_pdb_path + ".pdb").exists():
shutil.move(output_pdb_path + ".pdb", self.io_dict['out'].get('output_pdb_path'))
shutil.move(output_pdb_path + ".pdb", self.io_dict['out'].get('output_pdb_path', ''))
elif not Path(output_pdb_path).exists():
fu.log(f"WARNING: File not found output_pdb_path: {output_pdb_path}", self.out_log, self.global_log)

# Replace "ATOMTM" tag for "ATOM "

output_pdb_path = self.io_dict['out'].get('output_pdb_path')
output_pdb_path = self.io_dict['out'].get('output_pdb_path', '')
if output_pdb_path:
if Path(output_pdb_path).exists():
with open(output_pdb_path) as pdb_file:
Expand All @@ -261,7 +262,7 @@ def launch(self) -> int:
grid_dict = {'origin': origin_dict,
'size': size_dict,
'params': grid_params}
with open(self.io_dict['out'].get('output_json_box_path'), 'w') as json_file:
with open(self.io_dict['out'].get('output_json_box_path', ''), 'w') as json_file:
json_file.write(json.dumps(grid_dict, indent=4))

# Create external_json_box_path file from CMIP log file
Expand All @@ -279,14 +280,14 @@ def launch(self) -> int:
grid_dict = {'origin': origin_dict,
'size': size_dict,
'params': grid_params}
with open(self.io_dict['out'].get('output_json_external_box_path'), 'w') as json_file:
with open(self.io_dict['out'].get('output_json_external_box_path', ''), 'w') as json_file:
json_file.write(json.dumps(grid_dict, indent=4))

# Copy files to host
self.copy_to_host()

# remove temporary folder(s)
self.tmp_files.extend([self.stage_io_dict.get("unique_dir"), combined_params_dir])
self.tmp_files.extend([self.stage_io_dict.get("unique_dir", ""), combined_params_dir])
self.remove_tmp_files()

self.check_arguments(output_files_created=True, raise_exception=False)
Expand Down
5 changes: 3 additions & 2 deletions biobb_cmip/cmip/cmip_titration.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import os
import argparse
from typing import Optional
from typing import Any
from pathlib import Path
from biobb_common.generic.biobb_object import BiobbObject
from biobb_common.configuration import settings
Expand Down Expand Up @@ -88,7 +89,7 @@ def __init__(self, input_pdb_path: str, output_pdb_path: str,
self.output_params_path = properties.get('output_params_path', 'params')
if not self.io_dict['in'].get('input_vdw_params_path'):
self.io_dict['in']['input_vdw_params_path'] = f"{os.environ.get('CONDA_PREFIX')}/share/cmip/dat/vdwprm"
self.params = {k: str(v) for k, v in properties.get('params', dict()).items()}
self.params: dict[str, Any] = {k: str(v) for k, v in properties.get('params', dict()).items()}
self.energy_cutoff = properties.get('energy_cutoff', 9999.9)

# Check the properties
Expand Down Expand Up @@ -155,7 +156,7 @@ def launch(self) -> int:
self.copy_to_host()

# remove temporary folder(s)
self.tmp_files.extend([self.stage_io_dict.get("unique_dir"), combined_params_dir])
self.tmp_files.extend([self.stage_io_dict.get("unique_dir", ""), combined_params_dir])
self.remove_tmp_files()

self.check_arguments(output_files_created=True, raise_exception=False)
Expand Down
8 changes: 4 additions & 4 deletions biobb_cmip/cmip/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ def get_topology_cmip_elements_canonical(input_topology_filename: str) -> list:
# mda_charges = [round(val, 4) for val in u.atoms.charges]
# mda_atom_types = list(guess_types(u.atoms.names))
mda_atom_types = []
for atom in u.atoms:
for atom in u.atoms: # type: ignore
atom_element = guess_atom_element(atom.name)
if atom_element == 'H':
bonded_atom_element = guess_atom_element(atom.bonded_atoms[0].name)
Expand Down Expand Up @@ -178,7 +178,7 @@ def get_topology_charges(input_topology_filename: str) -> list:
os.unlink(top_file)
else:
u = mda.Universe(input_topology_filename)
return [round(val, 4) for val in u.atoms.charges]
return [round(val, 4) for val in u.atoms.charges] # type: ignore


class Residue:
Expand Down Expand Up @@ -241,7 +241,7 @@ def get_pdb_charges(input_pdb_filename: str, residue_library_path: Optional[str]
print(f"WARNING replacing {nomr[:-1]}:{line[23:27]} by {nomr}")
######################################################
parms = aaLib.getParams(nomr, nomat)
charges_list.append(parms.charg)
charges_list.append(parms.charg) # type: ignore
return charges_list


Expand Down Expand Up @@ -278,7 +278,7 @@ def get_pdb_cmip_elements_canonical(input_pdb_filename: str, residue_library_pat
print(f"WARNING replacing {nomr[:-1]}:{line[23:27]} by {nomr}")
######################################################
parms = aaLib.getParams(nomr, nomat)
elements_list.append(parms.atType)
elements_list.append(parms.atType) # type: ignore
return elements_list


Expand Down

0 comments on commit 07d419a

Please sign in to comment.