PrimeIntellect/SWE-rebench-V2 huggingface dataset:
Repository: cogent3/cogent3 (python)

Issue:
improve error message for invalid sequence file format
The so-called "relaxed" phylip format is not handled by the cogent3's phylip parser. But worse is that the error message is not very informative.
For the attached minimal file [locus-0.phy.zip](https://github.com/cogent3/cogent3/files/13421981/locus-0.phy.zip), I get the following error
```python
from cogent3 import load_aligned_seqs

aln = load_aligned_seqs("/Users/gavin/Desktop/Inbox/locus-0.phy", format="phylip", moltype="dna")
```
gives
```
...
   [3840](https://untitled+.vscode-resource.vscode-cdn.net/~/miniconda3/envs/c311/lib/python3.11/site-packages/cogent3/core/alignment.py:3840) seq_lengths = set(len(s) for s in seqs)
   [3841](https://untitled+.vscode-resource.vscode-cdn.net/~/miniconda3/envs/c311/lib/python3.11/site-packages/cogent3/core/alignment.py:3841) if len(seq_lengths) != 1:
-> [3842](https://untitled+.vscode-resource.vscode-cdn.net/~/miniconda3/envs/c311/lib/python3.11/site-packages/cogent3/core/alignment.py:3842)     raise ValueError("not all sequences have same length")

ValueError: not all sequences have same length
```


Pull request:
feature/issue 1632
ENH: Improved error message for sequence length validation, fixed #1632
Added a clear and informative error message that triggers if input sequences are not of the same length, detailing the unique lengths found.

Patch:
diff --git a/src/cogent3/core/alignment.py b/src/cogent3/core/alignment.py
index 4e8860f78..37f29b74e 100644
--- a/src/cogent3/core/alignment.py
+++ b/src/cogent3/core/alignment.py
@@ -5529,6 +5529,14 @@ def _coerce_to_array_aligned_seqs(data, names, label_to_name=str, moltype=None)
         seq = _construct_array_aligned_seq(data[name], moltype=moltype)
         seqs.append(seq)
 
+    # Ensure all sequences are of equal length
+    seq_lengths = {len(seq) for seq in seqs}
+    if len(seq_lengths) > 1:
+        raise ValueError(f"Input sequences are not all the same length: {seq_lengths}. "
+                         "Please ensure all sequences are properly aligned or "
+                         "correct the input file format.")
+
+
     return numpy.array(seqs), names
 
 


Test patch:
diff --git a/tests/test_core/test_alignment.py b/tests/test_core/test_alignment.py
index db1764a56..ffec7bb5a 100644
--- a/tests/test_core/test_alignment.py
+++ b/tests/test_core/test_alignment.py
@@ -3613,3 +3613,9 @@ def test_positions(cls):
     r.names = ["a", "b", "c"]
     expect = [list(v) for v in ("AAA", "AAA", "AAA", "A-A", "A--", "A--")]
     assert list(r.positions) == expect
+
+
+def test_array_align_error_with_mixed_length():
+    data = dict(s1="ACGG", s2="A-G")
+    with pytest.raises(ValueError, match=".* not all the same length.*"):
+        make_aligned_seqs(data=data)
\ No newline at end of file