diff --git a/pyproject.toml b/pyproject.toml index 437e945..773c65a 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -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", diff --git a/src/iris_validation/__init__.py b/src/iris_validation/__init__.py index 3fdcf9e..5610dc8 100644 --- a/src/iris_validation/__init__.py +++ b/src/iris_validation/__init__.py @@ -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, @@ -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, diff --git a/src/iris_validation/graphics/js/interaction.js b/src/iris_validation/graphics/js/interaction.js index 600e495..8e15a0e 100644 --- a/src/iris_validation/graphics/js/interaction.js +++ b/src/iris_validation/graphics/js/interaction.js @@ -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 + ')'; }; diff --git a/src/iris_validation/graphics/panel.py b/src/iris_validation/graphics/panel.py index 274a176..6f48eee 100644 --- a/src/iris_validation/graphics/panel.py +++ b/src/iris_validation/graphics/panel.py @@ -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, @@ -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')) @@ -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, @@ -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, @@ -228,11 +234,11 @@ 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, @@ -240,12 +246,12 @@ def _draw(self): 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, @@ -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')) diff --git a/src/iris_validation/graphics/residue.py b/src/iris_validation/graphics/residue.py index 6d9dd21..c5661ba 100644 --- a/src/iris_validation/graphics/residue.py +++ b/src/iris_validation/graphics/residue.py @@ -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, diff --git a/src/iris_validation/metrics/__init__.py b/src/iris_validation/metrics/__init__.py index 4fcfd3b..7757324 100644 --- a/src/iris_validation/metrics/__init__.py +++ b/src/iris_validation/metrics/__init__.py @@ -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() @@ -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'] @@ -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) diff --git a/tests/test_core.py b/tests/test_core.py index bf02293..6b360e4 100644 --- a/tests/test_core.py +++ b/tests/test_core.py @@ -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)