/** * Gets the local part of the BioPAX element ID. * * @param bpe * @return */ public static String getLocalId(BioPAXElement bpe) { String id = bpe.getRDFId(); return (id != null) ? id.replaceFirst("^.+#", "") : null; }
/** * Checks if the blacklist contains id of any mediator * @param ids blacklist * @param mediators mediators of inferred interactions * @return true if any mediator is blacklisted */ private boolean intersects(Set<String> ids, Set<BioPAXElement> mediators) { for (BioPAXElement mediator : mediators) { if (ids.contains(mediator.getRDFId())) return true; } return false; }
public void check(BioPAXElement thing, boolean fix) { String rdfid = thing.getRDFId(); if(rdfid != null && rdfid.length() > URI_MAX_LENGTH) error(thing, "too.long.id", false, rdfid.length(), URI_MAX_LENGTH); }
@Override public void run() { try { simpleExporter.writeObject(writer, bpe); } catch (Exception e) { log.error("Failed printing '" + bpe.getRDFId() + "' to OWL", e); } } }, com.ctc.wstx.stax.WstxInputFactory.class);
private static String toOwl(BioPAXElement bpe) { StringWriter writer = new StringWriter(); try { SimpleIOHandler simpleExporter = new SimpleIOHandler(BioPAXLevel.L3); simpleExporter.writeObject(writer, bpe); } catch (Exception e) { log.error("Failed printing '" + bpe.getRDFId() + "' to OWL", e); } return writer.toString(); }
/** * Gets object's "id" to use in error messages. * * If Object is BioPAXElement - its RDFid suffix (after #), * otherwise - simple class name + hash code. * * @param obj * @return string id */ public static String getId(Object obj) { String id = ""; if (obj instanceof BioPAXElement && ((BioPAXElement)obj).getRDFId() != null) { id = getLocalId((BioPAXElement)obj); } else { id = "" + obj; } return id; }
/** * Selects only PhysicalEntity as seed. * @param interactionSet inferred interactions * @param entity this must be a PhysicalEntity for L3 * @param model BioPAX model */ public final void inferInteractions(InteractionSet interactionSet, BioPAXElement entity, Model model) { if (entity instanceof PhysicalEntity) { inferInteractionsFromPE((InteractionSetL3) interactionSet, ((PhysicalEntity) entity), model); } else { if (log.isInfoEnabled()) log.info("Not a PE Skipping." + entity.getRDFId()); } }
public void check(BioPAXElement thing, boolean fix) { String rdfid = thing.getRDFId(); if(rdfid != null) { try { URI.create(rdfid); } catch (IllegalArgumentException e) { error(thing, "invalid.rdf.id", false, "not a valid URI: " + rdfid); } } else error(thing, "invalid.rdf.id", false, "null value"); }
/** * Tries to use a rule to infer interactions. If an exception occurs other than * MaximumInteractionThresholdExceedException, logs the error and continues. * @param model model to use * @param interactions inferred interactions * @param bpe base element for inference * @param rule current interaction rule * @exception MaximumInteractionThresholdExceedException if generated rules are over a certain * number */ private void tryInferringRule(Model model, InteractionSet interactions, BioPAXElement bpe, InteractionRule rule) { try { rule.inferInteractions(interactions, bpe, model); } catch (MaximumInteractionThresholdExceedException e) { throw e; } catch (Exception e) { log.error("Exception while applying rule :" + this.getClass().getSimpleName() + "to the element: " + bpe.getRDFId(), e); } }
/** * Gets the display name of the node * or URI. * * @param bpe BioPAX Element * @return */ public static String getName(BioPAXElement bpe) { String nodeName = null; if(bpe instanceof Named) nodeName = ((Named)bpe).getDisplayName(); return (nodeName == null || nodeName.isEmpty()) ? bpe.getRDFId() : StringEscapeUtils.unescapeHtml(nodeName); }
@Around("execution(public void org.biopax.validator.Rule*+.check(..)) && args(thing, fix)") public void checkBehavior(ProceedingJoinPoint jp, Object thing, boolean fix) throws Throwable { if(thing==null) return; Rule<?> r = (Rule<?>) jp.getTarget(); if (logger.isTraceEnabled()) { String what = (thing instanceof BioPAXElement) ? ((BioPAXElement)thing).getRDFId() : thing.toString(); logger.trace(r.getName() + " (" + r.getBehavior() + ") checks " + what); } if (r.getBehavior() != Behavior.IGNORE) { jp.proceed(); } else { if (logger.isTraceEnabled()) { logger.trace("skipped"); } } }
/** * Filters out interactions whose source or target are in black list. * @param interactions interactions to filter * @param blackList IDs of unwanted elements */ protected void removeInteractionsWithBlackListMolecules(Set<SimpleInteraction> interactions, Set<String> blackList) { Iterator<SimpleInteraction> iter = interactions.iterator(); while (iter.hasNext()) { SimpleInteraction inter = iter.next(); if (blackList.contains(inter.getSource().getRDFId()) || blackList.contains(inter.getTarget().getRDFId()) || intersects(blackList, inter.getMediators())) { iter.remove(); } } }
private void createIndividuals(OntModel ontModel, Model model) { for (BioPAXElement bp : model.getObjects()) { String name = bp.getModelInterface().getName(); name = name.substring(name.lastIndexOf('.') + 1); OntClass ontClass = ontModel.getOntClass(this.getLevel().getNameSpace() + name); if (log.isTraceEnabled()) { log.trace("ontClass = " + ontClass); } Individual individual = ontModel.createIndividual(bp.getRDFId(), ontClass); if (log.isTraceEnabled()) { log.trace("individual = " + individual); } objectToIndividualMap.put(bp, individual); } }
public static String getLocalPartRdfId(BioPAXElement bpe) { if(bpe == null) return ""; // also fix pEPs String id = (bpe instanceof physicalEntityParticipant && ((physicalEntityParticipant)bpe).getPHYSICAL_ENTITY()!=null) ? ((physicalEntityParticipant)bpe).getPHYSICAL_ENTITY().getRDFId() : bpe.getRDFId(); return id.replaceFirst("^.+#", ""); }
/** * Gets or infers the name of the node. * * @param bpe BioPAX Element * @return */ private static String getNodeName(BioPAXElement bpe) { if(bpe == null) { return ""; } String nodeName = getShortName(bpe); if (nodeName == null || nodeName.length()== 0) { nodeName = getStandardName(bpe); if (nodeName == null || nodeName.length() == 0) { Collection<String> names = getSynonyms(bpe); if (!names.isEmpty()) nodeName = getTheShortestString(names); } } return (nodeName == null || nodeName.length() == 0) ? bpe.getRDFId() : StringEscapeUtils.unescapeHtml(nodeName); }
if(nodeA == null) { log.debug("linkNodes: no node was created for " + bpeA.getModelInterface() + " " + bpeA.getRDFId()); return; //e.g., we do not create any pathway nodes currently... if(nodeB == null) { log.debug("linkNodes: no node was created for " + bpeB.getModelInterface() + " " + bpeB.getRDFId()); return; //e.g., we do not create any pathway nodes currently...
public static String generateId(BioPAXElement bpe) { String id = (bpe instanceof physicalEntityParticipant && ((physicalEntityParticipant)bpe).getPHYSICAL_ENTITY()!=null) ? ((physicalEntityParticipant)bpe).getPHYSICAL_ENTITY().getRDFId() : bpe.getRDFId(); return Cytoscape.getCurrentNetwork().getIdentifier().hashCode() + "" + id.hashCode() + "-" + getLocalPartRdfId(bpe); }
@Override protected void visit(Object value, BioPAXElement parent, Model model, PropertyEditor editor) { if (value instanceof process || value instanceof pathwayStep) { if (value instanceof pathway && thing.getRDFId().equalsIgnoreCase( ((BioPAXElement) value).getRDFId())) { error(thing, "cyclic.inclusion", false, getVisited().toString()); return; } traverse((BioPAXElement) value, model); } } };