use of org.biojava.nbio.structure.symmetry.geometry.DistanceBox in project mmtf-spark by sbl-sdsc.
the class StructureToProteinDimers method getAllAtomsDistanceBoxes.
private static List<DistanceBox<Integer>> getAllAtomsDistanceBoxes(List<StructureDataInterface> chains, double cutoffDistance) {
List<DistanceBox<Integer>> distanceBoxes = new ArrayList<DistanceBox<Integer>>();
for (int i = 0; i < chains.size(); i++) {
StructureDataInterface tmp = chains.get(i);
DistanceBox<Integer> newBox = new DistanceBox<Integer>(cutoffDistance);
// System.out.println(tmp.getNumAtoms());
for (int j = 0; j < tmp.getNumAtoms(); j++) {
double xCoord = tmp.getxCoords()[j];
double yCoord = tmp.getyCoords()[j];
double zCoord = tmp.getzCoords()[j];
Point3d newPoint = new Point3d(xCoord, yCoord, zCoord);
// System.out.println(newPoint);
newBox.addPoint(newPoint, j);
}
distanceBoxes.add(newBox);
}
return distanceBoxes;
}
use of org.biojava.nbio.structure.symmetry.geometry.DistanceBox in project mmtf-spark by sbl-sdsc.
the class StructureToProteinDimers method call.
@Override
public Iterator<Tuple2<String, StructureDataInterface>> call(Tuple2<String, StructureDataInterface> t) throws Exception {
StructureDataInterface structure = t._2;
List<Tuple2<String, StructureDataInterface>> resList = new ArrayList<>();
// split the structure into a list of structure of chains
List<StructureDataInterface> chains = splitToChains(structure);
List<Vector3d> chainVectors = getChainVectors(chains);
// for each chain, create a distance box
List<DistanceBox<Integer>> boxes;
if (useAllAtoms == true)
boxes = getAllAtomsDistanceBoxes(chains, cutoffDistance);
else
boxes = getCBetaAtomsDistanceBoxes(chains, cutoffDistance);
List<Vector3d> exclusiveList = new ArrayList<Vector3d>();
// loop through chains
for (int i = 0; i < chains.size(); i++) {
for (int j = 0; j < i; j++) {
// for each pair of chains, check if they are in contact or not
if (checkPair(boxes.get(i), boxes.get(j), chains.get(i), chains.get(j), cutoffDistance, contacts)) {
if (exclusive) {
// String es1 = chains.get(i).getEntitySequence(getChainToEntityIndex(chains.get(i))[0]);
// String es2 = chains.get(j).getEntitySequence(getChainToEntityIndex(chains.get(j))[0]);
Vector3d newVec = calcDiff(chainVectors.get(i), chainVectors.get(j));
// System.out.println(newVec);
if (!checkList(newVec, exclusiveList)) {
resList.add(combineChains(chains.get(i), chains.get(j)));
exclusiveList.add(newVec);
}
} else
resList.add(combineChains(chains.get(i), chains.get(j)));
}
}
}
// System.out.println(exclusiveList);
return resList.iterator();
}
use of org.biojava.nbio.structure.symmetry.geometry.DistanceBox in project mmtf-spark by sbl-sdsc.
the class StructureToAtomInteractions method getDistanceBox.
private DistanceBox<Integer> getDistanceBox(ColumnarStructure arrays) {
DistanceBox<Integer> box = new DistanceBox<>(filter.getDistanceCutoff());
float[] x = arrays.getxCoords();
float[] y = arrays.getyCoords();
float[] z = arrays.getzCoords();
String[] elements = arrays.getElements();
String[] groupNames = arrays.getGroupNames();
for (int i = 0; i < arrays.getNumAtoms(); i++) {
if (filter.isTargetGroup(groupNames[i]) && filter.isTargetElement(elements[i])) {
box.addPoint(new Point3d(x[i], y[i], z[i]), i);
}
}
return box;
}
use of org.biojava.nbio.structure.symmetry.geometry.DistanceBox in project mmtf-spark by sbl-sdsc.
the class StructureToProteinDimers method getCBetaAtomsDistanceBoxes.
private static List<DistanceBox<Integer>> getCBetaAtomsDistanceBoxes(List<StructureDataInterface> chains, double cutoffDistance) {
List<DistanceBox<Integer>> distanceBoxes = new ArrayList<DistanceBox<Integer>>();
for (int i = 0; i < chains.size(); i++) {
StructureDataInterface tmp = chains.get(i);
DistanceBox<Integer> newBox = new DistanceBox<Integer>(cutoffDistance);
int groupIndex = 0;
int atomIndex = 0;
for (int k = 0; k < tmp.getGroupsPerChain()[0]; k++) {
int groupType = tmp.getGroupTypeIndices()[groupIndex];
for (int m = 0; m < tmp.getNumAtomsInGroup(groupType); m++) {
String atomName = tmp.getGroupAtomNames(groupType)[m];
if (atomName.equals("CB")) {
double xCoord = tmp.getxCoords()[atomIndex];
double yCoord = tmp.getyCoords()[atomIndex];
double zCoord = tmp.getzCoords()[atomIndex];
Point3d newPoint = new Point3d(xCoord, yCoord, zCoord);
newBox.addPoint(newPoint, atomIndex);
}
atomIndex++;
}
groupIndex++;
}
distanceBoxes.add(newBox);
}
return distanceBoxes;
}
Aggregations