Skip to content

Commit

Permalink
allow overlap filter to be configurable (#2585)
Browse files Browse the repository at this point in the history
* allow overlap filter to be configurable

* updated config

* updated jbrowse track for pruning
  • Loading branch information
nathandunn committed Feb 22, 2021
1 parent b9c8e2d commit 20caebb
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 17 deletions.
1 change: 1 addition & 0 deletions ChangeLog.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ Features
- Added system info web service [2557](https://github.com/GMOD/Apollo/pull/2557).
- Add "merged from" comment to merged in transcript and gene [2567](https://github.com/GMOD/Apollo/issues/2567).
- Added support for "obsolete", and partials in the interface for GFF3s [2573](https://github.com/GMOD/Apollo/pull/2573).
- Allow overlap filter to be configurable [2582](https://github.com/GMOD/Apollo/issues/2582).

Bug Fixes:

Expand Down
32 changes: 17 additions & 15 deletions grails-app/controllers/org/bbop/apollo/JbrowseController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@ class JbrowseController {
def preferenceService
def jbrowseService
def servletContext
def configWrapperService
def trackService

def chooseOrganismForJbrowse() {
Expand Down Expand Up @@ -62,7 +61,6 @@ class JbrowseController {

// case 3 - validated login (just read from preferences, then
if (permissionService.currentUser && clientToken) {
// Organism organism = preferenceService.getOrganismForToken(clientToken)
Organism organism = preferenceService.getOrganismForTokenInDB(clientToken)
if(organism){
// we need to generate a client_token and do a redirection
Expand Down Expand Up @@ -393,7 +391,7 @@ class JbrowseController {
* @param tracksArray
*/
def pruneTracks(JSONArray tracksArray){
private JSONArray pruneTracks(JSONArray tracksArray){
JSONArray returnArray = new JSONArray()

for(track in tracksArray){
Expand Down Expand Up @@ -523,14 +521,18 @@ class JbrowseController {
response.outputStream.close()
}

private static boolean isCacheableFile(String fileName) {
if (fileName.endsWith(".txt") || fileName.endsWith("txtz") || fileName.endsWith("csv")) {
return true;
}
if (fileName.endsWith(".json") || fileName.endsWith("jsonz")) {
String[] names = fileName.split("\\/");
String requestName = names[names.length - 1];
return requestName.startsWith("lf-");
private boolean isCacheableFile(String fileName) {
try {
if (fileName.endsWith(".txt") || fileName.endsWith("txtz") || fileName.endsWith("csv")) {
return true;
}
if (fileName.endsWith(".json") || fileName.endsWith("jsonz")) {
String[] names = fileName.split("\\/");
String requestName = names[names.length - 1];
return requestName.startsWith("lf-");
}
} catch (e) {
log.warn "Problem trying to cache file ${fileName}: ${e}"
}

return false;
Expand Down Expand Up @@ -592,13 +594,13 @@ class JbrowseController {

String mimeType = getServletContext().getMimeType(fileName);

String eTag = createHashFromFile(file);
String dateString = formatLastModifiedDate(file);

// if (isCacheableFile(fileName)) {
if (isCacheableFile(fileName)) {
String eTag = createHashFromFile(file);
String dateString = formatLastModifiedDate(file);
response.setHeader("ETag", eTag);
response.setHeader("Last-Modified", dateString);
// }
}

response.setContentType(mimeType);
// Set content size
Expand Down
6 changes: 4 additions & 2 deletions grails-app/controllers/org/bbop/apollo/TrackController.groovy
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ class TrackController {
def trackService
def svgService

final double OVERLAP_FILTER = 10.0
final double DEFAULT_OVERLAP_FILTER = 20.0

def beforeInterceptor = {
if (params.action == "featuresByName"
Expand Down Expand Up @@ -196,6 +196,7 @@ class TrackController {
, @RestApiParam(name = "ignoreCache", type = "boolean", paramType = RestApiParamType.QUERY, description = "(default false). Use cache for request if available.")
, @RestApiParam(name = "flatten", type = "string", paramType = RestApiParamType.QUERY, description = "Brings nested top-level components to the root level. If not provided or 'false' it will not flatten. Default is 'gene'.")
, @RestApiParam(name = "type", type = "string", paramType = RestApiParamType.QUERY, description = ".json or .svg")
, @RestApiParam(name = "overlapFilter", type = "double", paramType = RestApiParamType.QUERY, description = "(default 20). The widget of overlapping genes to display. 1 would be only features directly overlapping. Double_max would be any gene that overlaps, even if it overlaps the entire chromosome.")
])
@Transactional
def featuresByLocation(String organismString, String trackName, String sequence, Long fmin, Long fmax, String type) {
Expand All @@ -206,6 +207,7 @@ class TrackController {
String flatten = params.flatten != null ? params.flatten : 'gene'
flatten = flatten == 'false' ? '' : flatten
Boolean ignoreCache = params.ignoreCache != null ? Boolean.valueOf(params.ignoreCache) : false
double overlapFilter = params.overlapFilter != null ? Double.valueOf(params.overlapFilter) : DEFAULT_OVERLAP_FILTER
Map paramMap = new TreeMap<>()
paramMap.put("type", type)
if (nameSet) {
Expand Down Expand Up @@ -267,7 +269,7 @@ class TrackController {

renderedArray = renderedArray.unique{ it.name } as JSONArray
renderedArray = renderedArray.findAll{ it ->
return (it.fmax - it.fmin) < (OVERLAP_FILTER*(fmax - fmin))
return (it.fmax - it.fmin) < (overlapFilter*(fmax - fmin))
} as JSONArray

if (type == "json") {
Expand Down

0 comments on commit 20caebb

Please sign in to comment.