|
21 | 21 | package org.biojava.nbio.structure.symmetry.gui; |
22 | 22 |
|
23 | 23 | import java.awt.event.KeyEvent; |
| 24 | +import java.util.ArrayList; |
| 25 | +import java.util.Arrays; |
24 | 26 | import java.util.List; |
| 27 | +import java.util.Set; |
| 28 | +import java.util.TreeSet; |
25 | 29 |
|
26 | 30 | import javax.swing.JMenu; |
27 | 31 | import javax.swing.JMenuBar; |
|
40 | 44 | import org.biojava.nbio.structure.symmetry.core.AxisAligner; |
41 | 45 | import org.biojava.nbio.structure.symmetry.core.QuatSymmetryResults; |
42 | 46 | import org.biojava.nbio.structure.symmetry.internal.CeSymmResult; |
| 47 | +import org.biojava.nbio.structure.symmetry.internal.SymmetryAxes; |
43 | 48 | import org.biojava.nbio.structure.symmetry.jmolScript.JmolSymmetryScriptGenerator; |
44 | 49 | import org.biojava.nbio.structure.symmetry.jmolScript.JmolSymmetryScriptGeneratorPointGroup; |
45 | 50 | import org.biojava.nbio.structure.symmetry.utils.SymmetryTools; |
46 | | -import org.jmol.util.Logger; |
| 51 | +import org.slf4j.Logger; |
| 52 | +import org.slf4j.LoggerFactory; |
47 | 53 |
|
48 | 54 | /** |
49 | 55 | * Class that provides visualizations methods for symmetry alignments. Call the |
|
54 | 60 | * |
55 | 61 | */ |
56 | 62 | public class SymmetryDisplay { |
| 63 | + |
| 64 | + private static final Logger logger = LoggerFactory |
| 65 | + .getLogger(SymmetryDisplay.class); |
57 | 66 |
|
58 | 67 | /** |
59 | 68 | * Displays a multiple alignment of the symmetry repeats. |
@@ -110,12 +119,12 @@ public static AbstractAlignmentJmol display(CeSymmResult symmResult) |
110 | 119 | jmol.setTitle(jmol.getStructure().getPDBHeader().getTitle()); |
111 | 120 | addSymmetryMenu(jmol, symmResult); |
112 | 121 | jmol.evalString(printSymmetryGroup(symmResult)); |
113 | | - jmol.evalString(printSymmetryAxes(symmResult, false)); |
| 122 | + jmol.evalString(printSymmetryAxes(symmResult)); |
114 | 123 | jmol.setTitle(getSymmTitle(symmResult)); |
115 | 124 | return jmol; |
116 | 125 | } else { |
117 | 126 | // Show the optimal self-alignment |
118 | | - Logger.info("Showing optimal self-alignment"); |
| 127 | + logger.info("Showing optimal self-alignment"); |
119 | 128 | Atom[] cloned = StructureTools |
120 | 129 | .cloneAtomArray(symmResult.getAtoms()); |
121 | 130 | AbstractAlignmentJmol jmol = StructureAlignmentDisplay.display( |
@@ -177,30 +186,31 @@ private static void addSymmetryMenu(MultipleAlignmentJmol jmol, |
177 | 186 | /** |
178 | 187 | * Generates a String that displays the symmetry axes of a structure. |
179 | 188 | * |
180 | | - * @param msa |
181 | | - * @param axes |
182 | | - * @param elementary |
183 | | - * only print elementary axes if true |
| 189 | + * @param symm CeSymmResult |
184 | 190 | * @return |
| 191 | + * @throws StructureException |
185 | 192 | */ |
186 | | - public static String printSymmetryAxes(CeSymmResult symm, boolean elementary) { |
| 193 | + public static String printSymmetryAxes(CeSymmResult symm) |
| 194 | + throws StructureException { |
187 | 195 |
|
188 | 196 | int id = 0; |
189 | 197 | String script = ""; |
190 | | - Atom[] atoms = symm.getAtoms(); |
191 | | - |
192 | | - List<Matrix4d> symmAxes = null; |
193 | | - if (elementary) { |
194 | | - symmAxes = symm.getAxes().getElementaryAxes(); |
195 | | - } else { |
196 | | - symmAxes = symm.getAxes().getSymmetryAxes(); |
197 | | - } |
198 | | - |
199 | | - for (Matrix4d axis : symmAxes) { |
200 | | - RotationAxis rot = new RotationAxis(axis); |
201 | | - script += rot.getJmolScript(atoms, id); |
| 198 | + SymmetryAxes axes = symm.getAxes(); |
| 199 | + List<Atom[]> repeats = SymmetryTools.toRepeatsAlignment(symm).getAtomArrays(); |
| 200 | + |
| 201 | + List<Matrix4d> symmAxes = axes.getElementaryAxes(); |
| 202 | + for (int a = 0; a < symmAxes.size(); a++) { |
| 203 | + RotationAxis rot = new RotationAxis(symmAxes.get(a)); |
| 204 | + Set<Integer> repIndex = new TreeSet<Integer>(axes.getRepeatRelation(a).get(0)); |
| 205 | + repIndex.addAll(axes.getRepeatRelation(a).get(1)); |
| 206 | + List<Atom> repAtoms = new ArrayList<Atom>(); |
| 207 | + for (Integer r : repIndex) |
| 208 | + repAtoms.addAll(Arrays.asList(repeats.get(r))); |
| 209 | + |
| 210 | + script += rot.getJmolScript(repAtoms.toArray(new Atom[repAtoms.size()]), id); |
202 | 211 | id++; |
203 | 212 | } |
| 213 | + |
204 | 214 | return script; |
205 | 215 | } |
206 | 216 |
|
|
0 commit comments