Skip to content

Commit bf39e58

Browse files
authored
Add "DotBracket" seqtype as compatible "B" seqtype (#134)
1 parent 8bd40a5 commit bf39e58

File tree

1 file changed

+17
-11
lines changed

1 file changed

+17
-11
lines changed

R/seqtype.R

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -17,11 +17,16 @@
1717
### The seqtype() function returns the sequence type. For
1818
### example 'seqtype(AAString())' returns "AA".
1919
###
20-
### The ModString package by Felix Ernst introduces two additional sequence
20+
### The Modstrings package by Felix Ernst introduces two additional sequence
2121
### types, "ModDNA" and "ModRNA", that are treated as sequence type "B" by
2222
### compatible_seqtypes(), get_seqtype_conversion_lookup(), and
2323
### get_seqtype_switches_before_binary_op() below.
2424
###
25+
### The Structstrings package by Felix Ernst introduces one additional sequence
26+
### type, "DotBracket", which is treated as sequence type "B" by
27+
### compatible_seqtypes(), get_seqtype_conversion_lookup(), and
28+
### get_seqtype_switches_before_binary_op() below.
29+
###
2530
### Unless specified otherwise, things in this file are not exported.
2631

2732

@@ -103,18 +108,19 @@ xs_dec_lkup <- function(x)
103108
### determine those restrictions.
104109
###
105110

106-
### Note that sequence types "ModDNA" and "ModRNA" are treated as sequence
107-
### type "B" by compatible_seqtypes(), get_seqtype_conversion_lookup(), and
108-
### get_seqtype_switches_before_binary_op() below.
109-
.SUPPORTED_SEQTYPES <- c("B", "DNA", "RNA", "AA", "ModDNA", "ModRNA")
111+
### Note that sequence types "ModDNA", "ModRNA" and "DotBracket" are treated as
112+
### sequence type "B" by compatible_seqtypes(), get_seqtype_conversion_lookup(),
113+
### and get_seqtype_switches_before_binary_op() below.
114+
.SUPPORTED_SEQTYPES <- c("B", "DNA", "RNA", "AA", "ModDNA", "ModRNA",
115+
"DotBracket")
110116

111117
compatible_seqtypes <- function(seqtype1, seqtype2)
112118
{
113119
stopifnot(isSingleString(seqtype1), seqtype1 %in% .SUPPORTED_SEQTYPES,
114120
isSingleString(seqtype2), seqtype2 %in% .SUPPORTED_SEQTYPES)
115121
if (seqtype1 == seqtype2 ||
116-
seqtype1 %in% c("B", "ModDNA", "ModRNA") ||
117-
seqtype2 %in% c("B", "ModDNA", "ModRNA"))
122+
seqtype1 %in% c("B", "ModDNA", "ModRNA", "DotBracket") ||
123+
seqtype2 %in% c("B", "ModDNA", "ModRNA", "DotBracket"))
118124
return(TRUE)
119125
is_nucleo1 <- seqtype1 %in% c("DNA", "RNA")
120126
is_nucleo2 <- seqtype2 %in% c("DNA", "RNA")
@@ -127,9 +133,9 @@ get_seqtype_conversion_lookup <- function(from_seqtype, to_seqtype)
127133
if (!compatible_seqtypes(from_seqtype, to_seqtype))
128134
stop("incompatible sequence types \"",
129135
from_seqtype, "\" and \"", to_seqtype, "\"")
130-
if (from_seqtype %in% c("ModDNA", "ModRNA"))
136+
if (from_seqtype %in% c("ModDNA", "ModRNA", "DotBracket"))
131137
from_seqtype <- "B"
132-
if (to_seqtype %in% c("ModDNA", "ModRNA"))
138+
if (to_seqtype %in% c("ModDNA", "ModRNA", "DotBracket"))
133139
to_seqtype <- "B"
134140
if (from_seqtype == to_seqtype)
135141
return(NULL)
@@ -159,9 +165,9 @@ get_seqtype_conversion_lookup <- function(from_seqtype, to_seqtype)
159165
what_op, class1, class2)
160166
{
161167
stopifnot(isSingleString(seqtype1), isSingleString(seqtype2))
162-
if (seqtype1 %in% c("ModDNA", "ModRNA"))
168+
if (seqtype1 %in% c("ModDNA", "ModRNA", "DotBracket"))
163169
seqtype1 <- "B"
164-
if (seqtype2 %in% c("ModDNA", "ModRNA"))
170+
if (seqtype2 %in% c("ModDNA", "ModRNA", "DotBracket"))
165171
seqtype2 <- "B"
166172
if (seqtype1 == seqtype2)
167173
return(c(seqtype1, seqtype2))

0 commit comments

Comments
 (0)