From 7151e34ab9a7ad85c0648072a1467031106f32e4 Mon Sep 17 00:00:00 2001 From: gph82 Date: Thu, 18 Dec 2025 10:40:41 +0100 Subject: [PATCH 1/2] [structure.superposition.sequences.fasta2select] BUGFIX: check GAP character between first and second sequence (old was checking 2nd vs 2nd) --- opencadd/structure/superposition/sequences.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/opencadd/structure/superposition/sequences.py b/opencadd/structure/superposition/sequences.py index e97c87ba..06c5eb79 100644 --- a/opencadd/structure/superposition/sequences.py +++ b/opencadd/structure/superposition/sequences.py @@ -213,7 +213,7 @@ def resid(nseq, ipos, t=t, s=s): # should be the same for both seqs GAP = find_gap_character(a.seq) - if GAP != find_gap_character(alignment[1].seq): + if GAP != find_gap_character(alignment[0].seq): raise ValueError("Different gap characters in sequence 'target' and 'mobile'.") for ipos in range(alignment.get_alignment_length()): aligned = list(alignment[:, ipos]) From 5f9e18f89a28c5f51218bc2a5ae92d24ff92fdfa Mon Sep 17 00:00:00 2001 From: gph82 Date: Thu, 18 Dec 2025 16:36:57 +0100 Subject: [PATCH 2/2] [structure.superposition.sequences.fasta2select] ENH: don't fail on gapless-sequences. Old: if gap char was "" (=None) and "-" the method would error out --- opencadd/structure/superposition/sequences.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/opencadd/structure/superposition/sequences.py b/opencadd/structure/superposition/sequences.py index 06c5eb79..e1424e16 100644 --- a/opencadd/structure/superposition/sequences.py +++ b/opencadd/structure/superposition/sequences.py @@ -212,9 +212,13 @@ def resid(nseq, ipos, t=t, s=s): res_list = [] # collect individual selection string # should be the same for both seqs - GAP = find_gap_character(a.seq) - if GAP != find_gap_character(alignment[0].seq): - raise ValueError("Different gap characters in sequence 'target' and 'mobile'.") + GAPS = [find_gap_character(a.seq) for a in alignment] + if "" not in GAPS: + if GAPS[0] != GAPS[1]: + raise ValueError(f"Different gap characters in sequence 'target' and 'mobile':{GAPS}.") + else: + GAPS.remove("") + GAP= GAPS[0] for ipos in range(alignment.get_alignment_length()): aligned = list(alignment[:, ipos]) if GAP in aligned: