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 |
filippis |
47 |
* 27/03/06 modified by IF (functional with comments - added cgo examples) |
16 |
filippis |
45 |
* 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 |
filippis |
47 |
//Edges as lines |
37 |
filippis |
45 |
//export the pdb file directly from msdsd and load it in pymol |
38 |
|
|
pdbFileName = Msdsd2Pdb.export2File("1rx4", 20717, 52567, 9, "/project/StruPPi/ioannis/tmp"); |
39 |
|
|
molObjName = pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
40 |
filippis |
42 |
System.out.println(molObjName); |
41 |
filippis |
45 |
|
42 |
|
|
//create a pymol contact graph object for the graph 33729 |
43 |
|
|
//use only SC_SC edges with SC_SC edge weight and nodes that have SC_SC edges |
44 |
|
|
//no further filtering in the edges based on the contact range is applied |
45 |
|
|
//no user based graph filtering is applied |
46 |
|
|
//the graph comes from msdsd |
47 |
|
|
//normal edges will be utilised |
48 |
|
|
//the graph will not be visualised as "directed" |
49 |
|
|
graphPml = new Graph2Pml(serverOutPw, molObjName, 33729, "SC_SC", "SC_SC_in+SC_SC_out", "SC_SC", "true", "true", true, false, false, conn); |
50 |
|
|
//draw nodes, edges, special residues but not surface |
51 |
|
|
//the node size will be calculated based on the SC_SC_out field on asc order |
52 |
|
|
//the node color will be calculated based on the BB_BB_out field not discretised |
53 |
|
|
//all ALA nodes will be transparent |
54 |
|
|
//all residues that do not have any SC interactions will be the special ones colored green |
55 |
|
|
//all edges will be lines of width determined by the SC_SC field in asc order |
56 |
|
|
//all edges lines will have color calculated based on the BB_BB_out field not discretised |
57 |
|
|
//all edges lines with adjacent ALA's will have gaps |
58 |
|
|
graphPml.draw(true, true, true, false); |
59 |
|
|
graphPml.setNodeSizeMethod("SC_SC_out", false); |
60 |
|
|
graphPml.setNodeColorMethod("BB_BB_out", false); |
61 |
|
|
graphPml.setNodeTranspCondition("(res = \"ALA\")"); |
62 |
|
|
graphPml.setSpecialRes("green", "SELECT cid, num FROM newmsdgraph.nodes WHERE (graph_id = 33729) AND (sc_sc_in+sc_sc_out = 0);"); |
63 |
|
|
graphPml.setEdgeSizeMethod("SC_SC", false); |
64 |
|
|
graphPml.setEdgeColorMethod("BB_BB", false); |
65 |
|
|
graphPml.setEdgeGapCondition("(i_res = \"ALA\" OR j_res = \"ALA\")"); |
66 |
|
|
//create the contact graph |
67 |
|
|
graphPml.outputGraph(); |
68 |
|
|
//save the image not ray-traced |
69 |
|
|
pml.saveImage("test1","/home/filippis/Desktop", false); |
70 |
|
|
//if you want later to read the view from a log file |
71 |
|
|
//pml.openLog("test1_log","/home/filippis/Desktop"); |
72 |
|
|
//get the view |
73 |
|
|
pml.getView("test1_view"); |
74 |
|
|
//pml.closeLog(); |
75 |
|
|
|
76 |
|
|
// delete all and reload the structure |
77 |
|
|
pml.delete("all", false); |
78 |
|
|
pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
79 |
|
|
|
80 |
|
|
//to check reversibility in setNodeSizeMethod, setEdgeSizeMethod |
81 |
|
|
//and discretised coloring in setNodeColorMethod, setEdgeColorMethod |
82 |
|
|
graphPml.setNodeSizeMethod("SC_SC_out", true); |
83 |
|
|
graphPml.setNodeColorMethod("BB_BB_out", true); |
84 |
|
|
graphPml.setEdgeSizeMethod("SC_SC", true); |
85 |
|
|
graphPml.setEdgeColorMethod("BB_BB", true); |
86 |
|
|
graphPml.outputGraph(); |
87 |
|
|
//set view by reading a log file |
88 |
|
|
//pml.getFileView("test2_view", "/home/filippis/Desktop/test1_log.pml"); |
89 |
|
|
//pml.setView("test2_view"); |
90 |
|
|
//set view based on the view of the first structure so that you can compare |
91 |
|
|
//different graphs for the same structure |
92 |
|
|
pml.setView("test1_view"); |
93 |
|
|
pml.saveImage("test2","/home/filippis/Desktop", false); |
94 |
|
|
|
95 |
|
|
pml.delete("all", false); |
96 |
|
|
pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
97 |
|
|
|
98 |
|
|
//to check node method for edge coloring when nodeColor method not discretised |
99 |
|
|
graphPml.setUniformNodeSize(0.6); |
100 |
|
|
graphPml.setNodeColorMethod("BB_BB_out", false); |
101 |
|
|
graphPml.setUniformEdgeSize(4); |
102 |
|
|
graphPml.setEdgeColorMethod("node", true); |
103 |
|
|
graphPml.outputGraph(); |
104 |
|
|
pml.setView("test1_view"); |
105 |
|
|
pml.saveImage("test3","/home/filippis/Desktop", false); |
106 |
|
|
|
107 |
|
|
pml.delete("all", false); |
108 |
|
|
pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
109 |
|
|
|
110 |
|
|
//to check node method for edge coloring when nodeColor method is discretised |
111 |
|
|
graphPml.setUniformNodeSize(0.6); |
112 |
|
|
graphPml.setNodeColorMethod("BB_BB_out", true); |
113 |
|
|
graphPml.setUniformEdgeSize(4); |
114 |
|
|
graphPml.setEdgeColorMethod("node", true); |
115 |
|
|
graphPml.outputGraph(); |
116 |
|
|
pml.setView("test1_view"); |
117 |
|
|
pml.saveImage("test4","/home/filippis/Desktop", false); |
118 |
|
|
|
119 |
|
|
pml.delete("all", false); |
120 |
|
|
pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
121 |
|
|
|
122 |
|
|
//to check node method for edge coloring when nodeColor method is uniform |
123 |
|
|
graphPml.setUniformNodeSize(0.6); |
124 |
|
|
graphPml.setUniformNodeColor("blue"); |
125 |
|
|
graphPml.setUniformEdgeSize(4); |
126 |
|
|
graphPml.setEdgeColorMethod("node", true); |
127 |
|
|
graphPml.outputGraph(); |
128 |
|
|
pml.setView("test1_view"); |
129 |
|
|
pml.saveImage("test5","/home/filippis/Desktop", false); |
130 |
|
|
|
131 |
|
|
pml.delete("all", false); |
132 |
|
|
pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
133 |
|
|
|
134 |
|
|
//to check the trick of directionality with gapped lines for "half" edges |
135 |
|
|
//for this purpose a SC_BB graph model is used that doesn't ensure bidirectionality |
136 |
|
|
graphPml = new Graph2Pml(serverOutPw, molObjName, 33729, "SC_BB", "SC_BB_in+SC_BB_out", "SC_BB", "true", "true", true, false, true, conn); |
137 |
|
|
graphPml.outputGraph(); |
138 |
|
|
pml.setView("test1_view"); |
139 |
|
|
pml.saveImage("test6","/home/filippis/Desktop", false); |
140 |
|
|
|
141 |
|
|
|
142 |
|
|
pml.delete("all", false); |
143 |
|
|
|
144 |
|
|
//test multi-chain macromolecule with RNA also |
145 |
|
|
pdbFileName = Msdsd2Pdb.export2File("1a0a", 1107, 2560, 1, "/project/StruPPi/ioannis/tmp"); |
146 |
|
|
molObjName = pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
147 |
|
|
System.out.println(molObjName); |
148 |
|
|
|
149 |
|
|
graphPml = new Graph2Pml(serverOutPw, molObjName, 95, "SC_SC", "SC_SC_in+SC_SC_out", "SC_SC", "true", "true", true, false, false, conn); |
150 |
|
|
graphPml.draw(true, true, false, false); |
151 |
|
|
//color nodes based on the chains they belong to |
152 |
|
|
graphPml.setNodeColorMethod("chain", true); |
153 |
|
|
graphPml.setNodeTransp(0.2); |
154 |
|
|
graphPml.setUniformEdgeColor("red"); |
155 |
|
|
graphPml.setUniformEdgeSize(4.5); |
156 |
|
|
graphPml.setEdgeGap(0.5); |
157 |
|
|
graphPml.outputGraph(); |
158 |
|
|
pml.saveImage("test7","/home/filippis/Desktop", false); |
159 |
|
|
pml.getView("test2_view"); |
160 |
|
|
|
161 |
|
|
pml.delete("all", false); |
162 |
|
|
pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
163 |
|
|
|
164 |
|
|
//color edges based on the chains they belong to |
165 |
|
|
graphPml.draw(true, true, false, false); |
166 |
|
|
graphPml.setUniformNodeColor("red"); |
167 |
|
|
graphPml.setEdgeColorMethod("chain", true); |
168 |
|
|
graphPml.outputGraph(); |
169 |
|
|
pml.setView("test2_view"); |
170 |
|
|
pml.saveImage("test8","/home/filippis/Desktop", false); |
171 |
|
|
|
172 |
|
|
pml.delete("all", false); |
173 |
|
|
pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
174 |
|
|
|
175 |
|
|
//to check node method for edge coloring when nodeColor method is based on chain coloring |
176 |
|
|
graphPml.setNodeColorMethod("chain", true); |
177 |
|
|
graphPml.setEdgeColorMethod("node", true); |
178 |
|
|
graphPml.outputGraph(); |
179 |
|
|
pml.setView("test2_view"); |
180 |
|
|
pml.saveImage("test9","/home/filippis/Desktop", false); |
181 |
|
|
|
182 |
|
|
pml.delete("all", false); |
183 |
|
|
pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
184 |
|
|
|
185 |
|
|
//draw also surface - you can not see the graph anymore |
186 |
|
|
graphPml.draw(true, true, false, true); |
187 |
|
|
graphPml.setSurfTransp(0.7); |
188 |
|
|
graphPml.outputGraph(); |
189 |
|
|
pml.setView("test2_view"); |
190 |
|
|
pml.saveImage("test10","/home/filippis/Desktop", false); |
191 |
|
|
|
192 |
|
|
try { Thread.sleep(10000); } catch (Exception e) {} |
193 |
|
|
|
194 |
|
|
//hide the surface, show the RNA also |
195 |
|
|
//change the color of the nodes for each chain using the pymol defined list of nodes for each chain |
196 |
|
|
pml.hideWhat("surface", "graphMol", false); |
197 |
|
|
pml.showWhat("lines", "restMol", false); |
198 |
|
|
graphPml.setNodesColorUniform("nodes_cidA","red"); |
199 |
|
|
graphPml.setNodesColorUniform("nodes_cidA","yellow"); |
200 |
|
|
|
201 |
|
|
try { Thread.sleep(10000); } catch (Exception e) {} |
202 |
|
|
|
203 |
|
|
//if you believe that the objects contained in the list won't exceed the pymol command length limit, |
204 |
|
|
//you can concatenate all objects as a single string selection and handle them all together |
205 |
|
|
pml.concatList("nodes", "+", "nodesStr"); |
206 |
|
|
pml.setNodeColor("blue", "nodesStr", true); |
207 |
|
|
pml.selPml("nodes", "nodesStr", true, true); |
208 |
|
|
|
209 |
|
|
pml.delete("all", false); |
210 |
|
|
pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
211 |
|
|
|
212 |
|
|
//check a graph model with only inter-secondary-structure-elements SC_SC edges |
213 |
|
|
//remember that all the nodes with SC_SC will be selected |
214 |
|
|
//use default behaviour |
215 |
|
|
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); |
216 |
|
|
graphPml.draw(true, true, false, false); |
217 |
|
|
graphPml.outputGraph(); |
218 |
|
|
pml.setView("test2_view"); |
219 |
|
|
pml.saveImage("test11","/home/filippis/Desktop", false); |
220 |
|
|
|
221 |
|
|
pml.delete("all", false); |
222 |
|
|
|
223 |
filippis |
47 |
//CGO EDGES SECTION |
224 |
|
|
pdbFileName = Msdsd2Pdb.export2File("1kj0", 21698, 55132, 9, "/project/StruPPi/ioannis/tmp"); |
225 |
|
|
molObjName = pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
226 |
|
|
|
227 |
|
|
//Cgo makes sense to be used with directed graph |
228 |
|
|
graphPml = new Graph2Pml(serverOutPw, molObjName, 35666, "SC_SC", "SC_SC_in+SC_SC_out", "SC_SC", "true", "true", true, true, true, conn); |
229 |
|
|
graphPml.draw(true, true, false, false); |
230 |
|
|
graphPml.outputGraph(); |
231 |
|
|
pml.saveImage("test12","/home/filippis/Desktop", false); |
232 |
|
|
pml.getView("test3_view"); |
233 |
|
|
|
234 |
|
|
// delete all edges |
235 |
|
|
pml.iterateList("edges", "edge"); |
236 |
|
|
pml.delete("edge", true); |
237 |
|
|
|
238 |
|
|
graphPml.draw(false, true, false, false); |
239 |
|
|
graphPml.setUniformCgoEdgeSize(0.2); |
240 |
|
|
graphPml.setEdgeColorMethod("node", true); |
241 |
|
|
graphPml.outputGraph(); |
242 |
|
|
pml.setView("test3_view"); |
243 |
|
|
pml.saveImage("test13","/home/filippis/Desktop", false); |
244 |
|
|
|
245 |
|
|
// delete all edges |
246 |
|
|
pml.iterateList("edges", "edge"); |
247 |
|
|
pml.delete("edge", true); |
248 |
|
|
|
249 |
|
|
graphPml.setEdgeSizeMethod("SC_SC", false); |
250 |
|
|
graphPml.setEdgeColorMethod("BB_BB", false); |
251 |
|
|
graphPml.outputGraph(); |
252 |
|
|
pml.setView("test3_view"); |
253 |
|
|
pml.saveImage("test14","/home/filippis/Desktop", false); |
254 |
|
|
|
255 |
|
|
pml.iterateList("edges", "edge"); |
256 |
|
|
pml.delete("edge", true); |
257 |
|
|
|
258 |
|
|
graphPml.setEdgeSizeMethod("SC_SC", true); |
259 |
|
|
graphPml.setEdgeColorMethod("BB_BB", true); |
260 |
|
|
graphPml.outputGraph(); |
261 |
|
|
pml.setView("test3_view"); |
262 |
|
|
pml.saveImage("test15","/home/filippis/Desktop", false); |
263 |
|
|
|
264 |
|
|
pml.delete("all", false); |
265 |
|
|
pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
266 |
|
|
|
267 |
|
|
//to check node method for edge coloring when nodeColor method not discretised |
268 |
|
|
graphPml.draw(true, true, false, false); |
269 |
|
|
graphPml.setUniformNodeSize(0.6); |
270 |
|
|
graphPml.setNodeColorMethod("BB_BB_out", false); |
271 |
|
|
graphPml.setUniformEdgeSize(0.4); |
272 |
|
|
graphPml.setEdgeColorMethod("node", true); |
273 |
|
|
graphPml.outputGraph(); |
274 |
|
|
pml.setView("test3_view"); |
275 |
|
|
pml.saveImage("test16","/home/filippis/Desktop", false); |
276 |
|
|
|
277 |
|
|
pml.delete("all", false); |
278 |
|
|
pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
279 |
|
|
|
280 |
|
|
//to check node method for edge coloring when nodeColor method not discretised |
281 |
|
|
graphPml.setUniformNodeSize(0.6); |
282 |
|
|
graphPml.setNodeColorMethod("BB_BB_out", true); |
283 |
|
|
graphPml.setUniformEdgeSize(0.4); |
284 |
|
|
graphPml.setEdgeColorMethod("node", true); |
285 |
|
|
graphPml.outputGraph(); |
286 |
|
|
pml.setView("test3_view"); |
287 |
|
|
pml.saveImage("test17","/home/filippis/Desktop", false); |
288 |
|
|
|
289 |
|
|
pml.delete("all", false); |
290 |
|
|
pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
291 |
|
|
|
292 |
|
|
//see "real" half-edges |
293 |
|
|
graphPml = new Graph2Pml(serverOutPw, molObjName, 35666, "SC_BB", "SC_BB_in+SC_BB_out", "SC_BB", "true", "true", true, true, true, conn); |
294 |
|
|
graphPml.outputGraph(); |
295 |
|
|
pml.setView("test3_view"); |
296 |
|
|
pml.saveImage("test18","/home/filippis/Desktop", false); |
297 |
|
|
|
298 |
|
|
pml.delete("all", false); |
299 |
|
|
|
300 |
|
|
//test multi-chain macromolecule with RNA also |
301 |
|
|
pdbFileName = "1a0a_1107_2560.pdb"; |
302 |
|
|
molObjName = pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
303 |
|
|
System.out.println(molObjName); |
304 |
|
|
|
305 |
|
|
graphPml = new Graph2Pml(serverOutPw, molObjName, 95, "SC_SC", "SC_SC_in+SC_SC_out", "SC_SC", "true", "true", true, true, true, conn); |
306 |
|
|
graphPml.draw(true, true, false, false); |
307 |
|
|
graphPml.setNodeColorMethod("SC_SC_out", false); |
308 |
|
|
graphPml.setNodeTransp(0); |
309 |
|
|
graphPml.setEdgeSizeMethod("SC_SC", false); |
310 |
|
|
graphPml.setEdgeColorMethod("chain", true); |
311 |
|
|
graphPml.outputGraph(); |
312 |
|
|
pml.saveImage("test19","/home/filippis/Desktop", false); |
313 |
|
|
|
314 |
|
|
pml.delete("all", false); |
315 |
|
|
|
316 |
|
|
pdbFileName = "1rx4_20717_52567.pdb"; |
317 |
|
|
pml.loadPDB(pdbFileName, "/project/StruPPi/ioannis/tmp"); |
318 |
|
|
|
319 |
|
|
graphPml = new Graph2Pml(serverOutPw, molObjName, 33729, "SC_SC", "SC_SC_in+SC_SC_out", "SC_SC", "true", "true", true, true, true, conn); |
320 |
|
|
graphPml.draw(true, true, false, false); |
321 |
|
|
graphPml.setNodeSizeMethod("SC_SC_out", false); |
322 |
|
|
graphPml.setNodeColorMethod("SC_SC_out", false); |
323 |
|
|
graphPml.setNodeTransp(0.6); |
324 |
|
|
graphPml.setEdgeSizeMethod("SC_SC", false); |
325 |
|
|
graphPml.setEdgeColorMethod("SC_SC", false); |
326 |
|
|
graphPml.outputGraph(); |
327 |
|
|
pml.saveImage("test20","/home/filippis/Desktop", false); |
328 |
|
|
|
329 |
filippis |
42 |
SQLC.closeConnection(conn); |
330 |
|
|
|
331 |
|
|
} |
332 |
|
|
|
333 |
filippis |
45 |
} // end of class testGraph2Pml |