From 95db31d4682679306a2cd809cb79de404fc6a110 Mon Sep 17 00:00:00 2001 From: danielgarzonotero Date: Mon, 6 Apr 2026 10:57:54 -0400 Subject: [PATCH 1/2] Fixed indentation error for LocalColab Linux installation --- colabfold/plot.py | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/colabfold/plot.py b/colabfold/plot.py index f5b6dd76..da7996e5 100644 --- a/colabfold/plot.py +++ b/colabfold/plot.py @@ -1,10 +1,13 @@ from pathlib import Path import numpy as np +import matplotlib +matplotlib.use('Agg') +import matplotlib.pyplot as plt + def plot_predicted_alignment_error( jobname: str, num_models: int, outs: dict, result_dir: Path, show: bool = False ): - from matplotlib import pyplot as plt plt.figure(figsize=(3 * num_models, 2), dpi=100) for n, (model_name, value) in enumerate(outs.items()): plt.subplot(1, num_models, n + 1) @@ -18,17 +21,16 @@ def plot_predicted_alignment_error( def plot_msa_v2(feature_dict, sort_lines=True, dpi=100): - from matplotlib import pyplot as plt seq = feature_dict["msa"][0] if "asym_id" in feature_dict: - Ls = [0] - k = feature_dict["asym_id"][0] - for i in feature_dict["asym_id"]: - if i == k: Ls[-1] += 1 - else: Ls.append(1) - k = i + Ls = [0] + k = feature_dict["asym_id"][0] + for i in feature_dict["asym_id"]: + if i == k: Ls[-1] += 1 + else: Ls.append(1) + k = i else: - Ls = [len(seq)] + Ls = [len(seq)] Ln = np.cumsum([0] + Ls) try: @@ -58,6 +60,7 @@ def plot_msa_v2(feature_dict, sort_lines=True, dpi=100): Nn = np.cumsum(np.append(0,Nn)) lines = np.concatenate(lines,0) + plt.figure(figsize=(8,5), dpi=dpi) plt.title("Sequence coverage") plt.imshow(lines, @@ -78,11 +81,11 @@ def plot_msa_v2(feature_dict, sort_lines=True, dpi=100): return plt def plot_msa(msa, query_sequence, seq_len_list, total_seq_len, dpi=100): - from matplotlib import pyplot as plt # gather MSA info prev_pos = 0 msa_parts = [] - Ln = np.cumsum(np.append(0, [len for len in seq_len_list])) + # Corrección: Cambiado 'len' a 'l' para no sobrescribir la función integrada + Ln = np.cumsum(np.append(0, [l for l in seq_len_list])) for id, l in enumerate(seq_len_list): chain_seq = np.array(query_sequence[prev_pos : prev_pos + l]) chain_msa = np.array(msa[:, prev_pos : prev_pos + l]) @@ -97,6 +100,7 @@ def plot_msa(msa, query_sequence, seq_len_list, total_seq_len, dpi=100): non_gaps[non_gaps == 0] = np.nan msa_parts.append((non_gaps[:] * seqid[:, None]).tolist()) prev_pos += l + lines = [] lines_to_sort = [] prev_has_seq = [True] * len(seq_len_list) @@ -120,12 +124,11 @@ def plot_msa(msa, query_sequence, seq_len_list, total_seq_len, dpi=100): line += msa_parts[id][line_num] lines_to_sort.append(line) prev_has_seq = has_seq + lines_to_sort = np.array(lines_to_sort) lines_to_sort = lines_to_sort[np.argsort(-np.nanmax(lines_to_sort, axis=1))] lines += lines_to_sort.tolist() - # Nn = np.cumsum(np.append(0, Nn)) - # lines = np.concatenate(lines, 1) xaxis_size = len(lines[0]) yaxis_size = len(lines) @@ -143,10 +146,6 @@ def plot_msa(msa, query_sequence, seq_len_list, total_seq_len, dpi=100): ) for i in Ln[1:-1]: plt.plot([i, i], [0, yaxis_size], color="black") - # for i in Ln_dash[1:-1]: - # plt.plot([i, i], [0, lines.shape[0]], "--", color="black") - # for j in Nn[1:-1]: - # plt.plot([0, lines.shape[1]], [j, j], color="black") plt.plot((np.isnan(lines) == False).sum(0), color="black") plt.xlim(0, xaxis_size) @@ -155,4 +154,4 @@ def plot_msa(msa, query_sequence, seq_len_list, total_seq_len, dpi=100): plt.xlabel("Positions") plt.ylabel("Sequences") - return plt + return plt \ No newline at end of file From ff3d459acb72bc5608cc4241381cb756c9700a03 Mon Sep 17 00:00:00 2001 From: Daniel Garzon <122416545+danielgarzonotero@users.noreply.github.com> Date: Mon, 6 Apr 2026 11:56:08 -0400 Subject: [PATCH 2/2] Fix indentation error in plot.py Add a new function to plot predicted alignment error. --- colabfold/plot.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/colabfold/plot.py b/colabfold/plot.py index da7996e5..3121f4a6 100644 --- a/colabfold/plot.py +++ b/colabfold/plot.py @@ -5,6 +5,7 @@ matplotlib.use('Agg') import matplotlib.pyplot as plt + def plot_predicted_alignment_error( jobname: str, num_models: int, outs: dict, result_dir: Path, show: bool = False ): @@ -154,4 +155,4 @@ def plot_msa(msa, query_sequence, seq_len_list, total_seq_len, dpi=100): plt.xlabel("Positions") plt.ylabel("Sequences") - return plt \ No newline at end of file + return plt