X Tutup
Skip to content

Commit eef9765

Browse files
committed
Add information for construction of full list of symmetry axes.
For debugging, temporarily switched all axes to be default. Add CyclicForm methods to SymmetryAxes, which give a more compact representation of the aligned repeats
1 parent 87586f6 commit eef9765

File tree

4 files changed

+281
-49
lines changed

4 files changed

+281
-49
lines changed

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

Lines changed: 24 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -30,22 +30,22 @@
3030
import javax.swing.JMenu;
3131
import javax.swing.JMenuBar;
3232
import javax.swing.JMenuItem;
33-
import javax.vecmath.Matrix4d;
3433

3534
import org.biojava.nbio.structure.Atom;
3635
import org.biojava.nbio.structure.Group;
3736
import org.biojava.nbio.structure.StructureException;
3837
import org.biojava.nbio.structure.StructureTools;
38+
import org.biojava.nbio.structure.align.gui.MultipleAlignmentJmolDisplay;
3939
import org.biojava.nbio.structure.align.gui.StructureAlignmentDisplay;
4040
import org.biojava.nbio.structure.align.gui.jmol.AbstractAlignmentJmol;
41-
import org.biojava.nbio.structure.align.gui.MultipleAlignmentJmolDisplay;
4241
import org.biojava.nbio.structure.align.gui.jmol.MultipleAlignmentJmol;
4342
import org.biojava.nbio.structure.align.multiple.MultipleAlignment;
4443
import org.biojava.nbio.structure.align.util.RotationAxis;
4544
import org.biojava.nbio.structure.symmetry.core.AxisAligner;
4645
import org.biojava.nbio.structure.symmetry.core.QuatSymmetryResults;
4746
import org.biojava.nbio.structure.symmetry.internal.CeSymmResult;
4847
import org.biojava.nbio.structure.symmetry.internal.SymmetryAxes;
48+
import org.biojava.nbio.structure.symmetry.internal.SymmetryAxes.Axis;
4949
import org.biojava.nbio.structure.symmetry.jmolScript.JmolSymmetryScriptGenerator;
5050
import org.biojava.nbio.structure.symmetry.jmolScript.JmolSymmetryScriptGeneratorPointGroup;
5151
import org.biojava.nbio.structure.symmetry.utils.SymmetryTools;
@@ -208,16 +208,35 @@ private static void addSymmetryMenu(MultipleAlignmentJmol jmol,
208208
*/
209209
public static String printSymmetryAxes(CeSymmResult symm)
210210
throws StructureException {
211+
return printSymmetryAxes(symm,true);
212+
}
213+
/**
214+
* Generates a String that displays the symmetry axes of a structure.
215+
*
216+
* @param symm
217+
* CeSymmResult
218+
* @param allAxes Indicates whether all axes should be displayed or just
219+
* the elemenatary ones
220+
* @return
221+
* @throws StructureException
222+
*/
223+
public static String printSymmetryAxes(CeSymmResult symm,boolean allAxes)
224+
throws StructureException {
211225

212226
int id = 0;
213227
String script = "";
214228
SymmetryAxes axes = symm.getAxes();
215229
List<Atom[]> repeats = SymmetryTools.toRepeatsAlignment(symm)
216230
.getAtomArrays();
217231

218-
List<Matrix4d> symmAxes = axes.getElementaryAxes();
219-
for (int a = 0; a < symmAxes.size(); a++) {
220-
RotationAxis rot = new RotationAxis(symmAxes.get(a));
232+
List<Axis> symmAxes;
233+
if(allAxes) {
234+
symmAxes = axes.getSymmetryAxes();
235+
} else {
236+
symmAxes= axes.getElementaryAxesObjects();
237+
}
238+
for (Axis a : symmAxes) {
239+
RotationAxis rot = a.getRotationAxis();
221240
Set<Integer> repIndex = new TreeSet<Integer>(axes
222241
.getRepeatRelation(a).get(0));
223242
repIndex.addAll(axes.getRepeatRelation(a).get(1));

biojava-structure/src/main/java/org/biojava/nbio/structure/align/util/RotationAxis.java

Lines changed: 43 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.biojava.nbio.structure.Calc;
2626
import org.biojava.nbio.structure.StructureException;
2727
import org.biojava.nbio.structure.align.model.AFPChain;
28+
import org.biojava.nbio.structure.contact.Pair;
2829
import org.biojava.nbio.structure.jama.Matrix;
2930

3031
import javax.vecmath.AxisAngle4d;
@@ -112,6 +113,10 @@ public Atom getScrewTranslation() {
112113
public Vector3d getVector3dScrewTranslation() {
113114
return new Vector3d(screwTranslation.getX(),screwTranslation.getY(),screwTranslation.getZ());
114115
}
116+
117+
public double getTranslation() {
118+
return Calc.amount(screwTranslation);
119+
}
115120

116121
/**
117122
* Get the component of translation perpendicular to the axis of rotation.
@@ -385,27 +390,17 @@ public String getJmolScript(Atom[] atoms){
385390
}
386391

387392
/**
388-
* Returns a Jmol script which will display the axis of rotation. This
389-
* consists of a cyan arrow along the axis, plus an arc showing the angle
390-
* of rotation.
393+
* Find a segment of the axis that covers the specified set of atoms.
391394
* <p>
392-
* As the rotation angle gets smaller, the axis of rotation becomes poorly
393-
* defined and would need to get farther and farther away from the protein.
394-
* This is not particularly useful, so we arbitrarily draw it parallel to
395-
* the translation and omit the arc.
396-
* @param atoms Some atoms from the protein, used for determining the bounds
397-
* of the axis.
398-
* @param axisID in case of representing more than one axis in the same jmol
399-
* panel, indicate the ID number.
400-
*
401-
* @return The Jmol script, suitable for calls to
402-
* {@link org.biojava.nbio.structure.align.gui.jmol.StructureAlignmentJmol#evalString() jmol.evalString()}
395+
* Projects the input atoms onto the rotation axis and returns the bounding
396+
* points.
397+
* <p>
398+
* In the case of a pure translational axis, the axis location is undefined
399+
* so the center of mass will be used instead.
400+
* @param atoms
401+
* @return two points defining the axis segment
403402
*/
404-
public String getJmolScript(Atom[] atoms, int axisID){
405-
final double width=.5;// width of JMol object
406-
final String axisColor = "yellow"; //axis color
407-
final String screwColor = "orange"; //screw translation color
408-
403+
public Pair<Atom> getAxisEnds(Atom[] atoms) {
409404
// Project each Atom onto the rotation axis to determine limits
410405
double min, max;
411406
min = max = Calc.scalarProduct(rotationAxis,atoms[0]);
@@ -417,7 +412,7 @@ public String getJmolScript(Atom[] atoms, int axisID){
417412
double uLen = Calc.scalarProduct(rotationAxis,rotationAxis);// Should be 1, but double check
418413
min/=uLen;
419414
max/=uLen;
420-
415+
421416
// Project the origin onto the axis. If the axis is undefined, use the center of mass
422417
Atom axialPt;
423418
if(rotationPos == null) {
@@ -439,6 +434,34 @@ public String getJmolScript(Atom[] atoms, int axisID){
439434
Atom axisMax = (Atom) axialPt.clone();
440435
Calc.scaleAdd(max, rotationAxis, axisMax);
441436

437+
return new Pair<>(axisMin, axisMax);
438+
}
439+
/**
440+
* Returns a Jmol script which will display the axis of rotation. This
441+
* consists of a cyan arrow along the axis, plus an arc showing the angle
442+
* of rotation.
443+
* <p>
444+
* As the rotation angle gets smaller, the axis of rotation becomes poorly
445+
* defined and would need to get farther and farther away from the protein.
446+
* This is not particularly useful, so we arbitrarily draw it parallel to
447+
* the translation and omit the arc.
448+
* @param atoms Some atoms from the protein, used for determining the bounds
449+
* of the axis.
450+
* @param axisID in case of representing more than one axis in the same jmol
451+
* panel, indicate the ID number.
452+
*
453+
* @return The Jmol script, suitable for calls to
454+
* {@link org.biojava.nbio.structure.align.gui.jmol.StructureAlignmentJmol#evalString() jmol.evalString()}
455+
*/
456+
public String getJmolScript(Atom[] atoms, int axisID){
457+
final double width=.5;// width of JMol object
458+
final String axisColor = "yellow"; //axis color
459+
final String screwColor = "orange"; //screw translation color
460+
461+
Pair<Atom> endPoints = getAxisEnds(atoms);
462+
Atom axisMin = endPoints.getFirst();
463+
Atom axisMax = endPoints.getSecond();
464+
442465
StringWriter result = new StringWriter();
443466

444467
// set arrow heads to a reasonable length

0 commit comments

Comments
 (0)
X Tutup