use of org.biojava.nbio.structure.Chain 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;
}
use of org.biojava.nbio.structure.Chain in project mm-dev by sbl-sdsc.
the class BiojavaAligner method getCAAtoms.
/**
* Converts an array of points representing C-alpha position to a minimal BioJava data structure.
*
* @param points coordinates of C-alpha atoms
* @return BioJava atom array
*/
private static Atom[] getCAAtoms(Point3d[] points) {
Chain c = new ChainImpl();
c.setId("A");
// create dummy BioJava atoms for each C-alpha coordinate
Atom[] atoms = new Atom[points.length];
for (int i = 0; i < points.length; i++) {
atoms[i] = new AtomImpl();
atoms[i].setName(CA_NAME);
Group g = new AminoAcidImpl();
g.setPDBName(GROUP_NAME);
g.setResidueNumber("A", i, ' ');
g.addAtom(atoms[i]);
c.addGroup(g);
atoms[i].setX(points[i].x);
atoms[i].setY(points[i].y);
atoms[i].setZ(points[i].z);
}
return atoms;
}
Aggregations