Search in sources :

Example 71 with StructureDataInterface

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

the class StructureToInteractingResidues method call.

@Override
public Iterator<Row> call(Tuple2<String, StructureDataInterface> t) throws Exception {
    String structureId = t._1;
    StructureDataInterface structure = t._2;
    List<Integer> groupIndices = new ArrayList<>();
    List<String> groupNames = new ArrayList<>();
    getGroupIndices(structure, groupIndices, groupNames);
    List<Row> neighbors = new ArrayList<>();
    for (int i = 0; i < groupNames.size(); i++) {
        if (groupNames.get(i).equals(groupName)) {
            List<Integer> matches = new ArrayList<>();
            float[] boundingBox = calcBoundingBox(structure, groupIndices, i, cutoffDistance);
            matches.addAll(findNeighbors(structure, i, boundingBox, groupIndices));
            neighbors.addAll(getDistanceProfile(structureId, matches, i, groupIndices, groupNames, structure));
        }
    }
    return neighbors.iterator();
}
Also used : ArrayList(java.util.ArrayList) StructureDataInterface(org.rcsb.mmtf.api.StructureDataInterface) Row(org.apache.spark.sql.Row)

Example 72 with StructureDataInterface

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

the class StructureToAllInteractions method call.

@Override
public Iterator<Row> call(Tuple2<String, StructureDataInterface> t) throws Exception {
    String structureId = t._1;
    StructureDataInterface structure = t._2;
    // get index to first atom in each group and group name
    List<Integer> groupIndices = new ArrayList<>();
    List<String> groupNames = new ArrayList<>();
    getGroupIndices(structure, groupIndices, groupNames);
    List<Row> interactions = new ArrayList<>();
    for (int i = 0; i < groupNames.size(); i++) {
        if (groupNames.get(i).equals(groupName)) {
            List<Integer> matches = new ArrayList<>();
            float[] boundingBox = calcBoundingBox(structure, groupIndices, i, cutoffDistance);
            matches.addAll(findNeighbors(structure, i, boundingBox, groupIndices));
            interactions.addAll(getDistanceProfile(structureId, matches, i, groupIndices, groupNames, structure));
        }
    }
    return interactions.iterator();
}
Also used : ArrayList(java.util.ArrayList) StructureDataInterface(org.rcsb.mmtf.api.StructureDataInterface) Row(org.apache.spark.sql.Row)

Example 73 with StructureDataInterface

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

the class DownloadMmtfFiles method main.

public static void main(String[] args) {
    // instantiate Spark. Each Spark application needs these two lines of code.
    SparkConf conf = new SparkConf().setMaster("local[*]").setAppName(DownloadMmtfFiles.class.getSimpleName());
    JavaSparkContext sc = new JavaSparkContext(conf);
    // download a list of PDB entries using mmtf web services
    List<String> pdbIds = Arrays.asList("1AQ1", "1B38", "1B39", "1BUH");
    JavaPairRDD<String, StructureDataInterface> pdb = MmtfReader.downloadReducedMmtfFiles(pdbIds, sc);
    System.out.println("# structures: " + pdb.count());
    // close Spark
    sc.close();
}
Also used : JavaSparkContext(org.apache.spark.api.java.JavaSparkContext) StructureDataInterface(org.rcsb.mmtf.api.StructureDataInterface) SparkConf(org.apache.spark.SparkConf)

Example 74 with StructureDataInterface

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

the class ReadLocalMmtf method main.

public static void main(String[] args) {
    if (args.length != 1) {
        System.err.println("Usage: " + ReadLocalMmtf.class.getSimpleName() + " <inputFilePath>");
        System.exit(1);
    }
    // instantiate Spark. Each Spark application needs these two lines of code.
    SparkConf conf = new SparkConf().setMaster("local[*]").setAppName(ReadLocalMmtf.class.getSimpleName());
    JavaSparkContext sc = new JavaSparkContext(conf);
    // read a local MMTF file
    JavaPairRDD<String, StructureDataInterface> pdb = MmtfReader.readMmtfFiles(args[0], sc);
    // print structural details
    pdb.foreach(t -> TraverseStructureHierarchy.printStructureData(t._2));
    System.out.println("# structures: " + pdb.count());
    // close Spark
    sc.close();
}
Also used : JavaSparkContext(org.apache.spark.api.java.JavaSparkContext) StructureDataInterface(org.rcsb.mmtf.api.StructureDataInterface) SparkConf(org.apache.spark.SparkConf)

Example 75 with StructureDataInterface

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

the class ReadMmtfFull method main.

public static void main(String[] args) throws FileNotFoundException {
    long start = System.nanoTime();
    // instantiate Spark. Each Spark application needs these two lines of code.
    SparkConf conf = new SparkConf().setMaster("local[*]").setAppName(ReadMmtfFull.class.getSimpleName());
    JavaSparkContext sc = new JavaSparkContext(conf);
    // read all PDB entries from a local Hadoop sequence file
    JavaPairRDD<String, StructureDataInterface> pdb = MmtfReader.readFullSequenceFile(sc);
    System.out.println("# structures: " + pdb.count());
    // close Spark
    sc.close();
    long end = System.nanoTime();
    System.out.println((end - start) / 1E9 + " sec.");
}
Also used : JavaSparkContext(org.apache.spark.api.java.JavaSparkContext) StructureDataInterface(org.rcsb.mmtf.api.StructureDataInterface) SparkConf(org.apache.spark.SparkConf)

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