Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pdbfixer
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pdbfixer
Commits
111fd4c0
Commit
111fd4c0
authored
Mar 13, 2014
by
peastman
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Changes to work on Python 3
parent
16e09ec4
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
28 additions
and
13 deletions
+28
-13
pdbfixer.py
+3
-3
ui.py
+12
-7
uiserver.py
+13
-3
No files found.
pdbfixer.py
View file @
111fd4c0
...
@@ -116,7 +116,7 @@ class PDBFixer(object):
...
@@ -116,7 +116,7 @@ class PDBFixer(object):
templatesPath
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'templates'
)
templatesPath
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'templates'
)
for
file
in
os
.
listdir
(
templatesPath
):
for
file
in
os
.
listdir
(
templatesPath
):
templatePdb
=
app
.
PDBFile
(
os
.
path
.
join
(
templatesPath
,
file
))
templatePdb
=
app
.
PDBFile
(
os
.
path
.
join
(
templatesPath
,
file
))
name
=
templatePdb
.
topology
.
residues
()
.
next
(
)
.
name
name
=
next
(
templatePdb
.
topology
.
residues
()
)
.
name
self
.
templates
[
name
]
=
templatePdb
self
.
templates
[
name
]
=
templatePdb
def
_addAtomsToTopology
(
self
,
heavyAtomsOnly
,
omitUnknownMolecules
):
def
_addAtomsToTopology
(
self
,
heavyAtomsOnly
,
omitUnknownMolecules
):
...
@@ -256,7 +256,7 @@ class PDBFixer(object):
...
@@ -256,7 +256,7 @@ class PDBFixer(object):
newResidue
=
chain
.
topology
.
addResidue
(
residueName
,
chain
)
newResidue
=
chain
.
topology
.
addResidue
(
residueName
,
chain
)
translate
=
startPosition
+
(
endPosition
-
startPosition
)
*
(
i
+
1.0
)
/
(
len
(
residueNames
)
+
1.0
)
translate
=
startPosition
+
(
endPosition
-
startPosition
)
*
(
i
+
1.0
)
/
(
len
(
residueNames
)
+
1.0
)
templateAtoms
=
list
(
template
.
topology
.
atoms
())
templateAtoms
=
list
(
template
.
topology
.
atoms
())
if
newResidue
==
chain
.
residues
()
.
next
(
):
if
newResidue
==
next
(
chain
.
residues
()
):
templateAtoms
=
[
atom
for
atom
in
templateAtoms
if
atom
.
name
not
in
(
'P'
,
'OP1'
,
'OP2'
)]
templateAtoms
=
[
atom
for
atom
in
templateAtoms
if
atom
.
name
not
in
(
'P'
,
'OP1'
,
'OP2'
)]
for
atom
in
templateAtoms
:
for
atom
in
templateAtoms
:
newAtom
=
chain
.
topology
.
addAtom
(
atom
.
name
,
atom
.
element
,
newResidue
)
newAtom
=
chain
.
topology
.
addAtom
(
atom
.
name
,
atom
.
element
,
newResidue
)
...
@@ -443,7 +443,7 @@ class PDBFixer(object):
...
@@ -443,7 +443,7 @@ class PDBFixer(object):
# Set any previously existing atoms to be massless, they so won't move.
# Set any previously existing atoms to be massless, they so won't move.
for
atom
in
existingAtomMap
.
iter
values
():
for
atom
in
existingAtomMap
.
values
():
system
.
setParticleMass
(
atom
.
index
,
0.0
)
system
.
setParticleMass
(
atom
.
index
,
0.0
)
# If any heavy atoms were omitted, add them back to avoid steric clashes.
# If any heavy atoms were omitted, add them back to avoid steric clashes.
...
...
ui.py
View file @
111fd4c0
...
@@ -5,9 +5,14 @@ from pdbfixer import PDBFixer, substitutions, proteinResidues, dnaResidues, rnaR
...
@@ -5,9 +5,14 @@ from pdbfixer import PDBFixer, substitutions, proteinResidues, dnaResidues, rnaR
import
uiserver
import
uiserver
import
webbrowser
import
webbrowser
import
os.path
import
os.path
import
urllib2
import
gzip
import
gzip
from
cStringIO
import
StringIO
from
io
import
BytesIO
try
:
from
urllib.request
import
urlopen
from
io
import
StringIO
except
:
from
urllib2
import
urlopen
from
cStringIO
import
StringIO
def
loadHtmlFile
(
name
):
def
loadHtmlFile
(
name
):
htmlPath
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'html'
)
htmlPath
=
os
.
path
.
join
(
os
.
path
.
dirname
(
__file__
),
'html'
)
...
@@ -25,16 +30,16 @@ def startPageCallback(parameters, handler):
...
@@ -25,16 +30,16 @@ def startPageCallback(parameters, handler):
global
fixer
global
fixer
if
'type'
in
parameters
:
if
'type'
in
parameters
:
if
parameters
.
getfirst
(
'type'
)
==
'local'
:
if
parameters
.
getfirst
(
'type'
)
==
'local'
:
pdb
=
PdbStructure
(
parameters
[
'pdbfile'
]
.
value
.
splitlines
())
pdb
=
PdbStructure
(
parameters
[
'pdbfile'
]
.
value
.
decode
()
.
splitlines
())
fixer
=
PDBFixer
(
pdb
)
fixer
=
PDBFixer
(
pdb
)
displayDeleteChainsPage
()
displayDeleteChainsPage
()
else
:
else
:
id
=
parameters
.
getfirst
(
'pdbid'
)
id
=
parameters
.
getfirst
(
'pdbid'
)
url
=
"ftp://ftp.wwpdb.org/pub/pdb/data/structures/all/pdb/pdb"
+
id
.
lower
()
+
".ent.gz"
url
=
"ftp://ftp.wwpdb.org/pub/pdb/data/structures/all/pdb/pdb"
+
id
.
lower
()
+
".ent.gz"
try
:
try
:
response
=
url
lib2
.
url
open
(
url
)
response
=
urlopen
(
url
)
content
=
gzip
.
GzipFile
(
fileobj
=
String
IO
(
response
.
read
()))
.
read
()
content
=
gzip
.
GzipFile
(
fileobj
=
Bytes
IO
(
response
.
read
()))
.
read
()
pdb
=
PdbStructure
(
content
.
splitlines
())
pdb
=
PdbStructure
(
content
.
decode
()
.
splitlines
())
fixer
=
PDBFixer
(
pdb
)
fixer
=
PDBFixer
(
pdb
)
displayDeleteChainsPage
()
displayDeleteChainsPage
()
except
:
except
:
...
@@ -160,7 +165,7 @@ def displayConvertResiduesPage():
...
@@ -160,7 +165,7 @@ def displayConvertResiduesPage():
def
displayMissingAtomsPage
():
def
displayMissingAtomsPage
():
uiserver
.
setCallback
(
missingAtomsPageCallback
)
uiserver
.
setCallback
(
missingAtomsPageCallback
)
fixer
.
findMissingAtoms
()
fixer
.
findMissingAtoms
()
allResidues
=
list
(
set
(
fixer
.
missingAtoms
.
iterkeys
())
.
union
(
fixer
.
missingTerminals
.
iter
keys
()))
allResidues
=
list
(
set
(
fixer
.
missingAtoms
.
keys
())
.
union
(
fixer
.
missingTerminals
.
keys
()))
allResidues
.
sort
(
key
=
lambda
x
:
x
.
index
)
allResidues
.
sort
(
key
=
lambda
x
:
x
.
index
)
if
len
(
allResidues
)
==
0
:
if
len
(
allResidues
)
==
0
:
fixer
.
addMissingAtoms
()
fixer
.
addMissingAtoms
()
...
...
uiserver.py
View file @
111fd4c0
from
threading
import
Thread
from
threading
import
Thread
from
SocketServer
import
ThreadingMixIn
from
BaseHTTPServer
import
HTTPServer
,
BaseHTTPRequestHandler
from
urlparse
import
parse_qs
import
cgi
import
cgi
import
sys
try
:
from
socketserver
import
ThreadingMixIn
from
http.server
import
HTTPServer
,
BaseHTTPRequestHandler
from
urllib.parse
import
parse_qs
except
:
from
SocketServer
import
ThreadingMixIn
from
BaseHTTPServer
import
HTTPServer
,
BaseHTTPRequestHandler
from
urlparse
import
parse_qs
class
_Handler
(
BaseHTTPRequestHandler
):
class
_Handler
(
BaseHTTPRequestHandler
):
def
do_GET
(
self
):
def
do_GET
(
self
):
...
@@ -40,6 +46,8 @@ class _Handler(BaseHTTPRequestHandler):
...
@@ -40,6 +46,8 @@ class _Handler(BaseHTTPRequestHandler):
self
.
send_header
(
"Content-type"
,
type
)
self
.
send_header
(
"Content-type"
,
type
)
self
.
send_header
(
"Content-length"
,
str
(
len
(
response
)))
self
.
send_header
(
"Content-length"
,
str
(
len
(
response
)))
self
.
end_headers
()
self
.
end_headers
()
if
sys
.
version_info
.
major
>
2
:
response
=
bytes
(
response
,
'UTF-8'
)
self
.
wfile
.
write
(
response
)
self
.
wfile
.
write
(
response
)
def
sendDownload
(
self
,
download
,
filename
):
def
sendDownload
(
self
,
download
,
filename
):
...
@@ -49,6 +57,8 @@ class _Handler(BaseHTTPRequestHandler):
...
@@ -49,6 +57,8 @@ class _Handler(BaseHTTPRequestHandler):
self
.
send_header
(
"Content-length"
,
str
(
len
(
download
)))
self
.
send_header
(
"Content-length"
,
str
(
len
(
download
)))
self
.
send_header
(
"Content-Disposition"
,
'attachment; filename="
%
s"'
%
filename
)
self
.
send_header
(
"Content-Disposition"
,
'attachment; filename="
%
s"'
%
filename
)
self
.
end_headers
()
self
.
end_headers
()
if
sys
.
version_info
.
major
>
2
:
download
=
bytes
(
download
,
'UTF-8'
)
self
.
wfile
.
write
(
download
)
self
.
wfile
.
write
(
download
)
class
_ThreadingHTTPServer
(
ThreadingMixIn
,
HTTPServer
):
class
_ThreadingHTTPServer
(
ThreadingMixIn
,
HTTPServer
):
...
...
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