use of org.vcell.pathway.BioPaxObject in project vcell by virtualcell.
the class PathwayMapping method createReactionStepFromPathway.
/*
* for reaction:
* 1. annotate the selected vcell object using linked pathway conversion
* 2. add non-existing speciesContexts from linked pathway conversion
* 3. add links between relative vcell objects and pathway objects
* Questions:
* - how to deal with the case that the reaction is existing in the model?
* + add it in no matter what?
* (this is the version we have now:
* add the duplicated reactions in without name changing,
* all duplicated reactions share the same participant objects)
* + just modify the existing one?
*/
private void createReactionStepFromPathway(BioModel bioModel, Process process, ReactionStep reactionStep, RelationshipObject relationshipObject, boolean addSubunits) throws Exception {
// annotate the selected vcell object using linked pathway object
// add non-existing speciesContexts from linked pathway conversion
ReactionParticipant[] rpArray = parseReaction(reactionStep, bioModel, relationshipObject);
// create a hashtable for interaction Participants
Hashtable<String, BioPaxObject> participantTable = new Hashtable<String, BioPaxObject>();
for (BioPaxObject bpObject : ((Conversion) relationshipObject.getBioPaxObject()).getLeft()) {
if (((PhysicalEntity) bpObject).getName().size() == 0) {
participantTable.put(getSafetyName(((PhysicalEntity) bpObject).getID()), bpObject);
} else {
participantTable.put(getSafetyName(((PhysicalEntity) bpObject).getName().get(0)), bpObject);
}
}
for (BioPaxObject bpObject : ((Conversion) relationshipObject.getBioPaxObject()).getRight()) {
if (((PhysicalEntity) bpObject).getName().size() == 0) {
participantTable.put(getSafetyName(((PhysicalEntity) bpObject).getID()), bpObject);
} else {
participantTable.put(getSafetyName(((PhysicalEntity) bpObject).getName().get(0)), bpObject);
}
}
for (ReactionParticipant rp : rpArray) {
SpeciesContext speciesContext = rp.getSpeciesContext();
if (bioModel.getModel().getSpeciesContext(speciesContext.getName()) == null) {
// if the speciesContext is not existed, then add it to the bioModel and link it to the corresponding pathway object
if (bioModel.getModel().getSpecies(speciesContext.getName()) == null) {
bioModel.getModel().addSpecies(speciesContext.getSpecies());
}
bioModel.getModel().addSpeciesContext(speciesContext);
RelationshipObject newSpeciesContext = new RelationshipObject(speciesContext, participantTable.get(speciesContext.getName()));
bioModel.getRelationshipModel().addRelationshipObject(newSpeciesContext);
} else {
// if it is in the bioModel, then check whether it links to pathway object or not
HashSet<RelationshipObject> linkedReObjects = bioModel.getRelationshipModel().getRelationshipObjects(bioModel.getModel().getSpeciesContext(speciesContext.getName()));
if (linkedReObjects != null) {
boolean isLinked = false;
for (RelationshipObject reObject : linkedReObjects) {
if (reObject.getBioPaxObject() == participantTable.get(speciesContext.getName())) {
isLinked = true;
break;
}
}
if (!isLinked) {
RelationshipObject newSpeciesContext = new RelationshipObject(speciesContext, participantTable.get(speciesContext.getName()));
bioModel.getRelationshipModel().addRelationshipObject(newSpeciesContext);
}
} else {
RelationshipObject newSpeciesContext = new RelationshipObject(speciesContext, participantTable.get(speciesContext.getName()));
bioModel.getRelationshipModel().addRelationshipObject(newSpeciesContext);
}
}
}
(reactionStep).setReactionParticipants(rpArray);
// add Control to the reaction
if (process.getControl() != null) {
for (InteractionParticipant pe : process.getControl().getParticipants()) {
SpeciesContext newSpeciescontext = createSpeciesContextFromBioPaxObject(bioModel, pe.getPhysicalEntity(), addSubunits);
(reactionStep).addReactionParticipant(new Catalyst(null, reactionStep, newSpeciescontext));
}
}
addKinetics(reactionStep, process);
}
use of org.vcell.pathway.BioPaxObject in project vcell by virtualcell.
the class AnnotationMapping method annotation2BioPaxObject.
public String annotation2BioPaxObject(BioModel bioModel, Identifiable identifiable) {
String name = "";
String type = "";
ArrayList<String> componentInfo = getComponentInfo(bioModel, identifiable);
if (componentInfo.size() > 0) {
name = componentInfo.get(0);
type = componentInfo.get(1);
}
String info = type + " : " + name;
HashMap<String, String> refInfo = getRefInfo(bioModel, identifiable);
// otherwise, create object and add link
if (type.equals(VCID.CLASS_SPECIES)) {
// lookup name by speciesContext
ArrayList<SpeciesContext> speciesContextArrList = new ArrayList<SpeciesContext>(Arrays.asList(new SpeciesContext[] { bioModel.getModel().getSpeciesContext(name) }));
if (speciesContextArrList.get(0) == null) {
speciesContextArrList.clear();
// lookup name by species
for (int i = 0; i < bioModel.getModel().getSpeciesContexts().length; i++) {
if (bioModel.getModel().getSpeciesContexts()[i].getSpecies().getCommonName().equals(name)) {
speciesContextArrList.add(bioModel.getModel().getSpeciesContexts()[i]);
}
}
}
for (int i = 0; i < speciesContextArrList.size(); i++) {
SpeciesContext speciesContext = speciesContextArrList.get(i);
if (bioModel.getRelationshipModel().getRelationshipObjects(speciesContext).size() == 0) {
ArrayList<Xref> xRef = getXrefs(bioModel, refInfo);
ArrayList<String> refName = getNameRef(xRef, name);
BioPaxObject bpObject = bioModel.getPathwayModel().findFromNameAndType(refName.get(0), EntityImpl.TYPE_PHYSICALENTITY);
if (bpObject == null) {
bpObject = createPhysicalEntity(xRef, refName, name);
bioModel.getPathwayModel().add(bpObject);
}
if (!isLinked(bioModel, bpObject, speciesContext)) {
// create linkage
RelationshipObject newRelationship = new RelationshipObject(speciesContext, bpObject);
bioModel.getRelationshipModel().addRelationshipObject(newRelationship);
return info;
}
}
}
} else if (type.equals(VCID.CLASS_BIOMODEL)) {
// BioPaxObject bpObject = bioModel.getPathwayModel().findFromName(refName.get(0), "Pathway");
// if(bpObject == null){
// bpObject = createPathway(componentInfo, refInfo);
// bioModel.getPathwayModel().add(bpObject);
// return info;
// }
} else if (type.equals(VCID.CLASS_REACTION_STEP)) {
ReactionStep reactionStep = bioModel.getModel().getReactionStep(name);
ArrayList<Xref> xRef = getXrefs(bioModel, refInfo);
ArrayList<String> refName = getNameRef(xRef, name);
if (bioModel.getRelationshipModel().getRelationshipObjects(reactionStep).size() == 0) {
BioPaxObject bpObject = bioModel.getPathwayModel().findFromNameAndType(refName.get(0), EntityImpl.TYPE_INTERACTION);
if (bpObject == null) {
bpObject = createInteraction(reactionStep, xRef, refName);
bioModel.getPathwayModel().add(bpObject);
}
if (!isLinked(bioModel, bpObject, reactionStep)) {
// create linkage
RelationshipObject newRelationship = new RelationshipObject(reactionStep, bpObject);
bioModel.getRelationshipModel().addRelationshipObject(newRelationship);
return info;
}
}
}
return null;
}
use of org.vcell.pathway.BioPaxObject in project vcell by virtualcell.
the class PathwayProducerBiopax3 method addContentGroupObject.
private Element addContentGroupObject(BioPaxObject bpObject, Element element) {
element = addContentEntity(bpObject, element);
GroupObject ob = (GroupObject) bpObject;
Element tmpElement = null;
if (ob.getGroupedObjects() != null && ob.getGroupedObjects().size() > 0) {
HashSet<BioPaxObject> list = ob.getGroupedObjects();
for (BioPaxObject item : list) {
tmpElement = new Element("groupedObject", bp);
addIDToProperty(tmpElement, item);
mustPrintObject(item);
element.addContent(tmpElement);
}
}
if (ob.getType() != null) {
tmpElement = new Element("type", bp);
tmpElement.setAttribute("resource", ob.getType().toString(), rdf);
tmpElement.setText(ob.getType().toString());
element.addContent(tmpElement);
}
return element;
}
use of org.vcell.pathway.BioPaxObject in project vcell by virtualcell.
the class PathwayProducerBiopax3 method getXML.
public void getXML(PathwayModel pathwayModel, Element rootElement) {
objectsToPrint.addAll(pathwayModel.getBiopaxObjects());
biopaxElement = rootElement;
biopaxElement.addNamespaceDeclaration(bp);
biopaxElement.addNamespaceDeclaration(rdf);
if (pathwayModel.getDiagramObjects().size() > 0) {
for (String diagramObjectID : pathwayModel.getDiagramObjects()) {
if (diagramObjectID != null) {
Element e = new Element("DiagramObjectsID");
e.setText(diagramObjectID);
biopaxElement.addContent(e);
}
}
}
while (objectsToPrint.size() > 0) {
BioPaxObject bpObject = objectsToPrint.iterator().next();
if (bpObject == null) {
System.out.println("PathwayProducerBiopax3: null BioPaxObject in the PathwayModel.");
continue;
}
String className = bpObject.getClass().getName().substring(1 + bpObject.getClass().getName().lastIndexOf('.'));
// System.out.println("object: " + className);
if (className.equals("Test")) {
System.out.println("PathwayProducerBiopax3::getXML()");
// sbPAX section
} else if (className.equals("SBMeasurable")) {
biopaxElement.addContent(addObjectSBMeasurable(bpObject, className));
} else if (className.equals("SBState")) {
biopaxElement.addContent(addObjectSBState(bpObject, className));
} else if (className.equals("SBVocabulary")) {
biopaxElement.addContent(addObjectSBVocabulary(bpObject, className));
// bioPAX section
} else if (className.equals("Pathway")) {
biopaxElement.addContent(addObjectPathway(bpObject, className));
} else if (className.equals("BiochemicalReactionImpl")) {
biopaxElement.addContent(addObjectBiochemicalReaction(bpObject, "BiochemicalReaction"));
} else if (className.equals("ConversionImpl")) {
biopaxElement.addContent(addObjectConversion(bpObject, "Conversion"));
} else if (className.equals("CellularLocationVocabulary")) {
biopaxElement.addContent(addObjectCellularLocationVocabulary(bpObject, className));
} else if (className.equals("CellVocabulary")) {
biopaxElement.addContent(addObjectCellVocabulary(bpObject, className));
} else if (className.equals("EntityReferenceTypeVocabulary")) {
biopaxElement.addContent(addObjectEntityReferenceTypeVocabulary(bpObject, className));
} else if (className.equals("EvidenceCodeVocabulary")) {
biopaxElement.addContent(addObjectEvidenceCodeVocabulary(bpObject, className));
} else if (className.equals("ExperimentalFormVocabulary")) {
biopaxElement.addContent(addObjectExperimentalFormVocabulary(bpObject, className));
} else if (className.equals("InteractionVocabulary")) {
biopaxElement.addContent(addObjectInteractionVocabulary(bpObject, className));
} else if (className.equals("PhenotypeVocabulary")) {
biopaxElement.addContent(addObjectPhenotypeVocabulary(bpObject, className));
} else if (className.equals("RelationshipTypeVocabulary")) {
biopaxElement.addContent(addObjectRelationshipTypeVocabulary(bpObject, className));
} else if (className.equals("SequenceModificationVocabulary")) {
biopaxElement.addContent(addObjectSequenceModificationVocabulary(bpObject, className));
} else if (className.equals("SequenceRegionVocabulary")) {
biopaxElement.addContent(addObjectSequenceRegionVocabulary(bpObject, className));
} else if (className.equals("TissueVocabulary")) {
biopaxElement.addContent(addObjectTissueVocabulary(bpObject, className));
} else if (className.equals("PublicationXref")) {
biopaxElement.addContent(addObjectPublicationXref(bpObject, className));
} else if (className.equals("RelationshipXref")) {
biopaxElement.addContent(addObjectRelationshipXref(bpObject, className));
} else if (className.equals("UnificationXref")) {
biopaxElement.addContent(addObjectUnificationXref(bpObject, className));
} else if (className.equals("DnaReference")) {
biopaxElement.addContent(addObjectDnaReference(bpObject, className));
} else if (className.equals("DnaRegionReference")) {
biopaxElement.addContent(addObjectDnaRegionReference(bpObject, className));
} else if (className.equals("ProteinReference")) {
biopaxElement.addContent(addObjectProteinReference(bpObject, className));
} else if (className.equals("RnaReference")) {
biopaxElement.addContent(addObjectRnaReference(bpObject, className));
} else if (className.equals("RnaRegionReference")) {
biopaxElement.addContent(addObjectRnaRegionReference(bpObject, className));
} else if (className.equals("SmallMoleculeReference")) {
biopaxElement.addContent(addObjectSmallMoleculeReference(bpObject, className));
} else if (className.equals("Provenance")) {
biopaxElement.addContent(addObjectProvenance(bpObject, className));
} else if (className.equals("Control")) {
biopaxElement.addContent(addObjectControl(bpObject, className));
} else if (className.equals("Catalysis")) {
biopaxElement.addContent(addObjectCatalysis(bpObject, className));
} else if (className.equals("Modulation")) {
biopaxElement.addContent(addObjectModulation(bpObject, className));
} else if (className.equals("TemplateReactionRegulation")) {
biopaxElement.addContent(addObjectTemplateReactionRegulation(bpObject, className));
} else if (className.equals("Complex")) {
biopaxElement.addContent(addObjectComplex(bpObject, className));
} else if (className.equals("Protein")) {
biopaxElement.addContent(addObjectProtein(bpObject, className));
} else if (className.equals("Dna")) {
biopaxElement.addContent(addObjectDna(bpObject, className));
} else if (className.equals("DnaRegion")) {
biopaxElement.addContent(addObjectDnaRegion(bpObject, className));
} else if (className.equals("Rna")) {
biopaxElement.addContent(addObjectRna(bpObject, className));
} else if (className.equals("RnaRegion")) {
biopaxElement.addContent(addObjectRnaRegion(bpObject, className));
} else if (className.equals("SmallMolecule")) {
biopaxElement.addContent(addObjectSmallMolecule(bpObject, className));
} else if (className.equals("BioSource")) {
biopaxElement.addContent(addObjectBioSource(bpObject, className));
} else if (className.equals("EntityFeature")) {
biopaxElement.addContent(addObjectEntityFeature(bpObject, className));
} else if (className.equals("ModificationFeature")) {
biopaxElement.addContent(addObjectModificationFeature(bpObject, className));
} else if (className.equals("CovalentBindingFeature")) {
biopaxElement.addContent(addObjectCovalentBindingFeature(bpObject, className));
} else if (className.equals("FragmentFeature")) {
biopaxElement.addContent(addObjectFragmentFeature(bpObject, className));
} else if (className.equals("BindingFeature")) {
biopaxElement.addContent(addObjectBindingFeature(bpObject, className));
} else if (className.equals("SequenceInterval")) {
biopaxElement.addContent(addObjectSequenceInterval(bpObject, className));
} else if (className.equals("SequenceSite")) {
biopaxElement.addContent(addObjectSequenceSite(bpObject, className));
} else if (className.equals("Stoichiometry")) {
biopaxElement.addContent(addObjectStoichiometry(bpObject, className));
} else if (className.equals("PathwayStep")) {
biopaxElement.addContent(addObjectPathwayStep(bpObject, className));
} else if (className.equals("BiochemicalPathwayStep")) {
biopaxElement.addContent(addObjectBiochemicalPathwayStep(bpObject, className));
} else if (className.equals("PhysicalEntity")) {
biopaxElement.addContent(addObjectPhysicalEntity(bpObject, className));
//
// // not found "as is" in tested sample
} else if (className.equals("Gene")) {
biopaxElement.addContent(addObjectGene(bpObject, className));
} else if (className.equals("Ontology")) {
// showIgnored(bpObject, className);
} else if (className.equals("Interaction")) {
biopaxElement.addContent(addObjectInteraction(bpObject, className));
} else if (className.equals("Transport")) {
biopaxElement.addContent(addObjectTransport(bpObject, className));
} else if (className.equals("TransportWithBiochemicalReaction")) {
biopaxElement.addContent(addObjectTransportWithBiochemicalReaction(bpObject, className));
} else if (className.equals("GeneticInteraction")) {
biopaxElement.addContent(addObjectGeneticInteraction(bpObject, className));
} else if (className.equals("MolecularInteraction")) {
biopaxElement.addContent(addObjectMolecularInteraction(bpObject, className));
} else if (className.equals("TemplateReaction")) {
biopaxElement.addContent(addObjectTemplateReaction(bpObject, className));
} else if (className.equals("ComplexAssembly")) {
biopaxElement.addContent(addObjectComplexAssembly(bpObject, className));
} else if (className.equals("Degradation")) {
biopaxElement.addContent(addObjectDegradation(bpObject, className));
} else if (className.equals("ChemicalStructure")) {
biopaxElement.addContent(addObjectChemicalStructure(bpObject, className));
} else if (className.equals("DeltaG")) {
biopaxElement.addContent(addObjectDeltaG(bpObject, className));
} else if (className.equals("Evidence")) {
biopaxElement.addContent(addObjectEvidence(bpObject, className));
} else if (className.equals("ExperimentalForm")) {
biopaxElement.addContent(addObjectExperimentalForm(bpObject, className));
} else if (className.equals("KPrime")) {
biopaxElement.addContent(addObjectKPrime(bpObject, className));
} else if (className.equals("Score")) {
biopaxElement.addContent(addObjectScore(bpObject, className));
} else if (className.equals("GroupObject")) {
biopaxElement.addContent(addObjectGroupObject(bpObject, className));
} else {
showUnexpected(bpObject);
}
objectsPrinted.add(bpObject);
objectsToPrint.remove(bpObject);
}
return;
}
use of org.vcell.pathway.BioPaxObject in project vcell by virtualcell.
the class PathwayGrouping method computeNeighbors.
// get the neighbor of a given groupObject
public HashSet<BioPaxObject> computeNeighbors(PathwayModel pathwayModel, BioPaxObject bioPaxObject) {
Map<BioPaxObject, HashSet<BioPaxObject>> parentMap = pathwayModel.refreshParentMap();
HashSet<BioPaxObject> neighbors_temp = new HashSet<BioPaxObject>();
HashSet<BioPaxObject> components = new HashSet<BioPaxObject>();
if (bioPaxObject instanceof GroupObject) {
components = ((GroupObject) bioPaxObject).getGroupedObjects();
for (BioPaxObject bpObject : components) {
if (bpObject instanceof GroupObject) {
// compute neighbors for group object
neighbors_temp.addAll(computeNeighbors(pathwayModel, parentMap, (GroupObject) bpObject));
} else {
if (parentMap.get(bpObject) != null) {
neighbors_temp.addAll(parentMap.get(bpObject));
}
neighbors_temp.addAll(pathwayModel.getBioPaxElements(bpObject));
}
}
} else {
neighbors_temp.addAll(pathwayModel.getBioPaxElements(bioPaxObject));
if (parentMap.get(bioPaxObject) != null) {
neighbors_temp.addAll(parentMap.get(bioPaxObject));
}
}
Map<BioPaxObject, BioPaxObject> groupMap = pathwayModel.getGroupMap();
HashSet<BioPaxObject> neighbors = new HashSet<BioPaxObject>();
for (BioPaxObject bpo : neighbors_temp) {
neighbors.add(findGroupAncestor(groupMap, bpo));
}
neighbors.removeAll(components);
neighbors.remove(null);
neighbors.remove(bioPaxObject);
HashSet<BioPaxObject> notImported = new HashSet<BioPaxObject>();
for (BioPaxObject bpo : neighbors) {
if (!pathwayModel.getBiopaxObjects().contains(bpo)) {
notImported.add(bpo);
}
}
neighbors.remove(notImported);
return neighbors;
}
Aggregations