Skip to content

Commit

Permalink
follow addition of 'error.if.out.of.bounds' arg in transcriptLocs2ref…
Browse files Browse the repository at this point in the history
…Locs()

git-svn-id: https://hedgehog.fhcrc.org/bioconductor/trunk/madman/Rpacks/GenomicRanges@97944 bc3139a8-67e5-0310-9ffc-ced21a209358
  • Loading branch information
v.obenchain committed Dec 31, 2014
1 parent 9e7bf11 commit 8daeb93
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 10 deletions.
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -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 <[email protected]>
biocViews: Genetics, Infrastructure, Sequencing, Annotation, Coverage,
Expand Down
4 changes: 3 additions & 1 deletion R/transcript-utils.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand All @@ -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")
}

2 changes: 1 addition & 1 deletion src/R_init_GenomicRanges.c
Original file line number Diff line number Diff line change
Expand Up @@ -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}
};
Expand Down
23 changes: 16 additions & 7 deletions src/transcript_utils.c
Original file line number Diff line number Diff line change
Expand Up @@ -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++) {
Expand Down Expand Up @@ -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,
Expand Down

0 comments on commit 8daeb93

Please sign in to comment.