Skip to content

Commit

Permalink
Merge pull request #15 from GMOD/2.0.1-lgv-update
Browse files Browse the repository at this point in the history
2.0.1 lgv update
  • Loading branch information
elliothershberg authored Jul 19, 2022
2 parents f939494 + 166970f commit db77e79
Show file tree
Hide file tree
Showing 15 changed files with 1,087 additions and 2,023 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: JBrowseR
Title: An R Interface to the JBrowse 2 Genome Browser
Version: 0.9.0.9000
Version: 0.9.1
Authors@R:
c(person(given = "Elliot",
family = "Hershberg",
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ export(default_session)
export(json_config)
export(renderJBrowseR)
export(serve_data)
export(text_index)
export(theme)
export(track_alignments)
export(track_data_frame)
Expand Down
5 changes: 5 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
# JBrowse 0.9.1

- Updated `@jbrowse/react-linear-genome-view` to latest release (2.0.1). Check out the [JB2 release notes](https://jbrowse.org/jb2/blog/2022/07/13/v2.0.1-release/) to learn about all of the features!
- Added a new function `text_index()` to provide support for text search.

# JBrowseR 0.9.0

- Updated `@jbrowse/react-linear-genome-view` to latest release (1.4.4). Check out the [JB2 release notes](https://jbrowse.org/jb2/blog/2021/09/14/v1.4.4-release/) to learn about all of the features!
Expand Down
51 changes: 51 additions & 0 deletions R/text-index.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
#' Create configuration for a JBrowse 2 text index
#'
#' Creates the necessary configuration string for an adapter to a text index for
#' gene name search in the browser.
#'
#' Note: this function currently only supports aggregate indeces.
#'
#' For more information on JBrowse 2 text indeces, visit:
#' \url{https://jbrowse.org/jb2/docs/config_guide/#text-searching}
#'
#' @param ix_uri the URI for the ix file
#' @param ixx_uri the URI for the ixx file
#' @param meta_uri the URI for the JSON metadata file
#' @param assembly the assembly associated with the text index
#'
#' @return a character vector with the JSON text index adapter.
#'
#' @export
#'
#' @examples
#' text_index(
#' "https://jbrowse.org/genomes/hg19/trix/hg19.ix",
#' "https://jbrowse.org/genomes/hg19/trix/hg19.ixx",
#' "https://jbrowse.org/genomes/hg19/trix/meta.json",
#' "hg19"
#' )
text_index <- function(ix_uri, ixx_uri, meta_uri, assembly) {
id <- paste0(assembly, "-index")

as.character(
stringr::str_glue(
"{{",
'"type": "TrixTextSearchAdapter", ',
'"textSearchAdapterId": "{id}", ',
'"ixFilePath": {{',
'"uri": "{ix_uri}", ',
'"locationType": "UriLocation"',
"}}, ",
'"ixxFilePath": {{',
'"uri": "{ixx_uri}", ',
'"locationType": "UriLocation"',
"}}, ",
'"metaFilePath": {{',
'"uri": "{meta_uri}", ',
'"locationType": "UriLocation"',
"}}, ",
'"assemblyNames": ["{assembly}"]',
"}}"
)
)
}
1 change: 1 addition & 0 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ reference:
- contents:
- theme
- json_config
- text_index
- title: "Utilities"
- contents:
- serve_data
5 changes: 5 additions & 0 deletions example_apps/custom_app.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,11 @@ library(shiny)
library(JBrowseR)

ui <- fluidPage(
tags$head(
tags$style(HTML(
"html { font-size: 14px }"
))
),
titlePanel("JBrowseR Example"),
JBrowseROutput("widgetOutput")
)
Expand Down
30 changes: 30 additions & 0 deletions example_apps/hg38_index_app.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
library(shiny)
library(JBrowseR)

ui <- fluidPage(titlePanel("JBrowseR Example"),
JBrowseROutput("widgetOutput"))

server <- function(input, output, session) {
hg38 <- assembly(
"https://jbrowse.org/genomes/GRCh38/fasta/hg38.prefix.fa.gz",
bgzip = TRUE,
aliases = c("GRCh38"),
refname_aliases = "https://s3.amazonaws.com/jbrowse.org/genomes/GRCh38/hg38_aliases.txt"
)


output$widgetOutput <- renderJBrowseR(JBrowseR(
"View",
location = "10:29,838,737..29,838,819",
assembly = hg38,
text_index = text_index(
"https://jbrowse.org/genomes/GRCh38/trix/hg38.ix",
"https://jbrowse.org/genomes/GRCh38/trix/hg38.ixx",
"https://jbrowse.org/genomes/GRCh38/trix/meta.json",
"hg38"
)
))

}

shinyApp(ui, server)
187 changes: 102 additions & 85 deletions inst/htmlwidgets/JBrowseR.js

Large diffs are not rendered by default.

38 changes: 38 additions & 0 deletions man/text_index.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"private": true,
"dependencies": {
"@jbrowse/react-linear-genome-view": "^1.4.4",
"@jbrowse/react-linear-genome-view": "^2.0.1",
"react": "^17.0.1",
"react-dom": "^17.0.1"
},
Expand Down
7 changes: 3 additions & 4 deletions srcjs/components/JsonView.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { messageShiny } from "../utils";

export default function View(props) {
const configObject = JSON.parse(props.config);
const { assembly, tracks, defaultSession, theme } = configObject;
const { assembly, tracks, defaultSession, theme, text_index } = configObject;
const location = props.location;
const state = createViewState({
assembly,
Expand All @@ -16,9 +16,8 @@ export default function View(props) {
location,
onChange: messageShiny,
configuration: { theme },
aggregateTextSearchAdapters: [text_index],
});

return (
<JBrowseLinearGenomeView viewState={state} />
);
return <JBrowseLinearGenomeView viewState={state} />;
}
6 changes: 3 additions & 3 deletions srcjs/components/View.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ export default function View(props) {
if (key === "theme") {
theme = JSON.parse(value);
stateOpts["configuration"] = { theme };
} else if (key == "text_index") {
stateOpts["aggregateTextSearchAdapters"] = [JSON.parse(value)];
} else {
// parse the string of JSON config
key === "location"
Expand All @@ -25,7 +27,5 @@ export default function View(props) {

const state = createViewState(stateOpts);

return (
<JBrowseLinearGenomeView viewState={state} />
);
return <JBrowseLinearGenomeView viewState={state} />;
}
11 changes: 11 additions & 0 deletions tests/testthat/test-text-index.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
test_that("creating a text index returns valid configuration", {
expect_equal(
text_index(
"https://jbrowse.org/genomes/GRCh38/trix/hg38.ix",
"https://jbrowse.org/genomes/GRCh38/trix/hg38.ixx",
"https://jbrowse.org/genomes/GRCh38/trix/meta.json",
"hg38"
),
"{\"type\": \"TrixTextSearchAdapter\", \"textSearchAdapterId\": \"hg38-index\", \"ixFilePath\": {\"uri\": \"https://jbrowse.org/genomes/GRCh38/trix/hg38.ix\", \"locationType\": \"UriLocation\"}, \"ixxFilePath\": {\"uri\": \"https://jbrowse.org/genomes/GRCh38/trix/hg38.ixx\", \"locationType\": \"UriLocation\"}, \"metaFilePath\": {\"uri\": \"https://jbrowse.org/genomes/GRCh38/trix/meta.json\", \"locationType\": \"UriLocation\"}, \"assemblyNames\": [\"hg38\"]}"
)
})
6 changes: 6 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
var path = require('path');
var CompressionPlugin = require("compression-webpack-plugin");
var webpack = require('webpack')

module.exports = {
mode: 'production',
Expand Down Expand Up @@ -33,6 +34,11 @@ module.exports = {
stats: {
colors: true
},
plugins: [
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 1,
}),
],
// can toggle source map back on during development
// devtool: 'source-map'
devtool: '',
Expand Down
Loading

0 comments on commit db77e79

Please sign in to comment.