Skip to content

Commit

Permalink
Made a bit more space on the report to have up to 16 chains - will ne…
Browse files Browse the repository at this point in the history
…ed to work on ... button
  • Loading branch information
glycojones committed Jul 3, 2024
1 parent 984b52d commit 0a3a5c6
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 27 deletions.
1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ Issues = "https://github.com/glycojones/iris-validation/issues"
[tool.pytest.ini_options]
markers = [
"slow: marks tests as slow (deselect with '-m \"not slow\"')",
"simple: a simple test to get output quickly (deselect with '-m \"not simple\"')",
"tortoize: runs tortoize tests (deselect with '-m \"not tortoize\"')",
"molprobity: runs molprobity tests (deselect with '-m \"not molprobity\"')",
"problem",
Expand Down
9 changes: 9 additions & 0 deletions src/iris_validation/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import os
import sys
import json

from iris_validation.graphics import Panel
from iris_validation.metrics import metrics_model_series_from_files

PYTEST_RUN = 'pytest' in sys.modules

def generate_report(
latest_model_path,
Expand Down Expand Up @@ -44,7 +47,13 @@ def generate_report(
calculate_rama_z,
data_with_percentiles,
multiprocessing)

model_series_data = model_series.get_raw_data()

if PYTEST_RUN :
with open(os.path.join(output_dir, output_name_prefix + ".json"), 'w', encoding='utf8') as json_output :
json.dump(model_series_data, json_output, indent=2)

panel = Panel(
model_series_data,
continuous_metrics_to_display=continuous_metrics_to_display,
Expand Down
2 changes: 1 addition & 1 deletion src/iris_validation/graphics/js/interaction.js
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ function updateSelectedResidue() {
// Set summary text
let seqNum = modelData[selectedChain]['residue_seqnos'][selectedVersion][selectedResidue];
let aaCode = modelData[selectedChain]['residue_codes'][selectedVersion][selectedResidue];
residueSummary.textContent = 'Residue ' + seqNum + ' (' + aaCode + ')';
residueSummary.textContent = seqNum + ' (' + aaCode + ')';
};


Expand Down
40 changes: 23 additions & 17 deletions src/iris_validation/graphics/panel.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ def _draw(self):
middle_gap = 30
view_border = 10
view_title_font = 24
button_width = 38
button_height = 32
button_width = 26
button_height = 26
view_width, view_height = [ dim - view_border for dim in self.canvas_size ]
view_divider_x = round(2/3 * view_width, 2)
chain_view_bounds = (view_border,
Expand Down Expand Up @@ -183,9 +183,15 @@ def _draw(self):
font_size=view_title_font,
font_family='Arial'))

self.dwg.add(self.dwg.text(text='Residue',

self.dwg.add(self.dwg.text(text='Amino acid',
insert=(residue_view_bounds[0], residue_view_bounds[1]+view_title_font),
font_size=view_title_font,
font_family='Arial'))

self.dwg.add(self.dwg.text(text='',
insert=(residue_view_bounds[0]+130, residue_view_bounds[1]+view_title_font),
font_size=16,
font_family='Arial',
id=f'{self.svg_id}-residue-summary'))

Expand All @@ -200,9 +206,9 @@ def _draw(self):
stroke_width=2))

# Chain selector buttons
for chain_index, chain_id in enumerate(self.chain_ids[:12]):
for chain_index, chain_id in enumerate(self.chain_ids[:16]):
selector_color = self.swtich_colors[1] if chain_index == 0 else self.swtich_colors[0]
self.dwg.add(self.dwg.rect(insert=(chain_view_bounds[0] + 75 + 50*chain_index, chain_view_bounds[1]),
self.dwg.add(self.dwg.rect(insert=(chain_view_bounds[0] + 75 + 30*chain_index, chain_view_bounds[1]+5),
size=(button_width, button_height),
rx=5,
stroke_opacity=0,
Expand All @@ -211,13 +217,13 @@ def _draw(self):
id=f'{self.svg_id}-chain-selector-{chain_index}'))

self.dwg.add(self.dwg.text(text=chain_id,
insert=(chain_view_bounds[0] + 75 + button_width/2 + 50*chain_index, chain_view_bounds[1] + button_height/2),
font_size=view_title_font,
insert=(chain_view_bounds[0] + 75 + button_width/2 + 30*chain_index, chain_view_bounds[1] + 5 + button_height/2),
font_size=16,
font_family='Arial',
text_anchor='middle',
alignment_baseline='central'))

self.dwg.add(self.dwg.rect(insert=(chain_view_bounds[0] + 75 + 50*chain_index, chain_view_bounds[1]),
self.dwg.add(self.dwg.rect(insert=(chain_view_bounds[0] + 75 + 30*chain_index, chain_view_bounds[1]+5),
size=(button_width, button_height),
rx=5,
stroke_opacity=0,
Expand All @@ -228,24 +234,24 @@ def _draw(self):

# Extra chains dropdown
# TODO: finish this
if len(self.chain_ids) > 12:
chain_index = 12
if len(self.chain_ids) > 16:
chain_index = 16
selector_color = self.swtich_colors[0]
self.dwg.add(self.dwg.rect(insert=(chain_view_bounds[0] + 75 + 50*chain_index, chain_view_bounds[1]),
size=(38, 32),
self.dwg.add(self.dwg.rect(insert=(chain_view_bounds[0] + 75 + 30*chain_index, chain_view_bounds[1] +5),
size=(26, 26),
rx=5,
stroke_opacity=0,
fill_opacity=0.5,
fill=selector_color,
id=f'{self.svg_id}-chain-selector-dropdown'))

self.dwg.add(self.dwg.text(text='...',
insert=(chain_view_bounds[0] + 85 + 50*chain_index, chain_view_bounds[1]+view_title_font),
font_size=view_title_font,
insert=(chain_view_bounds[0] + 80 + 30*chain_index, chain_view_bounds[1]+24),
font_size=16,
font_family='Arial'))

self.dwg.add(self.dwg.rect(insert=(chain_view_bounds[0] + 75 + 50*chain_index, chain_view_bounds[1]),
size=(38, 32),
self.dwg.add(self.dwg.rect(insert=(chain_view_bounds[0] + 75 + 30*chain_index, chain_view_bounds[1]+5),
size=(26, 26),
rx=5,
stroke_opacity=0,
fill_opacity=0,
Expand All @@ -255,7 +261,7 @@ def _draw(self):

# Version toggle switch
self.dwg.add(self.dwg.text(text='Model version',
insert=(chain_view_bounds[2]-385, chain_view_bounds[1]+20),
insert=(chain_view_bounds[2]-380, chain_view_bounds[1]+20),
font_size=view_title_font,
font_family='Arial'))

Expand Down
4 changes: 2 additions & 2 deletions src/iris_validation/graphics/residue.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,8 +145,8 @@ def _draw(self):
self.dwg.add(
self.dwg.text(
self.percentile_bar_label,
insert=(self.canvas_size[0] / 2, bar_charts_bounds[3] + 50),
font_size=18,
insert=((self.canvas_size[0] / 2)+20, bar_charts_bounds[3] + 60),
font_size=24,
font_family="Arial",
fill=COLORS["BLACK"],
fill_opacity=1,
Expand Down
7 changes: 1 addition & 6 deletions src/iris_validation/metrics/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from iris_validation.metrics.series import MetricsModelSeries
from iris_validation.metrics.reflections import ReflectionsHandler

PYTEST_RUN = 'pytest' in sys.modules

def _get_minimol_from_path(model_path):
fpdb = clipper.MMDBfile()
Expand Down Expand Up @@ -190,9 +189,7 @@ def _get_tortoize_data(model_path, seq_nums, model_id=None, out_queue=None):

tortoize_output = tortoize_process.communicate()[0]
tortoize_dict = json.loads(tortoize_output)
if PYTEST_RUN :
with open("tortoize.json", "w") as json_output :
json.dump(tortoize_dict, json_output, indent=2)

residues = tortoize_dict["model"]["1"]["residues"]
for res in residues:
rama_z_data[res['pdb']['strandID']][res['pdb']['seqNum']] = res['ramachandran']['z-score']
Expand Down Expand Up @@ -320,8 +317,6 @@ def metrics_model_series_from_files(model_paths,
else:
rama_z_data = _get_tortoize_data(model_path, seq_nums)

if multiprocessing and PYTEST_RUN :
print (f"\nNumber of data sources queued: {num_queued}")
all_minimol_data.append(minimol)
all_covariance_data.append(covariance_data)
all_molprobity_data.append(molprobity_data)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_core.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
DATASET1_PATH = str(os.path.join(INPUT_DIR, "3atp")) + '{suffix}'
DATASET2_PATH = str(os.path.join(INPUT_DIR, "8ira")) + '{suffix}'


@pytest.mark.simple
def test_2m2d_noCOV_noMP_noRamaZ_mpro ():
import iris_validation as iris
importlib.reload(iris)
Expand Down

0 comments on commit 0a3a5c6

Please sign in to comment.