File: DB.R

package info (click to toggle)
r-bioc-cner 1.26.0%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 18,216 kB
  • sloc: ansic: 23,458; makefile: 6
file content (44 lines) | stat: -rw-r--r-- 1,392 bytes parent folder | download | duplicates (4)
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
### -----------------------------------------------------------------
### query the new CNEData data package
### Not exported!
#dbName = "/mnt/biggley/projects/gtan/projects/CNEr/CNErData/CNEData.sqlite"
#target = "equCab2"
#query = "canFam3"
#type = "all"
#winSize = 50
#identity = 49
#foo = queryCNEData(dbName, target, query, winSize, identity, type)

queryCNEData <- function(dbName, target, query, winSize, identity,
                         type=c("target", "all")
                         ){
  type <- match.arg(type)
  con <- dbConnect(SQLite(), dbname=dbName)
  on.exit(dbDisconnect(con))
  tableName <- ifelse(target < query, paste(target, query, sep="_"),
                      paste(query, target, sep="_"))
  tableName <- paste(tableName, identity, winSize, sep="_")
  if(type == "target"){
    if(target < query){
      sqlCmd <- "SELECT chr1, start1, end1"
    }else{
      sqlCmd <- "SELECT chr2, start2, end2"
    }
  #}else if(type == "query"){
  #  if(target < query){
  #    sqlCmd <- "SELECT chr2, start2, end2"
  #  }else{
  #    sqlCmd <- "SELECT chr1, start1, end1"
  #  }
  }else if(type == "all"){
    if(target < query){
      sqlCmd <- "SELECT chr1, start1, end1, chr2, start2, end2"
    }else{
      sqlCmd <- "SELECT chr2, start2, end2, chr1, start1, end1"
    }
  }
  sqlCmd <- paste(sqlCmd, "FROM", tableName)
  cne <- dbGetQuery(con, sqlCmd)
  return(cne)
}