R/RcppExports.R

# Generated by using Rcpp::compileAttributes() -> do not edit by hand
# Generator token: 10BE3573-1514-4C36-9D1C-5A225CD40393

#' @title Randomly delete nucleotides in a sequence
#'
#' @description Pass in a vector of nucleotides, the probability of single
#' nucleotide deletions for each of the four nucleotides, and return a new
#' vector of nucleotides.
#'
#' @param nt_sequence A vector of nucleotides, i.e. c("C","A","T","G","A").
#' @param deletion_rate_A The probability of an "A" deletion occurring.
#' @param deletion_rate_T The probability of an "T" deletion occurring.
#' @param deletion_rate_C The probability of an "C" deletion occurring.
#' @param deletion_rate_G The probability of an "G" deletion occurring.
#'
#' @import Rcpp
#'
#' @return A vector of nucleotides, i.e. c("C","T","G","A"), with deleted
#' nucleotides omitted.
#'
#' @examples
#' set.seed(1)
#' .deletion_mutator(
#' c("C","A","T","G","A"),
#' deletion_rate_A = 0.05,
#' deletion_rate_T = 0.05,
#' deletion_rate_C = 0.05,
#' deletion_rate_G = 0.05
#' )
#'
#' @useDynLib evolution, .registration = TRUE
#'
.deletion_mutator_cpp <- function(nt_sequence, deletion_rate_A = 0.05, deletion_rate_T = 0.05, deletion_rate_C = 0.05, deletion_rate_G = 0.05) {
    .Call(`_evolution_deletion_mutator_cpp`, nt_sequence, deletion_rate_A, deletion_rate_T, deletion_rate_C, deletion_rate_G)
}

#' @title Find the first start codon in a sequence.
#'
#' @description This function will return the index in a vector of nucleotides
#' of the first start codon.
#'
#' @param nt_sequence A vector of nucleotides, i.e. c("C","A","T","G","A").
#'
#' @import Rcpp
#'
#' @return Start codon site or NA if not found.
#'
#' @examples
#' .find_start_codon(
#' c("A", "A", "T", "G", "C", "A", "A", "T", "C", "A", "T", "A", "G", "A")
#' )
#'
#' @useDynLib evolution, .registration = TRUE
#'
.find_start_codon_cpp <- function(nt_sequence) {
    .Call(`_evolution_find_start_codon_cpp`, nt_sequence)
}

#' @title Find the first in-frame stop codon
#'
#' @param nt_sequence A vector of nucleotides, i.e. c("A","T","G","A", ...) in
#' which the first codon is the start codon.
#'
#' @import Rcpp
#'
#' @return Index of the first in-frame stop codon (or NA if not found).
#'
#' @examples
#' .find_stop_codon(
#' c("A", "A", "T", "G", "C", "A", "A", "T", "C", "A", "T", "A", "G", "A")
#' )
#'
#' @useDynLib evolution, .registration = TRUE
#'
.find_stop_codon_cpp <- function(nt_sequence) {
    .Call(`_evolution_find_stop_codon_cpp`, nt_sequence)
}

#' Iterate through the nucleotides and randomly insert nucleotides.
#'
#' @details Pass in a vector of nucleotides, the probability of any given
#' nucleotide being inserted, and get back a vector with insertion mutations.
#'
#' @param nt_sequence A vector of nucleotides, i.e. c("C","A","T","G","A").
#' @param insertion_rate_A The probability of an "A" insertion occurring.
#' @param insertion_rate_T The probability of an "T" insertion occurring.
#' @param insertion_rate_C The probability of an "C" insertion occurring.
#' @param insertion_rate_G The probability of an "G" insertion occurring.
#'
#' @import Rcpp
#'
#' @return A vector of nucleotides, i.e. c("C","A","T","G","A"), with any
#' insertions made included.
#'
#' @examples
#' set.seed(1)
#' .insertion_mutator(
#' c("C","A","T","G","A"),
#' insertion_rate_A = 0.05,
#' insertion_rate_T = 0.05,
#' insertion_rate_C = 0.05,
#' insertion_rate_G = 0.05
#' )
#'
#' @export
#'
#' @useDynLib evolution, .registration = TRUE
#'
.insertion_mutator_cpp <- function(nt_sequence, insertion_rate_A = 0.05, insertion_rate_T = 0.05, insertion_rate_C = 0.05, insertion_rate_G = 0.05) {
    .Call(`_evolution_insertion_mutator_cpp`, nt_sequence, insertion_rate_A, insertion_rate_T, insertion_rate_C, insertion_rate_G)
}

#' Perform substitution mutations on a nucelotide sequence.
#'
#' @details Pass in a vector of nucleotides and the probability of each type of
#'  substitution mutation. Get back a mutated vector.
#'
#' @param nt_sequence A vector of nucleotides, i.e. c("C","A","T","G","A").
#' @param sub_rate_A_to_T The probability of an "A" becoming a "T".
#' @param sub_rate_A_to_C The probability of an "A" becoming a "C".
#' @param sub_rate_A_to_G The probability of an "A" becoming a "G".
#' @param sub_rate_T_to_A The probability of an "T" becoming a "A".
#' @param sub_rate_T_to_C The probability of an "T" becoming a "C".
#' @param sub_rate_T_to_G The probability of an "T" becoming a "G".
#' @param sub_rate_C_to_A The probability of an "C" becoming a "A".
#' @param sub_rate_C_to_T The probability of an "C" becoming a "T".
#' @param sub_rate_C_to_G The probability of an "C" becoming a "G".
#' @param sub_rate_G_to_A The probability of an "G" becoming a "A".
#' @param sub_rate_G_to_T The probability of an "G" becoming a "T".
#' @param sub_rate_G_to_C The probability of an "G" becoming a "C".
#'
#' @import Rcpp
#'
#' @return A vector of nucleotides, i.e. c("C","A","A","G","A"), with
#' subsitution mutations included.
#'
#' @examples
#' set.seed(1)
#' .substitution_mutator(
#' c("C","A","T","G","A")
#' )
#'
#' @useDynLib evolution, .registration = TRUE
#'
.substitution_mutator_cpp <- function(nt_sequence, sub_rate_A_to_T = 0.05, sub_rate_A_to_C = 0.05, sub_rate_A_to_G = 0.05, sub_rate_T_to_A = 0.05, sub_rate_T_to_C = 0.05, sub_rate_T_to_G = 0.05, sub_rate_C_to_A = 0.05, sub_rate_C_to_T = 0.05, sub_rate_C_to_G = 0.05, sub_rate_G_to_A = 0.05, sub_rate_G_to_T = 0.05, sub_rate_G_to_C = 0.05) {
    .Call(`_evolution_substitution_mutator_cpp`, nt_sequence, sub_rate_A_to_T, sub_rate_A_to_C, sub_rate_A_to_G, sub_rate_T_to_A, sub_rate_T_to_C, sub_rate_T_to_G, sub_rate_C_to_A, sub_rate_C_to_T, sub_rate_C_to_G, sub_rate_G_to_A, sub_rate_G_to_T, sub_rate_G_to_C)
}

#' @title Translate a DNA sequence into an amino acid sequence.
#'
#' @param nt_sequence An in-frame vector of nucleotides, i.e. c("A","T","G","T"
#' ,"A","G"). The first and last codons should be start and stop codons.
#' @param check_start_and_stop Logical indicating whether the first and last
#' codons need to be start and stop codons, respectively.
#'
#' @import Rcpp
#'
#' @return A vector of amino acids.
#'
#' @examples
#' .translate(
#' c("A","T","G","T","A","G")
#' )
#'
#' @useDynLib evolution, .registration = TRUE
#'
.translate_cpp <- function(nt_sequence, check_start_and_stop = TRUE) {
    .Call(`_evolution_translate_cpp`, nt_sequence, check_start_and_stop)
}
zcolburn/evolution documentation built on May 19, 2019, 1:48 a.m.