Skip to content

Commit ff592b8

Browse files
committed
Use all models sequentially for symmetry analysis
This fixes point 3 of issue biojava#462
1 parent c726b74 commit ff592b8

File tree

2 files changed

+40
-11
lines changed
  • biojava-structure-gui/src/main/java/org/biojava/nbio/structure/symmetry/gui
  • biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/utils

2 files changed

+40
-11
lines changed

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

Lines changed: 13 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -23,35 +23,35 @@
2323
import org.biojava.nbio.structure.Atom;
2424
import org.biojava.nbio.structure.Structure;
2525
import org.biojava.nbio.structure.StructureException;
26-
import org.biojava.nbio.structure.StructureTools;
2726
import org.biojava.nbio.structure.align.gui.AlignmentCalculationRunnable;
2827
import org.biojava.nbio.structure.symmetry.internal.CESymmParameters;
2928
import org.biojava.nbio.structure.symmetry.internal.CeSymm;
3029
import org.biojava.nbio.structure.symmetry.internal.CeSymmResult;
30+
import org.biojava.nbio.structure.symmetry.utils.SymmetryTools;
3131
import org.slf4j.Logger;
3232
import org.slf4j.LoggerFactory;
3333

3434
/**
35-
* Calculates a symmetry analysis and displays the results.
36-
* Linked to the SymmetryGUI.
37-
* Does not generalize, uses CeSymm class directly to allow
38-
* for the symmetry axis recovery.
35+
* Calculates a symmetry analysis and displays the results. Linked to the
36+
* SymmetryGUI. Does not generalize, uses CeSymm class directly to allow for the
37+
* symmetry axis recovery.
3938
*
4039
* @author Aleix Lafita
4140
* @since 4.2.0
4241
*
4342
*/
4443
public class SymmetryCalc implements AlignmentCalculationRunnable {
4544

46-
private static final Logger logger =
47-
LoggerFactory.getLogger(SymmetryCalc.class);
45+
private static final Logger logger = LoggerFactory
46+
.getLogger(SymmetryCalc.class);
4847

4948
boolean interrupted = false;
5049

5150
private Structure structure;
5251
private SymmetryGui parent;
5352

54-
/** Requests for a structure to analyze.
53+
/**
54+
* Requests for a structure to analyze.
5555
*/
5656
public SymmetryCalc(SymmetryGui p, Structure s) {
5757
parent = p;
@@ -65,11 +65,12 @@ public void run() {
6565

6666
try {
6767

68-
Atom[] atoms = StructureTools.getRepresentativeAtomArray(structure);
68+
Atom[] atoms = SymmetryTools.getRepresentativeAtoms(structure);
69+
6970
CeSymmResult result = CeSymm.analyze(atoms, params);
7071
SymmetryDisplay.display(result);
7172

72-
} catch (StructureException e){
73+
} catch (StructureException e) {
7374
logger.warn(e.getMessage());
7475
}
7576
parent.notifyCalcFinished();
@@ -89,5 +90,6 @@ public void cleanup() {
8990
}
9091

9192
@Override
92-
public void setNrCPUs(int useNrCPUs) {}
93+
public void setNrCPUs(int useNrCPUs) {
94+
}
9395
}

biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/utils/SymmetryTools.java

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -977,4 +977,31 @@ public static void updateSymmetryScores(MultipleAlignment symm)
977977
symm.putScore(MultipleAlignmentScorer.RMSD, rmsd);
978978
}
979979

980+
/**
981+
* Returns the representative Atom Array of the first model, if the
982+
* structure is NMR, or the Array for each model, if it is a biological
983+
* assembly with multiple models.
984+
*
985+
* @param structure
986+
* @return representative Atom[]
987+
*/
988+
public static Atom[] getRepresentativeAtoms(Structure structure) {
989+
990+
if (structure.isNmr())
991+
return StructureTools.getRepresentativeAtomArray(structure);
992+
993+
else {
994+
995+
// Get Atoms of all models and rename chains (in case BIO)
996+
List<Atom> atomList = new ArrayList<Atom>();
997+
for (int m = 0; m < structure.nrModels(); m++) {
998+
for (Chain c : structure.getModel(m))
999+
atomList.addAll(Arrays.asList(StructureTools
1000+
.getRepresentativeAtomArray(c)));
1001+
}
1002+
return atomList.toArray(new Atom[0]);
1003+
}
1004+
1005+
}
1006+
9801007
}

0 commit comments

Comments
 (0)