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