-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add 'predict_topology_from_sequence' and 'predict_topologies_from_seq…
…uences'
- Loading branch information
richelbilderbeek
committed
Jan 16, 2021
1 parent
148f83e
commit bb0bdfb
Showing
12 changed files
with
225 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,7 +17,7 @@ Imports: | |
dplyr, | ||
ggplot2, | ||
plyr, | ||
pureseqtmr, | ||
pureseqtmr (>= 1.3), | ||
purrr, | ||
rappdirs, | ||
readr, | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#' Run TMHMM directy on a protein sequence | ||
#' @inheritParams default_params_doc | ||
#' @return one or more topology sequences, | ||
#' for example \code{c("iiiimmmmooooo", "iiiii")} | ||
#' @seealso use \link{mock_predict_topologies_from_sequences} | ||
#' to mock the prediction of protein sequences, as can be useful | ||
#' in testing | ||
#' @examples | ||
#' if (is_tmhmm_installed()) { | ||
#' protein_sequence <- paste0( | ||
#' "QEKNWSALLTAVVIILTIAGNILVIMAVSLEKKLQNATNYFLM", | ||
#' "SLAIADMLLGFLVMPVSMLTILYGYRWP" | ||
#' ) | ||
#' predict_topology_from_sequence(protein_sequence) | ||
#' } | ||
#' @author Richèl J.C. Bilderbeek | ||
#' @export | ||
predict_topologies_from_sequences <- function(# nolint indeed a long function name | ||
protein_sequences, | ||
folder_name = get_default_tmhmm_folder(), | ||
temp_fasta_filename = tempfile(fileext = ".fasta"), | ||
temp_topology_filename = tempfile(fileext = ".topo") | ||
) { | ||
t_sequences <- tibble::tibble( | ||
name = paste0("protein_", seq_along(protein_sequences)), | ||
sequence = protein_sequences | ||
) | ||
pureseqtmr::save_tibble_as_fasta_file( | ||
t = t_sequences, | ||
fasta_filename = temp_fasta_filename | ||
) | ||
t_topologies <- tmhmm::predict_topology( | ||
fasta_filename = temp_fasta_filename, | ||
folder_name = folder_name, | ||
temp_topology_filename = temp_topology_filename | ||
) | ||
file.remove(temp_fasta_filename) | ||
t_topologies$topology | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
#' Run TMHMM directy on a protein sequence | ||
#' @param protein_sequence a protein sequence, with | ||
#' the amino acids as capitals, for | ||
#' example \code{MEILCEDNTSLSSIPNSL} | ||
#' @inheritParams default_params_doc | ||
#' @return a topology sequence, | ||
#' for example \code{"iiiimmmmmoooo"} | ||
#' @examples | ||
#' if (is_tmhmm_installed()) { | ||
#' protein_sequence <- paste0( | ||
#' "QEKNWSALLTAVVIILTIAGNILVIMAVSLEKKLQNATNYFLM", | ||
#' "SLAIADMLLGFLVMPVSMLTILYGYRWP" | ||
#' ) | ||
#' predict_topology_from_sequence(protein_sequence) | ||
#' } | ||
#' @author Richèl J.C. Bilderbeek | ||
#' @export | ||
predict_topology_from_sequence <- function( | ||
protein_sequence, | ||
folder_name = get_default_tmhmm_folder(), | ||
temp_fasta_filename = tempfile(fileext = ".fasta"), | ||
temp_topology_filename = tempfile(fileext = ".topo") | ||
) { | ||
tmhmm::predict_topologies_from_sequences( | ||
protein_sequences = protein_sequence, | ||
folder_name = folder_name, | ||
temp_fasta_filename = temp_fasta_filename, | ||
temp_topology_filename = temp_topology_filename | ||
) | ||
} |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
test_that("use", { | ||
if (!is_tmhmm_installed()) return() | ||
protein_sequences <- c( | ||
"FAMILYVWFAMILYVW", | ||
"FAMILYVWFAMILY" | ||
) | ||
topologies <- predict_topologies_from_sequences( | ||
protein_sequences = protein_sequences | ||
) | ||
expect_equal(length(protein_sequences), length(topologies)) | ||
expect_equal(nchar(protein_sequences), nchar(topologies)) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
test_that("use", { | ||
if (!is_tmhmm_installed()) return() | ||
protein_sequence <- | ||
"QEKNWSALLTAVVIILTIAGNILVIMAVSLEKKLQNATNYFLMSLAIADMLLGFLVMPVSMLTILYGYRWP" | ||
topology <- predict_topology_from_sequence( | ||
protein_sequence = protein_sequence | ||
) | ||
expect_equal( | ||
topology, | ||
"iiiiiiMMMMMMMMMMMMMMMMMMMMMMMooooooooooooooMMMMMMMMMMMMMMMMMMMMMMMiiiii" | ||
) | ||
expect_equal(nchar(protein_sequence), nchar(topology)) | ||
}) |