/** * 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; }
@Override public boolean satisfies(Match match, int... ind) { Conversion cnv = (Conversion) match.get(ind[0]); Set<PhysicalEntity> left = cnv.getLeft(); if (left.size() > 1) return false; if (left.isEmpty()) return true; PhysicalEntity pe = left.iterator().next(); if (pe instanceof NucleicAcid) { PhysicalEntity rPE = cnv.getRight().iterator().next(); return rPE instanceof Protein; } return false; } }, 0)), "Conversion");
/** * 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(); }
/** * Checks if the common substrate is an input to one and output of the other. * @param pe common substrate * @param nextConversion second conversion * @param dirB direction for the second conversion * @return true if the flow matches */ private boolean commonSubstrateFollowsFlow(PhysicalEntity pe, Conversion nextConversion, ConversionDirectionType dirB) { if (dirB == null) return true; //Assume reversible switch (dirB) { case REVERSIBLE: return true; case LEFT_TO_RIGHT: return nextConversion.getLeft().contains(pe); case RIGHT_TO_LEFT: return nextConversion.getRight().contains(pe); default: throw new IllegalBioPAXArgumentException(); // Should never hit here } }
/** * 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); } }
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()); }
else if (conv.getRight().contains(pe)) parts = conv.getRight(); else throw new IllegalArgumentException("The PhysicalEntity has to be at least one " + "side of the Conversion"); context == RelType.INPUT ? conv.getLeft() : conv.getRight() : context == RelType.OUTPUT ? conv.getLeft() : conv.getRight();
parts = sideType == Type.OTHER_SIDE ? conv.getRight() : conv.getLeft(); else if (conv.getRight().contains(pe1)) parts = sideType == Type.SAME_SIDE ? conv.getRight() : conv.getLeft(); if ((dir == ConversionDirectionType.LEFT_TO_RIGHT && ((relType == RelType.INPUT && parts != conv.getLeft()) || (relType == RelType.OUTPUT && parts != conv.getRight()))) || (dir == ConversionDirectionType.RIGHT_TO_LEFT && ((relType == RelType.INPUT && parts != conv.getRight()) || (relType == RelType.OUTPUT && parts != conv.getLeft())))) return Collections.emptySet();
@Override public boolean satisfies(Match match, int... ind) { Conversion cnv1 = (Conversion) match.get(ind[0]); Conversion cnv2 = (Conversion) match.get(ind[1]); SmallMolecule linker = (SmallMolecule) match.get(ind[2]); Set<PhysicalEntity> input1 = cnv1.getLeft().contains(linker) ? cnv1.getRight() : cnv1.getLeft(); Set<PhysicalEntity> input2 = cnv2.getLeft().contains(linker) ? cnv2.getLeft() : cnv2.getRight(); Set<PhysicalEntity> output1 = cnv1.getLeft().contains(linker) ? cnv1.getLeft() : cnv1.getRight(); Set<PhysicalEntity> output2 = cnv2.getLeft().contains(linker) ? cnv2.getRight() : cnv2.getLeft(); if (input1.equals(input2) && output1.equals(output2)) return false; if (input1.equals(output2) && output1.equals(input2)) return false; if (blacklist != null) { Set<PhysicalEntity> set = new HashSet<PhysicalEntity>(input1); set = blacklist.getNonUbiques(set, RelType.INPUT); set.removeAll(output2); if (set.isEmpty()) { set.addAll(output2); set = blacklist.getNonUbiques(set, RelType.OUTPUT); set.removeAll(input1); if (set.isEmpty()) return false; } } return true; } }, "first Conversion", "second Conversion", "linker PE");
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()); }
/** * Continue inference with the Control and the Conversion. * @param is3 mined interactions * @param source source of interaction * @param cont the control that source is controller * @param conv the conversion that control is controlling */ private void processConversion(InteractionSetL3 is3, BioPAXElement source, Control cont, Conversion conv) { // Collect left and right simple physical entities of conversion in lists Set<BioPAXElement> left = collectEntities(conv.getLeft(), is3); Set<BioPAXElement> right = collectEntities(conv.getRight(), is3); // Detect physical entities which appear on both sides. Set<BioPAXElement> intersection = new HashSet<BioPAXElement>(left); intersection.retainAll(right); Set<BioPAXElement> union = new HashSet<BioPAXElement>(left); union.addAll(right); // Create simple interactions // Try creating a rule for each physical entity in presence list. for (BioPAXElement target : union) { if (source != target) { if (!(target instanceof Group) || !((Group) target).isComplex()) { mineTarget(source, target, is3, cont, conv, intersection); } } } }
/** * Adds a Conversion Interaction. */ private void addConversionInteraction(CyNetwork network, Conversion interactionElement) { // Add Left Side of Reaction Collection<PhysicalEntity> leftSideElements = interactionElement.getLeft(); for (PhysicalEntity leftElement: leftSideElements) { linkNodes(network, interactionElement, leftElement, "left"); } // Add Right Side of Reaction Collection<PhysicalEntity> rightSideElements = interactionElement.getRight(); for (PhysicalEntity rightElement : rightSideElements) { linkNodes(network, interactionElement, rightElement, "right"); } }
public void check(SimplePhysicalEntity spe, boolean fix) { Set<Conversion> conversions = new HashSet<Conversion>( new ClassFilterSet<Interaction,Conversion>( spe.getParticipantOf(), Conversion.class)); for(Conversion conversion : conversions) { if(conversion instanceof ComplexAssembly || conversion instanceof Degradation) { continue; //ignore these conversion types } Set<PhysicalEntity> side = conversion.getLeft(); if(side.contains(spe)) side = conversion.getRight(); if(!sameKindEntityExists(spe, side)) error(spe, "illegal.conversion", false, conversion); } }
for (PhysicalEntity pe : conv.getRight())
@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); }
getDirection(conv) + " conv.id=" + conv.getUri() + " pe.id=" +pe.getUri()); boolean rightContains = conv.getRight().contains(pe); boolean leftContains = conv.getLeft().contains(pe);
public void check(final Validation validation, SimplePhysicalEntity spe) { Set<Conversion> conversions = new HashSet<Conversion>( new ClassFilterSet<Interaction,Conversion>( spe.getParticipantOf(), Conversion.class)); for(Conversion conversion : conversions) { if(conversion instanceof ComplexAssembly || conversion instanceof Degradation) { continue; //ignore these conversion types } Set<SimplePhysicalEntity> side = new ClassFilterSet<PhysicalEntity,SimplePhysicalEntity>( conversion.getLeft(), SimplePhysicalEntity.class); if(side.contains(spe)) //then compare with the other side side = new ClassFilterSet<PhysicalEntity,SimplePhysicalEntity>( conversion.getRight(), SimplePhysicalEntity.class); if(!sameKindEntityExists(spe, side)) error(validation, spe, "illegal.conversion", false, conversion); } }
public void check(final Validation validation, Conversion conversion) { Set<PhysicalEntity> left = conversion.getLeft(); Set<PhysicalEntity> right = conversion.getRight(); for (PhysicalEntity lefty : left) { for (PhysicalEntity righty : right) { boolean isSame = false; isSame = righty.isEquivalent(lefty) && lefty.isEquivalent(righty); if(isSame) { // TODO what if both actually have no xrefs, features, i.e., none of "distinguishing" properties? - // a fix/hack - to consider ER's different for this rule purpose only if(lefty instanceof SimplePhysicalEntity) { // SimplePhysicalEntity can have an entity reference assert righty instanceof SimplePhysicalEntity; // - righty will be too EntityReference ler = ((SimplePhysicalEntity) lefty).getEntityReference(); EntityReference rer = ((SimplePhysicalEntity) righty).getEntityReference(); // put this: two PEs having ERs with different RDFID will be considered not equivalent if(ler != null && rer != null && !ler.getUri().equalsIgnoreCase(rer.getUri())) { isSame = false; } } if(isSame) error(validation, conversion, "same.state.participant", false, lefty, righty); } } } }
public void check(Conversion conversion, boolean fix) { Set<PhysicalEntity> left = conversion.getLeft(); Set<PhysicalEntity> right = conversion.getRight(); for (PhysicalEntity lefty : left) { for (PhysicalEntity righty : right) { boolean isSame = false; isSame = righty.isEquivalent(lefty) && lefty.isEquivalent(righty); if(isSame) { // TODO what if both actually have no xrefs, features, i.e., none of "distinguishing" properties? - // a fix/hack - to consider ER's different for this rule purpose only if(lefty instanceof SimplePhysicalEntity) { // SimplePhysicalEntity can have an entity reference assert righty instanceof SimplePhysicalEntity; // - righty will be too EntityReference ler = ((SimplePhysicalEntity) lefty).getEntityReference(); EntityReference rer = ((SimplePhysicalEntity) righty).getEntityReference(); // put this: two PEs having ERs with different RDFID will be considered not equivalent if(ler != null && rer != null && !ler.getRDFId().equalsIgnoreCase(rer.getRDFId())) { isSame = false; } } if(isSame) error(conversion, "same.state.participant", false, lefty, righty); } } } }