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();
}
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();
}
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();
}
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();
}
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.");
}
Aggregations