/** * Constructor. * * @param extraSynonyms a set of lists of unofficial names or common typos * @param ontologyManager the object that gives access to some of controlled vocabularies/ontologies (OBO) */ public XrefHelper(Set<List<String>> extraSynonyms, BiopaxOntologyManager ontologyManager) { // all database names and ID patterns go here this.dataPatterns = new ConcurrentHashMap<String, Pattern>(); // copy/normalize provided extra synonyms this.extraGroups = new CompositeCollection<String>(); if(extraSynonyms != null) { for(List<String> group : extraSynonyms) { Collection<String> newG = new ArrayList<String>(); for(String s : group) newG.add(dbName(s)); //trim, uppercase, add this.extraGroups.addComposited(newG); } } this.ontologyManager = ontologyManager; }
private boolean xcheck() { Object[] lists = allSynonyms.getCollections().toArray(); for(int i=0; i < lists.length; i++) { List<String> li = (List<String>) lists[i]; for(int j=i+1; j < lists.length; j++) { if(!Collections.disjoint(li, (Collection<?>) lists[j])) { log.error("different synonyms groups intercection found: " + li.toString() + " has names in common with " + lists[j].toString()); return false; } } } return true; // now intersection found :) }
this.allSynonyms = new CompositeCollection<String>(); this.unofficialDbNames = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>()); CompositeCollection<String> allSynonyms = new CompositeCollection<String>(); allSynonyms.addComposited(synonyms); synonyms.add(s); allSynonyms.addComposited(synonyms); if(!allSynonyms.contains(db)) unofficialDbNames.add(db); allSynonyms.addComposited((Collection<? extends String>[]) extraGroups.getCollections().toArray()); Set<Set<Collection<String>>> groupsOfGroups = clus.cluster(allSynonyms.getCollections(), Integer.MAX_VALUE); merged.add(0, primary); this.allSynonyms.addComposited(merged); } else { assert !groupsToMerge.isEmpty(); //one! this.allSynonyms.addComposited(groupsToMerge.iterator().next());
this.allSynonyms = new CompositeCollection<String>(); this.unofficialDbNames = Collections.newSetFromMap(new ConcurrentHashMap<String, Boolean>()); CompositeCollection<String> allSynonyms = new CompositeCollection<String>(); allSynonyms.addComposited(synonyms); synonyms.add(s); allSynonyms.addComposited(synonyms); if(!allSynonyms.contains(db)) unofficialDbNames.add(db); allSynonyms.addComposited((Collection<? extends String>[]) extraGroups.getCollections().toArray()); Set<Set<Collection<String>>> groupsOfGroups = clus.cluster(allSynonyms.getCollections(), Integer.MAX_VALUE); merged.add(0, primary); this.allSynonyms.addComposited(merged); } else { assert !groupsToMerge.isEmpty(); //one! this.allSynonyms.addComposited(groupsToMerge.iterator().next());
/** * Constructor. * * @param extraSynonyms a set of lists of unofficial names or common typos * @param ontologyManager the object that gives access to some of controlled vocabularies/ontologies (OBO) */ public XrefHelper(Set<List<String>> extraSynonyms, BiopaxOntologyManager ontologyManager) { // all database names and ID patterns go here this.dataPatterns = new ConcurrentHashMap<String, Pattern>(); // copy/normalize provided extra synonyms this.extraGroups = new CompositeCollection<String>(); if(extraSynonyms != null) { for(List<String> group : extraSynonyms) { Collection<String> newG = new ArrayList<String>(); for(String s : group) newG.add(dbName(s)); //trim, uppercase, add this.extraGroups.addComposited(newG); } } this.ontologyManager = ontologyManager; }
private boolean xcheck() { Object[] lists = allSynonyms.getCollections().toArray(); for(int i=0; i < lists.length; i++) { List<String> li = (List<String>) lists[i]; for(int j=i+1; j < lists.length; j++) { if(!Collections.disjoint(li, (Collection<?>) lists[j])) { log.error("different synonyms groups intercection found: " + li.toString() + " has names in common with " + lists[j].toString()); return false; } } } return true; // now intersection found :) }
private List<String> getSynonymsForName(String name, CompositeCollection<String> groups) { String dbName = dbName(name); for(Collection<String> group : groups.getCollections()) { if (group.contains(dbName)) { return (List<String>) group; } } return Collections.emptyList(); }
private List<String> getSynonymsForName(String name, CompositeCollection<String> groups) { String dbName = dbName(name); for(Collection<String> group : groups.getCollections()) { if (group.contains(dbName)) { return (List<String>) group; //copy to protect } } return Collections.emptyList(); }
/** * Gets the primary name for the DB. * It returns NULL for "unknown" database name. * * @param name case insensitive * @return */ public String getPrimaryDbName(String name) { String dbName = dbName(name); for(Collection<String> group : allSynonyms.getCollections()) { if (group.contains(dbName)) { return group.iterator().next(); //get the first } } return null; }