Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
tsoc
openmm
Commits
471cbbf0
"...src/ssh:/git@developer.sourcefind.cn:2222/tsoc/openmm.git" did not exist on "feb79f770145bb12c99bbe058e29d077a381465d"
Commit
471cbbf0
authored
Dec 03, 2012
by
Peter Eastman
Browse files
If a PDB file specifies elements, use them (see bug 1773)
parent
3835b2c9
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
26 additions
and
44 deletions
+26
-44
wrappers/python/simtk/openmm/app/internal/pdbstructure.py
wrappers/python/simtk/openmm/app/internal/pdbstructure.py
+2
-20
wrappers/python/simtk/openmm/app/pdbfile.py
wrappers/python/simtk/openmm/app/pdbfile.py
+24
-24
No files found.
wrappers/python/simtk/openmm/app/internal/pdbstructure.py
View file @
471cbbf0
...
@@ -708,28 +708,10 @@ class Atom(object):
...
@@ -708,28 +708,10 @@ class Atom(object):
except
ValueError
:
self
.
formal_charge
=
None
except
ValueError
:
self
.
formal_charge
=
None
# figure out atom element
# figure out atom element
try
:
try
:
#
First t
ry to find a sensible element symbol from columns 76-77
#
T
ry to find a sensible element symbol from columns 76-77
self
.
element
=
element
.
get_by_symbol
(
self
.
element_symbol
)
self
.
element
=
element
.
get_by_symbol
(
self
.
element_symbol
)
except
KeyError
:
except
KeyError
:
# otherwise, deduce element from first two characters of atom name
self
.
element
=
None
# remove digits found in some hydrogen atom names
symbol
=
self
.
name_with_spaces
[
0
:
2
].
strip
().
lstrip
(
"0123456789"
)
try
:
# Some molecular dynamics PDB files, such as gromacs with ffamber force
# field, include 4-character hydrogen atom names beginning with "H".
# Hopefully elements like holmium (Ho) and mercury (Hg) will have fewer than four
# characters in the atom name. This problem is the fault of molecular
# dynamics code authors who feel the need to make up their own atom
# nomenclature because it is too tedious to read that provided by the PDB.
# These are the same folks who invent their own meanings for biochemical terms
# like "dipeptide". Clowntards.
if
len
(
self
.
name
)
==
4
and
self
.
name
[
0
:
1
]
==
"H"
:
self
.
element
=
element
.
hydrogen
else
:
self
.
element
=
element
.
get_by_symbol
(
symbol
)
except
KeyError
:
# OK, I give up
self
.
element
=
None
def
iter_locations
(
self
):
def
iter_locations
(
self
):
"""
"""
...
...
wrappers/python/simtk/openmm/app/pdbfile.py
View file @
471cbbf0
...
@@ -92,30 +92,30 @@ class PDBFile(object):
...
@@ -92,30 +92,30 @@ class PDBFile(object):
if
atomName
in
atomReplacements
:
if
atomName
in
atomReplacements
:
atomName
=
atomReplacements
[
atomName
]
atomName
=
atomReplacements
[
atomName
]
atomName
=
atomName
.
strip
()
atomName
=
atomName
.
strip
()
element
=
None
element
=
atom
.
element
if
element
is
None
:
# Try to guess the element.
# Try to guess the element.
upper
=
atomName
.
upper
()
upper
=
atomName
.
upper
()
if
upper
.
startswith
(
'CL'
):
if
upper
.
startswith
(
'CL'
):
element
=
elem
.
chlorine
element
=
elem
.
chlorine
elif
upper
.
startswith
(
'NA'
):
elif
upper
.
startswith
(
'NA'
):
element
=
elem
.
sodium
element
=
elem
.
sodium
elif
upper
.
startswith
(
'MG'
):
elif
upper
.
startswith
(
'MG'
):
element
=
elem
.
magnesium
element
=
elem
.
magnesium
elif
upper
.
startswith
(
'BE'
):
elif
upper
.
startswith
(
'BE'
):
element
=
elem
.
beryllium
element
=
elem
.
beryllium
elif
upper
.
startswith
(
'LI'
):
elif
upper
.
startswith
(
'LI'
):
element
=
elem
.
lithium
element
=
elem
.
lithium
elif
upper
.
startswith
(
'K'
):
elif
upper
.
startswith
(
'K'
):
element
=
elem
.
potassium
element
=
elem
.
potassium
elif
(
len
(
residue
)
==
1
and
upper
.
startswith
(
'CA'
)
):
elif
(
len
(
residue
)
==
1
and
upper
.
startswith
(
'CA'
)
):
element
=
elem
.
calcium
element
=
elem
.
calcium
else
:
else
:
try
:
try
:
element
=
elem
.
get_by_symbol
(
atomName
[
0
])
element
=
elem
.
get_by_symbol
(
atomName
[
0
])
except
KeyError
:
except
KeyError
:
pass
pass
newAtom
=
top
.
addAtom
(
atomName
,
element
,
r
)
newAtom
=
top
.
addAtom
(
atomName
,
element
,
r
)
atomByNumber
[
atom
.
serial_number
]
=
newAtom
atomByNumber
[
atom
.
serial_number
]
=
newAtom
self
.
_positions
=
[]
self
.
_positions
=
[]
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment