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 1021178 commit d359972
Show file tree
Hide file tree
Showing 4 changed files with 39 additions and 40 deletions.
2 changes: 1 addition & 1 deletion .github/env.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,5 +4,5 @@ channels:
- bioconda
- anaconda
dependencies:
- biobb_common ==4.2.0
- biobb_common ==5.0.0
- cp2k ==7.1.0
57 changes: 29 additions & 28 deletions biobb_cp2k/cp2k/cp2k_prep.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
"""Module containing the Cp2kPrep class and the command line interface."""
import argparse
from typing import Optional
from typing import Any
import os
import collections.abc
from pathlib import Path
Expand Down Expand Up @@ -127,9 +128,9 @@ def iterdict(self, d, depth, fileout_h):
print(' ' * depth, k.upper(), v, file=fileout_h)

# global dict3 = {}
def parse_rec_def(self, cp2k_in_array, index, stop):
dict = {}
dict2 = {}
def parse_rec_def(self, cp2k_in_array: list[Any], index: int, stop: str) -> dict[Any, Any]:
dict_var: dict[Any, Any] = {}
dict_var2: dict[Any, Any] = {}
depth = 0
rec = False
for line in cp2k_in_array[index:]:
Expand All @@ -142,49 +143,49 @@ def parse_rec_def(self, cp2k_in_array, index, stop):
vals = line.lstrip().split()

if depth < 0:
return dict
return dict_var
elif '&' in line:
depth = depth + 1
if depth == 1:
vals = line.lstrip().split()
key = vals[0].replace('&', '')
if (key == 'KIND'):
key_name = key + "-" + vals[1]
if dict.get(key):
dict[key].append(self.parse_rec_def(cp2k_in_array, index, key_name))
if dict_var.get(key):
dict_var[key].append(self.parse_rec_def(cp2k_in_array, index, key_name))
else:
dict[key] = []
dict[key].append(self.parse_rec_def(cp2k_in_array, index, key_name))
dict_var[key] = []
dict_var[key].append(self.parse_rec_def(cp2k_in_array, index, key_name))
else:
rec = True
dict[key] = self.parse_rec_def(cp2k_in_array, index, key)
dict_var[key] = self.parse_rec_def(cp2k_in_array, index, key)
if len(vals) > 1 and key != 'KIND':
# print(stop + " Add dict[key]['name'] = " + str(vals[1].strip()))
dict[key]['name'] = vals[1].strip()
# print(stop + " Add dict_var[key]['name'] = " + str(vals[1].strip()))
dict_var[key]['name'] = vals[1].strip()

elif not rec:
vals = line.lstrip().split()
# print(stop + " Add dict[" + str(vals[0]) + "] = " + str(vals[1].strip()))
# print(stop + " Add dict_var[" + str(vals[0]) + "] = " + str(vals[1].strip()))
if (stop == 'COORD'):
if dict2.get('coords_list'):
dict2['coords_list'].append({vals[0]: vals[1:]})
if dict_var2.get('coords_list'):
dict_var2['coords_list'].append({vals[0]: vals[1:]})
else:
dict2['coords_list'] = []
dict2['coords_list'].append({vals[0]: vals[1:]})
dict_var2['coords_list'] = []
dict_var2['coords_list'].append({vals[0]: vals[1:]})

dict = dict2['coords_list']
dict_var = dict_var2['coords_list'] # type: ignore
elif (len(vals) == 2):
if (stop.startswith('KIND-')):
key2, name = stop.split('-')
dict['name'] = name
dict[vals[0]] = vals[1].strip()
dict_var['name'] = name
dict_var[vals[0]] = vals[1].strip()
else:
dict[vals[0]] = vals[1:]
dict_var[vals[0]] = vals[1:]

return dict
return dict_var

def parse_pdb(self, pdb_file):
dict = {}
dict_var = {}
# coord = {}
coord = []
cell = {}
Expand Down Expand Up @@ -237,11 +238,11 @@ def parse_pdb(self, pdb_file):

cell['ABC'] = [str(box_x), str(box_y), str(box_z)]

dict['coord'] = coord
# dict['coords'] = coords
dict['cell'] = cell
dict_var['coord'] = coord
# dict_var['coords'] = coords
dict_var['cell'] = cell

return dict
return dict_var

def merge(self, a, b):
for key_b in b:
Expand Down Expand Up @@ -273,7 +274,7 @@ def merge(self, a, b):
return a

def replace_coords(self, a, b):
# dict['force_eval'] = {'subsys' : {'coord' : coord } }
# dict_var['force_eval'] = {'subsys' : {'coord' : coord } }
print("BioBB_CP2K, replacing coordinates...")
for key in a:
if key.upper() == 'FORCE_EVAL':
Expand Down Expand Up @@ -364,7 +365,7 @@ def launch(self):
print("Will take just the input_inp_path.")
elif (self.simulation_type):
# path_cp2k_in = PurePath(myself.__file__).parent
path_cp2k_in = Path(os.getenv("CONDA_PREFIX")).joinpath('cp2k_aux')
path_cp2k_in = Path(os.getenv("CONDA_PREFIX", "")).joinpath('cp2k_aux')
if (self.simulation_type == 'energy'):
self.io_dict["in"]["input_inp_path"] = str(Path(path_cp2k_in).joinpath("cp2k_in/cp2k_energy.inp"))
elif (self.simulation_type == 'geom_opt'):
Expand Down
4 changes: 2 additions & 2 deletions biobb_cp2k/cp2k/cp2k_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def launch(self):
# set path to the CP2K parameter data files
if not self.param_path:
# os.environ["CP2K_DATA_DIR"] = str(PurePath(myself.__file__).parent.joinpath('cp2k_data'))
os.environ["CP2K_DATA_DIR"] = str(Path(os.getenv("CONDA_PREFIX")).joinpath('cp2k_aux').joinpath('cp2k_data'))
os.environ["CP2K_DATA_DIR"] = str(Path(os.getenv("CONDA_PREFIX", "")).joinpath('cp2k_aux').joinpath('cp2k_data'))
else:
if not Path(PurePath(self.param_path)).exists():
fu.log(self.__class__.__name__ + ': Unexisting %s folder, exiting' % self.param_path, self.out_log)
Expand Down Expand Up @@ -167,7 +167,7 @@ def launch(self):
else:
out_files.append(self.tmp_folder + '/' + file)

fu.zip_list(self.output, out_files, self.out_log)
fu.zip_list(str(self.output), out_files, self.out_log)

# Copy outputs from temporary folder to output path
shutil.copy2(self.output, PurePath(self.io_dict["out"]["output_outzip_path"]))
Expand Down
16 changes: 7 additions & 9 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="biobb_cp2k",
version="4.2.0",
version="5.0.0",
author="Biobb developers",
author_email="[email protected]",
description="Biobb_cp2k is a BioBB category for CP2K QM package.",
Expand All @@ -20,21 +20,19 @@
packages=setuptools.find_packages(exclude=['docs', 'test']),
package_data={'biobb_cp2k': ['py.typed']},
include_package_data=True,
install_requires=['biobb_common==4.2.0'],
python_requires='>=3.8',
install_requires=['biobb_common==5.0.0'],
python_requires='>=3.9',
entry_points={
"console_scripts": [
"cp2k_run = biobb_cp2k.cp2k.cp2k_run:main",
"cp2k_prep = biobb_cp2k.cp2k.cp2k_prep:main"
]
},
classifiers=(
"Development Status :: 3 - Alpha",
"Programming Language :: Python :: 3.8",
classifiers=[
"Development Status :: 5 - Production/Stable",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"License :: OSI Approved :: Apache Software License",
"Operating System :: MacOS :: MacOS X",
"Operating System :: POSIX",
),
"Operating System :: POSIX"
],
)

0 comments on commit d359972

Please sign in to comment.