Skip to content

Commit 8acab40

Browse files
committed
fix for biojava#610
1 parent 2d4a720 commit 8acab40

File tree

3 files changed

+70
-10
lines changed

3 files changed

+70
-10
lines changed

biojava-modfinder/src/main/java/org/biojava/nbio/phosphosite/Dataset.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ public void download(){
154154

155155
}
156156

157-
private void downloadFile(URL u, File localFile) throws IOException {
157+
public void downloadFile(URL u, File localFile) throws IOException {
158158

159159
System.out.println("Downloading " + u);
160160

@@ -234,6 +234,7 @@ public static void main(String[] args) {
234234

235235
List<Site> sites = Site.parseSites(f);
236236

237+
System.out.println("Got " + sites.size() + " sites");
237238
for (Site s : sites) {
238239
if (s.getUniprot().equals("P50225") || s.getUniprot().equals("P48025")) {
239240
System.out.println(s);

biojava-modfinder/src/main/java/org/biojava/nbio/phosphosite/Site.java

Lines changed: 15 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,25 @@ public static List<Site> parseSites(File f) throws IOException {
5656

5757
int proteinIndex = -1;
5858
int uniprotIndex = -1;
59-
int modTypeIndex = -1;
6059
int residueIndex = -1;
6160
int orgIndex = -1;
6261
int groupIndex = -1;
62+
int geneIndex = -1;
6363

6464
boolean inHeader = true;
6565

6666

6767
while ((line = buf.readLine()) != null){
68-
if ( line.startsWith("PROTEIN")) {
68+
if ( line.startsWith("GENE")) {
6969

7070
headerFields = parseHeaderFields(line);
7171

7272
proteinIndex = headerFields.indexOf("PROTEIN");
7373
uniprotIndex = headerFields.indexOf("ACC_ID");
74-
modTypeIndex = headerFields.indexOf("MOD_TYPE");
7574
residueIndex = headerFields.indexOf("MOD_RSD");
76-
orgIndex = headerFields.indexOf("ORG");
75+
orgIndex = headerFields.indexOf("ORGANISM");
7776
groupIndex = headerFields.indexOf("SITE_GRP_ID");
77+
geneIndex = headerFields.indexOf("GENE");
7878

7979
inHeader = false;
8080
continue;
@@ -95,19 +95,25 @@ public static List<Site> parseSites(File f) throws IOException {
9595

9696
String protein = spl[proteinIndex];
9797
String uniprot = spl[uniprotIndex];
98-
//String geneSymb = spl[2];
99-
//String chrLoc = spl[3];
100-
String modType = spl[modTypeIndex];
98+
10199
String residue = spl[residueIndex];
100+
101+
String[] resSpl = residue.split("-");
102+
String modType = null;
103+
if ( resSpl.length == 2) {
104+
105+
modType = resSpl[1];
106+
}
102107
String group = spl[groupIndex];
103108

104109
String organism = spl[orgIndex];
105110

111+
String geneSymb = spl[geneIndex];
112+
106113
Site s = new Site();
107114
s.setProtein(protein);
108115
s.setUniprot(uniprot);
109-
//s.setGeneSymb(geneSymb);
110-
//s.setChrLoc(chrLoc);
116+
s.setGeneSymb(geneSymb);
111117
s.setModType(modType);
112118
s.setResidue(residue);
113119
s.setGroup(group);
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
package org.biojava.nbio.protmod.phosphosite;
2+
3+
import junit.framework.TestCase;
4+
import org.biojava.nbio.phosphosite.Dataset;
5+
import org.biojava.nbio.phosphosite.Site;
6+
7+
import java.io.File;
8+
import java.net.URL;
9+
import java.util.List;
10+
11+
/**
12+
* Created by andreas on 11/29/16.
13+
*/
14+
public class TestAcetylation extends TestCase {
15+
16+
17+
/** Tests that the acetylation file can get downloaded and parsed
18+
*
19+
*/
20+
public void testAcetylation() {
21+
String f = Dataset.ACETYLATION;
22+
23+
Dataset ds = new Dataset();
24+
25+
try {
26+
File localDir = ds.getLocalDir();
27+
int slashIndex = f.lastIndexOf("/");
28+
29+
String fileName = f.substring(slashIndex);
30+
31+
File localFile = new File(localDir + "/" + fileName);
32+
33+
if (!localFile.exists()) {
34+
ds.downloadFile(new URL(f), localFile);
35+
}
36+
37+
List<Site> sites = Site.parseSites(localFile);
38+
39+
assertTrue(sites.size() > 0);
40+
41+
for (Site s : sites) {
42+
43+
assertTrue(s.getResidue() != null);
44+
45+
}
46+
47+
48+
} catch (Exception e) {
49+
e.printStackTrace();
50+
fail(e.getMessage());
51+
}
52+
}
53+
}

0 commit comments

Comments
 (0)