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):
# Try to guess the element.
upper = atomName.upper()
while len(upper) > 1 and upper[0].isdigit():
upper = upper[1:]
if upper.startswith('CL'):
element = elem.chlorine
elif upper.startswith('NA'):
......@@ -141,7 +143,7 @@ class PDBFile(object):
element = elem.calcium
else:
try:
element = elem.get_by_symbol(atomName[0])
element = elem.get_by_symbol(upper[0])
except KeyError:
pass
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