/** * Tries to get the most worthwhile identifier for the concept * * @param c * - concept * @return - some id (in order of decreasing preference: name, pid, * description, concepts class+is) */ private static String getSomething(ONDEXConcept c) { if (c.getConceptName() != null) { return c.getConceptName().getName(); } if (c.getPID() != null && c.getPID().equals("")) { return c.getPID(); } if (c.getDescription() != null && c.getDescription().equals("")) { return c.getDescription(); } return "[" + c.getOfType().getId() + " " + c.getId() + "]"; }
for (EvidenceType et : copySourceConcept.getEvidence()) { copyTargetConcept.addEvidenceType(et); for (ConceptAccession acc : copySourceConcept.getConceptAccessions()) { copyTargetConcept.createConceptAccession(acc.getAccession(), acc.getElementOf(), true); for (ConceptName name : copySourceConcept.getConceptNames()) { copyTargetConcept.createConceptName(name.getName(), name.isPreferred()); for (Attribute attribute : copySourceConcept.getAttributes()) { copyTargetConcept.createAttribute(attribute.getOfType(), attribute.getValue(), attribute.isDoIndex()); if (copySourceConcept.getAnnotation() != null) copyTargetConcept.setAnnotation(copySourceConcept.getAnnotation()); if (copySourceConcept.getDescription() != null) copyTargetConcept .setDescription(copySourceConcept.getDescription()); for (ONDEXConcept c : copySourceConcept.getTags()) copyTargetConcept.addTag(c);
/** * Clone concept with having a new PID. * * @param oldC * old ONDEXConcept * @param newPID * new PID to use * @return new ONDEXConcept */ public ONDEXConcept clone(ONDEXConcept oldC, String newPID) { // first clone concept with new PID ONDEXConcept newC = graph.createConcept(newPID, oldC.getAnnotation(), oldC.getDescription(), oldC.getElementOf(), oldC.getOfType(), oldC.getEvidence()); // copies everything else copyEverythingElse(oldC, newC); return newC; }
@Override protected void doAction() { // set flagged attribute to true on all concepts for (ONDEXConcept c : entities) { if (c.getAttribute(anFlag) == null) { c.createAttribute(anFlag, Boolean.TRUE, false); } else { c.getAttribute(anFlag).setValue(Boolean.TRUE); } } }
/** * Clone concept with having a new DataSource. * * @param oldC * old ONDEXConcept * @param newDataSource * new DataSource to use * @return new ONDEXConcept */ public ONDEXConcept clone(ONDEXConcept oldC, DataSource newDataSource) { // first clone concept with new DataSource ONDEXConcept newC = graph.createConcept(oldC.getPID(), oldC.getAnnotation(), oldC.getDescription(), newDataSource, oldC.getOfType(), oldC.getEvidence()); // copies everything else copyEverythingElse(oldC, newC); return newC; }
/** * Copies all of the attributes from one concept to another (only if they do * not already exist at target) * * @param from * - concept to copy from * @param to * - concept to copy to * @throws AccessDeniedException * @throws NullValueException * @throws EmptyStringException */ public static void copyConceptAttributes(ONDEXConcept from, ONDEXConcept to) throws NullValueException, AccessDeniedException, EmptyStringException { for (EvidenceType et : from.getEvidence()) addNewEvidence(to, et); for (ConceptAccession ca : from.getConceptAccessions()) addNewAccession(to, ca); for (ConceptName cn : from.getConceptNames()) addNewName(to, cn); for (Attribute attribute : from.getAttributes()) addNewAttribute(to, attribute); if (from.getAnnotation() != null && to.getDescription() == null) to.setAnnotation(from.getAnnotation()); if (from.getDescription() != null && to.getDescription() == null) to.setDescription(from.getDescription()); }
public String getName(ONDEXConcept ac) { String label = ""; // get first preferred name as label for (ConceptName cn : ac.getConceptNames()) { if (cn.isPreferred()) { label = cn.getName(); break; } } // next try annotation if (label == null || label.trim().length() == 0) { label = ac.getAnnotation(); } // next try description if (label == null || label.trim().length() == 0) { label = ac.getDescription(); } // next try pid if (label == null || label.trim().length() == 0) { label = ac.getPID(); } // last resort to concept id if (label == null || label.trim().length() == 0) { label = String.valueOf(ac.getId()); } return label; }
public int getOrCreateGeneID(String geneId) { if (poplarReg.containsGene(geneId)) { return poplarReg.getGene(geneId); } else { ONDEXConcept gene = og.getFactory().createConcept(geneId, dataSourcePHYTOZOME, ccGene, etIMPD); gene.createConceptAccession(geneId, dataSourcePHYTOZOME, false); gene.createConceptName(geneId, false); Integer ondexGeneId = gene.getId(); gene.createAttribute(anTaxID, Parser.POPLAR_TAX_ID, false); poplarReg.addGene(geneId, ondexGeneId); return ondexGeneId; } }
/** * Clone concept with having a new ConceptClass. * * @param oldC * old ONDEXConcept * @param newCC * new ConceptClass to use * @return new ONDEXConcept */ public ONDEXConcept clone(ONDEXConcept oldC, ConceptClass newCC) { // first clone concept with new ConceptClass ONDEXConcept newC = graph.createConcept(oldC.getPID(), oldC.getAnnotation(), oldC.getDescription(), oldC.getElementOf(), newCC, oldC.getEvidence()); // copies everything else copyEverythingElse(oldC, newC); return newC; }
/** * Generate metadata for Context. * @param context * A Context tag (from the Ondex API). * @return JSONObject * JSONObject containing information about the Context tag. */ private JSONObject buildContext(ONDEXConcept context) { JSONObject contextJson= new JSONObject(); contextJson.put(JSONAttributeNames.ID, context.getId()); return contextJson; }
@Override public String getUri ( ONDEXConcept c, Map<String, Object> params ) { String ns = Java2RdfUtils.getParam ( params, "instanceNamespace", NamespaceUtils.ns ( "bkr" ) ); String ccPart = Optional .ofNullable ( c.getOfType () ) .flatMap ( cc -> Optional.ofNullable ( cc.getId () ) ) .orElse ( null ); return OndexRDFUtils.iri ( ns, ccPart, c.getPID (), c.getId () ); } }
/** * helper method to extract a usable concept name. * * @param c * a concept. * @return a usable name. */ private String extractName(ONDEXConcept c) { String str = ""; if (c.getConceptName() != null) str = c.getConceptName().getName(); if (str.trim().length() == 0) str = c.getPID(); if (str.trim().length() == 0) str = c.getId() + ""; return str; }
@Override public void nodeToConcept(AbstractNode node) { Publication pub = (Publication) node; if(StandardFunctions.nullChecker(pub.getUniqueId(), dataSourceBioC, ccPublication, etIMPD)) return; ONDEXConcept concept = this.graph.getFactory().createConcept(pub.getUniqueId(), dataSourceBioC, ccPublication, etIMPD); if (pub.getPubMedId() != 0){ concept.createConceptAccession(new String(pub.getPubMedId() + ""), dataSourceNLM, false); } if (pub.getTitle() != null && !pub.getTitle().equals("")){ concept.createAttribute(attTitle, pub.getTitle(), false); } pub.setConcept(concept); }
@Override public ConceptClass getOfType() { return parent.getOfType(); }
@Override public Font transform(ONDEXConcept n) { ONDEXConcept c = graph.getConcept(n.getId()); Attribute attribute = c.getAttribute(an); if (attribute != null) { Float size = (float) (((Double) attribute.getValue() / (Double) gdsMax) * (maxSize - minSize) + minSize); return newFont.deriveFont(size); } return newFont; } });
private void updateSelectedNodes() { selected.clear(); OVTK2PropertiesAggregator viewer = OVTK2Desktop.getDesktopResources() .getSelectedViewer(); if (viewer != null) { PickedState<ONDEXConcept> state = viewer.getVisualizationViewer() .getPickedVertexState(); Set<ONDEXConcept> set = state.getPicked(); for (ONDEXConcept node : set) { ONDEXConcept ac = node; selected.put(ac.getId() + ":" + ac.getPID(), ac.getId()); } } }
private ONDEXConcept createGene(String geneid, String[] additionalIdsFrom, String conceptName) { ONDEXConcept gene = graph.getFactory() .createConcept(geneid, dataSource, cc_gene, eviType); createAccessions(additionalIdsFrom, gene); if (conceptName != null && !conceptName.equalsIgnoreCase("na")) { gene.createConceptName(conceptName.trim(), true); } gene.createAttribute(taxidAn, String.valueOf(3702), false); return gene; }
@Override public void nodeToConcept(AbstractNode node) { Reaction reaction = (Reaction) node; ONDEXConcept concept = graph.getFactory().createConcept( reaction.getUniqueId(), dataSourceAraC, ccReaction, etIMPD); if (reaction.getBalancedState() != null) concept.setAnnotation(reaction.getBalancedState()); concept.createConceptName(constructFormula(reaction), false); if (reaction.getDeltaGo() != null) { concept.createAttribute(deltaGo, reaction.getDeltaGo(), false); } reaction.setConcept(concept); }
/** * Copies all accessions from old concept to new concept. * * @param oldC * old ONDEXConcept * @param newC * new ONDEXConcept */ private void copyAccessions(ONDEXConcept oldC, ONDEXConcept newC) { // iterate over all old accessions for (ConceptAccession acc : oldC.getConceptAccessions()) { // clone old accession on new concept newC.createConceptAccession(acc.getAccession(), acc.getElementOf(), acc.isAmbiguous()); } }
public ONDEXConcept lookupHormone(String id) { Holder h = lookupConcept(hormoneIndex, hormone, id); ONDEXConcept c = h.concept; if (h.isNew) c.createConceptName(id, true); return c; }