Skip to content

Commit c9bd519

Browse files
committed
Filter symmetry by number of SSE
1 parent 1f63061 commit c9bd519

File tree

7 files changed

+235
-84
lines changed

7 files changed

+235
-84
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ public static void main(String[] args)
5151
*/
5252

5353
//Set the name of the protein structure to analyze
54-
String name = "1u6d";
54+
String name = "4i4q";
5555

5656
//Download the atoms
5757
AtomCache cache = new AtomCache();
@@ -66,6 +66,7 @@ public static void main(String[] args)
6666
params.setSymmType(SymmetryType.AUTO);
6767
params.setOptimization(true);
6868
params.setSymmLevels(0);
69+
params.setSSEThreshold(1);
6970

7071
//Run the alignment
7172
MultipleAlignment symmetry = ceSymm.analyze(atoms, params);

biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucTools.java

Lines changed: 72 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
/**
1414
* This class contains methods for obtaining and converting secondary structure
15-
* information from BioJava Structures.
15+
* information from BioJava {@link Structure}s.
1616
*
1717
* @author Aleix Lafita
1818
* @since 4.1.1
@@ -118,4 +118,75 @@ public static List<SecStrucElement> getSecStrucElements(Structure s) {
118118
}
119119
return listSSE;
120120
}
121+
122+
/**
123+
* Obtain the List of secondary structure elements (SecStrucElement) of a
124+
* List of Groups (assumed to be sequential, this is, connected in the
125+
* original Structure).
126+
*
127+
* @param groups
128+
* Structure with SS assignments
129+
* @return List of SecStrucElement objects
130+
*/
131+
public static List<SecStrucElement> getSecStrucElements(List<Group> groups) {
132+
133+
List<SecStrucElement> listSSE = new ArrayList<SecStrucElement>();
134+
135+
// SecStruc information - initialize
136+
SecStrucType type = SecStrucType.coil;
137+
ResidueNumber previous = new ResidueNumber();
138+
ResidueNumber start = new ResidueNumber();
139+
String chainId = "";
140+
int count = 0; // counts the number of residues in SSE
141+
142+
// Create a map for the IDs of the SSE in the structure
143+
Map<SecStrucType, Integer> ids = new TreeMap<SecStrucType, Integer>();
144+
for (SecStrucType t : SecStrucType.values())
145+
ids.put(t, 1);
146+
147+
for (Group g : groups) {
148+
149+
if (g.hasAminoAtoms()) {
150+
Object p = g.getProperty(Group.SEC_STRUC);
151+
if (p == null)
152+
continue;
153+
SecStrucInfo ss = (SecStrucInfo) p;
154+
155+
if (count > 0) {
156+
// If chain and type are equal increment counter
157+
if (ss.type == type && chainId == g.getChainId()) {
158+
previous = g.getResidueNumber();
159+
count++;
160+
continue;
161+
} else {
162+
// Save the current SSE if chain or type change
163+
SecStrucElement sse = new SecStrucElement(type, start,
164+
previous, count, ids.get(type), chainId);
165+
listSSE.add(sse);
166+
ids.put(type, ids.get(type) + 1);
167+
count = 0;
168+
169+
// Initialize a new SSE one
170+
if (ss.type != SecStrucType.coil) {
171+
type = ss.type;
172+
start = g.getResidueNumber();
173+
previous = start;
174+
chainId = g.getChainId();
175+
count = 1;
176+
}
177+
}
178+
} else {
179+
// This is for the first residue only
180+
if (ss.type != SecStrucType.coil) {
181+
type = ss.type;
182+
start = g.getResidueNumber();
183+
previous = start;
184+
chainId = g.getChainId();
185+
count = 1;
186+
}
187+
}
188+
}
189+
}
190+
return listSSE;
191+
}
121192
}

biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucType.java

Lines changed: 39 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -21,68 +21,82 @@
2121
package org.biojava.nbio.structure.secstruc;
2222

2323
/**
24-
* This enum contains all of the secondary structure types found
25-
* in the DSSP output. It also contains some methods to operate
26-
* with the SS types.
24+
* This enum contains all of the secondary structure types found in the DSSP
25+
* output. It also contains some methods to operate with the SS types.
2726
* <p>
28-
* When compared, the types are sorted in the declaration order of
29-
* the enum, which is the DSSP preference of type assignment.
27+
* When compared, the types are sorted in the declaration order of the enum,
28+
* which is the DSSP preference of type assignment.
3029
*
3130
* @author Andreas Prlic
3231
* @author Aleix Lafita
3332
*
3433
*/
3534
public enum SecStrucType {
3635

37-
helix4("alpha Helix",'H'),
38-
extended("Extended",'E'),
39-
bridge("Bridge",'B'),
40-
helix3("3-10 Helix",'G'),
41-
helix5("pi Helix",'I'),
42-
turn("Turn",'T'),
43-
bend("Bend",'S'),
44-
coil("Coil",' ');
36+
helix4("alpha Helix", 'H'),
37+
extended("Extended", 'E'),
38+
bridge("Bridge", 'B'),
39+
helix3("3-10 Helix", 'G'),
40+
helix5("pi Helix", 'I'),
41+
turn("Turn", 'T'),
42+
bend("Bend", 'S'),
43+
coil("Coil", ' ');
4544

4645
public final Character type;
4746
public final String name;
4847

49-
private SecStrucType(String name, Character stype){
48+
private SecStrucType(String name, Character stype) {
5049
this.name = name;
5150
this.type = stype;
5251
}
5352

5453
/**
55-
* Converts a Character representing a Secondary Structure type
56-
* into the corresponding enum object.
54+
* Converts a Character representing a Secondary Structure type into the
55+
* corresponding enum object.
5756
*
58-
* @param stype the character representing the SS type
57+
* @param stype
58+
* the character representing the SS type
5959
* @return SecStrucType or null if the character is invalid
6060
*/
61-
public static SecStrucType fromCharacter(Character stype){
61+
public static SecStrucType fromCharacter(Character stype) {
6262

63-
for (SecStrucType c : SecStrucType.values()){
64-
if ( c.type.equals(stype)){
63+
for (SecStrucType c : SecStrucType.values()) {
64+
if (c.type.equals(stype)) {
6565
return c;
6666
}
6767
}
6868
return null;
6969
}
7070

7171
@Override
72-
public String toString(){
72+
public String toString() {
7373
return type.toString();
7474
}
7575

7676
/**
7777
* Helix type can be 3-10 helix, pi-helix or alpha-helix.
78+
*
7879
* @return true if the type is any of the helix types, false otherwise
7980
*/
8081
public boolean isHelixType() {
81-
if (type.equals(helix4.type) ||
82-
type.equals(helix3.type) ||
83-
type.equals(helix5.type))
82+
if (type.equals(helix4.type) || type.equals(helix3.type)
83+
|| type.equals(helix5.type))
84+
return true;
85+
else
86+
return false;
87+
}
88+
89+
/**
90+
* A Beta-Strand is an extended set of sequential Bridges that, together
91+
* with other Beta-Strands, is part of a Beta-Sheet.
92+
*
93+
* @return true if the type is a Beta-Strand
94+
*/
95+
public boolean isBetaStrand() {
96+
if (type.equals(extended.type))
8497
return true;
85-
else return false;
98+
else
99+
return false;
86100
}
87101

88102
}

biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/CESymmParameters.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -190,7 +190,7 @@ public List<String> getUserConfigHelp() {
190190
params.add("SSE threshold: The minimum number of secondary structure "
191191
+ "elements (strands or helices) in each symmetrical subunit. "
192192
+ "If the subunits do not have enough SSE, the structure will "
193-
+ "be considered asymmetric.");
193+
+ "be considered asymmetric. 0 means no restriction.");
194194
// min core subunit length
195195
params.add("Minimum core length: the minimum number of non-gapped "
196196
+ "residues in every symmetric subunit.");
@@ -209,7 +209,7 @@ public List<String> getUserConfigParameters() {
209209
List<String> params = super.getUserConfigParameters();
210210
params.add("MaxSymmOrder");
211211
params.add("UserOrder");
212-
params.add("SymmetryType");
212+
params.add("SymmType");
213213
params.add("OrderDetectorMethod");
214214
params.add("RefineMethod");
215215
params.add("Optimization");
@@ -347,7 +347,7 @@ public int getSSEThreshold() {
347347
return sseThreshold;
348348
}
349349

350-
public void setSSEThrehold(Integer sseThreshold) {
350+
public void setSSEThreshold(Integer sseThreshold) {
351351
this.sseThreshold = sseThreshold;
352352
}
353353

biojava-structure/src/main/java/org/biojava/nbio/structure/symmetry/internal/CeSymm.java

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@
77

88
import org.biojava.nbio.structure.Atom;
99
import org.biojava.nbio.structure.Calc;
10+
import org.biojava.nbio.structure.Structure;
1011
import org.biojava.nbio.structure.StructureException;
1112
import org.biojava.nbio.structure.StructureTools;
1213
import org.biojava.nbio.structure.align.ce.CECalculator;
@@ -20,6 +21,8 @@
2021
import org.biojava.nbio.structure.align.multiple.util.MultipleAlignmentScorer;
2122
import org.biojava.nbio.structure.align.util.AFPChainScorer;
2223
import org.biojava.nbio.structure.jama.Matrix;
24+
import org.biojava.nbio.structure.secstruc.SecStrucPred;
25+
import org.biojava.nbio.structure.secstruc.SecStrucTools;
2326
import org.biojava.nbio.structure.symmetry.internal.CESymmParameters.RefineMethod;
2427
import org.biojava.nbio.structure.symmetry.internal.CESymmParameters.SymmetryType;
2528
import org.biojava.nbio.structure.symmetry.utils.SymmetryTools;
@@ -70,7 +73,7 @@ public class CeSymm {
7073
private SymmetryAxes axes;
7174
private boolean refined;
7275

73-
private CESymmParameters params;
76+
private CESymmParameters params = new CESymmParameters();
7477

7578
public CeSymm() {
7679
reset();
@@ -383,6 +386,15 @@ public MultipleAlignment analyze(Atom[] atoms, CESymmParameters param)
383386
}
384387
this.params = param;
385388

389+
// If the SSE information is needed, we calculate it if the user did not
390+
if (params.getSSEThreshold() > 0) {
391+
Structure s = atoms[0].getGroup().getChain().getStructure();
392+
if (SecStrucTools.getSecStrucInfo(s).isEmpty()){
393+
SecStrucPred ssp = new SecStrucPred();
394+
ssp.predict(s, true);
395+
}
396+
}
397+
386398
CeSymmIterative iter = new CeSymmIterative(param);
387399
msa = iter.execute(atoms);
388400
axes = iter.getSymmetryAxes();

0 commit comments

Comments
 (0)