File: test_intra-range-methods.R

package info (click to toggle)
r-bioc-genomicalignments 1.0.6-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 2,980 kB
  • ctags: 54
  • sloc: ansic: 1,493; makefile: 4; sh: 3
file content (47 lines) | stat: -rw-r--r-- 1,642 bytes parent folder | download | duplicates (5)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
.noGaps <- GAlignments(
    Rle(factor(c("chr1", "chr2", "chr1", "chr3")),
        c(1, 3, 2, 4)),
    pos=1:10, cigar=paste0(10:1, "M"),
    strand=Rle(strand(c("-", "+", "*", "+", "-")),
        c(1, 2, 2, 3, 2)),
    names=head(letters, 10), score=1:10)
.Gaps <- GAlignments(
    Rle(factor(c("chr2", "chr4")), c(3, 4)), pos=1:7,
    cigar=c("5M", "3M2N3M2N3M", "5M", "10M", "5M1N4M", "8M2N1M", "5M"),
    strand=Rle(strand(c("-", "+")), c(4, 3)),
    names=tail(letters, 7), score=1:7)

test_GAlignments_qnarrow <- function()
{
    gal <- GAlignments(seqnames=rep(factor("A"), 8),
                       pos=10:17,
                       cigar=c("5M", "5X", "3M2I3M", "3M2D3M",
                               "3M2N3M", "3M2S3M", "3M2H3M", "3M2P3M"),
                       strand=Rle(strand(rep("+", 8))))
    n1 <- narrow(gal, start=3)
    q1 <- qnarrow(gal, start=3)
    checkIdentical(qwidth(n1), qwidth(q1))
    checkIdentical(width(n1), width(q1))

    n2 <- narrow(gal, start=4)
    q2 <- qnarrow(gal, start=4)
    checkIdentical(width(n2), width(q2))
    ## M and X 
    checkIdentical(qwidth(n2[1:2]), qwidth(q2[1:2]))
    ## I 
    checkIdentical(qwidth(q2[3]), width(q2[3]) + 2L)
    ## D, N and P
    checkIdentical(qwidth(q2[c(4,5,8)]), width(q2[c(4,5,8)]))
    ## S and H
    checkIdentical(qwidth(q2[6]), width(q2[6]) + 2L)
    checkIdentical(qwidth(q2[7]), width(q2[7]))
}

test_GAlignmentsList_qnarrow <- function()
{
    galist <- GAlignmentsList(.noGaps[1:6], .Gaps)
    qn <- qnarrow(galist, end=-4)
    checkIdentical(qnarrow(galist[[1]], end=-4), qn[[1]])
    checkIdentical(qnarrow(galist[[2]], end=-4), qn[[2]])
}