1 |
duarte |
114 |
import java.io.FileNotFoundException; |
2 |
|
|
import java.io.PrintWriter; |
3 |
|
|
import java.io.OutputStream; |
4 |
|
|
import java.io.FileOutputStream; |
5 |
|
|
|
6 |
hstehr |
1005 |
import owl.core.util.MultiOutputStream; |
7 |
|
|
import owl.core.util.PyMol; |
8 |
|
|
import owl.core.util.PymolServerOutputStream; |
9 |
duarte |
114 |
|
10 |
hstehr |
1005 |
|
11 |
duarte |
114 |
public class testPyMol { |
12 |
|
|
|
13 |
|
|
/** |
14 |
|
|
* Test class for the PyMol class (our java to PyMol API) |
15 |
|
|
* @param file where PyMol script will be written |
16 |
|
|
* @author duarte |
17 |
|
|
*/ |
18 |
|
|
public static void main(String[] args) { |
19 |
|
|
String file = ""; |
20 |
|
|
boolean server=false; |
21 |
|
|
if (args.length<1){ |
22 |
|
|
System.err.println("Give at least one file argument"); |
23 |
|
|
System.exit(1); |
24 |
|
|
} |
25 |
|
|
file = args[0]; |
26 |
|
|
if (args.length>1){ // two arguments: output both file and server |
27 |
|
|
server=true; |
28 |
|
|
} |
29 |
|
|
|
30 |
|
|
|
31 |
|
|
String url = "http://anthrazit:9123"; |
32 |
|
|
|
33 |
|
|
String pdbFileName = "/project/StruPPi/jose/tinker/benchmarking/1bxy_A.pdb"; |
34 |
|
|
|
35 |
|
|
PrintWriter Out = null; |
36 |
|
|
|
37 |
|
|
// to output only to server we would need the following PrintWriter |
38 |
|
|
//Out = new PrintWriter(new PymolServerOutputStream(url),true); |
39 |
|
|
|
40 |
|
|
if (server){ |
41 |
|
|
OutputStream os1 = new PymolServerOutputStream(url); |
42 |
|
|
OutputStream os2 = null; |
43 |
|
|
try { |
44 |
|
|
os2 = new FileOutputStream(file); |
45 |
|
|
} catch (FileNotFoundException e) { |
46 |
|
|
e.printStackTrace(); |
47 |
|
|
System.exit(2); |
48 |
|
|
} |
49 |
|
|
OutputStream multi = new MultiOutputStream(os1, os2); |
50 |
|
|
Out = new PrintWriter(multi, true); |
51 |
|
|
} else { |
52 |
|
|
try { |
53 |
|
|
Out = new PrintWriter(new FileOutputStream(file),true); |
54 |
|
|
} catch (FileNotFoundException e) { |
55 |
|
|
e.printStackTrace(); |
56 |
|
|
System.exit(1); |
57 |
|
|
} |
58 |
|
|
} |
59 |
|
|
|
60 |
|
|
PyMol mypymol = new PyMol(Out); |
61 |
|
|
|
62 |
|
|
mypymol.loadPDB(pdbFileName); |
63 |
|
|
// more pymol commands |
64 |
|
|
|
65 |
|
|
} |
66 |
|
|
|
67 |
|
|
} |