Skip to content

Commit 02a7a6e

Browse files
committed
Modify the API for SS parsing and storage
1 parent 259b6ef commit 02a7a6e

7 files changed

Lines changed: 82 additions & 55 deletions

File tree

‎biojava-structure/src/main/java/demo/DemoLoadSecStruc.java‎

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,6 @@
2727
import org.biojava.nbio.structure.align.util.AtomCache;
2828
import org.biojava.nbio.structure.io.FileParsingParameters;
2929

30-
import java.util.Map;
31-
3230
public class DemoLoadSecStruc {
3331
public static void main(String[] args){
3432

@@ -48,9 +46,12 @@ public static void main(String[] args){
4846

4947
AminoAcid aa = (AminoAcid)g;
5048

51-
Map<String,String> sec = aa.getSecStruc();
49+
String sec = aa.getSecStruc().getAssignment()
50+
+ " : " + aa.getSecStruc().getType();
5251

53-
System.out.println(c.getChainID() + " " + g.getResidueNumber() + " " + g.getPDBName() + " " + " " +sec);
52+
System.out.println(c.getChainID() +
53+
" " + g.getResidueNumber() + " "
54+
+ g.getPDBName() + " " + " " +sec);
5455
}
5556
}
5657
}

‎biojava-structure/src/main/java/org/biojava/nbio/structure/AminoAcid.java‎

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525

2626
import java.util.Map;
2727

28+
import org.biojava.nbio.structure.secstruc.SecStrucInfo;
29+
2830

2931
/**
3032
* <p>
@@ -64,21 +66,21 @@ public interface AminoAcid extends Group {
6466
public static final String SEQRESRECORD = "SEQRES";
6567

6668
/**
67-
* Set the secondary structure as a Map.
69+
* Set the secondary structure information.
6870
*
69-
* @param secstr a Map object specifying the sec struc
71+
* @param secstr a {@link SecStrucInfo} object describing the SS.
7072
* @see #getSecStruc
7173
*/
72-
public void setSecStruc(Map<String,String> secstr) ;
74+
public void setSecStruc(SecStrucInfo secstr) ;
7375

7476
/**
75-
* Get secondary structure data .
77+
* Get secondary structure data.
7678
*
77-
* @return a Map object representing the sec struc value
79+
* @return a {@link SecStrucInfo} object describing the SS.
7880
*
7981
* @see #setSecStruc
8082
*/
81-
public Map<String,String> getSecStruc() ;
83+
public SecStrucInfo getSecStruc() ;
8284

8385
/**
8486
* Get N atom.

‎biojava-structure/src/main/java/org/biojava/nbio/structure/AminoAcidImpl.java‎

Lines changed: 8 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,13 @@
2222
*
2323
*/
2424
package org.biojava.nbio.structure;
25-
import java.io.Serializable;
26-
import java.util.HashMap;
27-
import java.util.Map;
2825

26+
import java.io.Serializable;
27+
import org.biojava.nbio.structure.secstruc.SecStrucInfo;
2928

3029
/**
31-
*
32-
* AminoAcid inherits most from Hetatom. Adds a few AminoAcid
33-
* specific methods.
30+
* AminoAcid inherits most from Hetatom. Adds a few AminoAcid
31+
* specific methods.
3432
* @author Andreas Prlic
3533
* @author Jules Jacobsen
3634
* @since 1.4
@@ -48,7 +46,7 @@ public class AminoAcidImpl extends HetatomImpl implements AminoAcid, Serializabl
4846
*/
4947
private Character amino_char ;
5048

51-
private Map<String,String> secstruc;
49+
private SecStrucInfo secstruc;
5250

5351
private String recordType; // allows to distinguish between AAs that have been created from SEQRES records and ATOM records
5452

@@ -59,7 +57,7 @@ public AminoAcidImpl() {
5957
super();
6058

6159
amino_char = null;
62-
secstruc = new HashMap<String,String>();
60+
secstruc = null;
6361
recordType = ATOMRECORD;
6462
}
6563

@@ -70,15 +68,15 @@ public AminoAcidImpl() {
7068
* {@inheritDoc}
7169
*/
7270
@Override
73-
public void setSecStruc(Map<String,String> secstr) {
71+
public void setSecStruc(SecStrucInfo secstr) {
7472
this.secstruc = secstr ;
7573
}
7674

7775
/**
7876
* {@inheritDoc}
7977
*/
8078
@Override
81-
public Map<String,String> getSecStruc(){
79+
public SecStrucInfo getSecStruc(){
8280
return secstruc ;
8381
}
8482

‎biojava-structure/src/main/java/org/biojava/nbio/structure/align/multiple/AbstractScoresCache.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,13 @@
1414
*
1515
*/
1616
public abstract class AbstractScoresCache implements ScoresCache {
17+
1718
private Map<String,Double> scores = null;
1819

1920
protected AbstractScoresCache() {
2021
scores = null;
2122
}
23+
2224
protected AbstractScoresCache(AbstractScoresCache cache) {
2325
this.scores = cache.scores;
2426
}

‎biojava-structure/src/main/java/org/biojava/nbio/structure/io/PDBFileParser.java‎

Lines changed: 9 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,16 @@
2424
import org.biojava.nbio.structure.*;
2525
import org.biojava.nbio.structure.io.mmcif.ChemCompGroupFactory;
2626
import org.biojava.nbio.structure.io.util.PDBTemporaryStorageUtils.LinkRecord;
27+
import org.biojava.nbio.structure.secstruc.SecStrucInfo;
28+
import org.biojava.nbio.structure.secstruc.SecStrucType;
2729
import org.biojava.nbio.structure.xtal.CrystalCell;
2830
import org.biojava.nbio.structure.xtal.SpaceGroup;
2931
import org.biojava.nbio.structure.xtal.SymoplibParser;
3032
import org.slf4j.Logger;
3133
import org.slf4j.LoggerFactory;
3234

3335
import javax.vecmath.Matrix4d;
36+
3437
import java.io.BufferedReader;
3538
import java.io.IOException;
3639
import java.io.InputStream;
@@ -203,32 +206,8 @@ public class PDBFileParser {
203206
"EXPRESSION_SYSTEM_VECTOR:", "EXPRESSION_SYSTEM_PLASMID:",
204207
"EXPRESSION_SYSTEM_GENE:", "OTHER_DETAILS:"));
205208

206-
207-
208-
/** Secondary strucuture assigned by the PDB author/
209-
*
210-
*/
211-
public static final String PDB_AUTHOR_ASSIGNMENT = "PDB_AUTHOR_ASSIGNMENT";
212-
213-
/** Helix secondary structure assignment.
214-
*
215-
*/
216-
public static final String HELIX = "HELIX";
217-
218-
/** Strand secondary structure assignment.
219-
*
220-
*/
221-
public static final String STRAND = "STRAND";
222-
223-
/** Turn secondary structure assignment.
224-
*
225-
*/
226-
public static final String TURN = "TURN";
227-
228209
private int atomCount;
229210

230-
231-
232211
private int my_ATOM_CA_THRESHOLD ;
233212

234213
private int load_max_atoms;
@@ -3005,13 +2984,13 @@ private void storeUnAlignedSeqRes(Structure structure, List<Chain> seqResChains)
30052984

30062985
private void setSecStruc(){
30072986

3008-
setSecElement(helixList, PDB_AUTHOR_ASSIGNMENT, HELIX );
3009-
setSecElement(strandList, PDB_AUTHOR_ASSIGNMENT, STRAND );
3010-
setSecElement(turnList, PDB_AUTHOR_ASSIGNMENT, TURN );
2987+
setSecElement(helixList, SecStrucInfo.PDB_AUTHOR_ASSIGNMENT, SecStrucType.helix4 );
2988+
setSecElement(strandList, SecStrucInfo.PDB_AUTHOR_ASSIGNMENT, SecStrucType.extended );
2989+
setSecElement(turnList, SecStrucInfo.PDB_AUTHOR_ASSIGNMENT, SecStrucType.coil );
30112990

30122991
}
30132992

3014-
private void setSecElement(List<Map<String,String>> secList, String assignment, String type){
2993+
private void setSecElement(List<Map<String,String>> secList, String assignment, SecStrucType type){
30152994

30162995

30172996
Iterator<Map<String,String>> iter = secList.iterator();
@@ -3052,10 +3031,8 @@ private void setSecElement(List<Map<String,String>> secList, String assignment,
30523031
if ( inRange){
30533032
if ( g instanceof AminoAcid) {
30543033
AminoAcid aa = (AminoAcid)g;
3055-
3056-
Map<String,String> assignmentMap = new HashMap<String,String>();
3057-
assignmentMap.put(assignment,type);
3058-
aa.setSecStruc(assignmentMap);
3034+
SecStrucInfo ss = new SecStrucInfo(aa, assignment, type);
3035+
aa.setSecStruc(ss);
30593036
}
30603037

30613038
}

‎biojava-structure/src/main/java/org/biojava/nbio/structure/secstruc/SecStrucElement.java‎

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ public class SecStrucElement {
1717
private SecStrucType type;
1818
private ResidueRange range;
1919
private int index;
20-
private int length = -1;
20+
private int length;
2121

2222
/**
2323
* Create a new SSE object.
@@ -27,13 +27,14 @@ public class SecStrucElement {
2727
* @param start first residue of the SSE
2828
* @param end final residue of the SSE
2929
* @param length number of residues included in the SSE
30+
* @param chainID the chain ID
3031
*/
3132
public SecStrucElement(SecStrucType type, ResidueNumber start,
32-
ResidueNumber end, int length){
33+
ResidueNumber end, int length, String chainID){
3334

3435
this.type = type;
3536
this.length = length;
36-
range = new ResidueRange(start.getChainId(), start, end);
37+
range = new ResidueRange(chainID, start, end);
3738
if (start.equals(end)) throw new IllegalArgumentException(
3839
"start and end residues cannot be equal in a SecStrucElement");
3940
}
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
package org.biojava.nbio.structure.secstruc;
2+
3+
import org.biojava.nbio.structure.AminoAcid;
4+
import org.biojava.nbio.structure.align.multiple.AbstractScoresCache;
5+
6+
/**
7+
* Container for the SS information of a single residue.
8+
* This class is designed to be stored inside an Amino Acid object.
9+
* It can also contain a back-reference to its parent AA.
10+
*
11+
* @author Aleix Lafita
12+
* @since 4.1.1
13+
*
14+
*/
15+
public class SecStrucInfo extends AbstractScoresCache {
16+
17+
/** Secondary strucuture assigned by the PDB author */
18+
public static final String PDB_AUTHOR_ASSIGNMENT = "PDB_AUTHOR_ASSIGNMENT";
19+
20+
/** Secondary strucuture predicted by the DSSP program */
21+
public static final String DSSP_ASSIGNMENT = "DSSP_ASSIGNMENT";
22+
23+
private final SecStrucType type;
24+
private final String assignment;
25+
private AminoAcid parent;
26+
27+
public SecStrucInfo(AminoAcid parent,String assignment,SecStrucType type){
28+
super();
29+
this.type = type;
30+
this.assignment = assignment;
31+
this.parent = parent;
32+
}
33+
34+
public SecStrucType getType() {
35+
return type;
36+
}
37+
38+
public String getAssignment() {
39+
return assignment;
40+
}
41+
42+
public AminoAcid getParent() {
43+
return parent;
44+
}
45+
46+
}

0 commit comments

Comments
 (0)