private String getShortestNotAmbiguousConceptAccession(Set<ConceptAccession> co_accs) { String shortest_acc=" "; int length= 100000; for(ConceptAccession acc : co_accs) { if(!(acc.isAmbiguous()) && (acc.getAccession().trim().length() <= length)) { shortest_acc= acc.getAccession().trim(); length= shortest_acc.length(); } } return shortest_acc; }
private String getShortestNotAmbiguousConceptAccession(Set<ConceptAccession> co_accs) { String shortest_acc=" "; int length= 100000; for(ConceptAccession acc : co_accs) { if(!(acc.isAmbiguous()) && (acc.getAccession().trim().length() <= length)) { shortest_acc= acc.getAccession().trim(); length= shortest_acc.length(); } } return shortest_acc; }
private String getShortestNotAmbiguousConceptAccession(Set<ConceptAccession> co_accs) { String shortest_acc=" "; int length= 100000; for(ConceptAccession acc : co_accs) { // System.out.println("\t acc: "+ acc.getAccession().trim() +", isAmbiguous: "+ acc.isAmbiguous()); if(!(acc.isAmbiguous()) && (acc.getAccession().trim().length() <= length)) { shortest_acc= acc.getAccession().trim(); length= shortest_acc.length(); } } // System.out.println("\t shortest_acc: "+ shortest_acc); return shortest_acc; }
private String getShortestNotAmbiguousConceptAccession(Set<ConceptAccession> co_accs) { String shortest_acc=" "; int length= 100000; for(ConceptAccession acc : co_accs) { // System.out.println("\t acc: "+ acc.getAccession().trim() +", isAmbiguous: "+ acc.isAmbiguous()); if(!(acc.isAmbiguous()) && (acc.getAccession().trim().length() <= length)) { shortest_acc= acc.getAccession().trim(); length= shortest_acc.length(); } } // System.out.println("\t shortest_acc: "+ shortest_acc); return shortest_acc; }
public static Set<String> getAccessions(ONDEXConcept c, DataSource cv) { Set<String> set = new HashSet<String>(); for (ConceptAccession ac : c.getConceptAccessions()) { if (ac.getElementOf().equals(cv)) { set.add(ac.getAccession()); } } return set; }
private List<String> getAcc(ONDEXConcept c, DataSource elOf) { List<String> accessions = new ArrayList<String>(); for (ConceptAccession acc : c.getConceptAccessions()) { if (acc.getElementOf().equals(elOf)) { accessions.add(acc.getAccession()); } } return accessions; }
public static String getAccession(ONDEXConcept c, DataSource cv) { for (ConceptAccession ac : c.getConceptAccessions()) { if (ac.getElementOf().equals(cv)) { return ac.getAccession(); } } return null; }
/** * Generate metadata for Concept Accession. * @param accession * A Concept Accession (from the Ondex API). * @return JSONObject * JSONObject containing information about the Concept Accession. */ private JSONObject buildConceptAccession(ConceptAccession accession) { JSONObject accJson= new JSONObject(); accJson.put(JSONAttributeNames.ACCESSION, accession.getAccession()); // Element Of (return parent data source information). accJson.put(JSONAttributeNames.ELEMENTOF, buildDataSource(accession.getElementOf())); // accJson.put(JSONAttributeNames.AMBIGUOUS, String.valueOf(accession.isAmbiguous())); return accJson; }
/** * * @param conceptAccessions * @return */ private static final String getAccessionOfCV(Set<ConceptAccession> conceptAccessions, String cv) { for (ConceptAccession acc : conceptAccessions) { if (acc.getElementOf().getId().equals(cv)) { return acc.getAccession(); } } return null; }
/** * Gets the list of all accessions of a particular cv from a concpet * * @param c * - concept with accessions * @param type * - type of accesions to extract * @return */ public static final List<String> getAccessionsOfType(ONDEXConcept c, DataSource type) { List<String> accs = new LinkedList<String>(); for (ConceptAccession a : c.getConceptAccessions()) { if (a.getElementOf().equals(type)) { accs.add(a.getAccession()); } } return accs; }
/** * Generate metadata for Concept Accession. * @param accession * A Concept Accession (from the Ondex API). * @return JSONObject * JSONObject containing information about the Concept Accession. */ private JSONObject buildConceptAccession(ConceptAccession accession) { JSONObject accJson= new JSONObject(); accJson.put(JSONAttributeNames.ACCESSION, accession.getAccession()); // Element Of (return parent data source information). accJson.put(JSONAttributeNames.ELEMENTOF, buildDataSource(accession.getElementOf())); accJson.put(JSONAttributeNames.AMBIGUOUS, String.valueOf(accession.isAmbiguous())); return accJson; }
@Override public boolean equals(Object o) { if (this == o) return true; if (o instanceof ConceptAccession) { ConceptAccession ca = (ConceptAccession) o; return this.getAccession().equals(ca.getAccession()) && this.getElementOf().equals(ca.getElementOf()); } return false; }
@Override public String getUri ( ConceptAccession acc, Map<String, Object> params ) { String ns = Java2RdfUtils.getParam ( params, "instanceNamespace", NamespaceUtils.ns ( "bkr" ) ); String accValue = acc.getAccession (); String dsPart = Optional.ofNullable ( acc.getElementOf () ).map ( DataSource::getId ).orElse ( "generic" ); // The accession is always present, so -1 will never be used return OndexRDFUtils.iri ( ns + "accsn_", dsPart, accValue, -1 ); } }
@Override public Component getTableCellEditorComponent(JTable table, Object value, boolean isSelected, int row, int column) { // which concept we are working on concept = (ONDEXConcept) table.getValueAt(row, 0); // check for concept accession values if (value instanceof ConceptAccession) { acc = (ConceptAccession) value; value = acc.getAccession(); } else { acc = null; } // use default text field editor return super.getTableCellEditorComponent(table, value, isSelected, row, column); }
@Override public int compare(ConceptAccession o1, ConceptAccession o2) { if (o1.getElementOf().equals(o2.getElementOf())) return o1.getAccession().compareTo(o2.getAccession()); return o1.getElementOf().getId() .compareTo(o2.getElementOf().getId()); } });
@Override public void actionPerformed(ActionEvent e) { this.setVisible(false); editor.acc.setAmbiguous(box.isSelected()); // has the DataSource of accession changed? DataSource dataSource = (DataSource) selection.getSelectedItem(); if (!editor.acc.getElementOf().equals(dataSource)) { // delete old one ConceptAccession old = editor.concept.getConceptAccession(editor.acc.getAccession(), editor.acc.getElementOf()); editor.concept.deleteConceptAccession(editor.acc.getAccession(), editor.acc.getElementOf()); // create one with new DataSource editor.acc = editor.concept.createConceptAccession(old.getAccession(), dataSource, old.isAmbiguous()); } } }
@Override public String toString(TableModel model, int row, int column) { Object o = model.getValueAt(row, column); if (o instanceof MetaData) return ((MetaData) o).getId(); else if (o instanceof ONDEXConcept) return String.valueOf(((ONDEXConcept) o).getId()); else if (o instanceof ONDEXRelation) return String.valueOf(((ONDEXRelation) o).getId()); else if (o instanceof ConceptName) return ((ConceptName) o).getName(); else if (o instanceof ConceptAccession) return ((ConceptAccession) o).getAccession(); else if (o instanceof Attribute) return ((Attribute) o).getValue().toString(); else if (o != null) return o.toString(); else return ""; }
@Override public int compare(ConceptAccession o1, ConceptAccession o2) { // within same DataSource sort first by ambiguity, than by accession if (o1.getElementOf().equals(o2.getElementOf())) { if (!o1.isAmbiguous() && o2.isAmbiguous()) return -1; else if (o1.isAmbiguous() && !o2.isAmbiguous()) return 1; else return o1.getAccession().compareTo(o2.getAccession()); } else { // sort according to DataSource return o1.getElementOf().getId().compareTo(o2.getElementOf().getId()); } }
/** * 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()); } }
/** * Cast a given ConceptAccession into a BerkeleyConceptAccession. * * @param old * ConceptAccession * @return BerkeleyConceptAccession */ protected static BerkeleyConceptAccession convert(ConceptAccession old) { BerkeleyConceptAccession nu = new BerkeleyConceptAccession( old.getSID(), old.getOwnerId(), old.getAccession(), old.getElementOf(), old.isAmbiguous()); return nu; }