~ubuntu-branches/ubuntu/wily/r-bioc-genomicranges/wily-proposed

« back to all changes in this revision

Viewing changes to inst/unitTests/test_findOverlaps-methods.R

  • Committer: Package Import Robot
  • Author(s): Andreas Tille
  • Date: 2014-06-13 15:04:19 UTC
  • mfrom: (1.1.2)
  • Revision ID: package-import@ubuntu.com-20140613150419-v49mxnlg42rnuks5
Tags: 1.16.3-1
* New upstream version
* New (Build-)Depends: r-bioc-genomeinfodb
* cme fix dpkg-control
* add autopkgtest

Show diffs side-by-side

added added

removed removed

Lines of Context:
400
400
                   subjectHits = unname(matchMatrix3[ , 2L]),
401
401
                   queryLength = 4L, subjectLength = 4L)
402
402
    checkIdentical(target3, current3)
 
403
 
 
404
    ## type = "within"
 
405
    q0 <- GRanges("A", IRanges(c(11, 5, 4, 11, 11, 4), 
 
406
                     c(30, 30, 30, 50, 51, 51)))
 
407
    s0 <- GRanges("A", IRanges(5, width=46))
 
408
    s0@seqinfo <- Seqinfo(seqnames="A", seqlengths=100, isCircular=TRUE)
 
409
    ## sanity check with linear shift 
 
410
    fo0 <- findOverlaps(q0, s0, type="within")
 
411
    expected <- c(1L, 2L, 4L)
 
412
    checkIdentical(queryHits(fo0), expected)
 
413
    A=90
 
414
    q1 <- shift(q0, A)
 
415
    s1 <- shift(s0, A)
 
416
    fo1 <- findOverlaps(q1, s1, type="within")
 
417
    checkIdentical(queryHits(fo1), expected)
 
418
    ## circular shift 
 
419
    n1=-1; n2=0
 
420
    q2 <- shift(q0, A + 100 * n1)
 
421
    s2 <- shift(s0, A + 100 * n2)
 
422
    fo1 <- findOverlaps(q1, s1, type="within")
 
423
    checkIdentical(queryHits(fo1), expected)
 
424
 
 
425
    ## With A of length 8 --> range 3 is within range 2 
 
426
    gr <- GRanges(seqnames=rep.int("A", 4),
 
427
                  ranges=IRanges(start=c(2, 4, 6, 8), width=c(3, 3, 3, 5)))
 
428
    gr@seqinfo <- Seqinfo(seqnames="A", seqlengths=8, isCircular=TRUE)
 
429
    current4 <- findOverlaps(gr, gr, type="within")
 
430
    matchMatrix4 <- matrix(c(1L, 1L, 2L, 3L, 4L, 
 
431
                             1L, 4L, 2L, 3L, 4L), ncol = 2,
 
432
                           dimnames = list(NULL, c("queryHits", "subjectHits")))
 
433
    target4 <- new("Hits",
 
434
                   queryHits = unname(matchMatrix4[ , 1L]),
 
435
                   subjectHits = unname(matchMatrix4[ , 2L]),
 
436
                   queryLength = 4L, subjectLength = 4L)
 
437
    checkIdentical(target4, current4)
 
438
    ## With A of length 9 --> range 3 is not within range 2 
 
439
    gr@seqinfo <- Seqinfo(seqnames="A", seqlengths=9, isCircular=TRUE)
 
440
    current5 <- findOverlaps(gr, gr, type="within")
 
441
    target5 <- new("Hits",
 
442
                   queryHits = unname(matchMatrix2[ , 1L]),
 
443
                   subjectHits = unname(matchMatrix2[ , 2L]),
 
444
                   queryLength = 4L, subjectLength = 4L)
 
445
    checkIdentical(target5, current5)
403
446
}
404