R/xcombr_interpret.R

Defines functions .xcombr_interpret .checkArgsInterpret

#' Identify cross-linked peptides from open modification searches.
#'
#'#' @include xlinkTbl.R

.xcombr_interpret <- function(PSMs,
                              xlSpecificity = NULL,
                              xlMass = NULL,
                              customSpecificity = NULL,) {

    # Define valid arg values --------------------------------------------------
    xlSpecificityValues <- c(xlinkTbl$name, "custom", NULL)

    # Check args ---------------------------------------------------------------
    .checkArgsInterpret(xlSpecificity,
                        xlMass,
                        customSpecificity,
                        # possible values for arguments:
                        xlSpecificityValues)

    # Find Candidate XL PSMs ---------------------------------------------------

    # Automatically determine xlMass --------------------------------------------
    # (uses distribution of precursor mass defects from candidate XL PSMs)
}




# Argument Checking
.checkArgsInterpret <- function(xlSpecificity,
                                xlMass,
                                customSpecificity,
                                xlSpecificityValues){
    # xlSpecificity
    if(!is.null(xlSpecificity)) {
        if(!is.character(xlSpecificity) |
           length(xlSpecificity) != 1) {
            stop("xlSpecificity must be a character vector of length 1 or NULL")
        } else if(!(tolower(xlSpecificity) %in% tolower(xlSpecificityValues))) {
            stop("Unrecognized xlSpecificity. Refer to xcombr_specificities() for options.")
        }
    }

    # xlMass
    if(!is.null(xlMass)) {
        if(length(xlMass) != 1 ||
           !is.numeric(minLength) ||
           minLength < 0) {
            stop("minLength must be a single positive integer value or NULL")
        }
    }

    #customSpecificity
    if(tolower(xlSpecificity == "custom")) {
        if(is.null(customSpecificity)) {
            stop("customSpecificity is required when xlSpecificity = 'custom'.")
        } else if(!is.character(customSpecificity) |
                  length(customSpecificity) != 2) {
            stop("customSpecificity must be a character vector of length 2.")
        }
    }
}
wfondrie/xcombr documentation built on May 7, 2019, 9:34 a.m.