Skip to contents

Checks that every array carries all of its parts: position_in_array running contiguously from 1, and — when domain_type and position_in_crd are present — position_in_crd equal to position_in_array minus the number of non-repeat parts before it.

Usage

tales_assert_complete(x, arg = "x")

Arguments

x

A tales object.

arg

Name of the argument being checked, for the error message.

Value

x, invisibly.

Details

Completeness is a precondition of some functions; the class itself does not require it: filter(x, domain_type == "repeat") legitimately produces a valid tales that is no longer complete. Alignment requires completeness, because the mapping back from a MAFFT alignment is positional — the k-th aligned residue is the k-th part fed in.

Examples

rvd_fasta <- system.file("extdata", "TalA_RVDSeqs_AnnoTALE.fasta",
                         package = "tantale")
x <- as_tales(rvd_fasta, sep = "-")
tales_assert_complete(x) # every array is 1..n already -- no error

# Keeping only the repeats breaks completeness, which tales_align() needs.
repeats_only <- x[x$position_in_array > 1, ]
try(tales_assert_complete(repeats_only))
#> Error in tales_assert_complete(repeats_only) : 
#>   `x` must hold complete arrays.
#> ✖ position_in_array is not 1..n in "TalA_BAI3", "TalA_CFBP1947", "TalA_MAI1",
#>   "TalA_MAI106", and "TalA_MAI129".
#> ℹ Subsetting parts (e.g. keeping only repeats) breaks completeness.