Skip to content

Commit d365f3f

Browse files
committed
Fix bug when an empty alignment is produced in CeSymm
This was solved by throwing a RefinerException and allowing missing information in the AFPChain to MultipleAlignment conversion method.
1 parent 156a6e2 commit d365f3f

5 files changed

Lines changed: 29 additions & 9 deletions

File tree

biojava-structure/src/main/java/org/biojava/nbio/structure/align/multiple/MultipleAlignmentEnsembleImpl.java

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,12 @@ public MultipleAlignmentEnsembleImpl(
149149
if (flexible){
150150
for (int bs=0; bs<afp.getBlockNum(); bs++){
151151
BlockSet blockSet = new BlockSetImpl(msa);
152-
Matrix4d blockTr = Calc.getTransformation(rot[bs], shift[bs]);
152+
Matrix4d blockTr = null;
153+
try {
154+
blockTr = Calc.getTransformation(rot[bs], shift[bs]);
155+
} catch (IndexOutOfBoundsException e){
156+
blockTr = ident;
157+
}
153158
blockSet.setTransformations(Arrays.asList(ident, blockTr));
154159
Block block = new BlockImpl(blockSet);
155160
block.setAlignRes(new ArrayList<List<Integer>>());
@@ -171,7 +176,12 @@ public MultipleAlignmentEnsembleImpl(
171176
} //Create a Block for every block in AFPChain if not flexible
172177
else {
173178
BlockSet blockSet = new BlockSetImpl(msa);
174-
Matrix4d blockTr = Calc.getTransformation(rot[0], shift[0]);
179+
Matrix4d blockTr = null;
180+
try {
181+
blockTr = Calc.getTransformation(rot[0], shift[0]);
182+
} catch (IndexOutOfBoundsException e){
183+
blockTr = ident;
184+
}
175185
blockSet.setTransformations(Arrays.asList(ident, blockTr));
176186
for (int bs=0; bs<afp.getBlockNum(); bs++){
177187
Block block = new BlockImpl(blockSet);

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -371,8 +371,7 @@ public boolean isSignificant() throws StructureException {
371371

372372
/**
373373
* If available, get the list of subalignments.<p>
374-
* Should be length one unless {@link CESymmParameters#getMaxSymmOrder()}
375-
* was set.
374+
* Should be length one unless using the MULTIPLE refiner.
376375
* @return List of AFP alignments
377376
*/
378377
public List<AFPChain> getAfpAlignments() {

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

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,8 @@
3838
*/
3939
public class CeSymmIterative {
4040

41-
private static Logger logger = LoggerFactory.getLogger(CeSymmIterative.class);
41+
private static Logger logger =
42+
LoggerFactory.getLogger(CeSymmIterative.class);
4243

4344
private CESymmParameters params;
4445
private MultipleAlignment msa;
@@ -109,17 +110,23 @@ public MultipleAlignment execute(Atom[] atoms)
109110
* @throws StructureException
110111
*/
111112
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);
113+
114+
logger.debug("Starting new iteration...");
115+
116+
if( atoms.length <= params.getWinSize() ||
117+
atoms.length <= params.getMinSubunitLength()) {
118+
logger.debug("Aborting iteration due to insufficient Atom "
119+
+ "array length: %d", atoms.length);
114120
return;
115121
}
122+
116123
//Perform the CeSymm alignment
117124
CeSymm aligner = new CeSymm();
118125
MultipleAlignment align = aligner.analyze(atoms, params);
119126
if (name == null)
120127
name = align.getEnsemble().getStructureNames().get(0);
121128

122-
//End iterations if non symmetric
129+
//End iterations if asymmetric
123130
if (!SymmetryTools.isRefined(align)) return;
124131
else if (align.getScore(MultipleAlignmentScorer.AVGTM_SCORE) <
125132
params.getSymmetryThreshold() ||

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

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,10 @@ else if (neigh.size() > 0) {
134134
if (group.size()==order) subunits.add(group);
135135
}
136136
}
137+
138+
if (subunits.size() == 0){
139+
throw new RefinerFailedException("Empty alignment");
140+
}
137141

138142
int[][][] optAln = new int[order][2][subunits.size()];
139143
for (int bk=0; bk<order; bk++){

biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/utils/SymmetryTools.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -443,7 +443,7 @@ public static Structure getQuaternaryStructure(MultipleAlignment symmetry) {
443443
}
444444

445445
Atom[] atoms = symmetry.getAtomArrays().get(0);
446-
Structure cloned = atoms[0].getGroup().getChain().getParent().clone();
446+
Structure cloned = atoms[0].getGroup().getChain().getStructure().clone();
447447
atoms = StructureTools.getRepresentativeAtomArray(cloned);
448448

449449
Structure symm = new StructureImpl();

0 commit comments

Comments
 (0)