Skip to content

Commit

Permalink
Updates and refactoring to the encoder to fix data inconsistencies in…
Browse files Browse the repository at this point in the history
… writer
  • Loading branch information
abradle committed Apr 13, 2016
1 parent ddb0955 commit eb712d5
Show file tree
Hide file tree
Showing 12 changed files with 39 additions and 19 deletions.
Expand Up @@ -47,9 +47,9 @@ void initStructure(int totalNumBonds, int totalNumAtoms, int totalNumGroups, int
* @param chainIndices the indices of the chain this refers to.
* @param sequence the full sequence of the entity
* @param description the text description of the entity
* @param title
* @param type as a string (POLYMER/NON-POLYMER and WATER)
*/
void setEntityInfo(int[] chainIndices, String sequence, String description, String title);
void setEntityInfo(int[] chainIndices, String sequence, String description, String type);

/**
* Sets the information for a given group / residue with atomic data.
Expand Down
12 changes: 12 additions & 0 deletions mmtf-common/pom.xml
Expand Up @@ -26,6 +26,18 @@
<groupId>junit</groupId>
<artifactId>junit</artifactId>
</dependency>
<dependency>
<groupId>uk.co.jemos.podam</groupId>
<artifactId>podam</artifactId>
</dependency>
<dependency>
<groupId>org.unitils</groupId>
<artifactId>unitils-core</artifactId>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
</dependency>
</dependencies>
<build>
<plugins>
Expand Down
Expand Up @@ -24,7 +24,6 @@ public class Entity implements Serializable {
private String sequence;



public String getDescription() {
return description;
}
Expand Down
1 change: 0 additions & 1 deletion mmtf-decoder/pom.xml
Expand Up @@ -20,7 +20,6 @@
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.3</version>
</dependency>
<dependency>
<groupId>org.rcsb</groupId>
Expand Down
Expand Up @@ -70,8 +70,10 @@ public DefaultDecoder(MmtfBean inputData) throws IOException {
// Get the group map (all the unique groups in the structure).
groupMap = inputData.getGroupList();
// Get the seqRes groups
seqResGroupList = ArrayConverters.convertFourByteToIntegers(
inputData.getSequenceIndexList());
seqResGroupList = ArrayDecoders.deltaDecode(
ArrayDecoders.runlengthDecode(
ArrayConverters.convertFourByteToIntegers(
inputData.getSequenceIndexList())));
// Get the number of chains per model
chainsPerModel = inputData.getChainsPerModel();
groupsPerChain = inputData.getGroupsPerChain();
Expand All @@ -97,7 +99,7 @@ public DefaultDecoder(MmtfBean inputData) throws IOException {
// Now get the relase information
depositionDate = inputData.getDepositionDate();
releaseDate = inputData.getReleaseDate();
secStructInfo = ArrayConverters.convertFourByteToIntegers(inputData.getSecStructList());
secStructInfo = ArrayConverters.convertByteToIntegers(inputData.getSecStructList());
}

/** The X coordinates */
Expand Down Expand Up @@ -195,10 +197,10 @@ public DefaultDecoder(MmtfBean inputData) throws IOException {

/** The deposition date of the structure */
private String depositionDate;

/** The release date of the structure */
private String releaseDate;

private int[] secStructInfo;


Expand Down
Expand Up @@ -2,7 +2,6 @@

import java.io.IOException;

import org.junit.Before;
import org.junit.Test;
import org.rcsb.mmtf.api.DataTransferInterface;
import org.rcsb.mmtf.dataholders.MmtfBean;
Expand Down
1 change: 0 additions & 1 deletion mmtf-encoder/pom.xml
Expand Up @@ -68,7 +68,6 @@
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.8.3</version>
</dependency>
</dependencies>
<reporting>
Expand Down
Expand Up @@ -73,12 +73,12 @@ public DefaultEncoder(DecodedDataInterface decodedDataInterface) throws IOExcept
// Run length encoded
mmtfBean.setAltLocList(ArrayConverters.convertIntegersToFourByte(
ArrayEncoders.runlengthEncode(
ArrayConverters.convertCharToIntegers(
decodedDataInterface.getAltLocIds()))));
ArrayConverters.convertCharToIntegers(
decodedDataInterface.getAltLocIds()))));
mmtfBean.setInsCodeList(ArrayConverters.convertIntegersToFourByte(
ArrayEncoders.runlengthEncode(
ArrayConverters.convertCharToIntegers(
decodedDataInterface.getInsCodes()))));
ArrayConverters.convertCharToIntegers(
decodedDataInterface.getInsCodes()))));

// Set the groupNumber
mmtfBean.setGroupIdList(ArrayConverters.convertIntegersToFourByte(
Expand All @@ -90,7 +90,9 @@ public DefaultEncoder(DecodedDataInterface decodedDataInterface) throws IOExcept
mmtfBean.setGroupList(EncoderUtils.generateGroupMap(decodedDataInterface));
// Set the indices for the groups mapping to the sequence
mmtfBean.setSequenceIndexList(ArrayConverters.convertIntegersToFourByte(
decodedDataInterface.getGroupSequenceIndices()));
ArrayEncoders.runlengthEncode(
ArrayEncoders.deltaEncode(
decodedDataInterface.getGroupSequenceIndices()))));
// Set the number of chains per model
mmtfBean.setChainsPerModel(decodedDataInterface.getChainsPerModel());
mmtfBean.setGroupsPerChain(decodedDataInterface.getGroupsPerChain());
Expand Down Expand Up @@ -124,7 +126,7 @@ public DefaultEncoder(DecodedDataInterface decodedDataInterface) throws IOExcept
mmtfBean.setExperimentalMethods(decodedDataInterface.getExperimentalMethods());
mmtfBean.setDepositionDate(decodedDataInterface.getDepositionDate());
mmtfBean.setReleaseDate(decodedDataInterface.getReleaseDate());
mmtfBean.setSecStructList(ArrayConverters.convertIntegersToFourByte(decodedDataInterface.getSecStructList()));
mmtfBean.setSecStructList(ArrayConverters.convertIntegersToBytes(decodedDataInterface.getSecStructList()));
}

public MmtfBean getMmtfBean() {
Expand Down
Expand Up @@ -491,7 +491,7 @@ public void setGroupInfo(String groupName, int groupNumber, char insertionCode,
pdbGroup.setChemCompType(polymerType);
pdbGroup.setElementList(new String[atomCount]);
pdbGroup.setGroupName(groupName);
pdbGroup.setSingleLetterCode(insertionCode);
pdbGroup.setSingleLetterCode(singleAtomCode);
groupAtomIndex=0;
groupBondIndex=0;
// Store the group level data
Expand Down
Expand Up @@ -3,6 +3,7 @@
import org.msgpack.jackson.dataformat.MessagePackFactory;
import org.rcsb.mmtf.dataholders.MmtfBean;

import com.fasterxml.jackson.annotation.JsonInclude.Include;
import com.fasterxml.jackson.core.JsonProcessingException;
import com.fasterxml.jackson.databind.ObjectMapper;

Expand All @@ -15,7 +16,9 @@
public class MessagePackSerializer {

public byte[] serialize(MmtfBean object) {

ObjectMapper objectMapper = new ObjectMapper(new MessagePackFactory());
objectMapper.setSerializationInclusion(Include.NON_NULL);
byte[] byteArray;
try {
byteArray = objectMapper.writeValueAsBytes(object);
Expand Down
Expand Up @@ -18,7 +18,6 @@ public void testEncodeAllFields() throws IOException {
DummyApiImpl dummyApiImpl = new DummyApiImpl();
DefaultEncoder defaultEncoder = new DefaultEncoder(dummyApiImpl);
ReflectionAssert.assertPropertiesNotNull("Some properties null after encoding", defaultEncoder.getMmtfBean());

}


Expand Down
6 changes: 6 additions & 0 deletions pom.xml
Expand Up @@ -345,6 +345,12 @@
<version>4.12</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>commons-beanutils</groupId>
<artifactId>commons-beanutils</artifactId>
<version>1.9.2</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>
Expand Down

0 comments on commit eb712d5

Please sign in to comment.