Skip to content

Commit

Permalink
Merge 69fd815 into 2512f2e
Browse files Browse the repository at this point in the history
  • Loading branch information
abradle committed May 3, 2016
2 parents 2512f2e + 69fd815 commit a808813
Show file tree
Hide file tree
Showing 7 changed files with 184 additions and 19 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,36 @@ public interface StructureDataInterface {
/**
* Returns the sequence for the entity specified by the index.
* @param entityInd the index of the specified entity.
* @return the one letter sequence for this entity. Empty string if no sequence is applicable.
* @return the one letter sequence for this entity. Empty string
* if no sequence is applicable.
*/
String getEntitySequence(int entityInd);

/**
* Returns the entity description (as defined in mmCIF dictionary)
* for the entity specified by the chain index.
* @param chainInd the index of the specified chain
* @return the entity description
*/
String getChainEntityDescription(int chainInd);

/**
* Returns the entity type (polymer, non-polymer, water)
* for the entity specified by the chain index.
* @param chainInd the index of the specified chain
* @return the entity type (polymer, non-polymer, water) for
* the specified chain
*/
String getChainEntityType(int chainInd);

/**
* Returns the sequence for the entity specified by the chain index.
* @param chainInd the index of the specified chain
* @return the one letter sequence for this chain. Empty string if
* no sequence is applicable.
*/
String getChainEntitySequence(int chainInd);


/**
* Returns the identifier of the structure.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,9 @@
package org.rcsb.mmtf.decoder;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.rcsb.mmtf.api.StructureDataInterface;
import org.rcsb.mmtf.dataholders.BioAssemblyData;
Expand Down Expand Up @@ -104,6 +106,8 @@ public DefaultDecoder(MmtfStructure inputData) {
depositionDate = inputData.getDepositionDate();
releaseDate = inputData.getReleaseDate();
secStructInfo = ArrayConverters.convertByteToIntegers(inputData.getSecStructList());
// Now generate this map
generateChanEntityIndexMap();
}

/** The X coordinates */
Expand Down Expand Up @@ -205,7 +209,11 @@ public DefaultDecoder(MmtfStructure inputData) {
/** The release date of the structure */
private String releaseDate;

/** The secondary structure info */
private int[] secStructInfo;

/** The map of chain indices to the entity */
private Map<Integer, Integer> chainToEntityIndexMap;


@Override
Expand Down Expand Up @@ -490,5 +498,54 @@ public String getReleaseDate() {
return releaseDate;
}

@Override
public String getChainEntityDescription(int chainInd) {
if(chainToEntityIndexMap==null){
generateChanEntityIndexMap();
}
Integer entityInd = chainToEntityIndexMap.get(chainInd);
if(entityInd==null){
return null;
}
return getEntityDescription(entityInd);
}

@Override
public String getChainEntityType(int chainInd) {
if(chainToEntityIndexMap==null){
generateChanEntityIndexMap();
}
Integer entityInd = chainToEntityIndexMap.get(chainInd);
if(entityInd==null){
return null;
}
return getEntityType(entityInd);
}

@Override
public String getChainEntitySequence(int chainInd) {
if(chainToEntityIndexMap==null){
generateChanEntityIndexMap();
}
Integer entityInd = chainToEntityIndexMap.get(chainInd);
if(entityInd==null){
return null;
}
return getEntitySequence(entityInd);
}

/**
* Utility function to generate a map, mapping chain index to
* entity index.
*/
private void generateChanEntityIndexMap() {
chainToEntityIndexMap = new HashMap<>();
for(int i=0; i<entityList.length; i++) {
for(int chainInd : entityList[i].getChainIndexList()){
chainToEntityIndexMap.put(chainInd, i);
}
}
}


}
15 changes: 15 additions & 0 deletions mmtf-decoder/src/test/java/org/rcsb/mmtf/decoder/DummyApiImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -289,4 +289,19 @@ public int[] getSecStructList() {
return new int[numGroups];
}

@Override
public String getChainEntityDescription(int chainInd) {
return "DESC";
}

@Override
public String getChainEntityType(int chainInd) {
return "TYPE";
}

@Override
public String getChainEntitySequence(int chainInd) {
return "SEQUENCE";
}

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

import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;

import org.rcsb.mmtf.api.StructureDataInterface;
import org.rcsb.mmtf.api.StructureAdapterInterface;
Expand Down Expand Up @@ -124,26 +126,27 @@ public class AdapterToStructureData implements StructureDataInterface, Structure
private int[] secStructInfo;

/** The atom counter */
int atomIndex = 0;
private int atomIndex = 0;
/** The atom counter within a group*/
int groupAtomIndex = 0;
private int groupAtomIndex = 0;
/** The current group bond */
int groupBondIndex = 0;
private int groupBondIndex = 0;
/** The group counter */
int groupIndex = 0;
private int groupIndex = 0;
/** The chain counter */
int chainIndex = 0;
private int chainIndex = 0;
/** The model counter */
int modelIndex = 0;
/** The entity counter */
int entityIndex = 0;
private int modelIndex = 0;
/** Add the atom information for the current group */
Group pdbGroup;
private Group pdbGroup;
/** A List for Entities as the number of entities is not defined*/
List<Entity> entities;
int totalNumBonds;
List<Group> pdbGroupList;

private List<Entity> entities;
/** The total number of bonds*/
private int totalNumBonds;
/** The list of {@link Group} objects */
private List<Group> pdbGroupList;
/** The map of chain indices to the entity */
private Map<Integer, Integer> chainToEntityIndexMap;

@Override
public float[] getxCoords() {
Expand Down Expand Up @@ -404,6 +407,55 @@ public String getDepositionDate() {
return depositionDate;
}


@Override
public String getChainEntityDescription(int chainInd) {
if(chainToEntityIndexMap==null){
generateChanEntityIndexMap();
}
Integer entityInd = chainToEntityIndexMap.get(chainInd);
if(entityInd==null){
return null;
}
return getEntityDescription(entityInd);
}

@Override
public String getChainEntityType(int chainInd) {
if(chainToEntityIndexMap==null){
generateChanEntityIndexMap();
}
Integer entityInd = chainToEntityIndexMap.get(chainInd);
if(entityInd==null){
return null;
}
return getEntityType(entityInd);
}

@Override
public String getChainEntitySequence(int chainInd) {
if(chainToEntityIndexMap==null){
generateChanEntityIndexMap();
}
Integer entityInd = chainToEntityIndexMap.get(chainInd);
if(entityInd==null){
return null;
}
return getEntitySequence(entityInd);
}

/**
* Utility function to generate a map, mapping chain index to
* entity index.
*/
private void generateChanEntityIndexMap() {
chainToEntityIndexMap = new HashMap<>();
for(int i=0; i<entityList.length; i++) {
for(int chainInd : entityList[i].getChainIndexList()){
chainToEntityIndexMap.put(chainInd, i);
}
}
}

@Override
public void initStructure(int totalNumBonds, int totalNumAtoms, int totalNumGroups,
Expand Down Expand Up @@ -451,6 +503,8 @@ public void finalizeStructure() {
// Find the index of this groups information.
groupList[i] = groupMap.indexOf(pdbGroupList.get(i));
}
// Now generate this map
generateChanEntityIndexMap();
}

@Override
Expand All @@ -476,7 +530,6 @@ public void setEntityInfo(int[] chainIndices, String sequence, String descriptio
entity.setType(title);
// Add this entity
entities.add(entity);
entityIndex++;
}

@Override
Expand Down
13 changes: 13 additions & 0 deletions mmtf-encoder/src/test/java/org/rcsb/mmtf/encoder/DummyApiImpl.java
Original file line number Diff line number Diff line change
Expand Up @@ -289,5 +289,18 @@ public String getReleaseDate() {
public int[] getSecStructList() {
return new int[numGroups];
}
@Override
public String getChainEntityDescription(int chainInd) {
return "DESC";
}

@Override
public String getChainEntityType(int chainInd) {
return "TYPE";
}

@Override
public String getChainEntitySequence(int chainInd) {
return "SEQUENCE";
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ public void testEncodeAllFields() throws IOException {
*/
@Test
public void testWriter() throws IllegalAccessException, IllegalArgumentException, InvocationTargetException, IntrospectionException {
AdapterToStructureData AdapterToStructureData = getWriterEncoder();
ReflectionAssert.assertPropertiesNotNull("Some properties null after writing", AdapterToStructureData);
AdapterToStructureData adapterToStructureData = getWriterEncoder();
ReflectionAssert.assertPropertiesNotNull("Some properties null after writing", adapterToStructureData);
for(PropertyDescriptor propertyDescriptor :
Introspector.getBeanInfo(AdapterToStructureData.class).getPropertyDescriptors()){
if(propertyDescriptor.getReadMethod()!=null){
assertNotNull(propertyDescriptor.getReadMethod().invoke(AdapterToStructureData));
assertNotNull(propertyDescriptor.getReadMethod().invoke(adapterToStructureData));
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -309,7 +309,7 @@
<plugin>
<groupId>com.versioneye</groupId>
<artifactId>versioneye-maven-plugin</artifactId>
<version>3.9.1</version>
<version>3.9.2</version>
</plugin>

</plugins>
Expand Down

0 comments on commit a808813

Please sign in to comment.