Spaces:
Running
Running
Update
Browse files- .ipynb_checkpoints/app-checkpoint.py +17 -16
- app.py +17 -16
.ipynb_checkpoints/app-checkpoint.py
CHANGED
@@ -215,10 +215,10 @@ def fetch_pdb(pdb_id):
|
|
215 |
print(f"Error fetching PDB: {e}")
|
216 |
return None
|
217 |
|
218 |
-
|
219 |
def score_to_color(score):
|
220 |
-
norm = Normalize(vmin=0, vmax=1) #
|
221 |
-
color_map = cm.
|
222 |
rgba = color_map(norm(score)) # Get RGBA values
|
223 |
hex_color = '#{:02x}{:02x}{:02x}'.format(int(rgba[0] * 255), int(rgba[1] * 255), int(rgba[2] * 255))
|
224 |
return hex_color
|
@@ -247,8 +247,10 @@ def process_pdb(pdb_id):
|
|
247 |
reps = [
|
248 |
{
|
249 |
"model": 0,
|
|
|
|
|
250 |
"style": "cartoon",
|
251 |
-
"color": "
|
252 |
"residue_range": "",
|
253 |
"around": 0,
|
254 |
"byres": False,
|
@@ -257,21 +259,20 @@ def process_pdb(pdb_id):
|
|
257 |
]
|
258 |
|
259 |
# Add color-coded residues based on binding site scores
|
260 |
-
for i, score in enumerate(normalized_scores):
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
|
272 |
# Create Molecule3D with the PDB file and representations
|
273 |
molecule_viewer = Molecule3D(
|
274 |
-
file=filtered_pdb_path,
|
275 |
reps=reps
|
276 |
)
|
277 |
|
|
|
215 |
print(f"Error fetching PDB: {e}")
|
216 |
return None
|
217 |
|
218 |
+
|
219 |
def score_to_color(score):
|
220 |
+
norm = Normalize(vmin=0, vmax=1) # Normalize scores between 0 and 1
|
221 |
+
color_map = cm.coolwarm # Directly use the colormap (e.g., 'cividis', 'coolwarm', etc.)
|
222 |
rgba = color_map(norm(score)) # Get RGBA values
|
223 |
hex_color = '#{:02x}{:02x}{:02x}'.format(int(rgba[0] * 255), int(rgba[1] * 255), int(rgba[2] * 255))
|
224 |
return hex_color
|
|
|
247 |
reps = [
|
248 |
{
|
249 |
"model": 0,
|
250 |
+
"chain": "",
|
251 |
+
"resname": "",
|
252 |
"style": "cartoon",
|
253 |
+
"color": "spectrum",
|
254 |
"residue_range": "",
|
255 |
"around": 0,
|
256 |
"byres": False,
|
|
|
259 |
]
|
260 |
|
261 |
# Add color-coded residues based on binding site scores
|
262 |
+
#for i, score in enumerate(normalized_scores):
|
263 |
+
# if score > 0.7: # You can adjust this threshold
|
264 |
+
# reps.append({
|
265 |
+
# "model": 0,
|
266 |
+
# "chain": chain.get_id(),
|
267 |
+
# "style": "stick",
|
268 |
+
# "color": score_to_color(score),
|
269 |
+
# "residue_range": f"{i+1}-{i+1}",
|
270 |
+
# "byres": True,
|
271 |
+
# "visible": True
|
272 |
+
# })
|
273 |
|
274 |
# Create Molecule3D with the PDB file and representations
|
275 |
molecule_viewer = Molecule3D(
|
|
|
276 |
reps=reps
|
277 |
)
|
278 |
|
app.py
CHANGED
@@ -215,10 +215,10 @@ def fetch_pdb(pdb_id):
|
|
215 |
print(f"Error fetching PDB: {e}")
|
216 |
return None
|
217 |
|
218 |
-
|
219 |
def score_to_color(score):
|
220 |
-
norm = Normalize(vmin=0, vmax=1) #
|
221 |
-
color_map = cm.
|
222 |
rgba = color_map(norm(score)) # Get RGBA values
|
223 |
hex_color = '#{:02x}{:02x}{:02x}'.format(int(rgba[0] * 255), int(rgba[1] * 255), int(rgba[2] * 255))
|
224 |
return hex_color
|
@@ -247,8 +247,10 @@ def process_pdb(pdb_id):
|
|
247 |
reps = [
|
248 |
{
|
249 |
"model": 0,
|
|
|
|
|
250 |
"style": "cartoon",
|
251 |
-
"color": "
|
252 |
"residue_range": "",
|
253 |
"around": 0,
|
254 |
"byres": False,
|
@@ -257,21 +259,20 @@ def process_pdb(pdb_id):
|
|
257 |
]
|
258 |
|
259 |
# Add color-coded residues based on binding site scores
|
260 |
-
for i, score in enumerate(normalized_scores):
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
|
265 |
-
|
266 |
-
|
267 |
-
|
268 |
-
|
269 |
-
|
270 |
-
|
271 |
|
272 |
# Create Molecule3D with the PDB file and representations
|
273 |
molecule_viewer = Molecule3D(
|
274 |
-
file=filtered_pdb_path,
|
275 |
reps=reps
|
276 |
)
|
277 |
|
|
|
215 |
print(f"Error fetching PDB: {e}")
|
216 |
return None
|
217 |
|
218 |
+
|
219 |
def score_to_color(score):
|
220 |
+
norm = Normalize(vmin=0, vmax=1) # Normalize scores between 0 and 1
|
221 |
+
color_map = cm.coolwarm # Directly use the colormap (e.g., 'cividis', 'coolwarm', etc.)
|
222 |
rgba = color_map(norm(score)) # Get RGBA values
|
223 |
hex_color = '#{:02x}{:02x}{:02x}'.format(int(rgba[0] * 255), int(rgba[1] * 255), int(rgba[2] * 255))
|
224 |
return hex_color
|
|
|
247 |
reps = [
|
248 |
{
|
249 |
"model": 0,
|
250 |
+
"chain": "",
|
251 |
+
"resname": "",
|
252 |
"style": "cartoon",
|
253 |
+
"color": "spectrum",
|
254 |
"residue_range": "",
|
255 |
"around": 0,
|
256 |
"byres": False,
|
|
|
259 |
]
|
260 |
|
261 |
# Add color-coded residues based on binding site scores
|
262 |
+
#for i, score in enumerate(normalized_scores):
|
263 |
+
# if score > 0.7: # You can adjust this threshold
|
264 |
+
# reps.append({
|
265 |
+
# "model": 0,
|
266 |
+
# "chain": chain.get_id(),
|
267 |
+
# "style": "stick",
|
268 |
+
# "color": score_to_color(score),
|
269 |
+
# "residue_range": f"{i+1}-{i+1}",
|
270 |
+
# "byres": True,
|
271 |
+
# "visible": True
|
272 |
+
# })
|
273 |
|
274 |
# Create Molecule3D with the PDB file and representations
|
275 |
molecule_viewer = Molecule3D(
|
|
|
276 |
reps=reps
|
277 |
)
|
278 |
|