Skip to content

Commit

Permalink
bugfix: reading topology file
Browse files Browse the repository at this point in the history
checking of last word of topology file block was .lower() == "END" - changed now to .lower() == "end"
  • Loading branch information
97gamjak committed May 31, 2024
1 parent d63a63b commit 45e78ed
Showing 1 changed file with 30 additions and 31 deletions.
61 changes: 30 additions & 31 deletions PQAnalysis/io/topology_file/topology_file_reader.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ def _get_definitions(self) -> dict[str, List[str]]:
lines = [line for line in lines if line.strip()]

# check if last line is END else raise error
if lines[-1].strip() != "END":
if lines[-1].strip().lower() != "end":
self.logger.error(
"Something went wrong. Each block should end with 'END'",
exception=TopologyFileError,
Expand All @@ -100,7 +100,7 @@ def _get_definitions(self) -> dict[str, List[str]]:
blocks = []
block = []
for line in lines:
if line.strip().lower() == "END":
if line.strip().lower() == "end":
blocks.append(block)
block = []
else:
Expand Down Expand Up @@ -163,8 +163,7 @@ def _parse_blocks(self, blocks: dict[str, List[str]]) -> BondedTopology:
impropers = self._parse_impropers(value)
else:
self.logger.error(
f"Unknown block {key}",
exception=TopologyFileError
f"Unknown block {key}", exception=TopologyFileError
)

return BondedTopology(
Expand Down Expand Up @@ -217,10 +216,10 @@ def _parse_bonds(self, block: List[str]) -> List[Bond]:

bonds.append(
Bond(
index1=int(index),
index2=int(target_index),
bond_type=int(bond_type),
is_linker=is_linker,
index1=int(index),
index2=int(target_index),
bond_type=int(bond_type),
is_linker=is_linker,
)
)

Expand Down Expand Up @@ -267,11 +266,11 @@ def _parse_angles(self, block: List[str]) -> List[Angle]:

angles.append(
Angle(
index1=int(index1),
index2=int(index2),
index3=int(index3),
angle_type=int(angle_type),
is_linker=is_linker,
index1=int(index1),
index2=int(index2),
index3=int(index3),
angle_type=int(angle_type),
is_linker=is_linker,
)
)

Expand Down Expand Up @@ -318,12 +317,12 @@ def _parse_dihedrals(self, block: List[str]) -> List[Dihedral]:

dihedrals.append(
Dihedral(
index1=int(index1),
index2=int(index2),
index3=int(index3),
index4=int(index4),
dihedral_type=int(dihedral_type),
is_linker=is_linker,
index1=int(index1),
index2=int(index2),
index3=int(index3),
index4=int(index4),
dihedral_type=int(dihedral_type),
is_linker=is_linker,
)
)

Expand Down Expand Up @@ -370,13 +369,13 @@ def _parse_impropers(self, block: List[str]) -> List[Dihedral]:

dihedrals.append(
Dihedral(
index1=int(index1),
index2=int(index2),
index3=int(index3),
index4=int(index4),
dihedral_type=int(dihedral_type),
is_linker=is_linker,
is_improper=True,
index1=int(index1),
index2=int(index2),
index3=int(index3),
index4=int(index4),
dihedral_type=int(dihedral_type),
is_linker=is_linker,
is_improper=True,
)
)

Expand Down Expand Up @@ -418,11 +417,11 @@ def _parse_shake(self, block: List[str]) -> List[Bond]:

shake_bonds.append(
Bond(
index1=int(index),
index2=int(target_index),
equilibrium_distance=float(distance),
is_linker=is_linker,
is_shake=True,
index1=int(index),
index2=int(target_index),
equilibrium_distance=float(distance),
is_linker=is_linker,
is_shake=True,
)
)

Expand Down

0 comments on commit 45e78ed

Please sign in to comment.