Skip to content

Commit

Permalink
speeds up add_peptide_positions by dropping Biostrings::match (#53)
Browse files Browse the repository at this point in the history
  • Loading branch information
TomSmithCGAT committed Jul 1, 2024
1 parent 2b92ec4 commit 197a446
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions R/ptm.R
Original file line number Diff line number Diff line change
Expand Up @@ -323,8 +323,10 @@ add_peptide_positions <- function(obj,
if (!protein %in% names(proteome)) {
return(c(NA, NA))
}
peptide_start <- Biostrings::start(Biostrings::matchPattern(sequence, proteome[[protein]]))
peptide_end <- Biostrings::end(Biostrings::matchPattern(sequence, proteome[[protein]]))

m <- gregexpr(sprintf('(?=(%s))', sequence), proteome[[protein]], perl=T)[[1]]
peptide_start <- attr(m,"capture.start")
peptide_end <- attr(m,"capture.start") + attr(m,"capture.length") - 1

if (length(peptide_start) != 1) {
return(c(NA, NA))
Expand All @@ -335,7 +337,6 @@ add_peptide_positions <- function(obj,
}
}


obj[, c('peptide_start', 'peptide_end')] <- t(apply(
obj,
MARGIN = 1, function(x) combine_protein_peptide_positions(
Expand Down

0 comments on commit 197a446

Please sign in to comment.