Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed issues around reduced format #41

Merged
merged 10 commits into from
Jun 14, 2017
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ Quick getting started.

1) Get the data for a PDB structure and print the number of chains:
```java
StructureDataInterface dataInterface = new GenericDecoder(ReaderUtils.getDataFromUrl("4cup"));
StructureDataInterface dataInterface = new GenericDecoder(ReaderUtils.getDataFromUrl("4CUP"));
System.out.println("PDB Code: "+dataInterface.getStructureId()+" has "+dataInterface.getNumChains()+" chains");
```

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -66,12 +66,6 @@ public static void addXtalographicInfo(StructureDataInterface dataApi, Structure
*/
public static void addEntityInfo(StructureDataInterface dataApi, StructureAdapterInterface structInflator) {
for (int i=0; i<dataApi.getNumEntities(); i++) {
String[] chainIdList = new String[dataApi.getEntityChainIndexList(i).length];
int counter = 0;
for (int chainInd : dataApi.getEntityChainIndexList(i)) {
chainIdList[counter] = dataApi.getChainIds()[chainInd];
counter++;
}
structInflator.setEntityInfo(dataApi.getEntityChainIndexList(i), dataApi.getEntitySequence(i), dataApi.getEntityDescription(i), dataApi.getEntityType(i));
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package org.rcsb.mmtf.decoder;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

Expand All @@ -18,7 +19,8 @@
* @author Anthony Bradley
*
*/
public class GenericDecoder implements StructureDataInterface {
public class GenericDecoder implements StructureDataInterface, Serializable {
private static final long serialVersionUID = 1109812420718081496L;

/**
* Constructor for the default decoder.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,18 @@
package org.rcsb.mmtf.decoder;

import org.rcsb.mmtf.api.StructureDataInterface;

import java.io.Serializable;

import org.rcsb.mmtf.api.StructureAdapterInterface;

/**
* Pass data from a {@link StructureDataInterface} into a {@link StructureAdapterInterface}.
* @author Anthony Bradley
*
*/
public class StructureDataToAdapter {
public class StructureDataToAdapter implements Serializable {
private static final long serialVersionUID = 1304850018382353781L;

/** The struct inflator. */
private StructureAdapterInterface structInflator;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ public class AdapterToStructureData implements StructureDataInterface, Structure
/** The mmtf version */
private String mmtfVersion = MmtfStructure.VERSION;

/** The mmtf prodcuer */
/** The mmtf producer */
private String mmtfProducer = "UNKNOWN";

/** The list of entities in this structure. */
Expand Down Expand Up @@ -139,14 +139,15 @@ public class AdapterToStructureData implements StructureDataInterface, Structure
private int modelIndex = 0;
/** Add the atom information for the current group */
private Group pdbGroup;
/** A List for Entities as the number of entities is not defined*/
private List<Entity> entities;
/** The total number of bonds in the structure */
private int totalNumBonds;
/** The list of groups */
private List<Group> pdbGroupList;
/** The NCS operation matrix list */
private double[][] ncsOperMatrixList;

/** Temporary list of entities */
private transient List<Entity> entities;


@Override
Expand Down Expand Up @@ -413,48 +414,53 @@ public String getDepositionDate() {
public void initStructure(int totalNumBonds, int totalNumAtoms, int totalNumGroups,
int totalNumChains, int totalNumModels, String structureId) {
this.totalNumBonds = totalNumBonds;
// Intitialise the bond level info
// Initialize the bond level info
interGroupBondIndices = new ArrayList<>();
interGroupBondOrders = new ArrayList<>();
// Intitialise the atom level arrays
// Initialize the atom level arrays
cartnX = new float[totalNumAtoms];
cartnY= new float[totalNumAtoms];
cartnZ = new float[totalNumAtoms];
occupancy = new float[totalNumAtoms];
bFactor = new float[totalNumAtoms];
atomId = new int[totalNumAtoms];
altId = new char[totalNumAtoms];
// Initialise the group level data
// Initialize the group level data
groupNum = new int[totalNumGroups];
// List for storing the group level information
pdbGroupList = new ArrayList<>();
insertionCodeList = new char[totalNumGroups];
seqResGroupList = new int[totalNumGroups];
secStructInfo = new int[totalNumGroups];
// Intialise the chain level data
// List for storing the group level information
pdbGroupList = new ArrayList<>();
// Initialize the chain level data
chainList = new String[totalNumChains];
publicChainIds = new String[totalNumChains];
groupsPerChain = new int[totalNumChains];
// Initialise the model level information
// Initialize the model level information
numModels = totalNumModels;
// Set the name
pdbId = structureId;
bioAssembly = new ArrayList<>();
entities = new ArrayList<>();
chainsPerModel = new int[totalNumModels];

// temporary data structure
entities = new ArrayList<>();
}

@Override
public void finalizeStructure() {
// Convert the entities array to a list
entityList = entities.toArray(new Entity[0]);
// clear temporary data structure to avoid "memory leak"
entities.clear();

// Cleanup the group list
groupMap = new ArrayList<>(new HashSet<>(pdbGroupList));
groupList = new int[pdbGroupList.size()];
for(int i=0; i<pdbGroupList.size(); i++){
// Find the index of this groups information.
groupList[i] = groupMap.indexOf(pdbGroupList.get(i));
}
}
}

@Override
Expand Down Expand Up @@ -581,6 +587,10 @@ public void setHeaderInfo(float rFree, float rWork, float resolution, String tit


}

public void setMmtfProducer(String mmtfProducer) {
this.mmtfProducer = mmtfProducer;
}

private Group getGroup(int groupInd) {
return groupMap.get(groupInd);
Expand Down Expand Up @@ -612,5 +622,4 @@ public double[][] getNcsOperatorList() {
public String getBioassemblyName(int bioassemblyIndex) {
return bioAssembly.get(bioassemblyIndex).getName();
}

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package org.rcsb.mmtf.encoder;

import java.io.Serializable;

import org.rcsb.mmtf.api.StructureDataInterface;
import org.rcsb.mmtf.codec.CharCodecs;
import org.rcsb.mmtf.codec.FloatCodecs;
Expand All @@ -12,9 +14,8 @@
* @author Anthony Bradley
*
*/
public class GenericEncoder implements EncoderInterface {


public class GenericEncoder implements EncoderInterface, Serializable {
private static final long serialVersionUID = 4128892132322015448L;
private MmtfStructure mmtfBean;
private int coordDivider = MmtfStructure.COORD_DIVIDER;
private int bfactorOccDivider = MmtfStructure.OCCUPANCY_BFACTOR_DIVIDER;
Expand Down