Skip to content

Commit bf59aba

Browse files
committed
Fix #378 show ligands in symmetry Jmol GUI
1 parent ff592b8 commit bf59aba

File tree

2 files changed

+38
-15
lines changed

2 files changed

+38
-15
lines changed

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

Lines changed: 33 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,7 @@
3333
import javax.vecmath.Matrix4d;
3434

3535
import org.biojava.nbio.structure.Atom;
36+
import org.biojava.nbio.structure.Group;
3637
import org.biojava.nbio.structure.StructureException;
3738
import org.biojava.nbio.structure.StructureTools;
3839
import org.biojava.nbio.structure.align.gui.StructureAlignmentDisplay;
@@ -60,7 +61,7 @@
6061
*
6162
*/
6263
public class SymmetryDisplay {
63-
64+
6465
private static final Logger logger = LoggerFactory
6566
.getLogger(SymmetryDisplay.class);
6667

@@ -75,7 +76,8 @@ public static MultipleAlignmentJmol displayRepeats(CeSymmResult symm)
7576
throws StructureException {
7677

7778
MultipleAlignment repeats = SymmetryTools.toRepeatsAlignment(symm);
78-
MultipleAlignmentJmol jmol = MultipleAlignmentJmolDisplay.display(repeats);
79+
MultipleAlignmentJmol jmol = MultipleAlignmentJmolDisplay
80+
.display(repeats);
7981
jmol.setTitle(getSymmTitle(symm));
8082
return jmol;
8183
}
@@ -112,9 +114,22 @@ public static AbstractAlignmentJmol display(CeSymmResult symmResult)
112114
throws StructureException {
113115

114116
if (symmResult.isSignificant() && symmResult.isRefined()) {
115-
// Show the structure colored by repeat
117+
// Show the structure colored by repeat (do not rotate)
116118
MultipleAlignment msa = symmResult.getMultipleAlignment();
117119
List<Atom[]> atoms = msa.getAtomArrays();
120+
121+
// Add non polymer protein groups
122+
Atom[] allAtoms = atoms.get(0);
123+
List<Group> hetatms = StructureTools.getUnalignedGroups(allAtoms);
124+
allAtoms = Arrays
125+
.copyOf(allAtoms, allAtoms.length + hetatms.size());
126+
for (int h = 0; h < hetatms.size(); h++) {
127+
int index = (allAtoms.length - hetatms.size()) + h;
128+
allAtoms[index] = hetatms.get(h).getAtom(0);
129+
}
130+
for (int s = 0; s < msa.size(); s++)
131+
atoms.set(s, allAtoms);
132+
118133
MultipleAlignmentJmol jmol = new MultipleAlignmentJmol(msa, atoms);
119134
jmol.setTitle(jmol.getStructure().getPDBHeader().getTitle());
120135
addSymmetryMenu(jmol, symmResult);
@@ -186,28 +201,32 @@ private static void addSymmetryMenu(MultipleAlignmentJmol jmol,
186201
/**
187202
* Generates a String that displays the symmetry axes of a structure.
188203
*
189-
* @param symm CeSymmResult
204+
* @param symm
205+
* CeSymmResult
190206
* @return
191-
* @throws StructureException
207+
* @throws StructureException
192208
*/
193-
public static String printSymmetryAxes(CeSymmResult symm)
209+
public static String printSymmetryAxes(CeSymmResult symm)
194210
throws StructureException {
195211

196212
int id = 0;
197213
String script = "";
198214
SymmetryAxes axes = symm.getAxes();
199-
List<Atom[]> repeats = SymmetryTools.toRepeatsAlignment(symm).getAtomArrays();
215+
List<Atom[]> repeats = SymmetryTools.toRepeatsAlignment(symm)
216+
.getAtomArrays();
200217

201218
List<Matrix4d> symmAxes = axes.getElementaryAxes();
202219
for (int a = 0; a < symmAxes.size(); a++) {
203220
RotationAxis rot = new RotationAxis(symmAxes.get(a));
204-
Set<Integer> repIndex = new TreeSet<Integer>(axes.getRepeatRelation(a).get(0));
221+
Set<Integer> repIndex = new TreeSet<Integer>(axes
222+
.getRepeatRelation(a).get(0));
205223
repIndex.addAll(axes.getRepeatRelation(a).get(1));
206224
List<Atom> repAtoms = new ArrayList<Atom>();
207225
for (Integer r : repIndex)
208226
repAtoms.addAll(Arrays.asList(repeats.get(r)));
209-
210-
script += rot.getJmolScript(repAtoms.toArray(new Atom[repAtoms.size()]), id);
227+
228+
script += rot.getJmolScript(
229+
repAtoms.toArray(new Atom[repAtoms.size()]), id);
211230
id++;
212231
}
213232

@@ -225,9 +244,11 @@ public static String printSymmetryAxes(CeSymmResult symm)
225244
* @return
226245
* @throws StructureException
227246
*/
228-
public static String printSymmetryGroup(CeSymmResult symm) throws StructureException {
247+
public static String printSymmetryGroup(CeSymmResult symm)
248+
throws StructureException {
229249

230-
QuatSymmetryResults gSymmetry = SymmetryTools.getQuaternarySymmetry(symm);
250+
QuatSymmetryResults gSymmetry = SymmetryTools
251+
.getQuaternarySymmetry(symm);
231252

232253
AxisAligner axes = AxisAligner.getInstance(gSymmetry);
233254

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,6 @@ public class MultipleAlignmentDisplay {
5656
* @return list of transformed AtomArrays
5757
* @throws StructureException
5858
*/
59-
6059
public static List<Atom[]> getRotatedAtoms(MultipleAlignment multAln)
6160
throws StructureException {
6261

@@ -96,12 +95,15 @@ public static List<Atom[]> getRotatedAtoms(MultipleAlignment multAln)
9695
// Assume all atoms are from the same structure
9796
Structure displayS = atomArrays.get(i)[0].getGroup().getChain()
9897
.getStructure().clone();
98+
9999
// Get all the atoms and include ligands and hetatoms
100100
Atom[] rotCA = StructureTools.getRepresentativeAtomArray(displayS);
101101
List<Group> hetatms = StructureTools.getUnalignedGroups(rotCA);
102+
int index = rotCA.length;
103+
rotCA = Arrays.copyOf(rotCA, rotCA.length + hetatms.size());
102104
for (Group g : hetatms) {
103-
rotCA = Arrays.copyOf(rotCA, rotCA.length + 1);
104-
rotCA[rotCA.length - 1] = g.getAtom(0);
105+
rotCA[index] = g.getAtom(0);
106+
index++;
105107
}
106108

107109
// Transform the structure to ensure a full rotation in the display

0 commit comments

Comments
 (0)