Repository navigation
Expand file tree
/
Copy pathTestBond.java
More file actions
164 lines (118 loc) · 4.01 KB
/
Copy pathTestBond.java
File metadata and controls
164 lines (118 loc) · 4.01 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
/*
* BioJava development code
*
* This code may be freely distributed and modified under the
* terms of the GNU Lesser General Public Licence. This should
* be distributed with the code. If you do not have a copy,
* see:
*
* http://www.gnu.org/copyleft/lesser.html
*
* Copyright for this code is held jointly by the individual
* authors. These should be listed in @author doc comments.
*
* For more information on the BioJava project and its aims,
* or to join the biojava-l mailing list, visit the home page
* at:
*
* http://www.biojava.org/
*
*/
package org.biojava.nbio.structure;
import java.io.IOException;
import org.biojava.nbio.structure.align.util.AtomCache;
import org.biojava.nbio.structure.io.FileParsingParameters;
import org.junit.BeforeClass;
import org.junit.Test;
import static org.junit.Assert.*;
public class TestBond {
@BeforeClass
public static void setUp() throws IOException, StructureException {
AtomCache cache = new AtomCache();
cache.setUseMmCif(false);
FileParsingParameters params = cache.getFileParsingParams();
params.setAlignSeqRes(true);
params.setLoadChemCompInfo(true);
params.setCreateAtomBonds(true);
StructureIO.setAtomCache(cache);
}
@Test
public void testIntraResidueBonds() throws StructureException, IOException {
Structure s = StructureIO.getStructure("1kh9");
Group g = s.getChainByPDB("A").getSeqResGroup(274);
Atom cg = g.getAtom("CG");
Atom cb = g.getAtom("CB");
Atom cd1 = g.getAtom("CD1");
Atom cd2 = g.getAtom("CD2");
assertEquals(3, cg.getBonds().size());
for (Bond bond : cg.getBonds()) {
if (bond.getOther(cg) == cb) {
assertEquals(1, bond.getBondOrder());
} else if (bond.getOther(cg) == cd1) {
assertEquals(2, bond.getBondOrder());
} else if (bond.getOther(cg) == cd2) {
assertEquals(1, bond.getBondOrder());
}
}
}
@Test
public void testPeptideBonds() throws StructureException, IOException {
Structure s = StructureIO.getStructure("1kh9");
AminoAcidImpl residue1 = (AminoAcidImpl) s.getChainByPDB("A").getSeqResGroup(273);
AminoAcidImpl residue2 = (AminoAcidImpl) s.getChainByPDB("A").getSeqResGroup(274);
Atom carboxylC = residue1.getC();
Atom aminoN = residue2.getN();
assertTrue(areBonded(carboxylC, aminoN));
}
@Test
public void testLINKBonds() throws StructureException, IOException {
Structure s = StructureIO.getStructure("1kh9");
Group g1 = s.getChainByPDB("A").getSeqResGroup(50);
assertNotNull(g1);
assertTrue(g1 instanceof AminoAcid);
AminoAcid aa = (AminoAcid)g1;
assertTrue(aa.getRecordType().equals(AminoAcid.ATOMRECORD));
Atom atom1 = g1.getAtom("OD1");
Atom atom2 = s.getChainByPDB("A").getAtomGroup(446).getAtom("MG");
assertNotNull(atom1);
assertNotNull(atom2);
assertTrue(areBonded(atom1, atom2));
}
@Test
public void testDisulfideBonds() throws StructureException, IOException {
Structure s = StructureIO.getStructure("1kh9");
Atom atom1 = s.getChainByPDB("A").getSeqResGroup(177).getAtom("SG");
Atom atom2 = s.getChainByPDB("A").getSeqResGroup(167).getAtom("SG");
assertTrue(areBonded(atom1, atom2));
}
@Test
public void testLigandBonds() throws StructureException, IOException {
Structure s = StructureIO.getStructure("1kh9");
Atom phosphateP = s.getChainByPDB("A").getAtomGroup(447).getAtom("P");
Atom phosphateO = s.getChainByPDB("A").getAtomGroup(447).getAtom("O1");
assertTrue(areBonded(phosphateP, phosphateO));
}
private boolean areBonded(Atom a, Atom b) {
for (Bond bond : a.getBonds()) {
if (bond.getOther(a) == b) {
return true;
}
}
return false;
}
/*
* Each of the following PDB IDs used to make formBonds() crash.
*/
@Test
public void test145D() throws IOException, StructureException {
StructureIO.getStructure("145D");
}
@Test
public void test1APJ() throws IOException, StructureException {
StructureIO.getStructure("1APJ");
}
@Test
public void test1BDX() throws IOException, StructureException {
StructureIO.getStructure("1BDX");
}
}