diff --git a/mmtf-api/pom.xml b/mmtf-api/pom.xml
index 800e6c6..d3d6f56 100644
--- a/mmtf-api/pom.xml
+++ b/mmtf-api/pom.xml
@@ -1,54 +1,54 @@
-
- 4.0.0
-
- org.rcsb
- mmtf
- 1.0.4-SNAPSHOT
-
- mmtf-api
- jar
- mmtf-api
- http://maven.apache.org
-
-
- UTF-8
-
-
-
-
- junit
- junit
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
- true
-
-
-
-
-
-
-
-
- org.codehaus.mojo
- findbugs-maven-plugin
- 3.0.3
-
-
-
-
-
-
+
+ 4.0.0
+
+ org.rcsb
+ mmtf
+ 1.0.4-SNAPSHOT
+
+ mmtf-api
+ jar
+ mmtf-api
+ http://maven.apache.org
+
+
+ UTF-8
+
+
+
+
+ junit
+ junit
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+ true
+
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ findbugs-maven-plugin
+ 3.0.3
+
+
+
+
+
+
diff --git a/mmtf-codec/pom.xml b/mmtf-codec/pom.xml
index 14243fc..7294a89 100644
--- a/mmtf-codec/pom.xml
+++ b/mmtf-codec/pom.xml
@@ -1,117 +1,117 @@
-
- 4.0.0
-
- org.rcsb
- mmtf
- 1.0.4-SNAPSHOT
-
- mmtf-codec
- jar
-
- mmtf-codec
- http://maven.apache.org
-
-
- UTF-8
-
-
-
-
- org.rcsb
- mmtf-api
- 1.0.4-SNAPSHOT
-
-
- org.rcsb
- mmtf-serialization
- 1.0.4-SNAPSHOT
-
-
- commons-lang
- commons-lang
- 2.4
-
-
-
- commons-beanutils
- commons-beanutils
-
-
- uk.co.jemos.podam
- podam
-
-
- org.unitils
- unitils-core
-
-
-
- junit
- junit
-
-
-
-
- org.slf4j
- slf4j-api
-
-
-
- org.apache.logging.log4j
- log4j-slf4j-impl
-
-
- org.apache.logging.log4j
- log4j-api
-
-
- org.apache.logging.log4j
- log4j-core
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
-
- true
-
-
-
-
-
-
-
-
- maven-javadoc-plugin
- 2.10.1
-
- true
- true
- true
-
- false
- true
-
-
-
- org.codehaus.mojo
- findbugs-maven-plugin
- 3.0.3
-
-
-
-
-
-
+
+ 4.0.0
+
+ org.rcsb
+ mmtf
+ 1.0.4-SNAPSHOT
+
+ mmtf-codec
+ jar
+
+ mmtf-codec
+ http://maven.apache.org
+
+
+ UTF-8
+
+
+
+
+ org.rcsb
+ mmtf-api
+ 1.0.4-SNAPSHOT
+
+
+ org.rcsb
+ mmtf-serialization
+ 1.0.4-SNAPSHOT
+
+
+ commons-lang
+ commons-lang
+ 2.4
+
+
+
+ commons-beanutils
+ commons-beanutils
+
+
+ uk.co.jemos.podam
+ podam
+
+
+ org.unitils
+ unitils-core
+
+
+
+ junit
+ junit
+
+
+
+
+ org.slf4j
+ slf4j-api
+
+
+
+ org.apache.logging.log4j
+ log4j-slf4j-impl
+
+
+ org.apache.logging.log4j
+ log4j-api
+
+
+ org.apache.logging.log4j
+ log4j-core
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ true
+
+
+
+
+
+
+
+
+ maven-javadoc-plugin
+ 2.10.1
+
+ true
+ true
+ true
+
+ false
+ true
+
+
+
+ org.codehaus.mojo
+ findbugs-maven-plugin
+ 3.0.3
+
+
+
+
+
+
diff --git a/mmtf-codec/src/main/java/org/rcsb/mmtf/decoder/GenericDecoder.java b/mmtf-codec/src/main/java/org/rcsb/mmtf/decoder/GenericDecoder.java
index 57951d4..10ab554 100644
--- a/mmtf-codec/src/main/java/org/rcsb/mmtf/decoder/GenericDecoder.java
+++ b/mmtf-codec/src/main/java/org/rcsb/mmtf/decoder/GenericDecoder.java
@@ -1,482 +1,484 @@
-package org.rcsb.mmtf.decoder;
-
-import java.util.ArrayList;
-import java.util.List;
-
-import org.rcsb.mmtf.api.StructureDataInterface;
-import org.rcsb.mmtf.codec.CharCodecs;
-import org.rcsb.mmtf.codec.FloatCodecs;
-import org.rcsb.mmtf.codec.IntCodecs;
-import org.rcsb.mmtf.codec.StringCodecs;
-import org.rcsb.mmtf.dataholders.BioAssemblyData;
-import org.rcsb.mmtf.dataholders.Entity;
-import org.rcsb.mmtf.dataholders.Group;
-import org.rcsb.mmtf.dataholders.MmtfStructure;
-
-/**
- * A genric decoder of MMTF data - that does not hard code the encoding strategy.
- * @author Anthony Bradley
- *
- */
-public class GenericDecoder implements StructureDataInterface {
-
- /**
- * Constructor for the default decoder.
- * @param inputData The input mmtfBean data to be decompressed.
- */
- public GenericDecoder(MmtfStructure inputData) {
- // Decode the coordinate and B-factor arrays.
- cartnX = FloatCodecs.decodeArr(inputData.getxCoordList());
- cartnY = FloatCodecs.decodeArr(inputData.getyCoordList());
- cartnZ = FloatCodecs.decodeArr(inputData.getzCoordList());
- bFactor = FloatCodecs.decodeArr(inputData.getbFactorList());
- // Run length decode the occupancy array
- occupancy = FloatCodecs.decodeArr(inputData.getOccupancyList());
- // Run length and delta
- atomId = IntCodecs.decodeArr(inputData.getAtomIdList());
- // Run length encoded
- altId = CharCodecs.decodeArr(inputData.getAltLocList());
- insertionCodeList = CharCodecs.decodeArr(inputData.getInsCodeList());
- // Get the groupNumber
- groupNum = IntCodecs.decodeArr(inputData.getGroupIdList());
- // Get the group map (all the unique groups in the structure).
- groupMap = inputData.getGroupList();
- // Get the seqRes groups
- seqResGroupList = IntCodecs.decodeArr(inputData.getSequenceIndexList());
- groupList = IntCodecs.decodeArr(inputData.getGroupTypeList());
- // Get the internal and public facing chain ids
- publicChainIds = StringCodecs.decodeArr(inputData.getChainNameList());
- chainList = StringCodecs.decodeArr(inputData.getChainIdList());
- interGroupBondIndices = IntCodecs.decodeArr(inputData.getBondAtomList());
- interGroupBondOrders = IntCodecs.decodeArr(inputData.getBondOrderList());
- secStructInfo = IntCodecs.decodeArr(inputData.getSecStructList());
- // Get the number of chains per model
- chainsPerModel = inputData.getChainsPerModel();
- groupsPerChain = inputData.getGroupsPerChain();
- spaceGroup = inputData.getSpaceGroup();
- unitCell = inputData.getUnitCell();
- bioAssembly = inputData.getBioAssemblyList();
- mmtfVersion = inputData.getMmtfVersion();
- mmtfProducer = inputData.getMmtfProducer();
- entityList = inputData.getEntityList();
- pdbId = inputData.getStructureId();
- // Now get the header data
- rFree = inputData.getrFree();
- // Optional fields
- rWork = inputData.getrWork();
- resolution = inputData.getResolution();
- title = inputData.getTitle();
- experimentalMethods = inputData.getExperimentalMethods();
- // Now get the relase information
- depositionDate = inputData.getDepositionDate();
- releaseDate = inputData.getReleaseDate();
- numGroups = inputData.getNumGroups();
- numChains = inputData.getNumChains();
- numModels = inputData.getNumModels();
- ncsOperMatrixList = inputData.getNcsOperatorList();
- }
-
- /** The X coordinates */
- private float[] cartnX;
-
- /** The Y coordinates */
- private float[] cartnY;
-
- /** The Z coordinates */
- private float[] cartnZ;
-
- /** The X coordinates */
- private float[] bFactor;
-
- /** The Y coordinates */
- private float[] occupancy;
-
- /** The atom id. */
- private int[] atomId;
-
- /** The alt id. */
- private char[] altId;
-
- /** The ins code. */
- private char[] insertionCodeList;
-
- /** The group num. */
- private int[] groupNum;
-
- /** The group map. */
- private Group[] groupMap;
-
- /** The group list. */
- private int[] groupList;
-
- /** The sequence ids of the groups */
- private int[] seqResGroupList;
-
- /** The public facing chain ids*/
- private String[] publicChainIds;
-
- /** The number of chains per model*/
- private int[] chainsPerModel;
-
- /** The number of groups per (internal) chain*/
- private int[] groupsPerChain;
-
- /** The space group of the structure*/
- private String spaceGroup;
-
- /** The unit cell of the structure*/
- private float[] unitCell;
-
- /** The bioassembly information for the structure*/
- private List bioAssembly;
-
- /** The bond indices for bonds between groups*/
- private int[] interGroupBondIndices;
-
- /** The bond orders for bonds between groups*/
- private int[] interGroupBondOrders;
-
- /** The chosen list of chain ids */
- private String[] chainList;
-
- /** The mmtf version */
- private String mmtfVersion;
-
- /** The mmtf prodcuer */
- private String mmtfProducer;
-
- /** A list containing pdb group names for nucleic acids */
- List nucAcidList = new ArrayList<>();
-
- /** The list of entities in this structure. */
- private Entity[] entityList;
-
- /** The PDB id */
- private String pdbId;
-
- /** The reported resolution of the dataset. */
- private Float resolution;
-
- /** The reported R Free of the model. */
- private Float rFree;
-
- /** The reported R Work of the model. */
- private Float rWork;
-
- /** The title of the model. */
- private String title;
-
- /** The list of experimental methods. */
- private String[] experimentalMethods;
-
- /** The deposition date of the structure */
- private String depositionDate;
-
- /** The release date of the structure */
- private String releaseDate;
-
- private int[] secStructInfo;
-
- private int numModels;
-
- private int numChains;
-
- private int numGroups;
-
- private double[][] ncsOperMatrixList;
-
-
-
- @Override
- public float[] getxCoords() {
- return cartnX;
- }
-
- @Override
- public float[] getyCoords() {
- return cartnY;
- }
-
- @Override
- public float[] getzCoords() {
- return cartnZ;
- }
-
- @Override
- public float[] getbFactors() {
- return bFactor;
- }
-
- @Override
- public float[] getOccupancies() {
- return occupancy;
- }
-
- @Override
- public int[] getAtomIds() {
- return atomId;
- }
-
- @Override
- public char[] getAltLocIds() {
- return altId;
- }
-
- @Override
- public char[] getInsCodes() {
- return insertionCodeList;
- }
-
- @Override
- public int[] getGroupIds() {
- return groupNum;
- }
-
- @Override
- public int[] getGroupTypeIndices() {
- return groupList;
- }
-
- @Override
- public int[] getGroupSequenceIndices() {
- return seqResGroupList;
- }
-
- @Override
- public String[] getChainNames() {
- return publicChainIds;
- }
-
- @Override
- public int[] getChainsPerModel() {
- return chainsPerModel;
- }
-
- @Override
- public int[] getGroupsPerChain() {
- return groupsPerChain;
- }
-
- @Override
- public String getSpaceGroup() {
- return spaceGroup;
- }
-
- @Override
- public float[] getUnitCell() {
- return unitCell;
- }
-
- @Override
- public int[] getInterGroupBondIndices() {
- return interGroupBondIndices;
- }
-
- @Override
- public int[] getInterGroupBondOrders() {
- return interGroupBondOrders;
- }
-
- @Override
- public String[] getChainIds() {
- return chainList;
- }
-
- @Override
- public String getMmtfVersion() {
- return mmtfVersion;
- }
-
- @Override
- public String getMmtfProducer() {
- return mmtfProducer;
- }
-
- @Override
- public String getStructureId() {
- return pdbId;
- }
-
- @Override
- public int getNumGroups() {
- return numGroups;
- }
-
- @Override
- public int getNumChains() {
- return numChains;
- }
-
- @Override
- public int getNumModels() {
- return numModels;
- }
-
- @Override
- public int getNumAtoms() {
- return this.cartnX.length;
- }
-
- @Override
- public float getRfree() {
- if (rFree==null|| rFree ==0.0f) {
- return MmtfStructure.UNAVAILABLE_R_VALUE;
- }
- return rFree;
- }
-
- @Override
- public float getResolution() {
- if (resolution==null || resolution==0.0f) {
- return MmtfStructure.UNAVAILABLE_RESOLUTION_VALUE;
- }
- return resolution;
- }
-
- @Override
- public float getRwork() {
- if (rWork==null|| rWork ==0.0f) {
- return MmtfStructure.UNAVAILABLE_R_VALUE;
- }
- return rWork;
- }
-
- @Override
- public String getTitle() {
- return title;
- }
-
- @Override
- public String[] getExperimentalMethods() {
- return experimentalMethods;
- }
-
- @Override
- public String getGroupName(int groupInd) {
- return groupMap[groupInd].getGroupName();
- }
-
- public int getNumAtomsInGroup(int groupInd) {
- return groupMap[groupInd].getFormalChargeList().length;
- }
-
- @Override
- public String[] getGroupAtomNames(int groupInd) {
- return groupMap[groupInd].getAtomNameList();
- }
-
- @Override
- public String[] getGroupElementNames(int groupInd) {
- return groupMap[groupInd].getElementList();
-
- }
-
- @Override
- public int[] getGroupBondOrders(int groupInd) {
- return groupMap[groupInd].getBondOrderList();
-
- }
-
- @Override
- public int[] getGroupBondIndices(int groupInd) {
- return groupMap[groupInd].getBondAtomList();
- }
-
- @Override
- public int[] getGroupAtomCharges(int groupInd) {
- return groupMap[groupInd].getFormalChargeList();
- }
-
- @Override
- public char getGroupSingleLetterCode(int groupInd) {
- return groupMap[groupInd].getSingleLetterCode();
- }
-
- @Override
- public String getGroupChemCompType(int groupInd) {
- return groupMap[groupInd].getChemCompType();
- }
-
- @Override
- public String getEntityDescription(int entityInd) {
- return entityList[entityInd].getDescription();
- }
-
- @Override
- public String getEntityType(int entityInd) {
- return entityList[entityInd].getType();
-
- }
-
- @Override
- public int[] getEntityChainIndexList(int entityInd) {
- return entityList[entityInd].getChainIndexList();
-
- }
-
- @Override
- public String getEntitySequence(int entityInd) {
- return entityList[entityInd].getSequence();
-
- }
-
- @Override
- public int getNumEntities() {
- return entityList.length;
- }
-
- @Override
- public int getNumBioassemblies() {
- return bioAssembly.size();
- }
-
- @Override
- public int getNumTransInBioassembly(int bioassemblyIndex) {
- return bioAssembly.get(bioassemblyIndex).getTransformList().size();
- }
-
- @Override
- public int[] getChainIndexListForTransform(int bioassemblyIndex, int transformationIndex) {
- return bioAssembly.get(bioassemblyIndex).getTransformList().get(transformationIndex).getChainIndexList();
- }
-
- @Override
- public double[] getMatrixForTransform(int bioassemblyIndex, int transformationIndex) {
- return bioAssembly.get(bioassemblyIndex).getTransformList().get(transformationIndex).getMatrix();
- }
-
- @Override
- public String getDepositionDate() {
- return depositionDate;
- }
-
- @Override
- public int getNumBonds() {
- int numIntergroupBonds = interGroupBondOrders.length;
- for(int groupIndex : groupList) {
- numIntergroupBonds+=groupMap[groupIndex].getBondOrderList().length;
- }
- return numIntergroupBonds;
- }
-
- @Override
- public int[] getSecStructList() {
- return secStructInfo;
- }
-
- @Override
- public String getReleaseDate() {
- return releaseDate;
- }
-
- @Override
- public double[][] getNcsOperatorList() {
- return ncsOperMatrixList;
- }
-
- @Override
- public String getBioassemblyName(int bioassemblyIndex) {
- return bioAssembly.get(bioassemblyIndex).getName();
- }
-
-}
+package org.rcsb.mmtf.decoder;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import org.rcsb.mmtf.api.StructureDataInterface;
+import org.rcsb.mmtf.codec.CharCodecs;
+import org.rcsb.mmtf.codec.FloatCodecs;
+import org.rcsb.mmtf.codec.IntCodecs;
+import org.rcsb.mmtf.codec.StringCodecs;
+import org.rcsb.mmtf.dataholders.BioAssemblyData;
+import org.rcsb.mmtf.dataholders.Entity;
+import org.rcsb.mmtf.dataholders.Group;
+import org.rcsb.mmtf.dataholders.MmtfStructure;
+
+/**
+ * A genric decoder of MMTF data - that does not hard code the encoding strategy.
+ * @author Anthony Bradley
+ *
+ */
+public class GenericDecoder implements StructureDataInterface {
+
+ /**
+ * Constructor for the default decoder.
+ * @param inputData The input mmtfBean data to be decompressed.
+ */
+ public GenericDecoder(MmtfStructure inputData) {
+ // Decode the coordinate and B-factor arrays.
+ cartnX = FloatCodecs.decodeArr(inputData.getxCoordList());
+ cartnY = FloatCodecs.decodeArr(inputData.getyCoordList());
+ cartnZ = FloatCodecs.decodeArr(inputData.getzCoordList());
+ bFactor = FloatCodecs.decodeArr(inputData.getbFactorList());
+ // Run length decode the occupancy array
+ occupancy = FloatCodecs.decodeArr(inputData.getOccupancyList());
+ // Run length and delta
+ atomId = IntCodecs.decodeArr(inputData.getAtomIdList());
+ // Run length encoded
+ altId = CharCodecs.decodeArr(inputData.getAltLocList());
+ insertionCodeList = CharCodecs.decodeArr(inputData.getInsCodeList());
+ // Get the groupNumber
+ groupNum = IntCodecs.decodeArr(inputData.getGroupIdList());
+ // Get the group map (all the unique groups in the structure).
+ groupMap = inputData.getGroupList();
+ // Get the seqRes groups
+ seqResGroupList = IntCodecs.decodeArr(inputData.getSequenceIndexList());
+ groupList = IntCodecs.decodeArr(inputData.getGroupTypeList());
+ // Get the internal and public facing chain ids
+ publicChainIds = StringCodecs.decodeArr(inputData.getChainNameList());
+ chainList = StringCodecs.decodeArr(inputData.getChainIdList());
+ interGroupBondIndices = IntCodecs.decodeArr(inputData.getBondAtomList());
+ interGroupBondOrders = IntCodecs.decodeArr(inputData.getBondOrderList());
+ secStructInfo = IntCodecs.decodeArr(inputData.getSecStructList());
+ // Get the number of chains per model
+ chainsPerModel = inputData.getChainsPerModel();
+ groupsPerChain = inputData.getGroupsPerChain();
+ spaceGroup = inputData.getSpaceGroup();
+ unitCell = inputData.getUnitCell();
+ bioAssembly = inputData.getBioAssemblyList();
+ mmtfVersion = inputData.getMmtfVersion();
+ mmtfProducer = inputData.getMmtfProducer();
+ entityList = inputData.getEntityList();
+ pdbId = inputData.getStructureId();
+ // Now get the header data
+ rFree = inputData.getrFree();
+ // Optional fields
+ rWork = inputData.getrWork();
+ resolution = inputData.getResolution();
+ title = inputData.getTitle();
+ experimentalMethods = inputData.getExperimentalMethods();
+ // Now get the relase information
+ depositionDate = inputData.getDepositionDate();
+ releaseDate = inputData.getReleaseDate();
+ numGroups = inputData.getNumGroups();
+ numChains = inputData.getNumChains();
+ numModels = inputData.getNumModels();
+ numIntergroupBonds = interGroupBondOrders.length;
+ for(int groupIndex : groupList) {
+ numIntergroupBonds += groupMap[groupIndex].getBondOrderList().length;
+ }
+ ncsOperMatrixList = inputData.getNcsOperatorList();
+ }
+
+ /** The X coordinates */
+ private float[] cartnX;
+
+ /** The Y coordinates */
+ private float[] cartnY;
+
+ /** The Z coordinates */
+ private float[] cartnZ;
+
+ /** The X coordinates */
+ private float[] bFactor;
+
+ /** The Y coordinates */
+ private float[] occupancy;
+
+ /** The atom id. */
+ private int[] atomId;
+
+ /** The alt id. */
+ private char[] altId;
+
+ /** The ins code. */
+ private char[] insertionCodeList;
+
+ /** The group num. */
+ private int[] groupNum;
+
+ /** The group map. */
+ private Group[] groupMap;
+
+ /** The group list. */
+ private int[] groupList;
+
+ /** The sequence ids of the groups */
+ private int[] seqResGroupList;
+
+ /** The public facing chain ids*/
+ private String[] publicChainIds;
+
+ /** The number of chains per model*/
+ private int[] chainsPerModel;
+
+ /** The number of groups per (internal) chain*/
+ private int[] groupsPerChain;
+
+ /** The space group of the structure*/
+ private String spaceGroup;
+
+ /** The unit cell of the structure*/
+ private float[] unitCell;
+
+ /** The bioassembly information for the structure*/
+ private List bioAssembly;
+
+ /** The bond indices for bonds between groups*/
+ private int[] interGroupBondIndices;
+
+ /** The bond orders for bonds between groups*/
+ private int[] interGroupBondOrders;
+
+ /** The chosen list of chain ids */
+ private String[] chainList;
+
+ /** The mmtf version */
+ private String mmtfVersion;
+
+ /** The mmtf prodcuer */
+ private String mmtfProducer;
+
+ /** A list containing pdb group names for nucleic acids */
+ List nucAcidList = new ArrayList<>();
+
+ /** The list of entities in this structure. */
+ private Entity[] entityList;
+
+ /** The PDB id */
+ private String pdbId;
+
+ /** The reported resolution of the dataset. */
+ private Float resolution;
+
+ /** The reported R Free of the model. */
+ private Float rFree;
+
+ /** The reported R Work of the model. */
+ private Float rWork;
+
+ /** The title of the model. */
+ private String title;
+
+ /** The list of experimental methods. */
+ private String[] experimentalMethods;
+
+ /** The deposition date of the structure */
+ private String depositionDate;
+
+ /** The release date of the structure */
+ private String releaseDate;
+
+ private int[] secStructInfo;
+
+ private int numModels;
+
+ private int numChains;
+
+ private int numGroups;
+
+ private int numIntergroupBonds;
+
+ private double[][] ncsOperMatrixList;
+
+
+
+ @Override
+ public float[] getxCoords() {
+ return cartnX;
+ }
+
+ @Override
+ public float[] getyCoords() {
+ return cartnY;
+ }
+
+ @Override
+ public float[] getzCoords() {
+ return cartnZ;
+ }
+
+ @Override
+ public float[] getbFactors() {
+ return bFactor;
+ }
+
+ @Override
+ public float[] getOccupancies() {
+ return occupancy;
+ }
+
+ @Override
+ public int[] getAtomIds() {
+ return atomId;
+ }
+
+ @Override
+ public char[] getAltLocIds() {
+ return altId;
+ }
+
+ @Override
+ public char[] getInsCodes() {
+ return insertionCodeList;
+ }
+
+ @Override
+ public int[] getGroupIds() {
+ return groupNum;
+ }
+
+ @Override
+ public int[] getGroupTypeIndices() {
+ return groupList;
+ }
+
+ @Override
+ public int[] getGroupSequenceIndices() {
+ return seqResGroupList;
+ }
+
+ @Override
+ public String[] getChainNames() {
+ return publicChainIds;
+ }
+
+ @Override
+ public int[] getChainsPerModel() {
+ return chainsPerModel;
+ }
+
+ @Override
+ public int[] getGroupsPerChain() {
+ return groupsPerChain;
+ }
+
+ @Override
+ public String getSpaceGroup() {
+ return spaceGroup;
+ }
+
+ @Override
+ public float[] getUnitCell() {
+ return unitCell;
+ }
+
+ @Override
+ public int[] getInterGroupBondIndices() {
+ return interGroupBondIndices;
+ }
+
+ @Override
+ public int[] getInterGroupBondOrders() {
+ return interGroupBondOrders;
+ }
+
+ @Override
+ public String[] getChainIds() {
+ return chainList;
+ }
+
+ @Override
+ public String getMmtfVersion() {
+ return mmtfVersion;
+ }
+
+ @Override
+ public String getMmtfProducer() {
+ return mmtfProducer;
+ }
+
+ @Override
+ public String getStructureId() {
+ return pdbId;
+ }
+
+ @Override
+ public int getNumGroups() {
+ return numGroups;
+ }
+
+ @Override
+ public int getNumChains() {
+ return numChains;
+ }
+
+ @Override
+ public int getNumModels() {
+ return numModels;
+ }
+
+ @Override
+ public int getNumAtoms() {
+ return this.cartnX.length;
+ }
+
+ @Override
+ public float getRfree() {
+ if (rFree==null|| rFree ==0.0f) {
+ return MmtfStructure.UNAVAILABLE_R_VALUE;
+ }
+ return rFree;
+ }
+
+ @Override
+ public float getResolution() {
+ if (resolution==null || resolution==0.0f) {
+ return MmtfStructure.UNAVAILABLE_RESOLUTION_VALUE;
+ }
+ return resolution;
+ }
+
+ @Override
+ public float getRwork() {
+ if (rWork==null|| rWork ==0.0f) {
+ return MmtfStructure.UNAVAILABLE_R_VALUE;
+ }
+ return rWork;
+ }
+
+ @Override
+ public String getTitle() {
+ return title;
+ }
+
+ @Override
+ public String[] getExperimentalMethods() {
+ return experimentalMethods;
+ }
+
+ @Override
+ public String getGroupName(int groupInd) {
+ return groupMap[groupInd].getGroupName();
+ }
+
+ public int getNumAtomsInGroup(int groupInd) {
+ return groupMap[groupInd].getFormalChargeList().length;
+ }
+
+ @Override
+ public String[] getGroupAtomNames(int groupInd) {
+ return groupMap[groupInd].getAtomNameList();
+ }
+
+ @Override
+ public String[] getGroupElementNames(int groupInd) {
+ return groupMap[groupInd].getElementList();
+
+ }
+
+ @Override
+ public int[] getGroupBondOrders(int groupInd) {
+ return groupMap[groupInd].getBondOrderList();
+
+ }
+
+ @Override
+ public int[] getGroupBondIndices(int groupInd) {
+ return groupMap[groupInd].getBondAtomList();
+ }
+
+ @Override
+ public int[] getGroupAtomCharges(int groupInd) {
+ return groupMap[groupInd].getFormalChargeList();
+ }
+
+ @Override
+ public char getGroupSingleLetterCode(int groupInd) {
+ return groupMap[groupInd].getSingleLetterCode();
+ }
+
+ @Override
+ public String getGroupChemCompType(int groupInd) {
+ return groupMap[groupInd].getChemCompType();
+ }
+
+ @Override
+ public String getEntityDescription(int entityInd) {
+ return entityList[entityInd].getDescription();
+ }
+
+ @Override
+ public String getEntityType(int entityInd) {
+ return entityList[entityInd].getType();
+
+ }
+
+ @Override
+ public int[] getEntityChainIndexList(int entityInd) {
+ return entityList[entityInd].getChainIndexList();
+
+ }
+
+ @Override
+ public String getEntitySequence(int entityInd) {
+ return entityList[entityInd].getSequence();
+
+ }
+
+ @Override
+ public int getNumEntities() {
+ return entityList.length;
+ }
+
+ @Override
+ public int getNumBioassemblies() {
+ return bioAssembly.size();
+ }
+
+ @Override
+ public int getNumTransInBioassembly(int bioassemblyIndex) {
+ return bioAssembly.get(bioassemblyIndex).getTransformList().size();
+ }
+
+ @Override
+ public int[] getChainIndexListForTransform(int bioassemblyIndex, int transformationIndex) {
+ return bioAssembly.get(bioassemblyIndex).getTransformList().get(transformationIndex).getChainIndexList();
+ }
+
+ @Override
+ public double[] getMatrixForTransform(int bioassemblyIndex, int transformationIndex) {
+ return bioAssembly.get(bioassemblyIndex).getTransformList().get(transformationIndex).getMatrix();
+ }
+
+ @Override
+ public String getDepositionDate() {
+ return depositionDate;
+ }
+
+ @Override
+ public int getNumBonds() {
+ return numIntergroupBonds;
+ }
+
+ @Override
+ public int[] getSecStructList() {
+ return secStructInfo;
+ }
+
+ @Override
+ public String getReleaseDate() {
+ return releaseDate;
+ }
+
+ @Override
+ public double[][] getNcsOperatorList() {
+ return ncsOperMatrixList;
+ }
+
+ @Override
+ public String getBioassemblyName(int bioassemblyIndex) {
+ return bioAssembly.get(bioassemblyIndex).getName();
+ }
+
+}
diff --git a/mmtf-codec/src/main/java/org/rcsb/mmtf/decoder/ReaderUtils.java b/mmtf-codec/src/main/java/org/rcsb/mmtf/decoder/ReaderUtils.java
index fccb05c..d2f430c 100644
--- a/mmtf-codec/src/main/java/org/rcsb/mmtf/decoder/ReaderUtils.java
+++ b/mmtf-codec/src/main/java/org/rcsb/mmtf/decoder/ReaderUtils.java
@@ -1,128 +1,148 @@
-package org.rcsb.mmtf.decoder;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-import java.nio.file.Files;
-import java.nio.file.Path;
-import java.util.zip.GZIPInputStream;
-
-import org.rcsb.mmtf.dataholders.MmtfStructure;
-import org.rcsb.mmtf.serialization.MessagePackSerialization;
-import org.rcsb.mmtf.utils.CodecUtils;
-
-/**
- * A class of static utility methods for reading data.
- * @author Anthony Bradley
- *
- */
-public class ReaderUtils {
-
- /** The size of a chunk for a byte buffer. */
- private static final int BYTE_BUFFER_CHUNK_SIZE = 4096;
-
- /**
- * Find the message pack byte array from the web using the input code and a base url.
- * Caches the file if possible.
- * @param pdbCode the pdb code for the desired structure.
- * @return the MMTFBean of the deserialized data
- * @throws IOException if the data cannot be read from the URL
- */
- public static MmtfStructure getDataFromUrl(String pdbCode) throws IOException {
- // Get these as an inputstream
- byte[] byteArr = getByteArrayFromUrl(pdbCode);
- // Now return the gzip deflated and deserialized byte array
- MessagePackSerialization mmtfBeanSeDeMessagePackImpl = new MessagePackSerialization();
- return mmtfBeanSeDeMessagePackImpl.deserialize(new ByteArrayInputStream(deflateGzip(byteArr)));
- }
-
- /**
- * Get the GZIP compressed and messagepack serialized data from the MMTF servers
- * @param pdbCode the PDB code for the data required
- * @return the byte array (GZIP compressed) of the data from the URL
- * @throws IOException an error reading the URL
- */
- public static byte[] getByteArrayFromUrl(String pdbCode) throws IOException {
- ByteArrayOutputStream baos = new ByteArrayOutputStream();
- InputStream inputStream = null;
- URL url = new URL(getUrl(pdbCode));
- try {
- inputStream = url.openStream();
- byte[] byteChunk = new byte[BYTE_BUFFER_CHUNK_SIZE]; // Or whatever size you want to read in at a time.
- int n;
- while ( (n = inputStream.read(byteChunk)) > 0 ) {
- baos.write(byteChunk, 0, n);
- }
- } finally {
- if (inputStream != null) { inputStream.close(); }
- }
- return baos.toByteArray();
- }
-
- /**
- * Deflate a gzip byte array.
- * @param inputBytes a gzip compressed byte array
- * @return a deflated byte array
- * @throws IOException error in gzip input stream
- */
- public static byte[] deflateGzip(byte[] inputBytes) throws IOException {
- // Start the byte input stream
- ByteArrayInputStream byteInputStream = new ByteArrayInputStream(inputBytes);
- GZIPInputStream gzipInputStream;
- ByteArrayOutputStream byteArrayOutputStream = null;
- try {
- gzipInputStream = new GZIPInputStream(byteInputStream);
-
- byteArrayOutputStream = new ByteArrayOutputStream();
- // Make a buffer
- byte[] buffer = new byte[BYTE_BUFFER_CHUNK_SIZE];
-
- while (gzipInputStream.available() == 1) {
- int size = gzipInputStream.read(buffer);
- if(size==-1){
- break;
- }
- byteArrayOutputStream.write(buffer, 0, size);
- }
-
- } finally {
- if (byteArrayOutputStream != null) {
- byteArrayOutputStream.close();
- }
- }
- return byteArrayOutputStream.toByteArray();
- }
-
- /**
- * A function to get MMTF data from a file path.
- * @param filePath the full path of the file to be read
- * @return the deserialized {@link MmtfStructure}
- * @throws IOException an error reading the file
- */
- public static MmtfStructure getDataFromFile(Path filePath) throws IOException {
-
- return getDataFromInputStream(Files.newInputStream(filePath));
- }
-
- /**
- * Read an input stream to an {@link MmtfStructure} object.
- * @param inStream the {@link InputStream} to read.
- * @return the {@link MmtfStructure} to be returned
- */
- public static MmtfStructure getDataFromInputStream(InputStream inStream) {
- MessagePackSerialization mmtfBeanSeDeMessagePackImpl = new MessagePackSerialization();
- return mmtfBeanSeDeMessagePackImpl.deserialize(inStream);
-
- }
-
- /**
- * Get the URL to return a given PDB id
- * @param pdbId the input PDB id
- * @return the URL {@link String} to get data from
- */
- public static String getUrl(String pdbId) {
- return CodecUtils.BASE_URL + pdbId;
- }
-}
+package org.rcsb.mmtf.decoder;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.text.ParseException;
+import java.util.zip.GZIPInputStream;
+
+import org.rcsb.mmtf.dataholders.MmtfStructure;
+import org.rcsb.mmtf.serialization.MessagePackSerialization;
+import org.rcsb.mmtf.utils.CodecUtils;
+
+/**
+ * A class of static utility methods for reading data.
+ *
+ * @author Anthony Bradley
+ *
+ */
+public class ReaderUtils {
+
+ /**
+ * The size of a chunk for a byte buffer.
+ */
+ private static final int BYTE_BUFFER_CHUNK_SIZE = 4096;
+
+ /**
+ * Find the message pack byte array from the web using the input code and a base url. Caches the
+ * file if possible.
+ *
+ * @param pdbCode the pdb code for the desired structure.
+ * @return the MMTFBean of the deserialized data
+ * @throws java.text.ParseException if MessagePack cannot be parsed
+ * @throws IOException if the data cannot be read from the URL
+ */
+ public static MmtfStructure getDataFromUrl(String pdbCode)
+ throws ParseException, IOException {
+ // Get these as an inputstream
+ byte[] bytes = getByteArrayFromUrl(pdbCode);
+ // Now return the gzip deflated and deserialized byte array
+ MessagePackSerialization mmtfBeanSeDeMessagePackImpl
+ = new MessagePackSerialization();
+ return mmtfBeanSeDeMessagePackImpl.deserialize(new ByteArrayInputStream(
+ deflateGzip(bytes)));
+ }
+
+ /**
+ * Get the GZIP compressed and messagepack serialized data from the MMTF servers
+ *
+ * @param pdbCode the PDB code for the data required
+ * @return the byte array (GZIP compressed) of the data from the URL
+ * @throws IOException an error reading the URL
+ */
+ public static byte[] getByteArrayFromUrl(String pdbCode)
+ throws IOException {
+ URL url = new URL(getUrl(pdbCode));
+ try (InputStream inputStream = url.openStream();
+ ByteArrayOutputStream baos = new ByteArrayOutputStream();) {
+ byte[] byteChunk = new byte[BYTE_BUFFER_CHUNK_SIZE];
+ // Or whatever size you want to read in at a time.
+ int n;
+ while ((n = inputStream.read(byteChunk)) > 0) {
+ baos.write(byteChunk, 0, n);
+ }
+ return baos.toByteArray();
+ }
+ }
+
+ /**
+ * Deflate a gzip byte array.
+ *
+ * @param inputBytes a gzip compressed byte array
+ * @return a deflated byte array
+ * @throws IOException error in gzip input stream
+ */
+ public static byte[] deflateGzip(byte[] inputBytes) throws IOException {
+ ByteArrayOutputStream byteArrayOutputStream
+ = new ByteArrayOutputStream();
+ try (GZIPInputStream gzipInputStream = new GZIPInputStream(
+ new ByteArrayInputStream(inputBytes))) {
+ byte[] buffer = new byte[BYTE_BUFFER_CHUNK_SIZE];
+ while (gzipInputStream.available() == 1) {
+ int size = gzipInputStream.read(buffer);
+ if (size == -1) {
+ break;
+ }
+ byteArrayOutputStream.write(buffer, 0, size);
+ }
+ return byteArrayOutputStream.toByteArray();
+ }
+ }
+
+ /**
+ * A function to get MMTF data from a file path.
+ *
+ * @param filePath the full path of the file to be read
+ * @return the deserialized {@link MmtfStructure}
+ * @throws IOException an error reading the file
+ * @throws java.text.ParseException if MessagePack cannot be parsed
+ */
+ public static MmtfStructure getDataFromFile(Path filePath)
+ throws IOException, ParseException {
+ // Now return the gzip deflated and deserialized byte array
+ try (InputStream is = new ByteArrayInputStream(readFile(filePath))) {
+ return getDataFromInputStream(is);
+ }
+ }
+
+ /**
+ * Read a byte array from a file
+ *
+ * @param path the input file path
+ * @return the returned byte array
+ * @throws IOException an error reading the file
+ */
+ private static byte[] readFile(Path path) throws IOException {
+ byte[] data = Files.readAllBytes(path);
+ return data;
+ }
+
+ /**
+ * Read an input stream to an {@link MmtfStructure} object.
+ *
+ * @param inStream the {@link InputStream} to read.
+ * @return the {@link MmtfStructure} to be returned
+ * @throws java.text.ParseException if MessagePack cannot be parsed
+ * @throws java.io.IOException if the inStream cannot be read
+ */
+ public static MmtfStructure getDataFromInputStream(InputStream inStream)
+ throws ParseException, IOException {
+ MessagePackSerialization mmtfBeanSeDeMessagePackImpl
+ = new MessagePackSerialization();
+ return mmtfBeanSeDeMessagePackImpl.deserialize(inStream);
+ }
+
+ /**
+ * Get the URL to return a given PDB id
+ *
+ * @param pdbId the input PDB id
+ * @return the URL {@link String} to get data from
+ */
+ public static String getUrl(String pdbId) {
+ return CodecUtils.BASE_URL + pdbId;
+ }
+}
diff --git a/mmtf-codec/src/test/java/org/rcsb/mmtf/codec/TestRoundTrip.java b/mmtf-codec/src/test/java/org/rcsb/mmtf/codec/TestRoundTrip.java
index 6ba12b9..c520b33 100644
--- a/mmtf-codec/src/test/java/org/rcsb/mmtf/codec/TestRoundTrip.java
+++ b/mmtf-codec/src/test/java/org/rcsb/mmtf/codec/TestRoundTrip.java
@@ -1,66 +1,65 @@
-package org.rcsb.mmtf.codec;
-
-import static org.junit.Assert.assertArrayEquals;
-
-import java.io.IOException;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-import org.junit.Test;
-import org.rcsb.mmtf.api.StructureDataInterface;
-import org.rcsb.mmtf.dataholders.MmtfStructure;
-import org.rcsb.mmtf.decoder.GenericDecoder;
-import org.rcsb.mmtf.decoder.ReaderUtils;
-
-/**
- * Basic integration tests of the codec suite.
- * @author Anthony Bradley
- *
- */
-public class TestRoundTrip {
-
- /**
- * Test that a simple roundtripping works - using GenericEncoder and GenericDecoder
- * @throws IOException error reading the file from the resource
- */
- @Test
- public void testGenericGeneric() throws IOException {
- Utils.compare(getDefaultFullData());
- }
-
- /**
- * Test that roundtripping on the recursive index code works.
- */
- @Test
- public void testRecursvieRoundTrip() {
- int[] inputArr = new int[] {1,1203,Short.MAX_VALUE, 1202, Short.MIN_VALUE};
- int[] outputArr = ArrayConverters.recursiveIndexDecode(ArrayConverters.recursiveIndexEncode(inputArr));
- assertArrayEquals(inputArr, outputArr);
- }
-
- /**
- * Test that round tripping how it is currently done works as expected.
- */
- @Test
- public void testArrayRoundTrip() {
- String[] inputStrings = new String[] {"1.3554545","2.9999999","3.939393"};
- float[] inArray = new float[inputStrings.length];
- for(int i=0; i bioAssemblyData = new ArrayList<>();
- BioAssemblyData bioAssemblyOne = new BioAssemblyData("1");
- bioAssemblyData.add(bioAssemblyOne);
- List bioAssemblyOneTransforms = new ArrayList<>();
- BioAssemblyTransformation bioassOneTransOne = new BioAssemblyTransformation();
- bioassOneTransOne.setChainIndexList(new int[]{1,2,3,4});
- bioassOneTransOne.setMatrix(new double[]{1.0,2.0,3.0,4.0});
- bioAssemblyOneTransforms.add(bioassOneTransOne);
- BioAssemblyTransformation bioassOneTransTwo = new BioAssemblyTransformation();
- bioassOneTransTwo.setChainIndexList(new int[]{5,7,11});
- bioassOneTransTwo.setMatrix(new double[]{5.0,2.0,8.0,4.0});
- bioAssemblyOneTransforms.add(bioassOneTransTwo);
- bioAssemblyOne.setTransformList(bioAssemblyOneTransforms);
- AdapterToStructureData adapterToStructureData = new AdapterToStructureData();
- adapterToStructureData.initStructure(0,0,0,0,0,"DUMMY");
- for (int i=0; i< bioAssemblyData.size(); i++){
- for (int j=0; j< bioAssemblyData.get(i).getTransformList().size();j++)
- adapterToStructureData.setBioAssemblyTrans(i,
- bioAssemblyData.get(i).getTransformList().get(j).getChainIndexList(),
- bioAssemblyData.get(i).getTransformList().get(j).getMatrix(),
- bioAssemblyData.get(i).getName());
- }
- List generateBioass = EncoderUtils.generateBioassemblies(adapterToStructureData);
- assertEquals(bioAssemblyData.get(0).getName(), generateBioass.get(0).getName());
- assertArrayEquals(bioAssemblyData.get(0).getTransformList().get(0).getChainIndexList(),
- generateBioass.get(0).getTransformList().get(0).getChainIndexList());
- assertArrayEquals(bioAssemblyData.get(0).getTransformList().get(0).getMatrix(),
- generateBioass.get(0).getTransformList().get(0).getMatrix(),0.0);
- }
-
- /**
- * Test that the entity type can be retrieved from a chain index
- */
- @Test
- public void testGetEntityType() {
- StructureDataInterface structureDataInterface = getDefaultFullData();
- assertEquals(EncoderUtils.getTypeFromChainId(structureDataInterface, 0),"polymer");
- assertEquals(EncoderUtils.getTypeFromChainId(structureDataInterface, 1),"non-polymer");
- assertEquals(EncoderUtils.getTypeFromChainId(structureDataInterface, 2),"non-polymer");
- assertEquals(EncoderUtils.getTypeFromChainId(structureDataInterface, 3),"non-polymer");
- assertEquals(EncoderUtils.getTypeFromChainId(structureDataInterface, 4),"non-polymer");
- assertEquals(EncoderUtils.getTypeFromChainId(structureDataInterface, 5),"water");
- }
-
- /**
- * Test that the entityList can be generated correctly.
- */
- @Test
- public void testGenerateEntityList() {
- StructureDataInterface structureDataInterface = getDefaultFullData();
- Entity[] entities = EncoderUtils.generateEntityList(structureDataInterface);
- assertEquals(entities.length, 4);
- assertArrayEquals(entities[0].getChainIndexList(), new int[] {0});
- assertArrayEquals(entities[1].getChainIndexList(), new int[] {1});
- assertArrayEquals(entities[2].getChainIndexList(), new int[] {2,3,4});
- assertArrayEquals(entities[3].getChainIndexList(), new int[] {5});
-
- assertEquals(entities[0].getDescription(),"BROMODOMAIN ADJACENT TO ZINC FINGER DOMAIN PROTEIN 2B");
- assertEquals(entities[1].getDescription(),"4-FLUOROBENZAMIDOXIME");
- assertEquals(entities[2].getDescription(),"METHANOL");
- assertEquals(entities[3].getDescription(),"water");
-
-
- assertEquals(entities[0].getSequence(),"SMSVKKPKRDDSKDLALCSMILTEMETHEDAWPFLLPVNLKLVPGYKKVIKKPMDFSTIREKLSSGQYPNLETFALDVRLVFDNCETFNEDDSDIGRAGHNMRKYFEKKWTDTFKVS");
- assertEquals(entities[1].getSequence(),"");
- assertEquals(entities[2].getSequence(),"");
- assertEquals(entities[3].getSequence(),"");
-
- assertEquals(entities[0].getType(),"polymer");
- assertEquals(entities[1].getType(),"non-polymer");
- assertEquals(entities[2].getType(),"non-polymer");
- assertEquals(entities[3].getType(),"water");
-
- }
-
- /**
- * Test that the groupList can be generated correctly
- */
- @Test
- public void testGenerateGroupMap() {
- StructureDataInterface structureDataInterface = getDefaultFullData();
- Group[] groupList = EncoderUtils.generateGroupList(structureDataInterface);
- assertEquals(groupList.length, 29);
- }
-
- /**
- * Get the default data for the full format.
- * @return a {@link StructureDataInterface} for the full data.
- */
- private StructureDataInterface getDefaultFullData() {
- ClassLoader classLoader = getClass().getClassLoader();
- Path inFile = Paths.get(classLoader.getResource("mmtf/4cup.mmtf").getFile());
- try {
- return new GenericDecoder(ReaderUtils.getDataFromFile(inFile));
- } catch (IOException e) {
- e.printStackTrace();
- throw new RuntimeException();
- }
- }
-
- private void testOutput(byte[] encodeByteArr, int codecId) {
- assertArrayEquals(encodeByteArr, new OptionParser(codecId, 0, 0).getHeader());
- }
-}
+package org.rcsb.mmtf.encoder;
+
+import org.junit.Test;
+import static org.junit.Assert.*;
+
+import java.io.IOException;
+import java.nio.file.Path;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.rcsb.mmtf.api.StructureAdapterInterface;
+import org.rcsb.mmtf.api.StructureDataInterface;
+import org.rcsb.mmtf.codec.CharCodecs;
+import org.rcsb.mmtf.codec.FloatCodecs;
+import org.rcsb.mmtf.codec.IntCodecs;
+import org.rcsb.mmtf.codec.OptionParser;
+import org.rcsb.mmtf.codec.StringCodecs;
+import org.rcsb.mmtf.codec.Utils;
+import org.rcsb.mmtf.dataholders.BioAssemblyData;
+import org.rcsb.mmtf.dataholders.BioAssemblyTransformation;
+import org.rcsb.mmtf.dataholders.Entity;
+import org.rcsb.mmtf.dataholders.Group;
+import org.rcsb.mmtf.decoder.GenericDecoder;
+import org.rcsb.mmtf.decoder.ReaderUtils;
+
+/**
+ * Tests for the {@link EncoderUtils} class of static methods.
+ *
+ * @author Anthony Bradley
+ *
+ */
+public class TestEncoderUtils {
+
+ /**
+ * Test that all of the codecs can handle and empty input array.
+ */
+ @Test
+ public void testEmptyArrs() {
+
+ for (FloatCodecs inputCodec : FloatCodecs.values()) {
+ testOutput(EncoderUtils.encodeByteArr(inputCodec, new float[]{}, 0),
+ inputCodec.getCodecId());
+ }
+
+ for (CharCodecs inputCodec : CharCodecs.values()) {
+ testOutput(EncoderUtils.encodeByteArr(inputCodec, new char[]{}, 0),
+ inputCodec.getCodecId());
+ }
+
+ for (IntCodecs inputCodec : IntCodecs.values()) {
+ testOutput(EncoderUtils.encodeByteArr(inputCodec, new int[]{}, 0),
+ inputCodec.getCodecId());
+ }
+
+ for (StringCodecs inputCodec : StringCodecs.values()) {
+ testOutput(EncoderUtils.encodeByteArr(inputCodec, new String[]{}, 0),
+ inputCodec.getCodecId());
+ }
+ }
+
+ /**
+ * Test that Bioassemblies can be generated correctly form a
+ * {@link StructureDataInterface} to a {@link StructureAdapterInterface}
+ */
+ @Test
+ public void testGenerateBioassemblies() {
+ List bioAssemblyData = new ArrayList<>();
+ BioAssemblyData bioAssemblyOne = new BioAssemblyData("1");
+ bioAssemblyData.add(bioAssemblyOne);
+ List bioAssemblyOneTransforms = new ArrayList<>();
+ BioAssemblyTransformation bioassOneTransOne = new BioAssemblyTransformation();
+ bioassOneTransOne.setChainIndexList(new int[]{1, 2, 3, 4});
+ bioassOneTransOne.setMatrix(new double[]{1.0, 2.0, 3.0, 4.0});
+ bioAssemblyOneTransforms.add(bioassOneTransOne);
+ BioAssemblyTransformation bioassOneTransTwo = new BioAssemblyTransformation();
+ bioassOneTransTwo.setChainIndexList(new int[]{5, 7, 11});
+ bioassOneTransTwo.setMatrix(new double[]{5.0, 2.0, 8.0, 4.0});
+ bioAssemblyOneTransforms.add(bioassOneTransTwo);
+ bioAssemblyOne.setTransformList(bioAssemblyOneTransforms);
+ AdapterToStructureData adapterToStructureData = new AdapterToStructureData();
+ adapterToStructureData.initStructure(0, 0, 0, 0, 0, "DUMMY");
+ for (int i = 0; i < bioAssemblyData.size(); i++) {
+ for (int j = 0; j < bioAssemblyData.get(i).getTransformList().size(); j++) {
+ adapterToStructureData.setBioAssemblyTrans(i,
+ bioAssemblyData.get(i).getTransformList().get(j).getChainIndexList(),
+ bioAssemblyData.get(i).getTransformList().get(j).getMatrix(),
+ bioAssemblyData.get(i).getName());
+ }
+ }
+ List generateBioass = EncoderUtils.generateBioassemblies(adapterToStructureData);
+ assertEquals(bioAssemblyData.get(0).getName(), generateBioass.get(0).getName());
+ assertArrayEquals(bioAssemblyData.get(0).getTransformList().get(0).getChainIndexList(),
+ generateBioass.get(0).getTransformList().get(0).getChainIndexList());
+ assertArrayEquals(bioAssemblyData.get(0).getTransformList().get(0).getMatrix(),
+ generateBioass.get(0).getTransformList().get(0).getMatrix(), 0.0);
+ }
+
+ /**
+ * Test that the entity type can be retrieved from a chain index
+ * @throws java.io.IOException
+ */
+ @Test
+ public void testGetEntityType() throws IOException, ParseException {
+ StructureDataInterface structureDataInterface = getDefaultFullData();
+ assertEquals(EncoderUtils.getTypeFromChainId(structureDataInterface, 0), "polymer");
+ assertEquals(EncoderUtils.getTypeFromChainId(structureDataInterface, 1), "non-polymer");
+ assertEquals(EncoderUtils.getTypeFromChainId(structureDataInterface, 2), "non-polymer");
+ assertEquals(EncoderUtils.getTypeFromChainId(structureDataInterface, 3), "non-polymer");
+ assertEquals(EncoderUtils.getTypeFromChainId(structureDataInterface, 4), "non-polymer");
+ assertEquals(EncoderUtils.getTypeFromChainId(structureDataInterface, 5), "water");
+ }
+
+ /**
+ * Test that the entityList can be generated correctly.
+ * @throws java.io.IOException
+ */
+ @Test
+ public void testGenerateEntityList() throws IOException, ParseException {
+ StructureDataInterface structureDataInterface = getDefaultFullData();
+ Entity[] entities = EncoderUtils.generateEntityList(structureDataInterface);
+ assertEquals(entities.length, 4);
+ assertArrayEquals(entities[0].getChainIndexList(), new int[]{0});
+ assertArrayEquals(entities[1].getChainIndexList(), new int[]{1});
+ assertArrayEquals(entities[2].getChainIndexList(), new int[]{2, 3, 4});
+ assertArrayEquals(entities[3].getChainIndexList(), new int[]{5});
+
+ assertEquals(entities[0].getDescription(), "BROMODOMAIN ADJACENT TO ZINC FINGER DOMAIN PROTEIN 2B");
+ assertEquals(entities[1].getDescription(), "4-FLUOROBENZAMIDOXIME");
+ assertEquals(entities[2].getDescription(), "METHANOL");
+ assertEquals(entities[3].getDescription(), "water");
+
+ assertEquals(entities[0].getSequence(), "SMSVKKPKRDDSKDLALCSMILTEMETHEDAWPFLLPVNLKLVPGYKKVIKKPMDFSTIREKLSSGQYPNLETFALDVRLVFDNCETFNEDDSDIGRAGHNMRKYFEKKWTDTFKVS");
+ assertEquals(entities[1].getSequence(), "");
+ assertEquals(entities[2].getSequence(), "");
+ assertEquals(entities[3].getSequence(), "");
+
+ assertEquals(entities[0].getType(), "polymer");
+ assertEquals(entities[1].getType(), "non-polymer");
+ assertEquals(entities[2].getType(), "non-polymer");
+ assertEquals(entities[3].getType(), "water");
+
+ }
+
+ /**
+ * Test that the groupList can be generated correctly
+ * @throws java.io.IOException
+ */
+ @Test
+ public void testGenerateGroupMap() throws IOException, ParseException {
+ StructureDataInterface structureDataInterface = getDefaultFullData();
+ Group[] groupList = EncoderUtils.generateGroupList(structureDataInterface);
+ assertEquals(groupList.length, 29);
+ }
+
+ /**
+ * Get the default data for the full format.
+ *
+ * @return a {@link StructureDataInterface} for the full data.
+ */
+ private StructureDataInterface getDefaultFullData() throws IOException, ParseException {
+ Path inFile = Utils.getResource("/mmtf/4cup.mmtf");
+ return new GenericDecoder(ReaderUtils.getDataFromFile(inFile));
+ }
+
+ private void testOutput(byte[] encodeByteArr, int codecId) {
+ assertArrayEquals(encodeByteArr, new OptionParser(codecId, 0, 0).getHeader());
+ }
+}
diff --git a/mmtf-codec/src/test/java/org/rcsb/mmtf/encoder/TestReducedEncoder.java b/mmtf-codec/src/test/java/org/rcsb/mmtf/encoder/TestReducedEncoder.java
index e40e849..0f100ac 100644
--- a/mmtf-codec/src/test/java/org/rcsb/mmtf/encoder/TestReducedEncoder.java
+++ b/mmtf-codec/src/test/java/org/rcsb/mmtf/encoder/TestReducedEncoder.java
@@ -1,118 +1,117 @@
-package org.rcsb.mmtf.encoder;
-
-import static org.junit.Assert.*;
-
-import java.beans.IntrospectionException;
-import java.beans.Introspector;
-import java.beans.PropertyDescriptor;
-import java.io.IOException;
-import java.lang.reflect.InvocationTargetException;
-import java.nio.file.Path;
-import java.nio.file.Paths;
-
-import org.junit.Test;
-import org.rcsb.mmtf.api.StructureDataInterface;
-import org.rcsb.mmtf.codec.Utils;
-import org.rcsb.mmtf.decoder.GenericDecoder;
-import org.rcsb.mmtf.decoder.ReaderUtils;
-
-/**
- * Class of tests for the Reduced encoder.
- * @author Anthony Bradley
- *
- */
-public class TestReducedEncoder {
-
-
- /**
- * Test that data can be reduced and read back in correctly.
- * @throws IOException error reading the file from the resource
- */
- @Test
- public void testReducedRoundTrip() throws IOException {
- StructureDataInterface structureDataInterface = ReducedEncoder.getReduced(getDefaultFullData());
- testStructDataInterface(structureDataInterface);
- Utils.compare(structureDataInterface);
- }
-
- /**
- * Test that data can be converted to reduced and certain core data stays the same.
- * @throws IOException error reading the file from the resource
- */
- @Test
- public void testReducedData() throws IOException {
- StructureDataInterface full = getDefaultFullData();
- StructureDataInterface reduced = ReducedEncoder.getReduced(full);
- // Check that the chain names are the same
- assertArrayEquals(full.getChainNames(), reduced.getChainNames());
- assertArrayEquals(full.getChainIds(), reduced.getChainIds());
- // Check that all non water groups are included
- assertEquals(removeWaters(full), reduced.getGroupTypeIndices().length);
- }
-
-
- private int removeWaters(StructureDataInterface structureDataInterface) {
- int outCounter = 0;
- for (int groupType : structureDataInterface.getGroupTypeIndices()){
- if(structureDataInterface.getGroupName(groupType).equals("HOH")){
- continue;
- }
- outCounter++;
- }
- return outCounter;
- }
-
- /**
- * Check that the data read in is not null.
- * @param structDataInterface
- */
- private void testStructDataInterface(StructureDataInterface structDataInterface) {
- try {
- for(PropertyDescriptor propertyDescriptor :
- Introspector.getBeanInfo(StructureDataInterface.class).getPropertyDescriptors()){
- if(propertyDescriptor.getReadMethod()!=null){
- if(propertyDescriptor.getReadMethod().invoke(structDataInterface).getClass().isArray()){
-
- }
- else{
- assertNotNull(propertyDescriptor.getReadMethod().invoke(structDataInterface));
- }
- }
- }
- } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
- | IntrospectionException e) {
- throw new RuntimeException();
- }
- // Now check the arrays
- assertNotNull(structDataInterface.getAtomIds());
- assertNotNull(structDataInterface.getxCoords());
- assertNotNull(structDataInterface.getyCoords());
- assertNotNull(structDataInterface.getzCoords());
- assertNotNull(structDataInterface.getbFactors());
- assertNotNull(structDataInterface.getOccupancies());
- assertNotNull(structDataInterface.getAltLocIds());
- assertNotNull(structDataInterface.getChainIds());
- assertNotNull(structDataInterface.getSecStructList());
- assertNotNull(structDataInterface.getChainNames());
- assertNotNull(structDataInterface.getExperimentalMethods());
- assertNotNull(structDataInterface.getGroupIds());
- assertNotNull(structDataInterface.getGroupSequenceIndices());
- assertNotNull(structDataInterface.getGroupsPerChain());
- assertNotNull(structDataInterface.getGroupTypeIndices());
- assertNotNull(structDataInterface.getInsCodes());
- assertNotNull(structDataInterface.getInterGroupBondIndices());
- assertNotNull(structDataInterface.getInterGroupBondOrders());
- }
-
-
- /**
- * Get the default data for the full format.
- * @return a {@link StructureDataInterface} for the full data.
- * @throws IOException
- */
- private StructureDataInterface getDefaultFullData() throws IOException {
- ClassLoader classLoader = getClass().getClassLoader();
- Path inFile = Paths.get(classLoader.getResource("mmtf/4cup.mmtf").getFile());
- return new GenericDecoder(ReaderUtils.getDataFromFile(inFile));
- }
-}
+package org.rcsb.mmtf.encoder;
+
+import static org.junit.Assert.*;
+
+import java.beans.IntrospectionException;
+import java.beans.Introspector;
+import java.beans.PropertyDescriptor;
+import java.io.IOException;
+import java.lang.reflect.InvocationTargetException;
+import java.nio.file.Path;
+import java.text.ParseException;
+
+import org.junit.Test;
+import org.rcsb.mmtf.api.StructureDataInterface;
+import org.rcsb.mmtf.codec.Utils;
+import org.rcsb.mmtf.decoder.GenericDecoder;
+import org.rcsb.mmtf.decoder.ReaderUtils;
+
+/**
+ * Class of tests for the Reduced encoder.
+ * @author Anthony Bradley
+ *
+ */
+public class TestReducedEncoder {
+
+
+ /**
+ * Test that data can be reduced and read back in correctly.
+ * @throws IOException error reading the file from the resource
+ */
+ @Test
+ public void testReducedRoundTrip() throws IOException, ParseException {
+ StructureDataInterface structureDataInterface = ReducedEncoder.getReduced(getDefaultFullData());
+ testStructDataInterface(structureDataInterface);
+ Utils.compare(structureDataInterface);
+ }
+
+ /**
+ * Test that data can be converted to reduced and certain core data stays the same.
+ * @throws IOException error reading the file from the resource
+ */
+ @Test
+ public void testReducedData() throws IOException, ParseException {
+ StructureDataInterface full = getDefaultFullData();
+ StructureDataInterface reduced = ReducedEncoder.getReduced(full);
+ // Check that the chain names are the same
+ assertArrayEquals(full.getChainNames(), reduced.getChainNames());
+ assertArrayEquals(full.getChainIds(), reduced.getChainIds());
+ // Check that all non water groups are included
+ assertEquals(removeWaters(full), reduced.getGroupTypeIndices().length);
+ }
+
+
+ private int removeWaters(StructureDataInterface structureDataInterface) {
+ int outCounter = 0;
+ for (int groupType : structureDataInterface.getGroupTypeIndices()){
+ if(structureDataInterface.getGroupName(groupType).equals("HOH")){
+ continue;
+ }
+ outCounter++;
+ }
+ return outCounter;
+ }
+
+ /**
+ * Check that the data read in is not null.
+ * @param structDataInterface
+ */
+ private void testStructDataInterface(StructureDataInterface structDataInterface) {
+ try {
+ for(PropertyDescriptor propertyDescriptor :
+ Introspector.getBeanInfo(StructureDataInterface.class).getPropertyDescriptors()){
+ if(propertyDescriptor.getReadMethod()!=null){
+ if(propertyDescriptor.getReadMethod().invoke(structDataInterface).getClass().isArray()){
+
+ }
+ else{
+ assertNotNull(propertyDescriptor.getReadMethod().invoke(structDataInterface));
+ }
+ }
+ }
+ } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException
+ | IntrospectionException e) {
+ throw new RuntimeException();
+ }
+ // Now check the arrays
+ assertNotNull(structDataInterface.getAtomIds());
+ assertNotNull(structDataInterface.getxCoords());
+ assertNotNull(structDataInterface.getyCoords());
+ assertNotNull(structDataInterface.getzCoords());
+ assertNotNull(structDataInterface.getbFactors());
+ assertNotNull(structDataInterface.getOccupancies());
+ assertNotNull(structDataInterface.getAltLocIds());
+ assertNotNull(structDataInterface.getChainIds());
+ assertNotNull(structDataInterface.getSecStructList());
+ assertNotNull(structDataInterface.getChainNames());
+ assertNotNull(structDataInterface.getExperimentalMethods());
+ assertNotNull(structDataInterface.getGroupIds());
+ assertNotNull(structDataInterface.getGroupSequenceIndices());
+ assertNotNull(structDataInterface.getGroupsPerChain());
+ assertNotNull(structDataInterface.getGroupTypeIndices());
+ assertNotNull(structDataInterface.getInsCodes());
+ assertNotNull(structDataInterface.getInterGroupBondIndices());
+ assertNotNull(structDataInterface.getInterGroupBondOrders());
+ }
+
+
+ /**
+ * Get the default data for the full format.
+ * @return a {@link StructureDataInterface} for the full data.
+ * @throws IOException
+ */
+ private StructureDataInterface getDefaultFullData() throws IOException, ParseException {
+ Path p = Utils.getResource("/mmtf/4cup.mmtf");
+ return new GenericDecoder(ReaderUtils.getDataFromFile(p));
+ }
+}
diff --git a/mmtf-codec/src/test/java/org/rcsb/mmtf/serialization/mp/MessagePackSerializationTest.java b/mmtf-codec/src/test/java/org/rcsb/mmtf/serialization/mp/MessagePackSerializationTest.java
new file mode 100644
index 0000000..ad6e5fd
--- /dev/null
+++ b/mmtf-codec/src/test/java/org/rcsb/mmtf/serialization/mp/MessagePackSerializationTest.java
@@ -0,0 +1,107 @@
+package org.rcsb.mmtf.serialization.mp;
+
+import org.rcsb.mmtf.utils.Lines;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URL;
+import java.text.ParseException;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.Random;
+
+import org.junit.Test;
+import org.rcsb.mmtf.api.StructureDataInterface;
+import org.rcsb.mmtf.dataholders.MmtfStructure;
+import org.rcsb.mmtf.decoder.GenericDecoder;
+import org.rcsb.mmtf.decoder.ReaderUtils;
+import org.rcsb.mmtf.serialization.MessagePackSerialization;
+
+import org.unitils.reflectionassert.ReflectionAssert;
+
+/**
+ * Tests if both MessagePack decoding methods, Jackson and the manual object
+ * creation gives identical data.
+ *
+ */
+public class MessagePackSerializationTest {
+
+ private final int n = 10; // how many structures should be tested
+ private final List testCodes;
+
+ public MessagePackSerializationTest() throws IOException {
+ testCodes = getTestCodes();
+ }
+
+ private List getTestCodes() throws IOException {
+ List result = new ArrayList<>();
+ Random random = new Random();
+ int seed = random.nextInt();
+ System.out.println("Using seed " + seed + " to select " + n + " random "
+ + "structures for MessagePack testing.");
+ random = new Random(seed);
+ List codes = getAllPdbCodes();
+ for (int i = 0; i < Math.min(n, codes.size()); i++) {
+ int r = random.nextInt(codes.size());
+ String code = codes.get(r);
+ codes.remove(r);
+ result.add(code);
+ }
+ return result;
+ }
+
+ public List getAllPdbCodes() throws IOException {
+ List codes = new ArrayList<>();
+ for (String line : Lines.readResource("/mmtf/pdb_codes.gz")) {
+ String code = line.trim().substring(0, 4);
+ codes.add(code);
+ }
+ return codes;
+ }
+
+ /**
+ * Decodes the MMTF from the MessagePack data.
+ */
+ private StructureDataInterface parse(byte[] bytes) throws IOException, ParseException {
+ MmtfStructure mmtf = ReaderUtils.getDataFromInputStream(
+ new ByteArrayInputStream(bytes));
+ GenericDecoder gd = new GenericDecoder(mmtf);
+ return gd;
+ }
+
+ private byte[] fetchMmtf(String code) throws IOException {
+ ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
+ String url = "http://mmtf.rcsb.org/v1.0/full/" + code + ".mmtf.gz";
+ try (InputStream is = new URL(url).openStream()) {
+ byte[] chunk = new byte[4096];
+ int bytesRead;
+ while ((bytesRead = is.read(chunk)) > 0) {
+ outputStream.write(chunk, 0, bytesRead);
+ }
+ }
+ return outputStream.toByteArray();
+ }
+
+ @Test
+ public void testByComparisonWithJackson() throws IOException {
+
+ for (String code : testCodes) {
+ try {
+ byte[] zipped = fetchMmtf(code);
+ byte[] bytes = ReaderUtils.deflateGzip(zipped);
+
+ MessagePackSerialization.setJackson(false);
+ StructureDataInterface sdiJmol = parse(bytes);
+
+ MessagePackSerialization.setJackson(true);
+ StructureDataInterface sdiJackson = parse(bytes);
+
+ ReflectionAssert.assertReflectionEquals(sdiJackson, sdiJmol);
+ } catch (Exception ex) {
+ throw new RuntimeException(code, ex);
+ }
+ }
+ }
+
+}
diff --git a/mmtf-serialization/pom.xml b/mmtf-serialization/pom.xml
index 58a04f3..b6081f5 100644
--- a/mmtf-serialization/pom.xml
+++ b/mmtf-serialization/pom.xml
@@ -1,296 +1,93 @@
-
- 4.0.0
-
- org.rcsb
- mmtf
- 1.0.4-SNAPSHOT
-
- mmtf-serialization
- jar
-
- mmtf-serialization
- http://maven.apache.org
-
-
- UTF-8
-
-
-
-
- org.msgpack
- jackson-dataformat-msgpack
- 0.7.1
-
-
- junit
- junit
-
-
- uk.co.jemos.podam
- podam
-
-
- org.unitils
- unitils-core
-
-
- commons-beanutils
- commons-beanutils
-
-
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
-
-
-
-
-
- org.apache.maven.plugins
- maven-compiler-plugin
-
-
- true
-
-
-
- pl.project13.maven
- git-commit-id-plugin
- 2.2.0
-
-
-
- revision
-
-
-
-
-
-
- ${project.basedir}/.git
-
-
- git
-
-
- dd.MM.yyyy '@' HH:mm:ss z
-
-
-
- ${user.timezone}
-
-
- false
-
-
-
-
-
- true
-
-
- ${project.build.outputDirectory}/git.properties
-
-
- properties
-
-
- true
-
-
-
- false
-
-
-
- true
-
-
-
- true
-
-
-
- false
-
-
-
- false
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- false
-
-
-
- 7
-
-
-
-
- flat
-
-
-
-
-
-
- false
-
-
- false
-
- 7
-
-
- -dirty
-
-
- *
-
-
- false
-
-
-
-
- true
-
-
- ${project.build.outputDirectory}/git.properties
-
-
-
-
-
-
-
-
-
-
-
-
- maven-javadoc-plugin
- 2.10.1
-
- true
- true
- true
-
- false
- true
-
-
-
- org.codehaus.mojo
- findbugs-maven-plugin
- 3.0.3
-
-
-
-
-
-
+
+ 4.0.0
+
+ org.rcsb
+ mmtf
+ 1.0.4-SNAPSHOT
+
+ mmtf-serialization
+ jar
+
+ mmtf-serialization
+ http://maven.apache.org
+
+
+ UTF-8
+
+
+
+
+ org.msgpack
+ jackson-dataformat-msgpack
+ 0.7.1
+
+
+ junit
+ junit
+
+
+ uk.co.jemos.podam
+ podam
+
+
+ commons-beanutils
+ commons-beanutils
+
+
+ ${project.groupId}
+ mmtf-api
+ ${project.version}
+
+
+ org.unitils
+ unitils-core
+ 3.4.2
+ test
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-compiler-plugin
+
+
+ true
+
+
+
+
+
+
+
+
+
+
+ maven-javadoc-plugin
+ 2.10.1
+
+ true
+ true
+ true
+
+ false
+ true
+
+
+
+ org.codehaus.mojo
+ findbugs-maven-plugin
+ 3.0.3
+
+
+
+
+
+
diff --git a/mmtf-serialization/src/main/java/org/rcsb/mmtf/dataholders/MmtfStructure.java b/mmtf-serialization/src/main/java/org/rcsb/mmtf/dataholders/MmtfStructure.java
index 1a89953..f3e7214 100644
--- a/mmtf-serialization/src/main/java/org/rcsb/mmtf/dataholders/MmtfStructure.java
+++ b/mmtf-serialization/src/main/java/org/rcsb/mmtf/dataholders/MmtfStructure.java
@@ -1,844 +1,844 @@
-package org.rcsb.mmtf.dataholders;
-
-import java.io.Serializable;
-import java.util.List;
-
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-
-/**
- * A class to store the data sent in an MMTF data source.
- *
- * @author Anthony Bradley
- */
-@JsonIgnoreProperties(ignoreUnknown = true)
-public class MmtfStructure implements Serializable {
-
- /** The number to divide coordinate int values by. */
- public static final int COORD_DIVIDER = 1000;
- /** The number to divide occupancy and bfactor int values by. */
- public static final int OCCUPANCY_BFACTOR_DIVIDER = 100;
- /** The default value for Rfree and Rwork */
- public static final float UNAVAILABLE_R_VALUE = 1.0f;
- /** The default value for resolution when not available or not applicable */
- public static final float UNAVAILABLE_RESOLUTION_VALUE = 99.0f;
- /** The default value for a missing or null string field */
- public static final char UNAVAILABLE_CHAR_VALUE = '\0';
- /** The number of characters in a chain.*/
- public static final int CHAIN_LENGTH = 4;
- /** The version of MMTF */
- public static final String VERSION = "1.0.0";
-
-
- /** Serial id for this version of the format. */
- private static final long serialVersionUID = 384559979573830324L;
-
- /** The mmtf version. */
- private String mmtfVersion;
-
- /** The mmtf producer. */
- private String mmtfProducer;
-
- /** The number of bonds. */
- private int numBonds;
-
- /** The number of atoms. */
- private int numAtoms;
-
- /** The number of groups. */
- private int numGroups;
-
- /** The number of chains. */
- private int numChains;
-
- /** The number of models. */
- private int numModels;
-
- /** The structure Id. Most commonly this will be the four character PDB id. */
- private String structureId;
-
- /** The title. */
- private String title;
-
- /** The number of chains per model. */
- private int[] chainsPerModel;
-
- /** The internal groups per chain. */
- private int[] groupsPerChain;
-
- /** The names of the chains. Each chain is allocated four bytes. Chain names can be up to four characters long. 0 bytes indicate the end of the chain name. These are taken from the auth id. */
- private byte[] chainNameList;
-
- /** The names of the chains. Each chain is allocated four bytes. Chain names can be up to four characters long. 0 bytes indicate the end of the chain name. These are taken from the asym id. */
- private byte[] chainIdList;
-
- /** The space group. */
- private String spaceGroup;
-
- /** The unit cell. */
- private float[] unitCell;
-
- /** The bio assembly. */
- private List bioAssemblyList;
-
- /** The bond atom (indices) list. */
- private byte[] bondAtomList;
-
- /** The bond order list. */
- private byte[] bondOrderList;
-
- /** The list of different PDBGroups in the structure. */
- private Group[] groupList;
-
- /** The encoded X coordinates. */
- private byte[] xCoordList;
-
- /** The encoded Y coordinates. */
- private byte[] yCoordList;
-
- /** The encoded Z coordinates. */
- private byte[] zCoordList;
-
- /** The encoded B-factors. */
- private byte[] bFactorList;
-
- /** The secondary structure list. Stored as 1 byte ints. */
- private byte[] secStructList;
-
- /** The occupancy list. */
- private byte[] occupancyList;
-
- /** The list of alternate location ids. */
- private byte[] altLocList;
-
- /** The insertion code list. */
- private byte[] insCodeList;
-
- /** The group type list. */
- private byte[] groupTypeList;
-
- /** The group id list. Identifies each group along the chain. */
- private byte[] groupIdList;
-
- /** The atom id list. */
- private byte[] atomIdList;
-
- /** The SeqRes group ids. */
- private byte[] sequenceIndexList;
-
- /** The experimental method(s). */
- private String[] experimentalMethods;
-
- /** The resolution in Angstrom. Null if not applicable*/
- private float resolution;
-
- /** The rfree. Null if not applicable */
- private float rFree;
-
- /** The r-work. Null if not applicable */
- private float rWork;
-
- /** The list of entities in this structure. */
- private Entity[] entityList;
-
- /** The deposition date of the structure in ISO time standard format. https://www.cl.cam.ac.uk/~mgk25/iso-time.html */
- private String depositionDate;
-
- /** The release data of the structure in ISO time standard format. https://www.cl.cam.ac.uk/~mgk25/iso-time.html */
- private String releaseDate;
-
- /** A float array for the NCS operator expression matrices, derived from the mmCIF file. */
- private double[][] ncsOperatorList;
-
- /** Constructor to set the default values for floats */
- public MmtfStructure() {
-
- /** The mmtf version. Set here. */
- mmtfVersion = MmtfStructure.VERSION;
-
- /** The mmtf producer. NA is default and for RCSB PDB data indicates an error. */
- mmtfProducer = "NA";
-
- /** The resolution in Angstrom. -1.0 if not applicable*/
- resolution = UNAVAILABLE_RESOLUTION_VALUE;
-
- /** The rfree. 1.0 if not applicable */
- rFree = UNAVAILABLE_R_VALUE;
-
- rWork = UNAVAILABLE_R_VALUE;
-
- /** The number of atoms. Default is -1 indicates error */
- numAtoms = -1;
-
- /** The number of bonds. Default of -1 indicates error*/
- numBonds = -1;
-
- }
-
- /**
- * @return the resolution
- */
- public Float getResolution() {
- if (resolution==UNAVAILABLE_RESOLUTION_VALUE) {
- return null;
- }
- return resolution;
- }
-
- /**
- * @param resolution the resolution to set
- */
- public void setResolution(float resolution) {
- if (resolution==0.0) {
- this.resolution = UNAVAILABLE_RESOLUTION_VALUE;
- }
- else{
- this.resolution = resolution;
- }
- }
-
- /**
- * @return the rFree
- */
- public Float getrFree() {
- if (rFree==UNAVAILABLE_R_VALUE) {
- return null;
- }
- return rFree;
- }
-
- /**
- * @param rFree the rFree to set
- */
- public void setrFree(float rFree) {
- if (rFree==0.0){
- this.rFree = UNAVAILABLE_R_VALUE;
- }
- else{
- this.rFree = rFree;
- }
- }
-
- /**
- * @return the rWork
- */
- public Float getrWork() {
- if (rWork==UNAVAILABLE_R_VALUE) {
- return null;
- }
- return rWork;
- }
-
- /**
- * @param rWork the rWork to set
- */
- public void setrWork(float rWork) {
- if (rWork==0.0){
- this.rWork = UNAVAILABLE_R_VALUE;
- }
- else{
- this.rWork = rWork;
- }
- }
-
-
- /**
- * Gets the space group.
- *
- * @return the space group
- */
- public String getSpaceGroup() {
- return spaceGroup;
- }
-
- /**
- * Sets the space group.
- *
- * @param inputSpaceGroup the new space group
- */
- public void setSpaceGroup(String inputSpaceGroup) {
- this.spaceGroup = inputSpaceGroup;
- }
-
- /**
- * Gets the unit cell.
- *
- * @return the unit cell
- */
- public float[] getUnitCell() {
- return unitCell;
- }
-
- /**
- * Sets the unit cell.
- *
- * @param inputUnitCell the new unit cell
- */
- public void setUnitCell(float[] inputUnitCell) {
- this.unitCell = inputUnitCell;
- }
-
- /**
- * Gets the group num list.
- *
- * @return the group num list
- */
- public byte[] getGroupIdList() {
- return groupIdList;
- }
-
- /**
- * Sets the group num list.
- *
- * @param inputGroupNumList the new group num list
- */
- public void setGroupIdList(byte[] inputGroupNumList) {
- this.groupIdList = inputGroupNumList;
- }
-
- /**
- * Gets the alternate location list.
- *
- * @return the alternate location list
- */
- public byte[] getAltLocList() {
- return altLocList;
- }
-
- /**
- * Sets the alt label list.
- *
- * @param inputAltLocList the new alternation location label list
- */
- public void setAltLocList(byte[] inputAltLocList) {
- this.altLocList = inputAltLocList;
- }
-
- /**
- * Gets the bio assembly.
- *
- * @return the bio assembly
- */
- public List getBioAssemblyList() {
- return bioAssemblyList;
- }
-
- /**
- * Gets the chain names. The byte array indicating the (up to four characters) name of the chain. This is taken from the auth id.
- *
- * @return the chain list
- */
- public byte[] getChainNameList() {
- return chainNameList;
- }
-
- /**
- * Sets the chain names. The byte array indicating the (up to four characters) name of the chain. This is taken from the auth id.
- *
- * @param inputChainList the new chain list
- */
- public void setChainNameList(byte[] inputChainList) {
- this.chainNameList = inputChainList;
- }
-
- /**
- * Sets the bioassembly information.
- *
- * @param inputBioAssembly the bio assembly
- */
- public void setBioAssemblyList(List inputBioAssembly) {
- this.bioAssemblyList = inputBioAssembly;
- }
-
- /**
- * Gets the num atoms.
- *
- * @return the num atoms
- */
- public int getNumAtoms() {
- return numAtoms;
- }
-
- /**
- * Sets the num atoms.
- *
- * @param inputNumAtoms the new num atoms
- */
- public void setNumAtoms(int inputNumAtoms) {
- this.numAtoms = inputNumAtoms;
- }
-
- /**
- * Gets the occupancy list - an encoded per atom list of occupancy values.
- *
- * @return the occupancy list - an encoded per atom list of occupancy values.
- */
- public byte[] getOccupancyList() {
- return occupancyList;
- }
-
- /**
- * Sets the occupancy list - an encoded per atom list of occupancy values.
- *
- * @param inputOccupancyList the occupancy list - an encoded per atom list of occupancy values.
- */
- public void setOccupancyList(byte[] inputOccupancyList) {
- this.occupancyList = inputOccupancyList;
- }
-
- /**
- * Gets the insertion code list.
- *
- * @return the insertion code list
- */
- public byte[] getInsCodeList() {
- return insCodeList;
- }
-
- /**
- * Sets the ins code list.
- *
- * @param inputInsertionCodeList the new insertion code list
- */
- public void setInsCodeList(byte[] inputInsertionCodeList) {
- this.insCodeList = inputInsertionCodeList;
- }
-
- /**
- * Gets the group map.
- *
- * @return the group map
- */
- public Group[] getGroupList() {
- return groupList;
- }
-
- /**
- * Sets the group map.
- *
- * @param inputGroupMap the group map
- */
- public void setGroupList(Group[] inputGroupMap) {
- this.groupList = inputGroupMap;
- }
-
- /**
- * Gets the sec struct list.
- *
- * @return the sec struct list
- */
- public byte[] getSecStructList() {
- return secStructList;
- }
-
- /**
- * Sets the sec struct list.
- *
- * @param secStruct the new sec struct list
- */
- public void setSecStructList(byte[] secStruct) {
- this.secStructList = secStruct;
- }
-
- /**
- * Gets the group type list.
- *
- * @return the group type list
- */
- public byte[] getGroupTypeList() {
- return groupTypeList;
- }
-
- /**
- * Sets the group type list.
- *
- * @param resOrder the new group type list
- */
- public void setGroupTypeList(byte[] resOrder) {
- this.groupTypeList = resOrder;
- }
-
- /**
- * Gets the atom id list.
- *
- * @return the atom id list
- */
- public byte[] getAtomIdList() {
- return atomIdList;
- }
-
- /**
- * Sets the atom id list.
- *
- * @param inputAtomIdList the new atom id list
- */
- public void setAtomIdList(byte[] inputAtomIdList) {
- this.atomIdList = inputAtomIdList;
- }
-
- /**
- * Gets the title.
- *
- * @return the title
- */
- public String getTitle() {
- return title;
- }
-
- /**
- * Sets the title.
- *
- * @param inputTitle the new title
- */
- public void setTitle(String inputTitle) {
- this.title = inputTitle;
- }
-
- /**
- * Gets the structure id. Should be used as a unique identifier of this structure.
- *
- * @return the the structure id a unique String id of this structure.
- */
- public String getStructureId() {
- return structureId;
- }
-
- /**
- * Sets the structure id. Should be used as a unique identifier of this structure.
- *
- * @param inputId a unique String id of this structure.
- */
- public void setStructureId(String inputId) {
- this.structureId = inputId;
- }
-
- /**
- * Gets the mmtf producer.
- *
- * @return the mmtf producer
- */
- public String getMmtfProducer() {
- return mmtfProducer;
- }
-
- /**
- * Sets the mmtf producer.
- *
- * @param inputMmtfProducer the new mmtf producer
- */
- public void setMmtfProducer(String inputMmtfProducer) {
- this.mmtfProducer = inputMmtfProducer;
- }
-
- /**
- * Gets the mmtf version.
- *
- * @return the mmtf version
- */
- public String getMmtfVersion() {
- return mmtfVersion;
- }
-
- /**
- * Sets the mmtf version.
- *
- * @param inputMmtfVersion the new mmtf version
- */
- public void setMmtfVersion(String inputMmtfVersion) {
- this.mmtfVersion = inputMmtfVersion;
- }
-
- /**
- * Gets the num bonds.
- *
- * @return the num bonds
- */
- public int getNumBonds() {
- return numBonds;
- }
-
- /**
- * Sets the number of bonds.
- *
- * @param inputNumBonds the new num bonds
- */
- public void setNumBonds(int inputNumBonds) {
- this.numBonds = inputNumBonds;
- }
-
- /**
- * Gets the bond atom list.
- *
- * @return the bond atom list
- */
- public byte[] getBondAtomList() {
- return bondAtomList;
- }
-
- /**
- * Sets the bond atom list.
- *
- * @param inputBondAtomList the new bond atom list
- */
- public void setBondAtomList(byte[] inputBondAtomList) {
- this.bondAtomList = inputBondAtomList;
- }
-
- /**
- * Gets the bond order list.
- *
- * @return the bond order list
- */
- public byte[] getBondOrderList() {
- return bondOrderList;
- }
-
- /**
- * Sets the bond order list.
- *
- * @param inputBondOrderList the new bond order list
- */
- public void setBondOrderList(byte[] inputBondOrderList) {
- this.bondOrderList = inputBondOrderList;
- }
-
- /**
- * Gets the number of chains per model. Chains are currently specified by asym (internal) chain ids.
- *
- * @return the list of chains per model.
- */
- public int[] getChainsPerModel() {
- return chainsPerModel;
- }
-
- /**
- * Sets the number of chains per model. Currently specified by asy (internal) chain ids.
- *
- * @param inputInternalChainsPerModel the new list of chains per model.
- */
- public void setChainsPerModel(int[]
- inputInternalChainsPerModel) {
- this.chainsPerModel = inputInternalChainsPerModel;
- }
-
- /**
- * Gets the number of groups per chain.
- *
- * @return the internal groups per chain
- */
- public int[] getGroupsPerChain() {
- return groupsPerChain;
- }
-
- /**
- * Sets the number of groups in a chain.
- *
- * @param inputGroupsPerChain the new internal groups per chain
- */
- public void setGroupsPerChain(int[]
- inputGroupsPerChain) {
- this.groupsPerChain = inputGroupsPerChain;
- }
-
- /**
- * Gets the internal chain list.
- *
- * @return the internal chain list
- */
- public byte[] getChainIdList() {
- return chainIdList;
- }
-
- /**
- * Sets the internal chain list.
- *
- * @param inputInternalChainList the new internal chain list
- */
- public void setChainIdList(byte[] inputInternalChainList) {
- this.chainIdList = inputInternalChainList;
- }
-
- /**
- * @return the experimental methods
- */
- public String[] getExperimentalMethods() {
- return experimentalMethods;
- }
-
- /**
- * @param experimentalMethods the experimental methods to set
- */
- public void setExperimentalMethods(String[] experimentalMethods) {
- this.experimentalMethods = experimentalMethods;
- }
-
- /**
- * @return the seqResGroupIds
- */
- public byte[] getSequenceIndexList() {
- return sequenceIndexList;
- }
-
- /**
- * @param seqResGroupIds the seqResGroupIds to set
- */
- public void setSequenceIndexList(byte[] seqResGroupIds) {
- this.sequenceIndexList = seqResGroupIds;
- }
-
- /**
- * Get the entity list.
- * @return the list of entities for this structure.
- */
- public Entity[] getEntityList() {
- return entityList;
- }
-
- /**
- * Set the entity list.
- * @param entityList the input list of entities.
- */
- public void setEntityList(Entity[] entityList) {
- this.entityList = entityList;
- }
-
- /**
- * @return the deposition date of the structure in ISO time standard.
- */
- public String getDepositionDate() {
- return depositionDate;
- }
-
- /**
- * @param depositionDate a string indicating the deposition date to set.
- */
- public void setDepositionDate(String depositionDate) {
- this.depositionDate = depositionDate;
- }
-
- /**
- * @return the release date of the structure in ISO time standard.
- */
- public String getReleaseDate() {
- return releaseDate;
- }
-
- /**
- * @param releaseDate a string indicating the deposition date to set.
- */
- public void setReleaseDate(String releaseDate) {
- this.releaseDate = releaseDate;
- }
-
- /**
- * @return the X coords as an encoded byte array.
- */
- public byte[] getxCoordList() {
- return xCoordList;
- }
-
- /**
- * @param xCoords the X coords as an encoded byte array.
- */
- public void setxCoordList(byte[] xCoords) {
- this.xCoordList = xCoords;
- }
-
- /**
- * @return the the Y coords as an encoded byte array.
- */
- public byte[] getyCoordList() {
- return yCoordList;
- }
-
- /**
- * @param yCoords the Y coords as an encoded byte array.
- */
- public void setyCoordList(byte[] yCoords) {
- this.yCoordList = yCoords;
- }
-
- /**
- * @return the Z coords as an encoded byte array.
- */
- public byte[] getzCoordList() {
- return zCoordList;
- }
-
- /**
- * @param zCoords the Z coords as an encoded byte array.
- */
- public void setzCoordList(byte[] zCoords) {
- this.zCoordList = zCoords;
- }
-
- /**
- * @return the atomic B-factors as an encoded byte array.
- */
- public byte[] getbFactorList() {
- return bFactorList;
- }
-
- /**
- * @param bFactors the atomic B-factors as an encoded byte array.
- */
- public void setbFactorList(byte[] bFactors) {
- this.bFactorList = bFactors;
- }
-
- /**
- * @return the number of groups in the structure
- */
- public int getNumGroups() {
- return numGroups;
- }
-
- /**
- * @param numGroups the number of groups in the structure
- */
- public void setNumGroups(int numGroups) {
- this.numGroups = numGroups;
- }
-
- /**
- * @return the number of chains in the structure
- */
- public int getNumChains() {
- return numChains;
- }
-
- /**
- * @param numChains the number of chains in the structure
- */
- public void setNumChains(int numChains) {
- this.numChains = numChains;
- }
-
- /**
- * @return the number of models in the structure
- */
- public int getNumModels() {
- return numModels;
- }
-
- /**
- * @param numModels the number of models in the structure
- */
- public void setNumModels(int numModels) {
- this.numModels = numModels;
- }
-
- /**
- * @return the ncsOperMatrixList
- */
- public double[][] getNcsOperatorList() {
- return ncsOperatorList;
- }
-
- /**
- * @param ncsOperatorList the ncsOperMatrixList to set
- */
- public void setNcsOperatorList(double[][] ncsOperatorList) {
- this.ncsOperatorList = ncsOperatorList;
- }
-
-}
+package org.rcsb.mmtf.dataholders;
+
+import java.io.Serializable;
+import java.util.List;
+
+import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
+
+/**
+ * A class to store the data sent in an MMTF data source.
+ *
+ * @author Anthony Bradley
+ */
+@JsonIgnoreProperties(ignoreUnknown = true)
+public class MmtfStructure implements Serializable {
+
+ /** The number to divide coordinate int values by. */
+ public static final int COORD_DIVIDER = 1000;
+ /** The number to divide occupancy and bfactor int values by. */
+ public static final int OCCUPANCY_BFACTOR_DIVIDER = 100;
+ /** The default value for Rfree and Rwork */
+ public static final float UNAVAILABLE_R_VALUE = 1.0f;
+ /** The default value for resolution when not available or not applicable */
+ public static final float UNAVAILABLE_RESOLUTION_VALUE = 99.0f;
+ /** The default value for a missing or null string field */
+ public static final char UNAVAILABLE_CHAR_VALUE = '\0';
+ /** The number of characters in a chain.*/
+ public static final int CHAIN_LENGTH = 4;
+ /** The version of MMTF */
+ public static final String VERSION = "1.0.0";
+
+
+ /** Serial id for this version of the format. */
+ private static final long serialVersionUID = 384559979573830324L;
+
+ /** The mmtf version. */
+ private String mmtfVersion;
+
+ /** The mmtf producer. */
+ private String mmtfProducer;
+
+ /** The number of bonds. */
+ private int numBonds;
+
+ /** The number of atoms. */
+ private int numAtoms;
+
+ /** The number of groups. */
+ private int numGroups;
+
+ /** The number of chains. */
+ private int numChains;
+
+ /** The number of models. */
+ private int numModels;
+
+ /** The structure Id. Most commonly this will be the four character PDB id. */
+ private String structureId;
+
+ /** The title. */
+ private String title;
+
+ /** The number of chains per model. */
+ private int[] chainsPerModel;
+
+ /** The internal groups per chain. */
+ private int[] groupsPerChain;
+
+ /** The names of the chains. Each chain is allocated four bytes. Chain names can be up to four characters long. 0 bytes indicate the end of the chain name. These are taken from the auth id. */
+ private byte[] chainNameList;
+
+ /** The names of the chains. Each chain is allocated four bytes. Chain names can be up to four characters long. 0 bytes indicate the end of the chain name. These are taken from the asym id. */
+ private byte[] chainIdList;
+
+ /** The space group. */
+ private String spaceGroup;
+
+ /** The unit cell. */
+ private float[] unitCell;
+
+ /** The bio assembly. */
+ private List bioAssemblyList;
+
+ /** The bond atom (indices) list. */
+ private byte[] bondAtomList;
+
+ /** The bond order list. */
+ private byte[] bondOrderList;
+
+ /** The list of different PDBGroups in the structure. */
+ private Group[] groupList;
+
+ /** The encoded X coordinates. */
+ private byte[] xCoordList;
+
+ /** The encoded Y coordinates. */
+ private byte[] yCoordList;
+
+ /** The encoded Z coordinates. */
+ private byte[] zCoordList;
+
+ /** The encoded B-factors. */
+ private byte[] bFactorList;
+
+ /** The secondary structure list. Stored as 1 byte ints. */
+ private byte[] secStructList;
+
+ /** The occupancy list. */
+ private byte[] occupancyList;
+
+ /** The list of alternate location ids. */
+ private byte[] altLocList;
+
+ /** The insertion code list. */
+ private byte[] insCodeList;
+
+ /** The group type list. */
+ private byte[] groupTypeList;
+
+ /** The group id list. Identifies each group along the chain. */
+ private byte[] groupIdList;
+
+ /** The atom id list. */
+ private byte[] atomIdList;
+
+ /** The SeqRes group ids. */
+ private byte[] sequenceIndexList;
+
+ /** The experimental method(s). */
+ private String[] experimentalMethods;
+
+ /** The resolution in Angstrom. Null if not applicable*/
+ private float resolution;
+
+ /** The rfree. Null if not applicable */
+ private float rFree;
+
+ /** The r-work. Null if not applicable */
+ private float rWork;
+
+ /** The list of entities in this structure. */
+ private Entity[] entityList;
+
+ /** The deposition date of the structure in ISO time standard format. https://www.cl.cam.ac.uk/~mgk25/iso-time.html */
+ private String depositionDate;
+
+ /** The release data of the structure in ISO time standard format. https://www.cl.cam.ac.uk/~mgk25/iso-time.html */
+ private String releaseDate;
+
+ /** A float array for the NCS operator expression matrices, derived from the mmCIF file. */
+ private double[][] ncsOperatorList;
+
+ /** Constructor to set the default values for floats */
+ public MmtfStructure() {
+
+ /** The mmtf version. Set here. */
+ mmtfVersion = MmtfStructure.VERSION;
+
+ /** The mmtf producer. NA is default and for RCSB PDB data indicates an error. */
+ mmtfProducer = "NA";
+
+ /** The resolution in Angstrom. -1.0 if not applicable*/
+ resolution = UNAVAILABLE_RESOLUTION_VALUE;
+
+ /** The rfree. 1.0 if not applicable */
+ rFree = UNAVAILABLE_R_VALUE;
+
+ rWork = UNAVAILABLE_R_VALUE;
+
+ /** The number of atoms. Default is -1 indicates error */
+ numAtoms = -1;
+
+ /** The number of bonds. Default of -1 indicates error*/
+ numBonds = -1;
+
+ }
+
+ /**
+ * @return the resolution
+ */
+ public Float getResolution() {
+ if (resolution==UNAVAILABLE_RESOLUTION_VALUE) {
+ return null;
+ }
+ return resolution;
+ }
+
+ /**
+ * @param resolution the resolution to set
+ */
+ public void setResolution(float resolution) {
+ if (resolution==0.0) {
+ this.resolution = UNAVAILABLE_RESOLUTION_VALUE;
+ }
+ else{
+ this.resolution = resolution;
+ }
+ }
+
+ /**
+ * @return the rFree
+ */
+ public Float getrFree() {
+ if (rFree==UNAVAILABLE_R_VALUE) {
+ return null;
+ }
+ return rFree;
+ }
+
+ /**
+ * @param rFree the rFree to set
+ */
+ public void setrFree(float rFree) {
+ if (rFree==0.0){
+ this.rFree = UNAVAILABLE_R_VALUE;
+ }
+ else{
+ this.rFree = rFree;
+ }
+ }
+
+ /**
+ * @return the rWork
+ */
+ public Float getrWork() {
+ if (rWork==UNAVAILABLE_R_VALUE) {
+ return null;
+ }
+ return rWork;
+ }
+
+ /**
+ * @param rWork the rWork to set
+ */
+ public void setrWork(float rWork) {
+ if (rWork==0.0){
+ this.rWork = UNAVAILABLE_R_VALUE;
+ }
+ else{
+ this.rWork = rWork;
+ }
+ }
+
+
+ /**
+ * Gets the space group.
+ *
+ * @return the space group
+ */
+ public String getSpaceGroup() {
+ return spaceGroup;
+ }
+
+ /**
+ * Sets the space group.
+ *
+ * @param inputSpaceGroup the new space group
+ */
+ public void setSpaceGroup(String inputSpaceGroup) {
+ this.spaceGroup = inputSpaceGroup;
+ }
+
+ /**
+ * Gets the unit cell.
+ *
+ * @return the unit cell
+ */
+ public float[] getUnitCell() {
+ return unitCell;
+ }
+
+ /**
+ * Sets the unit cell.
+ *
+ * @param inputUnitCell the new unit cell
+ */
+ public void setUnitCell(float[] inputUnitCell) {
+ this.unitCell = inputUnitCell;
+ }
+
+ /**
+ * Gets the group num list.
+ *
+ * @return the group num list
+ */
+ public byte[] getGroupIdList() {
+ return groupIdList;
+ }
+
+ /**
+ * Sets the group num list.
+ *
+ * @param inputGroupNumList the new group num list
+ */
+ public void setGroupIdList(byte[] inputGroupNumList) {
+ this.groupIdList = inputGroupNumList;
+ }
+
+ /**
+ * Gets the alternate location list.
+ *
+ * @return the alternate location list
+ */
+ public byte[] getAltLocList() {
+ return altLocList;
+ }
+
+ /**
+ * Sets the alt label list.
+ *
+ * @param inputAltLocList the new alternation location label list
+ */
+ public void setAltLocList(byte[] inputAltLocList) {
+ this.altLocList = inputAltLocList;
+ }
+
+ /**
+ * Gets the bio assembly.
+ *
+ * @return the bio assembly
+ */
+ public List getBioAssemblyList() {
+ return bioAssemblyList;
+ }
+
+ /**
+ * Gets the chain names. The byte array indicating the (up to four characters) name of the chain. This is taken from the auth id.
+ *
+ * @return the chain list
+ */
+ public byte[] getChainNameList() {
+ return chainNameList;
+ }
+
+ /**
+ * Sets the chain names. The byte array indicating the (up to four characters) name of the chain. This is taken from the auth id.
+ *
+ * @param inputChainList the new chain list
+ */
+ public void setChainNameList(byte[] inputChainList) {
+ this.chainNameList = inputChainList;
+ }
+
+ /**
+ * Sets the bioassembly information.
+ *
+ * @param inputBioAssembly the bio assembly
+ */
+ public void setBioAssemblyList(List inputBioAssembly) {
+ this.bioAssemblyList = inputBioAssembly;
+ }
+
+ /**
+ * Gets the num atoms.
+ *
+ * @return the num atoms
+ */
+ public int getNumAtoms() {
+ return numAtoms;
+ }
+
+ /**
+ * Sets the num atoms.
+ *
+ * @param inputNumAtoms the new num atoms
+ */
+ public void setNumAtoms(int inputNumAtoms) {
+ this.numAtoms = inputNumAtoms;
+ }
+
+ /**
+ * Gets the occupancy list - an encoded per atom list of occupancy values.
+ *
+ * @return the occupancy list - an encoded per atom list of occupancy values.
+ */
+ public byte[] getOccupancyList() {
+ return occupancyList;
+ }
+
+ /**
+ * Sets the occupancy list - an encoded per atom list of occupancy values.
+ *
+ * @param inputOccupancyList the occupancy list - an encoded per atom list of occupancy values.
+ */
+ public void setOccupancyList(byte[] inputOccupancyList) {
+ this.occupancyList = inputOccupancyList;
+ }
+
+ /**
+ * Gets the insertion code list.
+ *
+ * @return the insertion code list
+ */
+ public byte[] getInsCodeList() {
+ return insCodeList;
+ }
+
+ /**
+ * Sets the ins code list.
+ *
+ * @param inputInsertionCodeList the new insertion code list
+ */
+ public void setInsCodeList(byte[] inputInsertionCodeList) {
+ this.insCodeList = inputInsertionCodeList;
+ }
+
+ /**
+ * Gets the group map.
+ *
+ * @return the group map
+ */
+ public Group[] getGroupList() {
+ return groupList;
+ }
+
+ /**
+ * Sets the group map.
+ *
+ * @param inputGroupMap the group map
+ */
+ public void setGroupList(Group[] inputGroupMap) {
+ this.groupList = inputGroupMap;
+ }
+
+ /**
+ * Gets the sec struct list.
+ *
+ * @return the sec struct list
+ */
+ public byte[] getSecStructList() {
+ return secStructList;
+ }
+
+ /**
+ * Sets the sec struct list.
+ *
+ * @param secStruct the new sec struct list
+ */
+ public void setSecStructList(byte[] secStruct) {
+ this.secStructList = secStruct;
+ }
+
+ /**
+ * Gets the group type list.
+ *
+ * @return the group type list
+ */
+ public byte[] getGroupTypeList() {
+ return groupTypeList;
+ }
+
+ /**
+ * Sets the group type list.
+ *
+ * @param resOrder the new group type list
+ */
+ public void setGroupTypeList(byte[] resOrder) {
+ this.groupTypeList = resOrder;
+ }
+
+ /**
+ * Gets the atom id list.
+ *
+ * @return the atom id list
+ */
+ public byte[] getAtomIdList() {
+ return atomIdList;
+ }
+
+ /**
+ * Sets the atom id list.
+ *
+ * @param inputAtomIdList the new atom id list
+ */
+ public void setAtomIdList(byte[] inputAtomIdList) {
+ this.atomIdList = inputAtomIdList;
+ }
+
+ /**
+ * Gets the title.
+ *
+ * @return the title
+ */
+ public String getTitle() {
+ return title;
+ }
+
+ /**
+ * Sets the title.
+ *
+ * @param inputTitle the new title
+ */
+ public void setTitle(String inputTitle) {
+ this.title = inputTitle;
+ }
+
+ /**
+ * Gets the structure id. Should be used as a unique identifier of this structure.
+ *
+ * @return the the structure id a unique String id of this structure.
+ */
+ public String getStructureId() {
+ return structureId;
+ }
+
+ /**
+ * Sets the structure id. Should be used as a unique identifier of this structure.
+ *
+ * @param inputId a unique String id of this structure.
+ */
+ public void setStructureId(String inputId) {
+ this.structureId = inputId;
+ }
+
+ /**
+ * Gets the mmtf producer.
+ *
+ * @return the mmtf producer
+ */
+ public String getMmtfProducer() {
+ return mmtfProducer;
+ }
+
+ /**
+ * Sets the mmtf producer.
+ *
+ * @param inputMmtfProducer the new mmtf producer
+ */
+ public void setMmtfProducer(String inputMmtfProducer) {
+ this.mmtfProducer = inputMmtfProducer;
+ }
+
+ /**
+ * Gets the mmtf version.
+ *
+ * @return the mmtf version
+ */
+ public String getMmtfVersion() {
+ return mmtfVersion;
+ }
+
+ /**
+ * Sets the mmtf version.
+ *
+ * @param inputMmtfVersion the new mmtf version
+ */
+ public void setMmtfVersion(String inputMmtfVersion) {
+ this.mmtfVersion = inputMmtfVersion;
+ }
+
+ /**
+ * Gets the num bonds.
+ *
+ * @return the num bonds
+ */
+ public int getNumBonds() {
+ return numBonds;
+ }
+
+ /**
+ * Sets the number of bonds.
+ *
+ * @param inputNumBonds the new num bonds
+ */
+ public void setNumBonds(int inputNumBonds) {
+ this.numBonds = inputNumBonds;
+ }
+
+ /**
+ * Gets the bond atom list.
+ *
+ * @return the bond atom list
+ */
+ public byte[] getBondAtomList() {
+ return bondAtomList;
+ }
+
+ /**
+ * Sets the bond atom list.
+ *
+ * @param inputBondAtomList the new bond atom list
+ */
+ public void setBondAtomList(byte[] inputBondAtomList) {
+ this.bondAtomList = inputBondAtomList;
+ }
+
+ /**
+ * Gets the bond order list.
+ *
+ * @return the bond order list
+ */
+ public byte[] getBondOrderList() {
+ return bondOrderList;
+ }
+
+ /**
+ * Sets the bond order list.
+ *
+ * @param inputBondOrderList the new bond order list
+ */
+ public void setBondOrderList(byte[] inputBondOrderList) {
+ this.bondOrderList = inputBondOrderList;
+ }
+
+ /**
+ * Gets the number of chains per model. Chains are currently specified by asym (internal) chain ids.
+ *
+ * @return the list of chains per model.
+ */
+ public int[] getChainsPerModel() {
+ return chainsPerModel;
+ }
+
+ /**
+ * Sets the number of chains per model. Currently specified by asy (internal) chain ids.
+ *
+ * @param inputInternalChainsPerModel the new list of chains per model.
+ */
+ public void setChainsPerModel(int[]
+ inputInternalChainsPerModel) {
+ this.chainsPerModel = inputInternalChainsPerModel;
+ }
+
+ /**
+ * Gets the number of groups per chain.
+ *
+ * @return the internal groups per chain
+ */
+ public int[] getGroupsPerChain() {
+ return groupsPerChain;
+ }
+
+ /**
+ * Sets the number of groups in a chain.
+ *
+ * @param inputGroupsPerChain the new internal groups per chain
+ */
+ public void setGroupsPerChain(int[]
+ inputGroupsPerChain) {
+ this.groupsPerChain = inputGroupsPerChain;
+ }
+
+ /**
+ * Gets the internal chain list.
+ *
+ * @return the internal chain list
+ */
+ public byte[] getChainIdList() {
+ return chainIdList;
+ }
+
+ /**
+ * Sets the internal chain list.
+ *
+ * @param inputInternalChainList the new internal chain list
+ */
+ public void setChainIdList(byte[] inputInternalChainList) {
+ this.chainIdList = inputInternalChainList;
+ }
+
+ /**
+ * @return the experimental methods
+ */
+ public String[] getExperimentalMethods() {
+ return experimentalMethods;
+ }
+
+ /**
+ * @param experimentalMethods the experimental methods to set
+ */
+ public void setExperimentalMethods(String[] experimentalMethods) {
+ this.experimentalMethods = experimentalMethods;
+ }
+
+ /**
+ * @return the seqResGroupIds
+ */
+ public byte[] getSequenceIndexList() {
+ return sequenceIndexList;
+ }
+
+ /**
+ * @param seqResGroupIds the seqResGroupIds to set
+ */
+ public void setSequenceIndexList(byte[] seqResGroupIds) {
+ this.sequenceIndexList = seqResGroupIds;
+ }
+
+ /**
+ * Get the entity list.
+ * @return the list of entities for this structure.
+ */
+ public Entity[] getEntityList() {
+ return entityList;
+ }
+
+ /**
+ * Set the entity list.
+ * @param entityList the input list of entities.
+ */
+ public void setEntityList(Entity[] entityList) {
+ this.entityList = entityList;
+ }
+
+ /**
+ * @return the deposition date of the structure in ISO time standard.
+ */
+ public String getDepositionDate() {
+ return depositionDate;
+ }
+
+ /**
+ * @param depositionDate a string indicating the deposition date to set.
+ */
+ public void setDepositionDate(String depositionDate) {
+ this.depositionDate = depositionDate;
+ }
+
+ /**
+ * @return the release date of the structure in ISO time standard.
+ */
+ public String getReleaseDate() {
+ return releaseDate;
+ }
+
+ /**
+ * @param releaseDate a string indicating the deposition date to set.
+ */
+ public void setReleaseDate(String releaseDate) {
+ this.releaseDate = releaseDate;
+ }
+
+ /**
+ * @return the X coords as an encoded byte array.
+ */
+ public byte[] getxCoordList() {
+ return xCoordList;
+ }
+
+ /**
+ * @param xCoords the X coords as an encoded byte array.
+ */
+ public void setxCoordList(byte[] xCoords) {
+ this.xCoordList = xCoords;
+ }
+
+ /**
+ * @return the the Y coords as an encoded byte array.
+ */
+ public byte[] getyCoordList() {
+ return yCoordList;
+ }
+
+ /**
+ * @param yCoords the Y coords as an encoded byte array.
+ */
+ public void setyCoordList(byte[] yCoords) {
+ this.yCoordList = yCoords;
+ }
+
+ /**
+ * @return the Z coords as an encoded byte array.
+ */
+ public byte[] getzCoordList() {
+ return zCoordList;
+ }
+
+ /**
+ * @param zCoords the Z coords as an encoded byte array.
+ */
+ public void setzCoordList(byte[] zCoords) {
+ this.zCoordList = zCoords;
+ }
+
+ /**
+ * @return the atomic B-factors as an encoded byte array.
+ */
+ public byte[] getbFactorList() {
+ return bFactorList;
+ }
+
+ /**
+ * @param bFactors the atomic B-factors as an encoded byte array.
+ */
+ public void setbFactorList(byte[] bFactors) {
+ this.bFactorList = bFactors;
+ }
+
+ /**
+ * @return the number of groups in the structure
+ */
+ public int getNumGroups() {
+ return numGroups;
+ }
+
+ /**
+ * @param numGroups the number of groups in the structure
+ */
+ public void setNumGroups(int numGroups) {
+ this.numGroups = numGroups;
+ }
+
+ /**
+ * @return the number of chains in the structure
+ */
+ public int getNumChains() {
+ return numChains;
+ }
+
+ /**
+ * @param numChains the number of chains in the structure
+ */
+ public void setNumChains(int numChains) {
+ this.numChains = numChains;
+ }
+
+ /**
+ * @return the number of models in the structure
+ */
+ public int getNumModels() {
+ return numModels;
+ }
+
+ /**
+ * @param numModels the number of models in the structure
+ */
+ public void setNumModels(int numModels) {
+ this.numModels = numModels;
+ }
+
+ /**
+ * @return the ncsOperMatrixList
+ */
+ public double[][] getNcsOperatorList() {
+ return ncsOperatorList;
+ }
+
+ /**
+ * @param ncsOperatorList the ncsOperMatrixList to set
+ */
+ public void setNcsOperatorList(double[][] ncsOperatorList) {
+ this.ncsOperatorList = ncsOperatorList;
+ }
+
+}
diff --git a/mmtf-serialization/src/main/java/org/rcsb/mmtf/dataholders/MmtfStructureFactory.java b/mmtf-serialization/src/main/java/org/rcsb/mmtf/dataholders/MmtfStructureFactory.java
new file mode 100644
index 0000000..e7c5020
--- /dev/null
+++ b/mmtf-serialization/src/main/java/org/rcsb/mmtf/dataholders/MmtfStructureFactory.java
@@ -0,0 +1,134 @@
+package org.rcsb.mmtf.dataholders;
+
+import java.util.ArrayList;
+import java.util.Hashtable;
+import java.util.List;
+import org.rcsb.mmtf.serialization.quickmessagepackdeserialization.ObjectTree;
+
+/**
+ * This class constructs MmtfStructure objects from tree-like structure
+ * containing the data. The general types of the data are converted to proper
+ * type by this class.
+ *
+ * A solution using reflection, such as Jackson, is more elegant, but also
+ * slower.
+ *
+ * @author Antonin Pavelka
+ */
+public class MmtfStructureFactory {
+
+ public MmtfStructure create(ObjectTree tree) {
+ MmtfStructure s = new MmtfStructure();
+ s.setxCoordList(tree.getByteArray("xCoordList"));
+ s.setyCoordList(tree.getByteArray("yCoordList"));
+ s.setzCoordList(tree.getByteArray("zCoordList"));
+ s.setbFactorList(tree.getByteArray("bFactorList"));
+ s.setOccupancyList(tree.getByteArray("occupancyList"));
+ s.setNumAtoms(tree.getInt("numAtoms"));
+ s.setAtomIdList(tree.getByteArray("atomIdList"));
+ s.setAltLocList(tree.getByteArray("altLocList"));
+ s.setInsCodeList(tree.getByteArray("insCodeList"));
+ s.setGroupIdList(tree.getByteArray("groupIdList"));
+ s.setGroupList(createGroupList(tree.getObjectArray("groupList")));
+ s.setSequenceIndexList(tree.getByteArray("sequenceIndexList"));
+ s.setGroupTypeList(tree.getByteArray("groupTypeList"));
+ s.setChainNameList(tree.getByteArray("chainNameList"));
+ s.setChainIdList(tree.getByteArray("chainIdList"));
+ s.setNumBonds(tree.getInt("numBonds"));
+ s.setBondAtomList(tree.getByteArray("bondAtomList"));
+ s.setBondOrderList(tree.getByteArray("bondOrderList"));
+ s.setSecStructList(tree.getByteArray("secStructList"));
+ s.setChainsPerModel(tree.getIntArray("chainsPerModel"));
+ s.setGroupsPerChain(tree.getIntArray("groupsPerChain"));
+ s.setSpaceGroup(tree.getString("spaceGroup"));
+ s.setUnitCell(tree.getFloatArray("unitCell"));
+ s.setBioAssemblyList(createBioAssemblyList(tree.getObjectArray("bioAssemblyList")));
+ s.setMmtfVersion(tree.getString("mmtfVersion"));
+ s.setMmtfProducer(tree.getString("mmtfProducer"));
+ s.setEntityList(createEntityList(tree.getObjectArray("entityList")));
+ s.setStructureId(tree.getString("structureId"));
+ s.setrFree(tree.getFloat("rFree"));
+ s.setrWork(tree.getFloat("rWork"));
+ s.setResolution(tree.getFloat("resolution"));
+ s.setTitle(tree.getString("title"));
+ s.setExperimentalMethods(tree.getStringArray("experimentalMethods"));
+ s.setDepositionDate(tree.getString("depositionDate"));
+ s.setReleaseDate(tree.getString("releaseDate"));
+ s.setNumGroups(tree.getInt("numGroups"));
+ s.setNumChains(tree.getInt("numChains"));
+ s.setNumModels(tree.getInt("numModels"));
+ s.setNcsOperatorList(tree.getDoubleArray2d("ncsOperatorList"));
+ return s;
+ }
+
+ private Group[] createGroupList(Object[] array) {
+ Group[] ga = new Group[array.length];
+ for (int i = 0; i < ga.length; i++) {
+ ga[i] = createGroup(array[i]);
+ }
+ return ga;
+ }
+
+ private Group createGroup(Object o) {
+ ObjectTree t = new ObjectTree((Hashtable) o);
+ Group g = new Group();
+ g.setGroupName(t.getString("groupName"));
+ g.setAtomNameList(t.getStringArray("atomNameList"));
+ g.setElementList(t.getStringArray("elementList"));
+ g.setBondOrderList(t.getIntArray("bondOrderList"));
+ g.setBondAtomList(t.getIntArray("bondAtomList"));
+ g.setFormalChargeList(t.getIntArray("formalChargeList"));
+ g.setSingleLetterCode(t.getString("singleLetterCode").charAt(0));
+ g.setChemCompType(t.getString("chemCompType"));
+ return g;
+ }
+
+ private List createBioAssemblyList(Object[] array) {
+ List list = new ArrayList<>();
+ for (Object o : array) {
+ list.add(createBioAssemblyData(o));
+ }
+ return list;
+ }
+
+ private BioAssemblyData createBioAssemblyData(Object o) {
+ ObjectTree t = new ObjectTree((Hashtable) o);
+ BioAssemblyData data = new BioAssemblyData();
+ data.setName(t.getString("name"));
+ List ts = new ArrayList<>();
+ Object[] tls = t.getObjectArray("transformList");
+ for (Object tl : tls) {
+ ts.add(createBioAssemblyTransformation(tl));
+ }
+ data.setTransformList(ts);
+ return data;
+ }
+
+ private BioAssemblyTransformation createBioAssemblyTransformation(Object o) {
+ ObjectTree t = new ObjectTree((Hashtable) o);
+ BioAssemblyTransformation bat = new BioAssemblyTransformation();
+ bat.setChainIndexList(t.getIntArray("chainIndexList"));
+ double[] ds = t.getDoubleArray("matrix");
+ bat.setMatrix(ds);
+ return bat;
+ }
+
+ private Entity[] createEntityList(Object[] array) {
+ Entity[] list = new Entity[array.length];
+ for (int i = 0; i < array.length; i++) {
+ list[i] = createEntity(array[i]);
+ }
+ return list;
+ }
+
+ private Entity createEntity(Object o) {
+ ObjectTree t = new ObjectTree((Hashtable) o);
+ Entity e = new Entity();
+ e.setChainIndexList(t.getIntArray("chainIndexList"));
+ e.setDescription(t.getString("description"));
+ e.setSequence(t.getString("sequence"));
+ e.setType(t.getString("type"));
+ return e;
+ }
+
+}
diff --git a/mmtf-serialization/src/main/java/org/rcsb/mmtf/serialization/MessagePackSerialization.java b/mmtf-serialization/src/main/java/org/rcsb/mmtf/serialization/MessagePackSerialization.java
index 6fd344b..30209f4 100644
--- a/mmtf-serialization/src/main/java/org/rcsb/mmtf/serialization/MessagePackSerialization.java
+++ b/mmtf-serialization/src/main/java/org/rcsb/mmtf/serialization/MessagePackSerialization.java
@@ -1,51 +1,79 @@
-package org.rcsb.mmtf.serialization;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.msgpack.jackson.dataformat.MessagePackFactory;
-import org.rcsb.mmtf.dataholders.MmtfStructure;
-
-import com.fasterxml.jackson.annotation.JsonInclude.Include;
-import com.fasterxml.jackson.databind.ObjectMapper;
-
-/**
- * A message pack implementation of the {@link MmtfStructure} serializer / deserializer.
- * @author Anthony Bradley
- *
- */
-public class MessagePackSerialization implements MmtfStructureSerializationInterface {
-
- private ObjectMapper objectMapper;
-
- /**
- * Constructor for the {@link MessagePackSerialization} class.
- * Generates {@link ObjectMapper} and sets to include non-null.
- */
- public MessagePackSerialization() {
- objectMapper = new ObjectMapper(new MessagePackFactory());
- objectMapper.setSerializationInclusion(Include.NON_NULL);
- }
-
- @Override
- public MmtfStructure deserialize(InputStream inputStream){
- MmtfStructure mmtfBean = null;
- try {
- mmtfBean = objectMapper.readValue(inputStream, MmtfStructure.class);
- } catch (IOException e) {
- e.printStackTrace();
- }
- return mmtfBean;
- }
-
- @Override
- public void serialize(MmtfStructure mmtfStructure, OutputStream outputStream) {
- try {
- objectMapper.writeValue(outputStream, mmtfStructure);
- } catch (IOException e) {
- e.printStackTrace();
- }
- }
-
-}
+package org.rcsb.mmtf.serialization;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+
+import org.msgpack.jackson.dataformat.MessagePackFactory;
+import org.rcsb.mmtf.dataholders.MmtfStructure;
+
+import com.fasterxml.jackson.annotation.JsonInclude.Include;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import java.io.DataInputStream;
+import java.text.ParseException;
+import java.util.Map;
+import org.rcsb.mmtf.dataholders.MmtfStructureFactory;
+import org.rcsb.mmtf.serialization.quickmessagepackdeserialization.MessagePackReader;
+import org.rcsb.mmtf.serialization.quickmessagepackdeserialization.ObjectTree;
+
+/**
+ * A message pack implementation of the {@link MmtfStructure} serializer / deserializer.
+ *
+ * @author Anthony Bradley
+ * @author Antonin Pavelka
+ *
+ */
+public class MessagePackSerialization implements MmtfStructureSerializationInterface {
+
+ private ObjectMapper objectMapper;
+ private static boolean useJackson = false;
+
+ /**
+ * Constructor for the {@link MessagePackSerialization} class. Generates {@link ObjectMapper}
+ * and sets to include non-null.
+ */
+ public MessagePackSerialization() {
+ objectMapper = new ObjectMapper(new MessagePackFactory());
+ objectMapper.setSerializationInclusion(Include.NON_NULL);
+ }
+
+ public static void setJackson(boolean allowed) {
+ useJackson = allowed;
+ }
+
+ @Override
+ public MmtfStructure deserialize(InputStream inputStream)
+ throws ParseException, IOException {
+ if (useJackson) {
+ return deserializeByJackson(inputStream);
+ } else {
+ return deserializeQuick(inputStream);
+ }
+ }
+
+ /**
+ * Elegant, but slow (comparable to unzipping).
+ */
+ private MmtfStructure deserializeByJackson(InputStream inputStream) throws IOException {
+ return objectMapper.readValue(inputStream, MmtfStructure.class);
+ }
+
+ /**
+ * Several times faster.
+ */
+ private MmtfStructure deserializeQuick(InputStream inputStream)
+ throws ParseException, IOException {
+ MessagePackReader mpr = new MessagePackReader(new DataInputStream(inputStream), true);
+ Map map = mpr.readMap();
+ MmtfStructureFactory f = new MmtfStructureFactory();
+ MmtfStructure s = f.create(new ObjectTree(map));
+ return s;
+ }
+
+ @Override
+ public void serialize(MmtfStructure mmtfStructure,
+ OutputStream outputStream) throws IOException {
+ objectMapper.writeValue(outputStream, mmtfStructure);
+ }
+
+}
diff --git a/mmtf-serialization/src/main/java/org/rcsb/mmtf/serialization/MmtfStructureSerializationInterface.java b/mmtf-serialization/src/main/java/org/rcsb/mmtf/serialization/MmtfStructureSerializationInterface.java
index ef5a870..f0905b2 100644
--- a/mmtf-serialization/src/main/java/org/rcsb/mmtf/serialization/MmtfStructureSerializationInterface.java
+++ b/mmtf-serialization/src/main/java/org/rcsb/mmtf/serialization/MmtfStructureSerializationInterface.java
@@ -1,29 +1,37 @@
-package org.rcsb.mmtf.serialization;
-
-import java.io.InputStream;
-import java.io.OutputStream;
-
-import org.rcsb.mmtf.dataholders.MmtfStructure;
-
-/**
- * An interface to carry out serializing / deserializing to {@link MmtfStructure}.
- * @author Anthony Bradley
- *
- */
-public interface MmtfStructureSerializationInterface {
-
- /**
- * Serialize an {@link MmtfStructure} to a generic output stream.
- * @param mmtfStructure the compressed data
- * @param outputStream the output stream to write to
- */
- public void serialize(MmtfStructure mmtfStructure, OutputStream outputStream);
-
- /**
- * Deserialize an {@link MmtfStructure} from an input stream.
- * @param inputStream the inputstream to deserialize
- * @return the compressed structure data.
- */
- public MmtfStructure deserialize(InputStream inputStream);
-
-}
+package org.rcsb.mmtf.serialization;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.text.ParseException;
+
+import org.rcsb.mmtf.dataholders.MmtfStructure;
+
+/**
+ * An interface to carry out serializing / deserializing to
+ * {@link MmtfStructure}.
+ *
+ * @author Anthony Bradley
+ *
+ */
+public interface MmtfStructureSerializationInterface {
+
+ /**
+ * Serialize an {@link MmtfStructure} to a generic output stream.
+ *
+ * @param mmtfStructure the compressed data
+ * @param outputStream the output stream to write to
+ */
+ public void serialize(MmtfStructure mmtfStructure,
+ OutputStream outputStream) throws IOException;
+
+ /**
+ * Deserialize an {@link MmtfStructure} from an input stream.
+ *
+ * @param inputStream the inputstream to deserialize
+ * @return the compressed structure data.
+ */
+ public MmtfStructure deserialize(InputStream inputStream)
+ throws ParseException, IOException;
+
+}
diff --git a/mmtf-serialization/src/main/java/org/rcsb/mmtf/serialization/quickmessagepackdeserialization/MessagePackReader.java b/mmtf-serialization/src/main/java/org/rcsb/mmtf/serialization/quickmessagepackdeserialization/MessagePackReader.java
new file mode 100644
index 0000000..bf95240
--- /dev/null
+++ b/mmtf-serialization/src/main/java/org/rcsb/mmtf/serialization/quickmessagepackdeserialization/MessagePackReader.java
@@ -0,0 +1,429 @@
+package org.rcsb.mmtf.serialization.quickmessagepackdeserialization;
+
+import java.io.DataInputStream;
+import java.io.IOException;
+import java.text.ParseException;
+import java.util.Hashtable;
+import java.util.Map;
+
+/**
+ * A simple MessagePack reader. Adopted from Jmol code:
+ * https://github.com/msgpack/msgpack/blob/master/spec.md with very few dependencies. In contrast to
+ * original implementation, float64 is interpreted as double.
+ *
+ * Nuances:
+ *
+ * Does not implement unsigned int32 or int64 (delivers simple integers in all cases).
+ *
+ * Note:
+ *
+ * homogeneousArrays == true will deliver null for empty array.
+ *
+ *
+ * @author Bob Hanson hansonr@stolaf.edu
+ * @author Antonin Pavelka
+ *
+ */
+public class MessagePackReader {
+
+ private final boolean isHomo;// homogeneous arrays -- use int[] not Integer
+
+ // these maps must be checked for the specific number of bits, in the following order:
+ private final static int POSITIVEFIXINT_x80 = 0x80; //0xxxxxxx
+ private final static int FIXMAP_xF0 = 0x80; //1000xxxx
+// private final static int FIXARRAY_xF0 = 0x90; //1001xxxx
+ private final static int FIXSTR_xE0 = 0xa0; //101xxxxx
+ private final static int NEGATIVEFIXINT_xE0 = 0xe0; //111xxxxx
+ private final static int DEFINITE_xE0 = 0xc0; //110xxxxx
+
+ private final static int NIL = 0xc0;
+// private final static int (NEVERUSED) = 0xc1;
+ private final static int FALSE = 0xc2;
+ private final static int TRUE = 0xc3;
+ private final static int BIN8 = 0xc4;
+ private final static int BIN16 = 0xc5;
+ private final static int BIN32 = 0xc6;
+ private final static int EXT8 = 0xc7;
+ private final static int EXT16 = 0xc8;
+ private final static int EXT32 = 0xc9;
+ private final static int FLOAT32 = 0xca;
+ private final static int FLOAT64 = 0xcb;
+ private final static int UINT8 = 0xcc;
+ private final static int UINT16 = 0xcd;
+ private final static int UINT32 = 0xce;
+ private final static int UINT64 = 0xcf;
+ private final static int INT8 = 0xd0;
+ private final static int INT16 = 0xd1;
+ private final static int INT32 = 0xd2;
+ private final static int INT64 = 0xd3;
+ private final static int FIXEXT1 = 0xd4;
+ private final static int FIXEXT2 = 0xd5;
+ private final static int FIXEXT4 = 0xd6;
+ private final static int FIXEXT8 = 0xd7;
+ private final static int FIXEXT16 = 0xd8;
+ private final static int STR8 = 0xd9;
+ private final static int STR16 = 0xda;
+ private final static int STR32 = 0xdb;
+ private final static int ARRAY16 = 0xdc;
+ private final static int ARRAY32 = 0xdd;
+ private final static int MAP16 = 0xde;
+ private final static int MAP32 = 0xdf;
+
+ private final DataInputStream stream;
+ private final boolean isBigEndian = true;
+ private final byte[] t8 = new byte[8];
+
+ public MessagePackReader(DataInputStream dis,
+ boolean isHomogeneousArrays) {
+ this.isHomo = isHomogeneousArrays;
+ this.stream = dis;
+ }
+
+ public Map readMap() throws ParseException, IOException {
+ return (Map) getNext(null, 0);
+ }
+
+ private Object getNext(Object array, int pt)
+ throws ParseException, IOException {
+ int b = readByte() & 0xFF;
+ int be0 = b & 0xE0;
+ if ((b & POSITIVEFIXINT_x80) == 0) {
+ if (array != null) {
+ ((int[]) array)[pt] = b;
+ return null;
+ }
+ return b;
+ }
+ switch (be0) {
+ case NEGATIVEFIXINT_xE0:
+ b = b | 0xFFFFFF00;
+ if (array != null) {
+ ((int[]) array)[pt] = b;
+ return null;
+ }
+ return b;
+ case FIXSTR_xE0: {
+ String s = readString(b & 0x1F);
+ if (array != null) {
+ ((String[]) array)[pt] = s;
+ return null;
+ }
+ return s;
+ }
+ case FIXMAP_xF0:
+ return ((b & 0xF0) == FIXMAP_xF0 ? getMap(b & 0x0F) : getArray(b & 0x0F));
+ case DEFINITE_xE0:
+ switch (b) {
+ case NIL:
+ return null;
+ case FALSE:
+ return Boolean.FALSE;
+ case TRUE:
+ return Boolean.TRUE;
+ case EXT8: {
+ int n = readUInt8();
+ return new Object[]{readUInt8(), readBytes(n)};
+ }
+ case EXT16: {
+ int n = readUnsignedShort();
+ return new Object[]{readUInt8(), readBytes(n)};
+ }
+ case EXT32: {
+ int n = readInt(); // should be unsigned int
+ return new Object[]{readUInt8(), readBytes(n)};
+ }
+ case FIXEXT1:
+ return new Object[]{readUInt8(), readBytes(1)};
+ case FIXEXT2:
+ return new Object[]{readUInt8(), readBytes(2)};
+ case FIXEXT4:
+ return new Object[]{readUInt8(), readBytes(4)};
+ case FIXEXT8:
+ return new Object[]{readUInt8(), readBytes(8)};
+ case FIXEXT16:
+ return new Object[]{readUInt8(), readBytes(16)};
+ case ARRAY16:
+ return getArray(readUnsignedShort());
+ case ARRAY32:
+ return getArray(readInt());
+ case MAP16:
+ return getMap(readUnsignedShort());
+ case MAP32:
+ return getMap(readInt());
+
+ // binary arrays:
+ case BIN8:
+ return readBytes(readUInt8());
+ case BIN16:
+ return readBytes(readUnsignedShort());
+ case BIN32:
+ return readBytes(readInt());
+ }
+ if (array == null) {
+ switch (b) {
+ case FLOAT32:
+ return readFloat();
+ case FLOAT64:
+ return readDouble();
+ case UINT8:
+ return readUInt8();
+ case UINT16:
+ return readUnsignedShort();
+ case UINT32:
+ return readInt(); // should be unsigned int
+ case UINT64:
+ return readLong(); // should be unsigned long; incompatible with JavaScript!
+ case INT8:
+ return readByte();
+ case INT16:
+ return readShort();
+ case INT32:
+ return readInt(); // should be Unsigned Int here
+ case INT64:
+ return readLong();
+ case STR8:
+ return readString(readUInt8());
+ case STR16:
+ return readString(readShort());
+ case STR32:
+ return readString(readInt());
+ }
+ } else {
+ switch (b) {
+ case FLOAT32:
+ ((float[]) array)[pt] = readFloat();
+ break;
+ case FLOAT64:
+ ((double[]) array)[pt] = readDouble();
+ break;
+ case UINT8:
+ ((int[]) array)[pt] = readUInt8();
+ break;
+ case UINT16:
+ ((int[]) array)[pt] = readUnsignedShort();
+ break;
+ case UINT32:
+ ((int[]) array)[pt] = readInt(); // should be unsigned int
+ break;
+ case UINT64:
+ ((int[]) array)[pt] = (int) readLong(); // should be unsigned long; incompatible with JavaScript!
+ break;
+ case INT8:
+ ((int[]) array)[pt] = readByte();
+ break;
+ case INT16:
+ ((int[]) array)[pt] = readShort();
+ break;
+ case INT32:
+ ((int[]) array)[pt] = readInt(); // should be Unsigned Int here
+ break;
+ case INT64:
+ ((int[]) array)[pt] = (int) readLong();
+ break;
+ case STR8:
+ ((String[]) array)[pt] = readString(readUInt8());
+ break;
+ case STR16:
+ ((String[]) array)[pt] = readString(readShort());
+ break;
+ case STR32:
+ ((String[]) array)[pt] = readString(readInt());
+ break;
+ }
+ }
+ }
+ return null;
+ }
+
+ private Object getArray(int n) throws ParseException, IOException {
+ if (isHomo) {
+ if (n == 0) {
+ return null;
+ }
+ Object v = getNext(null, 0);
+ if (v instanceof Integer) {
+ int[] a = new int[n];
+ a[0] = ((Integer) v).intValue();
+ v = a;
+ } else if (v instanceof Float) {
+ float[] a = new float[n];
+ a[0] = ((Float) v).floatValue();
+ v = a;
+ } else if (v instanceof Double) {
+ double[] a = new double[n];
+ a[0] = ((Double) v).doubleValue();
+ v = a;
+ } else if (v instanceof String) {
+ String[] a = new String[n];
+ a[0] = (String) v;
+ v = a;
+ } else {
+ Object[] o = new Object[n];
+ o[0] = v;
+ for (int i = 1; i < n; i++) {
+ o[i] = getNext(null, 0);
+ }
+ return o;
+ }
+ for (int i = 1; i < n; i++) {
+ getNext(v, i);
+ }
+ return v;
+ }
+ Object[] o = new Object[n];
+ for (int i = 0; i < n; i++) {
+ o[i] = getNext(null, 0);
+ }
+ return o;
+ }
+
+ private Object getMap(int n) throws ParseException, IOException {
+ Map map = new Hashtable();
+ for (int i = 0; i < n; i++) {
+ String key = getNext(null, 0).toString();
+ Object value = getNext(null, 0);
+ if (value == null) {
+ } else {
+ map.put(key, value);
+ }
+ }
+ return map;
+ }
+
+ private byte readByte() throws IOException {
+ return ioReadByte();
+ }
+
+ private byte ioReadByte() throws IOException {
+ byte b = stream.readByte();
+ return b;
+ }
+
+ private int readUInt8() throws IOException {
+ int b = stream.readUnsignedByte();
+ return b;
+ }
+
+ private byte[] readBytes(int n) throws IOException {
+ byte[] b = new byte[n];
+ readByteArray(b, 0, n);
+ return b;
+ }
+
+ private int readByteArray(byte[] b, int off, int len) throws IOException {
+ int n = ioRead(b, off, len);
+ return n;
+ }
+
+ private int ioRead(byte[] b, int off, int len) throws IOException {
+ int m = 0;
+ while (len > 0) {
+ int n = stream.read(b, off, len);
+ m += n;
+ if (n >= len) {
+ break;
+ }
+ off += n;
+ len -= n;
+ }
+ return m;
+ }
+
+ private String readString(int nChar) throws IOException {
+ byte[] temp = new byte[nChar];
+ int n = readByteArray(temp, 0, nChar);
+ return new String(temp, 0, n, "UTF-8");
+ }
+
+ private short readShort() throws IOException {
+ return (isBigEndian ? ioReadShort()
+ : (short) ((ioReadByte() & 0xff)
+ | (ioReadByte() & 0xff) << 8));
+ }
+
+ private short ioReadShort() throws IOException {
+ return stream.readShort();
+ }
+
+ private int readInt() throws IOException {
+ return (isBigEndian ? ioReadInt() : readLEInt());
+ }
+
+ private int ioReadInt() throws IOException {
+ int i = stream.readInt();
+ return i;
+ }
+
+ private int readUnsignedShort() throws IOException {
+ int a = (ioReadByte() & 0xff);
+ int b = (ioReadByte() & 0xff);
+ return (isBigEndian ? (a << 8) + b : (b << 8) + a);
+ }
+
+ private long readLong() throws IOException {
+ return (isBigEndian ? ioReadLong()
+ : ((((long) ioReadByte()) & 0xff)
+ | (((long) ioReadByte()) & 0xff) << 8
+ | (((long) ioReadByte()) & 0xff) << 16
+ | (((long) ioReadByte()) & 0xff) << 24
+ | (((long) ioReadByte()) & 0xff) << 32
+ | (((long) ioReadByte()) & 0xff) << 40
+ | (((long) ioReadByte()) & 0xff) << 48
+ | (((long) ioReadByte()) & 0xff) << 54));
+ }
+
+ private long ioReadLong() throws IOException {
+ long b = stream.readLong();
+ return b;
+ }
+
+ private int readLEInt() throws IOException {
+ ioRead(t8, 0, 4);
+ return bytesToInt(t8, 0, false);
+ }
+
+ private float readFloat() throws ParseException, IOException {
+ return intToFloat(readInt());
+ }
+
+ private double readDouble() throws IOException {
+ // reading the float equivalent here in JavaScript
+ return (isBigEndian ? ioReadDouble() : Double.longBitsToDouble(readLELong()));
+ }
+
+ private double ioReadDouble() throws IOException {
+ double d = stream.readDouble();
+ return d;
+ }
+
+ private long readLELong() throws IOException {
+ return ((((long) ioReadByte()) & 0xff)
+ | (((long) ioReadByte()) & 0xff) << 8
+ | (((long) ioReadByte()) & 0xff) << 16
+ | (((long) ioReadByte()) & 0xff) << 24
+ | (((long) ioReadByte()) & 0xff) << 32
+ | (((long) ioReadByte()) & 0xff) << 40
+ | (((long) ioReadByte()) & 0xff) << 48
+ | (((long) ioReadByte()) & 0xff) << 56);
+ }
+
+ private static int bytesToInt(byte[] bytes, int j, boolean isBigEndian) {
+ return (isBigEndian ? (bytes[j + 3] & 0xff) | (bytes[j + 2] & 0xff) << 8
+ | (bytes[j + 1] & 0xff) << 16 | (bytes[j] & 0xff) << 24
+ : (bytes[j++] & 0xff) | (bytes[j++] & 0xff) << 8
+ | (bytes[j++] & 0xff) << 16 | (bytes[j++] & 0xff) << 24);
+ }
+
+ private static float intToFloat(int x) throws ParseException {
+ /**
+ * see http://en.wikipedia.org/wiki/Binary32
+ *
+ * [sign] [8 bits power] [23 bits fraction] 0x80000000 0x7F800000 0x7FFFFF
+ *
+ * (untested)
+ *
+ */
+ return Float.intBitsToFloat(x);
+ }
+
+}
diff --git a/mmtf-serialization/src/main/java/org/rcsb/mmtf/serialization/quickmessagepackdeserialization/ObjectTree.java b/mmtf-serialization/src/main/java/org/rcsb/mmtf/serialization/quickmessagepackdeserialization/ObjectTree.java
new file mode 100644
index 0000000..053e4a2
--- /dev/null
+++ b/mmtf-serialization/src/main/java/org/rcsb/mmtf/serialization/quickmessagepackdeserialization/ObjectTree.java
@@ -0,0 +1,120 @@
+package org.rcsb.mmtf.serialization.quickmessagepackdeserialization;
+
+import java.util.Hashtable;
+import java.util.Map;
+
+/**
+ * Utility class represeting an object whose attributes does not have types yet.
+ * The methods of the instance of this class can be called to retrieve the
+ * attributes in correct type specified by their name. Only several primitive
+ * types and their arrays are supported, application specific types are resolved
+ * elsewhere.
+ *
+ * @author Antonin Pavelka
+ */
+public class ObjectTree {
+
+ private Map root;
+
+ public ObjectTree(Map m) {
+ root = m;
+ }
+
+ public ObjectTree(Hashtable t) {
+ root = t;
+ }
+
+ public Object get(String s) {
+ return root.get(s);
+ }
+
+ public String getString(String s) {
+ Object o = root.get(s);
+ if (o == null) {
+ return "";
+ } else {
+ return (String) root.get(s);
+ }
+ }
+
+ public int getInt(String s) {
+ Object o = root.get(s);
+ if (o == null) {
+ return 0;
+ } else {
+ return (int) root.get(s);
+ }
+ }
+
+ public float getFloat(String s) {
+ Object o = root.get(s);
+ if (o == null) {
+ return 0;
+ } else {
+ return (float) root.get(s);
+ }
+ }
+
+ public byte[] getByteArray(String s) {
+ Object o = root.get(s);
+ if (o == null) {
+ return new byte[0];
+ } else {
+ return (byte[]) root.get(s);
+ }
+ }
+
+ public int[] getIntArray(String s) {
+ Object o = root.get(s);
+ if (o == null) {
+ return new int[0];
+ } else {
+ return (int[]) root.get(s);
+ }
+ }
+
+ public float[] getFloatArray(String s) {
+ return (float[]) root.get(s);
+ }
+
+ public double[] getDoubleArray(String s) {
+ return (double[]) root.get(s);
+ }
+
+ public double[][] getDoubleArray2d(String s) {
+ Object o = root.get(s);
+ double[][] aa;
+ if (o == null) {
+ aa = new double[0][0];
+ } else {
+ Object[] a = (Object[]) o;
+ aa = new double[a.length][];
+ for (int i = 0; i < a.length; i++) {
+ aa[i] = (double[]) a[i];
+ }
+ }
+ return aa;
+ }
+
+ public char getChar(String s) {
+ Object o = root.get(s);
+ if (o == null) {
+ return 0;
+ } else {
+ return (char) root.get(s);
+ }
+ }
+
+ public String[] getStringArray(String s) {
+ return (String[]) root.get(s);
+ }
+
+ public Object[] getObjectArray(String s) {
+ Object o = root.get(s);
+ if (o == null) {
+ return new Object[0];
+ } else {
+ return (Object[]) root.get(s);
+ }
+ }
+}
diff --git a/mmtf-serialization/src/main/java/org/rcsb/mmtf/utils/Lines.java b/mmtf-serialization/src/main/java/org/rcsb/mmtf/utils/Lines.java
new file mode 100644
index 0000000..ee87234
--- /dev/null
+++ b/mmtf-serialization/src/main/java/org/rcsb/mmtf/utils/Lines.java
@@ -0,0 +1,62 @@
+package org.rcsb.mmtf.utils;
+
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.zip.GZIPInputStream;
+
+/**
+ * @author Antonin Pavelka
+ *
+ * Allows to load all lines from a gzipped data source into memory.
+ */
+public class Lines {
+
+ /**
+ * Read lines from a resource specified by absolute path, e.g.
+ * /org/rcsb/mmtf/pdb_entry_type.gz. The location of the root of the path is
+ * something like project_dir/src/main/resources
+ *
+ * @param name Name of the resouce.
+ * @return Array containing all lines in the gzipped resouce.
+ * @throws java.io.IOException
+ */
+ public static String[] readResource(String name) throws IOException {
+ URL url = Lines.class.getResource(name);
+ try (InputStream is = url.openStream()) {
+ return readLines(is);
+ }
+ }
+
+ /**
+ * Read lines from a file.
+ *
+ * @param f The input gzipped text file.
+ * @return List of all lines in the gzipped resouce.
+ * @throws java.io.IOException
+ */
+ public static String[] readFile(File f) throws IOException {
+ try (FileInputStream fis = new FileInputStream(f)) {
+ return readLines(fis);
+ }
+ }
+
+ private static String[] readLines(InputStream is) throws IOException {
+ BufferedReader br = new BufferedReader(new InputStreamReader(
+ new GZIPInputStream(is)));
+ List lines = new ArrayList<>();
+ String line;
+ while ((line = br.readLine()) != null) {
+ lines.add(line);
+ }
+ String[] a = lines.toArray(new String[lines.size()]);
+ return a;
+ }
+
+}
diff --git a/mmtf-serialization/src/main/resources/mmtf/pdb_codes.gz b/mmtf-serialization/src/main/resources/mmtf/pdb_codes.gz
new file mode 100644
index 0000000..b2a8c4c
Binary files /dev/null and b/mmtf-serialization/src/main/resources/mmtf/pdb_codes.gz differ
diff --git a/mmtf-serialization/src/test/java/org/rcsb/mmtf/serialization/TestMessagePack.java b/mmtf-serialization/src/test/java/org/rcsb/mmtf/serialization/TestMessagePack.java
index 9e3270e..8a6e2c0 100644
--- a/mmtf-serialization/src/test/java/org/rcsb/mmtf/serialization/TestMessagePack.java
+++ b/mmtf-serialization/src/test/java/org/rcsb/mmtf/serialization/TestMessagePack.java
@@ -1,47 +1,48 @@
-package org.rcsb.mmtf.serialization;
-
-import static org.junit.Assert.assertNotNull;
-
-import java.io.ByteArrayInputStream;
-import java.io.ByteArrayOutputStream;
-
-import org.junit.Test;
-import org.rcsb.mmtf.dataholders.MmtfStructure;
-import org.rcsb.mmtf.serialization.MessagePackSerialization;
-
-import uk.co.jemos.podam.api.PodamFactory;
-import uk.co.jemos.podam.api.PodamFactoryImpl;
-
-/**
- * Class to test the message pack serializer and deserializer.
- * @author Anthony Bradley
- *
- */
-public class TestMessagePack {
-
-
- /**
- * Test the deserialize.
- */
- @Test
- public void testDeserialize() {
- MessagePackSerialization mmtfBeanSeDeMessagePackImpl = new MessagePackSerialization();
- byte[] source = new byte[] {(byte) (char) 129, (byte) (char)162, (byte) (char)100, (byte) (char)111, (byte) (char)1};
- ByteArrayInputStream bis = new ByteArrayInputStream(source);
- MmtfStructure mmtfBean = mmtfBeanSeDeMessagePackImpl.deserialize(bis);
- assertNotNull(mmtfBean);
- }
-
- /**
- * Test the serialize.
- */
- @Test
- public void testSerialize() {
- MessagePackSerialization mmtfBeanSeDeMessagePackImpl = new MessagePackSerialization();
- PodamFactory factory = new PodamFactoryImpl();
- MmtfStructure mmtfBean = factory.manufacturePojo(MmtfStructure.class);
- ByteArrayOutputStream bos = new ByteArrayOutputStream();
- mmtfBeanSeDeMessagePackImpl.serialize(mmtfBean, bos);
- assertNotNull(bos.toByteArray());
- }
-}
+package org.rcsb.mmtf.serialization;
+
+import static org.junit.Assert.assertNotNull;
+
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.text.ParseException;
+
+import org.junit.Test;
+import org.rcsb.mmtf.dataholders.MmtfStructure;
+
+import uk.co.jemos.podam.api.PodamFactory;
+import uk.co.jemos.podam.api.PodamFactoryImpl;
+
+/**
+ * Class to test the message pack serializer and deserializer.
+ * @author Anthony Bradley
+ *
+ */
+public class TestMessagePack {
+
+
+ /**
+ * Test the deserialize.
+ */
+ @Test
+ public void testDeserialize() throws ParseException, IOException {
+ MessagePackSerialization mmtfBeanSeDeMessagePackImpl = new MessagePackSerialization();
+ byte[] source = new byte[] {(byte) (char) 129, (byte) (char)162, (byte) (char)100, (byte) (char)111, (byte) (char)1};
+ ByteArrayInputStream bis = new ByteArrayInputStream(source);
+ MmtfStructure mmtfBean = mmtfBeanSeDeMessagePackImpl.deserialize(bis);
+ assertNotNull(mmtfBean);
+ }
+
+ /**
+ * Test the serialize.
+ */
+ @Test
+ public void testSerialize() throws IOException {
+ MessagePackSerialization mmtfBeanSeDeMessagePackImpl = new MessagePackSerialization();
+ PodamFactory factory = new PodamFactoryImpl();
+ MmtfStructure mmtfBean = factory.manufacturePojo(MmtfStructure.class);
+ ByteArrayOutputStream bos = new ByteArrayOutputStream();
+ mmtfBeanSeDeMessagePackImpl.serialize(mmtfBean, bos);
+ assertNotNull(bos.toByteArray());
+ }
+}
diff --git a/pom.xml b/pom.xml
index 2123d51..6494d5a 100644
--- a/pom.xml
+++ b/pom.xml
@@ -1,496 +1,496 @@
-
-
-
-
-
- org.sonatype.oss
- oss-parent
- 9
-
-
-
- 4.0.0
- org.rcsb
- mmtf
- pom
- 1.0.4-SNAPSHOT
- mmtf
- MMTF is a compressed, fast and useful format for serving macromolecular data.
-
- https://github.com/rcsb
-
- RCSB PDB
- http://www.rcsb.org/
-
-
-
- Apache 2.0
- https://www.apache.org/licenses/LICENSE-2.0
- repo
-
-
-
- 1.8
- 1.8
- UTF-8
- UTF-8
- 512M
- 1.7.21
- 2.6.2
-
-
- scm:git:git://github.com:rcsb/mmtf-java.git
- scm:git:git@github.com:rcsb/mmtf-java.git
- https://github.com/rcsb/mmtf-java
-
- HEAD
-
-
-
-
-
- org.eclipse.m2e
- lifecycle-mapping
- 1.0.0
-
-
-
-
-
- org.apache.maven.plugins
- maven-enforcer-plugin
- [1.0.0,)
-
- enforce
-
-
-
-
-
-
-
-
-
-
-
- maven-clean-plugin
- 3.0.0
-
-
- maven-compiler-plugin
- 3.5.1
-
-
- ${jdk.version}
-
-
-
- maven-dependency-plugin
- 2.10
-
-
- maven-jar-plugin
- 3.0.2
-
-
- maven-scm-plugin
- 1.9.5
-
-
- maven-source-plugin
- 3.0.1
-
-
- maven-failsafe-plugin
- 2.19.1
-
-
- net.sf
- stat-scm
- 1.2.0
-
-
- org.jvnet.jaxb2.maven2
- maven-jaxb2-plugin
- 0.13.1
-
-
- org.apache.maven.plugins
- maven-release-plugin
- 2.5.3
-
- true
- clean install
- true
-
- forked-path
-
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
- 2.10.4
-
- 256m
-
-
-
-
- org.apache.maven.plugins
- maven-shade-plugin
- 2.4.3
-
-
- maven-assembly-plugin
- 2.6
-
-
- src/main/assembly/assembly.xml
-
-
-
-
-
-
- assemble
- package
-
- single
-
-
-
-
-
-
- org.codehaus.mojo
- findbugs-maven-plugin
- 3.0.4
-
-
-
- org.codehaus.mojo
- buildnumber-maven-plugin
- 1.4
-
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
- 2.17
-
-
-
- org.apache.maven.plugins
- maven-resources-plugin
- 3.0.1
-
-
-
- maven-enforcer-plugin
- 1.4.1
-
-
- enforce-java
-
- enforce
-
-
-
-
- ${maven.enforcer.jdk-version}
-
-
-
-
-
-
-
-
-
-
-
-
-
- org.codehaus.mojo
- cobertura-maven-plugin
- 2.7
-
- xml
- 256m
-
- true
-
-
-
- org.eluder.coveralls
- coveralls-maven-plugin
- 4.2.0
-
-
-
- org.sonatype.plugins
- nexus-staging-maven-plugin
- 1.6.7
- true
-
- ossrh
- https://oss.sonatype.org/
- true
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- maven-surefire-plugin
- 2.19.1
-
- -Xmx1500M
- false
- 1
-
-
-
-
-
- org.apache.maven.plugins
- maven-jar-plugin
-
-
-
- false
-
- true
- true
-
-
-
- true
- all-permissions
- *
- MMTF
-
-
-
-
-
-
-
-
- org.codehaus.mojo
- findbugs-maven-plugin
-
-
- org.apache.maven.plugins
- maven-checkstyle-plugin
-
-
- false
-
-
-
-
-
- com.versioneye
- versioneye-maven-plugin
- 3.10.2
-
-
-
-
-
-
- org.apache.maven.wagon
- wagon-ssh
- 2.6
-
-
-
-
-
-
- uk.co.jemos.podam
- podam
- 2.3.5.RELEASE
- test
-
-
- org.unitils
- unitils-core
- 3.4.2
- test
-
-
- junit
- junit
- 4.12
- test
-
-
- commons-beanutils
- commons-beanutils
- 1.9.2
- test
-
-
- org.slf4j
- slf4j-api
- ${slf4j.version}
-
-
-
- org.apache.logging.log4j
- log4j-slf4j-impl
- ${log4j.version}
-
- runtime
-
-
-
- org.apache.logging.log4j
- log4j-api
- ${log4j.version}
-
- runtime
-
-
- org.apache.logging.log4j
- log4j-core
- ${log4j.version}
-
- runtime
-
-
-
-
-
-
-
- org.apache.maven.plugins
- maven-javadoc-plugin
- 2.10.4
-
- org.umlgraph.doclet.UmlGraphDoc
-
- org.umlgraph
- umlgraph
- 5.6
-
- -views -all
- true
-
-
-
- org.codehaus.mojo
- findbugs-maven-plugin
- 3.0.4
-
-
-
-
-
-
-
- codesigning
-
- false
-
-
-
-
- org.apache.maven.plugins
- maven-jarsigner-plugin
- 1.4
-
-
- sign
-
- sign
-
-
-
-
-
-
- true
- true
- ${keystore.type}
- ${keystore.path}
- ${keystore.alias}
- ${keystore.store.password}
- ${keystore.key.password}
- ${project.build.directory}/${project.build.finalName}.jar
- true
- true
- sign
-
- -tsa
- https://timestamp.geotrust.com/tsa
-
-
-
-
-
-
-
- release-sign-artifacts
-
-
- performRelease
- true
-
-
-
-
-
- org.apache.maven.plugins
- maven-gpg-plugin
- 1.6
-
-
- sign-artifacts
- verify
-
- sign
-
-
-
-
-
-
-
-
-
-
- mmtf-serialization
- mmtf-api
- mmtf-codec
-
- 2015
-
- Github
- https://github.com/rcsb/mmtf-java/issues
-
-
- Travis
- https://travis-ci.org/
-
-
+
+
+
+
+
+ org.sonatype.oss
+ oss-parent
+ 9
+
+
+
+ 4.0.0
+ org.rcsb
+ mmtf
+ pom
+ 1.0.4-SNAPSHOT
+ mmtf
+ MMTF is a compressed, fast and useful format for serving macromolecular data.
+
+ https://github.com/rcsb
+
+ RCSB PDB
+ http://www.rcsb.org/
+
+
+
+ Apache 2.0
+ https://www.apache.org/licenses/LICENSE-2.0
+ repo
+
+
+
+ 1.8
+ 1.8
+ UTF-8
+ UTF-8
+ 512M
+ 1.7.21
+ 2.6.2
+
+
+ scm:git:git://github.com:rcsb/mmtf-java.git
+ scm:git:git@github.com:rcsb/mmtf-java.git
+ https://github.com/rcsb/mmtf-java
+
+ HEAD
+
+
+
+
+
+ org.eclipse.m2e
+ lifecycle-mapping
+ 1.0.0
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-enforcer-plugin
+ [1.0.0,)
+
+ enforce
+
+
+
+
+
+
+
+
+
+
+
+ maven-clean-plugin
+ 3.0.0
+
+
+ maven-compiler-plugin
+ 3.5.1
+
+
+ ${jdk.version}
+
+
+
+ maven-dependency-plugin
+ 2.10
+
+
+ maven-jar-plugin
+ 3.0.2
+
+
+ maven-scm-plugin
+ 1.9.5
+
+
+ maven-source-plugin
+ 3.0.1
+
+
+ maven-failsafe-plugin
+ 2.19.1
+
+
+ net.sf
+ stat-scm
+ 1.2.0
+
+
+ org.jvnet.jaxb2.maven2
+ maven-jaxb2-plugin
+ 0.13.1
+
+
+ org.apache.maven.plugins
+ maven-release-plugin
+ 2.5.3
+
+ true
+ clean install
+ true
+
+ forked-path
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 2.10.4
+
+ 256m
+
+
+
+
+ org.apache.maven.plugins
+ maven-shade-plugin
+ 2.4.3
+
+
+ maven-assembly-plugin
+ 2.6
+
+
+ src/main/assembly/assembly.xml
+
+
+
+
+
+
+ assemble
+ package
+
+ single
+
+
+
+
+
+
+ org.codehaus.mojo
+ findbugs-maven-plugin
+ 3.0.4
+
+
+
+ org.codehaus.mojo
+ buildnumber-maven-plugin
+ 1.4
+
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+ 2.17
+
+
+
+ org.apache.maven.plugins
+ maven-resources-plugin
+ 3.0.1
+
+
+
+ maven-enforcer-plugin
+ 1.4.1
+
+
+ enforce-java
+
+ enforce
+
+
+
+
+ ${maven.enforcer.jdk-version}
+
+
+
+
+
+
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ cobertura-maven-plugin
+ 2.7
+
+ xml
+ 256m
+
+ true
+
+
+
+ org.eluder.coveralls
+ coveralls-maven-plugin
+ 4.2.0
+
+
+
+ org.sonatype.plugins
+ nexus-staging-maven-plugin
+ 1.6.7
+ true
+
+ ossrh
+ https://oss.sonatype.org/
+ true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+ maven-surefire-plugin
+ 2.19.1
+
+ -Xmx1800M
+ false
+ 1
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-jar-plugin
+
+
+
+ false
+
+ true
+ true
+
+
+
+ true
+ all-permissions
+ *
+ MMTF
+
+
+
+
+
+
+
+
+ org.codehaus.mojo
+ findbugs-maven-plugin
+
+
+ org.apache.maven.plugins
+ maven-checkstyle-plugin
+
+
+ false
+
+
+
+
+
+ com.versioneye
+ versioneye-maven-plugin
+ 3.10.2
+
+
+
+
+
+
+ org.apache.maven.wagon
+ wagon-ssh
+ 2.6
+
+
+
+
+
+
+ uk.co.jemos.podam
+ podam
+ 2.3.5.RELEASE
+ test
+
+
+ org.unitils
+ unitils-core
+ 3.4.2
+ test
+
+
+ junit
+ junit
+ 4.12
+ test
+
+
+ commons-beanutils
+ commons-beanutils
+ 1.9.2
+ test
+
+
+ org.slf4j
+ slf4j-api
+ ${slf4j.version}
+
+
+
+ org.apache.logging.log4j
+ log4j-slf4j-impl
+ ${log4j.version}
+
+ runtime
+
+
+
+ org.apache.logging.log4j
+ log4j-api
+ ${log4j.version}
+
+ runtime
+
+
+ org.apache.logging.log4j
+ log4j-core
+ ${log4j.version}
+
+ runtime
+
+
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-javadoc-plugin
+ 2.10.4
+
+ org.umlgraph.doclet.UmlGraphDoc
+
+ org.umlgraph
+ umlgraph
+ 5.6
+
+ -views -all
+ true
+
+
+
+ org.codehaus.mojo
+ findbugs-maven-plugin
+ 3.0.4
+
+
+
+
+
+
+
+ codesigning
+
+ false
+
+
+
+
+ org.apache.maven.plugins
+ maven-jarsigner-plugin
+ 1.4
+
+
+ sign
+
+ sign
+
+
+
+
+
+
+ true
+ true
+ ${keystore.type}
+ ${keystore.path}
+ ${keystore.alias}
+ ${keystore.store.password}
+ ${keystore.key.password}
+ ${project.build.directory}/${project.build.finalName}.jar
+ true
+ true
+ sign
+
+ -tsa
+ https://timestamp.geotrust.com/tsa
+
+
+
+
+
+
+
+ release-sign-artifacts
+
+
+ performRelease
+ true
+
+
+
+
+
+ org.apache.maven.plugins
+ maven-gpg-plugin
+ 1.6
+
+
+ sign-artifacts
+ verify
+
+ sign
+
+
+
+
+
+
+
+
+
+
+ mmtf-serialization
+ mmtf-api
+ mmtf-codec
+
+ 2015
+
+ Github
+ https://github.com/rcsb/mmtf-java/issues
+
+
+ Travis
+ https://travis-ci.org/
+
+