Skip to content

Commit d6d6b40

Browse files
committed
Implement test for QsAlign algorithm
1 parent 97f2635 commit d6d6b40

File tree

3 files changed

+149
-14
lines changed

3 files changed

+149
-14
lines changed

biojava-structure/src/main/java/demo/DemoQsAlign.java

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,14 @@
88
import org.biojava.nbio.structure.align.quaternary.QsAlign;
99
import org.biojava.nbio.structure.align.quaternary.QsAlignParameters;
1010
import org.biojava.nbio.structure.align.quaternary.QsAlignResult;
11-
import org.biojava.nbio.structure.align.util.AtomCache;
1211
import org.biojava.nbio.structure.cluster.SubunitClustererParameters;
1312

1413
/**
1514
* Demo on how to use programatically {@link QsAlign} for the alignment of
1615
* quaternary structures.
1716
* <p>
18-
* Small oligomers: proliferating cell nuclear antigens (1PLR, 3HI8),
19-
* photosynthetic reaction centers (2JIY, 1DXR) ]
17+
* Small oligomers: proliferating cell nuclear antigens (1PLR, 3HI8, 3IFV),
18+
* photosynthetic reaction centers (2JIY, 1DXR)
2019
* <p>
2120
* Big oligomers: cytochrome bc1 complexes (1bcc, 1kb9, 1qcr), phycocyanin
2221
* (2VML, 2BV8), bacterial ribosome (1FJG, 4V54).
@@ -31,11 +30,6 @@ public class DemoQsAlign {
3130
public static void main(String[] args) throws IOException,
3231
StructureException {
3332

34-
// Remove lines when bug with ChemComp in MMTF is fixed TODO
35-
AtomCache cache = new AtomCache();
36-
cache.setUseMmCif(true);
37-
StructureIO.setAtomCache(cache);
38-
3933
// Align two trimeric DNA clamps
4034
Structure s1 = StructureIO.getStructure("1bcc");
4135
Structure s2 = StructureIO.getStructure("1kb9");

biojava-structure/src/main/java/org/biojava/nbio/structure/align/quaternary/QsAlignResult.java

Lines changed: 45 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,10 @@
11
package org.biojava.nbio.structure.align.quaternary;
22

3+
import java.util.ArrayList;
34
import java.util.Collections;
45
import java.util.List;
56
import java.util.Map;
7+
import java.util.stream.Collectors;
68

79
import javax.vecmath.Matrix4d;
810

@@ -154,7 +156,7 @@ public double getRmsd() {
154156
if (alignment == null)
155157
return -1.0;
156158
if (alignment.getScore(MultipleAlignmentScorer.RMSD) == null)
157-
return -1.0;
159+
return MultipleAlignmentScorer.getRMSD(alignment);
158160

159161
return alignment.getScore(MultipleAlignmentScorer.RMSD);
160162
}
@@ -200,10 +202,50 @@ public void setAlignment(MultipleAlignment alignment) {
200202
this.alignment = alignment;
201203
}
202204

205+
/**
206+
* Return the aligned subunits of the first Subunit group.
207+
*
208+
* @return a List of Subunits in the alignment order
209+
*/
210+
public List<Subunit> getAlignedSubunits1() {
211+
212+
List<Subunit> aligned = new ArrayList<Subunit>(subunitMap.size());
213+
214+
for (Integer key : subunitMap.keySet())
215+
aligned.add(subunits1.get(key));
216+
217+
return aligned;
218+
}
219+
220+
/**
221+
* Return the aligned subunits of the second Subunit group.
222+
*
223+
* @return a List of Subunits in the alignment order
224+
*/
225+
public List<Subunit> getAlignedSubunits2() {
226+
227+
List<Subunit> aligned = new ArrayList<Subunit>(subunitMap.size());
228+
229+
for (Integer key : subunitMap.keySet())
230+
aligned.add(subunits1.get(subunitMap.get(key)));
231+
232+
return aligned;
233+
}
234+
203235
@Override
204236
public String toString() {
205-
return "QsAlignResult [relation=" + relation + ", rmsd=" + getRmsd()
206-
+ ", length=" + length() + "]";
237+
return "QsAlignResult [relation="
238+
+ relation
239+
+ ", rmsd="
240+
+ getRmsd()
241+
+ ", length="
242+
+ length()
243+
+ "\n Aligned subunits 1: "
244+
+ getAlignedSubunits1().stream().map(s -> s.getName())
245+
.collect(Collectors.toList())
246+
+ "\n Aligned subunits 2: "
247+
+ getAlignedSubunits2().stream().map(s -> s.getName())
248+
.collect(Collectors.toList()) + "]";
207249
}
208250

209251
}

biojava-structure/src/test/java/org/biojava/nbio/structure/align/quaternary/TestQsAlign.java

Lines changed: 102 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
11
package org.biojava.nbio.structure.align.quaternary;
22

3+
import static org.junit.Assert.*;
4+
35
import java.io.IOException;
46

7+
import org.biojava.nbio.structure.Structure;
58
import org.biojava.nbio.structure.StructureException;
9+
import org.biojava.nbio.structure.StructureIO;
10+
import org.biojava.nbio.structure.cluster.SubunitClustererParameters;
611
import org.junit.Test;
712

813
/**
@@ -16,20 +21,67 @@
1621
public class TestQsAlign {
1722

1823
/**
19-
* Identity: test hemoglobin against itself.
24+
* Identity: test hemoglobin (4HHB) against itself.
2025
*/
2126
@Test
2227
public void testIdentity() throws StructureException, IOException {
2328

29+
Structure s1 = StructureIO.getStructure("4hhb");
30+
Structure s2 = s1;
31+
32+
SubunitClustererParameters clusterParams = new SubunitClustererParameters();
33+
QsAlignParameters alignParams = new QsAlignParameters();
34+
35+
QsAlignResult result = QsAlign
36+
.align(s1, s2, clusterParams, alignParams);
37+
38+
assertEquals(result.length(), 4);
39+
assertEquals(result.getRelation(), QsRelation.EQUIVALENT);
40+
assertEquals(result.getAlignedSubunits1(), result.getAlignedSubunits2());
41+
assertEquals(result.getRmsd(), 0.0, 0.01);
42+
43+
}
44+
45+
/**
46+
* Different: test two completely different proteins (4HHB, 3IFV).
47+
*/
48+
@Test
49+
public void testDifferent() throws StructureException, IOException {
50+
51+
Structure s1 = StructureIO.getStructure("4hhb");
52+
Structure s2 = StructureIO.getStructure("3ifv");
53+
54+
SubunitClustererParameters clusterParams = new SubunitClustererParameters();
55+
QsAlignParameters alignParams = new QsAlignParameters();
56+
57+
QsAlignResult result = QsAlign
58+
.align(s1, s2, clusterParams, alignParams);
59+
60+
assertEquals(result.length(), 0);
61+
assertEquals(result.getRelation(), QsRelation.DIFFERENT);
62+
2463
}
2564

2665
/**
27-
* Proliferating cell nuclear antigens (1PLR, 3HI8) are structurally
66+
* Proliferating cell nuclear antigens (3IFV, 3HI8) are structurally
2867
* equivalent C3 homotrimers.
2968
*/
3069
@Test
3170
public void testHomoEquivalent() throws StructureException, IOException {
3271

72+
Structure s1 = StructureIO.getStructure("3ifv");
73+
Structure s2 = StructureIO.getStructure("BIO:3hi8:1");
74+
75+
SubunitClustererParameters clusterParams = new SubunitClustererParameters();
76+
QsAlignParameters alignParams = new QsAlignParameters();
77+
78+
QsAlignResult result = QsAlign
79+
.align(s1, s2, clusterParams, alignParams);
80+
81+
assertEquals(result.length(), 3);
82+
assertEquals(result.getRelation(), QsRelation.EQUIVALENT);
83+
assertTrue(result.getRmsd() < 10.0);
84+
3385
}
3486

3587
/**
@@ -39,16 +91,63 @@ public void testHomoEquivalent() throws StructureException, IOException {
3991
@Test
4092
public void testHeteroEquivalent() throws StructureException, IOException {
4193

94+
Structure s1 = StructureIO.getStructure("2vml");
95+
Structure s2 = StructureIO.getStructure("2bv8");
96+
97+
SubunitClustererParameters clusterParams = new SubunitClustererParameters();
98+
QsAlignParameters alignParams = new QsAlignParameters();
99+
100+
QsAlignResult result = QsAlign
101+
.align(s1, s2, clusterParams, alignParams);
102+
103+
assertEquals(result.length(), 12);
104+
assertEquals(result.getRelation(), QsRelation.EQUIVALENT);
105+
assertTrue(result.getRmsd() < 10.0);
106+
}
107+
108+
/**
109+
* Hydratases (2B3M dimer, 1Q6W hexamer). The C2 dimer is
110+
* triplicated into a D3 assembly.
111+
*/
112+
@Test
113+
public void testPartialComplete() throws StructureException,
114+
IOException {
115+
116+
Structure s1 = StructureIO.getStructure("BIO:2b3m:1");
117+
Structure s2 = StructureIO.getStructure("BIO:1Q6W:7");
118+
119+
SubunitClustererParameters clusterParams = new SubunitClustererParameters();
120+
QsAlignParameters alignParams = new QsAlignParameters();
121+
122+
QsAlignResult result = QsAlign
123+
.align(s1, s2, clusterParams, alignParams);
124+
125+
assertEquals(result.length(), 3);
126+
assertEquals(result.getRelation(), QsRelation.PARTIAL_COMPLETE);
127+
assertTrue(result.getRmsd() < 10.0);
128+
42129
}
43130

44131
/**
45132
* Cytochrome bc1 complexes (1BCC, 1KB9) have some equivalent Chains and
46133
* some unmatched.
47134
*/
48135
@Test
49-
public void testHeteroPartialComplete() throws StructureException,
136+
public void testPartialIncomplete() throws StructureException,
50137
IOException {
51138

139+
Structure s1 = StructureIO.getStructure("1bcc");
140+
Structure s2 = StructureIO.getStructure("1kb9");
141+
142+
SubunitClustererParameters clusterParams = new SubunitClustererParameters();
143+
QsAlignParameters alignParams = new QsAlignParameters();
144+
145+
QsAlignResult result = QsAlign
146+
.align(s1, s2, clusterParams, alignParams);
147+
148+
assertEquals(result.length(), 8);
149+
assertEquals(result.getRelation(), QsRelation.PARTIAL_INCOMPLETE);
150+
assertTrue(result.getRmsd() < 10.0);
52151
}
53152

54153
}

0 commit comments

Comments
 (0)