Skip to content

Commit 387946f

Browse files
author
Matt Larson
committed
The fix to the insertion code issue to is use the ResidueNumber object as the hash key instead of a string made from the residue number. Fixes bug where structures with insertion codes were likely to have incorrect secondary structure assignments.
1 parent 74d8349 commit 387946f

2 files changed

Lines changed: 9 additions & 9 deletions

File tree

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ public class SecStrucCalc {
101101
private Atom[] atoms;
102102
// Added by Anthony - to speed up intergroup calculations
103103
private AtomContactSet contactSet;
104-
private Map<String, Integer> indResMap;
104+
private Map<ResidueNumber, Integer> indResMap;
105105
public SecStrucCalc(){
106106
ladders = new ArrayList<Ladder>();
107107
bridges = new ArrayList<BetaBridge>();
@@ -161,10 +161,10 @@ private void initContactSet() {
161161
// Initialise an array of atoms
162162
atoms = new Atom[groups.length];
163163
// Remake this local var
164-
indResMap = new HashMap<String, Integer>();
164+
indResMap = new HashMap<>();
165165
for (int i=0 ; i < groups.length ; i++){
166166
SecStrucGroup one = groups[i];
167-
indResMap.put(one.getResidueNumber().getChainName()+one.getResidueNumber().getSeqNum(), i);
167+
indResMap.put(one.getResidueNumber(), i);
168168
atoms[i] = one.getCA();
169169
}
170170
Grid grid = new Grid(CA_MIN_DIST);
@@ -433,8 +433,8 @@ private void findBridges() {
433433
Group g1 = ac.getPair().getFirst().getGroup();
434434
Group g2 = ac.getPair().getSecond().getGroup();
435435
// Get the indices
436-
int i = indResMap.get(g1.getResidueNumber().getChainName()+g1.getResidueNumber().getSeqNum());
437-
int j = indResMap.get(g2.getResidueNumber().getChainName()+g2.getResidueNumber().getSeqNum());
436+
int i = indResMap.get(g1.getResidueNumber());
437+
int j = indResMap.get(g2.getResidueNumber());
438438
// If i>j switch them over
439439
if(i>j){
440440
// Switch them over
@@ -785,8 +785,8 @@ private void calculateHBonds() {
785785
Group g1 = pair.getFirst().getGroup();
786786
Group g2 = pair.getSecond().getGroup();
787787
// Now I need to get the index of the Group in the list groups
788-
int i = indResMap.get(g1.getResidueNumber().getChainName()+g1.getResidueNumber().getSeqNum());
789-
int j = indResMap.get(g2.getResidueNumber().getChainName()+g2.getResidueNumber().getSeqNum());
788+
int i = indResMap.get(g1.getResidueNumber());
789+
int j = indResMap.get(g2.getResidueNumber());
790790
// Now check this
791791
checkAddHBond(i,j);
792792
//"backwards" hbonds are not allowed
@@ -1054,7 +1054,7 @@ private static Atom calcSimple_H(Atom c, Atom o, Atom n) {
10541054
}
10551055

10561056
private void buildHelices(){
1057-
1057+
10581058
//Alpha-helix (i+4), 3-10-helix (i+3), Pi-helix (i+5)
10591059
checkSetHelix(4, SecStrucType.helix4);
10601060
checkSetHelix(3, SecStrucType.helix3);

biojava-structure/src/test/java/org/biojava/nbio/structure/secstruc/TestSecStrucCalc.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ public void testSecStrucPred() throws StructureException, IOException {
5353

5454
//List of names to test the DSSP prediction
5555
List<String> names = Arrays.asList(
56-
"5pti", "1tim", "4hhb", "1how", "4i4q", "2k4t");
56+
"5pti", "1tim", "4hhb", "1how", "4i4q", "2k4t", "1deu");
5757
SecStrucCalc sec = new SecStrucCalc();
5858
//Predict with BioJava the SS -> Anthony has moved this out of the loop.
5959
//SecStrucCalc does not need to be reinitialised every time

0 commit comments

Comments
 (0)