/** * Gets all left and right participant of a conversion in a set. * @param aConversion Conversion to get participants * @return left and right participants of the conversion */ private HashSet<PhysicalEntity> mergedSet(Conversion aConversion) { HashSet<PhysicalEntity> hashSet = new HashSet<PhysicalEntity>(); hashSet.addAll(aConversion.getLeft()); hashSet.addAll(aConversion.getRight()); return hashSet; }
/** * This method returns true iff conversion can go from/to the side specified by the first parameter in the direction * specified by the second parameter * * @param targetSide true if flow needs to be checked from/to the left side false otherwise * @param forward true if we are asking if a flow can start from the targetSide, false if we are asking if a flow * can go to the targetSide. * @return */ private boolean canFlow(boolean targetSide, boolean forward) { boolean flow = true; ConversionDirectionType cd = conv.getConversionDirection(); if (cd != null) switch (cd) { case LEFT_TO_RIGHT: flow = !(targetSide ^ forward); break; case RIGHT_TO_LEFT: flow = (targetSide ^ forward); break; default: flow = true; } return flow; }
/** * Searches the controlling catalysis for possible direction of the conversion. * @param conv the conversion * @return direction inferred from catalysis objects */ protected ConversionDirectionType findDirectionInCatalysis(Conversion conv) { Set<ConversionDirectionType> dirs = new HashSet<ConversionDirectionType>(); for (Control control : conv.getControlledOf()) { ConversionDirectionType dir = getCatalysisDirection(control); if (dir != null) dirs.add(dir); } if (dirs.size() > 1) return ConversionDirectionType.REVERSIBLE; else if (!dirs.isEmpty()) return dirs.iterator().next(); else return null; }
@Override public void check(Conversion thing, boolean fix) { float lsto = getStoichiometry(thing.getParticipantStoichiometry(), thing.getLeft()), rsto = getStoichiometry(thing.getParticipantStoichiometry(), thing.getRight()), diff = Math.abs(lsto - rsto); if(diff > 0) error(thing, "stoichiometry.mismatch", false, lsto, rsto); }
public void check(final Validation validation, Conversion thing) { //for thread safety (concurrency) we're using a new fetcher here rather than static one Fetcher fetcher = new Fetcher( SimpleEditorMap.L3, new Filter<PropertyEditor>() { //complex.component only public boolean filter(PropertyEditor editor) { return editor.getProperty().equals("component"); } }); Set<PhysicalEntity> left = new HashSet<PhysicalEntity>(getPEsRecursively(thing.getLeft(), fetcher)); //need a mutable set Set<PhysicalEntity> right = getPEsRecursively(thing.getRight(), fetcher); left.removeAll(right); int complexDiff = getComplexCount(thing.getLeft()) - getComplexCount(thing.getRight()); if( left.isEmpty() // when there are no modifications really, but different no. complexes or participants && (complexDiff != 0 || thing.getLeft().size() - thing.getRight().size() != 0 )) error(validation, thing, "wrong.conversion.class", false, thing.getModelInterface()); }
assert cnv.getConversionDirection() == null || cnv.getConversionDirection().equals(direction) || cnv.getConversionDirection().equals(ConversionDirectionType.REVERSIBLE); process.setId(convertID(cnv.getUri()) + "_" + direction.name().replaceAll("_","")); glyphMap.put(process.getId(), process); cnv.getRight() : cnv.getLeft(); Set<PhysicalEntity> output = direction.equals(ConversionDirectionType.RIGHT_TO_LEFT) ? cnv.getLeft() : cnv.getRight(); processControllers(cnv.getControlledOf(), process); uris.add(cnv.getUri()); sbgn2BPMap.put(process.getId(), uris);
Set<PhysicalEntity> lefts = conversionBP.getLeft(); for (PhysicalEntity left : lefts) { leftItems.add(left.getRDFId().split("#")[1]); Set<PhysicalEntity> rights = conversionBP.getRight(); for (PhysicalEntity right : rights) { rightItems.add(right.getRDFId().split("#")[1]); if (conversionBP.getConversionDirection() != null) { switch (conversionBP.getConversionDirection().toString()) { case "REVERSIBLE": reaction.setReversible(true); if (conversionBP.getSpontaneous() != null) { if (conversionBP.getSpontaneous()) { reaction.setSpontaneous(true); } else { Set<Stoichiometry> stoichiometryItems = conversionBP.getParticipantStoichiometry(); for (Stoichiometry stoichiometryItem : stoichiometryItems) { Map<String, Object> stchmtr = new HashMap<>();
throw new IllegalArgumentException("peType = " + peType + ", and related participant set does not contain this PE. Conv dir = " + getDirection(conv) + " conv.id=" + conv.getUri() + " pe.id=" +pe.getUri()); boolean rightContains = conv.getRight().contains(pe); boolean leftContains = conv.getLeft().contains(pe);
for (Entity part : direction == Direction.ANY ? conv.getParticipant() : direction == Direction.LEFT ? conv.getLeft() : conv.getRight()) Set<BioPAXElement> rightSimples = new HashSet<BioPAXElement>(); for (PhysicalEntity pe : conv.getLeft()) for (PhysicalEntity pe : conv.getRight())
&& con.getConversionDirection() != null && con.getConversionDirection() != ConversionDirectionType.REVERSIBLE) + ", but " + con.getUri() + " has conversionDirection=" + con.getConversionDirection() + " (must be REVERSIBLE or empty)"); if(validation.isFix()) { fix(step, con, null);
Set<Control> controls = nextConversion.getControlledOf(); mapDirectionToConversion(consequentCatalysis.getCatalysisDirection()); ConversionDirectionType dirB = findConsensusDirection(nextConversion.getConversionDirection(), direction2);
/** * Gets the map of stoichiometry coefficients of participants. * @param conv the conversion * @return map from physical entities to their stoichiometry */ private Map<PhysicalEntity, Stoichiometry> getStoichiometry(Conversion conv) { Map<PhysicalEntity, Stoichiometry> map = new HashMap<PhysicalEntity, Stoichiometry>(); for (Stoichiometry stoc : conv.getParticipantStoichiometry()) { map.put(stoc.getPhysicalEntity(), stoc); } return map; }
private void fix(BiochemicalPathwayStep t, Object... values) { if(values[0] instanceof Catalysis) { ((Catalysis)values[0]).setCatalysisDirection((CatalysisDirectionType) values[1]); } else if (values[0] instanceof Conversion){ ((Conversion)values[0]).setConversionDirection((ConversionDirectionType) values[1]); } }
public void check(Conversion thing, boolean fix) { //for thread safety (concurrency) we're using a new fetcher here rather than static one Fetcher fetcher = new Fetcher( SimpleEditorMap.L3, new Filter<PropertyEditor>() { //complex.component only public boolean filter(PropertyEditor editor) { return editor.getProperty().equals("component"); } }); Set<PhysicalEntity> left = new HashSet<PhysicalEntity>(getPEsRecursively(thing.getLeft(), fetcher)); //need a mutable set Set<PhysicalEntity> right = getPEsRecursively(thing.getRight(), fetcher); left.removeAll(right); int complexDiff = getComplexCount(thing.getLeft()) - getComplexCount(thing.getRight()); if( left.isEmpty() // when there are no modifications really, but different no. complexes or participants && (complexDiff != 0 || thing.getLeft().size() - thing.getRight().size() != 0 )) error(thing, "wrong.conversion.class", false, thing.getModelInterface()); }
private void fix(BiochemicalPathwayStep t, Object... values) { if(values[0] instanceof Catalysis) { ((Catalysis)values[0]).setCatalysisDirection((CatalysisDirectionType) values[1]); } else if (values[0] instanceof Conversion){ ((Conversion)values[0]).setConversionDirection((ConversionDirectionType) values[1]); } }
/** * Gets input ot output participants of the Conversion. * @param conv Conversion to get participants * @param type input or output * @return related participants */ protected Set<PhysicalEntity> getConvParticipants(Conversion conv, RelType type) { ConversionDirectionType dir = getDirection(conv); if (dir == ConversionDirectionType.REVERSIBLE) { HashSet<PhysicalEntity> set = new HashSet<PhysicalEntity>(conv.getLeft()); set.addAll(conv.getRight()); return set; } else if (dir == ConversionDirectionType.RIGHT_TO_LEFT) { return type == RelType.INPUT ? conv.getRight() : conv.getLeft(); } else return type == RelType.OUTPUT ? conv.getRight() : conv.getLeft(); }
protected ConversionDirectionType getDirection(Conversion conv) { if (conv.getConversionDirection() != null) return conv.getConversionDirection(); ConversionDirectionType catDir = findDirectionInCatalysis(conv); ConversionDirectionType patDir = findDirectionInPathways(conv); if (catDir != null && patDir != null && catDir != patDir) return ConversionDirectionType.REVERSIBLE; else if (catDir != null) return catDir; else if (patDir != null) return patDir; // No direction found! Assuming it is left-to-right. else return ConversionDirectionType.LEFT_TO_RIGHT; } }
private static void captureExtendedControls(Conversion conv, Map<Conversion, Set<EntityReference>> extendedControls, PhysicalEntity leftRoot, PhysicalEntity rightRoot) { if (leftRoot instanceof Complex || rightRoot instanceof Complex) { if (conv.getControlledOf().isEmpty()) //?? Todo check this { Set<SimplePhysicalEntity> leftSpe = new HashSet<SimplePhysicalEntity>(); getSimpleMembers(leftRoot, leftSpe); EquivalenceGrouper<SimplePhysicalEntity> leftComps = new EquivalenceGrouper<SimplePhysicalEntity>(leftSpe); Set<SimplePhysicalEntity> rightSpe = new HashSet<SimplePhysicalEntity>(); getSimpleMembers(rightRoot, rightSpe); EquivalenceGrouper rightComps = new EquivalenceGrouper<SimplePhysicalEntity>(rightSpe); leftComps.getBuckets().retainAll(rightComps.getBuckets()); for (List<SimplePhysicalEntity> bucket : leftComps.getBuckets()) { SimplePhysicalEntity pe = bucket.get(0); Set<EntityReference> erSet = extendedControls.get(conv); if (erSet == null) { erSet = new HashSet<EntityReference>(); extendedControls.put(conv, erSet); } erSet.add(pe.getEntityReference()); } } } }
/** * This method returns the PEPs that are on the correct side of the conversion * * @param direction determining the side * @param aConversion Conversion to get inputs or outputs * @return inputs or outputs */ private Set<PhysicalEntity> getOutputPEs(ConversionDirectionType direction, Conversion aConversion) { switch (direction) { case LEFT_TO_RIGHT: return aConversion.getRight(); case RIGHT_TO_LEFT: return aConversion.getLeft(); default: return mergedSet(aConversion); } }
if (conv.getConversionDirection() == null || conv.getConversionDirection().equals(ConversionDirectionType.LEFT_TO_RIGHT) || (conv.getConversionDirection().equals(ConversionDirectionType.REVERSIBLE) && useTwoGlyphsForReversibleConversion)) { createProcessAndConnections(conv, ConversionDirectionType.LEFT_TO_RIGHT); } else if (conv.getConversionDirection() != null && (conv.getConversionDirection().equals(ConversionDirectionType.RIGHT_TO_LEFT) || (conv.getConversionDirection().equals(ConversionDirectionType.REVERSIBLE)) && useTwoGlyphsForReversibleConversion)) { createProcessAndConnections(conv, ConversionDirectionType.RIGHT_TO_LEFT); } else if (conv.getConversionDirection() != null && conv.getConversionDirection().equals(ConversionDirectionType.REVERSIBLE) && !useTwoGlyphsForReversibleConversion) { createProcessAndConnections(conv, ConversionDirectionType.REVERSIBLE);