diff --git a/DESCRIPTION b/DESCRIPTION index 592c589..56eac0e 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -7,7 +7,7 @@ Description: The ability to efficiently represent and manipulate genomic intervals. Specialized containers for representing and manipulating short alignments against a reference genome are defined in the GenomicAlignments package. -Version: 1.19.26 +Version: 1.19.27 Author: P. Aboyoun, H. Pages and M. Lawrence Maintainer: Bioconductor Package Maintainer biocViews: Genetics, Infrastructure, Sequencing, Annotation, Coverage, diff --git a/R/transcript-utils.R b/R/transcript-utils.R index 7de0d0b..11df699 100644 --- a/R/transcript-utils.R +++ b/R/transcript-utils.R @@ -17,6 +17,7 @@ ### o 'strand' is assumed to be a character vector with allowed values ### "+" and "-" only; ### o 'decreasing.rank.on.minus.strand' is assumed to be TRUE or FALSE. +### o 'error.if.out.of.bounds' is assumed to be TRUE or FALSE. unsafe.transcriptWidths <- function(exonStarts, exonEnds) { @@ -29,12 +30,13 @@ unsafe.transcriptWidths <- function(exonStarts, exonEnds) ### not necessarily the "same shape") as 'exonStarts' and 'exonEnds'. unsafe.transcriptLocs2refLocs <- function(tlocs, exonStarts, exonEnds, strand, - decreasing.rank.on.minus.strand) + decreasing.rank.on.minus.strand, error.if.out.of.bounds) { .Call2("tlocs2rlocs", tlocs, exonStarts, exonEnds, strand, decreasing.rank.on.minus.strand, + error.if.out.of.bounds, PACKAGE="GenomicRanges") } diff --git a/src/R_init_GenomicRanges.c b/src/R_init_GenomicRanges.c index fbea228..416c472 100644 --- a/src/R_init_GenomicRanges.c +++ b/src/R_init_GenomicRanges.c @@ -7,7 +7,7 @@ static const R_CallMethodDef callMethods[] = { /* transcript_utils.c */ CALLMETHOD_DEF(transcript_widths, 2), - CALLMETHOD_DEF(tlocs2rlocs, 5), + CALLMETHOD_DEF(tlocs2rlocs, 6), {NULL, NULL, 0} }; diff --git a/src/transcript_utils.c b/src/transcript_utils.c index 0064a9b..b3da12d 100644 --- a/src/transcript_utils.c +++ b/src/transcript_utils.c @@ -154,14 +154,16 @@ SEXP transcript_widths(SEXP exonStarts, SEXP exonEnds) } SEXP tlocs2rlocs(SEXP tlocs, SEXP exonStarts, SEXP exonEnds, - SEXP strand, SEXP decreasing_rank_on_minus_strand) + SEXP strand, SEXP decreasing_rank_on_minus_strand, + SEXP error_if_out_of_bounds) { SEXP ans, starts, ends, ans_elt; - int decreasing_rank_on_minus_strand0, ans_length, + int decreasing_rank_on_minus_strand0, oob_error, ans_length, i, transcript_width, on_minus_strand, nlocs, j, tloc; decreasing_rank_on_minus_strand0 = LOGICAL(decreasing_rank_on_minus_strand)[0]; + oob_error = LOGICAL(error_if_out_of_bounds)[0]; ans_length = LENGTH(tlocs); PROTECT(ans = duplicate(tlocs)); for (i = 0; i < ans_length; i++) { @@ -191,11 +193,18 @@ SEXP tlocs2rlocs(SEXP tlocs, SEXP exonStarts, SEXP exonEnds, if (tloc == NA_INTEGER) continue; if (tloc < 1 || tloc > transcript_width) { - UNPROTECT(1); - error("'tlocs[[%d]]' contains \"out of limits\" " - "transcript locations (length of " - "transcript is %d)", j + 1, transcript_width); - } + if (oob_error) { + UNPROTECT(1); + error("'tlocs[[%d]]' contains " + "\"out of limits\" transcript " + "locations (length of " + "transcript is %d)", j + 1, + transcript_width); + } else { + INTEGER(ans_elt)[j] = NA_INTEGER; + break; + } + } INTEGER(ans_elt)[j] = tloc2rloc(tloc, starts, ends, on_minus_strand,