Skip to content

Commit

Permalink
fix: Update sequence length validation and PAE array handling
Browse files Browse the repository at this point in the history
  • Loading branch information
devin-ai-integration[bot] committed Oct 31, 2024
1 parent c8b55aa commit e30de50
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion NeuroFlex/scientific_domains/mock_alphafold_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit e30de50

Please sign in to comment.