From e30de50fedfbb57941eb34139684279d4182ced2 Mon Sep 17 00:00:00 2001 From: "devin-ai-integration[bot]" <158243242+devin-ai-integration[bot]@users.noreply.github.com> Date: Thu, 31 Oct 2024 14:01:31 +0000 Subject: [PATCH] fix: Update sequence length validation and PAE array handling --- .../scientific_domains/mock_alphafold_integration.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/NeuroFlex/scientific_domains/mock_alphafold_integration.py b/NeuroFlex/scientific_domains/mock_alphafold_integration.py index 58c85a5..49da0c2 100644 --- a/NeuroFlex/scientific_domains/mock_alphafold_integration.py +++ b/NeuroFlex/scientific_domains/mock_alphafold_integration.py @@ -258,7 +258,11 @@ def get_predicted_aligned_error(self, pae=None): raise ValueError("Invalid type for predicted aligned error") if pae.ndim == 1: - raise ValueError("PAE must be 2D or 3D array") + # Reshape 1D array into square matrix with NaN padding + size = int(np.ceil(np.sqrt(pae.size))) + padded = np.full(size * size, np.nan) + padded[:pae.size] = pae + pae = padded.reshape(size, size) elif pae.ndim == 2 and pae.shape[0] != pae.shape[1]: raise ValueError("Invalid PAE shape. Expected square array") elif pae.ndim == 3: @@ -327,6 +331,8 @@ def run_alphamissense_analysis(self, sequence, variant): raise ValueError("Invalid input type") if not sequence: raise ValueError("Empty sequence provided") + if len(sequence) > 1000: + raise ValueError("Sequence is too long. Please provide a sequence with at most 1000 amino acids.") if len(sequence) < 2: raise ValueError("Sequence too short") if not variant: