generate_complement: Generate complementary sequence

View source: R/generate_complement.R

generate_complementR Documentation

Generate complementary sequence

Description

Generate the complementary sequence of a nucleic acid sequence, with an option to reverse it.

Usage

generate_complement(input_seq, reverse = FALSE)

Arguments

input_seq

Input sequence(s) in 5' to 3' direction. Must be provided as either: - A character string (e.g., c("ATGCG", "GCTAG"))

reverse

Logical, controlling which of the two ways of writing the opposite strand is returned.

FALSE (default) gives the plain complement: base i of the result pairs with base i of the input, so written underneath the input it runs 3' to 5'. This is the form to_genomic_ranges expects for complement_seq, and the form its auto-generated complements take.

TRUE gives the reverse complement: the same strand written the conventional way round, 5' to 3'. It is what you would order from a supplier, and it is not what complement_seq wants – passing it there pairs every position against the wrong base.

  input                 5'-A T G C G-3'
  reverse = FALSE          T A C G C     (3' to 5', pairs position by position)
  reverse = TRUE        5'-C G C A T-3'  (the same strand, written 5' to 3')
  

Value

Returns the complementary sequence(s) in the specified direction.

Author(s)

Junhui Li

References

citation("TmCalculator")

Examples


# Plain complement: pairs position by position, reads 3' to 5'
generate_complement("ATGCG", reverse = FALSE)

# Reverse complement: the same strand written 5' to 3'
generate_complement("ATGCG", reverse = TRUE)


TmCalculator documentation built on Oct. 5, 2026, 5:08 p.m.