Skip to content

Commit d4d3d5b

Browse files
committed
1 parent 744b2bf commit d4d3d5b

File tree

6 files changed

+47
-13
lines changed

6 files changed

+47
-13
lines changed

biojava-integrationtest/src/test/java/org/biojava/nbio/structure/test/align/ce/OptimalCECPMainTest.java

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -364,4 +364,22 @@ private static void printOptAln(AFPChain cpAlignment) {
364364
System.out.println();
365365
}
366366
}
367+
368+
public static void main(String[] args) throws Exception {
369+
// this is to test this issue:
370+
// https://github.com/rcsb/symmetry/issues/46
371+
//
372+
373+
OptimalCECPMainTest t = new OptimalCECPMainTest();
374+
System.out.println("Test 1");
375+
t.testPermuteOptAlnUnpermuted();
376+
System.out.println("Test 2");
377+
t.testOptimalAlignmentConsistency();
378+
//System.out.println("Test 3");
379+
//t.testUnpermuted();
380+
//System.out.println("Test 4");
381+
//t.testPermuteArray();
382+
//System.out.println("Test 5");
383+
//t.testPermuteOptAln();
384+
}
367385
}

biojava-structure/src/main/java/org/biojava/nbio/structure/align/StructureAlignmentFactory.java

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@ public static void clearAlgorithms() {
100100
algorithms.clear();
101101
}
102102

103-
@SuppressWarnings("unchecked")
104103
public static StructureAlignment getAlgorithm(String name) throws StructureException{
105104
for ( StructureAlignment algo : algorithms){
106105
if (algo.getAlgorithmName().equalsIgnoreCase(name)) {
@@ -109,12 +108,21 @@ public static StructureAlignment getAlgorithm(String name) throws StructureExcep
109108
// avoid issues with this in multi-threaded environments bu
110109
// creating a new StructureAlignment every time this is called
111110
try {
111+
@SuppressWarnings("unchecked")
112112
Class<StructureAlignment> c = (Class<StructureAlignment>) Class.forName(algo.getClass().getName());
113113
return c.newInstance();
114-
} catch (Exception e){
114+
} catch (ClassNotFoundException e){
115+
logger.error("Exception: ", e);
116+
return null;
117+
} catch (IllegalAccessException e){
118+
logger.error("Exception: ", e);
119+
return null;
120+
} catch (InstantiationException e){
115121
logger.error("Exception: ", e);
116122
return null;
117123
}
124+
125+
118126
}
119127
}
120128

biojava-structure/src/main/java/org/biojava/nbio/structure/align/ce/CECalculator.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,12 @@
2626

2727
import org.biojava.nbio.alignment.aaindex.ScaledSubstitutionMatrix;
2828
import org.biojava.nbio.alignment.template.SubstitutionMatrix;
29-
import org.biojava.nbio.structure.*;
29+
import org.biojava.nbio.structure.Atom;
30+
import org.biojava.nbio.structure.Calc;
31+
import org.biojava.nbio.structure.Group;
32+
import org.biojava.nbio.structure.SVDSuperimposer;
33+
import org.biojava.nbio.structure.StructureException;
34+
import org.biojava.nbio.structure.StructureTools;
3035
import org.biojava.nbio.structure.align.model.AFP;
3136
import org.biojava.nbio.structure.align.model.AFPChain;
3237
import org.biojava.nbio.structure.align.util.AFPAlignmentDisplay;

biojava-structure/src/main/java/org/biojava/nbio/structure/align/ce/CeMain.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -114,12 +114,12 @@ public AFPChain align(Atom[] ca1, Atom[] ca2, Object param) throws StructureExce
114114
afpChain.setVersion(version);
115115

116116
// Try to guess names
117-
try {
117+
118+
if (ca1.length!=0 && ca1[0].getGroup().getChain()!=null && ca1[0].getGroup().getChain().getParent()!=null)
118119
afpChain.setName1(ca1[0].getGroup().getChain().getParent().getName());
119-
} catch( Exception e) {}
120-
try {
120+
121+
if (ca2.length!=0 && ca2[0].getGroup().getChain()!=null && ca2[0].getGroup().getChain().getParent()!=null)
121122
afpChain.setName2(ca2[0].getGroup().getChain().getParent().getName());
122-
} catch( Exception e) {}
123123

124124
if ( afpChain.getNrEQR() == 0)
125125
return afpChain;

biojava-structure/src/main/java/org/biojava/nbio/structure/align/ce/OptimalCECPMain.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@
5353
*
5454
*/
5555
public class OptimalCECPMain extends CeMain {
56-
private static boolean debug = true;
56+
private static final boolean debug = true;
5757

5858

5959
public static final String algorithmName = "jCE Optimal Circular Permutation";
@@ -507,11 +507,11 @@ public AFPChain alignOptimal(Atom[] ca1, Atom[] ca2, Object param, AFPChain[] al
507507
if(debug) System.out.print(".");
508508

509509
// fix up names, since cloning ca2 wipes it
510-
try {
510+
511+
if (ca2.length!=0 && ca2[0].getGroup().getChain()!=null && ca2[0].getGroup().getChain().getParent()!=null) {
511512
currentAlignment.setName2(ca2[0].getGroup().getChain().getParent().getName()+" CP="+cp);
512-
} catch( Exception e) {
513-
//null pointers, empty arrays, etc.
514513
}
514+
515515
double currentScore = currentAlignment.getAlignScore();
516516

517517
if(alignments != null) {

biojava-structure/src/test/java/org/biojava/nbio/structure/TestDNAAlignment.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,10 @@
2424

2525
package org.biojava.nbio.structure;
2626

27+
import java.io.IOException;
28+
2729
import junit.framework.TestCase;
30+
2831
import org.biojava.nbio.structure.align.ce.CeMain;
2932
import org.biojava.nbio.structure.align.model.AFPChain;
3033
import org.biojava.nbio.structure.align.util.AtomCache;
@@ -37,7 +40,7 @@
3740
public class TestDNAAlignment extends TestCase
3841
{
3942

40-
public void test1(){
43+
public void test1() throws IOException {
4144
String name1="1l3s.A";
4245
String name2="1t7p.P";
4346

@@ -53,7 +56,7 @@ public void test1(){
5356

5457
assertNotNull(txt);
5558

56-
} catch (Exception e){
59+
} catch (StructureException e){
5760
e.printStackTrace();
5861
fail(e.getMessage());
5962
}

0 commit comments

Comments
 (0)