/** * @param acTo * @param acFrom */ public void copyContext(ONDEXRelation acTo, Set<ONDEXConcept> acFrom){ for (ONDEXConcept concept : acFrom) { if (acTo.getTags().contains(concept) == false) { acTo.addTag(concept); } } }
/** * @param acTo * @param acFrom */ public void copyContext(ONDEXRelation acTo, Set<ONDEXConcept> acFrom){ Iterator<ONDEXConcept> concepts = acFrom.iterator(); while(concepts.hasNext()){ ONDEXConcept concept = concepts.next(); if ( acTo.getTags().contains(concept) == false ) acTo.addTag(concept); } }
/** * @param acTo * @param acFrom */ public void copyContext(ONDEXRelation acTo, Set<ONDEXConcept> acFrom){ Iterator<ONDEXConcept> concepts = acFrom.iterator(); while(concepts.hasNext()){ ONDEXConcept concept = concepts.next(); if ( acTo.getTags().contains(concept) == false ) acTo.addTag(concept); } }
/** * @param acTo * @param acFrom */ public void copyContext(ONDEXRelation acTo, Set<ONDEXConcept> acFrom){ for (ONDEXConcept concept : acFrom) { if (!acTo.getTags().contains(concept)) { acTo.addTag(concept); } } }
/** * Copies all context information from old relation to new relation. * * @param oldR * old ONDEXRelation * @param newR * new ONDEXRelation */ private void copyContext(ONDEXRelation oldR, ONDEXRelation newR) { // transfer context from old relation to new relation for (ONDEXConcept c : oldR.getTags()) { newR.addTag(c); } }
/** * Adds context to a relation * * @param xmlr * XMLStreamReader * @param r * ONDEXRelation to add context to * @throws XMLStreamException */ protected void parseContext(XMLStreamReader xmlr, ONDEXRelation r) throws XMLStreamException { int eventType = xmlr.getEventType(); while (xmlr.hasNext() && eventType != XMLStreamConstants.END_ELEMENT) { if (eventType == XMLStreamConstants.START_ELEMENT && xmlr.getLocalName().equals(XMLTagNames.CONTEXT)) { // example tags // <id>12</id> xmlr.nextTag(); // id int number = Integer.parseInt(xmlr.getElementText()); // add context to data repository ... r.addTag(og.getConcept(idMapping.get(number))); xmlr.nextTag(); // skip end tag } eventType = xmlr.next(); } }
@Override public void pointerToRelation(AbstractNode node) { HashSet<ONDEXRelation> relations = new HashSet<ONDEXRelation>(); Compound compound = (Compound) node; for (AbstractNode abstractNode : compound.getCofactorOf()) { // Compound (cofactor of)=> Enzyme relations.add(graph.getFactory().createRelation(abstractNode.getConcept(), compound.getConcept(), rtCofectorOf, etIMPD)); } for( ONDEXRelation relation: relations ){ for (ONDEXConcept c : node.getConcept().getTags()){ relation.addTag(c); } }/* for( AbstractNode n: compound.getCofactorOf()){ Set<ONDEXConcept> toConcepts = node.getConcept().getContext(s); while( toConcepts.hasNext() ){ ONDEXConcept toContext = toConcepts.next(); if ( !n.getConcept().getContext(s).contains(toContext) ) n.getConcept().addContext(toContext); } }*/ } }
@Override public void pointerToRelation(AbstractNode node) { HashSet<ONDEXRelation> relations = new HashSet<ONDEXRelation>(); Compound compound = (Compound) node; for (AbstractNode abstractNode : compound.getCofactorOf()) { // Compound (cofactor of)=> Enzyme relations.add(graph.getFactory().createRelation(abstractNode.getConcept(), compound.getConcept(), rtCofectorOf, etIMPD)); } for( ONDEXRelation relation: relations ){ for (ONDEXConcept c : node.getConcept().getTags()){ relation.addTag(c); } }/* for( AbstractNode n: compound.getCofactorOf()){ Set<ONDEXConcept> toConcepts = node.getConcept().getContext(s); while( toConcepts.hasNext() ){ ONDEXConcept toContext = toConcepts.next(); if ( !n.getConcept().getContext(s).contains(toContext) ) n.getConcept().addContext(toContext); } }*/ } }
@Override public void pointerToRelation(AbstractNode node) { HashSet<ONDEXRelation> relations = new HashSet<ONDEXRelation>(); Compound compound = (Compound) node; for (AbstractNode abstractNode : compound.getCofactorOf()) { // Compound (cofactor of)=> Enzyme relations.add(graph.getFactory().createRelation(abstractNode.getConcept(), compound.getConcept(), rtCofectorOf, etIMPD)); } for( ONDEXRelation relation: relations ){ for (ONDEXConcept c : node.getConcept().getTags()){ relation.addTag(c); } }/* for( AbstractNode n: compound.getCofactorOf()){ Set<ONDEXConcept> toConcepts = node.getConcept().getContext(s); while( toConcepts.hasNext() ){ ONDEXConcept toContext = toConcepts.next(); if ( !n.getConcept().getContext(s).contains(toContext) ) n.getConcept().addContext(toContext); } }*/ } }
@Override public void pointerToRelation(AbstractNode node) { HashSet<ONDEXRelation> relations = new HashSet<ONDEXRelation>(); Compound compound = (Compound) node; for (AbstractNode abstractNode : compound.getCofactorOf()) { // Compound (cofactor of)=> Enzyme relations.add(graph.getFactory().createRelation(abstractNode.getConcept(), compound.getConcept(), rtCofectorOf, etIMPD)); } for( ONDEXRelation relation: relations ){ for(ONDEXConcept c : node.getConcept().getTags()){ relation.addTag(c); } }/* for( AbstractNode n: compound.getCofactorOf()){ Set<ONDEXConcept> toConcepts = node.getConcept().getContext(s); while( toConcepts.hasNext() ){ ONDEXConcept toContext = toConcepts.next(); if ( !n.getConcept().getContext(s).contains(toContext) ) n.getConcept().addContext(toContext); } }*/ } }
/** * Copies all context information from old concept to new concept and * updates context references on other entities. * * @param oldC * old ONDEXConcept * @param newC * new ONDEXConcept */ private void copyContext(ONDEXConcept oldC, ONDEXConcept newC) { // add new concept to same references as old concept for (ONDEXConcept c : graph.getConceptsOfTag(oldC)) { c.addTag(newC); } for (ONDEXRelation r : graph.getRelationsOfTag(oldC)) { r.addTag(newC); } // transfer context from old concept to new concept for (ONDEXConcept c : oldC.getTags()) { newC.addTag(c); } }
public void parseLine(String[] data) throws FileNotFoundException, IOException { ONDEXConcept prot = lookup.lookupProtein(data[1], data[2]); ONDEXConcept h = lookup.lookupHormone(data[3]); ONDEXRelation rel = createRealtion(prot, h, r); ONDEXConcept anno = graph.getFactory().createConcept(data[4], ahd, annotation, evidence); if (!data[4].equals("-")) { anno.createConceptName(data[4], true); } if (data[5].length() != 0) { anno.createAttribute(description, data[5], false); } anno.createAttribute(micro, data[7], false); String z = "Mutant"; if (data.length == 9) { z = data[8]; } anno.createAttribute(annoSource, z, false); rel.addTag(anno); String[] ids = data[6].split(";"); for (String id1 : ids) { id1 = id1.trim(); if (id1 == null || id1.length() == 0) continue; ONDEXConcept pub = lookup.lookupPublication(id1); graph.getFactory().createRelation(anno, pub, pub_in, evidence); createHormoneContext(data[3], pub); } createHormoneContext(data[3], prot, rel, anno); } });
/** * This method will create a copy of the original relation between the * concepts specified. * * @param graph * - graph where this things live * @param from * - source concept of the copied relation * @param to * - target concept of the copied relation * @param r * - relation that will be copied */ public static void copyRelation(ONDEXGraph graph, ONDEXConcept from, ONDEXConcept to, ONDEXRelation r) { ONDEXRelation nr = null; Collection<EvidenceType> evidence = r.getEvidence(); Collection<ONDEXConcept> tags = new HashSet<ONDEXConcept>(r.getTags()); Collection<Attribute> rgdss = r.getAttributes(); nr = graph.createRelation(from, to, r.getOfType(), evidence); for (ONDEXConcept tag : tags) nr.addTag(tag); for (Attribute rattribute : rgdss) { cloneAttributeWithAttName(graph, r, nr, rattribute.getOfType()); } }
/** * Will add a specified tag concept to all members of this subgraph * * @param tag - a tag concept */ public void addTag(ONDEXConcept tag) { int conceptCounter = 0; for(ONDEXConcept c : concepts) { if (graph.getConcept(c.getId()) != null) { graph.getConcept(c.getId()).addTag(tag); conceptCounter++; } } int relationCounter = 0; for(ONDEXRelation r : relations) { if (graph.getRelation(r.getId()) != null) { graph.getRelation(r.getId()).addTag(tag); relationCounter++; } } System.err.println("Assigned tag to " + conceptCounter + " concepts and " + relationCounter + " relations."); }
pathwayNode.setBelongsToSuperPathway(true); graph.getFactory().createRelation(pathway.getConcept(),pathwayNode.getConcept(), rtPrecededBy, etIMPD).addTag(node.getConcept()); if ( !pathwayNode.getConcept().getTags().contains(node.getConcept())) pathwayNode.getConcept().addTag(node.getConcept()); graph.getFactory().createRelation(pathwayNode.getConcept(),pathway.getConcept(), rtMemberIsPart, etIMPD).addTag(node.getConcept());
/** * Transfers all relations that the old concept takes part into to the new * concept. * * @param oldC * old ONDEXConcept * @param newC * new ONDEXConcept */ private void transferRelations(ONDEXConcept oldC, ONDEXConcept newC) { // iterate over all relations of old concept for (ONDEXRelation oldR : graph.getRelationsOfConcept(oldC)) { ONDEXRelation newR = null; if (oldR.getFromConcept().equals(oldC)) { // old concept is from concept newR = graph.createRelation(newC, oldR.getToConcept(), oldR.getOfType(), oldR.getEvidence()); } else if (oldR.getToConcept().equals(oldC)) { // old concept is to concept newR = graph.createRelation(oldR.getFromConcept(), newC, oldR.getOfType(), oldR.getEvidence()); } // transfer context old to new for (ONDEXConcept c : oldR.getTags()) { newR.addTag(c); } } }
pathwayNode.setBelongsToSuperPathway(true); pathwayNode.getConcept().addTag(node.getConcept()); graph.getFactory().createRelation(pathway.getConcept(),pathwayNode.getConcept(), rtPrecededBy, etIMPD).addTag(node.getConcept()); if ( !pathwayNode.getConcept().getTags().contains(node.getConcept())) pathwayNode.getConcept().addTag(node.getConcept()); graph.getFactory().createRelation(pathwayNode.getConcept(),pathway.getConcept(), rtMemberIsPart, etIMPD).addTag(node.getConcept());
pathwayNode.setBelongsToSuperPathway(true); pathwayNode.getConcept().addTag(node.getConcept()); graph.getFactory().createRelation(pathway.getConcept(),pathwayNode.getConcept(), rtPrecededBy, etIMPD).addTag(node.getConcept()); if ( !pathwayNode.getConcept().getTags().contains(node.getConcept())) pathwayNode.getConcept().addTag(node.getConcept()); graph.getFactory().createRelation(pathwayNode.getConcept(),pathway.getConcept(), rtMemberIsPart, etIMPD).addTag(node.getConcept());
@Override public void start() throws Exception { String conceptClass = (String) args.getUniqueValue(CC); String name = (String) args.getUniqueValue(NAME); Set<ONDEXConcept> cs = graph.getConcepts(); Set<ONDEXRelation> rs = graph.getRelations(); ONDEXConcept c = graph.getFactory().createConcept(name, createDataSource(graph, "UC"), createCC(graph, conceptClass), createEvidence(graph, "M")); c.createConceptName(name, true); for (ONDEXConcept co : cs) { co.addTag(c); } for (ONDEXRelation re : rs) { re.addTag(c); } }
/** * This function will create a context from a set of concepts and relations * currently selected in the graph * * @param viewer * - viewer * @param name * - name that the new context will have */ public static void createContextFromSelection(OVTK2PropertiesAggregator viewer, String name) { ONDEXGraph graph = viewer.getONDEXJUNGGraph(); ONDEXConcept context = graph.getFactory().createConcept(name, createDataSource(graph, "unknown"), createCC(graph, "Thing"), createEvidence(graph, "manual")); context.createConceptName(name, true); PickedState<ONDEXRelation> stateE = viewer.getVisualizationViewer().getPickedEdgeState(); Set<ONDEXRelation> setE = stateE.getPicked(); for (ONDEXRelation e : setE) { graph.getRelation(e.getId()).addTag(context); } PickedState<ONDEXConcept> stateN = viewer.getVisualizationViewer().getPickedVertexState(); Set<ONDEXConcept> setN = stateN.getPicked(); for (ONDEXConcept n : setN) { graph.getConcept(n.getId()).addTag(context); } } }