@Override public void mapClass( OWLIndividual bpInstance, BioPAXFactory bpFactory, XMLFileAdaptor fileAdaptor, Map<OWLIndividual, GKInstance> bpToRInstancesMap) throws Exception { RDFSClass cls = bpInstance.getRDFType(); if (cls != bpFactory.getpathwayClass()) return; // this method will work for pathway only GKInstance instance = fileAdaptor.createNewInstance(ReactomeJavaConstants.Pathway); bpToRInstancesMap.put(bpInstance, instance); }
private void getPathwayComponents( OWLIndividual bpInstance, BioPAXFactory bpFactory, GKInstance rPathway, Map<OWLIndividual, GKInstance> bpToRInstanceMap) throws Exception { OWLProperty prop = bpFactory.getOWLProperty(BioPAXJavaConstants.PATHWAY_COMPONENTS); Collection bpComponents = bpInstance.getPropertyValues(prop); if (bpComponents == null || bpComponents.size() == 0) return; OWLIndividual bpComp; RDFSClass bpCompType; GKInstance rComp; // Used to check value // Try to make it work for the new schema (6/13/07 - wgm) SchemaAttribute hasComponentAtt = null; if (rPathway.getSchemClass().isValidAttribute(ReactomeJavaConstants.hasComponent)) hasComponentAtt = rPathway.getSchemClass().getAttribute(ReactomeJavaConstants.hasComponent); else if (rPathway.getSchemClass().isValidAttribute(ReactomeJavaConstants.hasEvent)) hasComponentAtt = rPathway.getSchemClass().getAttribute(ReactomeJavaConstants.hasEvent); if (hasComponentAtt == null) return; // Do a sort based on NEXT_STEP for (Iterator it = bpComponents.iterator(); it.hasNext(); ) { Object obj = it.next(); if (!(obj instanceof OWLIndividual)) { System.out.println(obj + " is not an OWLIndividual object!"); throw new IllegalStateException( "Object in the pathway component list is not an OWLIndividual object: " + obj); } bpComp = (OWLIndividual) obj; bpCompType = bpComp.getRDFType(); if (bpCompType == bpFactory.getpathwayStepClass()) { // Grep the wrapped interaction or pathway instances prop = bpFactory.getOWLProperty(BioPAXJavaConstants.STEP_INTERACTIONS); Collection stepInteractions = bpComp.getPropertyValues(prop); if (stepInteractions == null || stepInteractions.size() == 0) continue; for (Iterator it1 = stepInteractions.iterator(); it1.hasNext(); ) { OWLIndividual stepInteraction = (OWLIndividual) it1.next(); if (stepInteraction.getRDFType() != bpFactory.getcontrolClass()) { rComp = bpToRInstanceMap.get(stepInteraction); // Some control Individuals are listed under PATHWAY_COMPONENT. However, // they should not be a value in hasComponent if (rComp != null && hasComponentAtt.isValidValue(rComp)) rPathway.addAttributeValue(hasComponentAtt, rComp); } } } else if (bpCompType != bpFactory.getcontrolClass() && !bpCompType.isSubclassOf(bpFactory.getcontrolClass())) { // Another two types should be: Interaction and Pathway. But should exclude // control class. Control class is attached to Reaction in Reactome rComp = bpToRInstanceMap.get(bpComp); if (rComp != null) rPathway.addAttributeValue(hasComponentAtt, rComp); } } }