Skip to content

Commit 85bc14a

Browse files
committed
Simplify and rename Demo for Quaternary Symmetry in structure-gui
1 parent 5bffe75 commit 85bc14a

File tree

6 files changed

+192
-498
lines changed

6 files changed

+192
-498
lines changed

biojava-structure-gui/src/main/java/demo/DemoOrientBioAssembly.java

Lines changed: 0 additions & 242 deletions
This file was deleted.
Lines changed: 129 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,129 @@
1+
/*
2+
* BioJava development code
3+
*
4+
* This code may be freely distributed and modified under the
5+
* terms of the GNU Lesser General Public Licence. This should
6+
* be distributed with the code. If you do not have a copy,
7+
* see:
8+
*
9+
* http://www.gnu.org/copyleft/lesser.html
10+
*
11+
* Copyright for this code is held jointly by the individual
12+
* authors. These should be listed in @author doc comments.
13+
*
14+
* For more information on the BioJava project and its aims,
15+
* or to join the biojava-l mailing list, visit the home page
16+
* at:
17+
*
18+
* http://www.biojava.org/
19+
*
20+
*/
21+
package demo;
22+
23+
import org.biojava.nbio.structure.Structure;
24+
import org.biojava.nbio.structure.StructureException;
25+
import org.biojava.nbio.structure.align.util.AtomCache;
26+
import org.biojava.nbio.structure.cluster.SubunitClustererMethod;
27+
import org.biojava.nbio.structure.cluster.SubunitClustererParameters;
28+
import org.biojava.nbio.structure.gui.BiojavaJmol;
29+
import org.biojava.nbio.structure.symmetry.axis.AxisAligner;
30+
import org.biojava.nbio.structure.symmetry.core.QuatSymmetryDetector;
31+
import org.biojava.nbio.structure.symmetry.core.QuatSymmetryParameters;
32+
import org.biojava.nbio.structure.symmetry.core.QuatSymmetryResults;
33+
import org.biojava.nbio.structure.symmetry.jmolScript.JmolSymmetryScriptGenerator;
34+
import org.biojava.nbio.structure.symmetry.jmolScript.JmolSymmetryScriptGeneratorPointGroup;
35+
36+
import java.io.IOException;
37+
import java.util.List;
38+
39+
/**
40+
* This demo shows how to display the {@link QuatSymmetryResults} of a
41+
* structure.
42+
* <p>
43+
* Examples: 4HHB, 4AQ5, 1LTI, 1STP, 4F88, 2W6E, 2LXC, 3OE7, 4INU, 4D8s, 4EAR,
44+
* 4IYQ, 3ZKR
45+
* <p>
46+
* Local symmetry: 2WPD (2 local symmetries), 4F88 (local C8), 1LTI (local C5),
47+
* 2W6E (local C3), 2LXC (local C2), 3OE7 (local C3)
48+
* <p>
49+
* Local Pseudosymmetry: 3ZDY, 3ZDX
50+
* <p>
51+
* Helical: 1B47
52+
* <p>
53+
* With internal symmetry: 4E3E, 1VYM
54+
*
55+
* @author Peter Rose
56+
* @author Aleix Lafita
57+
*
58+
*/
59+
public class DemoQuatSymmetryJmol {
60+
61+
public static void main(String[] args) throws IOException,
62+
StructureException {
63+
64+
String name = "4hhb";
65+
66+
// Download the biological assembly
67+
AtomCache cache = new AtomCache();
68+
cache.setUseMmCif(true);
69+
Structure structure = cache.getStructure("BIO:" + name + ":1");
70+
71+
QuatSymmetryParameters sp = new QuatSymmetryParameters();
72+
SubunitClustererParameters cp = new SubunitClustererParameters();
73+
cp.setClustererMethod(SubunitClustererMethod.SEQUENCE); // normal
74+
// cp.setClustererMethod(SubunitClustererMethod.STRUCTURE); // pseudo
75+
// cp.setClustererMethod(SubunitClustererMethod.INTERNAL_SYMMETRY);
76+
cp.setCoverageThreshold(0.9);
77+
78+
// Calculate and display the global symmetry
79+
QuatSymmetryResults globalSymmetry = QuatSymmetryDetector
80+
.calcGlobalSymmetry(structure, sp, cp);
81+
showResults(structure, name, globalSymmetry);
82+
83+
// Calculate and displaythe local symmetry
84+
List<QuatSymmetryResults> localSymmetry = QuatSymmetryDetector
85+
.calcLocalSymmetries(structure, sp, cp);
86+
87+
for (QuatSymmetryResults result : localSymmetry)
88+
showResults(structure, name, result);
89+
90+
}
91+
92+
private static void showResults(Structure s, String name,
93+
QuatSymmetryResults results) {
94+
95+
String title = name + ": " + results.getSubunits().getStoichiometry()
96+
+ ", " + results.getSymmetry();
97+
98+
if (results.getSubunits().isPseudoSymmetric())
99+
title += ", pseudosymmetric";
100+
101+
if (results.isLocal())
102+
title += ", local";
103+
104+
String script = "set defaultStructureDSSP true; set measurementUnits ANGSTROMS; select all; spacefill off; wireframe off; "
105+
+ "backbone off; cartoon on; color cartoon structure; color structure; select ligand;wireframe 0.16;spacefill 0.5; "
106+
+ "color cpk ; select all; model 0;set antialiasDisplay true; autobond=false;save STATE state_1;";
107+
108+
AxisAligner aligner = AxisAligner.getInstance(results);
109+
110+
JmolSymmetryScriptGenerator scriptGenerator = JmolSymmetryScriptGeneratorPointGroup
111+
.getInstance(aligner, "g");
112+
113+
script += scriptGenerator.getOrientationWithZoom(0);
114+
script += scriptGenerator.drawPolyhedron();
115+
script += scriptGenerator.drawAxes();
116+
script += scriptGenerator.colorBySymmetry();
117+
118+
title += ", method: " + results.getMethod();
119+
120+
script += "draw axes* on; draw poly* on;";
121+
122+
BiojavaJmol jmol = new BiojavaJmol();
123+
jmol.setStructure(s);
124+
125+
jmol.setTitle(title);
126+
jmol.evalString(script);
127+
128+
}
129+
}

0 commit comments

Comments
 (0)