"platforms/reference/vscode:/vscode.git/clone" did not exist on "3eb561ad211cf8fbcca9e28ac90aa9dacdda42c1"
Commit f21bb6a5 authored by peastman's avatar peastman Committed by GitHub
Browse files

Merge pull request #1783 from peastman/element

Improved logic for guessing elements from atom names
parents 111844a2 2846ca7e
...@@ -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].isdigit():
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