Search in sources :

Example 6 with AdapterToStructureData

use of org.rcsb.mmtf.encoder.AdapterToStructureData in project mmtf-spark by sbl-sdsc.

the class MmtfImporter method getFromPdbUrl.

/**
 * Reads a PDB file from a URL.
 *
 * @param uniProtId
 * @return
 * @throws IOException
 */
private static AdapterToStructureData getFromPdbUrl(String url, String structureId) throws IOException {
    URL u = new URL(url);
    InputStream is = null;
    try {
        is = u.openStream();
    } catch (IOException e) {
        return null;
    }
    AdapterToStructureData structure = toStructureDataInterface(is, structureId);
    is.close();
    return structure;
}
Also used : AdapterToStructureData(org.rcsb.mmtf.encoder.AdapterToStructureData) GZIPInputStream(java.util.zip.GZIPInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) URL(java.net.URL)

Example 7 with AdapterToStructureData

use of org.rcsb.mmtf.encoder.AdapterToStructureData in project mmtf-spark by sbl-sdsc.

the class MmtfImporter method getFromPdbFile.

/**
 * Reads a PDB file from a file system.
 *
 * @param
 * @return
 * @throws IOException
 */
private static AdapterToStructureData getFromPdbFile(File file, String structureId) throws IOException {
    AdapterToStructureData structure = null;
    InputStream is = null;
    String path = file.toString();
    if (path.endsWith(".pdb.gz") || path.endsWith(".ent.gz")) {
        is = new GZIPInputStream(new FileInputStream(file));
        structure = toStructureDataInterface(is, structureId);
    } else if (path.endsWith(".pdb") || path.endsWith(".ent")) {
        is = new FileInputStream(file);
        structure = toStructureDataInterface(is, structureId);
    } else {
        return null;
    }
    is.close();
    return structure;
}
Also used : GZIPInputStream(java.util.zip.GZIPInputStream) AdapterToStructureData(org.rcsb.mmtf.encoder.AdapterToStructureData) GZIPInputStream(java.util.zip.GZIPInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) FileInputStream(java.io.FileInputStream)

Example 8 with AdapterToStructureData

use of org.rcsb.mmtf.encoder.AdapterToStructureData in project mm-dev by sbl-sdsc.

the class MergeMmtf method MergeStructures.

public static StructureDataInterface MergeStructures(String structureId, StructureDataInterface... structures) {
    for (StructureDataInterface s : structures) {
        if (s.getNumModels() != 1) {
            throw new IllegalArgumentException("ERROR: Cannot merge structures with more than one model");
        }
    }
    AdapterToStructureData complex = new AdapterToStructureData();
    initStructure(structureId, structures, complex);
    addEntityInfo(structures, complex);
    for (StructureDataInterface structure : structures) {
        addStructure(structure, complex);
    }
    complex.finalizeStructure();
    return complex;
}
Also used : AdapterToStructureData(org.rcsb.mmtf.encoder.AdapterToStructureData) StructureDataInterface(org.rcsb.mmtf.api.StructureDataInterface)

Example 9 with AdapterToStructureData

use of org.rcsb.mmtf.encoder.AdapterToStructureData in project mm-dev by sbl-sdsc.

the class Molmporter method readFile.

public AdapterToStructureData readFile(String fileName) throws IOException {
    InputStream is = new FileInputStream(fileName);
    AdapterToStructureData structure = read(is, fileName);
    is.close();
    return structure;
}
Also used : AdapterToStructureData(org.rcsb.mmtf.encoder.AdapterToStructureData) FileInputStream(java.io.FileInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) FileInputStream(java.io.FileInputStream)

Example 10 with AdapterToStructureData

use of org.rcsb.mmtf.encoder.AdapterToStructureData in project mm-dev by sbl-sdsc.

the class Molmporter method readUrl.

public AdapterToStructureData readUrl(String url) throws IOException {
    URL u = new URL(url);
    InputStream is = null;
    try {
        is = u.openStream();
    } catch (IOException e) {
        return null;
    }
    AdapterToStructureData structure = read(is, url);
    return structure;
}
Also used : AdapterToStructureData(org.rcsb.mmtf.encoder.AdapterToStructureData) FileInputStream(java.io.FileInputStream) ByteArrayInputStream(java.io.ByteArrayInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) URL(java.net.URL)

Aggregations

AdapterToStructureData (org.rcsb.mmtf.encoder.AdapterToStructureData)14 ByteArrayInputStream (java.io.ByteArrayInputStream)7 FileInputStream (java.io.FileInputStream)7 InputStream (java.io.InputStream)7 StructureDataInterface (org.rcsb.mmtf.api.StructureDataInterface)7 IOException (java.io.IOException)5 GZIPInputStream (java.util.zip.GZIPInputStream)5 ArrayList (java.util.ArrayList)4 Tuple2 (scala.Tuple2)4 URL (java.net.URL)3 Structure (org.biojava.nbio.structure.Structure)3 MmtfStructureWriter (org.biojava.nbio.structure.io.mmtf.MmtfStructureWriter)3 HashMap (java.util.HashMap)2 Point3f (javax.vecmath.Point3f)2 FileParsingParameters (org.biojava.nbio.structure.io.FileParsingParameters)2 MMCIFFileReader (org.biojava.nbio.structure.io.MMCIFFileReader)2 File (java.io.File)1 HashSet (java.util.HashSet)1 Matrix4d (javax.vecmath.Matrix4d)1 Matrix4f (javax.vecmath.Matrix4f)1