Search in sources :

Example 86 with StructureDataInterface

use of org.rcsb.mmtf.api.StructureDataInterface in project mmtf-spark by sbl-sdsc.

the class MmtfReaderTest method test2.

@Test
public void test2() throws IOException {
    Path p = Paths.get("./src/main/resources/files/test");
    JavaPairRDD<String, StructureDataInterface> pdb = MmtfReader.readMmtfFiles(p.toString(), sc);
    assertTrue(pdb.count() == 1);
    pdb = pdb.flatMapToPair(new StructureToPolymerChains());
    assertTrue(pdb.count() == 8);
}
Also used : Path(java.nio.file.Path) StructureToPolymerChains(edu.sdsc.mmtf.spark.mappers.StructureToPolymerChains) StructureDataInterface(org.rcsb.mmtf.api.StructureDataInterface) Test(org.junit.Test)

Example 87 with StructureDataInterface

use of org.rcsb.mmtf.api.StructureDataInterface in project mmtf-spark by sbl-sdsc.

the class StructureToBioJavaTest method test.

@Test
public void test() throws IOException {
    List<String> pdbIds = Arrays.asList("1STP", "4HHB", "1JLP", "5X6H", "5L2G", "2MK1");
    JavaPairRDD<String, StructureDataInterface> pdb = MmtfReader.downloadFullMmtfFiles(pdbIds, sc).cache();
    // 1STP: 1 L-protein chain:
    // 4HHB: 4 polymer chains
    // 1JLP: 1 L-protein chains with non-polymer capping group (NH2)
    // 5X6H: 1 L-protein and 1 DNA chain
    // 5L2G: 2 DNA chains
    // 2MK1: 0 polymer chains
    // --------------------
    // tot : 10 polymer chains
    JavaDoubleRDD chainCounts = pdb.mapValues(new StructureToBioJava()).values().mapToDouble(v -> v.getPolyChains().size());
    assertEquals(10, Math.round(chainCounts.sum()));
    // extract polymer chains and count chains again
    chainCounts = pdb.flatMapToPair(new StructureToPolymerChains()).mapValues(new StructureToBioJava()).values().mapToDouble(v -> v.getChains().size());
    assertEquals(10, Math.round(chainCounts.sum()));
}
Also used : Arrays(java.util.Arrays) SparkConf(org.apache.spark.SparkConf) JavaSparkContext(org.apache.spark.api.java.JavaSparkContext) IOException(java.io.IOException) Test(org.junit.Test) JavaPairRDD(org.apache.spark.api.java.JavaPairRDD) JavaDoubleRDD(org.apache.spark.api.java.JavaDoubleRDD) List(java.util.List) StructureDataInterface(org.rcsb.mmtf.api.StructureDataInterface) After(org.junit.After) MmtfReader(edu.sdsc.mmtf.spark.io.MmtfReader) Assert.assertEquals(org.junit.Assert.assertEquals) Before(org.junit.Before) StructureDataInterface(org.rcsb.mmtf.api.StructureDataInterface) JavaDoubleRDD(org.apache.spark.api.java.JavaDoubleRDD) Test(org.junit.Test)

Example 88 with StructureDataInterface

use of org.rcsb.mmtf.api.StructureDataInterface in project mmtf-spark by sbl-sdsc.

the class ColumnarStructureTest method testGetxCoords.

@Test
public void testGetxCoords() {
    StructureDataInterface s = pdb.values().first();
    ColumnarStructure cs = new ColumnarStructure(s, true);
    assertEquals(26.260, cs.getxCoords()[20], 0.001);
}
Also used : ColumnarStructure(edu.sdsc.mmtf.spark.utils.ColumnarStructure) StructureDataInterface(org.rcsb.mmtf.api.StructureDataInterface) Test(org.junit.Test)

Example 89 with StructureDataInterface

use of org.rcsb.mmtf.api.StructureDataInterface in project mmtf-spark by sbl-sdsc.

the class ColumnarStructureTest method testGetChainIds.

@Test
public void testGetChainIds() {
    StructureDataInterface s = pdb.values().first();
    ColumnarStructure cs = new ColumnarStructure(s, true);
    assertEquals("A", cs.getChainIds()[100]);
    // BTN
    assertEquals("B", cs.getChainIds()[901]);
    // HOH
    assertEquals("C", cs.getChainIds()[917]);
}
Also used : ColumnarStructure(edu.sdsc.mmtf.spark.utils.ColumnarStructure) StructureDataInterface(org.rcsb.mmtf.api.StructureDataInterface) Test(org.junit.Test)

Example 90 with StructureDataInterface

use of org.rcsb.mmtf.api.StructureDataInterface in project mmtf-spark by sbl-sdsc.

the class ColumnarStructureTest method testGetGroupNumbers.

@Test
public void testGetGroupNumbers() {
    StructureDataInterface s = pdb.values().first();
    ColumnarStructure cs = new ColumnarStructure(s, true);
    assertEquals("130", cs.getGroupNumbers()[877]);
}
Also used : ColumnarStructure(edu.sdsc.mmtf.spark.utils.ColumnarStructure) StructureDataInterface(org.rcsb.mmtf.api.StructureDataInterface) Test(org.junit.Test)

Aggregations

StructureDataInterface (org.rcsb.mmtf.api.StructureDataInterface)102 JavaSparkContext (org.apache.spark.api.java.JavaSparkContext)60 SparkConf (org.apache.spark.SparkConf)58 Row (org.apache.spark.sql.Row)27 StructureToPolymerChains (edu.sdsc.mmtf.spark.mappers.StructureToPolymerChains)22 Test (org.junit.Test)20 Pisces (edu.sdsc.mmtf.spark.webfilters.Pisces)19 ArrayList (java.util.ArrayList)12 ProteinSequenceEncoder (edu.sdsc.mmtf.spark.ml.ProteinSequenceEncoder)10 ColumnarStructure (edu.sdsc.mmtf.spark.utils.ColumnarStructure)10 Tuple2 (scala.Tuple2)9 Path (java.nio.file.Path)7 HashSet (java.util.HashSet)7 AdapterToStructureData (org.rcsb.mmtf.encoder.AdapterToStructureData)7 JavaPairRDD (org.apache.spark.api.java.JavaPairRDD)6 ContainsLProteinChain (edu.sdsc.mmtf.spark.filters.ContainsLProteinChain)5 List (java.util.List)5 Resolution (edu.sdsc.mmtf.spark.filters.Resolution)4 MmtfReader (edu.sdsc.mmtf.spark.io.MmtfReader)4 File (java.io.File)4