Skip to content

Commit 386275e

Browse files
authored
Merge pull request #79 from cBioPortal/alias-history-feature
Alias history feature
2 parents 09b44fa + 7446e49 commit 386275e

File tree

12 files changed

+98
-320
lines changed

12 files changed

+98
-320
lines changed

core/src/main/java/org/mskcc/oncotree/crosswalk/MSKConcept.java

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ public class MSKConcept {
3737
private HashMap<String, List<String>> crosswalks;
3838
@JsonIgnore
3939
private Map<String, Object> additionalProperties = new HashMap<String, Object>();
40+
private Set<String> history = new HashSet<String>();
4041

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

85+
/**
86+
*
87+
* @return history
88+
*/
89+
public Set<String> getHistory() {
90+
return history;
91+
}
92+
93+
/**
94+
*
95+
* @param oncotreeCode
96+
*/
97+
public void addHistory(String oncotreeCode) {
98+
this.history.add(oncotreeCode);
99+
}
100+
101+
/**
102+
*
103+
* @param oncotreeCodes
104+
*/
105+
public void addHistory(Set<String> oncotreeCodes) {
106+
this.history.addAll(oncotreeCodes);
107+
}
108+
84109
@JsonAnyGetter
85110
public Map<String, Object> getAdditionalProperties() {
86111
return this.additionalProperties;

core/src/main/java/org/mskcc/oncotree/crosswalk/MSKConceptCache.java

Lines changed: 27 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
import org.mskcc.oncotree.topbraid.OncoTreeNode;
2626
import org.mskcc.oncotree.topbraid.OncoTreeRepository;
2727
import org.mskcc.oncotree.utils.VersionUtil;
28+
import org.mskcc.oncotree.model.Version;
2829
import org.springframework.beans.factory.annotation.Autowired;
2930
import org.springframework.scheduling.annotation.EnableScheduling;
3031
import org.springframework.scheduling.annotation.Scheduled;
@@ -41,6 +42,8 @@ public class MSKConceptCache {
4142

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

4548
@Autowired
4649
private OncoTreeRepository oncoTreeRepository;
@@ -67,20 +70,38 @@ public MSKConcept get(String oncoTreeCode) {
6770
private void resetCache() {
6871
logger.info("resetCache() -- clearing Crosswalk MSKConcept cache and refilling");
6972
oncoTreeCodesToMSKConcepts.clear();
70-
List<OncoTreeNode> oncoTreeNodes = oncoTreeRepository.getOncoTree(VersionUtil.getDefaultVersion());
71-
for (OncoTreeNode node : oncoTreeNodes) {
72-
getFromCrosswalkAndSave(node.getCode());
73-
}
73+
// versions are ordered in ascending order by release date
74+
for (Version version : VersionUtil.getVersions()) {
75+
List<OncoTreeNode> oncoTreeNodes = oncoTreeRepository.getOncoTree(version);
76+
for (OncoTreeNode node : oncoTreeNodes) {
77+
MSKConcept mskConcept = getFromCrosswalkAndSave(node.getCode());
78+
// get all codes defined so far for this topbraid uri and save in history
79+
if (topBraidURIsToOncotreeCodes.containsKey(node.getURI())) {
80+
// do not add this code to the history, but add any others
81+
HashSet<String> allButThisNode = new HashSet<String>(topBraidURIsToOncotreeCodes.get(node.getURI()));
82+
allButThisNode.remove(node.getCode());
83+
mskConcept.addHistory(allButThisNode);
84+
} else {
85+
topBraidURIsToOncotreeCodes.put(node.getURI(), new HashSet<String>());
86+
}
87+
// now save this as onoctree code history for this topbraid uri
88+
topBraidURIsToOncotreeCodes.get(node.getURI()).add(node.getCode());
89+
}
90+
}
7491
}
7592

7693
private MSKConcept getFromCrosswalkAndSave(String oncoTreeCode) {
77-
MSKConcept concept = null;
94+
// only save if we have not seen before (UMLS/NCI info will not be different)
95+
if (oncoTreeCodesToMSKConcepts.containsKey(oncoTreeCode)) {
96+
return oncoTreeCodesToMSKConcepts.get(oncoTreeCode);
97+
}
98+
MSKConcept concept = new MSKConcept();
7899
try {
79100
concept = crosswalkRepository.getByOncotreeCode(oncoTreeCode);
80101
} catch (CrosswalkException e) {
81102
// do nothing
82103
}
83-
// save even if null
104+
// save even if has no information in it
84105
oncoTreeCodesToMSKConcepts.put(oncoTreeCode, concept);
85106
return concept;
86107
}

core/src/main/java/org/mskcc/oncotree/model/History.java

Lines changed: 0 additions & 123 deletions
This file was deleted.

core/src/main/java/org/mskcc/oncotree/model/SearchHistoryResp.java

Lines changed: 0 additions & 74 deletions
This file was deleted.

core/src/main/java/org/mskcc/oncotree/model/TumorType.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class TumorType {
2323
private Map<String, TumorType> children = new HashMap<String, TumorType>();
2424
private String parent = null;
2525
private Boolean deprecated = false;
26-
private List<History> history = new ArrayList<History>();
26+
private List<String> history = new ArrayList<String>();
2727
private Links links = null;
2828
private Level level = null;
2929

@@ -197,11 +197,11 @@ public void setDeprecated(Boolean deprecated) {
197197
**/
198198
@ApiModelProperty(value = "")
199199
@JsonProperty("history")
200-
public List<History> getHistory() {
200+
public List<String> getHistory() {
201201
return history;
202202
}
203203

204-
public void setHistory(List<History> history) {
204+
public void setHistory(List<String> history) {
205205
this.history = history;
206206
}
207207

0 commit comments

Comments
 (0)