use of org.openrdf.model.Resource in project vcell by virtualcell.
the class ModelComparer method recordIfBlankNode.
private void recordIfBlankNode(Value node, Statement statement, Set<Resource> bNodes, MultiMap<Resource, Statement> triples) {
if (node instanceof BNode) {
Resource resource = (Resource) node;
bNodes.add(resource);
triples.add(resource, statement);
}
}
use of org.openrdf.model.Resource in project vcell by virtualcell.
the class RDFObjectCompositePool method getPrimaryResource.
public Resource getPrimaryResource(T object) {
Class<T1> createdClass1 = pool1.getCreatedClass();
if (createdClass1.isInstance(object)) {
T1 object1 = createdClass1.cast(object);
Resource primaryResource = pool1.getPrimaryResource(object1);
if (primaryResource != null) {
return primaryResource;
}
}
Class<T2> createdClass2 = pool2.getCreatedClass();
if (createdClass2.isInstance(object)) {
T2 object2 = createdClass2.cast(object);
Resource primaryResource = pool2.getPrimaryResource(object2);
if (primaryResource != null) {
return primaryResource;
}
}
return null;
}
use of org.openrdf.model.Resource in project vcell by virtualcell.
the class RDFObjectSimplePool method remove.
public void remove(T object) {
Set<Resource> resourcesToDelete = new HashSet<Resource>();
Set<Resource> resources = object2resources.get(object);
if (resources != null) {
object2resources.remove(object);
resourcesToDelete.addAll(resources);
}
Resource primaryResource = object2primaryResource.get(object);
if (primaryResource != null) {
object2primaryResource.remove(object);
resourcesToDelete.add(primaryResource);
}
for (Resource resourceToDelete : resourcesToDelete) {
resource2object.remove(resourceToDelete);
}
}
use of org.openrdf.model.Resource in project vcell by virtualcell.
the class RDFResourceProjection method project.
public URI project(URI property) {
Resource resourceMapped = map.get(property);
URI propertyMapped = property;
if (resourceMapped instanceof URI) {
propertyMapped = (URI) resourceMapped;
}
return propertyMapped;
}
use of org.openrdf.model.Resource in project vcell by virtualcell.
the class UniProtExtractor method extractBox.
public UniProtBox extractBox() {
UniProtBoxImp box = new UniProtBoxImp();
Iterator<Statement> stmtIter1 = model.match(null, UniProtConstants.replaces, null);
while (stmtIter1.hasNext()) {
Statement statement = stmtIter1.next();
Resource subject = statement.getSubject();
Value object = statement.getObject();
if (subject instanceof URI && object instanceof URI) {
String idSubject = id((URI) subject);
String idObject = id((URI) object);
if (StringUtil.notEmpty(idSubject) && StringUtil.notEmpty(idObject)) {
UniProtBox.Entry entrySubject = box.entry(idSubject);
UniProtBox.Entry entryObject = box.entry(idObject);
box.setReplaces(entrySubject, entryObject);
}
}
}
Iterator<Statement> stmtIter2 = model.match(null, UniProtConstants.replacedBy, null);
while (stmtIter2.hasNext()) {
Statement statement = stmtIter2.next();
Resource subject = statement.getSubject();
Value object = statement.getObject();
if (subject instanceof URI && object instanceof URI) {
String idSubject = id((URI) subject);
String idObject = id((URI) object);
if (StringUtil.notEmpty(idSubject) && StringUtil.notEmpty(idObject)) {
UniProtBox.Entry entrySubject = box.entry(idSubject);
UniProtBox.Entry entryObject = box.entry(idObject);
box.setReplaces(entryObject, entrySubject);
}
}
}
Iterator<Statement> stmtIter3 = model.match(null, UniProtConstants.recommendedName, null);
if (stmtIter3.hasNext()) {
while (stmtIter3.hasNext()) {
Statement statement = stmtIter3.next();
Resource entryNode = statement.getSubject();
Value nameNode = statement.getObject();
if (nameNode instanceof Resource) {
Resource nameResource = (Resource) nameNode;
Iterator<Statement> stmtIter4 = model.match(nameResource, UniProtConstants.fullName, null);
// System.out.println("hello world");
while (stmtIter4.hasNext()) {
Statement statement2 = stmtIter4.next();
Value objectNode = statement2.getObject();
// System.out.println("hello moon");
if (entryNode instanceof URI && objectNode instanceof Literal) {
String name = ((Literal) objectNode).stringValue();
UniProtBox.Entry entry = box.entry(UniProtConstants.idFromResource((URI) entryNode));
System.out.println("UniProtExtractor: name: " + name + "\tid: " + entry.id());
entry.setRecommendedName(name);
}
}
}
}
} else {
// sometimes, recommended name is not present for an uniprot id : check the full name
stmtIter3 = model.match(null, UniProtConstants.fullName, null);
while (stmtIter3.hasNext()) {
Statement statement2 = stmtIter3.next();
Resource entryNode = statement2.getSubject();
Value objectNode = statement2.getObject();
if (entryNode instanceof URI && objectNode instanceof Literal) {
String name = ((Literal) objectNode).stringValue();
UniProtBox.Entry entry = box.entry(UniProtConstants.idFromResource((URI) entryNode));
entry.setRecommendedName(name);
System.out.println("UniProtExtractor: name: " + name + "\tid: " + entry.id());
}
}
}
return box;
}
Aggregations