Skip to content

Commit 93297eb

Browse files
committed
Display only elementary axes of symmetry
Limit their range to the atoms that they apply to only.
1 parent 1d9db1b commit 93297eb

3 files changed

Lines changed: 31 additions & 25 deletions

File tree

biojava-structure-gui/src/main/java/org/biojava/nbio/structure/symmetry/gui/SymmetryDisplay.java

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,11 @@
2121
package org.biojava.nbio.structure.symmetry.gui;
2222

2323
import java.awt.event.KeyEvent;
24+
import java.util.ArrayList;
25+
import java.util.Arrays;
2426
import java.util.List;
27+
import java.util.Set;
28+
import java.util.TreeSet;
2529

2630
import javax.swing.JMenu;
2731
import javax.swing.JMenuBar;
@@ -40,10 +44,10 @@
4044
import org.biojava.nbio.structure.symmetry.core.AxisAligner;
4145
import org.biojava.nbio.structure.symmetry.core.QuatSymmetryResults;
4246
import org.biojava.nbio.structure.symmetry.internal.CeSymmResult;
47+
import org.biojava.nbio.structure.symmetry.internal.SymmetryAxes;
4348
import org.biojava.nbio.structure.symmetry.jmolScript.JmolSymmetryScriptGenerator;
4449
import org.biojava.nbio.structure.symmetry.jmolScript.JmolSymmetryScriptGeneratorPointGroup;
4550
import org.biojava.nbio.structure.symmetry.utils.SymmetryTools;
46-
4751
import org.slf4j.Logger;
4852
import org.slf4j.LoggerFactory;
4953

@@ -115,7 +119,7 @@ public static AbstractAlignmentJmol display(CeSymmResult symmResult)
115119
jmol.setTitle(jmol.getStructure().getPDBHeader().getTitle());
116120
addSymmetryMenu(jmol, symmResult);
117121
jmol.evalString(printSymmetryGroup(symmResult));
118-
jmol.evalString(printSymmetryAxes(symmResult, false));
122+
jmol.evalString(printSymmetryAxes(symmResult));
119123
jmol.setTitle(getSymmTitle(symmResult));
120124
return jmol;
121125
} else {
@@ -182,30 +186,31 @@ private static void addSymmetryMenu(MultipleAlignmentJmol jmol,
182186
/**
183187
* Generates a String that displays the symmetry axes of a structure.
184188
*
185-
* @param msa
186-
* @param axes
187-
* @param elementary
188-
* only print elementary axes if true
189+
* @param symm CeSymmResult
189190
* @return
191+
* @throws StructureException
190192
*/
191-
public static String printSymmetryAxes(CeSymmResult symm, boolean elementary) {
193+
public static String printSymmetryAxes(CeSymmResult symm)
194+
throws StructureException {
192195

193196
int id = 0;
194197
String script = "";
195-
Atom[] atoms = symm.getAtoms();
196-
197-
List<Matrix4d> symmAxes = null;
198-
if (elementary) {
199-
symmAxes = symm.getAxes().getElementaryAxes();
200-
} else {
201-
symmAxes = symm.getAxes().getSymmetryAxes();
202-
}
203-
204-
for (Matrix4d axis : symmAxes) {
205-
RotationAxis rot = new RotationAxis(axis);
206-
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);
207211
id++;
208212
}
213+
209214
return script;
210215
}
211216

biojava-structure-gui/src/main/java/org/biojava/nbio/structure/symmetry/gui/SymmetryListener.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,12 +66,12 @@ public void actionPerformed(ActionEvent ae) {
6666
try {
6767
if (cmd.equals("Repeats Superposition")) {
6868
MultipleAlignmentJmol j = SymmetryDisplay.displayRepeats(symm);
69-
String s = SymmetryDisplay.printSymmetryAxes(symm, true);
69+
String s = SymmetryDisplay.printSymmetryAxes(symm);
7070
j.evalString(s);
7171

7272
} else if (cmd.equals("Multiple Structure Alignment")) {
7373
MultipleAlignmentJmol j = SymmetryDisplay.displayFull(symm);
74-
String s = SymmetryDisplay.printSymmetryAxes(symm, false);
74+
String s = SymmetryDisplay.printSymmetryAxes(symm);
7575
j.evalString(s);
7676

7777
} else if (cmd.equals("Optimal Self Alignment")) {
@@ -87,7 +87,7 @@ public void actionPerformed(ActionEvent ae) {
8787
jmol.evalString(script);
8888

8989
} else if (cmd.equals("Show Symmetry Axes")) {
90-
String s = SymmetryDisplay.printSymmetryAxes(symm, false);
90+
String s = SymmetryDisplay.printSymmetryAxes(symm);
9191
jmol.evalString(s);
9292
}
9393

biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/SymmetryAxes.java

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -221,11 +221,12 @@ public Matrix4d getRepeatTransform(int repeat){
221221
/**
222222
* Return all symmetry axes of of the structure: the set of axes that
223223
* describe all parts of the structure. This combines the elementary
224-
* axes to generate all possible axes.
225-
* Use this method to display the axes.
226-
*
224+
* axes to generate all possible axes. The axes are returned in the repeat
225+
* order.
226+
* @deprecated because it does not work as expected for open symmetry
227227
* @return axes all symmetry axes of the structure.
228228
*/
229+
@Deprecated
229230
public List<Matrix4d> getSymmetryAxes(){
230231

231232
List<Matrix4d> symmAxes = new ArrayList<Matrix4d>();

0 commit comments

Comments
 (0)