Skip to content

Commit

Permalink
Refactoring of the names of the interfaces and decoder/encoder classes.
Browse files Browse the repository at this point in the history
  • Loading branch information
abradle committed Apr 13, 2016
1 parent db82cca commit 407e6d4
Show file tree
Hide file tree
Showing 9 changed files with 32 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*
* @author Anthony Bradley
*/
public interface MmtfDecoderInterface {
public interface DataTransferInterface {

/**
* Used before any additions to do any required pre-processing.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
* @author Anthony Bradley
* @author Jose Duarte
*/
public interface MmtfDecodedDataInterface {
public interface DecodedDataInterface {

/**
* Returns an array containing the X coordinates of the atoms in Angstroms.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,22 +3,22 @@
import java.util.HashSet;
import java.util.Set;

import org.rcsb.mmtf.api.MmtfDecodedDataInterface;
import org.rcsb.mmtf.api.MmtfDecoderInterface;
import org.rcsb.mmtf.api.DecodedDataInterface;
import org.rcsb.mmtf.api.DataTransferInterface;

/**
* Decode an MMTF structure using a structure inflator.
* The class also allows access to the unconsumed but parsed and inflated underlying data.
* @author Anthony Bradley
*
*/
public class DataApiToReader {
public class DecoderToReader {

/** The struct inflator. */
private MmtfDecoderInterface structInflator;
private DataTransferInterface structInflator;

/** The api to the data */
private MmtfDecodedDataInterface dataApi;
private DecodedDataInterface dataApi;

// Intialises the counters.
private int modelCounter = 0;
Expand All @@ -28,14 +28,14 @@ public class DataApiToReader {
private int currentAtomIndex = 0;
private Set<String> chainIdSet;

public DataApiToReader(){
public DecoderToReader(){

}

/**
* Passes data from the data interface to the inflator interface.
*/
public void read(MmtfDecodedDataInterface inputApi, MmtfDecoderInterface inputInflator){
public void read(DecodedDataInterface inputApi, DataTransferInterface inputInflator){
// Set the api and the inflator
dataApi = inputApi;
structInflator = inputInflator;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
package org.rcsb.mmtf.decoder;

import org.rcsb.mmtf.api.MmtfDecodedDataInterface;
import org.rcsb.mmtf.api.MmtfDecoderInterface;
import org.rcsb.mmtf.api.DecodedDataInterface;
import org.rcsb.mmtf.api.DataTransferInterface;

public class DecoderUtils {

/**
* Parses the bioassembly data and inputs it to the structure inflator
*/
public static void generateBioAssembly(MmtfDecodedDataInterface dataApi, MmtfDecoderInterface structInflator) {
public static void generateBioAssembly(DecodedDataInterface dataApi, DataTransferInterface structInflator) {
for (int i=0; i<dataApi.getNumBioassemblies(); i++) {
for(int j=0; j<dataApi.getNumTransInBioassembly(i); j++) {
structInflator.setBioAssemblyTrans(i+1, dataApi.getChainIndexListForTransform(i, j), dataApi.getMatrixForTransform(i,j));
Expand All @@ -20,7 +20,7 @@ public static void generateBioAssembly(MmtfDecodedDataInterface dataApi, MmtfDec
* Generate inter group bonds
* Bond indices are specified within the whole structure and start at 0.
*/
public static void addInterGroupBonds(MmtfDecodedDataInterface dataApi, MmtfDecoderInterface structInflator) {
public static void addInterGroupBonds(DecodedDataInterface dataApi, DataTransferInterface structInflator) {
for (int i = 0; i < dataApi.getInterGroupBondOrders().length; i++) {
structInflator.setInterGroupBond(dataApi.getInterGroupBondIndices()[i * 2],
dataApi.getInterGroupBondIndices()[i * 2 + 1], dataApi.getInterGroupBondOrders()[i]);
Expand All @@ -30,7 +30,7 @@ public static void addInterGroupBonds(MmtfDecodedDataInterface dataApi, MmtfDeco
/**
* Add ancilliary header information to the structure
*/
public static void addHeaderInfo(MmtfDecodedDataInterface dataApi, MmtfDecoderInterface structInflator) {
public static void addHeaderInfo(DecodedDataInterface dataApi, DataTransferInterface structInflator) {
structInflator.setHeaderInfo(dataApi.getRfree(),dataApi.getRwork(), dataApi.getResolution(),
dataApi.getTitle(), dataApi.getDepositionDate(), dataApi.getReleaseDate(), dataApi.getExperimentalMethods());
}
Expand All @@ -41,7 +41,7 @@ public static void addHeaderInfo(MmtfDecodedDataInterface dataApi, MmtfDecoderIn
* @param dataApi
* @param structInflator
*/
public static void addXtalographicInfo(MmtfDecodedDataInterface dataApi, MmtfDecoderInterface structInflator) {
public static void addXtalographicInfo(DecodedDataInterface dataApi, DataTransferInterface structInflator) {
if(dataApi.getUnitCell()!=null){
structInflator.setXtalInfo(dataApi.getSpaceGroup(), dataApi.getUnitCell());
}
Expand All @@ -52,7 +52,7 @@ public static void addXtalographicInfo(MmtfDecodedDataInterface dataApi, MmtfDec
* @param dataApi
* @param structInflator
*/
public static void addEntityInfo(MmtfDecodedDataInterface dataApi, MmtfDecoderInterface structInflator) {
public static void addEntityInfo(DecodedDataInterface dataApi, DataTransferInterface structInflator) {
for (int i=0; i<dataApi.getNumEntities(); i++) {
String[] chainIdList = new String[dataApi.getEntityChainIndexList(i).length];
int counter = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import java.util.ArrayList;
import java.util.List;

import org.rcsb.mmtf.api.MmtfDecodedDataInterface;
import org.rcsb.mmtf.api.DecodedDataInterface;
import org.rcsb.mmtf.dataholders.BioAssemblyData;
import org.rcsb.mmtf.dataholders.Entity;
import org.rcsb.mmtf.dataholders.MmtfBean;
Expand All @@ -15,9 +15,9 @@
* @author Anthony Bradley
*
*/
public class BeanToDataApi implements MmtfDecodedDataInterface {
public class DefaultDecoder implements DecodedDataInterface {

public BeanToDataApi(MmtfBean inputData) throws IOException {
public DefaultDecoder(MmtfBean inputData) throws IOException {
groupList = ArrayConverters.convertFourByteToIntegers(inputData.getGroupTypeList());
// Decode the coordinate and B-factor arrays.
cartnX = ArrayConverters.convertIntsToFloats(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.io.IOException;
import java.util.List;

import org.rcsb.mmtf.api.MmtfDecodedDataInterface;
import org.rcsb.mmtf.api.DecodedDataInterface;
import org.rcsb.mmtf.dataholders.MmtfBean;
import org.rcsb.mmtf.encoder.ArrayConverters;
import org.rcsb.mmtf.encoder.ArrayEncoders;
Expand All @@ -14,11 +14,11 @@
* @author Anthony Bradley
*
*/
public class DataApiToBean {
public class DefaultEncoder {

private MmtfBean mmtfBean;

public DataApiToBean(MmtfDecodedDataInterface mmtfDecodedDataInterface) throws IOException {
public DefaultEncoder(DecodedDataInterface mmtfDecodedDataInterface) throws IOException {
mmtfBean = new MmtfBean();
// Set the group types
mmtfBean.setGroupTypeList(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import java.util.ArrayList;
import java.util.List;

import org.rcsb.mmtf.api.MmtfDecodedDataInterface;
import org.rcsb.mmtf.api.DecodedDataInterface;
import org.rcsb.mmtf.dataholders.BioAssemblyData;
import org.rcsb.mmtf.dataholders.BioAssemblyTrans;
import org.rcsb.mmtf.dataholders.Entity;
Expand All @@ -17,7 +17,7 @@ public class EncoderUtils {
* @param mmtfDecodedDataInterface the input interface
* @return a list of all the groups in the molecule
*/
public static PDBGroup[] generateGroupMap(MmtfDecodedDataInterface mmtfDecodedDataInterface) {
public static PDBGroup[] generateGroupMap(DecodedDataInterface mmtfDecodedDataInterface) {
int[] groupTypeIndices = mmtfDecodedDataInterface.getGroupTypeIndices();
int maxIndex = CodecUtils.findMaxInIntArray(groupTypeIndices);
PDBGroup[] outGroupList = new PDBGroup[maxIndex+1];
Expand All @@ -42,7 +42,7 @@ public static PDBGroup[] generateGroupMap(MmtfDecodedDataInterface mmtfDecodedDa
* @param mmtfDecodedDataInterface the interface from where to find the data
* @return a list of bioassembly information
*/
public static List<BioAssemblyData> generateBioassemblies(MmtfDecodedDataInterface mmtfDecodedDataInterface) {
public static List<BioAssemblyData> generateBioassemblies(DecodedDataInterface mmtfDecodedDataInterface) {
int numBioassemblies = mmtfDecodedDataInterface.getNumBioassemblies();
List<BioAssemblyData> outList = new ArrayList<>();
for (int i=0; i<numBioassemblies; i++) {
Expand All @@ -68,7 +68,7 @@ public static List<BioAssemblyData> generateBioassemblies(MmtfDecodedDataInterfa
* @param mmtfDecodedDataInterface the input interface
* @return the list of entities
*/
public static Entity[] generateEntityList(MmtfDecodedDataInterface mmtfDecodedDataInterface) {
public static Entity[] generateEntityList(DecodedDataInterface mmtfDecodedDataInterface) {
int numEntities = mmtfDecodedDataInterface.getNumEntities();
Entity[] outList = new Entity[numEntities];
for (int i=0; i<numEntities;i++) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
import java.util.HashSet;
import java.util.List;

import org.rcsb.mmtf.api.MmtfDecodedDataInterface;
import org.rcsb.mmtf.api.MmtfDecoderInterface;
import org.rcsb.mmtf.api.DecodedDataInterface;
import org.rcsb.mmtf.api.DataTransferInterface;
import org.rcsb.mmtf.dataholders.BioAssemblyData;
import org.rcsb.mmtf.dataholders.BioAssemblyTrans;
import org.rcsb.mmtf.dataholders.Entity;
Expand All @@ -17,7 +17,7 @@
* @author Anthony Bradley
*
*/
public class WriterToDataApi implements MmtfDecodedDataInterface, MmtfDecoderInterface {
public class WriterToEncoder implements DecodedDataInterface, DataTransferInterface {


/** The X coordinates */
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,18 +13,18 @@ public class WriterUtils {
* @param path
* @throws IOException
*/
public static void writeDataToFile(WriterToDataApi inflatorToGet, String path) throws IOException {
public static void writeDataToFile(WriterToEncoder inflatorToGet, String path) throws IOException {
byte[] byteArray = getDataAsByteArr(inflatorToGet);
FileOutputStream fos = new FileOutputStream(path);
fos.write(byteArray);
fos.close();
}


public static byte[] getDataAsByteArr(WriterToDataApi inflatorToGet) throws IOException {
public static byte[] getDataAsByteArr(WriterToEncoder inflatorToGet) throws IOException {
MessagePackSerializer messagePackSerializer = new MessagePackSerializer();
// Get to bean
DataApiToBean getToBean = new DataApiToBean(inflatorToGet);
DefaultEncoder getToBean = new DefaultEncoder(inflatorToGet);
return messagePackSerializer.serialize(getToBean.getMmtfBean());
}

Expand Down

0 comments on commit 407e6d4

Please sign in to comment.