public void check(Complex thing, boolean fix) { Set<PhysicalEntity> ents = thing.getComponent(); if (ents != null) { Collection<String> diffLocs = new HashSet<String>(); PhysicalEntity ref = thing; for (PhysicalEntity e : ents) { if(ref.getCellularLocation()==null && e.getCellularLocation() != null) { ref = e; continue; } if (e.getCellularLocation() != null && !ref.getCellularLocation().isEquivalent(e.getCellularLocation())) { diffLocs.add(e + " " + e.getCellularLocation()); } } if(!diffLocs.isEmpty()) { error(thing, "component.different.location", false, thing.getCellularLocation() + "", diffLocs); } } }
public void check(final Validation validation, PhysicalEntity thing) { // Capture PEs that is both a participant of a conversion and a component of a complex if(!thing.getParticipantOf().isEmpty() && !thing.getComponentOf().isEmpty()) { HashSet<EntityFeature> efs = new HashSet<EntityFeature>(); efs.addAll(thing.getFeature()); efs.addAll(thing.getNotFeature()); // Do we have any information about the binding properties? If so, it's OK. for(EntityFeature ef: efs) { if(ef instanceof BindingFeature) { return; } } // TODO: Call Emek's feature resolver function explicitly if the PE is to be fixed error(validation, thing, "ambiguous.feature", false, thing.getName()); } }
public static void getSimpleMembers(PhysicalEntity root, Set<SimplePhysicalEntity> value) { if (root != null) { if (root instanceof Complex) { Complex complex = (Complex) root; for (PhysicalEntity component : complex.getComponent()) { getSimpleMembers(component, value); } } if (root.getMemberPhysicalEntity().isEmpty()) { if (root instanceof SimplePhysicalEntity) value.add((SimplePhysicalEntity) root); } else { for (PhysicalEntity generic : root.getMemberPhysicalEntity()) { getSimpleMembers(generic, value); } } } }
private void scanInteractions(GroupMap groupMap, Set<PEStateChange> stateChanges, EntityReference pr, PhysicalEntity spe) { for (Interaction interaction : spe.getParticipantOf()) { if (interaction instanceof Conversion) { Simplify.entityHasAChange(pr, (Conversion) interaction, groupMap, stateChanges, extendedControls); } } for (PhysicalEntity generic : spe.getMemberPhysicalEntityOf()) { scanInteractions(groupMap, stateChanges, pr, generic); } for (Complex complex : spe.getComponentOf()) { scanInteractions(groupMap, stateChanges, pr, complex); } }
for (EntityFeature entityFeature : right.getFeature()) { result.put(entityFeature, NOT_EXIST_TO_EXIST); for (EntityFeature entityFeature : left.getFeature()) { result.put(entityFeature, EXIST_TO_NOT_EXIST); for (EntityFeature lFeat : left.getFeature()) { if (right.getFeature().contains(lFeat)) else if (right.getNotFeature().contains(lFeat)) { result.put(lFeat, EXIST_TO_NOT_EXIST); } else { for (EntityFeature lFeat : left.getNotFeature()) { if (right.getFeature().contains(lFeat)) { result.put(lFeat, NOT_EXIST_TO_EXIST); (right.getNotFeature().contains(lFeat)) { result.put(lFeat, UNCHANGED); } else { for (EntityFeature rFeat : right.getFeature()) { if (!result.containsKey(rFeat)) { result.put(rFeat, UNKNOWN_TO_EXIST); for (EntityFeature rFeat : right.getNotFeature()) { if (!result.containsKey(rFeat)) { result.put(rFeat, UNKNOWN_TO_NOT_EXIST);
physicalEntity.setId(physicalEntityBP.getRDFId().split("#")[1]); if (physicalEntityBP.getDisplayName() != null) { physicalEntity.setName(physicalEntityBP.getDisplayName()); physicalEntity.setXref(new org.opencb.bionetdb.core.models.Xref(REACTOME_FEAT + "biopax", "", physicalEntityBP.getDisplayName(), "")); for (String name : physicalEntityBP.getName()) { physicalEntity.setXref(new org.opencb.bionetdb.core.models.Xref(REACTOME_FEAT + "biopax", "", name, "")); for (String name : physicalEntityBP.getCellularLocation().getTerm()) { cellularLocation.setName(name); for (Xref cellLocXref : physicalEntityBP.getCellularLocation().getXref()) { Ontology ontology= new Ontology(); if (cellLocXref.getDb().toLowerCase().equals("gene ontology")) { for (Provenance provenance : physicalEntityBP.getDataSource()) { sources.addAll(provenance.getName()); for (PhysicalEntity pe : physicalEntityBP.getMemberPhysicalEntity()) { physicalEntity.getMembers().add(pe.getRDFId().split("#")[1]); for (PhysicalEntity peOf : physicalEntityBP.getMemberPhysicalEntityOf()) { physicalEntity.getMemberOfSet().add(peOf.getRDFId().split("#")[1]); for (Complex complex : physicalEntityBP.getComponentOf()) { physicalEntity.getComponentOfComplex().add(complex.getRDFId().split("#")[1]);
/** * Infers interactions starting from the given PhysicalEntity. * @param interactionSet to be populated * @param pe PhysicalEntity that will be the seed of the inference * @param model BioPAX model */ public void inferInteractionsFromPE(InteractionSetL3 interactionSet, PhysicalEntity pe, Model model) { for (Interaction interaction : pe.getParticipantOf()) { BinaryInteractionType type = getType(interaction); for (Entity participant : interaction.getParticipant()) { processParticipant(interactionSet, participant, type, interaction); } } }
private void buildGeneric(PhysicalEntity generic, Glyph or, Glyph container) { assert "or".equalsIgnoreCase(or.getClazz()) : "must be 'or' glyph class"; for (PhysicalEntity m : generic.getMemberPhysicalEntity()) { Glyph g = createGlyphBasics(m,false); if(container!=null) container.getGlyph().add(g); String gid = g.getId() + "_" + ModelUtils.md5hex("memberof_" + or.getId()); g.setId(gid); glyphMap.put(gid, g); Set<String> uris = new HashSet<String>(); uris.add(m.getUri()); sbgn2BPMap.put(gid, uris); assignLocation(m, g); createArc(g, or, LOGIC_ARC.getClazz(), null); if(m instanceof Complex) createComplexContent((Complex) m, g); } }
for (PhysicalEntity mem : parent.getMemberPhysicalEntity()) for (PhysicalEntity grand : parent.getMemberPhysicalEntityOf())
private boolean isBound(Set<PhysicalEntity> participants) { for(PhysicalEntity pe : participants) { //if(pe instanceof Complex) continue; // it's impossible as far isBound called from where it is called if(pe.getFeature() != null && pe.getFeature() instanceof BindingFeature) { BindingFeature bf1 = (BindingFeature) pe.getFeature(); BindingFeature bf2 = bf1.getBindsTo(); if(bf2 != null) { Set<PhysicalEntity> bf2Of = bf2.getFeatureOf(); //if these phys. entities are (same side) participants as well if(!Collections.disjoint(participants, bf2Of)) return true; } } } return false; }
if(!lefty.getModelInterface().equals(righty.getModelInterface())) { continue; && CollectionUtils.containsAny(lefty.getName(), righty.getName()); boolean sameLoc = lefty.hasEquivalentCellularLocation(righty); if(!sameLoc && !(react instanceof Transport)) { error(validation, react, "participant.location.changed", false, lefty, righty);
/** * Constructor with endpoints. The end points are differentiated with the terms small and big. * This refers to a hierarchy in the relation. Small means you will get to this end while going * towards MEMBER direction, and big means this end is at the COMPLEX direction. To understand * this please see the directions in LinkedPE. * @param small member end of the chain * @param big complex end of the chain * @see org.biopax.paxtools.pattern.constraint.LinkedPE */ public PhysicalEntityChain(PhysicalEntity small, PhysicalEntity big) { pes = fillArray(big, small, 1, 0); if (pes == null) { throw new IllegalArgumentException("No link found between small PE = " + small.getUri() + " and big PE = " + big.getUri()); } assert !containsNull(pes); }
private org.opencb.bionetdb.core.models.Complex createComplex(BioPAXElement bioPAXElement) { org.opencb.bionetdb.core.models.Complex complex = new org.opencb.bionetdb.core.models.Complex(); Complex complexBP = (Complex) bioPAXElement; // Common properties setPhysicalEntityCommonProperties(complexBP, complex); // Complex properties // Components Set<PhysicalEntity> components = complexBP.getComponent(); for (PhysicalEntity component : components) { complex.getComponents().add(component.getRDFId().split("#")[1]); } // Stoichiometry List<Map<String, Object>> stoichiometry = new ArrayList<>(); Set<Stoichiometry> stoichiometryItems = complexBP.getComponentStoichiometry(); for (Stoichiometry stoichiometryItem : stoichiometryItems) { Map<String, Object> stchmtr = new HashMap<>(); stchmtr.put("component", stoichiometryItem.getPhysicalEntity().toString().split("#")[1]); stchmtr.put("coefficient", stoichiometryItem.getStoichiometricCoefficient()); stoichiometry.add(stchmtr); } complex.setStoichiometry(stoichiometry); return complex; }
/** * Checks if the chain has a member with an activity label. * @return the activity status found */ public Activity checkActivityLabel() { boolean active = false; boolean inactive = false; for (PhysicalEntity pe : pes) { for (Object o : PE2TERM.getValueFromBean(pe)) { String s = (String) o; if (s.contains("inactiv")) inactive = true; else if (s.contains("activ")) active = true; } for (String s : pe.getName()) { if (s.contains("inactiv")) inactive = true; else if (s.contains("activ")) active = true; } } if (active) if (inactive) return Activity.BOTH; else return Activity.ACTIVE; else if (inactive) return Activity.INACTIVE; else return Activity.NONE; }
extractFeatures(pe.getFeature(), true, list); extractFeatures(pe.getNotFeature(), false, list);
/** * Infers interactions using the given PhysicalEntity as seed. * @param interactionSet to be populated * @param pe PhysicalEntity that will be the seed of the inference * @param model BioPAX model */ public void inferInteractionsFromPE(InteractionSetL3 interactionSet, PhysicalEntity pe, Model model) { for (Interaction inter : pe.getParticipantOf()) { if (inter instanceof Catalysis) { BioPAXElement bpe = interactionSet.getGroupMap().getEntityReferenceOrGroup(pe); processCatalysis(interactionSet, (Catalysis) inter, bpe); } } }
private static Set<Modification> collectFeatures(PhysicalEntity pe) { Set<Modification> set = new HashSet<Modification>(); for (EntityFeature f : pe.getFeature()) { if (f instanceof ModificationFeature) set.add(new Modification((ModificationFeature) f)); } return set; }
/** * Gets the glyphs of the given set of PhysicalEntity objects. Does not create anything. * * @param pes entities to get their glyphs * @return glyphs of entities */ private List<Glyph> getGlyphsOfPEs(Set<PhysicalEntity> pes, String context) { List<Glyph> gs = new ArrayList<Glyph>(); for (PhysicalEntity pe : pes) { if (glyphMap.containsKey(convertID(pe.getUri()))) { gs.add(getGlyphToLink(pe, context)); } } return gs; }
private org.opencb.bionetdb.core.models.Catalysis createCatalysis(BioPAXElement bioPAXElement) { org.opencb.bionetdb.core.models.Catalysis catalysis = new org.opencb.bionetdb.core.models.Catalysis(); Catalysis catalysisBP = (Catalysis) bioPAXElement; // Common Interaction properties setInteractionCommonProperties(catalysisBP, catalysis); // Catalysis properties // controllers Set<Controller> controllers = catalysisBP.getController(); for (Controller controller: controllers) { catalysis.getControllers().add(controller.getRDFId().split("#")[1]); } // controlled Set<Process> controlledProcesses = catalysisBP.getControlled(); for (Process controlledProcess: controlledProcesses) { catalysis.getControlledProcesses().add(controlledProcess.getRDFId().split("#")[1]); } // controlType catalysis.setControlType(catalysisBP.getControlType().toString()); // cofactor Set<PhysicalEntity> cofactors = catalysisBP.getCofactor(); for (PhysicalEntity cofactor: cofactors) { catalysis.getCofactors().add(cofactor.getRDFId().split("#")[1]); } return catalysis; }
@Override public void check(PhysicalEntity thing, boolean fix) { // Capture PEs that is both a participant of a conversion and a component of a complex if(!thing.getParticipantOf().isEmpty() && !thing.getComponentOf().isEmpty()) { HashSet<EntityFeature> efs = new HashSet<EntityFeature>(); efs.addAll(thing.getFeature()); efs.addAll(thing.getNotFeature()); // Do we have any information about the binding properties? If so, it's OK. for(EntityFeature ef: efs) { if(ef instanceof BindingFeature) { return; } } // TODO: Call Emek's feature resolver function explicitly if the PE is to be fixed error(thing, "ambiguous.feature", false, thing.getName()); } }