Search in sources :

Example 16 with Xref

use of org.vcell.pathway.Xref in project vcell by virtualcell.

the class AnnotationMapping method getNameRef.

public static ArrayList<String> getNameRef(ArrayList<Xref> xRef, String entryName) {
    CachedDataBaseReferenceReader dbReader = CachedDataBaseReferenceReader.getCachedReader();
    ArrayList<String> names = new ArrayList<String>();
    for (Xref xref : xRef) {
        try {
            // System.out.println(xref.getDb() + "***" + xref.getId());
            if (xref.getDb().toLowerCase().equals("uniprot")) {
            // String name = dbReader.getMoleculeDataBaseReference(xref.getId());
            // if(name != null)names.add(name);
            // if(xref.getId() != null && xref.getDb().toLowerCase() != null) {
            // names.add(xref.getDb().toLowerCase()+ ":" + xref.getId());
            // }
            // System.out.println(xref.getId() + ">>>>>>>"+ name);
            } else if (xref.getDb().toLowerCase().equals("interpro")) {
            // String name = dbReader.getMoleculeDataBaseReference("interpro", xref.getId());
            // if(name != null)names.add(name);
            // if(xref.getId() != null && xref.getDb().toLowerCase() != null) {
            // names.add(xref.getDb().toLowerCase()+ ":" + xref.getId());
            // }
            // System.out.println(xref.getId() + ">>>>>>>"+ name);
            } else if (xref.getDb().toLowerCase().equals("obo.chebi")) {
                String id = xref.getId().substring(6);
                String name = dbReader.getChEBIName(id);
                if (name != null)
                    names.add(name);
            // System.out.println(xref.getId() + ">>>>>>>"+ name);
            } else if (xref.getDb().toLowerCase().equals("gene_ontology")) {
            // String name = dbReader.getGOTerm(xref.getId());
            // if(name != null) {
            // names.add(name);
            // } else
            // if(xref.getId() != null && xref.getDb().toLowerCase() != null) {
            // names.add(xref.getDb().toLowerCase()+ ":" + xref.getId());
            // }
            // System.out.println(xref.getId() + ">>>>>>>"+ name);
            } else // else if(xref.getDb().toLowerCase().equals("ec-code")){
            // WSDBFetchServerServiceLocator providerLocator = new WSDBFetchServerServiceLocator();
            // WSDBFetchServer server = providerLocator.getWSDbfetch();
            // String[] supported = server.getSupportedDBs();
            // for (int i = 0; i < supported.length; i++) {
            // System.out.println(supported[i]);
            // }
            // String fetchResultStr = server.fetchBatch("embl", xref.getId(),null,null);
            // System.out.println(xref.getId() + ">>>>>>> lookup"+fetchResultStr);
            // }
            {
            // System.out.println(xref.getDb());
            }
        } catch (DbfConnException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (DbfNoEntryFoundException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (DbfParamsException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (DbfException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (InputException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (RemoteException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (ServiceException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (DataAccessException e) {
            // TODO Auto-generated catch block
            e.printStackTrace();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
    if (names.size() == 0 && entryName != null)
        names.add(entryName);
    return names;
}
Also used : DbfNoEntryFoundException(uk.ac.ebi.jdbfetch.exceptions.DbfNoEntryFoundException) DbfException(uk.ac.ebi.jdbfetch.exceptions.DbfException) ArrayList(java.util.ArrayList) DbfParamsException(uk.ac.ebi.jdbfetch.exceptions.DbfParamsException) ServiceException(javax.xml.rpc.ServiceException) DbfNoEntryFoundException(uk.ac.ebi.jdbfetch.exceptions.DbfNoEntryFoundException) DbfParamsException(uk.ac.ebi.jdbfetch.exceptions.DbfParamsException) DataAccessException(org.vcell.util.DataAccessException) DbfException(uk.ac.ebi.jdbfetch.exceptions.DbfException) RemoteException(java.rmi.RemoteException) InputException(uk.ac.ebi.www.ws.services.WSDbfetch.InputException) DbfConnException(uk.ac.ebi.jdbfetch.exceptions.DbfConnException) Xref(org.vcell.pathway.Xref) UnificationXref(org.vcell.pathway.UnificationXref) RelationshipXref(org.vcell.pathway.RelationshipXref) PublicationXref(org.vcell.pathway.PublicationXref) ServiceException(javax.xml.rpc.ServiceException) InputException(uk.ac.ebi.www.ws.services.WSDbfetch.InputException) DbfConnException(uk.ac.ebi.jdbfetch.exceptions.DbfConnException) RemoteException(java.rmi.RemoteException) DataAccessException(org.vcell.util.DataAccessException)

Example 17 with Xref

use of org.vcell.pathway.Xref in project vcell by virtualcell.

the class AnnotationMapping method getXrefs.

private ArrayList<Xref> getXrefs(BioModel bioModel, HashMap<String, String> refInfo) {
    ArrayList<Xref> xRef = new ArrayList<Xref>();
    for (String id : refInfo.keySet()) {
        String[] temp = (refInfo.get(id)).split(":");
        String db = temp[0];
        String type = temp[1];
        if (db.toUpperCase().contains("OBO.GO")) {
            db = "GENE_ONTOLOGY";
            if (id.contains(":")) {
                id = id.split(":")[1];
            }
        }
        String refId = db + "_" + id;
        Xref xref = (Xref) bioModel.getPathwayModel().findBioPaxObject(refId);
        if (xref == null) {
            if (type.toLowerCase().contains("described")) {
                xref = new PublicationXref();
            } else if (type.toLowerCase().contains("homolog") || db.toUpperCase().contains("TAXONOMY")) {
                xref = new RelationshipXref();
            } else {
                xref = new UnificationXref();
            }
            xref.setId(id);
            xref.setDb(db.toUpperCase());
            xref.setID(refId);
        }
        xRef.add(xref);
    }
    return xRef;
}
Also used : Xref(org.vcell.pathway.Xref) UnificationXref(org.vcell.pathway.UnificationXref) RelationshipXref(org.vcell.pathway.RelationshipXref) PublicationXref(org.vcell.pathway.PublicationXref) PublicationXref(org.vcell.pathway.PublicationXref) UnificationXref(org.vcell.pathway.UnificationXref) ArrayList(java.util.ArrayList) RelationshipXref(org.vcell.pathway.RelationshipXref)

Example 18 with Xref

use of org.vcell.pathway.Xref in project vcell by virtualcell.

the class AnnotationMapping method createPhysicalEntity.

private PhysicalEntity createPhysicalEntity(ArrayList<Xref> xRef, ArrayList<String> refName, String name) {
    PhysicalEntity physicalEntity = null;
    if (isSmallMolecule(xRef)) {
        physicalEntity = new SmallMolecule();
    } else {
        physicalEntity = new PhysicalEntity();
    }
    physicalEntity.setName(refName);
    physicalEntity.setID("BIOMODEL_" + name);
    // physicalEntity.setxRef(xRef);
    for (Xref ref : xRef) {
        physicalEntity.getxRef().add(ref);
    }
    return physicalEntity;
}
Also used : Xref(org.vcell.pathway.Xref) UnificationXref(org.vcell.pathway.UnificationXref) RelationshipXref(org.vcell.pathway.RelationshipXref) PublicationXref(org.vcell.pathway.PublicationXref) PhysicalEntity(org.vcell.pathway.PhysicalEntity) SmallMolecule(org.vcell.pathway.SmallMolecule)

Example 19 with Xref

use of org.vcell.pathway.Xref in project vcell by virtualcell.

the class AnnotationMapping method createInteraction.

private Interaction createInteraction(ReactionStep reactionStep, ArrayList<Xref> xRef, ArrayList<String> name) {
    Interaction interaction = null;
    if (reactionStep instanceof SimpleReaction) {
        interaction = new BiochemicalReactionImpl();
    } else if (reactionStep instanceof FluxReaction) {
        interaction = new TransportImpl();
    }
    interaction.setName(name);
    interaction.setID("BIOMODEL_" + reactionStep.getName());
    for (Xref ref : xRef) {
        interaction.getxRef().add(ref);
    }
    return interaction;
}
Also used : Xref(org.vcell.pathway.Xref) UnificationXref(org.vcell.pathway.UnificationXref) RelationshipXref(org.vcell.pathway.RelationshipXref) PublicationXref(org.vcell.pathway.PublicationXref) SimpleReaction(cbit.vcell.model.SimpleReaction) BiochemicalReactionImpl(org.vcell.pathway.BiochemicalReactionImpl) Interaction(org.vcell.pathway.Interaction) FluxReaction(cbit.vcell.model.FluxReaction) TransportImpl(org.vcell.pathway.TransportImpl)

Example 20 with Xref

use of org.vcell.pathway.Xref 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

Xref (org.vcell.pathway.Xref)20 PublicationXref (org.vcell.pathway.PublicationXref)18 RelationshipXref (org.vcell.pathway.RelationshipXref)18 UnificationXref (org.vcell.pathway.UnificationXref)12 Element (org.jdom.Element)9 BioPaxObject (org.vcell.pathway.BioPaxObject)7 ArrayList (java.util.ArrayList)5 PathwayXMLHelper.schemaString (org.vcell.pathway.PathwayXMLHelper.schemaString)5 PhysicalEntity (org.vcell.pathway.PhysicalEntity)5 HashSet (java.util.HashSet)4 BioModelEntityObject (cbit.vcell.model.BioModelEntityObject)3 Entity (org.vcell.pathway.Entity)3 GroupObject (org.vcell.pathway.GroupObject)3 SBEntity (org.vcell.pathway.sbpax.SBEntity)3 SimpleReaction (cbit.vcell.model.SimpleReaction)2 SpeciesContext (cbit.vcell.model.SpeciesContext)2 Namespace (org.jdom.Namespace)2 MolecularType (org.vcell.model.rbm.MolecularType)2 XrefProxy (org.vcell.pathway.persistence.BiopaxProxy.XrefProxy)2 RelationshipObject (org.vcell.relationship.RelationshipObject)2