use of org.rcsb.mmtf.api.StructureDataInterface in project mmtf-spark by sbl-sdsc.
the class PolymerComposition method call.
@Override
public Boolean call(Tuple2<String, StructureDataInterface> t) throws Exception {
StructureDataInterface structure = t._2;
boolean containsPolymer = false;
boolean globalMatch = false;
// only check first model
int numChains = structure.getChainsPerModel()[0];
for (int i = 0, groupCounter = 0; i < numChains; i++) {
boolean match = true;
String chainType = EncoderUtils.getTypeFromChainId(structure, i);
boolean polymer = chainType.equals("polymer");
if (polymer) {
containsPolymer = true;
} else {
match = false;
}
for (int j = 0; j < structure.getGroupsPerChain()[i]; j++, groupCounter++) {
if (match && polymer) {
int groupIndex = structure.getGroupTypeIndices()[groupCounter];
String name = structure.getGroupName(groupIndex);
match = residues.contains(name);
}
}
if (polymer && match && !exclusive) {
return true;
}
if (polymer && !match && exclusive) {
return false;
}
if (match) {
globalMatch = true;
}
}
return globalMatch && containsPolymer;
}
use of org.rcsb.mmtf.api.StructureDataInterface in project mmtf-spark by sbl-sdsc.
the class ContainsPolymerChainType method call.
@Override
public Boolean call(Tuple2<String, StructureDataInterface> t) throws Exception {
StructureDataInterface structure = t._2;
boolean containsPolymer = false;
boolean globalMatch = false;
// only check first model
int numChains = structure.getChainsPerModel()[0];
for (int i = 0, groupCounter = 0; i < numChains; i++) {
boolean match = true;
String chainType = EncoderUtils.getTypeFromChainId(structure, i);
boolean polymer = chainType.equals("polymer");
if (polymer) {
containsPolymer = true;
} else {
match = false;
}
for (int j = 0; j < structure.getGroupsPerChain()[i]; j++, groupCounter++) {
if (match && polymer) {
int groupIndex = structure.getGroupTypeIndices()[groupCounter];
String type = structure.getGroupChemCompType(groupIndex);
match = entityTypes.contains(type);
}
}
if (polymer && match && !exclusive) {
return true;
}
if (polymer && !match && exclusive) {
return false;
}
if (match) {
globalMatch = true;
}
}
return globalMatch && containsPolymer;
}
use of org.rcsb.mmtf.api.StructureDataInterface in project mmtf-spark by sbl-sdsc.
the class MmtfImporterTest method test3.
@Test
public void test3() throws IOException {
Path p = Paths.get("./src/main/resources/files/test");
JavaPairRDD<String, StructureDataInterface> pdb = MmtfImporter.importPdbFiles(p.toString(), sc);
assertTrue(pdb.count() == 1);
pdb = pdb.flatMapToPair(new StructureToPolymerChains());
assertEquals(8, pdb.count());
}
use of org.rcsb.mmtf.api.StructureDataInterface in project mmtf-spark by sbl-sdsc.
the class MmtfImporterTest method test4.
@Test
public void test4() throws IOException {
Path p = Paths.get("./src/main/resources/files/test");
JavaPairRDD<String, StructureDataInterface> pdb = MmtfImporter.importMmcifFiles(p.toString(), sc);
assertTrue(pdb.count() == 1);
pdb = pdb.flatMapToPair(new StructureToPolymerChains());
assertEquals(8, pdb.count());
}
use of org.rcsb.mmtf.api.StructureDataInterface in project mmtf-spark by sbl-sdsc.
the class MmtfImporterTest method test2.
@Test
public void test2() throws IOException {
Path p = Paths.get("./src/main/resources/files/");
JavaPairRDD<String, StructureDataInterface> pdb = MmtfImporter.importMmcifFiles(p.toString(), sc);
assertEquals(2, pdb.count());
}
Aggregations