Search in sources :

Example 1 with VCID

use of cbit.vcell.biomodel.meta.VCID in project vcell by virtualcell.

the class MiriamTreeModel method createTree.

private void createTree() {
    if (!createTree) {
        return;
    }
    MiriamManager miriamManager = vcMetaData.getMiriamManager();
    TreeMap<Identifiable, Map<MiriamRefGroup, MIRIAMQualifier>> miriamDescrHeir = miriamManager.getMiriamTreeMap();
    Map<Identifiable, Map<DateQualifier, Set<DublinCoreDate>>> dateMapMap = miriamManager.getDublinCoreDateMap();
    Set<Identifiable> identifiables = vcMetaData.getIdentifiableProvider().getAllIdentifiables();
    TreeSet<Identifiable> sortedIdentifiables = new TreeSet<Identifiable>(new IdentifiableComparator(vcMetaData.getIdentifiableProvider()));
    sortedIdentifiables.addAll(identifiables);
    ((DefaultMutableTreeNode) getRoot()).removeAllChildren();
    for (Identifiable identifiable : sortedIdentifiables) {
        Map<MiriamRefGroup, MIRIAMQualifier> refGroupMap = miriamDescrHeir.get(identifiable);
        Map<DateQualifier, Set<DublinCoreDate>> dateMap = dateMapMap.get(identifiable);
        VCID vcid = vcMetaData.getIdentifiableProvider().getVCID(identifiable);
        String modelComponentType = vcid.getClassName();
        String modelComponentName = vcid.getLocalName();
        IdentifiableNode modelComponentNode = new IdentifiableNode(identifiable, modelComponentType + " : " + modelComponentName);
        String freeTextAnnotation = vcMetaData.getFreeTextAnnotation(identifiable);
        if (freeTextAnnotation != null) {
            modelComponentNode.add(new BioModelNode(new Annotation(freeTextAnnotation), false));
        } else {
            modelComponentNode.add(new BioModelNode(new Annotation(""), false));
        }
        if (refGroupMap != null) {
            for (MiriamRefGroup refGroup : refGroupMap.keySet()) {
                MIRIAMQualifier qualifier = refGroupMap.get(refGroup);
                for (MiriamResource miriamResource : refGroup.getMiriamRefs()) {
                    LinkNode linkNode = new LinkNode(qualifier, miriamResource);
                    modelComponentNode.add(linkNode);
                }
            }
        }
        if (dateMap != null) {
            for (DublinCoreQualifier.DateQualifier qualifier : dateMap.keySet()) {
                Set<DublinCoreDate> dates = dateMap.get(qualifier);
                for (DublinCoreDate date : dates) {
                    modelComponentNode.add(new DateNode(qualifier, date));
                }
            }
        }
        ((DefaultMutableTreeNode) getRoot()).add(modelComponentNode);
    }
}
Also used : IdentifiableComparator(cbit.vcell.biomodel.meta.IdentifiableComparator) MiriamManager(cbit.vcell.biomodel.meta.MiriamManager) TreeSet(java.util.TreeSet) Set(java.util.Set) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) BioModelNode(cbit.vcell.desktop.BioModelNode) DateQualifier(org.vcell.sybil.models.dublincore.DublinCoreQualifier.DateQualifier) MiriamResource(cbit.vcell.biomodel.meta.MiriamManager.MiriamResource) TreeSet(java.util.TreeSet) MiriamRefGroup(cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup) VCID(cbit.vcell.biomodel.meta.VCID) DublinCoreDate(org.vcell.sybil.models.dublincore.DublinCoreDate) Annotation(cbit.vcell.desktop.Annotation) Identifiable(org.vcell.util.document.Identifiable) DateQualifier(org.vcell.sybil.models.dublincore.DublinCoreQualifier.DateQualifier) DublinCoreQualifier(org.vcell.sybil.models.dublincore.DublinCoreQualifier) Map(java.util.Map) TreeMap(java.util.TreeMap) MIRIAMQualifier(org.vcell.sybil.models.miriam.MIRIAMQualifier)

Example 2 with VCID

use of cbit.vcell.biomodel.meta.VCID in project vcell by virtualcell.

the class MiriamTreeModel method createTree.

public void createTree(Identifiable identifiable) {
    if (identifiable == null) {
        ((DefaultMutableTreeNode) getRoot()).removeAllChildren();
        fireTreeStructureChanged(this, getPathToRoot(((DefaultMutableTreeNode) getRoot())), null, null);
        return;
    }
    ((DefaultMutableTreeNode) getRoot()).removeAllChildren();
    MiriamManager miriamManager = vcMetaData.getMiriamManager();
    TreeMap<Identifiable, Map<MiriamRefGroup, MIRIAMQualifier>> miriamDescrHeir = miriamManager.getMiriamTreeMap();
    Map<MiriamRefGroup, MIRIAMQualifier> refGroupMap = miriamDescrHeir.get(identifiable);
    VCID vcid = vcMetaData.getIdentifiableProvider().getVCID(identifiable);
    // Map<Identifiable, Map<DateQualifier, Set<DublinCoreDate>>> dateMapMap = miriamManager.getDublinCoreDateMap();
    // Map<DateQualifier, Set<DublinCoreDate>> dateMap = dateMapMap.get(identifiable);
    List<LinkNode> nodeList = new ArrayList<>();
    if (refGroupMap != null) {
        for (MiriamRefGroup refGroup : refGroupMap.keySet()) {
            MIRIAMQualifier qualifier = refGroupMap.get(refGroup);
            for (MiriamResource miriamResource : refGroup.getMiriamRefs()) {
                LinkNode ln = new LinkNode(qualifier, miriamResource);
                nodeList.add(ln);
            }
        }
        Collections.sort(nodeList);
        for (LinkNode ln : nodeList) {
            ((DefaultMutableTreeNode) getRoot()).add(ln);
        }
    }
    // if (dateMap!=null){
    // for (DublinCoreQualifier.DateQualifier qualifier : dateMap.keySet()){
    // Set<DublinCoreDate> dates = dateMap.get(qualifier);
    // for (DublinCoreDate date : dates){
    // ((DefaultMutableTreeNode)getRoot()).add(new DateNode(qualifier,date));
    // }
    // }
    // }
    fireTreeStructureChanged(this, getPathToRoot(((DefaultMutableTreeNode) getRoot())), null, null);
}
Also used : VCID(cbit.vcell.biomodel.meta.VCID) MiriamManager(cbit.vcell.biomodel.meta.MiriamManager) DefaultMutableTreeNode(javax.swing.tree.DefaultMutableTreeNode) ArrayList(java.util.ArrayList) Identifiable(org.vcell.util.document.Identifiable) MiriamResource(cbit.vcell.biomodel.meta.MiriamManager.MiriamResource) Map(java.util.Map) TreeMap(java.util.TreeMap) MIRIAMQualifier(org.vcell.sybil.models.miriam.MIRIAMQualifier) MiriamRefGroup(cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup)

Example 3 with VCID

use of cbit.vcell.biomodel.meta.VCID in project vcell by virtualcell.

the class BioModel method getVCID.

public VCID getVCID(Identifiable identifiable) {
    if (identifiable == null) {
        return null;
    }
    String localName;
    String className;
    if (identifiable instanceof SpeciesContext) {
        localName = ((SpeciesContext) identifiable).getName();
        className = VCID.CLASS_SPECIES_CONTEXT;
    } else if (identifiable instanceof Species) {
        localName = ((Species) identifiable).getCommonName();
        className = VCID.CLASS_SPECIES;
    } else if (identifiable instanceof Structure) {
        localName = ((Structure) identifiable).getName();
        className = VCID.CLASS_STRUCTURE;
    } else if (identifiable instanceof ReactionStep) {
        localName = ((ReactionStep) identifiable).getName();
        className = VCID.CLASS_REACTION_STEP;
    } else if (identifiable instanceof BioModel) {
        localName = ((BioModel) identifiable).getName();
        className = VCID.CLASS_BIOMODEL;
    } else if (identifiable instanceof BioPaxObject) {
        localName = ((BioPaxObject) identifiable).getID();
        className = VCID.CLASS_BIOPAX_OBJECT;
    } else if (identifiable instanceof MolecularType) {
        localName = ((MolecularType) identifiable).getName();
        className = VCID.CLASS_MOLECULE;
    } else if (identifiable instanceof ReactionRule) {
        localName = ((ReactionRule) identifiable).getName();
        className = VCID.CLASS_REACTION_RULE;
    } else if (identifiable instanceof RbmObservable) {
        localName = ((RbmObservable) identifiable).getName();
        className = VCID.CLASS_OBSERVABLE;
    } else if (identifiable instanceof Model.ModelParameter) {
        localName = ((Model.ModelParameter) identifiable).getName();
        className = VCID.CLASS_MODEL_PARAMETER;
    } else if (identifiable instanceof SimulationContext) {
        localName = ((SimulationContext) identifiable).getName();
        className = VCID.CLASS_APPLICATION;
    } else {
        throw new RuntimeException("unsupported Identifiable class");
    }
    localName = TokenMangler.mangleVCId(localName);
    VCID vcid;
    try {
        vcid = VCID.fromString(className + "(" + localName + ")");
    } catch (VCID.InvalidVCIDException e) {
        e.printStackTrace();
        throw new RuntimeException(e.getMessage());
    }
    return vcid;
}
Also used : VCID(cbit.vcell.biomodel.meta.VCID) ReactionRule(cbit.vcell.model.ReactionRule) BioPaxObject(org.vcell.pathway.BioPaxObject) RbmObservable(cbit.vcell.model.RbmObservable) SpeciesContext(cbit.vcell.model.SpeciesContext) SimulationContext(cbit.vcell.mapping.SimulationContext) MolecularType(org.vcell.model.rbm.MolecularType) ReactionStep(cbit.vcell.model.ReactionStep) RelationshipModel(org.vcell.relationship.RelationshipModel) Model(cbit.vcell.model.Model) PathwayModel(org.vcell.pathway.PathwayModel) Structure(cbit.vcell.model.Structure) Species(cbit.vcell.model.Species)

Example 4 with VCID

use of cbit.vcell.biomodel.meta.VCID in project vcell by virtualcell.

the class XMLMetaDataReader method readFromElement.

@SuppressWarnings("unchecked")
public static void readFromElement(VCMetaData metaData, IdentifiableProvider identifiableProvider, Element metadataElement) throws XmlParseException {
    Element bindingElement = metadataElement.getChild(XMLMetaData.URI_BINDING_LIST_TAG, VCMetaData.nsVCML);
    if (bindingElement != null) {
        // read binding
        List<Element> entryElements = bindingElement.getChildren(XMLMetaData.URI_BINDING_TAG, VCMetaData.nsVCML);
        for (Iterator<Element> iterator = entryElements.iterator(); iterator.hasNext(); ) {
            Element entryElement = iterator.next();
            try {
                String uri = entryElement.getAttributeValue(XMLMetaData.URI_ATTR_TAG);
                String vcidString = entryElement.getAttributeValue(XMLMetaData.VCID_ATTR_TAG);
                // make new entry based on URI
                // create VCID
                VCID vcid = VCID.fromString(vcidString);
                // lookup Identifiable object using VCID ... add to entry.
                metaData.getRegistry().newEntry(metaData.getRdfData(), identifiableProvider.getIdentifiableObject(vcid), uri);
            } catch (VCID.InvalidVCIDException e) {
                e.printStackTrace();
                throw new XmlParseException(e);
            }
        }
    }
    Element rdfElement = metadataElement.getChild(XMLRDF.tagRDF, XMLRDF.nsRDF);
    if (rdfElement != null) {
        // read RDF
        try {
            metaData.addToModelFromElement(rdfElement);
        } catch (RDFParseException e) {
            e.printStackTrace();
            throw new XmlParseException(e.getMessage());
        } catch (RDFHandlerException e) {
            e.printStackTrace();
            throw new XmlParseException(e.getMessage());
        } catch (IOException e) {
            e.printStackTrace();
            throw new XmlParseException(e.getMessage());
        }
    }
    Element nonRDFAnnotationListElement = metadataElement.getChild(XMLMetaData.NONRDF_ANNOTATION_LIST_TAG, VCMetaData.nsVCML);
    if (nonRDFAnnotationListElement != null) {
        List<Element> nonRDFAnnotationElements = nonRDFAnnotationListElement.getChildren(XMLMetaData.NONRDF_ANNOTATION_TAG, VCMetaData.nsVCML);
        for (Element nonRDFAnnotationElement : nonRDFAnnotationElements) {
            String vcidString = nonRDFAnnotationElement.getAttributeValue(XMLMetaData.VCID_ATTR_TAG);
            VCID vcid = null;
            try {
                vcid = VCID.fromString(vcidString);
            } catch (InvalidVCIDException e) {
                e.printStackTrace();
                throw new XmlParseException(e.getMessage());
            }
            Identifiable identifiable = identifiableProvider.getIdentifiableObject(vcid);
            if (identifiable != null) {
                // populate the annotation
                Element freeTextAnnotationElement = nonRDFAnnotationElement.getChild(XMLMetaData.FREETEXT_TAG, VCMetaData.nsVCML);
                if (freeTextAnnotationElement != null) {
                    String freeText = freeTextAnnotationElement.getText();
                    metaData.setFreeTextAnnotation(identifiable, freeText);
                }
                Element xhtmlNotesElement = nonRDFAnnotationElement.getChild(XMLMetaData.NOTES_TAG, VCMetaData.nsVCML);
                if (xhtmlNotesElement != null) {
                    metaData.setXhtmlNotes(identifiable, xhtmlNotesElement);
                }
                Element annotationListElement = nonRDFAnnotationElement.getChild(XMLMetaData.ANNOTATION_LIST_TAG, VCMetaData.nsVCML);
                if (annotationListElement != null) {
                    List<?> annotationContents = annotationListElement.getContent();
                    List<Element> annotationElements = new ArrayList<Element>();
                    for (int i = 0; i < annotationContents.size(); i++) {
                        if (annotationContents.get(i) instanceof Element) {
                            annotationElements.add((Element) annotationContents.get(i));
                        }
                    }
                    metaData.setXmlAnnotations(identifiable, annotationElements.toArray(new Element[annotationElements.size()]));
                }
            } else {
                System.err.println("Cannot find identifiable for vcid : " + vcidString);
            }
        }
    }
}
Also used : VCID(cbit.vcell.biomodel.meta.VCID) Element(org.jdom.Element) ArrayList(java.util.ArrayList) XmlParseException(cbit.vcell.xml.XmlParseException) IOException(java.io.IOException) InvalidVCIDException(cbit.vcell.biomodel.meta.VCID.InvalidVCIDException) Identifiable(org.vcell.util.document.Identifiable) RDFHandlerException(org.openrdf.rio.RDFHandlerException) InvalidVCIDException(cbit.vcell.biomodel.meta.VCID.InvalidVCIDException) RDFParseException(org.openrdf.rio.RDFParseException)

Example 5 with VCID

use of cbit.vcell.biomodel.meta.VCID in project vcell by virtualcell.

the class XMLMetaDataWriter method getElement.

public static Element getElement(VCMetaData metaData, IdentifiableProvider identifiableProvider) {
    Element element = new Element(XMLMetaData.VCMETADATA_TAG);
    Element elementRDF = metaData.createElement();
    // add RDF data
    if (elementRDF != null) {
        element.addContent(elementRDF);
    }
    Element elementNonRDFList = createNonRDFAnnotationElement(metaData, identifiableProvider);
    element.addContent(elementNonRDFList);
    // add resource binding table
    Element bindingListElement = new Element(XMLMetaData.URI_BINDING_LIST_TAG);
    Set<Registry.Entry> resources = metaData.getRegistry().getAllEntries();
    for (Iterator<Registry.Entry> i = resources.iterator(); i.hasNext(); ) {
        Registry.Entry entry = i.next();
        if (entry.getIdentifiable() == null) {
            System.err.println("Null identifiable for metadata registry entry");
            i.remove();
            continue;
        }
        VCID vcid = identifiableProvider.getVCID(entry.getIdentifiable());
        if (vcid == null) {
            throw new RuntimeException("Identifiable missing for " + entry.getResource());
        }
        Identifiable identifiable = identifiableProvider.getIdentifiableObject(vcid);
        if (identifiable != null && entry.getResource() != null) {
            Element entryElement = new Element(XMLMetaData.URI_BINDING_TAG);
            Resource resource = entry.getResource();
            if (resource != null) {
                entryElement.setAttribute(XMLMetaData.URI_ATTR_TAG, resource.stringValue());
            }
            entryElement.setAttribute(XMLMetaData.VCID_ATTR_TAG, vcid.toASCIIString());
            bindingListElement.addContent(entryElement);
        }
    }
    element.addContent(bindingListElement);
    return element;
}
Also used : VCID(cbit.vcell.biomodel.meta.VCID) Entry(cbit.vcell.biomodel.meta.registry.Registry.Entry) Element(org.jdom.Element) Resource(org.openrdf.model.Resource) Entry(cbit.vcell.biomodel.meta.registry.Registry.Entry) Registry(cbit.vcell.biomodel.meta.registry.Registry) Identifiable(org.vcell.util.document.Identifiable)

Aggregations

VCID (cbit.vcell.biomodel.meta.VCID)10 Identifiable (org.vcell.util.document.Identifiable)5 ArrayList (java.util.ArrayList)3 Map (java.util.Map)3 Element (org.jdom.Element)3 MiriamManager (cbit.vcell.biomodel.meta.MiriamManager)2 MiriamRefGroup (cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup)2 MiriamResource (cbit.vcell.biomodel.meta.MiriamManager.MiriamResource)2 Entry (cbit.vcell.biomodel.meta.registry.Registry.Entry)2 TreeMap (java.util.TreeMap)2 DefaultMutableTreeNode (javax.swing.tree.DefaultMutableTreeNode)2 Resource (org.openrdf.model.Resource)2 MIRIAMQualifier (org.vcell.sybil.models.miriam.MIRIAMQualifier)2 IdentifiableComparator (cbit.vcell.biomodel.meta.IdentifiableComparator)1 NonRDFAnnotation (cbit.vcell.biomodel.meta.NonRDFAnnotation)1 InvalidVCIDException (cbit.vcell.biomodel.meta.VCID.InvalidVCIDException)1 VCMetaData (cbit.vcell.biomodel.meta.VCMetaData)1 Registry (cbit.vcell.biomodel.meta.registry.Registry)1 Annotation (cbit.vcell.desktop.Annotation)1 BioModelNode (cbit.vcell.desktop.BioModelNode)1