Skip to content

Commit bc14209

Browse files
committed
Make the secondary structure objects serializable
1 parent 67b947a commit bc14209

File tree

7 files changed

+30
-7
lines changed

7 files changed

+30
-7
lines changed

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
*/
2121
package org.biojava.nbio.structure.secstruc;
2222

23+
import java.io.Serializable;
24+
2325
/**
2426
* Container that represents a beta Bridge between two residues. It contains the
2527
* two partner indices and the type of the bridge. For consistency, partner1 is
@@ -28,8 +30,10 @@
2830
* @author Aleix Lafita
2931
*
3032
*/
31-
public class BetaBridge {
33+
public class BetaBridge implements Serializable {
3234

35+
private static final long serialVersionUID = -5097435425455958487L;
36+
3337
BridgeType type;
3438
int partner1;
3539
int partner2;

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
*/
1919
package org.biojava.nbio.structure.secstruc;
2020

21+
import java.io.Serializable;
22+
2123
/**
2224
* Container that represents a hidrogen bond. It contains the energy of the bond
2325
* in cal/mol and the partner index.
@@ -26,8 +28,10 @@
2628
* @author Aleix Lafita
2729
*
2830
*/
29-
public class HBond {
31+
public class HBond implements Serializable {
3032

33+
private static final long serialVersionUID = 8246764841329431337L;
34+
3135
private double energy;
3236
private int partner;
3337

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
*/
2121
package org.biojava.nbio.structure.secstruc;
2222

23+
import java.io.Serializable;
24+
2325
/**
2426
* A Ladder is a set of one or more consecutive bridges of identical type. A
2527
* Bridge is a Ladder of length one.
@@ -28,8 +30,10 @@
2830
* @author Aleix Lafita
2931
*
3032
*/
31-
public class Ladder {
33+
public class Ladder implements Serializable {
3234

35+
private static final long serialVersionUID = -1658305503250364409L;
36+
3337
int from; // start of the first strand
3438
int to; // end of the first strand
3539
int lfrom; // start of the second strand

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
*/
2121
package org.biojava.nbio.structure.secstruc;
2222

23+
import java.io.Serializable;
24+
2325
import org.biojava.nbio.structure.ResidueNumber;
2426
import org.biojava.nbio.structure.ResidueRangeAndLength;
2527

@@ -31,8 +33,10 @@
3133
* @since 4.1.1
3234
*
3335
*/
34-
public class SecStrucElement {
36+
public class SecStrucElement implements Serializable {
3537

38+
private static final long serialVersionUID = -8485685793171396131L;
39+
3640
private SecStrucType type;
3741
private ResidueRangeAndLength range;
3842
private int index;

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

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
*/
2121
package org.biojava.nbio.structure.secstruc;
2222

23+
import java.io.Serializable;
24+
2325
import org.biojava.nbio.structure.Group;
2426

2527
/**
@@ -31,7 +33,9 @@
3133
* @since 4.1.1
3234
*
3335
*/
34-
public class SecStrucInfo {
36+
public class SecStrucInfo implements Serializable {
37+
38+
private static final long serialVersionUID = 4516925175715607227L;
3539

3640
/** Secondary strucuture assigned by the PDB author */
3741
public static final String PDB_AUTHOR_ASSIGNMENT = "PDB_AUTHOR_ASSIGNMENT";

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,6 +36,8 @@
3636
*/
3737
public class SecStrucState extends SecStrucInfo {
3838

39+
private static final long serialVersionUID = -5549430890272724340L;
40+
3941
private static final Logger logger = LoggerFactory
4042
.getLogger(SecStrucState.class);
4143

biojava-structure/src/test/java/org/biojava/nbio/structure/TestStructureSerialization.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232
import static org.junit.Assert.*;
3333

3434
/**
35-
* Test the serialization of BioJava structure objects.
35+
* Test the serialization and deserialization of BioJava structure objects.
3636
*
3737
* @author Aleix Lafita
3838
*
@@ -43,6 +43,7 @@ public class TestStructureSerialization {
4343
public void testSerializeStructure() throws IOException, StructureException, ClassNotFoundException {
4444

4545
PDBFileReader reader = new PDBFileReader();
46+
reader.getFileParsingParameters().setParseSecStruc(true);
4647
Structure sin = reader.getStructure("src/test/resources/2gox.pdb");
4748

4849
// Serialize the structure object and keep it in memory
@@ -58,7 +59,7 @@ public void testSerializeStructure() throws IOException, StructureException, Cla
5859
Structure sout = (Structure) objectIn.readObject();
5960
objectIn.close();
6061

61-
// Test some properties of the structures
62+
// Test properties of the structures before and after serialization
6263
assertEquals(sin.nrModels(), sout.nrModels());
6364
assertEquals(sin.getChains().size(), sout.getChains().size());
6465
assertEquals(sin.getName(), sout.getName());

0 commit comments

Comments
 (0)