"vscode:/vscode.git/clone" did not exist on "bd3088748eeb6723b8fdcb26b51ab4b09bf851e7"
Commit c04e70d9 authored by peastman's avatar peastman
Browse files

Improved logic for guessing elements from atom names

parent 111844a2
...@@ -123,6 +123,8 @@ class PDBFile(object): ...@@ -123,6 +123,8 @@ class PDBFile(object):
# Try to guess the element. # Try to guess the element.
upper = atomName.upper() upper = atomName.upper()
while len(upper) > 1 and upper[0].isnumeric():
upper = upper[1:]
if upper.startswith('CL'): if upper.startswith('CL'):
element = elem.chlorine element = elem.chlorine
elif upper.startswith('NA'): elif upper.startswith('NA'):
...@@ -141,7 +143,7 @@ class PDBFile(object): ...@@ -141,7 +143,7 @@ class PDBFile(object):
element = elem.calcium element = elem.calcium
else: else:
try: try:
element = elem.get_by_symbol(atomName[0]) element = elem.get_by_symbol(upper[0])
except KeyError: except KeyError:
pass pass
newAtom = top.addAtom(atomName, element, r, str(atom.serial_number)) newAtom = top.addAtom(atomName, element, r, str(atom.serial_number))
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment