1 |
filippis |
42 |
import java.sql.*; |
2 |
|
|
import java.io.*; |
3 |
|
|
import tools.*; |
4 |
|
|
|
5 |
filippis |
45 |
/** |
6 |
|
|
* Package: tools |
7 |
|
|
* Class: testGraph2Pml |
8 |
|
|
* Author: Ioannis Filippis, filippis@molgen.mpg.de |
9 |
|
|
* Date: 21/03/2006 |
10 |
|
|
* |
11 |
|
|
* Simple test class for visualizing contact graphs using Graph2Pml class plus |
12 |
|
|
* PyMol class. Run PyMol with the -R option to run the server. |
13 |
|
|
* |
14 |
|
|
* Changelog: |
15 |
|
|
* 27/03/06 modified by IF (functional with comments) |
16 |
|
|
* 21/03/06 first created by IF (non functional) |
17 |
|
|
*/ |
18 |
|
|
|
19 |
filippis |
42 |
public class testGraph2Pml { |
20 |
|
|
|
21 |
|
|
public static void main(String[] args) { |
22 |
filippis |
45 |
|
23 |
|
|
String connFile = "/project/StruPPi/ioannis/cnfs/msdgraph.my.cnf", pdbFileName = "", molObjName = ""; |
24 |
|
|
Graph2Pml graphPml = null; |
25 |
|
|
PyMol pml = null; |
26 |
|
|
|
27 |
filippis |
42 |
mySQLConnect SQLC = new mySQLConnect(); |
28 |
|
|
SQLC.readConnectionFile(connFile); |
29 |
|
|
Connection conn = SQLC.openConnection(); |
30 |
|
|
|
31 |
filippis |
45 |
//Create a new output stream to the pymol server running at the localhost |
32 |
|
|
//all commands will be send there |
33 |
|
|
PrintWriter serverOutPw = new PrintWriter(new PymolServerOutputStream("http://"+Machine.getClient()+":9123"), true); |
34 |
|
|
pml = new PyMol(serverOutPw); |
35 |
|
|
|
36 |
|
|
//export the pdb file directly from msdsd and load it in pymol |
37 |
|
|
pdbFileName = Msdsd2Pdb.export2File("1rx4", 20717, 52567, 9, "/project/StruPPi/ioannis/tmp"); |
38 |
|
|
molObjName = pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
39 |
filippis |
42 |
System.out.println(molObjName); |
40 |
filippis |
45 |
|
41 |
|
|
//create a pymol contact graph object for the graph 33729 |
42 |
|
|
//use only SC_SC edges with SC_SC edge weight and nodes that have SC_SC edges |
43 |
|
|
//no further filtering in the edges based on the contact range is applied |
44 |
|
|
//no user based graph filtering is applied |
45 |
|
|
//the graph comes from msdsd |
46 |
|
|
//normal edges will be utilised |
47 |
|
|
//the graph will not be visualised as "directed" |
48 |
|
|
graphPml = new Graph2Pml(serverOutPw, molObjName, 33729, "SC_SC", "SC_SC_in+SC_SC_out", "SC_SC", "true", "true", true, false, false, conn); |
49 |
|
|
//draw nodes, edges, special residues but not surface |
50 |
|
|
//the node size will be calculated based on the SC_SC_out field on asc order |
51 |
|
|
//the node color will be calculated based on the BB_BB_out field not discretised |
52 |
|
|
//all ALA nodes will be transparent |
53 |
|
|
//all residues that do not have any SC interactions will be the special ones colored green |
54 |
|
|
//all edges will be lines of width determined by the SC_SC field in asc order |
55 |
|
|
//all edges lines will have color calculated based on the BB_BB_out field not discretised |
56 |
|
|
//all edges lines with adjacent ALA's will have gaps |
57 |
|
|
graphPml.draw(true, true, true, false); |
58 |
|
|
graphPml.setNodeSizeMethod("SC_SC_out", false); |
59 |
|
|
graphPml.setNodeColorMethod("BB_BB_out", false); |
60 |
|
|
graphPml.setNodeTranspCondition("(res = \"ALA\")"); |
61 |
|
|
graphPml.setSpecialRes("green", "SELECT cid, num FROM newmsdgraph.nodes WHERE (graph_id = 33729) AND (sc_sc_in+sc_sc_out = 0);"); |
62 |
|
|
graphPml.setEdgeSizeMethod("SC_SC", false); |
63 |
|
|
graphPml.setEdgeColorMethod("BB_BB", false); |
64 |
|
|
graphPml.setEdgeGapCondition("(i_res = \"ALA\" OR j_res = \"ALA\")"); |
65 |
|
|
//create the contact graph |
66 |
|
|
graphPml.outputGraph(); |
67 |
|
|
//save the image not ray-traced |
68 |
|
|
pml.saveImage("test1","/home/filippis/Desktop", false); |
69 |
|
|
//if you want later to read the view from a log file |
70 |
|
|
//pml.openLog("test1_log","/home/filippis/Desktop"); |
71 |
|
|
//get the view |
72 |
|
|
pml.getView("test1_view"); |
73 |
|
|
//pml.closeLog(); |
74 |
|
|
|
75 |
|
|
// delete all and reload the structure |
76 |
|
|
pml.delete("all", false); |
77 |
|
|
pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
78 |
|
|
|
79 |
|
|
//to check reversibility in setNodeSizeMethod, setEdgeSizeMethod |
80 |
|
|
//and discretised coloring in setNodeColorMethod, setEdgeColorMethod |
81 |
|
|
graphPml.setNodeSizeMethod("SC_SC_out", true); |
82 |
|
|
graphPml.setNodeColorMethod("BB_BB_out", true); |
83 |
|
|
graphPml.setEdgeSizeMethod("SC_SC", true); |
84 |
|
|
graphPml.setEdgeColorMethod("BB_BB", true); |
85 |
|
|
graphPml.outputGraph(); |
86 |
|
|
//set view by reading a log file |
87 |
|
|
//pml.getFileView("test2_view", "/home/filippis/Desktop/test1_log.pml"); |
88 |
|
|
//pml.setView("test2_view"); |
89 |
|
|
//set view based on the view of the first structure so that you can compare |
90 |
|
|
//different graphs for the same structure |
91 |
|
|
pml.setView("test1_view"); |
92 |
|
|
pml.saveImage("test2","/home/filippis/Desktop", false); |
93 |
|
|
|
94 |
|
|
pml.delete("all", false); |
95 |
|
|
pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
96 |
|
|
|
97 |
|
|
//to check node method for edge coloring when nodeColor method not discretised |
98 |
|
|
graphPml.setUniformNodeSize(0.6); |
99 |
|
|
graphPml.setNodeColorMethod("BB_BB_out", false); |
100 |
|
|
graphPml.setUniformEdgeSize(4); |
101 |
|
|
graphPml.setEdgeColorMethod("node", true); |
102 |
|
|
graphPml.outputGraph(); |
103 |
|
|
pml.setView("test1_view"); |
104 |
|
|
pml.saveImage("test3","/home/filippis/Desktop", false); |
105 |
|
|
|
106 |
|
|
pml.delete("all", false); |
107 |
|
|
pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
108 |
|
|
|
109 |
|
|
//to check node method for edge coloring when nodeColor method is discretised |
110 |
|
|
graphPml.setUniformNodeSize(0.6); |
111 |
|
|
graphPml.setNodeColorMethod("BB_BB_out", true); |
112 |
|
|
graphPml.setUniformEdgeSize(4); |
113 |
|
|
graphPml.setEdgeColorMethod("node", true); |
114 |
|
|
graphPml.outputGraph(); |
115 |
|
|
pml.setView("test1_view"); |
116 |
|
|
pml.saveImage("test4","/home/filippis/Desktop", false); |
117 |
|
|
|
118 |
|
|
pml.delete("all", false); |
119 |
|
|
pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
120 |
|
|
|
121 |
|
|
//to check node method for edge coloring when nodeColor method is uniform |
122 |
|
|
graphPml.setUniformNodeSize(0.6); |
123 |
|
|
graphPml.setUniformNodeColor("blue"); |
124 |
|
|
graphPml.setUniformEdgeSize(4); |
125 |
|
|
graphPml.setEdgeColorMethod("node", true); |
126 |
|
|
graphPml.outputGraph(); |
127 |
|
|
pml.setView("test1_view"); |
128 |
|
|
pml.saveImage("test5","/home/filippis/Desktop", false); |
129 |
|
|
|
130 |
|
|
pml.delete("all", false); |
131 |
|
|
pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
132 |
|
|
|
133 |
|
|
//to check the trick of directionality with gapped lines for "half" edges |
134 |
|
|
//for this purpose a SC_BB graph model is used that doesn't ensure bidirectionality |
135 |
|
|
graphPml = new Graph2Pml(serverOutPw, molObjName, 33729, "SC_BB", "SC_BB_in+SC_BB_out", "SC_BB", "true", "true", true, false, true, conn); |
136 |
|
|
graphPml.outputGraph(); |
137 |
|
|
pml.setView("test1_view"); |
138 |
|
|
pml.saveImage("test6","/home/filippis/Desktop", false); |
139 |
|
|
|
140 |
|
|
|
141 |
|
|
pml.delete("all", false); |
142 |
|
|
|
143 |
|
|
//test multi-chain macromolecule with RNA also |
144 |
|
|
pdbFileName = Msdsd2Pdb.export2File("1a0a", 1107, 2560, 1, "/project/StruPPi/ioannis/tmp"); |
145 |
|
|
molObjName = pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
146 |
|
|
System.out.println(molObjName); |
147 |
|
|
|
148 |
|
|
graphPml = new Graph2Pml(serverOutPw, molObjName, 95, "SC_SC", "SC_SC_in+SC_SC_out", "SC_SC", "true", "true", true, false, false, conn); |
149 |
|
|
graphPml.draw(true, true, false, false); |
150 |
|
|
//color nodes based on the chains they belong to |
151 |
|
|
graphPml.setNodeColorMethod("chain", true); |
152 |
|
|
graphPml.setNodeTransp(0.2); |
153 |
|
|
graphPml.setUniformEdgeColor("red"); |
154 |
|
|
graphPml.setUniformEdgeSize(4.5); |
155 |
|
|
graphPml.setEdgeGap(0.5); |
156 |
|
|
graphPml.outputGraph(); |
157 |
|
|
pml.saveImage("test7","/home/filippis/Desktop", false); |
158 |
|
|
pml.getView("test2_view"); |
159 |
|
|
|
160 |
|
|
pml.delete("all", false); |
161 |
|
|
pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
162 |
|
|
|
163 |
|
|
//color edges based on the chains they belong to |
164 |
|
|
graphPml.draw(true, true, false, false); |
165 |
|
|
graphPml.setUniformNodeColor("red"); |
166 |
|
|
graphPml.setEdgeColorMethod("chain", true); |
167 |
|
|
graphPml.outputGraph(); |
168 |
|
|
pml.setView("test2_view"); |
169 |
|
|
pml.saveImage("test8","/home/filippis/Desktop", false); |
170 |
|
|
|
171 |
|
|
pml.delete("all", false); |
172 |
|
|
pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
173 |
|
|
|
174 |
|
|
//to check node method for edge coloring when nodeColor method is based on chain coloring |
175 |
|
|
graphPml.setNodeColorMethod("chain", true); |
176 |
|
|
graphPml.setEdgeColorMethod("node", true); |
177 |
|
|
graphPml.outputGraph(); |
178 |
|
|
pml.setView("test2_view"); |
179 |
|
|
pml.saveImage("test9","/home/filippis/Desktop", false); |
180 |
|
|
|
181 |
|
|
pml.delete("all", false); |
182 |
|
|
pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
183 |
|
|
|
184 |
|
|
//draw also surface - you can not see the graph anymore |
185 |
|
|
graphPml.draw(true, true, false, true); |
186 |
|
|
graphPml.setSurfTransp(0.7); |
187 |
|
|
graphPml.outputGraph(); |
188 |
|
|
pml.setView("test2_view"); |
189 |
|
|
pml.saveImage("test10","/home/filippis/Desktop", false); |
190 |
|
|
|
191 |
|
|
try { Thread.sleep(10000); } catch (Exception e) {} |
192 |
|
|
|
193 |
|
|
//hide the surface, show the RNA also |
194 |
|
|
//change the color of the nodes for each chain using the pymol defined list of nodes for each chain |
195 |
|
|
pml.hideWhat("surface", "graphMol", false); |
196 |
|
|
pml.showWhat("lines", "restMol", false); |
197 |
|
|
graphPml.setNodesColorUniform("nodes_cidA","red"); |
198 |
|
|
graphPml.setNodesColorUniform("nodes_cidA","yellow"); |
199 |
|
|
|
200 |
|
|
try { Thread.sleep(10000); } catch (Exception e) {} |
201 |
|
|
|
202 |
|
|
//if you believe that the objects contained in the list won't exceed the pymol command length limit, |
203 |
|
|
//you can concatenate all objects as a single string selection and handle them all together |
204 |
|
|
pml.concatList("nodes", "+", "nodesStr"); |
205 |
|
|
pml.setNodeColor("blue", "nodesStr", true); |
206 |
|
|
pml.selPml("nodes", "nodesStr", true, true); |
207 |
|
|
|
208 |
|
|
pml.delete("all", false); |
209 |
|
|
pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
210 |
|
|
|
211 |
|
|
//check a graph model with only inter-secondary-structure-elements SC_SC edges |
212 |
|
|
//remember that all the nodes with SC_SC will be selected |
213 |
|
|
//use default behaviour |
214 |
|
|
graphPml = new Graph2Pml(serverOutPw, molObjName, 95, "SC_SC", "SC_SC_in+SC_SC_out", "SC_SC", "(!((i_ssid = j_ssid) AND (i_sstype = j_sstype)))", "true", true, false, false, conn); |
215 |
|
|
graphPml.draw(true, true, false, false); |
216 |
|
|
graphPml.outputGraph(); |
217 |
|
|
pml.setView("test2_view"); |
218 |
|
|
pml.saveImage("test11","/home/filippis/Desktop", false); |
219 |
|
|
|
220 |
|
|
pml.delete("all", false); |
221 |
|
|
|
222 |
filippis |
42 |
SQLC.closeConnection(conn); |
223 |
|
|
|
224 |
|
|
} |
225 |
|
|
|
226 |
filippis |
45 |
} // end of class testGraph2Pml |