/** * Checks if a Complex contains any PhysicalEntity member which is not a Complex. * @param cx to check * @return true if there is a non-complex member */ private boolean hasNonComplexMember(Complex cx) { for (PhysicalEntity mem : cx.getComponent()) { if (! (mem instanceof Complex)) return true; else { if (hasNonComplexMember((Complex) mem)) return true; } } return false; }
private int getStoichiometry(Set<Stoichiometry> stois, Set<PhysicalEntity> pes) { int total = 0; Map<PhysicalEntity, Float> stoiMap = new HashMap<PhysicalEntity, Float>(); for(Stoichiometry s: stois) stoiMap.put(s.getPhysicalEntity(), s.getStoichiometricCoefficient()); for(PhysicalEntity pe: pes) { if(pe instanceof Complex) { Complex c = (Complex) pe; total += getStoichiometry(c.getComponentStoichiometry(), c.getComponent()); } else { Float k = stoiMap.get(pe); if( k == null ) k = 1.0f; total += k; } } return total; }
public void check(Complex thing, boolean fix) { if(thing.getCellularLocation() != null) { Set<PhysicalEntity> ents = thing.getComponent(); if (ents != null) { Collection<String> comps = new HashSet<String>(); for (PhysicalEntity e : ents) { if (e.getCellularLocation() == null) { comps.add(e + " " + e.getCellularLocation()); } } if(!comps.isEmpty()) { error(thing, "component.no.location", false, thing.getCellularLocation().toString(), comps); } } } }
private Group inferGroupFromComplex(Complex complex, Model model) Set<PhysicalEntity> PElvlMembers = complex.getMemberPhysicalEntity(); if (PElvlMembers.isEmpty()) for (PhysicalEntity component : complex.getComponent()) if (!complex.getComponent().isEmpty()) log.debug("Generic complex with both membership types (" + complex.getRDFId() + "). Skipping."); } else .getRDFId() + "). Skipping");
e instanceof Complex && !((Complex)e).getMemberPhysicalEntity().isEmpty() && ((Complex) e).getComponent().isEmpty()) || (e instanceof SimplePhysicalEntity && ((SimplePhysicalEntity) e).getEntityReference()==null
physicalEntity.getComponentOfComplex().add(complex.getRDFId().split("#")[1]);
/** * Gets the members of the Complex that needs to be displayed in a flattened view. * @param cx to get members * @return members to display */ private Set<PhysicalEntity> getFlattenedMembers(Complex cx) { Set<PhysicalEntity> set = new HashSet<PhysicalEntity>(); for (PhysicalEntity mem : cx.getComponent()) { if (mem instanceof Complex) { if (!hasNonComplexMember((Complex) mem)) { set.add(mem); } else { set.addAll(getFlattenedMembers((Complex) mem)); } } else set.add(mem); } return set; }
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; }
public void check(final Validation validation, Complex thing) { if(thing.getCellularLocation() != null) { Set<PhysicalEntity> ents = thing.getComponent(); if (ents != null) { Collection<String> comps = new HashSet<String>(); for (PhysicalEntity e : ents) { if (e.getCellularLocation() == null) { comps.add(e + " " + e.getCellularLocation()); } } if(!comps.isEmpty()) { error(validation, thing, "component.no.location", false, thing.getCellularLocation().toString(), comps); } } } }
private void createComplexEdges(CyNetwork network) { // iterate through all pe's for (Complex complexElement : model.getObjects(Complex.class)) { Set<PhysicalEntity> members = complexElement.getComponent(); if(members.isEmpty()) continue; // get node CyNode complexCyNode = bpeToCyNodeMap.get(complexElement); // get all components. There can be 0 or more for (PhysicalEntity member : members) { CyNode complexMemberCyNode = bpeToCyNodeMap.get(member); // create edge, set attributes CyEdge edge = network.addEdge(complexCyNode, complexMemberCyNode, true); AttributeUtil.set(network, edge, "interaction", "contains", String.class); } } }
public void check(Complex thing, boolean fix) Set<PhysicalEntity> components = thing.getComponent(); Set<Stoichiometry> stoi = thing.getComponentStoichiometry(); String msg = "has one component"; if(stoi.isEmpty()) {
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 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); } } } }
public void check(final Validation validation, Complex thing) Set<PhysicalEntity> components = thing.getComponent(); Set<Stoichiometry> stoi = thing.getComponentStoichiometry(); String msg = "has one component"; if(stoi.isEmpty()) {
public void check(final Validation validation, Complex thing) { 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(validation, thing, "component.different.location", false, thing.getCellularLocation() + "", diffLocs); } } }
if (!rightInComplex || ((Complex) leftRoot).getComponent().contains(rightRoot)) { bindingDirection = EXIST_TO_NOT_EXIST; } else if (((Complex) rightRoot).getComponent().contains(leftRoot)) { bindingDirection = NOT_EXIST_TO_EXIST;
/** * Recursive method for creating the content of a complex. A complex may contain other complexes * (bad practice), but SBGN needs them flattened. If an inner complex is empty, then we * represent it using a glyph. Otherwise we represent only the members of this inner complex, * merging them with the most outer complex. * * @param cx inner complex to add as member * @param container glyph for most outer complex */ private void addComplexAsMember(Complex cx, Glyph container) { // Create a glyph for the inner complex Glyph inner = createComplexMember(cx, container); for (PhysicalEntity mem : cx.getComponent()) { if (mem instanceof Complex) { // Recursive call for inner complexes addComplexAsMember((Complex) mem, inner); } else { createComplexMember(mem, inner); } } }
private static SimplePhysicalEntity getAssociatedState(BioPAXElement element, PhysicalEntity pe, GroupMap map) { if (pe instanceof Complex) { for (PhysicalEntity component : ((Complex) pe).getComponent()) { SimplePhysicalEntity viaComplex = getAssociatedState(element, component, map); if (viaComplex != null) { return viaComplex; } } } else if (checkEntity(map, pe, element)) return (SimplePhysicalEntity) pe; for (PhysicalEntity member : pe.getMemberPhysicalEntity()) { SimplePhysicalEntity viaGeneric = getAssociatedState(element, member, map); if (viaGeneric != null) return viaGeneric; } return null; }
/** * Fills in the content of a complex. * * @param cx Complex to be filled * @param cg its glyph */ private void createComplexContent(Complex cx, Glyph cg) { if (flattenComplexContent) { for (PhysicalEntity mem : getFlattenedMembers(cx)) { createComplexMember(mem, cg); } } else { for (PhysicalEntity mem : cx.getComponent()) { if (mem instanceof Complex) { addComplexAsMember((Complex) mem, cg); } else { createComplexMember(mem, cg); } } } }
for (PhysicalEntity mem : ((Complex) parent).getComponent())