use of org.mskcc.oncotree.crosswalk.MSKConcept in project oncotree by cBioPortal.
the class OncoTreePersistentCache method backupMSKConceptPersistentCache.
public synchronized void backupMSKConceptPersistentCache(Map<String, MSKConcept> oncoTreeCodesToMSKConcepts) throws Exception {
CacheManager cacheManager = null;
Cache<String, MSKConcept> cache = null;
try {
if (oncoTreeCodesToMSKConcepts == null) {
System.out.println("null argument passed to backupMSKConceptPersistentCache");
return;
}
cacheManager = getCacheManager(BACKUP_CACHE_CONFIG_FILENAME);
cache = cacheManager.getCache(MSKCONCEPT_CACHE);
cache.putAll(oncoTreeCodesToMSKConcepts);
} catch (Exception e) {
logger.warn("exception in oncotreeCocdesToMSKConcepts -- exception: " + e);
throw e;
} finally {
if (cacheManager != null) {
// closes all caches it knows about
cacheManager.close();
}
}
}
use of org.mskcc.oncotree.crosswalk.MSKConcept in project oncotree by cBioPortal.
the class OncoTreePersistentCache method updateMSKConceptInPersistentCache.
// Updating MSKConcepts
@CachePut(value = "mskConceptEHCache", key = "#oncoTreeCode", unless = "#result==null")
public MSKConcept updateMSKConceptInPersistentCache(String oncoTreeCode) {
logger.info("updating EHCache with updated MSKConcept from Crosswalk");
MSKConcept mskConcept = crosswalkRepository.getByOncotreeCode(oncoTreeCode);
if (mskConcept != null) {
return mskConcept;
}
return new MSKConcept();
}
use of org.mskcc.oncotree.crosswalk.MSKConcept in project oncotree by cBioPortal.
the class OncotreeTestConfig method crosswalkRepository.
@Bean
public CrosswalkRepository crosswalkRepository() {
CrosswalkRepository repository = Mockito.mock(CrosswalkRepository.class);
MSKConcept mskConcept = new MSKConcept();
mskConcept.setConceptIds(Arrays.asList("MSK00001", "MSK00002"));
Mockito.when(repository.getByOncotreeCode(any(String.class))).thenReturn(mskConcept);
return repository;
}
use of org.mskcc.oncotree.crosswalk.MSKConcept in project oncotree by cBioPortal.
the class OncoTreePersistentCache method getMSKConceptFromPersistentCacheBackup.
@Cacheable(value = "mskConceptEHCache", key = "#oncoTreeCode", unless = "#result==null")
private synchronized MSKConcept getMSKConceptFromPersistentCacheBackup(String oncoTreeCode) throws Exception {
CacheManager cacheManager = null;
Cache<String, MSKConcept> cache = null;
MSKConcept mskConcept = null;
try {
cacheManager = getCacheManager(BACKUP_CACHE_CONFIG_FILENAME);
cache = cacheManager.getCache(MSKCONCEPT_CACHE);
mskConcept = cache.get(oncoTreeCode);
} finally {
if (cacheManager != null) {
// closes all caches it knows about
cacheManager.close();
}
}
return mskConcept;
}
use of org.mskcc.oncotree.crosswalk.MSKConcept in project oncotree by cBioPortal.
the class TumorTypesUtil method loadFromRepository.
private static Map<String, TumorType> loadFromRepository(Version version) throws InvalidOncoTreeDataException {
List<OncoTreeNode> oncoTreeNodes = oncoTreeRepository.getOncoTree(version);
Map<String, TumorType> allNodes = new HashMap<>();
HashSet<String> rootNodeCodeSet = new HashSet<>();
HashSet<String> duplicateCodeSet = new HashSet<>();
// construct basic nodes
for (OncoTreeNode thisNode : oncoTreeNodes) {
logger.debug("OncoTreeNode: code='" + thisNode.getCode() + "', name='" + thisNode.getName() + "'");
TumorType tumorType = initTumorType(thisNode, version);
String thisNodeCode = tumorType.getCode();
if (allNodes.containsKey(thisNodeCode)) {
duplicateCodeSet.add(thisNodeCode);
}
allNodes.put(thisNodeCode, tumorType);
if (hasNoParent(tumorType)) {
rootNodeCodeSet.add(thisNodeCode);
}
}
validateOncoTreeOrThrowException(rootNodeCodeSet, duplicateCodeSet, allNodes);
// also set NCI and UMLS codes
for (TumorType tumorType : allNodes.values()) {
String thisNodeCode = tumorType.getCode();
MSKConcept mskConcept = mskConceptCache.get(thisNodeCode);
if (mskConcept != null) {
HashMap<String, List<String>> crosswalks = mskConcept.getCrosswalks();
if (crosswalks != null && crosswalks.containsKey("NCI")) {
tumorType.setNCI(crosswalks.get("NCI"));
}
List<String> umlsIds = new ArrayList<String>();
if (mskConcept.getConceptIds() != null) {
for (String mskConceptId : mskConcept.getConceptIds()) {
umlsIds.add(mskConceptId.replace("MSK", "C"));
}
}
tumorType.setUMLS(umlsIds);
tumorType.setHistory(new ArrayList(mskConcept.getHistory()));
}
if (rootNodeCodeSet.contains(thisNodeCode)) {
// root node has no parent
continue;
}
TumorType parent = allNodes.get(tumorType.getParent());
parent.addChild(tumorType);
}
// set depth and tissue properties (root has tissue = null)
String rootCode = rootNodeCodeSet.iterator().next();
TumorType rootNode = allNodes.get(rootCode);
setDepthAndTissue(rootNode, 0, null);
// now that all children have a path of references to them from the root, return only the root node.
allNodes.clear();
allNodes.put(rootCode, rootNode);
return allNodes;
}
Aggregations