-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdna.py
More file actions
53 lines (45 loc) · 1.38 KB
/
Copy pathdna.py
File metadata and controls
53 lines (45 loc) · 1.38 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
import numpy as np
from Bio.PDB import PDBParser
from OpenGL.GL import *
from OpenGL.GLUT import *
from OpenGL.GLU import *
def load_dna_structure(pdb_file):
parser = PDBParser(QUIET=True)
structure = parser.get_structure('DNA', pdb_file)
model = structure[0]
return model
# Inicializando a janela OpenGL
def draw_dna_model(model):
glutInit()
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB)
glutCreateWindow("Representação do DNA humano")
# Inicializando a renderização da janela
def render():
glClear(GL_COLOR_BUFFER_CLEAR)
glRotatef(1, 3, 1, 1)
glLineWidth(2.0)
glBegin(GL_LINES)
for chain in model.get_chains():
for residue in chain:
for atom in residue:
if atom.get_name() == "p":
x, y, z = atom.get_coord()
glVertex3f(x, y, z)
glEnd()
glFlush()
# Inicializando a matriz de projeção
glMatrixMode(GL_PROJECTION)
glLoadIdentity()
gluPerspective(45, (800 / 600), 1, 50)
# Definindo a posição do observador
glMatrixMode(GL_MODELVIEW)
glLoadIdentity()
gluLookAt(0, 0, -15, 0, 0, 0, 0, 1, 0)
# Iniciando o loop de renderização
glutDisplayFunc(render)
glutIdleFunc(render)
glutMainLoop()
if __name__ == "__main__":
# Substituindo "dna.pdb" pelo caminho do arquivo PDB que contém a estrutura do DNA
dna_structure = load_dna_structure("dna.pdb")
draw_dna_model(dna_structure)