Skip to content

Commit

Permalink
Merge pull request #79 from cBioPortal/alias-history-feature
Browse files Browse the repository at this point in the history
Alias history feature
  • Loading branch information
mandawilson authored Aug 30, 2017
2 parents 09b44fa + 7446e49 commit 386275e
Show file tree
Hide file tree
Showing 12 changed files with 98 additions and 320 deletions.
25 changes: 25 additions & 0 deletions core/src/main/java/org/mskcc/oncotree/crosswalk/MSKConcept.java
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public class MSKConcept {
private HashMap<String, List<String>> crosswalks;
@JsonIgnore
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
private Set<String> history = new HashSet<String>();

/**
* No args constructor for use in serialization
Expand Down Expand Up @@ -81,6 +82,30 @@ public void setCrosswalks(HashMap<String, List<String>> crosswalks) {
this.crosswalks = crosswalks;
}

/**
*
* @return history
*/
public Set<String> getHistory() {
return history;
}

/**
*
* @param oncotreeCode
*/
public void addHistory(String oncotreeCode) {
this.history.add(oncotreeCode);
}

/**
*
* @param oncotreeCodes
*/
public void addHistory(Set<String> oncotreeCodes) {
this.history.addAll(oncotreeCodes);
}

@JsonAnyGetter
public Map<String, Object> getAdditionalProperties() {
return this.additionalProperties;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import org.mskcc.oncotree.topbraid.OncoTreeNode;
import org.mskcc.oncotree.topbraid.OncoTreeRepository;
import org.mskcc.oncotree.utils.VersionUtil;
import org.mskcc.oncotree.model.Version;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.EnableScheduling;
import org.springframework.scheduling.annotation.Scheduled;
Expand All @@ -41,6 +42,8 @@ public class MSKConceptCache {

private final static Logger logger = Logger.getLogger(MSKConceptCache.class);
private static HashMap<String, MSKConcept> oncoTreeCodesToMSKConcepts = new HashMap<String, MSKConcept>();
// use this to store and look up previous oncoTree codes
private static HashMap<String, HashSet<String>> topBraidURIsToOncotreeCodes = new HashMap<String, HashSet<String>>();

@Autowired
private OncoTreeRepository oncoTreeRepository;
Expand All @@ -67,20 +70,38 @@ public MSKConcept get(String oncoTreeCode) {
private void resetCache() {
logger.info("resetCache() -- clearing Crosswalk MSKConcept cache and refilling");
oncoTreeCodesToMSKConcepts.clear();
List<OncoTreeNode> oncoTreeNodes = oncoTreeRepository.getOncoTree(VersionUtil.getDefaultVersion());
for (OncoTreeNode node : oncoTreeNodes) {
getFromCrosswalkAndSave(node.getCode());
}
// versions are ordered in ascending order by release date
for (Version version : VersionUtil.getVersions()) {
List<OncoTreeNode> oncoTreeNodes = oncoTreeRepository.getOncoTree(version);
for (OncoTreeNode node : oncoTreeNodes) {
MSKConcept mskConcept = getFromCrosswalkAndSave(node.getCode());
// get all codes defined so far for this topbraid uri and save in history
if (topBraidURIsToOncotreeCodes.containsKey(node.getURI())) {
// do not add this code to the history, but add any others
HashSet<String> allButThisNode = new HashSet<String>(topBraidURIsToOncotreeCodes.get(node.getURI()));
allButThisNode.remove(node.getCode());
mskConcept.addHistory(allButThisNode);
} else {
topBraidURIsToOncotreeCodes.put(node.getURI(), new HashSet<String>());
}
// now save this as onoctree code history for this topbraid uri
topBraidURIsToOncotreeCodes.get(node.getURI()).add(node.getCode());
}
}
}

private MSKConcept getFromCrosswalkAndSave(String oncoTreeCode) {
MSKConcept concept = null;
// only save if we have not seen before (UMLS/NCI info will not be different)
if (oncoTreeCodesToMSKConcepts.containsKey(oncoTreeCode)) {
return oncoTreeCodesToMSKConcepts.get(oncoTreeCode);
}
MSKConcept concept = new MSKConcept();
try {
concept = crosswalkRepository.getByOncotreeCode(oncoTreeCode);
} catch (CrosswalkException e) {
// do nothing
}
// save even if null
// save even if has no information in it
oncoTreeCodesToMSKConcepts.put(oncoTreeCode, concept);
return concept;
}
Expand Down
123 changes: 0 additions & 123 deletions core/src/main/java/org/mskcc/oncotree/model/History.java

This file was deleted.

74 changes: 0 additions & 74 deletions core/src/main/java/org/mskcc/oncotree/model/SearchHistoryResp.java

This file was deleted.

6 changes: 3 additions & 3 deletions core/src/main/java/org/mskcc/oncotree/model/TumorType.java
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ public class TumorType {
private Map<String, TumorType> children = new HashMap<String, TumorType>();
private String parent = null;
private Boolean deprecated = false;
private List<History> history = new ArrayList<History>();
private List<String> history = new ArrayList<String>();
private Links links = null;
private Level level = null;

Expand Down Expand Up @@ -197,11 +197,11 @@ public void setDeprecated(Boolean deprecated) {
**/
@ApiModelProperty(value = "")
@JsonProperty("history")
public List<History> getHistory() {
public List<String> getHistory() {
return history;
}

public void setHistory(List<History> history) {
public void setHistory(List<String> history) {
this.history = history;
}

Expand Down
Loading

0 comments on commit 386275e

Please sign in to comment.