diff --git a/MutSiteFind.R b/MutSiteFind.R new file mode 100644 index 0000000..84354c8 --- /dev/null +++ b/MutSiteFind.R @@ -0,0 +1,31 @@ +# #<----------------------------> +# # Please include this section when distributing and/or using this code. +# # Please read and abide by the terms of the included LICENSE +# # +# # Author : Deepankar Chakroborty (https://gitlab.utu.fi/deecha) +# # Report issues: https://gitlab.utu.fi/deecha/shared_scripts/-/issues +# # License: https://gitlab.utu.fi/deecha/shared_scripts/-/blob/master/LICENSE +# # +# # PURPOSE: +# # For a given vector of amino acid changes like A123T, V256F, E746_A750del +# # this function returns c(123, 256, 746) as amino acid positions of +# # the mutated residue. +# # In case of indels, it doesn't return the range!! (returns only the start position) +# # +# #<----------------------------> + +dependencies <- c("stringi") +missing_packages <- dependencies[!(dependencies %in% installed.packages()[, "Package"])] +if(length(missing_packages)) install.packages(missing_packages) + +## ----- Legacy version relying on r::base -------- +MutSiteFind.legacy=function(MutationColumn){ + MutationSite=c() + for(i in seq(1:length(MutationColumn))){ + Site=regmatches(MutationColumn[i], gregexpr("[[:digit:]]+",MutationColumn[i]))[[1]][1] + MutationSite=c(MutationSite,Site) + } + return(MutationSite) +} + + diff --git a/unparalogMutations.R b/unparalogMutations.R index f34e540..9168357 100644 --- a/unparalogMutations.R +++ b/unparalogMutations.R @@ -1,6 +1,6 @@ # #<----------------------------> -# # Please include this when distributing and/or using this code. -# # I hope you will read and respect the terms of the included LICENSE +# # Please include this section when distributing and/or using this code. +# # Please read and abide by the terms of the included LICENSE # # # # Author : Deepankar Chakroborty (https://gitlab.utu.fi/deecha) # # Report issues: https://gitlab.utu.fi/deecha/shared_scripts/-/issues @@ -29,12 +29,12 @@ # <---------------> +# Installing missing dependencies +dependencies <- c("stringi", "progress") +missing_packages <- dependencies[!(dependencies %in% installed.packages()[, "Package"])] +if(length(missing_packages)) install.packages(missing_packages) + unparalog <- function(DATA, paralog_separator = ";", annotation_separator = ",", GeneColName , AnnotationColName ){ - # Installing missing dependencies - dependencies <- c("stringi", "progress") - missing_packages <- dependencies[!(dependencies %in% installed.packages()[, "Package"])] - if(length(missing_packages)) install.packages(missing_packages) - # Sanity checks check_paralog_sep <- !any(stringi::stri_detect_fixed(str = DATA$Gene.refGene,pattern = paralog_separator)) check_annotation_sep <- !any(stringi::stri_detect_fixed(str = DATA$AAChange.refGene, pattern = annotation_separator))