if (attribute != null) { relation.deleteAttribute(an); attribute = null;
public static String assignAverageWeight(ONDEXGraph graph, List<String> atts) { List<AttributeName> ans = new ArrayList<AttributeName>(); String name = ""; for (String a : atts) { ans.add(graph.getMetaData().getAttributeName(a)); if (!name.equals("")) { name = name + ","; } name = name + a; } AttributeName av = graph.getMetaData().getFactory().createAttributeName("COMBINED[" + name + "]", Double.class); for (ONDEXRelation r : graph.getRelations()) { Double sum = 0d; for (AttributeName an : ans) { sum = sum + getNumber(an, r); } Double average = sum / ((double) ans.size()); if (r.getAttribute(av) != null) { r.deleteAttribute(av); } r.createAttribute(av, average, false); } return "COMBINED[" + name + "]"; }
r.deleteAttribute(clustAtt); if (attribute != null && attribute.getValue().equals(clusterId)) { if (r.getAttribute(clustAtt) != null) r.deleteAttribute(clustAtt); r.createAttribute(clustAtt, clusterId, false);
public static void changeAttributeValue(ONDEXEntity e, AttributeName n, Object value) { if (e instanceof ONDEXConcept) { ONDEXConcept c = (ONDEXConcept) e; boolean doIndex = c.getAttribute(n).isDoIndex(); c.deleteAttribute(n); c.createAttribute(n, value, doIndex); } if (e instanceof ONDEXRelation) { ONDEXRelation r = (ONDEXRelation) e; boolean doIndex = r.getAttribute(n).isDoIndex(); r.deleteAttribute(n); r.createAttribute(n, value, doIndex); } else { throw new IllegalArgumentException( "This method only works with Ondex concepts and relations."); } }
/** * Copies all Attribute from old relation to new relation. * * @param oldR * old ONDEXRelation * @param newR * new ONDEXRelation */ private void copyGDS(ONDEXRelation oldR, ONDEXRelation newR) { // iterate over all old Attribute for (Attribute attribute : oldR.getAttributes()) { // clone old Attribute on new relation only if not yet exists if (newR.getAttribute(attribute.getOfType()) != null) // old Attribute gets overridden newR.deleteAttribute(attribute.getOfType()); else newR.createAttribute(attribute.getOfType(), attribute.getValue(), attribute.isDoIndex()); } } }
if (relation.deleteAttribute(an)) number++; if (relation.deleteAttribute(an)) number++;
relation.deleteAttribute(atrBitscore); // remove
public static void assignCombinedWeight(ONDEXGraph graph) { AttributeName coex = graph.getMetaData().getAttributeName("COEX_WEIGHT"); AttributeName blast = graph.getMetaData().getAttributeName("BLAST_WEIGHT"); AttributeName itwi = graph.getMetaData().getAttributeName("INTERACTION_WEIGHT"); AttributeName tm = graph.getMetaData().getAttributeName("Co-citation_weight"); AttributeName all = graph.getMetaData().getFactory().createAttributeName("COMBINED_WEIGHT", Double.class); for (ONDEXRelation r : graph.getRelations()) { Double value = ((getNumber(coex, r) + getNumber(blast, r) + getNumber(itwi, r) + getNumber(tm, r)) / 4d); if (r.getAttribute(all) != null) { r.deleteAttribute(all); } r.createAttribute(all, value, false); } }