2525import org .biojava .nbio .structure .Calc ;
2626import org .biojava .nbio .structure .StructureException ;
2727import org .biojava .nbio .structure .align .model .AFPChain ;
28+ import org .biojava .nbio .structure .contact .Pair ;
2829import org .biojava .nbio .structure .jama .Matrix ;
2930
3031import 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