Skip to content

Commit 7f39af2

Browse files
committed
moving SIFTS unit test to parse local file, since file from remote location has changed (and seems to contain inconsistent data)
1 parent 7360400 commit 7f39af2

File tree

4 files changed

+27
-7
lines changed

4 files changed

+27
-7
lines changed

biojava-structure/src/main/java/org/biojava/nbio/structure/io/sifts/SiftsMappingProvider.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,13 @@ public static List<SiftsEntity> getSiftsMapping(String pdbId) throws IOException
9898
}
9999
File dest = new File( hashDir, pdbId + ".sifts.xml.gz");
100100

101+
logger.debug("testing SIFTS file " + dest.getAbsolutePath());
102+
103+
101104
if ( ! dest.exists()){
102105
String u = String.format(fileLoc,pdbId);
103106
URL url = new URL(u);
104-
logger.info("Downloading SIFTS file {} to {}",url,dest);
107+
logger.debug("Downloading SIFTS file {} to {}",url,dest);
105108
FileDownloadUtils.downloadFile(url, dest);
106109
}
107110

biojava-structure/src/main/java/org/biojava/nbio/structure/io/sifts/SiftsXMLParser.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
*/
2525
package org.biojava.nbio.structure.io.sifts;
2626

27+
import org.slf4j.Logger;
28+
import org.slf4j.LoggerFactory;
2729
import org.w3c.dom.Document;
2830
import org.w3c.dom.Element;
2931
import org.w3c.dom.NodeList;
@@ -40,6 +42,10 @@
4042

4143
public class SiftsXMLParser {
4244

45+
private final static Logger logger = LoggerFactory.getLogger(SiftsXMLParser.class);
46+
47+
48+
4349
Document dom;
4450
List<SiftsEntity> entities;
4551

@@ -125,11 +131,13 @@ private SiftsEntity getSiftsEntity(Element empEl) {
125131

126132
SiftsSegment s = getSiftsSegment(el);
127133

134+
logger.debug("new segment: " + s);
128135
entity.addSegment(s);
129136

130137
}
131138
}
132139

140+
logger.debug("new SIFTS entity: " + entity);
133141
return entity;
134142
}
135143

biojava-structure/src/test/java/org/biojava/nbio/structure/io/TestSiftsParsing.java

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,12 +25,11 @@
2525
package org.biojava.nbio.structure.io;
2626

2727
import junit.framework.TestCase;
28-
import org.biojava.nbio.structure.io.sifts.SiftsEntity;
29-
import org.biojava.nbio.structure.io.sifts.SiftsMappingProvider;
30-
import org.biojava.nbio.structure.io.sifts.SiftsResidue;
31-
import org.biojava.nbio.structure.io.sifts.SiftsSegment;
28+
import org.biojava.nbio.structure.io.sifts.*;
3229

30+
import java.io.InputStream;
3331
import java.util.List;
32+
import java.util.zip.GZIPInputStream;
3433

3534
public class TestSiftsParsing extends TestCase {
3635

@@ -116,8 +115,18 @@ public void test4jn3(){
116115
}
117116

118117
public void test4DOU(){
118+
119+
// get file from test resource folder, since the file from EBI seems to have issues (on 20170405).
120+
119121
try {
120-
List<SiftsEntity> entities = SiftsMappingProvider.getSiftsMapping("4dou");
122+
123+
InputStream inStream = new GZIPInputStream(this.getClass().getResourceAsStream("/org/biojava/nbio/structure/io/4dou.sifts.xml.gz"));
124+
125+
SiftsXMLParser parser = new SiftsXMLParser();
126+
127+
parser.parseXmlFile(inStream);
128+
129+
List<SiftsEntity> entities = parser.getEntities();
121130

122131
assertNotNull(entities);
123132

@@ -127,7 +136,7 @@ public void test4DOU(){
127136
//System.out.println(e.getEntityId() + " " +e.getType());
128137

129138
// 4DOU has 3 segments
130-
assertTrue(e.getSegments().size() == 3);
139+
assertTrue("SiftsEntity does not have 3 segments, but " + e.getSegments().size(),e.getSegments().size() == 3);
131140

132141
// test segment 1:
133142

Binary file not shown.

0 commit comments

Comments
 (0)