Skip to content

Commit

Permalink
Add open_marker_symbol_in_mgi()
Browse files Browse the repository at this point in the history
- Renamed `open_marker_in_mgi()` to `open_marker_id_in_mgi()`
- Add `open_marker_symbol_in_mgi()`
  • Loading branch information
ramiromagno committed Jul 7, 2024
1 parent 8c71bd7 commit e59cd4f
Show file tree
Hide file tree
Showing 9 changed files with 95 additions and 19 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
Package: mgi.report.reader
Title: Read Mouse Genome Informatics Reports
Version: 0.1.2
Version: 0.1.3
Authors@R: c(
person("Ramiro", "Magno", , "[email protected]", role = c("aut", "cre"),
comment = c(ORCID = "0000-0001-5226-3441")),
Expand Down
3 changes: 2 additions & 1 deletion NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@
export(chromosomes)
export(feature_types)
export(marker_types)
export(open_marker_in_mgi)
export(open_marker_id_in_mgi)
export(open_marker_symbol_in_mgi)
export(read_report)
export(report_example)
export(report_file)
Expand Down
5 changes: 4 additions & 1 deletion NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,10 @@
keyed column for improved look-up performance.
* Mappings from symbols to symbols/identifiers is backed up by memoised functions
making interactive experience a bit nicer.
* Added bundled tiny examples of MRK_List1.rpt, accessible with `report_example()`.
* Added bundled tiny examples of MRK_List1.rpt, accessible with
`report_example()`, for examples and unit tests.
* Renamed `open_marker_in_mgi()` to `open_marker_id_in_mgi()`, and added
`open_marker_symbol_in_mgi()`.

# mgi.report.reader 0.1.2

Expand Down
51 changes: 45 additions & 6 deletions R/browser.R
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,9 @@ mgi_reports_index_md <- function() {
paste0("[MGI Reports Index](",mgi_reports_index_url(),")")
}

#' Browse MGI markers online
#' Browse MGI markers identifiers online
#'
#' [open_marker_in_mgi()] launches the web browser and opens a tab for each MGI
#' [open_marker_id_in_mgi()] launches the web browser and opens a tab for each MGI
#' accession identifier on the Mouse Genome Informatics web interface:
#' \url{https://www.informatics.jax.org}.
#'
Expand All @@ -48,14 +48,14 @@ mgi_reports_index_md <- function() {
#'
#' @examples
#' # Read about Acta1 (actin alpha 1, skeletal muscle) online.
#' open_marker_in_mgi("MGI:87902")
#' open_marker_id_in_mgi("MGI:87902")
#'
#' # `open_marker_in_mgi()` is vectorized, so you can open multiple pages.
#' # `open_marker_id_in_mgi()` is vectorized, so you can open multiple pages.
#' # NB: think twice if you really need to open many tabs at once.
#' open_marker_in_mgi(c("MGI:87902", "MGI:87909"))
#' open_marker_id_in_mgi(c("MGI:87902", "MGI:87909"))
#'
#' @export
open_marker_in_mgi <- function(marker_id) {
open_marker_id_in_mgi <- function(marker_id) {
if (!(all(is_mgi_identifier(marker_id))))
stop("`marker_id` must be a character vector of valid MGI identifiers.")

Expand All @@ -75,3 +75,42 @@ open_marker_in_mgi <- function(marker_id) {
return(invisible(TRUE))
}
}

#' Browse MGI markers symbols online
#'
#' [open_marker_symbol_in_mgi()] launches the web browser and opens a tab for each MGI
#' symbol on the Mouse Genome Informatics web interface:
#' \url{https://www.informatics.jax.org}.
#'
#' @inheritParams common-args
#'
#' @returns Returns `TRUE` if successful, or `FALSE` otherwise. But note that
#' this function is run for its side effect of launching the browser.
#'
#' @examples
#' # Read about Acta1 (actin alpha 1, skeletal muscle) online.
#' open_marker_symbol_in_mgi("Acta1")
#'
#' # `open_marker_symbol_in_mgi()` is vectorized, so you can open multiple pages.
#' # NB: think twice if you really need to open many tabs at once.
#' open_marker_symbol_in_mgi(c("Acta1", "Hes1"))
#'
#' @export
open_marker_symbol_in_mgi <- function(marker_symbol) {

if (interactive()) {
msg <- paste("You are about to open",
length(marker_symbol),
"pages in your browser.")
if (length(marker_symbol) > 10L)
if (!sure(before_question = msg))
return(invisible(FALSE))

urls <- paste0(mgi_base_url(), "/quicksearch/summary?queryType=exactPhrase&query=", marker_symbol)
lapply(urls, utils::browseURL)

return(invisible(TRUE))
} else {
return(invisible(TRUE))
}
}
1 change: 1 addition & 0 deletions R/docs.R
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
#' `r desc_package_name()`.
#'
#' @param marker_id A character vector. MGI accession identifiers.
#' @param marker_symbol A character vector. MGI marker symbols.
#'
#' @param report_key A character vector. A key used to uniquely refer to an MGI
#' report.
Expand Down
5 changes: 3 additions & 2 deletions _pkgdown.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ reference:
- marker_types
- feature_types

- subtitle: Helpers
- subtitle: Browse MGI Webserver
contents:
- open_marker_in_mgi
- open_marker_id_in_mgi
- open_marker_symbol_in_mgi
2 changes: 2 additions & 0 deletions man/common-args.Rd

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

16 changes: 8 additions & 8 deletions man/open_marker_in_mgi.Rd → man/open_marker_id_in_mgi.Rd

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

29 changes: 29 additions & 0 deletions man/open_marker_symbol_in_mgi.Rd

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

0 comments on commit e59cd4f

Please sign in to comment.