-
Notifications
You must be signed in to change notification settings - Fork 0
/
HPOMappingResources.java
67 lines (53 loc) · 1.71 KB
/
HPOMappingResources.java
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
/**
* Java program to process HPO file to get the annotated resources
*
*
* author: Kalpana Raja, Morgridge Institute for Research, WI, USA
*/
import java.io.BufferedReader;
import java.io.BufferedWriter;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.util.ArrayList;
public class HPOMappingResources {
public static void main(String[] args) {
long startTime = System.currentTimeMillis();
String line="", ref="";
int count=0;
ArrayList<String> mappingRef = new ArrayList<String>();
String arg1 = args[0]; //input_file --hp.obo
String arg2 = args[1]; //output_file
try {
FileInputStream fis = new FileInputStream(arg1);
InputStreamReader isr = new InputStreamReader(fis,"UTF-8");
BufferedReader br = new BufferedReader(isr);
FileOutputStream fos = new FileOutputStream(arg2);
OutputStreamWriter osr = new OutputStreamWriter(fos, "UTF-8");
BufferedWriter bw = new BufferedWriter(osr);
while((line = br.readLine()) != null) {
//id
if(line.startsWith("xref: ")) {
ref = line.substring(0, line.lastIndexOf(":"));
if(!mappingRef.contains(ref)) mappingRef.add(ref);
}
count++;
if(count==100) break;
//if(count%1000==0) System.out.println(count);
}
for(String each : mappingRef) {
bw.append(each);
bw.append("\n");
}
br.close();
bw.close();
} catch(IOException e) {
System.err.println(e);
}
long stopTime = System.currentTimeMillis();
long elapsedTime = stopTime - startTime;
System.out.println("Execution time in milliseconds: " + elapsedTime);
}
}