Skip to content

Commit d7133ca

Browse files
committed
Fix ArrayIndexOutOfBounds due to iterating over too-short proteins
1 parent a34b1bb commit d7133ca

2 files changed

Lines changed: 13 additions & 6 deletions

File tree

biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/CeSymm.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -241,7 +241,7 @@ protected AFPChain align(Atom[] ca10, Atom[] ca2O, Object param)
241241

242242
//Save the results to the CeSymm member variables
243243
afpChain = afpAlignments.get(0);
244-
String name = ca1[0].getGroup().getChain().getParent().getIdentifier();
244+
String name = ca1[0].getGroup().getChain().getStructure().getIdentifier();
245245
afpChain.setName1(name);
246246
afpChain.setName2(name);
247247

biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/CeSymmIterative.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
import org.biojava.nbio.structure.align.multiple.MultipleAlignmentImpl;
1818
import org.biojava.nbio.structure.align.multiple.util.MultipleAlignmentScorer;
1919
import org.biojava.nbio.structure.symmetry.utils.SymmetryTools;
20+
import org.slf4j.Logger;
21+
import org.slf4j.LoggerFactory;
2022

2123
/**
2224
* Iterative version of CeSymm that aims at identifying all symmetry axis
@@ -35,6 +37,8 @@
3537
* @since 4.2.0
3638
*/
3739
public class CeSymmIterative {
40+
41+
private static Logger logger = LoggerFactory.getLogger(CeSymmIterative.class);
3842

3943
private CESymmParameters params;
4044
private MultipleAlignment msa;
@@ -90,7 +94,7 @@ public MultipleAlignment execute(Atom[] atoms)
9094
alignment.add(new ArrayList<Integer>());
9195
}
9296

93-
iterate(atoms, 0);
97+
iterate(atoms);
9498
buildAlignment();
9599
recoverAxes();
96100

@@ -102,11 +106,13 @@ public MultipleAlignment execute(Atom[] atoms)
102106
* until no more symmetries exist.
103107
*
104108
* @param atoms Coordinates of the structure atoms
105-
* @param first starting position of the atom array in the original array
106109
* @throws StructureException
107110
*/
108-
private void iterate(Atom[] atoms, int first) throws StructureException {
109-
111+
private void iterate(Atom[] atoms) throws StructureException {
112+
if( atoms.length <= params.getWinSize() || atoms.length <= params.getMinSubunitLength()) {
113+
logger.debug("Aborting iteration due to insufficient length: %d",atoms.length);
114+
return;
115+
}
110116
//Perform the CeSymm alignment
111117
CeSymm aligner = new CeSymm();
112118
MultipleAlignment align = aligner.analyze(atoms, params);
@@ -150,7 +156,8 @@ else if (align.getScore(MultipleAlignmentScorer.AVGTM_SCORE) <
150156
}
151157
//Iterate further
152158
Atom[] atomsR = Arrays.copyOfRange(atoms, start, end+1);
153-
iterate(atomsR, start+first);
159+
160+
iterate(atomsR);
154161
}
155162

156163
private void buildAlignment() throws StructureException {

0 commit comments

Comments
 (0)