Skip to content

Commit 8fd9fd4

Browse files
committed
Provisional fix for Subunit coloring options
1 parent 0d13b49 commit 8fd9fd4

File tree

2 files changed

+53
-3
lines changed

2 files changed

+53
-3
lines changed

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -444,7 +444,7 @@ public String colorBySequenceCluster() {
444444
int n = subunits.getSubunitCount();
445445
List<Integer> modelNumbers = subunits.getModelNumbers();
446446
List<String> chainIds = subunits.getChainIds();
447-
List<Integer> seqClusterIds = subunits.getSequenceClusterIds();
447+
List<Integer> seqClusterIds = subunits.getClusterIds();
448448
int clusters = Collections.max(seqClusterIds) + 1;
449449
Color[] col = ColorBrewer.BrBG.getColorPalette(clusters);
450450
Color4f[] colors = ColorConverter.convertColor4f(col);
@@ -478,7 +478,7 @@ public String colorBySymmetry() {
478478
QuatSymmetrySubunits subunits = helixAxisAligner.getSubunits();
479479
List<Integer> modelNumbers = subunits.getModelNumbers();
480480
List<String> chainIds = subunits.getChainIds();
481-
List<Integer> clusterIds = subunits.getSequenceClusterIds();
481+
List<Integer> clusterIds = subunits.getClusterIds();
482482
int clusterCount = Collections.max(clusterIds) + 1;
483483

484484
Map<Color4f, List<String>> colorMap = new HashMap<Color4f, List<String>>();

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

Lines changed: 51 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222

2323
import org.biojava.nbio.structure.Atom;
2424
import org.biojava.nbio.structure.Calc;
25+
import org.biojava.nbio.structure.Chain;
2526
import org.biojava.nbio.structure.cluster.SubunitCluster;
2627
import org.biojava.nbio.structure.symmetry.geometry.MomentsOfInertia;
2728
import org.biojava.nbio.structure.symmetry.utils.SymmetryTools;
@@ -51,6 +52,7 @@ public class QuatSymmetrySubunits {
5152

5253
private List<Integer> folds = new ArrayList<Integer>();
5354
private List<Integer> clusterIds = new ArrayList<Integer>();
55+
private List<SubunitCluster> clusters;
5456

5557
private Point3d centroid;
5658
private MomentsOfInertia momentsOfInertia = new MomentsOfInertia();
@@ -63,6 +65,8 @@ public class QuatSymmetrySubunits {
6365
*/
6466
public QuatSymmetrySubunits(List<SubunitCluster> clusters) {
6567

68+
this.clusters = clusters;
69+
6670
// Loop through all subunits in the clusters and fill Lists
6771
for (int c = 0; c < clusters.size(); c++) {
6872

@@ -82,7 +86,7 @@ public QuatSymmetrySubunits(List<SubunitCluster> clusters) {
8286

8387
// List number of members in each cluster
8488
List<Integer> stoichiometries = clusters.stream().map(c -> c.size())
85-
.collect(Collectors.toList());
89+
.collect(Collectors.toList());
8690
folds = SymmetryTools.getValidFolds(stoichiometries);
8791
}
8892

@@ -94,6 +98,52 @@ public List<Integer> getClusterIds() {
9498
return clusterIds;
9599
}
96100

101+
/**
102+
* This method is provisional and should only be used for coloring Subunits.
103+
* A new coloring schema has to be implemented to allow the coloring of
104+
* Subunits, without implying one Subunit = one Chain.
105+
*
106+
* @return A List of the Chain Ids of each Subunit
107+
*/
108+
public List<String> getChainIds() {
109+
return clusters
110+
.stream()
111+
.map(c -> c.getSubunits().get(0).getRepresentativeAtoms()[0]
112+
.getGroup().getChainId()).collect(Collectors.toList());
113+
}
114+
115+
/**
116+
* This method is provisional and should only be used for coloring Subunits.
117+
* A new coloring schema has to be implemented to allow the coloring of
118+
* Subunits, without implying one Subunit = one Chain.
119+
*
120+
* @return A List of the Model number of each Subunit
121+
*/
122+
public List<Integer> getModelNumbers() {
123+
List<Integer> models = new ArrayList<Integer>(clusterIds.size());
124+
125+
// Loop through all subunits in the clusters and fill Lists
126+
for (int c = 0; c < clusters.size(); c++) {
127+
for (int s = 0; s < clusters.get(c).size(); s++) {
128+
129+
Atom[] atoms = clusters.get(c).getAlignedAtomsSubunit(s);
130+
131+
// TODO guess them chain and model (very ugly)
132+
Chain chain = atoms[0].getGroup().getChain();
133+
134+
int model = 0;
135+
for (int m = 0; m < chain.getStructure().nrModels(); m++) {
136+
if (chain.getStructure().getModel(m).contains(chain)) {
137+
model = m;
138+
break;
139+
}
140+
}
141+
models.add(model);
142+
}
143+
}
144+
return models;
145+
}
146+
97147
public int getSubunitCount() {
98148
run();
99149
if (centers == null) {

0 commit comments

Comments
 (0)