Skip to content

Commit 08eec04

Browse files
committed
Fixing tests that were broken when running in maven
1 parent 988dee7 commit 08eec04

File tree

5 files changed

+39
-5
lines changed

5 files changed

+39
-5
lines changed

biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/AtomCache.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1046,15 +1046,17 @@ else if (useMmCif) {
10461046
* @throws IOException error reading from Web or file system
10471047
*/
10481048
private Structure loadStructureFromMmtfByPdbId(String pdbId) throws IOException {
1049-
MMTFFileReader reader = new MMTFFileReader();
1050-
reader.setFetchBehavior(fetchBehavior);
1051-
reader.setObsoleteBehavior(obsoleteBehavior);
1052-
Structure structure = reader.getStructureById(pdbId.toLowerCase());
1053-
return structure;
1049+
logger.debug("Loading structure {} from mmtf file.", pdbId);
1050+
MMTFFileReader reader = new MMTFFileReader();
1051+
reader.setFetchBehavior(fetchBehavior);
1052+
reader.setObsoleteBehavior(obsoleteBehavior);
1053+
Structure structure = reader.getStructureById(pdbId.toLowerCase());
1054+
return structure;
10541055
}
10551056

10561057
protected Structure loadStructureFromCifByPdbId(String pdbId) throws IOException, StructureException {
10571058

1059+
logger.debug("Loading structure {} from mmCIF file {}.", pdbId, path);
10581060
Structure s;
10591061
flagLoading(pdbId);
10601062
try {
@@ -1073,6 +1075,7 @@ protected Structure loadStructureFromCifByPdbId(String pdbId) throws IOException
10731075

10741076
protected Structure loadStructureFromPdbByPdbId(String pdbId) throws IOException, StructureException {
10751077

1078+
logger.debug("Loading structure {} from PDB file {}.", pdbId, path);
10761079
Structure s;
10771080
flagLoading(pdbId);
10781081
try {

biojava-structure/src/main/java/org/biojava/nbio/structure/io/BondMaker.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,7 @@ public BondMaker(Structure structure, FileParsingParameters params) {
102102
* </li>
103103
*/
104104
public void makeBonds() {
105+
logger.debug("Going to start making bonds");
105106
formPeptideBonds();
106107
formNucleotideBonds();
107108
formIntraResidueBonds();
@@ -208,12 +209,16 @@ private void formIntraResidueBonds() {
208209
for(Group group : totList){
209210

210211
ChemComp aminoChemComp = ChemCompGroupFactory.getChemComp(group.getPDBName());
212+
logger.debug("chemcomp for residue {}-{} has {} atoms and {} bonds",
213+
group.getPDBName(), group.getResidueNumber(), aminoChemComp.getAtoms().size(), aminoChemComp.getBonds().size());
211214

212215
for (ChemCompBond chemCompBond : aminoChemComp.getBonds()) {
213216
Atom a = getAtom(chemCompBond.getAtom_id_1(), group);
214217
Atom b = getAtom(chemCompBond.getAtom_id_2(), group);
215218
if ( a != null && b != null){
216219
int bondOrder = chemCompBond.getNumericalBondOrder();
220+
logger.debug("Forming bond between atoms {}-{} and {}-{} with bond order {}",
221+
a.getPDBserial(), a.getName(), b.getPDBserial(), b.getName(), bondOrder);
217222
new BondImpl(a, b, bondOrder);
218223
}
219224
else{

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,19 +26,30 @@
2626

2727
import org.biojava.nbio.structure.align.util.AtomCache;
2828
import org.biojava.nbio.structure.io.FileParsingParameters;
29+
import org.biojava.nbio.structure.io.mmcif.ChemCompGroupFactory;
30+
import org.biojava.nbio.structure.io.mmcif.DownloadChemCompProvider;
2931
import org.junit.BeforeClass;
3032
import org.junit.Test;
33+
import org.slf4j.Logger;
34+
import org.slf4j.LoggerFactory;
3135

3236
import static org.junit.Assert.*;
3337

3438

3539
public class TestBond {
40+
41+
private static final Logger logger = LoggerFactory.getLogger(TestBond.class);
3642

3743

3844
private static AtomCache cache;
3945

4046
@BeforeClass
4147
public static void setUp() {
48+
49+
// important: without this the tests can fail when running in maven (but not in IDE)
50+
// that's because it depends on the order on how tests were run - JD 2018-03-10
51+
ChemCompGroupFactory.setChemCompProvider(new DownloadChemCompProvider());
52+
4253
cache = new AtomCache();
4354

4455
cache.setUseMmCif(true);
@@ -221,6 +232,7 @@ private int countAtomsWithoutBonds(String pdbId) throws IOException, StructureEx
221232
// Check they all have bonds
222233
for(Atom a: atomsList){
223234
if(a.getBonds()==null){
235+
logger.debug("Atom {}-{} has no bonds", a.getPDBserial(), a.getName());
224236
nonBondedCounter++;
225237
}
226238
}

biojava-structure/src/test/java/org/biojava/nbio/structure/asa/TestAsaCalc.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
import org.biojava.nbio.structure.Structure;
2525
import org.biojava.nbio.structure.StructureException;
2626
import org.biojava.nbio.structure.StructureIO;
27+
import org.biojava.nbio.structure.io.mmcif.ChemCompGroupFactory;
28+
import org.biojava.nbio.structure.io.mmcif.DownloadChemCompProvider;
2729

2830
import java.io.IOException;
2931

@@ -39,6 +41,10 @@ public class TestAsaCalc extends TestCase {
3941

4042
public void testAsa3PIU() throws StructureException, IOException {
4143

44+
// important: without this the tests can fail when running in maven (but not in IDE)
45+
// that's because it depends on the order on how tests were run - JD 2018-03-10
46+
ChemCompGroupFactory.setChemCompProvider(new DownloadChemCompProvider());
47+
4248
Structure structure = StructureIO.getStructure("3PIU");
4349

4450

biojava-structure/src/test/resources/log4j2.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,5 +9,13 @@
99
<root level="warn">
1010
<appender-ref ref="Console"/>
1111
</root>
12+
<!--
13+
<Logger name="org.biojava.nbio.structure.io.BondMaker" level="debug" additivity="false">
14+
<appender-ref ref="Console"/>
15+
</Logger>
16+
<Logger name="org.biojava.nbio.structure.align.util.AtomCache" level="debug" additivity="false">
17+
<appender-ref ref="Console"/>
18+
</Logger>
19+
-->
1220
</loggers>
1321
</configuration>

0 commit comments

Comments
 (0)