-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgui.py
78 lines (55 loc) · 1.99 KB
/
gui.py
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Thu Sep 14 13:59:02 2017
@author: Shuto Araki
"""
import os
from Tkinter import *
import chimera
from chimera.baseDialog import ModelessDialog
import MutationHighlighter as mh
#filename = os.path.abspath(os.path.join('/MutationHighlighter/', 'csvSample.csv'))
filename = os.path.dirname(__file__) + "/csvSample.csv"
def extractProteinNames():
import csv
f = open(filename, 'rU')
data = csv.reader(f)
proteins = []
for row in data:
proteins.append(row[0])
proteins.remove('Gene ID')
proteinNames = sorted(set(proteins), key = proteins.index)
return proteinNames
proteinNames = extractProteinNames()
proteinMap = {}
for i in range(len(proteinNames)):
proteinMap.update({proteinNames[i]:i})
class MutationDialog(ModelessDialog):
name = "Rare Genetic Disease Mutation Highlighter"
def fillInUI(self, parent):
topText = Label(parent, text = " Select Gene ",
font = ("Helvetica", 13, "normal"))
global hbond
hbond = IntVar()
cbA = Checkbutton(parent, text="detect H-bonds", variable=hbond)
global namesel
namesel = IntVar()
cbB = Checkbutton(parent, text="create named selections", variable=namesel)
global var
var = StringVar(parent)
var.set(proteinNames[0])
options = OptionMenu(parent, var, *proteinNames)
# Layouts
topText.grid(row=0, column=0)
options.grid(row=0, column=1)
cbA.grid(row=1, column=0)
cbB.grid(row=1, column=1)
def Apply(self):
protein_num = proteinMap[var.get()]
mh.highlightMutation(filename, protein_num, hbond.get(), namesel.get())
chimera.dialogs.register(MutationDialog.name, MutationDialog)
dir, file = os.path.split(__file__)
icon = os.path.join(dir, 'ExtensionUI.tiff')
chimera.tkgui.app.toolbar.add(icon, lambda d=chimera.dialogs.display,
n=MutationDialog.name: d(n), MutationDialog.name, None)