/** * Constructor. * * @param model * @param forceInteractionToComplex - always generate Complex instead of MolecularInteraction */ public EntryMapper(Model model, boolean forceInteractionToComplex) { this.bpModel = model; this.xmlBase = (model.getXmlBase()==null) ? "" : model.getXmlBase(); this.counter = System.currentTimeMillis(); this.forceInteractionToComplex = forceInteractionToComplex; }
/** * Creates a name for to the BioPAX model * using its top-level process name(s). * * @param model * @return */ public static String getName(Model model) { StringBuffer modelName = new StringBuffer(); Collection<Pathway> pws = ModelUtils.getRootElements(model, Pathway.class); for(Pathway pw: pws) { modelName.append(" ").append(getName(pw)); } if(modelName.length()==0) { Collection<Interaction> itrs = ModelUtils.getRootElements(model, Interaction.class); for(Interaction it: itrs) { modelName.append(" ").append(getName(it)); } } if(modelName.length()==0) { modelName.append(model.getXmlBase()); } String name = modelName.toString().trim(); return name; }
public String identify(Object obj) { String id = ""; if(obj instanceof SimpleIOHandler) { SimpleIOHandler r = (SimpleIOHandler) obj; id = r.getClass().getSimpleName(); try { id = r.getId(); //current element URI } catch (Throwable e) { id = r.getXmlStreamInfo(); //location } } else if (obj instanceof BioPAXElement && ((BioPAXElement)obj).getUri() != null) { id = ((BioPAXElement) obj).getUri().replaceFirst("^.+#", ""); // - strictly spk., does not always get the local part (depends on xml:base) but is OK. } else if(obj instanceof Model) { id = obj + "; xml:base=" + ((Model) obj).getXmlBase(); } else { id = "" + obj; } return id; } }
private OntModel initializeEmptyOntModel(Model model) { OntModel ontModel = createModel(); String xmlBase = model.getXmlBase(); if (xmlBase == null || xmlBase.equals("")) { xmlBase = "http://biopax.org/paxtools#"; } Ontology base = ontModel.createOntology(xmlBase); String uri = model.getLevel().getNameSpace(); uri = uri.substring(0, uri.length() - 1); if (log.isDebugEnabled()) { log.debug("uri = " + uri); } ontModel.setNsPrefixes(model.getNameSpacePrefixMap()); base.addImport(ontModel.createResource(uri)); ontModel.loadImports(); return ontModel; }
/** * Writes a model in OWL format using the an output stream. * @param model model to be converted into OWL format * @param outputStream output stream to which the model will be written */ public void convertToOWL(Model model, OutputStream outputStream) { objectToIndividualMap = new HashMap<Object, Individual>(); OntModel ontModel = initializeEmptyOntModel(model); createIndividuals(ontModel, model); bindObjectsToProperties(ontModel, model); RDFWriter writer = ontModel.getWriter("RDF/XML-ABBREV"); writer.setProperty("relativeURIs", "same-document, relative, parent, absolute"); String base = model.getXmlBase(); if (log.isDebugEnabled()) { log.debug("base = " + base); } if(base != null && !"".equals(base)) writer.setProperty("xmlbase", base); writer.setProperty("showXmlDeclaration", "true"); writer.write(ontModel, outputStream, base); //objectToIndividualMap = null; }
|| e instanceof Complex || e.getModelInterface().equals(PhysicalEntity.class)) { String cpathId = e.getRDFId().replaceFirst(model.getXmlBase(), ""); if (cpathId != null) { cpathId = cpathId.replaceAll("CPATH-", "");
throw new RuntimeException("SBGN Layout of " + model.getXmlBase() + ((model.getName()==null) ? "" : model.getName()) + " failed.", e);