Search in sources :

Example 1 with Chain

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;
}
Also used : Chain(org.biojava.nbio.structure.Chain) AdapterToStructureData(org.rcsb.mmtf.encoder.AdapterToStructureData) GZIPInputStream(java.util.zip.GZIPInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) EntityInfo(org.biojava.nbio.structure.EntityInfo) PDBFileParser(org.biojava.nbio.structure.io.PDBFileParser) Structure(org.biojava.nbio.structure.Structure) MmtfStructureWriter(org.biojava.nbio.structure.io.mmtf.MmtfStructureWriter)

Example 2 with Chain

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;
}
Also used : Chain(org.biojava.nbio.structure.Chain) AFPChain(org.biojava.nbio.structure.align.model.AFPChain) Group(org.biojava.nbio.structure.Group) ChainImpl(org.biojava.nbio.structure.ChainImpl) AtomImpl(org.biojava.nbio.structure.AtomImpl) AminoAcidImpl(org.biojava.nbio.structure.AminoAcidImpl) Atom(org.biojava.nbio.structure.Atom)

Aggregations

Chain (org.biojava.nbio.structure.Chain)2 ByteArrayInputStream (java.io.ByteArrayInputStream)1 FileInputStream (java.io.FileInputStream)1 InputStream (java.io.InputStream)1 GZIPInputStream (java.util.zip.GZIPInputStream)1 AminoAcidImpl (org.biojava.nbio.structure.AminoAcidImpl)1 Atom (org.biojava.nbio.structure.Atom)1 AtomImpl (org.biojava.nbio.structure.AtomImpl)1 ChainImpl (org.biojava.nbio.structure.ChainImpl)1 EntityInfo (org.biojava.nbio.structure.EntityInfo)1 Group (org.biojava.nbio.structure.Group)1 Structure (org.biojava.nbio.structure.Structure)1 AFPChain (org.biojava.nbio.structure.align.model.AFPChain)1 PDBFileParser (org.biojava.nbio.structure.io.PDBFileParser)1 MmtfStructureWriter (org.biojava.nbio.structure.io.mmtf.MmtfStructureWriter)1 AdapterToStructureData (org.rcsb.mmtf.encoder.AdapterToStructureData)1