Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update News.md #1

Open
wants to merge 28 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
ed02741
Update resource_uri_to_oncocode_mapping.txt
ritikakundra Apr 1, 2020
674c1ec
Update News.md
sheridancbio Apr 2, 2020
be79283
Update resource_uri_to_oncocode_mapping.txt
ritikakundra Aug 4, 2020
e0543a2
Adjustments to allow use with TopBraid 6.3 (#216)
sheridancbio Sep 11, 2020
e6cd3d2
fix empty crosswalk NCI references
sheridancbio Sep 14, 2020
b14ac35
rescind oncotree node PCT
sheridancbio Sep 30, 2020
b6b34c1
news relese - 2020_10_01
sheridancbio Oct 1, 2020
7a266ae
Added ontology mappings file
rmadupuri Oct 26, 2020
c4d7c30
Update OncoTree-Mapping-Tool.md (#221)
ritikakundra Oct 26, 2020
c141045
Update ontology_mappings.txt
ritikakundra Oct 27, 2020
68cb1b2
adjust homepage to count all nodes
sheridancbio Oct 27, 2020
40aae03
Fix formatting
rmadupuri Nov 2, 2020
f213db5
Update OncoTree-Mapping-Tool.md
sheridancbio Nov 2, 2020
e89dc65
add source-code
rmadupuri Nov 2, 2020
a676571
Update News.md (#227)
ritikakundra Nov 4, 2020
5258907
Update News.md
sheridancbio Nov 4, 2020
32bfd07
Update News.md
sheridancbio Nov 4, 2020
e284590
Update News.md
sheridancbio Nov 5, 2020
8150723
oncotree_to_oncotree.py should support python3 (#233)
sheridancbio Feb 3, 2021
5c5a9c2
Update resource_uri_to_oncocode_mapping.txt
ritikakundra Apr 22, 2021
43869be
Update index.html
ritikakundra Apr 22, 2021
f412e1a
Update index.html
ritikakundra May 20, 2021
48249c5
Update resource_uri_to_oncocode_mapping.txt
ritikakundra Oct 14, 2021
83f6432
Update resource_uri_to_oncocode_mapping.txt
ritikakundra Oct 25, 2021
c08e98c
Update resource_uri_to_oncocode_mapping.txt
ritikakundra Oct 25, 2021
86540e6
Update resource_uri_to_oncocode_mapping.txt
ritikakundra Nov 2, 2021
acdf8de
add oncotree ontology and taxonomy resources
sheridancbio Nov 2, 2021
4652a07
rename rdf file
sheridancbio Nov 2, 2021
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017 - 2019 Memorial Sloan-Kettering Cancer Center.
* Copyright (c) 2017 - 2020 Memorial Sloan-Kettering Cancer Center.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
Expand All @@ -18,20 +18,15 @@

package org.mskcc.oncotree.crosswalk;

import java.io.*;
import java.nio.charset.Charset;
import java.util.*;

import org.mskcc.oncotree.error.*;
import org.mskcc.oncotree.crosswalk.CrosswalkStaticResourceParsingException;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.core.io.ClassPathResource;
import org.springframework.core.io.Resource;
import org.springframework.stereotype.Repository;
import org.springframework.web.client.HttpServerErrorException;
import org.springframework.web.client.HttpStatusCodeException;
import org.springframework.web.client.RestClientException;
import org.springframework.web.client.RestTemplate;

/**
*
Expand All @@ -42,48 +37,70 @@ public class CrosswalkRepository {

private static final Logger logger = LoggerFactory.getLogger(CrosswalkRepository.class);

// URI variables should be vocabularyId={vocabularyId}&conceptId={conceptId}&histologyCode={histologyCode}&siteCode={siteCode}
@Value("${crosswalk.url}")
private String crosswalkURL;
private static final String STATIC_CROSSWALK_FILENAME = "staticCrosswalkOncotreeMappings.txt";
private Map<String, MSKConcept> parsedStaticResource = null;

@Value("${crosswalk.disable_cvs_querying:false}")
private Boolean DISABLE_CVS_QUERYING;
public MSKConcept getByOncotreeCode(String oncotreeCode) {
parseCrosswalkResourceFileIfNeeded();
MSKConcept concept = parsedStaticResource.get(oncotreeCode);
return concept;
}

public MSKConcept getByOncotreeCode(String oncotreeCode)
throws CrosswalkException {
return queryCVS("ONCOTREE", oncotreeCode, null, null);
private void parseCrosswalkResourceFileIfNeeded() {
if (parsedStaticResource == null) {
parsedStaticResource = new HashMap<String, MSKConcept>();
try {
parseCrosswalkResourceFile();
} catch (CrosswalkStaticResourceParsingException e) {
logger.error(e.toString());
parsedStaticResource.clear();
logger.error("external reference map empty following parsing error");
}
}
}

public MSKConcept queryCVS(String vocabularyId, String conceptId, String histologyCode, String siteCode)
throws CrosswalkException {
if (DISABLE_CVS_QUERYING) {
throw new CrosswalkServiceUnavailableException("CVS server queries have been disabled (crosswalk.disable_cvs_querying set to true)", new HttpServerErrorException(HttpStatus.SERVICE_UNAVAILABLE));
private String[] parseValuesIfPresent(String valueString) {
if (valueString.trim().length() > 0) {
return valueString.split(",");
}
RestTemplate restTemplate = new RestTemplate();
return new String[0];
}

private void parseCrosswalkResourceFile() throws CrosswalkStaticResourceParsingException {
try {
ResponseEntity<MSKConcept> response = restTemplate.getForEntity(crosswalkURL, MSKConcept.class, vocabularyId, conceptId, histologyCode, siteCode);
return response.getBody();
} catch (HttpStatusCodeException e) {
logger.error("queryCVS() -- caught HttpStatusCodeException: " + e);
String errorString = "URI: " + crosswalkURL + "\n" +
"vocabularyId: " + vocabularyId + "\n" +
"conceptId: " + conceptId + "\n" +
"histologyCode: " + histologyCode + "\n" +
"siteCode: " + siteCode + "\n";
if (e.getStatusCode().is4xxClientError()) {
throw new CrosswalkConceptNotFoundException("4xx Error while getting data from CVS Service with: \n" + errorString, e);
} else if (e.getStatusCode().is5xxServerError()) {
throw new CrosswalkServiceUnavailableException("5xx Error while getting data from CVS", e);
Resource resource = new ClassPathResource(STATIC_CROSSWALK_FILENAME);
InputStream inputStream = resource.getInputStream();
InputStreamReader isreader = new InputStreamReader(inputStream, Charset.forName("UTF-8"));
BufferedReader reader = new BufferedReader(isreader);
while (reader.ready()) {
String line = reader.readLine();
String columns[] = line.split("\t");
if (columns.length != 3) {
throw new CrosswalkStaticResourceParsingException("could not parse static file with crosswalk mappings - wrong column count");
}
String code = columns[0];
String nci[] = parseValuesIfPresent(columns[1]);
String umln[] = parseValuesIfPresent(columns[2]);
MSKConcept concept = new MSKConcept();
List<String> oncotreeCodes = new ArrayList<>();
oncotreeCodes.add(code);
concept.setOncotreeCodes(oncotreeCodes);
List<String> conceptIdList = Arrays.asList(umln);
if (conceptIdList.size() > 0) {
concept.setConceptIds(conceptIdList);
}
HashMap<String, List<String>> crosswalks = new HashMap<String, List<String>>();
List<String> nciList = Arrays.asList(nci);
if (nciList.size() > 0) {
crosswalks.put("NCI", nciList);
}
concept.setCrosswalks(crosswalks);
parsedStaticResource.put(code, concept);
}
throw new UnexpectedCrosswalkResponseException("Exception while getting data from CVS Service with: \n" + errorString, e);
} catch (RestClientException e) {
logger.error("queryCVS() -- caught RestClientErrorException: " + e);
String errorString = "URI: " + crosswalkURL + "\n" +
"vocabularyId: " + vocabularyId + "\n" +
"conceptId: " + conceptId + "\n" +
"histologyCode: " + histologyCode + "\n" +
"siteCode: " + siteCode + "\n";
throw new UnexpectedCrosswalkResponseException("RestClientException while getting data from CVS Service" + errorString, e);
} catch (IOException e) {
throw new CrosswalkStaticResourceParsingException("error : could not parse static file with crosswalk mappings");
}
}

}

Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017 Memorial Sloan-Kettering Cancer Center.
* Copyright (c) 2020 Memorial Sloan-Kettering Cancer Center.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
Expand All @@ -16,20 +16,24 @@
* has been advised of the possibility of such damage.
*/

package org.mskcc.oncotree.error;
package org.mskcc.oncotree.crosswalk;

import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
/**
*
* @author Manda Wilson
**/
public class CrosswalkException extends RuntimeException {

private static final Logger logger = LoggerFactory.getLogger(CrosswalkException.class);
public class CrosswalkStaticResourceParsingException extends Exception {

private static final Logger logger = LoggerFactory.getLogger(CrosswalkStaticResourceParsingException.class);

public CrosswalkStaticResourceParsingException() {
super();
}

public CrosswalkStaticResourceParsingException(String message) {
super(message);
}

public CrosswalkException(String message, Throwable cause) {
public CrosswalkStaticResourceParsingException(String message, Throwable cause) {
super(message, cause);
logger.error(message);
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2017 - 2019 Memorial Sloan-Kettering Cancer Center.
* Copyright (c) 2017 - 2020 Memorial Sloan-Kettering Cancer Center.
*
* This library is distributed in the hope that it will be useful, but
* WITHOUT ANY WARRANTY, WITHOUT EVEN THE IMPLIED WARRANTY OF
Expand Down Expand Up @@ -83,18 +83,13 @@ private void resetCache() throws Exception {
try {
oncoTreeNodes = oncoTreePersistentCache.getOncoTreeNodesFromPersistentCache(version);
} catch (RuntimeException e) {
throw new FailedCacheRefreshException("Failed to refresh MSKConceptCache");
throw new FailedCacheRefreshException("Failed to refresh MSKConceptCache : " + e.toString());
}
for (OncoTreeNode node : oncoTreeNodes) {
// skip querying repeated nodes/MSKConcepts
if (!latestOncoTreeCodesToMSKConcepts.containsKey(node.getCode())) {
// pull from crosswalk first
try {
oncoTreePersistentCache.updateMSKConceptInPersistentCache(node.getCode());
} catch (CrosswalkException e) {
// only thrown if can't connect to crosswalk (5XX error)
logger.error("Unable to update oncotree node with code " + node.getCode() + " from crosswalk...");
}
oncoTreePersistentCache.updateMSKConceptInPersistentCache(node.getCode());
MSKConcept concept = oncoTreePersistentCache.getMSKConceptFromPersistentCache(node.getCode());
latestOncoTreeCodesToMSKConcepts.put(node.getCode(), concept);
}
Expand Down

This file was deleted.

This file was deleted.

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@

import org.mskcc.oncotree.model.Version;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.core.ParameterizedTypeReference;
import org.springframework.stereotype.Repository;

Expand All @@ -38,24 +39,34 @@ public class OncoTreeRepository extends TopBraidRepository<OncoTreeNode> {

private static final Logger logger = LoggerFactory.getLogger(OncoTreeRepository.class);

private String query = "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> " +
"PREFIX onc:<http://data.mskcc.org/ontologies/oncotree#> " +
"SELECT DISTINCT (?s AS ?uri) ?code ?name ?mainType ?color ?parentCode ?revocations ?precursors " +
"WHERE { " +
" GRAPH <%s> { " +
" ?s skos:prefLabel ?name;" +
" skos:notation ?code." +
" OPTIONAL{?s skos:broader ?broader." +
" ?broader skos:notation ?parentCode}." +
" OPTIONAL{?s onc:mainType ?mainType}." +
" OPTIONAL{?s onc:color ?color}." +
" OPTIONAL{?s onc:revocations ?revocations}." +
" OPTIONAL{?s onc:precursors ?precursors}." +
" }" +
"}";
@Value("${topbraid.oncotree_namespace_prefix:http://data.mskcc.org/ontologies/oncotree#}")
private String topBraidOncotreeNamespacePrefix;

private String query = null;

private String getQuery() {
if (query == null) {
query = "PREFIX skos:<http://www.w3.org/2004/02/skos/core#> " +
"PREFIX onc:<" + topBraidOncotreeNamespacePrefix + "> " +
"SELECT DISTINCT (?s AS ?uri) ?code ?name ?mainType ?color ?parentCode ?revocations ?precursors " +
"WHERE { " +
" GRAPH <%s> { " +
" ?s skos:prefLabel ?name;" +
" skos:notation ?code." +
" OPTIONAL{?s skos:broader ?broader." +
" ?broader skos:notation ?parentCode}." +
" OPTIONAL{?s onc:mainType ?mainType}." +
" OPTIONAL{?s onc:color ?color}." +
" OPTIONAL{?s onc:revocations ?revocations}." +
" OPTIONAL{?s onc:precursors ?precursors}." +
" }" +
"}";
}
return query;
}

public ArrayList<OncoTreeNode> getOncoTree(Version version) throws TopBraidException {
return new ArrayList<OncoTreeNode>(super.query(String.format(query, version.getGraphURI()), new ParameterizedTypeReference<List<OncoTreeNode>>(){}));
return new ArrayList<OncoTreeNode>(super.query(String.format(getQuery(), version.getGraphURI()), new ParameterizedTypeReference<List<OncoTreeNode>>(){}));
}

}
Loading