Search in sources :

Example 16 with MIRIAMQualifier

use of org.vcell.sybil.models.miriam.MIRIAMQualifier in project vcell by virtualcell.

the class BioModelEditorModelPanel method hasAnnotation.

private boolean hasAnnotation(Identifiable identifiable) {
    Identifiable entity = AnnotationsPanel.getIdentifiable(identifiable);
    String freeText = bioModel.getVCMetaData().getFreeTextAnnotation(entity);
    MiriamManager miriamManager = bioModel.getVCMetaData().getMiriamManager();
    TreeMap<Identifiable, Map<MiriamRefGroup, MIRIAMQualifier>> miriamDescrHeir = miriamManager.getMiriamTreeMap();
    Map<MiriamRefGroup, MIRIAMQualifier> refGroupMap = miriamDescrHeir.get(entity);
    Icon icon = VCellIcons.issueGoodIcon;
    if (freeText != null && !freeText.isEmpty()) {
        return true;
    } else if (refGroupMap != null && !refGroupMap.isEmpty()) {
        return true;
    }
    return false;
}
Also used : MiriamManager(cbit.vcell.biomodel.meta.MiriamManager) DownArrowIcon(org.vcell.util.gui.DownArrowIcon) Icon(javax.swing.Icon) StructureToolShapeIcon(cbit.vcell.graph.gui.StructureToolShapeIcon) Map(java.util.Map) LinkedHashMap(java.util.LinkedHashMap) TreeMap(java.util.TreeMap) MIRIAMQualifier(org.vcell.sybil.models.miriam.MIRIAMQualifier) MiriamRefGroup(cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup) Identifiable(org.vcell.util.document.Identifiable)

Example 17 with MIRIAMQualifier

use of org.vcell.sybil.models.miriam.MIRIAMQualifier in project vcell by virtualcell.

the class AnnotationsPanel method removeIdentifier.

private void removeIdentifier() {
    Object treeNode = jTreeMIRIAM.getLastSelectedPathComponent();
    if (treeNode instanceof LinkNode) {
        LinkNode linkNode = (LinkNode) treeNode;
        MiriamResource resourceToDelete = linkNode.getMiriamResource();
        Identifiable entity = getIdentifiable(selectedObject);
        // Map<MiriamRefGroup, MIRIAMQualifier> refGroupsToRemove = vcMetaData.getMiriamManager().getAllMiriamRefGroups(entity);
        MiriamManager mm = vcMetaData.getMiriamManager();
        Map<MiriamRefGroup, MIRIAMQualifier> refGroupsToRemove = mm.getMiriamTreeMap().get(entity);
        boolean found = false;
        for (MiriamRefGroup refGroup : refGroupsToRemove.keySet()) {
            MIRIAMQualifier qualifier = refGroupsToRemove.get(refGroup);
            for (MiriamResource miriamResource : refGroup.getMiriamRefs()) {
                if (!isEqual(miriamResource, resourceToDelete)) {
                    continue;
                }
                try {
                    // remove the ref group for this resource
                    mm.remove2(entity, qualifier, refGroup);
                    System.out.println(vcMetaData.printRdfStatements());
                    found = true;
                    break;
                } catch (URNParseFailureException e) {
                    e.printStackTrace(System.out);
                }
            }
            if (found == true) {
                updateInterface();
                if (selectedObject instanceof ReactionStep) {
                    ((ReactionStep) selectedObject).firePropertyChange("addIdentifier", true, false);
                }
                break;
            }
        }
    }
}
Also used : MiriamManager(cbit.vcell.biomodel.meta.MiriamManager) VCMetaDataMiriamManager(cbit.vcell.biomodel.meta.VCMetaDataMiriamManager) MiriamResource(cbit.vcell.biomodel.meta.MiriamManager.MiriamResource) ReactionStep(cbit.vcell.model.ReactionStep) LinkNode(cbit.vcell.xml.gui.MiriamTreeModel.LinkNode) BioPaxObject(org.vcell.pathway.BioPaxObject) MIRIAMQualifier(org.vcell.sybil.models.miriam.MIRIAMQualifier) URNParseFailureException(org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException) MiriamRefGroup(cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup) Identifiable(org.vcell.util.document.Identifiable)

Example 18 with MIRIAMQualifier

use of org.vcell.sybil.models.miriam.MIRIAMQualifier in project vcell by virtualcell.

the class VCMetaDataMiriamManager method getMiriamRefGroups.

public Set<MiriamRefGroup> getMiriamRefGroups(Identifiable identifiable, MIRIAMQualifier miriamQualifier) {
    // get from cache.
    Map<MiriamRefGroup, MIRIAMQualifier> map = getMiriamTreeMap().get(identifiable);
    HashSet<MiriamRefGroup> matchingRefGroups = new HashSet<MiriamRefGroup>();
    if (map != null && map.size() > 0) {
        Set<MiriamRefGroup> allStoredRefGroups = map.keySet();
        if (map != null && map.size() > 0) {
            for (MiriamRefGroup storedRefGroup : allStoredRefGroups) {
                MIRIAMQualifier storedQualifier = map.get(storedRefGroup);
                if (storedQualifier.equals(miriamQualifier)) {
                    matchingRefGroups.add(storedRefGroup);
                }
            }
        }
    }
    return matchingRefGroups;
}
Also used : MIRIAMQualifier(org.vcell.sybil.models.miriam.MIRIAMQualifier) HashSet(java.util.HashSet)

Example 19 with MIRIAMQualifier

use of org.vcell.sybil.models.miriam.MIRIAMQualifier in project vcell by virtualcell.

the class AnnotationMapping method getRefInfo.

private HashMap<String, String> getRefInfo(BioModel bioModel, Identifiable identifiable) {
    HashMap<String, String> info = new HashMap<String, String>();
    VCMetaData vcMetaData = bioModel.getVCMetaData();
    MiriamManager miriamManager = vcMetaData.getMiriamManager();
    TreeMap<Identifiable, Map<MiriamRefGroup, MIRIAMQualifier>> miriamDescrHeir = miriamManager.getMiriamTreeMap();
    Map<MiriamRefGroup, MIRIAMQualifier> refGroupMap = miriamDescrHeir.get(identifiable);
    if (refGroupMap != null) {
        for (MiriamRefGroup refGroup : refGroupMap.keySet()) {
            MIRIAMQualifier qualifier = refGroupMap.get(refGroup);
            String[] quaTemp = qualifier.toString().split("/");
            String bioQualifier = quaTemp[quaTemp.length - 1];
            bioQualifier = bioQualifier.substring(0, bioQualifier.length() - 1);
            for (MiriamResource miriamResource : refGroup.getMiriamRefs()) {
                String refSource = miriamResource.getMiriamURN();
                String[] temp = refSource.split(":");
                String sourceInfo = temp[2] + ":" + bioQualifier;
                String refId = miriamResource.getIdentifier();
                info.put(refId, sourceInfo);
            // System.out.println(refId + "*********" + sourceInfo);
            }
        }
    }
    return info;
}
Also used : MiriamManager(cbit.vcell.biomodel.meta.MiriamManager) HashMap(java.util.HashMap) Identifiable(org.vcell.util.document.Identifiable) VCMetaData(cbit.vcell.biomodel.meta.VCMetaData) MiriamResource(cbit.vcell.biomodel.meta.MiriamManager.MiriamResource) HashMap(java.util.HashMap) Map(java.util.Map) TreeMap(java.util.TreeMap) MIRIAMQualifier(org.vcell.sybil.models.miriam.MIRIAMQualifier) MiriamRefGroup(cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup)

Example 20 with MIRIAMQualifier

use of org.vcell.sybil.models.miriam.MIRIAMQualifier in project vcell by virtualcell.

the class PathwayMapping method createMolecularTypeFromBioPaxObject.

// TODO: not in use
// public void createBioModelEntitiesFromBioPaxObjects(BioModel bioModel, Object[] selectedObjects) throws Exception
// {
// for(int i = 0; i < selectedObjects.length; i++) {
// if(selectedObjects[i] instanceof BioPaxObject) {
// BioPaxObject bioPaxObject = (BioPaxObject)selectedObjects[i];
// if(bioPaxObject instanceof PhysicalEntity && !(bioPaxObject instanceof Complex)) {
// createMolecularTypeFromBioPaxObject(bioModel, (PhysicalEntity)bioPaxObject);
// }
// } else if(selectedObjects[i] instanceof ConversionTableRow) {
// ConversionTableRow ctr = (ConversionTableRow)selectedObjects[i];
// if(ctr.getBioPaxObject() instanceof PhysicalEntity && !(ctr.getBioPaxObject() instanceof Complex)) {
// createMolecularTypeFromBioPaxObject(bioModel, (PhysicalEntity)ctr.getBioPaxObject());
// }
// }
// }
// 
// for(int i = 0; i < selectedObjects.length; i++) {
// if(selectedObjects[i] instanceof BioPaxObject) {
// BioPaxObject bioPaxObject = (BioPaxObject)selectedObjects[i];
// if(bioPaxObject instanceof PhysicalEntity) {
// createSpeciesContextFromBioPaxObject(bioModel, (PhysicalEntity)bioPaxObject);
// } else if(bioPaxObject instanceof Conversion) {
// createReactionStepsFromBioPaxObject(bioModel, (Conversion)bioPaxObject);
// }
// } else if(selectedObjects[i] instanceof ConversionTableRow) {
// ConversionTableRow ctr = (ConversionTableRow)selectedObjects[i];
// if(ctr.getBioPaxObject() instanceof PhysicalEntity) {
// createSpeciesContextFromTableRow(bioModel, (PhysicalEntity)ctr.getBioPaxObject(), ctr.stoich(), ctr.id(), ctr.location());
// } else if(ctr.getBioPaxObject() instanceof Conversion) {
// createReactionStepsFromTableRow(bioModel, (Conversion)ctr.getBioPaxObject(), ctr.stoich(), ctr.id(), ctr.location());
// }
// }
// }
// }
private MolecularType createMolecularTypeFromBioPaxObject(BioModel bioModel, PhysicalEntity bioPaxObject, boolean addSubunits) {
    String name;
    if (bioPaxObject.getName().size() == 0) {
        name = getSafetyName(bioPaxObject.getID());
    } else {
        name = getSafetyName(bioPaxObject.getName().get(0));
    }
    RbmModelContainer rbmmc = bioModel.getModel().getRbmModelContainer();
    if (rbmmc.getMolecularType(name) != null) {
        // already exists
        MolecularType mt = rbmmc.getMolecularType(name);
        // check whether it links to pathway object, create relationship object if not
        if (!bioModel.getRelationshipModel().isRelationship(mt, bioPaxObject)) {
            RelationshipObject ro = new RelationshipObject(mt, bioPaxObject);
            bioModel.getRelationshipModel().addRelationshipObject(ro);
        }
        return mt;
    }
    int numSubunits = 0;
    if (addSubunits) {
        for (String comment : bioPaxObject.getComments()) {
            numSubunits = StringUtils.countMatches(comment, "SUBUNIT:");
        }
    }
    MolecularType mt = new MolecularType(name, bioModel.getModel());
    try {
        for (int i = 0; i < numSubunits; i++) {
            MolecularComponent mc = new MolecularComponent("Subunit" + i);
            mt.addMolecularComponent(mc);
        }
        rbmmc.addMolecularType(mt, true);
        // we know for sure that a relationship can't exist, so we make one
        RelationshipObject ro = new RelationshipObject(mt, bioPaxObject);
        bioModel.getRelationshipModel().addRelationshipObject(ro);
    } catch (ModelException | PropertyVetoException e) {
        e.printStackTrace();
    }
    ArrayList<String> commentList = bioPaxObject.getComments();
    final String htmlStart = "<html><font face = \"Arial\"><font size =\"-2\">";
    final String htmlEnd = "</font></font></html>";
    if (commentList != null && !commentList.isEmpty()) {
        String comment = commentList.get(0);
        if (!comment.isEmpty()) {
            String text = FormatDetails(comment);
            mt.setComment(htmlStart + text + htmlEnd);
        }
    } else {
        mt.setComment("");
    }
    VCMetaData vcMetaData = bioModel.getVCMetaData();
    MiriamManager miriamManager = vcMetaData.getMiriamManager();
    MIRIAMQualifier qualifier = MIRIAMQualifier.MODEL_isDescribedBy;
    ArrayList<Xref> xrefList = bioPaxObject.getxRef();
    for (Xref xref : xrefList) {
        String url = xref.getURL();
        if (url == null || url.isEmpty()) {
            continue;
        }
        System.out.println(xref.getDb() + ": " + xref.getId());
        try {
            HashSet<MiriamResource> miriamResources = new HashSet<MiriamResource>();
            // http://www.ncbi.nlm.nih.gov/protein/NP_005429	unrecognized (not a valid DataType)
            // http://www.uniprot.org/uniprot/P17275			good
            // TODO: find a mechanism to store the unrecognized ones - they often do work
            MiriamResource mr = miriamManager.createMiriamResource(url);
            miriamResources.add(mr);
            miriamManager.addMiriamRefGroup(mt, qualifier, miriamResources);
        } catch (URNParseFailureException e) {
            e.printStackTrace();
        }
        System.out.println(xref.getDisplayName());
    }
    return mt;
}
Also used : MiriamManager(cbit.vcell.biomodel.meta.MiriamManager) ModelException(cbit.vcell.model.ModelException) MolecularType(org.vcell.model.rbm.MolecularType) PropertyVetoException(java.beans.PropertyVetoException) VCMetaData(cbit.vcell.biomodel.meta.VCMetaData) Xref(org.vcell.pathway.Xref) MiriamResource(cbit.vcell.biomodel.meta.MiriamManager.MiriamResource) RbmModelContainer(cbit.vcell.model.Model.RbmModelContainer) MolecularComponent(org.vcell.model.rbm.MolecularComponent) MIRIAMQualifier(org.vcell.sybil.models.miriam.MIRIAMQualifier) URNParseFailureException(org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException) HashSet(java.util.HashSet)

Aggregations

MIRIAMQualifier (org.vcell.sybil.models.miriam.MIRIAMQualifier)21 MiriamManager (cbit.vcell.biomodel.meta.MiriamManager)12 MiriamRefGroup (cbit.vcell.biomodel.meta.MiriamManager.MiriamRefGroup)12 Identifiable (org.vcell.util.document.Identifiable)12 MiriamResource (cbit.vcell.biomodel.meta.MiriamManager.MiriamResource)9 Map (java.util.Map)9 TreeMap (java.util.TreeMap)9 URNParseFailureException (org.vcell.sybil.models.miriam.MIRIAMRef.URNParseFailureException)7 HashSet (java.util.HashSet)4 Entry (cbit.vcell.biomodel.meta.registry.Registry.Entry)3 ReactionStep (cbit.vcell.model.ReactionStep)3 Icon (javax.swing.Icon)3 DataType (cbit.vcell.biomodel.meta.MiriamManager.DataType)2 VCID (cbit.vcell.biomodel.meta.VCID)2 VCMetaData (cbit.vcell.biomodel.meta.VCMetaData)2 VCMetaDataMiriamManager (cbit.vcell.biomodel.meta.VCMetaDataMiriamManager)2 Registry (cbit.vcell.biomodel.meta.registry.Registry)2 StructureToolShapeIcon (cbit.vcell.graph.gui.StructureToolShapeIcon)2 SpeciesContext (cbit.vcell.model.SpeciesContext)2 LinkNode (cbit.vcell.xml.gui.MiriamTreeModel.LinkNode)2