Skip to content

Commit 23125f1

Browse files
committed
Cleanup and docs
1 parent b821226 commit 23125f1

2 files changed

Lines changed: 32 additions & 55 deletions

File tree

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

Lines changed: 8 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -41,37 +41,20 @@ public class SiftsMappingProvider {
4141
private final static Logger logger = LoggerFactory.getLogger(SiftsMappingProvider.class);
4242

4343

44-
static String EBI_SIFTS_FILE_LOCATION = "ftp://ftp.ebi.ac.uk/pub/databases/msd/sifts/xml/%s.xml.gz";
44+
private static final String EBI_SIFTS_FILE_LOCATION = "ftp://ftp.ebi.ac.uk/pub/databases/msd/sifts/xml/%s.xml.gz";
4545

46-
static String RCSB_SIFTS_FILE_LOCATION = "http://www.rcsb.org/pdb/files/%s.sifts.xml.gz";
47-
48-
static String fileLoc = EBI_SIFTS_FILE_LOCATION;
49-
50-
public static void main(String[] args){
51-
try {
52-
List<SiftsEntity> entities = getSiftsMapping("1gc1");
53-
54-
for (SiftsEntity e : entities){
55-
System.out.println(e.getEntityId() + " " +e.getType());
56-
57-
for ( SiftsSegment seg: e.getSegments()) {
58-
System.out.println(" Segment: " + seg.getSegId() + " " + seg.getStart() + " " + seg.getEnd()) ;
59-
60-
for ( SiftsResidue res: seg.getResidues() ) {
61-
System.out.println(" " + res);
62-
}
63-
}
64-
65-
}
66-
} catch (Exception e){
67-
e.printStackTrace();
68-
}
69-
}
46+
private static String fileLoc = EBI_SIFTS_FILE_LOCATION;
7047

7148
public static void setFileLocation(String myFileLocation){
7249
fileLoc = myFileLocation;
7350
}
7451

52+
/**
53+
* Return the SIFTS mappings by getting the info from individual SIFTS xml files at URL {@value EBI_SIFTS_FILE_LOCATION}
54+
* @param pdbId the pdb identifier
55+
* @return
56+
* @throws IOException if problems downloading or parsing the file
57+
*/
7558
public static List<SiftsEntity> getSiftsMapping(String pdbId) throws IOException{
7659
// grab files from here:
7760

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

Lines changed: 24 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ public void test4DIA() throws Exception {
4141

4242
Assert.assertNotNull(entities);
4343

44-
Assert.assertTrue(entities.size() == 1);
44+
Assert.assertEquals(1, entities.size());
4545

4646
for (SiftsEntity e : entities) {
4747
//System.out.println(e.getEntityId() + " " +e.getType());
@@ -73,39 +73,33 @@ public void test4DIA() throws Exception {
7373
}
7474

7575
@Test
76-
public void test4jn3(){
77-
try {
78-
List<SiftsEntity> entities = SiftsMappingProvider.getSiftsMapping("4jn3");
76+
public void test4jn3() throws Exception {
77+
List<SiftsEntity> entities = SiftsMappingProvider.getSiftsMapping("4jn3");
7978

80-
Assert.assertNotNull(entities);
79+
Assert.assertNotNull(entities);
8180

82-
Assert.assertTrue(entities.size() == 2);
81+
Assert.assertEquals(2, entities.size());
8382

84-
for (SiftsEntity e : entities){
85-
//System.out.println(e.getEntityId() + " " +e.getType());
83+
for (SiftsEntity e : entities) {
84+
//System.out.println(e.getEntityId() + " " +e.getType());
8685

8786

88-
Assert.assertTrue(e.getSegments().size() > 0);
89-
for ( SiftsSegment seg: e.getSegments()) {
90-
Assert.assertTrue(seg.getResidues().size() > 0);
91-
//System.out.println(seg.getResidues().size());
92-
//System.out.println(" Segment: " + seg.getSegId() + " " + seg.getStart() + " " + seg.getEnd()) ;
93-
//
94-
for ( SiftsResidue res: seg.getResidues() ) {
95-
//System.out.println(" " + res);
96-
if ( res.getUniProtResName() != null ) {
97-
Assert.assertNotNull(res.getUniProtAccessionId());
98-
Assert.assertNotNull(res.getUniProtResName());
87+
Assert.assertTrue(e.getSegments().size() > 0);
88+
for (SiftsSegment seg : e.getSegments()) {
89+
Assert.assertTrue(seg.getResidues().size() > 0);
90+
//System.out.println(seg.getResidues().size());
91+
//System.out.println(" Segment: " + seg.getSegId() + " " + seg.getStart() + " " + seg.getEnd()) ;
92+
//
93+
for (SiftsResidue res : seg.getResidues()) {
94+
//System.out.println(" " + res);
95+
if (res.getUniProtResName() != null) {
96+
Assert.assertNotNull(res.getUniProtAccessionId());
97+
Assert.assertNotNull(res.getUniProtResName());
9998

100-
}
10199
}
102100
}
103-
104101
}
105102

106-
} catch (Exception e){
107-
e.printStackTrace();
108-
Assert.fail(e.getMessage());
109103
}
110104

111105

@@ -126,13 +120,13 @@ public void test4DOU() throws Exception {
126120

127121
Assert.assertNotNull(entities);
128122

129-
Assert.assertTrue(entities.size() == 1);
123+
Assert.assertEquals(1, entities.size());
130124

131125
for (SiftsEntity e : entities) {
132126
//System.out.println(e.getEntityId() + " " +e.getType());
133127

134128
// 4DOU has 3 segments
135-
Assert.assertTrue("SiftsEntity does not have 3 segments, but " + e.getSegments().size(), e.getSegments().size() == 3);
129+
Assert.assertEquals("SiftsEntity does not have 3 segments, but " + e.getSegments().size(), 3, e.getSegments().size());
136130

137131
// test segment 1:
138132

@@ -169,7 +163,7 @@ public void test4O6W() throws Exception {
169163

170164
Assert.assertNotNull(entities);
171165

172-
Assert.assertTrue(entities.size() == 2);
166+
Assert.assertEquals(2, entities.size());
173167

174168
int ecount = 0;
175169
for (SiftsEntity e : entities) {
@@ -180,12 +174,12 @@ public void test4O6W() throws Exception {
180174
continue;
181175

182176

183-
Assert.assertTrue(e.getEntityId().equals("A"));
184-
Assert.assertTrue(e.getType().equals("protein"));
177+
Assert.assertEquals("A", e.getEntityId());
178+
Assert.assertEquals("protein", e.getType());
185179

186180

187181
// 4O6W A has 2 segments
188-
Assert.assertTrue(e.getSegments().size() == 2);
182+
Assert.assertEquals(2, e.getSegments().size());
189183

190184
// test segment 2:
191185

0 commit comments

Comments
 (0)