Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,18 @@ public enum EntityType {
*/
POLYMER("polymer"),

/**
* The 'branched' type use mainly to represent carbohydrates.
* The type was introduced in these versions of the mmcif dictionary:
* 5.101 2012-08-22
* 5.291 2017-09-10
* 5.304 2018-08-01
* The type will only be used for PDB-deposited files from July 2020, as part of
* the carbohydrate remediation project.
* @since 5.4.0
*/
BRANCHED("branched"),

/**
* Non-polymeric entities: ligands, metal ions, buffer molecules, etc
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,10 @@ public void addChain(Chain c) {
logger.warn("Chain with asym id {} (author id {}) has entity type 'macrolide', considering it non-polymeric", c.getId(), c.getName());
nonPolyChains.add(c);

} else if (info.getType() == EntityType.BRANCHED) {
logger.warn("Chain with asym id {} (author id {}) has entity type 'branched', considering it non-polymeric", c.getId(), c.getName());
nonPolyChains.add(c);

} else {
logger.warn("Chain with asym id {} (author id {}) has unsupported entity type '{}'. Will not add it to the Structure.", c.getId(), c.getName(), info.getType().toString());
// ignore it
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,8 @@
import org.biojava.nbio.structure.quaternary.BioAssemblyInfo;
import org.rcsb.mmtf.api.StructureAdapterInterface;
import org.rcsb.mmtf.dataholders.MmtfStructure;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
* Class to take Biojava structure data and covert to the DataApi for encoding.
Expand All @@ -48,7 +50,9 @@
*/
public class MmtfStructureWriter {

private StructureAdapterInterface mmtfDecoderInterface;
private static final Logger logger = LoggerFactory.getLogger(MmtfStructureWriter.class);

private final StructureAdapterInterface mmtfDecoderInterface;

/**
* Pass data from Biojava structure to another generic output type. Loops through the data
Expand Down Expand Up @@ -179,9 +183,8 @@ private void storeEntityInformation(List<Chain> allChains, List<EntityInfo> enti
List<Chain> entityChains = entityInfo.getChains();
if (entityChains.isEmpty()){
// Error mapping chain to entity
System.err.println("ERROR MAPPING CHAIN TO ENTITY: "+description);
logger.error("ERROR MAPPING CHAIN TO ENTITY: "+description);
mmtfDecoderInterface.setEntityInfo(new int[0], "", description, type);
continue;
}
else{
int[] chainIndices = new int[entityChains.size()];
Expand All @@ -194,7 +197,7 @@ private void storeEntityInformation(List<Chain> allChains, List<EntityInfo> enti
chainImpl = (ChainImpl) entityChains.get(0);
}
else{
throw new RuntimeException();
throw new RuntimeException("Encountered Chain of unexpected type");
}
String sequence = chainImpl.getSeqResOneLetterSeq();
mmtfDecoderInterface.setEntityInfo(chainIndices, sequence, description, type);
Expand All @@ -205,8 +208,7 @@ private void storeEntityInformation(List<Chain> allChains, List<EntityInfo> enti

/**
* Generate the bioassembly information on in the desired form.
* @param bioJavaStruct the Biojava structure
* @param header the header
*
*/
private void storeBioassemblyInformation(Map<String, Integer> chainIdToIndexMap, Map<Integer, BioAssemblyInfo> inputBioAss) {
int bioAssemblyIndex = 0;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.List;
import java.util.zip.GZIPInputStream;

Expand Down Expand Up @@ -443,4 +444,35 @@ private static int[] countEntityTypes(List<EntityInfo> entities) {
return counts;

}

@Test
public void testStructureWithBranchedEntities() throws IOException {
// Example carbohydrate remediation file to be released in July 2020
URL url = new URL("https://raw.githubusercontent.com/pdbxmmcifwg/carbohydrate-extension/master/examples/models/1B5F-carb.cif");
InputStream inStream = url.openStream();

MMcifParser parser = new SimpleMMcifParser();

SimpleMMcifConsumer consumer = new SimpleMMcifConsumer();
parser.addMMcifConsumer(consumer);
parser.parse(new BufferedReader(new InputStreamReader(inStream)));

Structure structure = consumer.getStructure();

assertEquals(7, structure.getEntityInfos().size());

assertEquals(2, structure.getEntityById(1).getChains().size());
assertEquals(2, structure.getEntityById(2).getChains().size());

// we consider the branched chains non-poly chains
assertEquals(4, structure.getNonPolyChains().size());
assertEquals(4, structure.getPolyChains().size());

assertEquals(1, structure.getEntityById(3).getChains().size());

// chain asym_id="E" is from entity 3
assertSame(structure.getNonPolyChain("E"), structure.getEntityById(3).getChains().get(0));

assertEquals(5, structure.getNonPolyChain("E").getAtomGroups().size());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,11 @@
*/
package org.biojava.nbio.structure.io.mmtf;

import static org.junit.Assert.assertArrayEquals;
import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.URL;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
Expand All @@ -43,12 +42,17 @@
import org.biojava.nbio.structure.io.FileParsingParameters;
import org.biojava.nbio.structure.io.mmcif.ChemCompGroupFactory;
import org.biojava.nbio.structure.io.mmcif.DownloadChemCompProvider;
import org.biojava.nbio.structure.io.mmcif.MMcifParser;
import org.biojava.nbio.structure.io.mmcif.SimpleMMcifConsumer;
import org.biojava.nbio.structure.io.mmcif.SimpleMMcifParser;
import org.biojava.nbio.structure.quaternary.BioAssemblyInfo;
import org.biojava.nbio.structure.quaternary.BiologicalAssemblyTransformation;
import org.junit.Test;
import org.rcsb.mmtf.decoder.StructureDataToAdapter;
import org.rcsb.mmtf.encoder.AdapterToStructureData;

import static org.junit.Assert.*;

/**
* Tests to see if roundtripping of MMTF can be done.
*
Expand Down Expand Up @@ -350,4 +354,40 @@ private void checkBioAssemblies1(Structure structOne, Structure structTwo) throw
}
}
}

@Test
public void testStructWithBranchedEntitiesRoundTrip() throws IOException {
// Example carbohydrate remediation file to be released in July 2020
URL url = new URL("https://raw.githubusercontent.com/pdbxmmcifwg/carbohydrate-extension/master/examples/models/1B5F-carb.cif");
InputStream inStream = url.openStream();

MMcifParser parser = new SimpleMMcifParser();

SimpleMMcifConsumer consumer = new SimpleMMcifConsumer();
parser.addMMcifConsumer(consumer);
parser.parse(new BufferedReader(new InputStreamReader(inStream)));

Structure structure = consumer.getStructure();

AdapterToStructureData writerToEncoder = new AdapterToStructureData();
new MmtfStructureWriter(structure, writerToEncoder);
MmtfStructureReader mmtfStructureReader = new MmtfStructureReader();
new StructureDataToAdapter(writerToEncoder, mmtfStructureReader);
Structure structure2 = mmtfStructureReader.getStructure();

assertEquals(7, structure2.getEntityInfos().size());

assertEquals(2, structure2.getEntityById(1).getChains().size());
assertEquals(2, structure2.getEntityById(2).getChains().size());

assertEquals(4, structure2.getNonPolyChains().size());
assertEquals(4, structure2.getPolyChains().size());

assertEquals(1, structure2.getEntityById(3).getChains().size());

// chain asym_id="E" is from entity 3
assertSame(structure2.getNonPolyChain("E"), structure2.getEntityById(3).getChains().get(0));

assertEquals(5, structure2.getNonPolyChain("E").getAtomGroups().size());
}
}