List of usage examples for org.apache.commons.collections.keyvalue MultiKey MultiKey
public MultiKey(Object key1, Object key2, Object key3)
From source file:org.intermine.bio.dataconversion.TreefamConverter.java
private String getGene(String geneId, String symbol, String type, String taxonId) throws ObjectStoreException { String identifierType = (StringUtils.isNotEmpty(type) ? type : DEFAULT_IDENTIFIER_TYPE); String resolvedGenePid = null; // test if id has been resolved if (resolvedIds.containsKey(new MultiKey(taxonId, geneId, symbol))) { resolvedGenePid = resolvedIds.get(new MultiKey(taxonId, geneId, symbol)); } else {/*from w w w . j av a2s .co m*/ resolvedGenePid = resolveGene(taxonId, geneId, symbol); } if (resolvedGenePid == null) { return null; } String refId = identifiersToGenes.get(resolvedGenePid); if (refId == null) { Item gene = createItem("Gene"); gene.setAttribute(DEFAULT_IDENTIFIER_TYPE, resolvedGenePid); if (!identifierType.equals(DEFAULT_IDENTIFIER_TYPE)) { if ("crossReferences".equals(identifierType)) { gene.addToCollection(identifierType, createCrossReference(gene.getIdentifier(), geneId, DATA_SOURCE_NAME, true)); } else { gene.setAttribute(identifierType, geneId); } } gene.setReference("organism", getOrganism(taxonId)); refId = gene.getIdentifier(); identifiersToGenes.put(resolvedGenePid, refId); store(gene); } return refId; }
From source file:org.intermine.bio.dataconversion.TreefamConverter.java
private String resolveGene(String taxonId, String identifier, String symbol) { if (rslv == null || !rslv.hasTaxon(taxonId)) { // no id resolver available, so return the original identifier LOG.info("ID resolver not used for taxon ID " + taxonId); return identifier; }// w w w. j av a 2 s .co m String resolvedId = rslv.resolveIds(taxonId, Arrays.asList(identifier, symbol)); if (resolvedId != null) { LOG.info("RESOLVER: failed to resolve gene to one identifier, ignoring gene: " + identifier + " for taxon ID " + taxonId); } resolvedIds.put(new MultiKey(taxonId, identifier, symbol), resolvedId); return resolvedId; }
From source file:org.intermine.bio.web.displayer.FriendlyMineLinkGenerator.java
/** * Generate a list of genes and orthologues for remote mines. * * 1. Query local mine for orthologues for genes given. * 2. if orthologue found query remote mine for genes * 3. if orthologue not found query remote mine for orthologues * * @param olm LinkManager/*from ww w . j a va 2 s. co m*/ * @param organismShortName organism.shortName, eg. C. elegans * @param primaryIdentifier identifier for gene * @param mineName name of mine to query * @return map from mine to organism-->genes */ public Collection<JSONObject> getLinks(FriendlyMineManager olm, String mineName, String organismShortName, String primaryIdentifier) { if (StringUtils.isEmpty(mineName) || StringUtils.isEmpty(organismShortName) || StringUtils.isEmpty(primaryIdentifier)) { return null; } // FIXME temporarily ignoring lists with more than one organism if (organismShortName.contains(",")) { return null; } MultiKey key = new MultiKey(mineName, primaryIdentifier, organismShortName); Collection<JSONObject> cachedResults = olm.getLink(key); if (cachedResults != null && !debug) { return cachedResults; } Mine mine = olm.getMine(mineName); if (mine == null || mine.getReleaseVersion() == null) { LOG.info(mineName + " seems to be dead"); return null; } Model model = olm.getInterMineAPI().getModel(); Map<String, Set<String[]>> genes = new HashMap<String, Set<String[]>>(); try { // query for homologues in remote mine PathQuery q = getHomologueQuery(model, organismShortName, primaryIdentifier); Map<String, Set<String[]>> results = runQuery(mine, q, organismShortName); if (results != null && !results.isEmpty()) { genes.putAll(results); } else { // no luck, query local mine Map<String, Set<String>> localHomologues = getLocalHomologues(olm, organismShortName, primaryIdentifier); for (String remoteMineOrganism : mine.getDefaultValues()) { Set<String> matchingHomologues = localHomologues.get(remoteMineOrganism); if (matchingHomologues != null && !matchingHomologues.isEmpty()) { String identifiers = StringUtil.join(matchingHomologues, ","); // query remote mine for genes found in local mine q = getGeneQuery(model, remoteMineOrganism, identifiers); results = runQuery(mine, q, remoteMineOrganism); if (results != null && !results.isEmpty()) { genes.putAll(results); } } } } q = getGeneQuery(model, organismShortName, primaryIdentifier); results = runQuery(mine, q, organismShortName); if (results != null && !results.isEmpty()) { genes.putAll(results); } } catch (Exception e) { LOG.warn("error generating friendly mine links", e); return null; } Collection<JSONObject> results = resultsToJSON(key, genes); olm.addLink(key, results); return results; }
From source file:org.kuali.student.r2.core.room.service.decorators.RoomServiceCacheDecorator.java
@Override public List<RoomInfo> getRoomsByBuildingAndRoomCode(@WebParam(name = "buildingCode") String buildingCode, @WebParam(name = "roomCode") String roomCode, @WebParam(name = "contextInfo") ContextInfo contextInfo) throws DoesNotExistException, InvalidParameterException, MissingParameterException, OperationFailedException, PermissionDeniedException { MultiKey cacheKey = new MultiKey(BUILDING_ROOM_CODE_CACHE_PREFIX, buildingCode, roomCode); Element cachedResult = cacheManager.getCache(buildingRoomCodeCache).get(cacheKey); List<RoomInfo> result = null; if (cachedResult == null) { result = getNextDecorator().getRoomsByBuildingAndRoomCode(buildingCode, roomCode, contextInfo); cacheManager.getCache(buildingRoomCodeCache).put(new Element(cacheKey, result)); } else {/*from www .j a v a 2s. co m*/ result = (List<RoomInfo>) cachedResult.getValue(); } return result; }