-
Notifications
You must be signed in to change notification settings - Fork 8
Expand file tree
/
Copy pathpredictBatchPEPSTATS.java
More file actions
121 lines (104 loc) · 4.37 KB
/
predictBatchPEPSTATS.java
File metadata and controls
121 lines (104 loc) · 4.37 KB
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
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
import java.io.File;
import java.io.IOException;
import java.io.PrintWriter;
import java.nio.file.Files;
import java.nio.file.Paths;
import java.util.Date;
import java.util.List;
import java.util.Vector;
public class predictBatchPEPSTATS
{
public static void main(String[] args, Vector<String> ecnums, long time, String ROOTPATH, String fastaFile, String tempDir)
throws IOException, InterruptedException
{
String predictProg = ROOTPATH.substring(0, ROOTPATH.length() - 3) + "/svmlight/svm_classify";
String method = "pepstats";
for (int i = 0; i < ecnums.size(); i++)
{
Date d1 = new Date();
String path = ROOTPATH + File.separator + (String)ecnums.get(i) + File.separator + method;
String modelfile = path + File.separator + "model.svm";
String rangefile = path + File.separator + "rangefile";
String testpath = tempDir + File.separator + "testResult" + File.separator + time + File.separator + (String)ecnums.get(i) + File.separator + method;
String batchSVM = testpath + "/test.svm";
String batchVect = testpath + "/test.vec";
File workdir = new File(testpath);
workdir.mkdirs();
fasta2Pepstats_noscale fas = new fasta2Pepstats_noscale();
String predFile = testpath + File.separator + (String)ecnums.get(i) + ".preds";
String confFile = testpath + File.separator + (String)ecnums.get(i) + ".confs";
String posPredFile = path + File.separator + "ppreds.txt";
String negPredFile = path + File.separator + "npreds.txt";
String[] cmdArray = new String[7];
cmdArray[0] = (ROOTPATH.substring(0, ROOTPATH.length() - 3) + "/EMBOSS-6.5.7/emboss/pepstats");
cmdArray[1] = "-sequence";
cmdArray[2] = fastaFile;
cmdArray[3] = "-outfile";
cmdArray[4] = (workdir + "/temp.out");
cmdArray[5] = "-warning";
cmdArray[6] = "FALSE";
String cmd = ROOTPATH.substring(0, ROOTPATH.length() - 3) + "/EMBOSS-6.5.7/emboss/pepstats -sequence " + fastaFile + " -outfile " + workdir + "/temp.out -warning FALSE";
ProcessBuilder pb = new ProcessBuilder(cmd.split(" "));
Process process = pb.start();
try
{
process.waitFor();
int exitVal = process.exitValue();
}
catch (InterruptedException e)
{
System.out.print("pepstats is not working!");
e.printStackTrace();
}
fasta2Pepstats_noscale.parse_pepstats(cmdArray[4], ecnums.get(i), "1", time, ROOTPATH, tempDir);
File deletefile = new File(cmdArray[4]);
deletefile.delete();
cmdArray = new String[1];
PrintWriter scalefile = new PrintWriter(tempDir + File.separator + "testResult" + File.separator + time + File.separator + time + ".sh", "UTF-8");
scalefile.println("#!/bin/bash");
scalefile.println(ROOTPATH.substring(0, ROOTPATH.length() - 3) + "/libsvm-3.16/svm-scale -r " + ROOTPATH + "/" + ecnums.get(i) + "/pepstats/rangefile " + batchSVM + " > " + batchVect + " 2> /dev/null");
scalefile.close();
cmd = "chmod +x " + tempDir + File.separator + "testResult" + File.separator + time + File.separator + time + ".sh";
pb = new ProcessBuilder(cmd.split(" "));
process = pb.start();
try
{
process.waitFor();
int j = process.exitValue();
}
catch (InterruptedException e)
{
System.out.print("svm-scale is not working!");
e.printStackTrace();
}
cmd = tempDir + File.separator + "testResult" + File.separator + time + File.separator + time + ".sh";
pb = new ProcessBuilder(new String[] { cmd });
process = pb.start();
try
{
process.waitFor();
int k = process.exitValue();
}
catch (InterruptedException e)
{
System.out.print("Svm_classify is not working!");
e.printStackTrace();
}
cmd = predictProg + " " + batchVect + " " + modelfile + " " + predFile;
pb = new ProcessBuilder(cmd.split(" "));
process = pb.start();
try
{
process.waitFor();
int m = process.exitValue();
}
catch (InterruptedException e)
{
System.out.print("Svm_classify is not working!");
e.printStackTrace();
}
utils u = new utils();
utils.calculateConfidence(posPredFile, negPredFile, predFile, confFile);
}
}
}