Creates the complementary sequence from a given RNA or DNA sequence. The function keeps the type of sequence intact.

complement(x, ...)

# S3 method for sq_dna_bsc
complement(x, ..., NA_letter = getOption("tidysq_NA_letter"))

# S3 method for sq_dna_ext
complement(x, ..., NA_letter = getOption("tidysq_NA_letter"))

# S3 method for sq_rna_bsc
complement(x, ..., NA_letter = getOption("tidysq_NA_letter"))

# S3 method for sq_rna_ext
complement(x, ..., NA_letter = getOption("tidysq_NA_letter"))

Arguments

x

[sq_dna_bsc || sq_rna_bsc || sq_dna_ext || sq_rna_ext]
An object this function is applied to.

...

further arguments to be passed from or to other methods.

NA_letter

[character(1)]
A string that is used to interpret and display NA value in the context of sq class. Default value equals to "!".

Value

sq object of the same type as input but built of nucleotides complementary to those in the entered sequences.

Details

This function matches elements of sequence to their complementary letters. For unambiguous letters, "C" is matched with "G" and "A" is matched with either "T" (thymine) or "U" (uracil), depending on whether input is of dna or rna type.

Ambiguous letters are matched as well, for example "N" (any nucleotide) is matched with itself, while "B" (not alanine) is matched with "V" (not thymine/uracil).

See also

sq

Functions interpreting sq in biological context: %has%(), find_motifs(), translate()

Examples

# Creating DNA and RNA sequences to work on:
sq_dna <- sq(c("ACTGCTG", "CTTAGA", "CCCT", "CTGAATGT"),
             alphabet = "dna_bsc")
sq_rna <- sq(c("BRAUDUG", "URKKBKUCA", "ANKRUGBNNG", "YYAUNAAAG"),
             alphabet = "rna_ext")

# Here complement() function is used to make PCR (Polymerase Chain Reaction)
# primers. Every sequence is rewritten to its complementary equivalent as
# in the following example: AAATTTGGG -> TTTAAACCC.

complement(sq_dna)
#> basic DNA sequences list:
#> [1] TGACGAC                                                                  <7>
#> [2] GAATCT                                                                   <6>
#> [3] GGGA                                                                     <4>
#> [4] GACTTACA                                                                 <8>
complement(sq_rna)
#> extended RNA sequences list:
#> [1] VYUAHAC                                                                  <7>
#> [2] AYMMVMAGU                                                                <9>
#> [3] UNMYACVNNC                                                              <10>
#> [4] RRUANUUUC                                                                <9>

# Each sequence have now a complementary equivalent, which can be helpful
# during constructing PCR primers.