Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
src
PyPDB3
Commits
44d85a20
Commit
44d85a20
authored
1 year ago
by
Pierre Tufféry
Browse files
Options
Download
Email Patches
Plain Diff
enhanced contact detection
parent
059fbc7c
master
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
PyPDB/PyPDB.py
+68
-5
PyPDB/PyPDB.py
with
68 additions
and
5 deletions
+68
-5
PyPDB/PyPDB.py
+
68
-
5
View file @
44d85a20
...
...
@@ -2084,21 +2084,70 @@ class residue(atmList):
return
True
return
False
def
contact
(
self
,
res2
,
dist
=
4.
):
def
contact
(
self
,
res2
,
dist
=
4.
,
what
=
"All"
,
what_return
=
"info"
):
"""
PDB.contact: return true or false depending on the distance between the atoms.
@param what : the atom name (CA, CB)
@param dist : the threshold to detect contacts
@param what : "All", "BBBB", "BBSC", "SCSC"
@param what_info : "info", or the atom name for distance (CA, CB)
@return : an array of the contactMap
"""
for
atm
in
self
:
if
what
!=
"All"
:
isBB
=
atm
.
atmName
()
in
BBATMS
x1
,
y1
,
z1
=
atm
.
xyz
()
for
atm2
in
res2
:
x2
,
y2
,
z2
=
atm2
.
xyz
()
if
what
!=
"All"
:
isBB2
=
atm2
.
atmName
()
in
BBATMS
if
(
what
==
"SCSC"
)
and
(
isBB
or
isBB2
):
continue
if
(
what
==
"BBBB"
)
and
((
not
isBB
)
or
(
not
isBB2
)):
continue
if
(
what
==
"BBSC"
)
and
(
((
isBB
)
and
(
isBB2
))
or
((
not
isBB
)
and
(
not
isBB2
))):
continue
if
(
what
==
"notBBBB"
)
and
(
((
isBB
)
and
(
isBB2
))):
continue
# water is 2.8 (diameter)
aDist
=
distance
(
x1
,
y1
,
z1
,
x2
,
y2
,
z2
)
if
aDist
<
dist
:
return
True
return
False
r1
=
0.8
# 1.6 # C
elem
=
atm
.
atmName
()[
0
]
if
elem
==
"N"
:
r1
=
0.9
# 1.5
if
elem
==
"O"
:
r1
=
0.73
# 1.4
if
elem
==
"S"
:
r1
=
1.04
# 1.85
if
elem
==
"H"
:
r1
=
0.37
# 1.2
r2
=
0.8
# 1.6 # C
elem2
=
atm2
.
atmName
()[
0
]
if
elem2
==
"N"
:
r2
=
0.9
# 1.5
if
elem2
==
"O"
:
r2
=
0.73
# 1.4
if
elem2
==
"S"
:
r2
=
1.04
# 1.85
if
elem2
==
"H"
:
r2
=
0.37
# 1.2
if
aDist
-
r1
-
r2
<
dist
:
if
what_return
==
"info"
:
# print(what, atm.atmName(), atm.resNum(), r1, isBB, atm2.atmName(), atm2.resNum(), r2, isBB2, aDist)
return
True
else
:
ca1
=
self
.
findAtm
(
atmName
=
what_return
)
ca2
=
res2
.
findAtm
(
atmName
=
what_return
)
# print(what_return, ca1.atmName(), ca2.atmName())
if
(
ca1
!=
None
)
and
(
ca2
!=
None
):
x1
,
y1
,
z1
=
ca1
.
xyz
()
x2
,
y2
,
z2
=
ca2
.
xyz
()
# print("distance calculated")
return
distance
(
x1
,
y1
,
z1
,
x2
,
y2
,
z2
)
if
what_return
==
"info"
:
return
False
return
None
## ========================================
...
...
@@ -4972,6 +5021,20 @@ x[0:2]
return
True
return
False
def
intraContacts
(
self
,
dist
=
4.
,
what
=
"All"
):
"""
what is one of All, SCSC, BBBB or BBSC
"""
for
res
in
range
(
0
,
len
(
self
)):
for
res2
in
range
(
res
+
2
,
len
(
self
)):
if
self
[
res
].
contact
(
self
[
res2
],
dist
=
dist
,
what
=
what
,
what_return
=
"info"
):
# print("%s %s %s %s %s" % (self.id, \
# self[res].rName(), self[res].rNum(), self[res2].rName(), self[res2].rNum()))
print
(
"%s %s %s %s %s %f"
%
(
self
.
id
,
\
self
[
res
].
rName
(),
self
[
res
].
rNum
(),
self
[
res2
].
rName
(),
self
[
res2
].
rNum
(),
\
self
[
res
].
contact
(
self
[
res2
],
dist
=
dist
,
what
=
what
,
what_return
=
"CA"
)))
return
False
def
contactMap
(
self
,
what
=
"CA"
,
dist
=
11.
):
"""
PDB.contactMap: return an internal contact map based on
...
...
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
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
Menu
Projects
Groups
Snippets
Help