Search in sources :

Example 11 with Resource

use of org.openrdf.model.Resource in project vcell by virtualcell.

the class RefGroup method remove.

public RefGroup remove(Graph graph, MIRIAMRef ref) {
    Resource resourceRef = graph.getValueFactory().createURI(ref.urn());
    Iterator<Statement> stmtIter = graph.match(getResource(), null, resourceRef);
    while (stmtIter.hasNext()) {
        stmtIter.next();
        stmtIter.remove();
    }
    return this;
}
Also used : Statement(org.openrdf.model.Statement) Resource(org.openrdf.model.Resource)

Example 12 with Resource

use of org.openrdf.model.Resource in project vcell by virtualcell.

the class RefGroup method contains.

public boolean contains(Graph graph, MIRIAMRef ref) {
    Resource rRef = graph.getValueFactory().createURI(ref.urn());
    Statement statement = graph.getValueFactory().createStatement(getResource(), RDF.LI, rRef);
    return graph.contains(statement);
}
Also used : Statement(org.openrdf.model.Statement) Resource(org.openrdf.model.Resource)

Example 13 with Resource

use of org.openrdf.model.Resource in project vcell by virtualcell.

the class RefGroup method add.

public RefGroup add(Graph graph, MIRIAMRef ref) {
    Resource rRef = graph.getValueFactory().createURI(ref.urn());
    graph.add(getResource(), RDF.LI, rRef);
    return this;
}
Also used : Resource(org.openrdf.model.Resource)

Example 14 with Resource

use of org.openrdf.model.Resource in project vcell by virtualcell.

the class SBMLAnnotationUtil method writeAnnotation.

public void writeAnnotation(Identifiable identifiable, SBase sBase, Element vcellImportRelatedElement) throws XMLStreamException {
    // Deal with RDF annotation
    XMLNode rootAnnotation = new XMLNode(tripleAnnotation, new XMLAttributes());
    Resource resource = metaData.getRegistry().getEntry(identifiable).getResource();
    Graph rdfChunk = null;
    if (resource != null) {
        rdfChunk = chopper.getChops().get(resource);
    }
    if (identifiable == root && rdfChunk != null) {
        rdfChunk.addAll(chopper.getRemains());
    }
    XMLNode rootRDF = null;
    if (rdfChunk != null && metaData.getBaseURIExtended() != null) {
        Element element = XMLRDFWriter.createElement(rdfChunk, nsSBML);
        XMLNamespaces xmlnss = new XMLNamespaces();
        xmlnss.add(DefaultNameSpaces.RDF.uri, DefaultNameSpaces.RDF.prefix);
        rootRDF = XMLNode.convertStringToXMLNode(XmlUtil.xmlToString(element), xmlnss);
    }
    if (rootRDF != null && rootRDF.getNumChildren() > 0) {
        rootAnnotation.addChild(rootRDF);
    }
    // Deal with the non-RDF; VCell free-text annotations
    // get free text annotation from NonRDFAnnotation (associated with identifiable); create XMLNode
    XMLNode rootVCellInfo = new XMLNode(tripleVCellInfo, new XMLAttributes());
    rootVCellInfo.addNamespace(XMLTags.SBML_VCELL_NS, XMLTags.VCELL_NS_PREFIX);
    String freeTextStr = metaData.getFreeTextAnnotation(identifiable);
    if (freeTextStr != null && freeTextStr.length() > 0) {
        XMLNode contentFreeText = new XMLNode(freeTextStr);
        XMLNode rootFreeText = new XMLNode(tripleFreeText, new XMLAttributes());
        rootFreeText.addChild(contentFreeText);
        rootVCellInfo.addChild(rootFreeText);
    }
    // VCell specific info to be exported to SBML as annotation - used for import, not needed for metadata
    if (vcellImportRelatedElement != null) {
        XMLNode xn = elementToXMLNode(vcellImportRelatedElement);
        if (xn != null) {
            xn.removeNamespace(XMLTags.VCELL_NS_PREFIX);
            rootVCellInfo.addChild(xn);
        }
    }
    if (rootVCellInfo.getNumChildren() > 0) {
        rootAnnotation.addChild(rootVCellInfo);
    }
    // Deal with the non-RDF (other tool-related?) annotation
    Element[] elementsXML = metaData.getXmlAnnotations(identifiable);
    if (elementsXML != null) {
        for (Element elementXML : elementsXML) {
            XMLTriple tripleXML = new XMLTriple(elementXML.getName(), elementXML.getNamespaceURI(), elementXML.getNamespacePrefix());
            XMLNode contentXML = elementToXMLNode(elementXML);
            XMLNode rootXML = new XMLNode(tripleXML, new XMLAttributes());
            rootXML.addChild(contentXML);
            rootAnnotation.addChild(rootXML);
        }
    }
    if (rootAnnotation.getNumChildren() > 0) {
        sBase.setAnnotation(rootAnnotation);
    }
    writeMetaID(identifiable, sBase);
}
Also used : XMLAttributes(org.sbml.jsbml.xml.XMLAttributes) HashGraph(org.sbpax.impl.HashGraph) Graph(org.openrdf.model.Graph) XMLNode(org.sbml.jsbml.xml.XMLNode) Element(org.jdom.Element) Resource(org.openrdf.model.Resource) XMLNamespaces(org.sbml.jsbml.xml.XMLNamespaces) XMLTriple(org.sbml.jsbml.xml.XMLTriple)

Example 15 with Resource

use of org.openrdf.model.Resource in project vcell by virtualcell.

the class SBMLAnnotationUtil method writeMetaID.

public void writeMetaID(Identifiable identifiable, SBase sBase) {
    Resource resource = metaData.getRegistry().getEntry(identifiable).getResource();
    if (resource != null) {
        Resource mappedResource = namespaceAssimilator.map(resource);
        if (mappedResource instanceof URI) {
            String metaID = ((URI) mappedResource).getLocalName();
            sBase.setMetaId(metaID);
        }
    }
}
Also used : Resource(org.openrdf.model.Resource) URI(org.openrdf.model.URI)

Aggregations

Resource (org.openrdf.model.Resource)60 Statement (org.openrdf.model.Statement)22 URI (org.openrdf.model.URI)20 Value (org.openrdf.model.Value)17 HashSet (java.util.HashSet)14 Graph (org.openrdf.model.Graph)7 Literal (org.openrdf.model.Literal)6 SailConnection (org.openrdf.sail.SailConnection)5 SailException (org.openrdf.sail.SailException)5 Entry (cbit.vcell.biomodel.meta.registry.Registry.Entry)4 HashMap (java.util.HashMap)4 Test (org.junit.Test)4 NotifyingSailConnection (org.openrdf.sail.NotifyingSailConnection)4 Map (java.util.Map)3 Set (java.util.Set)3 Element (org.jdom.Element)3 HashGraph (org.sbpax.impl.HashGraph)3 VCID (cbit.vcell.biomodel.meta.VCID)2 Registry (cbit.vcell.biomodel.meta.registry.Registry)2 Edge (com.tinkerpop.blueprints.Edge)2