Skip to content

Commit 97f2635

Browse files
committed
Fix small bug in QuatSymmetryResults
1 parent 8fd9fd4 commit 97f2635

File tree

3 files changed

+31
-9
lines changed

3 files changed

+31
-9
lines changed

biojava-structure-gui/src/main/java/demo/DemoQuatSymmetryJmol.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ public class DemoQuatSymmetryJmol {
6161
public static void main(String[] args) throws IOException,
6262
StructureException {
6363

64-
String name = "4hhb";
64+
String name = "1VYM";
6565

6666
// Download the biological assembly
6767
AtomCache cache = new AtomCache();

biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/core/QuatSymmetryResults.java

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424

2525
import java.util.Collections;
2626
import java.util.List;
27+
2728
import org.biojava.nbio.structure.Structure;
2829
import org.biojava.nbio.structure.cluster.SubunitCluster;
2930
import org.biojava.nbio.structure.cluster.SubunitClusterUtils;
@@ -47,6 +48,7 @@ public class QuatSymmetryResults {
4748

4849
// Cached properties
4950
private String stoichiometry;
51+
int subunitCount;
5052

5153
// Information about the symmetry
5254
private SymmetryPerceptionMethod method;
@@ -70,7 +72,11 @@ public QuatSymmetryResults(List<SubunitCluster> clusters,
7072
this.clusters = clusters;
7173
this.stoichiometry = SubunitClusterUtils
7274
.getStoichiometryString(clusters);
73-
75+
76+
subunitCount = 0;
77+
for (SubunitCluster c : clusters)
78+
subunitCount += c.size();
79+
7480
this.rotationGroup = rotationGroup;
7581
this.method = method;
7682
}
@@ -102,7 +108,16 @@ public QuatSymmetryResults(List<SubunitCluster> clusters,
102108
public List<SubunitCluster> getSubunitClusters() {
103109
return Collections.unmodifiableList(clusters);
104110
}
105-
111+
112+
/**
113+
* Return the number of Subunits involved in the symmetry.
114+
*
115+
* @return the number of Subunits
116+
*/
117+
public int getSubunitCount() {
118+
return subunitCount;
119+
}
120+
106121
/**
107122
* @return rotation group (point group) information representing rotational
108123
* quaternary symmetry.
@@ -211,7 +226,7 @@ public void setStructure(Structure structure) {
211226
@Override
212227
public String toString() {
213228
return "QuatSymmetryResults [stoichiometry: " + getStoichiometry()
214-
+ ", symmetry: " + getSymmetry() + ", pseudoStoichiometric: "
229+
+ ", symmetry: " + getSymmetry() + ", pseudo-stoichiometric: "
215230
+ isPseudoStoichiometric() + ", local: " + local + ", method: "
216231
+ method + "]";
217232
}

biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/core/QuatSymmetrySubunits.java

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -106,10 +106,16 @@ public List<Integer> getClusterIds() {
106106
* @return A List of the Chain Ids of each Subunit
107107
*/
108108
public List<String> getChainIds() {
109-
return clusters
110-
.stream()
111-
.map(c -> c.getSubunits().get(0).getRepresentativeAtoms()[0]
112-
.getGroup().getChainId()).collect(Collectors.toList());
109+
110+
List<String> chains = new ArrayList<String>(getSubunitCount());
111+
112+
// Loop through all subunits in the clusters and fill Lists
113+
for (int c = 0; c < clusters.size(); c++) {
114+
for (int s = 0; s < clusters.get(c).size(); s++)
115+
chains.add(clusters.get(c).getSubunits().get(s).getName());
116+
}
117+
118+
return chains;
113119
}
114120

115121
/**
@@ -120,7 +126,8 @@ public List<String> getChainIds() {
120126
* @return A List of the Model number of each Subunit
121127
*/
122128
public List<Integer> getModelNumbers() {
123-
List<Integer> models = new ArrayList<Integer>(clusterIds.size());
129+
130+
List<Integer> models = new ArrayList<Integer>(getSubunitCount());
124131

125132
// Loop through all subunits in the clusters and fill Lists
126133
for (int c = 0; c < clusters.size(); c++) {

0 commit comments

Comments
 (0)