Skip to content

Commit 0d76e0d

Browse files
committed
account for edge case
1 parent 63eba6e commit 0d76e0d

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

R/clean_Spectronaut.R

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -183,7 +183,7 @@
183183
#' @keywords internal
184184
#' @noRd
185185
.assignSpectronautIsotopeLabelType = function(spec_input, heavyLabels) {
186-
IsotopeLabelType = PeptideSequence = NULL
186+
IsotopeLabelType = PeptideSequence = StrippedSequence = NULL
187187
if (is.null(heavyLabels)) {
188188
return(spec_input)
189189
}
@@ -196,16 +196,19 @@
196196
collapse = "|"
197197
)
198198

199+
spec_input[, StrippedSequence := gsub("\\[.*?\\]", "", PeptideSequence)]
200+
199201
spec_input[, IsotopeLabelType := data.table::fcase(
200202
grepl(heavy_brackets_escaped_pattern, PeptideSequence, perl = TRUE), "H",
201-
grepl(bare_amino_acids_pattern, PeptideSequence, perl = TRUE), "L",
203+
grepl(bare_amino_acids_pattern, StrippedSequence, perl = TRUE), "L",
202204
default = NA_character_
203205
)]
204206

207+
spec_input[, StrippedSequence := NULL]
208+
205209
for (i in seq_along(heavyLabels)) {
206210
escaped = gsub("([\\[\\]])", "\\\\\\1", heavyLabels[i], perl = TRUE)
207211
spec_input[, PeptideSequence := gsub(escaped, bare_amino_acids[i], PeptideSequence, perl = TRUE)]
208212
}
209-
210213
spec_input
211214
}

0 commit comments

Comments
 (0)