@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()); } });
private Map<DataSource, List<ConceptAccession>> getCVtoAccessions(ONDEXConcept c) { Map<DataSource, List<ConceptAccession>> cvMap = new HashMap<DataSource, List<ConceptAccession>>(); for (ConceptAccession acc : c.getConceptAccessions()) { // add all accessions by data source DataSource cv = acc.getElementOf(); if (!cvMap.containsKey(cv)) { List<ConceptAccession> ll = new LinkedList<ConceptAccession>(); cvMap.put(cv, ll); } cvMap.get(cv).add(acc); } return cvMap; }
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 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()); } }
@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 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; }
/** * Checks if a Pfam accession is in the * <code>Set<ConceptAccession></code> Iterator * * @param accessions - accessions which should be checked * @param graph - AbstractONDEXGraph * @return boolean - true, if the protein has pfam information attached */ private boolean hasPfamInformationAttached( Set<ConceptAccession> accessions, ONDEXGraph graph) { DataSource pfam = graph.getMetaData().getDataSource(MetaData.CV_PFAM); for (ConceptAccession accession : accessions) { if (accession.getElementOf().equals(pfam)) { return true; } } return false; }
/** * Creates an accession on concept only if it does not already exists * * @param target * - relation * @param newAcc * - attribute to create * @throws AccessDeniedException * @throws EmptyStringException * @throws NullValueException */ public static void addNewAccession(ONDEXConcept target, ConceptAccession newAcc) throws NullValueException, EmptyStringException, AccessDeniedException { if (target.getConceptAccession(newAcc.getAccession(), newAcc.getElementOf()) == null) target.createConceptAccession(newAcc.getAccession(), newAcc.getElementOf(), true); }
@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 boolean accepts() { // get meta data ONDEXGraph graph = viewer.getONDEXJUNGGraph(); DataSource dsSyngenta = graph.getMetaData().getDataSource("Syngenta"); // look at all selected concepts for (ONDEXConcept c : entities) { for (ConceptAccession ca : c.getConceptAccessions()) { // at least one accession with source Syngenta if (ca.getElementOf().equals(dsSyngenta)) { return true; } } } return false; }
@Override public boolean accepts() { // get meta data ONDEXGraph graph = viewer.getONDEXJUNGGraph(); DataSource dsUNIPROTKB = graph.getMetaData().getDataSource("UNIPROTKB"); // look at all selected concepts for (ONDEXConcept c : entities) { for (ConceptAccession ca : c.getConceptAccessions()) { // at least one accession with source UNIPROT if (ca.getElementOf().equals(dsUNIPROTKB)) { return true; } } } return false; }
/** * 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()); } }
@Override public boolean accepts() { // get meta data ONDEXGraph graph = viewer.getONDEXJUNGGraph(); ConceptClass ccComp = graph.getMetaData().getConceptClass("Comp"); DataSource dsCHEMBL = graph.getMetaData().getDataSource("CHEMBL"); // look at all selected chemical compounds for (ONDEXConcept c : entities) { if (c.getOfType().equals(ccComp)) { for (ConceptAccession ca : c.getConceptAccessions()) { // at least one accession with source CHEMBL if (ca.getElementOf().equals(dsCHEMBL)) { return true; } } } } return false; }
/** * 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; }