Prints input sq
object in a
human-friendly form.
[sq
]
An object this function is applied to.
[integer(1)
]
How many sequences should be printed.
[logical(1)
]
Should sequences be colored?
[character(1)
]
How the letters should be separated.
[character(1)
]
A string that is used to interpret and display NA
value in the
context of sq class
. Default value equals to
"!
".
further arguments to be passed from or to other methods.
An object that was passed as the first argument to the function.
It is returned invisibly (equivalent of invisible(x)
)
print
method is often called implicitly by calling variable name.
Only explicit calling of this method allows its parameters to be changed.
Printed information consists of three parts:
First line is always a header that contains info about the type of sequences contained.
The next part is the content. Each sequence has its own line, but not
all sequences are printed. The number of printed sequences is limited by
parameter max_sequences
, defaulting to 10. These sequences are
printed with:
left-aligned index of sequence in square brackets (e.g. [3]
),
left-aligned sequence data (more about it in paragraph below),
right-aligned sequence length in angle brackets (e.g. <27>
).
Finally, if number of sequences is greater than max_sequences
,
then a footer is displayed with how many sequences are there and how many
were printed.
Each sequence data is printed as letters. If sequence is too long to fit in
one line, then only a subsequence is displayed - a subsequence that begins
from the first letter. Sequence printing is controlled by letters_sep
and NA_letter
parameters. The first one specifies a string that should
be inserted between any two letters. By default it's empty when all letters
are one character in length; and a space otherwise. NA_letter
dictates
how NA
values are displayed, by default it's an exclamation mark
("!
").
Most consoles support color printing, but when any of these do not, then the
user might use use_color
parameter set to FALSE
- or better
yet, change related option value, where said option is called
"tidysq_print_use_color"
.
Functions that display sequence info:
get_tidysq_options()
# Creating objects to work on:
sq_ami <- sq(c("MIAANYTWIL","TIAALGNIIYRAIE", "NYERTGHLI", "MAYXXXIALN"),
alphabet = "ami_ext")
sq_dna <- sq(c("ATGCAGGA", "GACCGNBAACGAN", "TGACGAGCTTA"),
alphabet = "dna_bsc")
sq_unt <- sq(c("ATGCAGGA?", "TGACGAGCTTA", "", "TIAALGNIIYRAIE"))
# Printing without explicit function calling with default parameters:
sq_ami
#> extended amino acid sequences list:
#> [1] MIAANYTWIL <10>
#> [2] TIAALGNIIYRAIE <14>
#> [3] NYERTGHLI <9>
#> [4] MAYXXXIALN <10>
sq_dna
#> basic DNA sequences list:
#> [1] ATGCAGGA <8>
#> [2] GACCG!!AACGA! <13>
#> [3] TGACGAGCTTA <11>
sq_unt
#> unt (unspecified type) sequences list:
#> [1] ATGCAGGA? <9>
#> [2] TGACGAGCTTA <11>
#> [3] <NULL> <0>
#> [4] TIAALGNIIYRAIE <14>
# Printing with explicit function calling and specific parameters:
print(sq_ami)
#> extended amino acid sequences list:
#> [1] MIAANYTWIL <10>
#> [2] TIAALGNIIYRAIE <14>
#> [3] NYERTGHLI <9>
#> [4] MAYXXXIALN <10>
print(sq_dna, max_sequences = 1, use_color = FALSE)
#> basic DNA sequences list:
#> [1] ATGCAGGA <8>
#> printed 1 out of 3
print(sq_unt, letters_sep = ":")
#> unt (unspecified type) sequences list:
#> [1] A:T:G:C:A:G:G:A:? <9>
#> [2] T:G:A:C:G:A:G:C:T:T:A <11>
#> [3] <NULL> <0>
#> [4] T:I:A:A:L:G:N:I:I:Y:R:A:I:E <14>