Skip to content
Open
Show file tree
Hide file tree
Changes from 7 commits
Commits
Show all changes
47 commits
Select commit Hold shift + click to select a range
d787e94
Refactor: Add __len__ method to AtomicSystem class
galjos Aug 5, 2024
f43393d
chore: Update setup.py with compiler directive for Python 3 compatibi…
galjos Aug 5, 2024
b2a9600
bug: Missing comma in setup.py
galjos Aug 5, 2024
7048666
chore: Update setup.py, compiler directive for Python 3 compatibility…
galjos Aug 6, 2024
229bfae
add a function which adds not defined optional keys in the directory …
stkroe Dec 11, 2024
d64f70a
use this new not_defined_optional_keys function
stkroe Dec 11, 2024
e7db465
add None in the if conditions to ensure that NoneType are not causing…
stkroe Dec 11, 2024
275b3dc
rewrite the not_defined_optional_keys function with __setitem__ metho…
stkroe Dec 11, 2024
cc1e059
add None in the function annotations
stkroe Dec 11, 2024
409a3be
if restart file and moldescriptor are empty it is not working because…
stkroe Dec 11, 2024
375eb49
target density was not defined for no_intra_molecular=False; now the …
stkroe Dec 11, 2024
dbdebbd
Merge pull request #109 from MolarVerse/feature/len_in_atomsys
97gamjak Dec 11, 2024
eac4dc1
Add .github/.pylint_cache on push event
github-actions[bot] Dec 11, 2024
dbba27d
add None as type for boolean assert_logging_with_exception
stkroe Dec 12, 2024
dffb1d0
update GitHub Actions to use setup-python@v5
galjos Dec 15, 2024
bfb0365
fix: Disable iteration over AtomicSystem object
galjos Dec 29, 2024
cfb5391
fix: Replace np.in1d with np.isin for improved index matching
galjos Dec 29, 2024
92e68ee
bugfix: delete atleast numpy function and handle input types directly.
galjos Dec 29, 2024
d52e3b1
fix: update setuptools dependency to latest version
galjos Dec 29, 2024
1b191f8
fix: pin setuptools to version 70.0.0 so that pytest.sh works
galjos Dec 29, 2024
8630902
Merge pull request #115 from MolarVerse/bugfix/atleast_1d
97gamjak Dec 30, 2024
5233c5b
Add .github/.pylint_cache on push event
github-actions[bot] Dec 30, 2024
ff076a9
add a function which adds not defined optional keys in the directory …
stkroe Dec 11, 2024
5ea4351
use this new not_defined_optional_keys function
stkroe Dec 11, 2024
d72d124
add None in the if conditions to ensure that NoneType are not causing…
stkroe Dec 11, 2024
5a97cbe
rewrite the not_defined_optional_keys function with __setitem__ metho…
stkroe Dec 11, 2024
6ae17a8
add None in the function annotations
stkroe Dec 11, 2024
d166c80
if restart file and moldescriptor are empty it is not working because…
stkroe Dec 11, 2024
ab32870
target density was not defined for no_intra_molecular=False; now the …
stkroe Dec 11, 2024
3e476c7
add None as type for boolean assert_logging_with_exception
stkroe Dec 12, 2024
736e5c9
update GitHub Actions to use setup-python@v5
galjos Dec 15, 2024
1a818ac
Merge branch 'bugfix/rdf_bugfix' of github.com:MolarVerse/PQAnalysis …
stkroe Jan 7, 2025
776737c
Update PQAnalysis/analysis/rdf/rdf.py
stkroe Jan 7, 2025
4acdbc8
Test of pqanalysis_input_file_reader
stkroe Jan 7, 2025
d486b1e
Test of rdf_input_file_reader.py
stkroe Jan 7, 2025
614df34
Merge branch 'bugfix/rdf_bugfix' of github.com:MolarVerse/PQAnalysis …
stkroe Jan 7, 2025
78aa426
Testing warnings needs assert_logging()
stkroe Jan 7, 2025
0eeebd0
Tests for rdfOutputFileReader:
stkroe Jan 7, 2025
6be6534
Implementation before mentioned suggestion to remove the brackets
stkroe Jan 7, 2025
03fd8ce
Added one line which was missing \n.
stkroe Jan 7, 2025
92f780c
Tests for rdf.py
stkroe Jan 8, 2025
ce61178
More t#est for rdf.py.
stkroe Jan 8, 2025
91fac6a
Correct typo in filename
stkroe Jan 8, 2025
41b626d
Test in _parse.py and delete in rdf.py a space
stkroe Jan 8, 2025
3050345
Create a example rdf
stkroe Jan 13, 2025
8e454f1
Topology bug solved if no moldescriptor or restart file was given
stkroe Jan 13, 2025
0b1efc5
example for rdf with and without restart file
stkroe Jan 13, 2025
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
19 changes: 11 additions & 8 deletions PQAnalysis/analysis/rdf/rdf.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@
from .exceptions import RDFError



class RDF:

"""
Expand Down Expand Up @@ -75,8 +74,8 @@ def __init__(
traj: Trajectory | TrajectoryReader,
reference_species: SelectionCompatible,
target_species: SelectionCompatible,
use_full_atom_info: bool = False,
no_intra_molecular: bool = False,
use_full_atom_info: bool | None = False ,
no_intra_molecular: bool | None = False,
n_bins: PositiveInt | None = None,
delta_r: PositiveReal | None = None,
r_max: PositiveReal | None = None,
Expand All @@ -92,10 +91,10 @@ def __init__(
The reference species of the RDF analysis.
target_species : SelectionCompatible
The target species of the RDF analysis.
use_full_atom_info : bool, optional
use_full_atom_info : bool | None, optional
Whether to use the full atom information of the trajectory
or not, by default None (False).
no_intra_molecular : bool, optional
no_intra_molecular : bool | None, optional
Whether to exclude intra-molecular distances or not, by default None (False).
n_bins : PositiveInt | None, optional
number of bins, by default None
Expand Down Expand Up @@ -193,7 +192,7 @@ def __init__(
############################################
# Initialize Trajectory iterator/generator #
############################################

self.cells = traj.cells

if isinstance(traj, TrajectoryReader):
Expand All @@ -209,6 +208,7 @@ def __init__(
)

self.first_frame = next(self.frame_generator)

self.topology = traj.topology

self._setup_bins(
Expand Down Expand Up @@ -526,8 +526,11 @@ def _finalize_run(
differential_bins : Np1DNumberArray
The differential bins of the RDF analysis based on the spherical shell model.
"""

target_density = len(self.target_index_combinations[0])
if self.no_intra_molecular:
target_density = len(self.target_index_combinations[0])
else:
target_density = len(self.target_indices)

target_density /= self._average_volume

norm = self._norm(
Expand Down
13 changes: 12 additions & 1 deletion PQAnalysis/analysis/rdf/rdf_input_file_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,8 @@ def read(self):
super().read()
super().check_required_keys(self.required_keys)
super().check_known_keys(self.required_keys + self.optional_keys)

super().not_defined_optional_keys(self.optional_keys)

if (self.no_intra_molecular is not None and
(self.restart_file is None or self.moldescriptor_file is None)):
self.logger.error(
Expand All @@ -96,6 +97,16 @@ def read(self):
exception=InputFileError,
)

if self.restart_file is None and self.moldescriptor_file is None:
self.logger.error(
(
"The restart_file key or the moldescriptor_file key with restart_file key "
"have to be set in order to use the RDF analysis."
Copy link
Collaborator

Choose a reason for hiding this comment

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

If I recall it correctly, this does not have to be the case. For example if you have a plain xyz trajectory and want to give just the plain indices than this should be fine without any restart file or am I wrong?
The restart file should only be necessary if the user want to have a special selection based on atomtypes, molecules, ...

maybe this does not work as expected atm, but then we should tackle the problem there. So that if only an index selection is given the RDF calculation works without restart file.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Okay so i went through your description once again and I see you already mention this issue. Before merging this we should find a solution on how to calculate RDF's without a rst file.

"It is needed for the selection of the target and reference residues."
),
exception=InputFileError,
)



input_keys_documentation = f"""
Expand Down
17 changes: 10 additions & 7 deletions PQAnalysis/io/input_file_reader/pq_analysis/_parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ def _parse_real(input_dict: InputDictionary, key: str) -> Real | None:
except PQKeyError:
return None

if data[1] not in ["float", "int"]:
if data[1] not in ["float", "int", "None"]:
logger.error(
f"The \"{key}\" value has to be of float type - actually it is parsed as a {data[1]}",
exception=InputFileError
Expand Down Expand Up @@ -132,7 +132,10 @@ def _parse_files(input_dict: InputDictionary, key: str) -> List[str] | None:

if data_type in {"glob", "list(str)"}:
return data[0]


if data_type == "None":
return None

logger.error(
(
f"The \"{key}\" value has to be either a "
Expand Down Expand Up @@ -170,7 +173,7 @@ def _parse_int(input_dict: InputDictionary, key: str) -> int | None:
except PQKeyError:
return None

if data[1] != "int":
if data[1] not in ["int", "None"]:
logger.error(
f"The \"{key}\" value has to be of int type - actually it is parsed as a {data[1]}",
exception=InputFileError
Expand Down Expand Up @@ -245,7 +248,7 @@ def _parse_string(input_dict: InputDictionary, key: str) -> str | None:
except PQKeyError:
return None

if data[1] != "str":
if data[1] not in ["str", "None"]:
logger.error(
(
f"The \"{key}\" value has to be of "
Expand All @@ -266,7 +269,7 @@ def _parse_bool(input_dict: InputDictionary, key: str) -> bool | None:
----------
dict : InputDictionary
the input dictionary
key : str
key : str
the key to get the value from

Returns
Expand All @@ -283,8 +286,8 @@ def _parse_bool(input_dict: InputDictionary, key: str) -> bool | None:
data = input_dict[key]
except PQKeyError:
return None

if data[1] != "bool":
if data[1] not in["bool", "None"]:
logger.error(
f"The \"{key}\" value has to be of bool type - actually it is parsed as a {data[1]}",
exception=InputFileError
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,17 @@ def check_known_keys(self, known_keys: List[str] | None = None):
"Unknown keys were set in the input file! "
f"The known keys are: {known_keys}. They will be ignored!"
)

def not_defined_optional_keys(self, optional_keys: List[str]):
"""
Checks if optional keys are set in the input file.
If not set, it sets them to None.

Parameters
----------
optional_keys : List[str]
the optional keys
"""
for key in optional_keys:
if key not in self.dictionary.keys():
self.dictionary.__setitem__(key=key,value=(None,"None","None"))
2 changes: 1 addition & 1 deletion PQAnalysis/io/traj_file/trajectory_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def __init__(
The format is inferred from the file extension.
md_format : MDEngineFormat | str, optional
The format of the trajectory. Default is MDEngineFormat.PQ.
topology : Topology, optional
topology : Topology | None, optional
The topology of the trajectory. Default is None.
constant_topology : bool, optional
Whether the topology is constant over the trajectory or does change. Default is True.
Expand Down