use of org.biojava.nbio.structure.EntityInfo in project mmtf-spark by sbl-sdsc.
the class MmtfImporter method toStructureDataInterface.
/**
* Parses PDB-formatted input stream and return structure data.
*
* @param inputStream PDB-formatted input stream
* @param structureId id to be assigned to the structure
* @return structure data
* @throws IOException
*/
private static AdapterToStructureData toStructureDataInterface(InputStream inputStream, String structureId) throws IOException {
// standardize PDB formatting
InputStream pdbIs = standardizePdbInputStream(inputStream);
// parse PDB and generate BioJava Structure object
PDBFileParser parser = new PDBFileParser();
parser.getFileParsingParameters().setCreateAtomBonds(true);
Structure struct = parser.parsePDBFile(pdbIs);
struct.setPDBCode(structureId);
// where the entity info is null when there is only one polymer chain.
for (EntityInfo info : struct.getEntityInfos()) {
if (info.getType() == null) {
for (String chainId : info.getChainIds()) {
Chain c = struct.getChain(chainId);
if (c.getAtomSequence().length() > 0) {
info.setType(EntityType.POLYMER);
}
}
}
}
pdbIs.close();
// convert to MMTF
AdapterToStructureData writerToEncoder = new AdapterToStructureData();
// TODO get version number
writerToEncoder.setMmtfProducer("mmtf-spark 0.2.0");
new MmtfStructureWriter(struct, writerToEncoder);
return writerToEncoder;
}
Aggregations