emmas96 commited on
Commit
7f14dcf
·
1 Parent(s): 97213c3

omit protein display temporarily

Browse files
Files changed (1) hide show
  1. app.py +61 -2
app.py CHANGED
@@ -43,6 +43,7 @@ def about_page():
43
  #st.image('hyper-dti.png') todo
44
  )
45
 
 
46
  def display_dti():
47
  st.markdown('##')
48
  smiles = st.text_input("Enter the SMILES of the query drug compound", value="CC(=O)OC1=CC=CC=C1C(=O)O", placeholder="CC(=O)OC1=CC=CC=C1C(=O)O")
@@ -59,12 +60,70 @@ def display_dti():
59
  st.write("")
60
  st.markdown('##')
61
 
 
 
 
62
  sequence = st.text_input("Enter the amino-acid sequence of the query protein target", value="HXHVWPVQDAKARFSEFLDACITEGPQIVSRRGAEEAVLVPIGEWRRLQAAA", placeholder="HXHVWPVQDAKARFSEFLDACITEGPQIVSRRGAEEAVLVPIGEWRRLQAAA")
63
 
64
  if sequence:
65
- st.markdown(f'TODO plot {sequence}')
 
 
 
 
 
 
66
 
67
- # example proteins ["HXHVWPVQDAKARFSEFLDACITEGPQIVSRRGAEEAVLVPIGEWRRLQAAA"], ["AHKLFIGGLPNYLNDDQVKELLTSFGPLKAFNLVKDSATGLSKGYAFCEYVDINVTDQAIAGLNGMQLGDKKLLVQRASVGAKNA"]
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
68
 
69
  page_names_to_func = {
70
  'About': about_page,
 
43
  #st.image('hyper-dti.png') todo
44
  )
45
 
46
+
47
  def display_dti():
48
  st.markdown('##')
49
  smiles = st.text_input("Enter the SMILES of the query drug compound", value="CC(=O)OC1=CC=CC=C1C(=O)O", placeholder="CC(=O)OC1=CC=CC=C1C(=O)O")
 
60
  st.write("")
61
  st.markdown('##')
62
 
63
+
64
+ def display_protein():
65
+ """
66
  sequence = st.text_input("Enter the amino-acid sequence of the query protein target", value="HXHVWPVQDAKARFSEFLDACITEGPQIVSRRGAEEAVLVPIGEWRRLQAAA", placeholder="HXHVWPVQDAKARFSEFLDACITEGPQIVSRRGAEEAVLVPIGEWRRLQAAA")
67
 
68
  if sequence:
69
+ def esm_search(model, sequnce, batch_converter,top_k=5):
70
+ batch_labels, batch_strs, batch_tokens = batch_converter([("protein1", sequnce),])
71
+
72
+ # Extract per-residue representations (on CPU)
73
+ with torch.no_grad():
74
+ results = model(batch_tokens, repr_layers=[12], return_contacts=True)
75
+ token_representations = results["representations"][12]
76
 
77
+ token_list = token_representations.tolist()[0][0][0]
78
+
79
+ client = Client(
80
+ url=st.secrets["DB_URL"], user=st.secrets["USER"], password=st.secrets["PASSWD"])
81
+
82
+ result = client.fetch("SELECT seq, distance('topK=500')(representations, " + str(token_list) + ')'+ "as dist FROM default.esm_protein_indexer_768")
83
+
84
+ result_temp_seq = []
85
+
86
+ for i in result:
87
+ # result_temp_coords = i['seq']
88
+ result_temp_seq.append(i['seq'])
89
+
90
+ result_temp_seq = list(set(result_temp_seq))
91
+
92
+ result_temp_seq = esm_search(model, sequence, esm_search,top_k=5)
93
+ st.text('search result: ')
94
+ # tab1, tab2, tab3, tab4, = st.tabs(["Cat", "Dog", "Owl"])
95
+ if st.button(result_temp_seq[0]):
96
+ print(result_temp_seq[0])
97
+ elif st.button(result_temp_seq[1]):
98
+ print(result_temp_seq[1])
99
+ elif st.button(result_temp_seq[2]):
100
+ print(result_temp_seq[2])
101
+ elif st.button(result_temp_seq[3]):
102
+ print(result_temp_seq[3])
103
+ elif st.button(result_temp_seq[4]):
104
+ print(result_temp_seq[4])
105
+
106
+ start[2] = st.pyplot(visualize_3D_Coordinates(result_temp_coords).figure)
107
+ def show_protein_structure(sequence):
108
+ headers = {
109
+ 'Content-Type': 'application/x-www-form-urlencoded',
110
+ }
111
+ response = requests.post('https://api.esmatlas.com/foldSequence/v1/pdb/', headers=headers, data=sequence)
112
+ name = sequence[:3] + sequence[-3:]
113
+ pdb_string = response.content.decode('utf-8')
114
+ with open('predicted.pdb', 'w') as f:
115
+ f.write(pdb_string)
116
+ struct = bsio.load_structure('predicted.pdb', extra_fields=["b_factor"])
117
+ b_value = round(struct.b_factor.mean(), 4)
118
+ render_mol(pdb_string)
119
+ if residues_marker:
120
+ start[3] = showmol(render_pdb_resn(viewer = render_pdb(id = id_PDB),resn_lst = [residues_marker]))
121
+ else:
122
+ start[3] = showmol(render_pdb(id = id_PDB))
123
+ st.session_state['xq'] = st.session_state.model
124
+
125
+ # example proteins ["HXHVWPVQDAKARFSEFLDACITEGPQIVSRRGAEEAVLVPIGEWRRLQAAA"], ["AHKLFIGGLPNYLNDDQVKELLTSFGPLKAFNLVKDSATGLSKGYAFCEYVDINVTDQAIAGLNGMQLGDKKLLVQRASVGAKNA"]
126
+ """
127
 
128
  page_names_to_func = {
129
  'About': about_page,