├── R ├── 00RTobjs.R ├── methods-SQLiteConnection.R ├── test_AnnotationDbi_package.R ├── print.probetable.R ├── FlatBimap.R ├── makeMap.R ├── unlist2.R ├── utils.R ├── createAnnObjs.KEGG_DB.R ├── methods-OrthologyDb.R ├── AnnDbPkg-templates-common.R ├── createAnnObjs.MALARIA_DB.R ├── methods-AnnotationDb.R ├── flatten.R └── AllGenerics.R ├── vignettes └── databaseTypes.pdf ├── inst ├── extdata │ ├── resultTable.Rda │ ├── HG-U95Av2_probe_tab.gz │ ├── manyToOneBlackList.Rda │ └── org.testing.db │ │ ├── inst │ │ └── extdata │ │ │ └── org.testing.sqlite │ │ ├── NAMESPACE │ │ ├── DESCRIPTION │ │ ├── man │ │ ├── org.TguttataTestingSubset.egORGANISM.Rd │ │ ├── org.TguttataTestingSubset.egBASE.Rd │ │ └── org.TguttataTestingSubset.eg_dbconn.Rd │ │ └── R │ │ └── zzz.R ├── TODO ├── unitTests │ ├── test_geneCentricDbs.R │ ├── test_mapIds.R │ ├── test_select_reactome.R │ └── test_select_NOSCHEMA.R ├── DBschemas │ ├── schemas_0.9 │ │ ├── 00README.TXT │ │ ├── KEGG_DB.sql │ │ └── YEASTCHIP_DB.sql │ ├── schemas_2.0 │ │ ├── ARABIDOPSISCHIP_DB.sql │ │ ├── YEASTCHIP_DB.sql │ │ ├── 00README.TXT │ │ ├── BOVINECHIP_DB.sql │ │ ├── CANINECHIP_DB.sql │ │ ├── CHICKENCHIP_DB.sql │ │ ├── FLYCHIP_DB.sql │ │ ├── HUMANCHIP_DB.sql │ │ ├── MOUSECHIP_DB.sql │ │ ├── RATCHIP_DB.sql │ │ ├── WORMCHIP_DB.sql │ │ ├── XENOPUSCHIP_DB.sql │ │ ├── ZEBRAFISHCHIP_DB.sql │ │ ├── KEGG_DB.sql │ │ ├── PFAM_DB.sql │ │ ├── MALARIA_DB.sql │ │ └── ECOLI_DB.sql │ ├── schemas_2.1 │ │ ├── ARABIDOPSISCHIP_DB.sql │ │ ├── YEASTCHIP_DB.sql │ │ ├── 00README.TXT │ │ ├── BOVINECHIP_DB.sql │ │ ├── CANINECHIP_DB.sql │ │ ├── CHICKENCHIP_DB.sql │ │ ├── FLYCHIP_DB.sql │ │ ├── HUMANCHIP_DB.sql │ │ ├── MOUSECHIP_DB.sql │ │ ├── RATCHIP_DB.sql │ │ ├── WORMCHIP_DB.sql │ │ ├── XENOPUSCHIP_DB.sql │ │ ├── ZEBRAFISHCHIP_DB.sql │ │ ├── KEGG_DB.sql │ │ ├── PFAM_DB.sql │ │ ├── COELICOLOR_DB.sql │ │ ├── MALARIA_DB.sql │ │ └── ECOLI_DB.sql │ ├── schemas_1.0 │ │ ├── KEGG_DB.sql │ │ ├── 00README.TXT │ │ ├── MALARIA_DB.sql │ │ ├── PIG_DB.sql │ │ ├── CANINE_DB.sql │ │ ├── PIGCHIP_DB.sql │ │ ├── CANINECHIP_DB.sql │ │ ├── PFAM_DB.sql │ │ ├── ECOLI_DB.sql │ │ ├── ECOLICHIP_DB.sql │ │ ├── YEASTCHIP_DB.sql │ │ └── GO_DB.sql │ └── SchemaGuidelines.txt └── NOTES-Herve ├── tests └── AnnotationDbi_unit_tests.R ├── README.md ├── man ├── organismKEGGFrame.Rd ├── AnnDbPkg-checker.Rd ├── makeGOGraph.Rd ├── make_eg_to_go_map.Rd ├── orgPackageName.Rd ├── print.probetable.Rd ├── AnnotationDbi-internals.Rd ├── toSQLStringSet.Rd ├── BimapFormatting.Rd ├── KEGGFrame.Rd ├── GOColsAndKeytypes.Rd ├── unlist2.Rd ├── GOFrame.Rd ├── createSimpleBimap.Rd ├── Bimap-envirAPI.Rd ├── BimapFiltering.Rd ├── GOTerms-class.Rd └── Bimap-keys.Rd ├── DESCRIPTION └── NAMESPACE /R/00RTobjs.R: -------------------------------------------------------------------------------- 1 | ### Environment for storing run-time objects 2 | RTobjs <- new.env(hash=TRUE, parent=emptyenv()) 3 | 4 | -------------------------------------------------------------------------------- /vignettes/databaseTypes.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bioconductor/AnnotationDbi/devel/vignettes/databaseTypes.pdf -------------------------------------------------------------------------------- /inst/extdata/resultTable.Rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bioconductor/AnnotationDbi/devel/inst/extdata/resultTable.Rda -------------------------------------------------------------------------------- /inst/extdata/HG-U95Av2_probe_tab.gz: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bioconductor/AnnotationDbi/devel/inst/extdata/HG-U95Av2_probe_tab.gz -------------------------------------------------------------------------------- /inst/extdata/manyToOneBlackList.Rda: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bioconductor/AnnotationDbi/devel/inst/extdata/manyToOneBlackList.Rda -------------------------------------------------------------------------------- /tests/AnnotationDbi_unit_tests.R: -------------------------------------------------------------------------------- 1 | require("AnnotationDbi") || stop("unable to load AnnotationDbi package") 2 | 3 | AnnotationDbi:::.test() 4 | -------------------------------------------------------------------------------- /R/methods-SQLiteConnection.R: -------------------------------------------------------------------------------- 1 | setMethod("dbconn", "SQLiteConnection", function(x) x) 2 | 3 | setMethod("dbfile", "SQLiteConnection", function(x) x@dbname) 4 | -------------------------------------------------------------------------------- /inst/extdata/org.testing.db/inst/extdata/org.testing.sqlite: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/Bioconductor/AnnotationDbi/devel/inst/extdata/org.testing.db/inst/extdata/org.testing.sqlite -------------------------------------------------------------------------------- /R/test_AnnotationDbi_package.R: -------------------------------------------------------------------------------- 1 | ## if(!suppressWarnings(library('org.testing.db',logical.return=TRUE))){ 2 | ## install.packages(system.file('extdata','org.testing.db', package='AnnotationDbi'), repos=NULL) 3 | ## } 4 | 5 | .test <- function() BiocGenerics:::testPackage("AnnotationDbi") 6 | -------------------------------------------------------------------------------- /R/print.probetable.R: -------------------------------------------------------------------------------- 1 | print.probetable = function(x, maxrows = 3, ...) { 2 | nr = nrow(x) 3 | np = min(nr, maxrows) 4 | cat("Object of class", class(x), "with", nr, "rows and", ncol(x), "columns.\n") 5 | if(nr>maxrows) cat("First", np, "rows are:\n") 6 | print.data.frame(x[seq_len(np), ]) 7 | } 8 | -------------------------------------------------------------------------------- /inst/extdata/org.testing.db/NAMESPACE: -------------------------------------------------------------------------------- 1 | import(methods) 2 | import(AnnotationDbi) 3 | 4 | ### Only put what is statically exported here. All the AnnObj instances 5 | ### created at load time are dynamically exported (refer to R/zzz.R for 6 | ### the details). 7 | export( 8 | org.testing, 9 | org.testing_dbconn, 10 | org.testing_dbfile, 11 | org.testing_dbschema, 12 | org.testing_dbInfo, 13 | 14 | org.testingORGANISM 15 | ) 16 | 17 | -------------------------------------------------------------------------------- /inst/TODO: -------------------------------------------------------------------------------- 1 | Some TODOs: 2 | 3 | 1) (from Marc) 4 | 5 | Add a function to the templates for all the classes to make the 6 | datacache available do this before we push out new devel packages in 7 | January. So near to where you see: 8 | @ANNOBJPREFIX@_dbInfo <- function() dbInfo(datacache) 9 | Add something that will produce: 10 | hgu95av2_datacache(), once it has been called. 11 | 12 | 2) Defunct CHR* family and PFAM and PROSITE. Coordinate with AnnotationForge. 13 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | [](https://bioconductor.org/) 2 | 3 | **AnnotationDbi** is an R/Bioconductor package that implements a user-friendly interface for querying SQLite-based annotation data packages. 4 | 5 | See https://bioconductor.org/packages/AnnotationDbi for more information including how to install the release version of the package (please refrain from installing directly from GitHub). 6 | 7 | -------------------------------------------------------------------------------- /man/organismKEGGFrame.Rd: -------------------------------------------------------------------------------- 1 | \name{organismKEGGFrame} 2 | \alias{organismKEGGFrame} 3 | \alias{organismKEGGFrame} 4 | 5 | \title{A data frame that maps species names to KEGG organisms} 6 | \description{ 7 | Create a data.frame that maps a species name (e.g. Homo sapeins) to the 8 | KEGG organsim notation (e.g. hsa). 9 | } 10 | \usage{ 11 | organismKEGGFrame() 12 | } 13 | 14 | \value{ 15 | A data.frame with 2 columns, species and organsim. 16 | } 17 | \author{Kayla Interdonato} 18 | \examples{ 19 | query <- organismKEGGFrame() 20 | head(query) 21 | } 22 | -------------------------------------------------------------------------------- /inst/unitTests/test_geneCentricDbs.R: -------------------------------------------------------------------------------- 1 | test_getOrgPkg_load_only <- function() { 2 | ## check that map between chip and org package works with loaded 3 | ## but not attached org package 4 | if ("package:org.Hs.eg.db" %in% search()) { 5 | detach("package:org.Hs.eg.db") 6 | on.exit(attachNamespace("org.Hs.eg.db")) 7 | } 8 | pkg <- "hgu95av2.db" 9 | env <- loadNamespace(pkg) 10 | db <- get(pkg, env) 11 | keys <- head(AnnotationDbi::keys(db)) 12 | df <- AnnotationDbi::select(db, keys, "SYMBOL") 13 | checkIdentical(c(6L, 2L), dim(df)) 14 | } 15 | -------------------------------------------------------------------------------- /inst/extdata/org.testing.db/DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: org.testing.db 2 | Title: Genome wide annotation for Taeniopygia guttataTestingSubset 3 | Description: Genome wide annotation for Taeniopygia guttataTestingSubset, primarily based on mapping using Entrez Gene identifiers. 4 | Version: 0.1 5 | Author: Some One 6 | Maintainer: Some One 7 | Depends: R (>= 2.7.0), methods, AnnotationDbi (>= 1.23.23) 8 | Suggests: annotate, RUnit 9 | Imports: methods, AnnotationDbi 10 | License: Artistic-2.0 11 | organism: Taeniopygia guttataTestingSubset 12 | species: Taeniopygia guttataTestingSubset 13 | biocViews: OrgDb, annotation 14 | 15 | -------------------------------------------------------------------------------- /man/AnnDbPkg-checker.Rd: -------------------------------------------------------------------------------- 1 | \name{AnnDbPkg-checker} 2 | 3 | \alias{AnnDbPkg-checker} 4 | 5 | \alias{checkMAPCOUNTS} 6 | 7 | 8 | \title{Check the SQL data contained in an SQLite-based annotation package} 9 | 10 | \description{ 11 | Check the SQL data contained in an SQLite-based annotation package. 12 | } 13 | 14 | \usage{ 15 | checkMAPCOUNTS(pkgname) 16 | } 17 | 18 | \arguments{ 19 | \item{pkgname}{ 20 | The name of the SQLite-based annotation package to check. 21 | } 22 | } 23 | 24 | 25 | \author{H. Pagès} 26 | 27 | \seealso{ 28 | \code{\link[AnnotationForge:AnnDbPkg-maker]{AnnDbPkg-maker}} 29 | } 30 | 31 | \examples{ 32 | checkMAPCOUNTS("org.Sc.sgd.db") 33 | } 34 | 35 | \keyword{utilities} 36 | -------------------------------------------------------------------------------- /inst/extdata/org.testing.db/man/org.TguttataTestingSubset.egORGANISM.Rd: -------------------------------------------------------------------------------- 1 | \name{org.TguttataTestingSubset.egORGANISM} 2 | \alias{org.TguttataTestingSubset.egORGANISM} 3 | \title{The Organism for org.TguttataTestingSubset.eg} 4 | \description{ 5 | org.TguttataTestingSubset.egORGANISM is an R object that contains a single item: a 6 | character string that names the organism for which org.TguttataTestingSubset.eg was built. 7 | } 8 | \details{ 9 | Although the package name is suggestive of the organism for which it 10 | was built, org.TguttataTestingSubset.egORGANISM provides a simple way to programmatically 11 | extract the organism name. 12 | } 13 | \examples{ 14 | org.TguttataTestingSubset.egORGANISM 15 | } 16 | \keyword{datasets} 17 | 18 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_0.9/00README.TXT: -------------------------------------------------------------------------------- 1 | This directory contains version 0.9 of the full set of schemas used in the 2 | sqlite-based annotation data packages. 3 | 4 | Version 0.9 is our target for the BioC 2.1 release i.e. it is the version 5 | that we plan to use in the data packages that will be released with 6 | Bioconductor 2.1 (AnnotationDbi 1.0.0). 7 | 8 | Version 0.9 has been successfully tested (i.e. imported) with SQLite 9 | (3.4.1), MySQL+InnoDB (5.0.26) and PostgreSQL (8.1.9) on a 64-bit openSUSE 10 | 10.2 system. It has not been tested on Oracle yet. 11 | 12 | All the *.sqlite files using one of the 0.9 schemas must set DBSCHEMAVERSION 13 | to 0.9 in their "metadata" table. 14 | 15 | See the DataTypes.txt file for all the data types used across the 0.9 schemas. 16 | 17 | -------------------------------------------------------------------------------- /man/makeGOGraph.Rd: -------------------------------------------------------------------------------- 1 | \name{makeGOGraph} 2 | 3 | \alias{makeGOGraph} 4 | 5 | \title{A convenience function to generate graphs based on the GO.db package} 6 | 7 | \description{ 8 | WARNING: \code{AnnotationDbi::makeGOGraph} is deprecated! 9 | 10 | \code{makeGOGraph} is a function to quickly convert any of the three Gene 11 | Ontologies in GO.db into a graphNEL object where each edge is given a 12 | weight of 1. 13 | } 14 | 15 | \usage{ 16 | makeGOGraph(ont = c("bp","mf","cc")) 17 | } 18 | 19 | \arguments{ 20 | \item{ont}{Specifies the ontology: "cc", "bp" or "mf".} 21 | } 22 | 23 | \author{Marc Carlson} 24 | 25 | \seealso{ 26 | \code{\link{GOTerms}} 27 | } 28 | 29 | \examples{ 30 | \dontrun{ 31 | ## makes a GO graph from the CC ontology 32 | f <- makeGOGraph("cc") 33 | } 34 | } 35 | 36 | \keyword{utilities} 37 | \keyword{manip} 38 | 39 | -------------------------------------------------------------------------------- /man/make_eg_to_go_map.Rd: -------------------------------------------------------------------------------- 1 | \name{make_eg_to_go_map} 2 | \alias{make_eg_to_go_map} 3 | \alias{make_go_to_eg_map} 4 | 5 | \title{Create GO to Entrez Gene maps for chip-based packages} 6 | \description{ 7 | Create a new map object mapping Entrez ID to GO (or vice versa) given 8 | a chip annotation data package. 9 | 10 | This is a temporary solution until a more general pluggable map 11 | solution comes online. 12 | } 13 | \usage{ 14 | make_eg_to_go_map(chip) 15 | } 16 | 17 | \arguments{ 18 | \item{chip}{The name of the annotation data package.} 19 | } 20 | 21 | \value{ 22 | Either a \code{Go3AnnDbMap} or a \code{RevGo3AnnDbMap}. 23 | } 24 | \author{Seth Falcon and Hervé Pagès} 25 | \examples{ 26 | library("hgu95av2.db") 27 | 28 | eg2go = make_eg_to_go_map("hgu95av2.db") 29 | sample(eg2go, 2) 30 | 31 | go2eg = make_go_to_eg_map("hgu95av2.db") 32 | sample(go2eg, 2) 33 | 34 | } 35 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.0/ARABIDOPSISCHIP_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 13 | CREATE TABLE probes (probe_id VARCHAR(80) NOT NULL, is_multiple SMALLINT NOT NULL, gene_id VARCHAR(10) NULL); 14 | 15 | -- Explicit index creation on the referencing column of all the foreign keys. 16 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 17 | -- indexes automatically. 18 | CREATE INDEX Fprobes ON probes (probe_id); 19 | CREATE INDEX Fgenes ON probes (gene_id); 20 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.1/ARABIDOPSISCHIP_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 13 | CREATE TABLE probes (probe_id VARCHAR(80) NOT NULL, is_multiple SMALLINT NOT NULL, gene_id VARCHAR(10) NULL); 14 | 15 | -- Explicit index creation on the referencing column of all the foreign keys. 16 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 17 | -- indexes automatically. 18 | CREATE INDEX Fprobes ON probes (probe_id); 19 | CREATE INDEX Fgenes ON probes (gene_id); 20 | -------------------------------------------------------------------------------- /man/orgPackageName.Rd: -------------------------------------------------------------------------------- 1 | \name{orgPackageName} 2 | 3 | \alias{orgPackageName} 4 | 5 | \title{Org package contained in annotation object} 6 | 7 | \description{ 8 | Get the name of the org package used by an annotation resource object. 9 | 10 | NOTE: This man page is for the \code{orgPackageName} \emph{S4 generic 11 | function} defined in the \pkg{AnnotationDbi} package. 12 | Bioconductor packages can define specific methods for annotation 13 | objects not supported by the default method. 14 | } 15 | 16 | \usage{ 17 | orgPackageName(x, ...) 18 | } 19 | 20 | \arguments{ 21 | \item{x}{ 22 | An annotation resource object. 23 | } 24 | \item{...}{ 25 | Additional arguments. 26 | } 27 | } 28 | 29 | \value{ 30 | A \code{character(1)} vector indicating the org package name. 31 | 32 | Specific methods defined in Bioconductor packages should 33 | behave as consistently as possible with the default method. 34 | } 35 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.0/YEASTCHIP_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 13 | CREATE TABLE probes (probe_id VARCHAR(80), systematic_name VARCHAR(14) NULL, gene_name VARCHAR(14) NULL, sgd_id CHAR(10) NULL, is_multiple SMALLINT NOT NULL); 14 | 15 | -- Explicit index creation on the referencing column of all the foreign keys. 16 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 17 | -- indexes automatically. 18 | CREATE INDEX Fprobes ON probes (probe_id); 19 | CREATE INDEX Fgenes ON probes (systematic_name); 20 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.1/YEASTCHIP_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 13 | CREATE TABLE probes (probe_id VARCHAR(80), systematic_name VARCHAR(14) NULL, gene_name VARCHAR(14) NULL, sgd_id CHAR(10) NULL, is_multiple SMALLINT NOT NULL); 14 | 15 | -- Explicit index creation on the referencing column of all the foreign keys. 16 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 17 | -- indexes automatically. 18 | CREATE INDEX Fprobes ON probes (probe_id); 19 | CREATE INDEX Fgenes ON probes (systematic_name); 20 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.0/00README.TXT: -------------------------------------------------------------------------------- 1 | This directory contains version 2.0 of the full set of schemas used in the 2 | sqlite-based annotation data packages. 3 | 4 | Version 2.0 is our target for the BioC 2.5 release. 5 | 6 | All the *.sqlite files using one of the 2.0 schemas must set DBSCHEMAVERSION 7 | to 2.0 in their "metadata" table. 8 | 9 | See the DataTypes.txt file for all the data types used across the 2.0 schemas. 10 | 11 | 12 | SUMMARY OF CHANGES SINCE VERSION 1.0 13 | ------------------------------------ 14 | 15 | Note that some of these changes are disruptive (i.e. they potentially break the 16 | SQL queries written for version 1.0). 17 | 18 | All probe-based schemas: 19 | 20 | o dropped all tables except the following: genbank, map_counts, map_metadata, metadata, probes 21 | o _id in the probes table is now replaced by a gene_id which is a foreign key to a matching org package 22 | o accessions table has been added to hold accessions associated with probes by the manufacturer 23 | 24 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.1/00README.TXT: -------------------------------------------------------------------------------- 1 | This directory contains version 2.0 of the full set of schemas used in the 2 | sqlite-based annotation data packages. 3 | 4 | Version 2.0 is our target for the BioC 2.5 release. 5 | 6 | All the *.sqlite files using one of the 2.0 schemas must set DBSCHEMAVERSION 7 | to 2.0 in their "metadata" table. 8 | 9 | See the DataTypes.txt file for all the data types used across the 2.0 schemas. 10 | 11 | 12 | SUMMARY OF CHANGES SINCE VERSION 1.0 13 | ------------------------------------ 14 | 15 | Note that some of these changes are disruptive (i.e. they potentially break the 16 | SQL queries written for version 1.0). 17 | 18 | All probe-based schemas: 19 | 20 | o dropped all tables except the following: genbank, map_counts, map_metadata, metadata, probes 21 | o _id in the probes table is now replaced by a gene_id which is a foreign key to a matching org package 22 | o accessions table has been added to hold accessions associated with probes by the manufacturer 23 | 24 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.0/BOVINECHIP_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 13 | CREATE TABLE accessions (probe_id VARCHAR(80),accession VARCHAR(20)); 14 | CREATE TABLE probes (probe_id VARCHAR(80), gene_id VARCHAR(10) NULL, is_multiple SMALLINT NOT NULL); 15 | 16 | -- Explicit index creation on the referencing column of all the foreign keys. 17 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 18 | -- indexes automatically. 19 | CREATE INDEX Fgbprobes ON accessions (probe_id); 20 | CREATE INDEX Fprobes ON probes (probe_id); 21 | CREATE INDEX Fgenes ON probes (gene_id); 22 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.0/CANINECHIP_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 13 | CREATE TABLE accessions (probe_id VARCHAR(80),accession VARCHAR(20)); 14 | CREATE TABLE probes (probe_id VARCHAR(80), gene_id VARCHAR(10) NULL, is_multiple SMALLINT NOT NULL); 15 | 16 | -- Explicit index creation on the referencing column of all the foreign keys. 17 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 18 | -- indexes automatically. 19 | CREATE INDEX Fgbprobes ON accessions (probe_id); 20 | CREATE INDEX Fprobes ON probes (probe_id); 21 | CREATE INDEX Fgenes ON probes (gene_id); 22 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.0/CHICKENCHIP_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 13 | CREATE TABLE accessions (probe_id VARCHAR(80),accession VARCHAR(20)); 14 | CREATE TABLE probes (probe_id VARCHAR(80), gene_id VARCHAR(10) NULL, is_multiple SMALLINT NOT NULL); 15 | 16 | -- Explicit index creation on the referencing column of all the foreign keys. 17 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 18 | -- indexes automatically. 19 | CREATE INDEX Fgbprobes ON accessions (probe_id); 20 | CREATE INDEX Fprobes ON probes (probe_id); 21 | CREATE INDEX Fgenes ON probes (gene_id); 22 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.0/FLYCHIP_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 13 | CREATE TABLE accessions (probe_id VARCHAR(80),accession VARCHAR(20)); 14 | CREATE TABLE probes (probe_id VARCHAR(80), gene_id VARCHAR(10) NULL, is_multiple SMALLINT NOT NULL); 15 | 16 | -- Explicit index creation on the referencing column of all the foreign keys. 17 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 18 | -- indexes automatically. 19 | CREATE INDEX Fgbprobes ON accessions (probe_id); 20 | CREATE INDEX Fprobes ON probes (probe_id); 21 | CREATE INDEX Fgenes ON probes (gene_id); 22 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.0/HUMANCHIP_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 13 | CREATE TABLE accessions (probe_id VARCHAR(80),accession VARCHAR(20)); 14 | CREATE TABLE probes (probe_id VARCHAR(80), gene_id VARCHAR(10) NULL, is_multiple SMALLINT NOT NULL); 15 | 16 | -- Explicit index creation on the referencing column of all the foreign keys. 17 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 18 | -- indexes automatically. 19 | CREATE INDEX Fgbprobes ON accessions (probe_id); 20 | CREATE INDEX Fprobes ON probes (probe_id); 21 | CREATE INDEX Fgenes ON probes (gene_id); 22 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.0/MOUSECHIP_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 13 | CREATE TABLE accessions (probe_id VARCHAR(80),accession VARCHAR(20)); 14 | CREATE TABLE probes (probe_id VARCHAR(80), gene_id VARCHAR(10) NULL, is_multiple SMALLINT NOT NULL); 15 | 16 | -- Explicit index creation on the referencing column of all the foreign keys. 17 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 18 | -- indexes automatically. 19 | CREATE INDEX Fgbprobes ON accessions (probe_id); 20 | CREATE INDEX Fprobes ON probes (probe_id); 21 | CREATE INDEX Fgenes ON probes (gene_id); 22 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.0/RATCHIP_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 13 | CREATE TABLE accessions (probe_id VARCHAR(80),accession VARCHAR(20)); 14 | CREATE TABLE probes (probe_id VARCHAR(80), gene_id VARCHAR(10) NULL, is_multiple SMALLINT NOT NULL); 15 | 16 | -- Explicit index creation on the referencing column of all the foreign keys. 17 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 18 | -- indexes automatically. 19 | CREATE INDEX Fgbprobes ON accessions (probe_id); 20 | CREATE INDEX Fprobes ON probes (probe_id); 21 | CREATE INDEX Fgenes ON probes (gene_id); 22 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.0/WORMCHIP_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 13 | CREATE TABLE accessions (probe_id VARCHAR(80),accession VARCHAR(20)); 14 | CREATE TABLE probes (probe_id VARCHAR(80), gene_id VARCHAR(10) NULL, is_multiple SMALLINT NOT NULL); 15 | 16 | -- Explicit index creation on the referencing column of all the foreign keys. 17 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 18 | -- indexes automatically. 19 | CREATE INDEX Fgbprobes ON accessions (probe_id); 20 | CREATE INDEX Fprobes ON probes (probe_id); 21 | CREATE INDEX Fgenes ON probes (gene_id); 22 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.0/XENOPUSCHIP_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 13 | CREATE TABLE accessions (probe_id VARCHAR(80),accession VARCHAR(20)); 14 | CREATE TABLE probes (probe_id VARCHAR(80), gene_id VARCHAR(10) NULL, is_multiple SMALLINT NOT NULL); 15 | 16 | -- Explicit index creation on the referencing column of all the foreign keys. 17 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 18 | -- indexes automatically. 19 | CREATE INDEX Fgbprobes ON accessions (probe_id); 20 | CREATE INDEX Fprobes ON probes (probe_id); 21 | CREATE INDEX Fgenes ON probes (gene_id); 22 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.1/BOVINECHIP_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 13 | CREATE TABLE accessions (probe_id VARCHAR(80),accession VARCHAR(20)); 14 | CREATE TABLE probes (probe_id VARCHAR(80), gene_id VARCHAR(10) NULL, is_multiple SMALLINT NOT NULL); 15 | 16 | -- Explicit index creation on the referencing column of all the foreign keys. 17 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 18 | -- indexes automatically. 19 | CREATE INDEX Fgbprobes ON accessions (probe_id); 20 | CREATE INDEX Fprobes ON probes (probe_id); 21 | CREATE INDEX Fgenes ON probes (gene_id); 22 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.1/CANINECHIP_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 13 | CREATE TABLE accessions (probe_id VARCHAR(80),accession VARCHAR(20)); 14 | CREATE TABLE probes (probe_id VARCHAR(80), gene_id VARCHAR(10) NULL, is_multiple SMALLINT NOT NULL); 15 | 16 | -- Explicit index creation on the referencing column of all the foreign keys. 17 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 18 | -- indexes automatically. 19 | CREATE INDEX Fgbprobes ON accessions (probe_id); 20 | CREATE INDEX Fprobes ON probes (probe_id); 21 | CREATE INDEX Fgenes ON probes (gene_id); 22 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.1/CHICKENCHIP_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 13 | CREATE TABLE accessions (probe_id VARCHAR(80),accession VARCHAR(20)); 14 | CREATE TABLE probes (probe_id VARCHAR(80), gene_id VARCHAR(10) NULL, is_multiple SMALLINT NOT NULL); 15 | 16 | -- Explicit index creation on the referencing column of all the foreign keys. 17 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 18 | -- indexes automatically. 19 | CREATE INDEX Fgbprobes ON accessions (probe_id); 20 | CREATE INDEX Fprobes ON probes (probe_id); 21 | CREATE INDEX Fgenes ON probes (gene_id); 22 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.1/FLYCHIP_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 13 | CREATE TABLE accessions (probe_id VARCHAR(80),accession VARCHAR(20)); 14 | CREATE TABLE probes (probe_id VARCHAR(80), gene_id VARCHAR(10) NULL, is_multiple SMALLINT NOT NULL); 15 | 16 | -- Explicit index creation on the referencing column of all the foreign keys. 17 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 18 | -- indexes automatically. 19 | CREATE INDEX Fgbprobes ON accessions (probe_id); 20 | CREATE INDEX Fprobes ON probes (probe_id); 21 | CREATE INDEX Fgenes ON probes (gene_id); 22 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.1/HUMANCHIP_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 13 | CREATE TABLE accessions (probe_id VARCHAR(80),accession VARCHAR(20)); 14 | CREATE TABLE probes (probe_id VARCHAR(80), gene_id VARCHAR(10) NULL, is_multiple SMALLINT NOT NULL); 15 | 16 | -- Explicit index creation on the referencing column of all the foreign keys. 17 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 18 | -- indexes automatically. 19 | CREATE INDEX Fgbprobes ON accessions (probe_id); 20 | CREATE INDEX Fprobes ON probes (probe_id); 21 | CREATE INDEX Fgenes ON probes (gene_id); 22 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.1/MOUSECHIP_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 13 | CREATE TABLE accessions (probe_id VARCHAR(80),accession VARCHAR(20)); 14 | CREATE TABLE probes (probe_id VARCHAR(80), gene_id VARCHAR(10) NULL, is_multiple SMALLINT NOT NULL); 15 | 16 | -- Explicit index creation on the referencing column of all the foreign keys. 17 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 18 | -- indexes automatically. 19 | CREATE INDEX Fgbprobes ON accessions (probe_id); 20 | CREATE INDEX Fprobes ON probes (probe_id); 21 | CREATE INDEX Fgenes ON probes (gene_id); 22 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.1/RATCHIP_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 13 | CREATE TABLE accessions (probe_id VARCHAR(80),accession VARCHAR(20)); 14 | CREATE TABLE probes (probe_id VARCHAR(80), gene_id VARCHAR(10) NULL, is_multiple SMALLINT NOT NULL); 15 | 16 | -- Explicit index creation on the referencing column of all the foreign keys. 17 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 18 | -- indexes automatically. 19 | CREATE INDEX Fgbprobes ON accessions (probe_id); 20 | CREATE INDEX Fprobes ON probes (probe_id); 21 | CREATE INDEX Fgenes ON probes (gene_id); 22 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.1/WORMCHIP_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 13 | CREATE TABLE accessions (probe_id VARCHAR(80),accession VARCHAR(20)); 14 | CREATE TABLE probes (probe_id VARCHAR(80), gene_id VARCHAR(10) NULL, is_multiple SMALLINT NOT NULL); 15 | 16 | -- Explicit index creation on the referencing column of all the foreign keys. 17 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 18 | -- indexes automatically. 19 | CREATE INDEX Fgbprobes ON accessions (probe_id); 20 | CREATE INDEX Fprobes ON probes (probe_id); 21 | CREATE INDEX Fgenes ON probes (gene_id); 22 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.1/XENOPUSCHIP_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 13 | CREATE TABLE accessions (probe_id VARCHAR(80),accession VARCHAR(20)); 14 | CREATE TABLE probes (probe_id VARCHAR(80), gene_id VARCHAR(10) NULL, is_multiple SMALLINT NOT NULL); 15 | 16 | -- Explicit index creation on the referencing column of all the foreign keys. 17 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 18 | -- indexes automatically. 19 | CREATE INDEX Fgbprobes ON accessions (probe_id); 20 | CREATE INDEX Fprobes ON probes (probe_id); 21 | CREATE INDEX Fgenes ON probes (gene_id); 22 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.0/ZEBRAFISHCHIP_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 13 | CREATE TABLE accessions (probe_id VARCHAR(80),accession VARCHAR(20)); 14 | CREATE TABLE probes (probe_id VARCHAR(80), gene_id VARCHAR(10) NULL, is_multiple SMALLINT NOT NULL); 15 | 16 | -- Explicit index creation on the referencing column of all the foreign keys. 17 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 18 | -- indexes automatically. 19 | CREATE INDEX Fgbprobes ON accessions (probe_id); 20 | CREATE INDEX Fprobes ON probes (probe_id); 21 | CREATE INDEX Fgenes ON probes (gene_id); 22 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.1/ZEBRAFISHCHIP_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 13 | CREATE TABLE accessions (probe_id VARCHAR(80),accession VARCHAR(20)); 14 | CREATE TABLE probes (probe_id VARCHAR(80), gene_id VARCHAR(10) NULL, is_multiple SMALLINT NOT NULL); 15 | 16 | -- Explicit index creation on the referencing column of all the foreign keys. 17 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 18 | -- indexes automatically. 19 | CREATE INDEX Fgbprobes ON accessions (probe_id); 20 | CREATE INDEX Fprobes ON probes (probe_id); 21 | CREATE INDEX Fgenes ON probes (gene_id); 22 | -------------------------------------------------------------------------------- /man/print.probetable.Rd: -------------------------------------------------------------------------------- 1 | \name{print.probetable} 2 | \alias{print.probetable} 3 | \title{Print method for probetable objects} 4 | \usage{ 5 | \method{print}{probetable}(x, maxrows, \dots) 6 | } 7 | \description{ 8 | Prints class(x), nrow(x) and ncol(x), but not the elements of x. 9 | The motivation for having this method is that methods from the package 10 | \code{base} such as 11 | \code{\link[base:print.dataframe]{print.data.frame}} 12 | will try to print the values of all elements of \code{x}, which can 13 | take inconveniently much time and screen space if \code{x} is large. 14 | } 15 | \arguments{ 16 | \item{x}{an object of S3-class \code{probetable}.} 17 | \item{maxrows}{maximum number of rows to print.} 18 | \item{\dots}{further arguments that get ignored.} 19 | } 20 | \seealso{ 21 | \code{\link[base:print.dataframe]{print.data.frame}} 22 | } 23 | \examples{ 24 | a = as.data.frame(matrix(runif(1e6), ncol=1e3)) 25 | class(a) = c("probetable", class(a)) 26 | print(a) 27 | print(as.matrix(a[2:3, 4:6])) 28 | } 29 | \keyword{print} 30 | -------------------------------------------------------------------------------- /man/AnnotationDbi-internals.Rd: -------------------------------------------------------------------------------- 1 | \name{AnnotationDbi internals} 2 | 3 | \alias{debugSQL} 4 | 5 | \alias{class:FlatBimap} 6 | \alias{FlatBimap-class} 7 | \alias{FlatBimap} 8 | 9 | \alias{class:AnnObj} 10 | \alias{AnnObj-class} 11 | \alias{AnnObj} 12 | 13 | \alias{showQCData} 14 | 15 | \alias{class:L2Rlink} 16 | \alias{L2Rlink-class} 17 | \alias{L2Rlink} 18 | 19 | \alias{initialize,FlatBimap-method} 20 | \alias{initialize,L2Rlink-method} 21 | \alias{show,L2Rlink-method} 22 | 23 | \alias{dbGetTable} 24 | \alias{dbFileConnect} 25 | \alias{dbFileDisconnect} 26 | \alias{mergeToNamespaceAndExport} 27 | 28 | 29 | \alias{createAnnObjs.SchemaChoice} 30 | \alias{NCBICHIP_DB_SeedGenerator} 31 | \alias{getOrgPkgForSchema} 32 | \alias{filterSeeds} 33 | \alias{chooseCentralOrgPkgSymbol} 34 | \alias{mapIds_base} 35 | \alias{resort_base} 36 | \alias{testForValidKeytype} 37 | \alias{testSelectArgs} 38 | 39 | 40 | \title{AnnotationDbi internals} 41 | 42 | \description{ 43 | AnnotationDbi objects, classes and methods that are not intended to 44 | be used directly. 45 | } 46 | 47 | \keyword{internal} 48 | \keyword{methods} 49 | \keyword{classes} 50 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_0.9/KEGG_DB.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- KEGG_DB schema 3 | -- ============== 4 | -- 5 | 6 | CREATE TABLE ec2go ( 7 | ec_no VARCHAR(16) NOT NULL, -- EC number (with "EC:" prefix) 8 | go_id CHAR(10) NOT NULL -- GO ID 9 | ); 10 | CREATE TABLE pathway2gene ( 11 | pathway_id CHAR(8) NOT NULL, -- KEGG pathway long ID 12 | gene_id VARCHAR(20) NOT NULL -- Entrez Gene or ORF ID 13 | ); 14 | CREATE TABLE pathway2name ( 15 | path_id CHAR(5) NOT NULL UNIQUE, -- KEGG pathway short ID 16 | path_name VARCHAR(80) NOT NULL UNIQUE -- KEGG pathway name 17 | ); 18 | 19 | -- Metadata tables. 20 | CREATE TABLE metadata ( 21 | name VARCHAR(80) PRIMARY KEY, 22 | value VARCHAR(255) 23 | ); 24 | CREATE TABLE qcdata ( 25 | map_name VARCHAR(80) PRIMARY KEY, 26 | count INTEGER NOT NULL 27 | ); 28 | CREATE TABLE map_metadata ( 29 | map_name VARCHAR(80) NOT NULL, 30 | source_name VARCHAR(80) NOT NULL, 31 | source_url VARCHAR(255) NOT NULL, 32 | source_date VARCHAR(20) NOT NULL 33 | ); 34 | 35 | -- Indexes. 36 | CREATE INDEX Ipathway2gene ON pathway2gene (gene_id); 37 | 38 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_1.0/KEGG_DB.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- KEGG_DB schema 3 | -- ============== 4 | -- 5 | 6 | CREATE TABLE ec2go ( 7 | ec_no VARCHAR(16) NOT NULL, -- EC number (with "EC:" prefix) 8 | go_id CHAR(10) NOT NULL -- GO ID 9 | ); 10 | CREATE TABLE pathway2gene ( 11 | pathway_id CHAR(8) NOT NULL, -- KEGG pathway long ID 12 | gene_or_orf_id VARCHAR(20) NOT NULL -- Entrez Gene or ORF ID 13 | ); 14 | CREATE TABLE pathway2name ( 15 | path_id CHAR(5) NOT NULL UNIQUE, -- KEGG pathway short ID 16 | path_name VARCHAR(80) NOT NULL UNIQUE -- KEGG pathway name 17 | ); 18 | 19 | -- Metadata tables. 20 | CREATE TABLE metadata ( 21 | name VARCHAR(80) PRIMARY KEY, 22 | value VARCHAR(255) 23 | ); 24 | CREATE TABLE map_counts ( 25 | map_name VARCHAR(80) PRIMARY KEY, 26 | count INTEGER NOT NULL 27 | ); 28 | CREATE TABLE map_metadata ( 29 | map_name VARCHAR(80) NOT NULL, 30 | source_name VARCHAR(80) NOT NULL, 31 | source_url VARCHAR(255) NOT NULL, 32 | source_date VARCHAR(20) NOT NULL 33 | ); 34 | 35 | -- Indexes. 36 | CREATE INDEX Ipathway2gene ON pathway2gene (gene_id); 37 | 38 | -------------------------------------------------------------------------------- /man/toSQLStringSet.Rd: -------------------------------------------------------------------------------- 1 | \name{toSQLStringSet} 2 | \alias{toSQLStringSet} 3 | 4 | \title{Convert a vector to a quoted string for use as a SQL value list} 5 | \description{ 6 | Given a vector, this function returns a string with each element of 7 | the input coerced to character, quoted, and separated by ",". 8 | } 9 | \usage{ 10 | toSQLStringSet(names) 11 | } 12 | \arguments{ 13 | \item{names}{A vector of values to quote} 14 | } 15 | \details{ 16 | If \code{names} is a character vector with elements containing single 17 | quotes, these quotes will be doubled so as to escape the quote in SQL. 18 | } 19 | \value{ 20 | A character vector of length one that represents the input vector as a 21 | SQL value list. Each element is single quoted and elements are 22 | comma separated. 23 | } 24 | \author{Hervé Pagès} 25 | \note{ 26 | Do not use \code{sQuote} for generating SQL as that function is 27 | intended for display purposes only. In some locales, \code{sQuote} 28 | will generate fancy quotes which will break your SQL. 29 | } 30 | \examples{ 31 | toSQLStringSet(letters[1:4]) 32 | toSQLStringSet(c("'foo'", "ab'cd", "bar")) 33 | 34 | } 35 | 36 | \keyword{utilities} 37 | \keyword{manip} 38 | -------------------------------------------------------------------------------- /inst/extdata/org.testing.db/man/org.TguttataTestingSubset.egBASE.Rd: -------------------------------------------------------------------------------- 1 | \name{org.TguttataTestingSubset.eg.db} 2 | \alias{org.TguttataTestingSubset.eg.db} 3 | \alias{org.TguttataTestingSubset.eg} 4 | \title{Bioconductor annotation data package} 5 | \description{ 6 | 7 | Welcome to the org.TguttataTestingSubset.eg.db annotation Package. This is an 8 | organism specific package. The purpose is to provide detailed 9 | information about the species abbreviated in the second part of the 10 | package name org.TguttataTestingSubset.eg.db. "Hs" is for Homo sapiens. This 11 | package is updated biannually. 12 | 13 | You can learn what objects this package supports with the following command: 14 | 15 | \code{ls("package:org.TguttataTestingSubset.eg.db")} 16 | 17 | Each of these objects has their own manual page detailing where relevant 18 | data was obtained along with examples of how to use it. Many of these 19 | objects also have a reverse map available. When this is true, expect 20 | to usually find relevant information on the same manual page as the 21 | forward map. 22 | } 23 | \examples{ 24 | ls("package:org.TguttataTestingSubset.eg.db") 25 | } 26 | \keyword{datasets} 27 | 28 | -------------------------------------------------------------------------------- /R/FlatBimap.R: -------------------------------------------------------------------------------- 1 | ### ========================================================================= 2 | ### FlatBimap objects 3 | ### ----------------- 4 | ### 5 | 6 | ### Possible col metanames are: "Lkeyname", "Rkeyname" and "tagname" 7 | ### There must be exactly 1 "Lkeyname" and 1 "Rkeyname" col. 8 | ### There can be 0 or 1 "tagname" col. 9 | setMethod("initialize", "FlatBimap", 10 | function(.Object, colmetanames, direction, data, Lkeys, Rkeys) 11 | { 12 | if (!is.character(colmetanames) 13 | || any(duplicated(colmetanames)) 14 | || !all(colmetanames %in% c("Lkeyname", "Rkeyname", "tagname")) 15 | || !all(c("Lkeyname", "Rkeyname") %in% colmetanames)) 16 | stop("invalid col metanames") 17 | if (ncol(data) < length(colmetanames)) 18 | stop("FlatBimap object has not enough columns") 19 | .Object@colmetanames <- colmetanames 20 | if (!missing(direction)) 21 | .Object@direction <- .normalize.direction(direction) 22 | .Object@data <- data 23 | .Object@Lkeys <- Lkeys 24 | .Object@Rkeys <- Rkeys 25 | if (any(duplicated(Rattribnames(.Object)))) 26 | stop("duplicated Rattrib names") 27 | .Object 28 | } 29 | ) 30 | 31 | -------------------------------------------------------------------------------- /man/BimapFormatting.Rd: -------------------------------------------------------------------------------- 1 | \name{BimapFormatting} 2 | 3 | \alias{BimapFormatting} 4 | 5 | \alias{as.list} 6 | \alias{as.list,FlatBimap-method} 7 | \alias{as.list,Bimap-method} 8 | \alias{as.list.Bimap} 9 | \alias{as.list,IpiAnnDbMap-method} 10 | \alias{as.list,AgiAnnDbMap-method} 11 | \alias{as.list,GoAnnDbBimap-method} 12 | \alias{as.list,GOTermsAnnDbBimap-method} 13 | 14 | \alias{as.character,AnnDbBimap-method} 15 | \alias{as.character,FlatBimap-method} 16 | 17 | 18 | \title{Formatting a Bimap as a list or character vector} 19 | 20 | \description{ 21 | These functions format a Bimap as a list or character vector. 22 | } 23 | 24 | 25 | \usage{ 26 | ## Formatting as a list 27 | as.list(x, ...) 28 | 29 | ## Formatting as a character vector 30 | #as.character(x, ...) 31 | 32 | } 33 | 34 | \arguments{ 35 | \item{x}{ 36 | A \link{Bimap} object. 37 | } 38 | \item{...}{ 39 | Further arguments are ignored. 40 | } 41 | } 42 | 43 | 44 | \author{H. Pagès} 45 | 46 | \seealso{ 47 | \link{Bimap}, 48 | \link{Bimap-envirAPI} 49 | } 50 | 51 | \examples{ 52 | library(hgu95av2.db) 53 | as.list(hgu95av2CHRLOC)[1:9] 54 | as.list(hgu95av2ENTREZID)[1:9] 55 | as.character(hgu95av2ENTREZID)[1:9] 56 | } 57 | 58 | \keyword{methods} 59 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.0/KEGG_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata ( 2 | name VARCHAR(80) PRIMARY KEY, 3 | value VARCHAR(255) 4 | ); 5 | CREATE TABLE pathway2name ( 6 | path_id CHAR(5) NOT NULL UNIQUE, -- KEGG pathway short ID 7 | path_name VARCHAR(100) NOT NULL UNIQUE -- KEGG pathway name 8 | ); 9 | CREATE TABLE pathway2gene ( 10 | pathway_id CHAR(8) NOT NULL, -- KEGG pathway long ID 11 | gene_or_orf_id VARCHAR(20) NOT NULL -- Entrez Gene or ORF ID 12 | ); 13 | CREATE TABLE ath_NCBI_pathway2gene ( 14 | pathway_id CHAR(8) NOT NULL, -- KEGG pathway long ID 15 | gene_or_orf_id VARCHAR(20) NOT NULL -- Entrez Gene or ORF ID 16 | ); 17 | CREATE TABLE ec2go(ec_no VARCHAR(16),go_id CHAR(10)); 18 | CREATE TABLE map_counts ( 19 | map_name VARCHAR(80) PRIMARY KEY, 20 | count INTEGER NOT NULL 21 | ); 22 | CREATE TABLE map_metadata ( 23 | map_name VARCHAR(80) NOT NULL, 24 | source_name VARCHAR(80) NOT NULL, 25 | source_url VARCHAR(255) NOT NULL, 26 | source_date VARCHAR(20) NOT NULL 27 | ); 28 | 29 | -- Explicit index creation on the referencing column of all the foreign keys. 30 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 31 | -- indexes automatically. 32 | CREATE INDEX Ipathway2gene ON pathway2gene (gene_or_orf_id); 33 | CREATE INDEX ath_NCBI_Ipathway2gene ON ath_NCBI_pathway2gene (gene_or_orf_id); 34 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.1/KEGG_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata ( 2 | name VARCHAR(80) PRIMARY KEY, 3 | value VARCHAR(255) 4 | ); 5 | CREATE TABLE pathway2name ( 6 | path_id CHAR(5) NOT NULL UNIQUE, -- KEGG pathway short ID 7 | path_name VARCHAR(100) NOT NULL UNIQUE -- KEGG pathway name 8 | ); 9 | CREATE TABLE pathway2gene ( 10 | pathway_id CHAR(8) NOT NULL, -- KEGG pathway long ID 11 | gene_or_orf_id VARCHAR(20) NOT NULL -- Entrez Gene or ORF ID 12 | ); 13 | CREATE TABLE ath_NCBI_pathway2gene ( 14 | pathway_id CHAR(8) NOT NULL, -- KEGG pathway long ID 15 | gene_or_orf_id VARCHAR(20) NOT NULL -- Entrez Gene or ORF ID 16 | ); 17 | CREATE TABLE ec2go(ec_no VARCHAR(16),go_id CHAR(10)); 18 | CREATE TABLE map_counts ( 19 | map_name VARCHAR(80) PRIMARY KEY, 20 | count INTEGER NOT NULL 21 | ); 22 | CREATE TABLE map_metadata ( 23 | map_name VARCHAR(80) NOT NULL, 24 | source_name VARCHAR(80) NOT NULL, 25 | source_url VARCHAR(255) NOT NULL, 26 | source_date VARCHAR(20) NOT NULL 27 | ); 28 | 29 | -- Explicit index creation on the referencing column of all the foreign keys. 30 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 31 | -- indexes automatically. 32 | CREATE INDEX Ipathway2gene ON pathway2gene (gene_or_orf_id); 33 | CREATE INDEX ath_NCBI_Ipathway2gene ON ath_NCBI_pathway2gene (gene_or_orf_id); 34 | -------------------------------------------------------------------------------- /inst/extdata/org.testing.db/R/zzz.R: -------------------------------------------------------------------------------- 1 | datacache <- new.env(hash=TRUE, parent=emptyenv()) 2 | 3 | org.testing <- function() showQCData("org.testing", datacache) 4 | org.testing_dbconn <- function() dbconn(datacache) 5 | org.testing_dbfile <- function() dbfile(datacache) 6 | org.testing_dbschema <- function(file="", show.indices=FALSE) dbschema(datacache, file=file, show.indices=show.indices) 7 | org.testing_dbInfo <- function() dbInfo(datacache) 8 | 9 | org.testingORGANISM <- "Taeniopygia guttataTestingSubset" 10 | 11 | .onLoad <- function(libname, pkgname) 12 | { 13 | require("methods", quietly=TRUE) 14 | ## Connect to the SQLite DB 15 | dbfile <- system.file("extdata", "org.testing.sqlite", package=pkgname, lib.loc=libname) 16 | assign("dbfile", dbfile, envir=datacache) 17 | dbconn <- dbFileConnect(dbfile) 18 | assign("dbconn", dbconn, envir=datacache) 19 | 20 | ## Create the OrgDb object 21 | sPkgname <- sub(".db$","",pkgname) 22 | db <- loadDb(system.file("extdata", paste(sPkgname, 23 | ".sqlite",sep=""), package=pkgname, lib.loc=libname), 24 | packageName=pkgname) 25 | dbNewname <- AnnotationDbi:::dbObjectName(pkgname,"OrgDb") 26 | ns <- asNamespace(pkgname) 27 | assign(dbNewname, db, envir=ns) 28 | namespaceExport(ns, dbNewname) 29 | 30 | packageStartupMessage(AnnotationDbi:::annoStartupMessages("org.testing.db")) 31 | } 32 | 33 | .onUnload <- function(libpath) 34 | { 35 | dbFileDisconnect(org.testing_dbconn()) 36 | } 37 | 38 | -------------------------------------------------------------------------------- /man/KEGGFrame.Rd: -------------------------------------------------------------------------------- 1 | \name{KEGGFrame} 2 | \docType{class} 3 | 4 | % Classes 5 | 6 | \alias{KEGGFrame} 7 | \alias{class:KEGGFrame} 8 | \alias{KEGGFrame-class} 9 | 10 | 11 | % methods 12 | \alias{KEGGFrame} 13 | \alias{KEGGFrame,data.frame,character-method} 14 | \alias{KEGGFrame,data.frame,missing-method} 15 | 16 | \alias{getKEGGFrameData} 17 | \alias{getKEGGFrameData,KEGGFrame-method} 18 | \alias{getKEGGFrameData,KEGGAllFrame-method} 19 | 20 | 21 | \title{KEGGFrame objects} 22 | 23 | \description{ 24 | These objects each contain a data frame which is required to be 25 | composed of 2 columns. The 1st column are KEGG IDs. The second are 26 | the gene IDs that match to the KEGG IDs. There is also a slot for the 27 | organism that these anotations pertain to. \code{getKEGGFrameData} is 28 | just an accessor method and returns the data.frame contained in the 29 | KEGGFrame object and is mostly used by other code internally. 30 | } 31 | 32 | 33 | \details{ 34 | The purpose of these objects is to create a safe way for annotation 35 | data about KEGG from non-traditional sources to be used for analysis 36 | packages like GSEABase and eventually Category. 37 | } 38 | 39 | \examples{ 40 | ## Make up an example 41 | genes = c(2,9,9,10) 42 | KEGGIds = c("04610","00232","00983","00232") 43 | frameData = data.frame(cbind(KEGGIds,genes)) 44 | 45 | library(AnnotationDbi) 46 | frame=KEGGFrame(frameData,organism="Homo sapiens") 47 | 48 | getKEGGFrameData(frame) 49 | } 50 | 51 | \keyword{classes} 52 | \keyword{interface} 53 | -------------------------------------------------------------------------------- /man/GOColsAndKeytypes.Rd: -------------------------------------------------------------------------------- 1 | \name{GOID} 2 | 3 | \alias{GOID} 4 | \alias{TERM} 5 | \alias{ONTOLOGY} 6 | \alias{DEFINITION} 7 | 8 | \title{Descriptions of available values for \code{columns} and 9 | \code{keytypes} for GO.db.} 10 | 11 | 12 | \description{ 13 | This manual page enumerates the kinds of data represented by the 14 | values returned when the user calls \code{columns} or \code{keytypes} 15 | } 16 | 17 | 18 | \details{ 19 | All the possible values for \code{columns} and \code{keytypes} are listed 20 | below. 21 | 22 | \describe{ 23 | \item{GOID:}{GO Identifiers} 24 | \item{DEFINITION:}{The definition of a GO Term} 25 | \item{ONTOLOGY:}{Which of the three Gene Ontologies (BP, CC, or MF)} 26 | \item{TERM:}{The actual GO term} 27 | } 28 | 29 | To get the latest information about the date stamps and source URLS 30 | for the data used to make an annotation package, please use the 31 | metadata method as shown in the example below. 32 | 33 | } 34 | 35 | 36 | \author{Marc Carlson} 37 | 38 | 39 | \examples{ 40 | library(GO.db) 41 | ## List the possible values for columns 42 | columns(GO.db) 43 | ## List the possible values for keytypes 44 | keytypes(GO.db) 45 | ## get some values back 46 | keys <- head(keys(GO.db)) 47 | keys 48 | select(GO.db, keys=keys, columns=c("TERM","ONTOLOGY"), 49 | keytype="GOID") 50 | 51 | ## More infomation about the dates and original sources for these data: 52 | metadata(GO.db) 53 | } 54 | 55 | 56 | \keyword{utilities} 57 | \keyword{manip} 58 | -------------------------------------------------------------------------------- /man/unlist2.Rd: -------------------------------------------------------------------------------- 1 | \name{unlist2} 2 | 3 | \alias{unlist2} 4 | 5 | \title{A replacement for unlist() that does not mangle the names} 6 | 7 | \description{ 8 | \code{unlist2} is a replacement for \code{base::unlist()} that 9 | does not mangle the names. 10 | } 11 | 12 | \usage{ 13 | unlist2(x, recursive=TRUE, use.names=TRUE, what.names="inherited") 14 | } 15 | 16 | \arguments{ 17 | \item{x, recursive, use.names}{See \code{?unlist}.} 18 | \item{what.names}{\code{"inherited"} or \code{"full"}.} 19 | } 20 | 21 | \details{ 22 | Use this function if you don't like the mangled names returned 23 | by the standard \code{unlist} function from the base package. 24 | Using \code{unlist} with annotation data is dangerous and it is 25 | highly recommended to use \code{unlist2} instead. 26 | } 27 | 28 | \author{Hervé Pagès} 29 | 30 | \seealso{ 31 | \code{\link{unlist}} 32 | } 33 | 34 | \examples{ 35 | x <- list(A=c(b=-4, 2, b=7), B=3:-1, c(a=1, a=-2), C=list(c(2:-1, d=55), e=99)) 36 | unlist(x) 37 | unlist2(x) 38 | 39 | library(hgu95av2.db) 40 | egids <- c("10", "100", "1000") 41 | egids2pbids <- mget(egids, revmap(hgu95av2ENTREZID)) 42 | egids2pbids 43 | 44 | unlist(egids2pbids) # 1001, 1002, 10001 and 10002 are not real 45 | # Entrez ids but are the result of unlist() 46 | # mangling the names! 47 | 48 | unlist2(egids2pbids) # much cleaner! yes the names are not unique 49 | # but at least they are correct... 50 | } 51 | 52 | \keyword{utilities} 53 | \keyword{manip} 54 | -------------------------------------------------------------------------------- /R/makeMap.R: -------------------------------------------------------------------------------- 1 | make_eg_to_go_map <- function(chip) { 2 | 3 | if (length(grep("\\.db$", chip))) 4 | chip <- substr(chip, 1, nchar(chip) - 3) 5 | chipNS <- getNamespace(paste0(chip, ".db")) 6 | chip2GO <- get(paste0(chip, "GO"), chipNS) 7 | chipGO2PROBE <- get(paste0(chip, "GO2PROBE"), chipNS) 8 | L2Rchain <- list(new("L2Rlink", tablename="probes", Lcolname="gene_id", Rcolname="gene_id"), 9 | chip2GO@L2Rchain[[2]], 10 | chip2GO@L2Rchain[[3]]) 11 | eg2go.map <- new("Go3AnnDbBimap", 12 | rightTables=chipGO2PROBE@rightTables, 13 | L2Rchain=L2Rchain, 14 | datacache=chipGO2PROBE@datacache, 15 | objName="ENTREZID2GO", 16 | objTarget=paste("chip", chip)) 17 | eg2go.map 18 | } 19 | 20 | make_go_to_eg_map <- function(chip) { 21 | map <- make_eg_to_go_map(chip) 22 | revmap(map) 23 | } 24 | 25 | ## Notes by Hervé: 26 | ## 1) First define the left-to-right path that you need to take to go from 27 | ## the ENZYME space to the ENTREZID space. You can look at the 28 | ## hgu95av2ENZYME2PROBE/hgu95av2ENTREZID slots for this or consult 29 | ## the schemas definitions in AnnotationDbi: 30 | 31 | ## L2Rchain <- list( 32 | ## new("L2Rlink", tablename="ec", Lcolname="ec_number", Rcolname="_id"), 33 | ## new("L2Rlink", tablename="genes", Lcolname="_id", Rcolname="gene_id") 34 | ## ) 35 | 36 | ## 2) Create a new AnnDbBimap instance: 37 | 38 | ## hgu95av2ENZYME2ENTREZID <- new("AnnDbBimap", 39 | ## L2Rchain=L2Rchain, 40 | ## datacache=hgu95av2ENZYME@datacache, 41 | ## objName="ENZYME2ENTREZID", 42 | ## objTarget="chip hgu95av2" 43 | ## ) 44 | 45 | -------------------------------------------------------------------------------- /man/GOFrame.Rd: -------------------------------------------------------------------------------- 1 | \name{GOFrame} 2 | \docType{class} 3 | 4 | % Classes 5 | 6 | \alias{GOFrame} 7 | \alias{class:GOFrame} 8 | \alias{GOFrame-class} 9 | 10 | \alias{GOAllFrame} 11 | \alias{class:GOAllFrame} 12 | \alias{GOAllFrame-class} 13 | 14 | 15 | % methods 16 | \alias{GOFrame} 17 | \alias{GOFrame,data.frame,character-method} 18 | \alias{GOFrame,data.frame,missing-method} 19 | 20 | \alias{GOAllFrame} 21 | \alias{GOAllFrame,GOFrame-method} 22 | 23 | \alias{getGOFrameData} 24 | \alias{getGOFrameData,GOFrame-method} 25 | \alias{getGOFrameData,GOAllFrame-method} 26 | 27 | 28 | \title{GOFrame and GOAllFrame objects} 29 | 30 | \description{ 31 | These objects each contain a data frame which is required to be 32 | composed of 3 columns. The 1st column are GO IDs. The second are 33 | evidence codes and the 3rd are the gene IDs that match to the GO IDs 34 | using those evidence codes. There is also a slot for the organism 35 | that these anotations pertain to. 36 | } 37 | 38 | 39 | \details{ 40 | The GOAllFrame object can only be generated from a GOFrame object and 41 | its contructor method does this automatically from a GOFrame 42 | argument. The purpose of these objects is to create a safe way for 43 | annotation data about GO from non-traditional sources to be used for 44 | analysis packages like GSEABase and eventually GOstats. 45 | } 46 | 47 | \examples{ 48 | ## Make up an example 49 | genes = c(1,10,100) 50 | evi = c("ND","IEA","IDA") 51 | GOIds = c("GO:0008150","GO:0008152","GO:0001666") 52 | frameData = data.frame(cbind(GOIds,evi,genes)) 53 | 54 | library(AnnotationDbi) 55 | frame=GOFrame(frameData,organism="Homo sapiens") 56 | allFrame=GOAllFrame(frame) 57 | 58 | getGOFrameData(allFrame) 59 | } 60 | 61 | \keyword{classes} 62 | \keyword{interface} 63 | -------------------------------------------------------------------------------- /R/unlist2.R: -------------------------------------------------------------------------------- 1 | ### ========================================================================= 2 | ### unlist2(): A replacement for base::unlist() that does not mangle the 3 | ### names. 4 | ### ------------------------------------------------------------------------- 5 | 6 | make.name.tree <- function(x, recursive, what.names) 7 | { 8 | if (!is.character(what.names) || length(what.names) != 1) 9 | stop("'what.names' must be a single string") 10 | what.names <- match.arg(what.names, c("inherited" , "full")) 11 | .make.name.tree.rec <- function(x, parent_name, depth) 12 | { 13 | if (length(x) == 0) 14 | return(character(0)) 15 | x_names <- names(x) 16 | if (is.null(x_names)) 17 | x_names <- rep.int(parent_name, length(x)) 18 | else if (what.names == "full") 19 | x_names <- paste0(parent_name, x_names) 20 | else 21 | x_names[x_names == ""] <- parent_name 22 | if (!is.list(x) || (!recursive && depth >= 1L)) 23 | return(x_names) 24 | if (what.names == "full") 25 | x_names <- paste0(x_names, ".") 26 | lapply(seq_len(length(x)), 27 | function(i) .make.name.tree.rec(x[[i]], x_names[i], depth + 1L)) 28 | } 29 | .make.name.tree.rec(x, "", 0L) 30 | } 31 | 32 | unlist2 <- function(x, recursive=TRUE, use.names=TRUE, what.names="inherited") 33 | { 34 | ans <- unlist(x, recursive, FALSE) 35 | if (!use.names) 36 | return(ans) 37 | if (!is.character(what.names) || length(what.names) != 1) 38 | stop("'what.names' must be a single string") 39 | what.names <- match.arg(what.names, c("inherited" , "full")) 40 | names(ans) <- unlist(make.name.tree(x, recursive, what.names), recursive, FALSE) 41 | ans 42 | } 43 | 44 | -------------------------------------------------------------------------------- /DESCRIPTION: -------------------------------------------------------------------------------- 1 | Package: AnnotationDbi 2 | Title: Manipulation of SQLite-based annotations in Bioconductor 3 | Description: Implements a user-friendly interface for querying SQLite-based annotation data packages. 4 | biocViews: Annotation, Microarray, Sequencing, GenomeAnnotation 5 | URL: https://bioconductor.org/packages/AnnotationDbi 6 | Video: https://www.youtube.com/watch?v=8qvGNTVz3Ik 7 | BugReports: https://github.com/Bioconductor/AnnotationDbi/issues 8 | Version: 1.73.0 9 | License: Artistic-2.0 10 | Encoding: UTF-8 11 | Author: Hervé Pagès, Marc Carlson, Seth Falcon, Nianhua Li 12 | Maintainer: Bioconductor Package Maintainer 13 | Depends: R (>= 2.7.0), methods, stats4, BiocGenerics (>= 0.29.2), 14 | Biobase (>= 1.17.0), IRanges 15 | Imports: DBI, RSQLite, S4Vectors (>= 0.9.25), stats, KEGGREST 16 | Suggests: utils, hgu95av2.db, GO.db, org.Sc.sgd.db, org.At.tair.db, 17 | RUnit, TxDb.Hsapiens.UCSC.hg19.knownGene, 18 | org.Hs.eg.db, reactome.db, AnnotationForge, graph, 19 | EnsDb.Hsapiens.v75, BiocStyle, knitr 20 | VignetteBuilder: knitr 21 | Collate: 00RTobjs.R AllGenerics.R AllClasses.R 22 | unlist2.R utils.R SQL.R FlatBimap.R 23 | AnnDbObj-lowAPI.R Bimap.R GOTerms.R BimapFormatting.R 24 | Bimap-envirAPI.R flatten.R methods-AnnotationDb.R 25 | methods-SQLiteConnection.R 26 | methods-geneCentricDbs.R methods-geneCentricDbs-keys.R 27 | methods-ReactomeDb.R methods-OrthologyDb.R 28 | loadDb.R createAnnObjs-utils.R createAnnObjs.NCBIORG_DBs.R 29 | createAnnObjs.NCBICHIP_DBs.R createAnnObjs.ORGANISM_DB.R 30 | createAnnObjs.YEASTCHIP_DB.R createAnnObjs.COELICOLOR_DB.R 31 | createAnnObjs.ARABIDOPSISCHIP_DB.R createAnnObjs.MALARIA_DB.R 32 | createAnnObjs.YEAST_DB.R createAnnObjs.YEASTNCBI_DB.R 33 | createAnnObjs.ARABIDOPSIS_DB.R createAnnObjs.GO_DB.R 34 | createAnnObjs.KEGG_DB.R 35 | createAnnObjs.PFAM_DB.R AnnDbPkg-templates-common.R 36 | AnnDbPkg-checker.R print.probetable.R makeMap.R inpIDMapper.R 37 | test_AnnotationDbi_package.R 38 | -------------------------------------------------------------------------------- /R/utils.R: -------------------------------------------------------------------------------- 1 | ### ========================================================================= 2 | ### Miscellaneous low-level utils 3 | ### ------------------------------------------------------------------------- 4 | ### 5 | 6 | ### Used at load time (in .onLoad) by all SQLite-based ann data packages. 7 | dbFileConnect <- function(dbfile) 8 | { 9 | ## This is a protection against dbConnect() working even with non-existing 10 | ## files (for our use case, the .sqlite file _must_ exist): 11 | if (!file.exists(dbfile)) 12 | stop("DB file '", dbfile, "' not found") 13 | 14 | ## Use of 'vsf="unix-none"' added on 01/11/2017 to avoid the infamous "da- 15 | ## tabase is locked" error that some users have reported on a few occasions 16 | ## in the past 10 years (and that we were never able to reproduce). Last 17 | ## time it was reported was on 01/11/2017 by Rob Bradley at Fred Hutch. 18 | ## Rob was trying to access TxDb.Hsapiens.UCSC.hg19.knownGene from multiple 19 | ## nodes on the Hutch cluster where TxDb.Hsapiens.UCSC.hg19.knownGene is 20 | ## installed on an NFS file system. Many thanks to Ben McGough, System 21 | ## Administrator at the Hutch, for investigating this and suggesting the 22 | ## 'vsf="unix-none"' solution. 23 | ## See ?`dbConnect,SQLiteDriver-method` and http://www.sqlite.org/vfs.html 24 | ## for more information about the the SQLite OS Interface or "VFS". 25 | if (.Platform$OS.type == "unix") { 26 | dbConnect(SQLite(), dbname=dbfile, cache_size=64000L, 27 | synchronous="off", flags=SQLITE_RO, vfs="unix-none") 28 | } else { 29 | ## Use default 'vfs' on Windows. 30 | dbConnect(SQLite(), dbname=dbfile, cache_size=64000L, 31 | synchronous="off", flags=SQLITE_RO) 32 | } 33 | } 34 | 35 | ### Used at unload time (in .onUnload) by all SQLite-based ann data packages. 36 | dbFileDisconnect <- function(dbconn) 37 | { 38 | dbDisconnect(dbconn) 39 | } 40 | 41 | -------------------------------------------------------------------------------- /man/createSimpleBimap.Rd: -------------------------------------------------------------------------------- 1 | \name{createSimpleBimap} 2 | 3 | \alias{createSimpleBimap} 4 | 5 | \title{Creates a simple Bimap from a SQLite database in an situation that 6 | is external to AnnotationDbi} 7 | 8 | \description{ 9 | This function allows users to easily make a simple Bimap object for 10 | extra tables etc that they may wish to add to their annotation 11 | packages. For most Bimaps, their definition is stored 12 | inside of AnnotationDbi. The addition of this function is to help 13 | ensure that this does not become a limitation, by allowing simple 14 | extra Bimaps to easily be defined external to AnnotationDbi. Usually, 15 | this will be done in the zzz.R source file of a package so that these 16 | extra mappings can be seemlessly integrated with the rest of the 17 | package. For now, this function assumes that users will want to use 18 | data from just one table. 19 | } 20 | 21 | \usage{ 22 | createSimpleBimap(tablename, Lcolname, Rcolname, datacache, objName, 23 | objTarget) 24 | } 25 | 26 | \arguments{ 27 | \item{tablename}{ 28 | The name of the database table to grab the mapping information from. 29 | } 30 | \item{Lcolname}{ 31 | The field name from the database table. These will become the Lkeys 32 | in the final mapping. 33 | } 34 | \item{Rcolname}{ 35 | The field name from the database table. These will become the Rkeys 36 | in the final mapping. 37 | } 38 | \item{datacache}{ 39 | The datacache object should already exist for every standard 40 | Annotation package. It is not exported though, so you will have to 41 | access it with ::: . It is needed to provide the connection 42 | information to the function. 43 | } 44 | \item{objName}{ 45 | This is the name of the mapping. 46 | } 47 | \item{objTarget}{ 48 | This is the name of the thing the mapping goes with. For most uses, 49 | this will mean the package name that the mapping belongs with. 50 | } 51 | } 52 | 53 | \examples{ 54 | ##You simply have to call this function to create a new mapping. For 55 | ##example, you could have created a mapping between the gene_name and 56 | ##the symbols fields from the gene_info table contained in the hgu95av2 57 | ##package by doing this: 58 | library(hgu95av2.db) 59 | hgu95av2NAMESYMBOL <- createSimpleBimap("gene_info", 60 | "gene_name", 61 | "symbol", 62 | hgu95av2.db:::datacache, 63 | "NAMESYMBOL", 64 | "hgu95av2.db") 65 | 66 | } 67 | 68 | \keyword{utilities} 69 | -------------------------------------------------------------------------------- /inst/NOTES-Herve: -------------------------------------------------------------------------------- 1 | - Fix this problem: 2 | library("org.Mm.eg.db") 3 | x <- org.Mm.egREFSEQ2EG 4 | mapped_seqs <- mappedkeys(x) 5 | y <- x[mapped_seqs] 6 | as.list(y) 7 | It occurs because the SQL statement is too long (the max length supported 8 | by SQLite seems to be 1000000 characters). 9 | For example, this will work: 10 | zz <- as.list(x[mapped_seqs[1:77403]]) 11 | but not this 12 | zz <- as.list(x[mapped_seqs[1:77404]]) 13 | nchar(toSQLStringSet(mapped_seqs[1:77404])) is 999869! 14 | 15 | - fix dbInfo() 16 | 17 | - in addition to dbschema(), provide a way to retrieve a high-level 18 | description of a given schema (UML? XML? via some S4 classes?) 19 | 20 | - add AnnotationDbi.Rnw vignette (main vignette) with more focus on the 21 | Bimap interface 22 | 23 | - fix the current INDEX mess (mix of old and new CREATE INDEX 24 | statements that lead to duplicated indices and an sqlite file 25 | bigger in size), I think all the old CREATE INDEX statements 26 | can be removed (they are the same as the new ones) except in 27 | GO_DB where some useful indices are missing in 0.9 28 | 29 | - try adding a "go" (or "go_all") VIEW in the schema that contains 30 | the UNION of the go_[bp|cc|mf] (or go_[bp|cc|mf]_all) tables. 31 | 2 things to check carefully: the impact on the size of the SQLite 32 | file and the impact on the speed of the GO, GO2PROBES and 33 | GO2ALLPROBES maps (their definitions would first need to be 34 | modified to make them GoAnnDbBimap instances and have them use 35 | this new view as the right table instead of the 3 original tables). 36 | 37 | - look at subListExtract in Biobase and see where it can 38 | be used to improve speed in AnnotationDbi 39 | 40 | 41 | - pluggable maps 42 | -------------- 43 | 44 | If [to.tablename(x1),to.colname(x1)] (the right table/colname for a direct 45 | map, the left table/colname for a reverse map) is the same as 46 | [from.tablename(x2)|from.colname(x2)] (the left table/colname for a direct 47 | map, the right/colname table for a reverse map), and if inslot.to.keys(x1) 48 | and inslot.from.keys(x2) are both NAs, then x1 and x2 are "pluggable". 49 | x <- plugmaps(x1, x2), the result of the "plug" operation, is a map that 50 | goes from [from.tablename(x1),from.colname(x1)] to 51 | [to.tablename(x2)|to.colname(x2)]. 52 | 53 | Of course, only maps that belong to the same package will be pluggable 54 | this way (e.g. hgu95av2PATH2PROBE and hgu95av2ACCNUM, x1 is a reverse 55 | map and x2 a direct map). So, in fact, something else to check before 56 | to decide whether x1 and x2 are pluggable is that dbfile(x1) == dbfile(x2). 57 | 58 | -------------------------------------------------------------------------------- /inst/unitTests/test_mapIds.R: -------------------------------------------------------------------------------- 1 | ## unit test to just check that mapIds is behaving itself 2 | require(org.Hs.eg.db) 3 | 4 | ## constants 5 | k <- head(keys(org.Hs.eg.db, 'ENTREZID')) 6 | 7 | # trace("mapIds", tracer=browser, signature ="AnnotationDb") 8 | 9 | ### The actual tests. 10 | 11 | ## Default is currently 'first' 12 | test_mapIds_default <- function(){ 13 | res <- mapIds(org.Hs.eg.db, keys=k, column='ALIAS', keytype='ENTREZID') 14 | checkTrue(length(res) == length(k)) 15 | checkTrue(res[[1]] == "A1B") 16 | checkTrue(class(res)=='character') 17 | } 18 | 19 | ## test other return types. 20 | 21 | ## "list" 22 | test_mapIds_CharacterList <- function(){ 23 | res <- mapIds(org.Hs.eg.db, keys=k, column='ALIAS', keytype='ENTREZID', 24 | multiVals="list") 25 | checkTrue(length(res) == length(k)) 26 | checkTrue(res[[1]][1] == "A1B") 27 | checkTrue(class(res)=='list') 28 | } 29 | 30 | ## "CharacterList" 31 | test_mapIds_CharacterList <- function(){ 32 | res <- mapIds(org.Hs.eg.db, keys=k, column='ALIAS', keytype='ENTREZID', 33 | multiVals="CharacterList") 34 | checkTrue(length(res) == length(k)) 35 | checkTrue(res[[1]][1] == "A1B") 36 | checkTrue(class(res)=='SimpleCharacterList') 37 | } 38 | 39 | ## "NAMultiples" 40 | test_mapIds_NAMultiples <- function(){ 41 | res <- mapIds(org.Hs.eg.db, keys=k, column='PFAM', keytype='ENTREZID', 42 | multiVals="asNA") 43 | checkTrue(length(res) == length(k)) 44 | checkTrue(res[['10']] == "PF00797") 45 | checkTrue(class(res)=='character') 46 | 47 | res <- mapIds(org.Hs.eg.db, "2", "PFAM", "ENTREZID", multiVals = "asNA") 48 | checkTrue(is.character(res)) 49 | checkIdentical(length(res), 1L) 50 | } 51 | 52 | ## "filterMultiples" 53 | test_mapIds_filterMultiples <- function(){ 54 | res <- mapIds(org.Hs.eg.db, keys=k, column='PFAM', keytype='ENTREZID', 55 | multiVals="filter") 56 | checkTrue(length(res) < length(k)) ## multi matchers means should be shorter 57 | checkTrue(res[['10']] == "PF00797") 58 | checkTrue(res[['1']] == "PF13895") 59 | checkTrue(class(res)=='character') 60 | 61 | res <- mapIds(org.Hs.eg.db, "2", "PFAM", "ENTREZID", multiVals = "filter") 62 | checkTrue(is.character(res)) 63 | checkIdentical(length(res), 0L) 64 | } 65 | 66 | 67 | ## CUSTOM function 68 | test_mapIds_FUN <- function(){ 69 | last <- function(x){ 70 | x[[length(x)]] 71 | } 72 | res <- mapIds(org.Hs.eg.db, keys=k, column='ALIAS', keytype='ENTREZID', 73 | multiVals=last) 74 | checkTrue(length(res) == length(k)) 75 | checkTrue(res[[1]] == "A1BG") 76 | checkTrue(class(res)=='character') 77 | } 78 | -------------------------------------------------------------------------------- /R/createAnnObjs.KEGG_DB.R: -------------------------------------------------------------------------------- 1 | ### ========================================================================= 2 | ### An SQLite-based ann data package (AnnDbPkg) provides a set of pre-defined 3 | ### AnnObj objects that are created at load-time. This set depends only on 4 | ### the underlying db schema i.e. all the SQLite-based ann data packages that 5 | ### share the same underlying db schema will provide the same set of AnnObj 6 | ### objects. 7 | ### 8 | ### This file describes the set of AnnObj objects provided by any 9 | ### KEGG_DB-based package i.e. any SQLite-based ann data package based 10 | ### on the KEGG_DB schema. 11 | ### The createAnnObjs.KEGG_DB() function is the main entry point for 12 | ### this file: it is called by any KEGG_DB-based package at load-time. 13 | ### ------------------------------------------------------------------------- 14 | 15 | 16 | ### Mandatory fields: objName, Class and L2Rchain 17 | KEGG_DB_AnnDbBimap_seeds <- list( 18 | list( 19 | objName="PATHID2NAME", 20 | Class="AnnDbBimap", 21 | L2Rchain=list( 22 | list( 23 | tablename="pathway2name", 24 | Lcolname="path_id", 25 | Rcolname="path_name" 26 | ) 27 | ) 28 | ), 29 | list( 30 | objName="PATHID2EXTID", 31 | Class="AnnDbBimap", 32 | L2Rchain=list( 33 | list( 34 | tablename="pathway2gene", 35 | Lcolname="pathway_id", 36 | Rcolname="gene_or_orf_id" 37 | ) 38 | ) 39 | ), 40 | list( 41 | objName="ENZYMEID2GO", 42 | Class="AnnDbBimap", 43 | L2Rchain=list( 44 | list( 45 | tablename="ec2go", 46 | Lcolname="ec_no", 47 | Rcolname="go_id" 48 | ) 49 | ) 50 | ) 51 | ) 52 | 53 | createAnnObjs.KEGG_DB <- function(prefix, objTarget, dbconn, datacache) 54 | { 55 | checkDBSCHEMA(dbconn, "KEGG_DB") 56 | 57 | ## AnnDbBimap objects 58 | seed0 <- list( 59 | objTarget=objTarget, 60 | datacache=datacache 61 | ) 62 | ann_objs <- createAnnDbBimaps(KEGG_DB_AnnDbBimap_seeds, seed0) 63 | 64 | ## Reverse maps 65 | ann_objs$PATHNAME2ID <- revmap(ann_objs$PATHID2NAME, objName="PATHNAME2ID") 66 | ann_objs$EXTID2PATHID <- revmap(ann_objs$PATHID2EXTID, objName="EXTID2PATHID") 67 | ann_objs$GO2ENZYMEID <- revmap(ann_objs$ENZYMEID2GO, objName="GO2ENZYMEID") 68 | 69 | ## 1 special map that is not an AnnDbBimap object (just a named integer vector) 70 | ann_objs$MAPCOUNTS <- createMAPCOUNTS(dbconn, prefix) 71 | 72 | prefixAnnObjNames(ann_objs, prefix) 73 | } 74 | 75 | -------------------------------------------------------------------------------- /inst/DBschemas/SchemaGuidelines.txt: -------------------------------------------------------------------------------- 1 | SchemaGuidelines 2 | ================ 3 | 4 | We want our schemas to be as portable as possible. In particular they should 5 | be compatible with SQLite, MySQL, PostgreSQL and Oracle. 6 | All the current schemas (i.e. the *_DB.sql files in schemas_0.9/ and 7 | schemas_1.0/) have been successfully tested (i.e. imported) with SQLite 8 | (3.4.1), MySQL+InnoDB (5.0.26) and PostgreSQL (8.1.9) on a 64-bit openSUSE 9 | 10.2 system. They have not been tested on Oracle yet. 10 | 11 | o All of the *_DB.sql files must define a "metadata" table (with cols "name" 12 | and "value") and all the *.sqlite files using one of these schemas must 13 | have a 'DBSCHEMA' and a 'DBSCHEMAVERSION' entry in their "metadata" table. 14 | 15 | o Make explicit use of the NULL or NOT NULL constraint on every column (except 16 | on PRIMARY KEY cols that are implicitly NOT NULL). 17 | 18 | o Centralize all the data type definitions in the DataTypes.txt file and use 19 | them consistently across all the *_DB.sql files. 20 | 21 | o Use preferably CHAR(n) or VARCHAR(n) types instead of non-standard TEXT type 22 | for character columns. Note that n must be <= 255 for compatibility with 23 | MySQL. Don't define an INDEX (or try to put a UNIQUE constraint, which 24 | implicitly creates an INDEX) on a TEXT column since this is not portable. 25 | Also don't define an INDEX on a CHAR(n) or VARCHAR(n) column where n is 26 | large (i.e. > 80) since this is not portable either. Doing so when n <= 80 27 | should be safe though. 28 | 29 | o Always use a character type for "external" (aka "real world") ids even for 30 | ids like Entrez Gene IDs, PubMed IDs or OMIM IDs that are in fact integers. 31 | 32 | o Put PRIMARY KEY and UNIQUE definitions "in line" at the end of the column 33 | definition (after the SQL type and the NULL/NOT NULL constraint for UNIQUE). 34 | 35 | o Make the PRIMARY KEY column the first column in the CREATE TABLE statement. 36 | 37 | o Put "regular" (i.e. non PRIMARY KEY, non UNIQUE) INDEX definitions all 38 | together at the end of the *_DB.sql file. 39 | 40 | o Make sure that referenced tables are created before referencing tables. 41 | 42 | o Make the FOREIGN KEYs portable. This means that: 43 | - Use portable syntax. Putting 44 | FOREIGN KEY (col) REFERENCES table (col) 45 | inside the CREATE TABLE statement but at the end of it (after all the 46 | column definitions) is compatible with SQLite (which will just ignore 47 | it), MySQL+InnoDB and PostgreSQL. 48 | - There must be NOT NULL and UNIQUE constraints on the referenced column 49 | (typically a PRIMARY KEY). 50 | - The referencing and referenced columns must have the same type. 51 | 52 | o Prefix with an underscore the column names that store "internal" ids. 53 | 54 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_1.0/00README.TXT: -------------------------------------------------------------------------------- 1 | This directory contains version 1.0 of the full set of schemas used in the 2 | sqlite-based annotation data packages. 3 | 4 | Version 1.0 is our target for the BioC 2.2 release. 5 | 6 | Version 1.0 has been successfully tested (i.e. imported) with SQLite 7 | (3.4.1), MySQL+InnoDB (5.0.26) and PostgreSQL (8.1.9) on a 64-bit openSUSE 8 | 10.2 system. It has not been tested on Oracle yet. 9 | 10 | All the *.sqlite files using one of the 1.0 schemas must set DBSCHEMAVERSION 11 | to 1.0 in their "metadata" table. 12 | 13 | See the DataTypes.txt file for all the data types used across the 1.0 schemas. 14 | 15 | 16 | SUMMARY OF CHANGES SINCE VERSION 0.9 17 | ------------------------------------ 18 | 19 | Note that those changes are disruptive (i.e. they potentially break the 20 | SQL queries written for version 0.9). 21 | 22 | New schemas: 23 | 24 | o replaced RODENT_DB schema by MOUSE_DB and RAT_DB schemas 25 | o replaced RODENTCHIP_DB schema by MOUSECHIP_DB and RATCHIP_DB schemas 26 | o added the Inparanoid schemas: INPARANOIDHOMSA_DB, INPARANOIDMUSMU_DB, 27 | INPARANOIDRATNO_DB, INPARANOIDDROME_DB and INPARANOIDSACCE_DB 28 | o added the PFAM_DB schema 29 | 30 | All schemas: 31 | 32 | o renamed "qcdata" table -> "map_counts" 33 | 34 | All probe-based and org-based schemas: 35 | 36 | o renamed internal id "id" -> "_id" 37 | o renamed chromosome_locations.chromosome -> chromosome_locations.seqname 38 | o renamed kegg.kegg_id col -> kegg.path_id 39 | o renamed chrlengths.chr col -> chrlengths.chromosome 40 | 41 | All probe-based schemas: 42 | 43 | o moved "_id" col to last position in "probes" table 44 | o removed the "accessions" table 45 | 46 | Schemas for Human, Mouse and Rat: 47 | 48 | o added "ensembl" table 49 | 50 | HUMAN_DB and RAT_DB schemas: 51 | 52 | o added "ensembl_prot" table 53 | 54 | MOUSE_DB and MOUSECHIP_DB schemas: 55 | 56 | o added "mgi" table 57 | 58 | FLY_DB and FLYCHIP_DB schemas: 59 | 60 | o added "flybase_cg" table 61 | 62 | FLY_DB schema: 63 | 64 | o added "flybase_prot" table 65 | 66 | GO_DB schema: 67 | 68 | o renamed "term_id" cols -> "_id" 69 | o renamed "offspring_id" cols -> "_offspring_id" 70 | o renamed "parent_id" cols -> "_parent_id" 71 | o renamed "evidence" cols -> "relationship_type" 72 | o removed "gene2go_evidence" table 73 | o moved "ontology" col to 1st position in "go_ontology" table 74 | o removed go_obsolete.term_id column and made go_obsolete.go_id the 75 | new PRIMARY KEY 76 | 77 | Note that, ideally, we could add UNIQUE constraints on (_id, _parent_id) in 78 | the go_[bp|cc|mf]_parents tables and on (_id, _offspring_id) in the 79 | go_[bp|cc|mf]_offspring tables but the cost of doing this is high (+5M for 80 | the size of GO.sqlite: 37M instead of 32M). 81 | 82 | KEGG_DB schema: 83 | 84 | o renamed "gene_id" col -> "gene_or_orf_id" 85 | 86 | -------------------------------------------------------------------------------- /inst/extdata/org.testing.db/man/org.TguttataTestingSubset.eg_dbconn.Rd: -------------------------------------------------------------------------------- 1 | 2 | \name{org.TguttataTestingSubset.eg_dbconn} 3 | 4 | \alias{org.TguttataTestingSubset.eg_dbconn} 5 | \alias{org.TguttataTestingSubset.eg_dbfile} 6 | \alias{org.TguttataTestingSubset.eg_dbschema} 7 | \alias{org.TguttataTestingSubset.eg_dbInfo} 8 | 9 | 10 | \title{Collect information about the package annotation DB} 11 | 12 | \description{ 13 | Some convenience functions for getting a connection object to (or collecting 14 | information about) the package annotation DB. 15 | } 16 | 17 | \usage{ 18 | org.TguttataTestingSubset.eg_dbconn() 19 | org.TguttataTestingSubset.eg_dbfile() 20 | org.TguttataTestingSubset.eg_dbschema(file="", show.indices=FALSE) 21 | org.TguttataTestingSubset.eg_dbInfo() 22 | } 23 | 24 | \arguments{ 25 | \item{file}{ 26 | A connection, or a character string naming the file to print to (see 27 | the \code{file} argument of the \code{\link[base]{cat}} function for 28 | the details). 29 | } 30 | \item{show.indices}{ 31 | The CREATE INDEX statements are not shown by default. 32 | Use \code{show.indices=TRUE} to get them. 33 | } 34 | } 35 | 36 | \details{ 37 | \code{org.TguttataTestingSubset.eg_dbconn} returns a connection object to the 38 | package annotation DB. IMPORTANT: Don't call 39 | \code{\link[DBI:dbConnect]{dbDisconnect}} on the connection object 40 | returned by \code{org.TguttataTestingSubset.eg_dbconn} or you will break all the 41 | \code{\link[AnnotationDbi:AnnDbObj-class]{AnnDbObj}} objects defined 42 | in this package! 43 | 44 | \code{org.TguttataTestingSubset.eg_dbfile} returns the path (character string) to the 45 | package annotation DB (this is an SQLite file). 46 | 47 | \code{org.TguttataTestingSubset.eg_dbschema} prints the schema definition of the 48 | package annotation DB. 49 | 50 | \code{org.TguttataTestingSubset.eg_dbInfo} prints other information about the package 51 | annotation DB. 52 | } 53 | 54 | \value{ 55 | \code{org.TguttataTestingSubset.eg_dbconn}: a DBIConnection object representing an 56 | open connection to the package annotation DB. 57 | 58 | \code{org.TguttataTestingSubset.eg_dbfile}: a character string with the path to the 59 | package annotation DB. 60 | 61 | \code{org.TguttataTestingSubset.eg_dbschema}: none (invisible \code{NULL}). 62 | 63 | \code{org.TguttataTestingSubset.eg_dbInfo}: none (invisible \code{NULL}). 64 | } 65 | 66 | \seealso{ 67 | \code{\link[DBI:dbSendQuery]{dbGetQuery}}, 68 | \code{\link[DBI:dbConnect]{dbConnect}}, 69 | \code{\link[AnnotationDbi:AnnDbObj-class]{dbconn}}, 70 | \code{\link[AnnotationDbi:AnnDbObj-class]{dbfile}}, 71 | \code{\link[AnnotationDbi:AnnDbObj-class]{dbschema}}, 72 | \code{\link[AnnotationDbi:AnnDbObj-class]{dbInfo}} 73 | } 74 | 75 | \examples{ 76 | ## Count the number of rows in the "genes" table: 77 | dbGetQuery(org.TguttataTestingSubset.eg_dbconn(), "SELECT COUNT(*) FROM genes") 78 | 79 | ## The connection object returned by org.TguttataTestingSubset.eg_dbconn() was 80 | ## created with: 81 | dbConnect(SQLite(), dbname=org.TguttataTestingSubset.eg_dbfile(), cache_size=64000, 82 | synchronous="off") 83 | 84 | org.TguttataTestingSubset.eg_dbschema() 85 | 86 | org.TguttataTestingSubset.eg_dbInfo() 87 | } 88 | 89 | \keyword{utilities} 90 | \keyword{datasets} 91 | 92 | -------------------------------------------------------------------------------- /R/methods-OrthologyDb.R: -------------------------------------------------------------------------------- 1 | ## Code specifically for the Orthology.eg.db package 2 | ## the underlying DB only has two tables, one that has 3 | ## species -> taxonid mappings, and another that has 4 | ## taxon/gene -> othertaxon/gene orthology mappings 5 | ## we have to map the column and keytype to taxon ID 6 | ## and then make the query between taxa 7 | 8 | .keyColMapper <- function(x, colOrKey){ 9 | colOrKey <- toupper(sub("\\.", "_", colOrKey)) 10 | taxonid <- dbGetQuery(dbconn(x), paste0("select taxid from names where name='", colOrKey, "';")) 11 | taxonid 12 | } 13 | 14 | ## This part refactored in 11/2022. 15 | ## the genes table in the underlying DB was converted to have 16 | ## each row duplicated in reverse order, which makes lookups easier 17 | ## e.g., its now like this where the second row is the reverse map of the first 18 | ## 19 | ## taxid gene_id other_taxid other_gene_id 20 | ## 9606 100 10090 12345 21 | ## 10090 12345 9606 100 22 | ## 23 | ## What this gains us is quicker direct lookups 24 | ## e.g., we can get from human to mouse and vice versa 25 | ## by just doing a query on gene_id -> other_gene_id 26 | ## 27 | ## Also, there are any number of mappings that are like this: 28 | 29 | ## taxid gene_id other_taxid other_gene_id 30 | ## 8030 100136351 9606 5894 31 | ## 9606 5894 7955 557109 32 | 33 | ## Where there isn't a direct mapping from 8030 -> 7955, 34 | ## but there is an implicit mapping from 8030 -> 9606 -> 7955 35 | ## By duplicating the rows we can make a performant lookup that 36 | ## includes any mapping via a single extra species 37 | 38 | .straightQuery <- function(x, fromTax, toTax, keys){ 39 | sql <- paste0("SELECT gene_id, other_gene_id FROM genes WHERE ", 40 | "taxid = '", fromTax, "' AND other_taxid='", toTax, "' AND ", 41 | "gene_id IN ('", paste(keys, collapse = "','"), "');") 42 | res <- dbGetQuery(dbconn(x), sql) 43 | res 44 | } 45 | 46 | .doubleQuery <- function(x, fromTax, toTax, keys){ 47 | sql <- paste0("SELECT G1.gene_id, G2.other_gene_id FROM genes ", 48 | "AS G1 INNER JOIN genes AS G2 ON G1.other_gene_id=G2.gene_id ", 49 | "WHERE G1.taxid='", fromTax, "' AND G2.other_taxid='", 50 | toTax, "' AND G1.gene_id IN ('", paste(keys, collapse = "','"), 51 | "');") 52 | res <- dbGetQuery(dbconn(x), sql) 53 | res 54 | } 55 | 56 | 57 | ## select function for Ontology.eg.db package 58 | .selectOnto <- function(x, keys, columns, keytype, ...){ 59 | fromTax <- .keyColMapper(x, keytype) 60 | toTax <- .keyColMapper(x, columns) 61 | res <- rbind(.straightQuery(x, fromTax, toTax, keys), 62 | .doubleQuery(x, fromTax, toTax, keys)) 63 | out <- data.frame(keys, rep(NA, length(keys))) 64 | names(out) <- c(keytype, columns) 65 | out[,2] <- res[match(out[,1], res[,1]),2] 66 | out 67 | 68 | } 69 | 70 | .ontoKeys <- function(x, keytype) { 71 | tax <- .keyColMapper(x, keytype) 72 | sql <- paste0("SELECT gene_id FROM genes WHERE taxid='", 73 | tax, "' UNION SELECT other_gene_id FROM ", 74 | "genes WHERE other_taxid='", tax, "';") 75 | res <- dbGetQuery(dbconn(x), sql)[,1] 76 | res 77 | } 78 | 79 | .justFirstUpper <- function(string){ 80 | stringlst <- strsplit(string, "") 81 | gsub("_", ".", do.call(c, lapply(stringlst, function(x) paste(c(x[1], tolower(x[-1])), collapse = "")))) 82 | } 83 | 84 | 85 | 86 | -------------------------------------------------------------------------------- /R/AnnDbPkg-templates-common.R: -------------------------------------------------------------------------------- 1 | ### The functions below are shared across all SQLite-based ann data packages. 2 | ### They're centralized here and used in the templates of the ann data 3 | ### packages instead of being redefined over and over in every templates. 4 | 5 | ### Used at load time (in .onLoad) by the SQLite-based ann data package to 6 | ### dynamically add exported symbols to its namespace environment. 7 | 8 | .kosherPkg <- function(pkgname){ 9 | if(pkgname %in% c('PFAM.db','mpedbarray.db','pedbarrayv9.db', 10 | 'pedbarrayv10.db','humanCHRLOC','mouseCHRLOC', 11 | 'ratCHRLOC')){ 12 | return(FALSE) 13 | }else{ 14 | return(TRUE) 15 | } 16 | } 17 | 18 | addToNamespaceAndExport <- function(x, value, pkgname) 19 | { 20 | prefix <- sub('.db','',pkgname) 21 | dc <- eval(parse(text=paste0(pkgname,":::datacache"))) 22 | warnIfDep <- function(){ 23 | if(grepl("CHR$",x)){ 24 | bimapName <- paste0(prefix,"CHR") 25 | }else if(grepl("CHRLENGTHS$",x)){ 26 | bimapName <- paste0(prefix,"CHRLENGTHS") 27 | }else if(grepl("CHRLOC$",x)){ 28 | bimapName <- paste0(prefix,"CHRLOC") 29 | }else if(grepl("CHRLOCEND$",x)){ 30 | bimapName <- paste0(prefix,"CHRLOCEND") 31 | } 32 | x <- dc[[bimapName]] 33 | x 34 | } 35 | warnIfDef <- function(){ 36 | if(grepl("PFAM",x)){ 37 | bimapName <- paste0(prefix,"PFAM") 38 | }else{ 39 | bimapName <- paste0(prefix,"PROSITE") 40 | } 41 | x <- dc[[bimapName]] 42 | msg = wmsg(paste0(bimapName, 43 | " is defunct. ", 44 | "Please use select() if you need access to PFAM or PROSITE accessions. \n")) 45 | if(interactive()){ 46 | stop(msg) 47 | } 48 | } 49 | ns <- asNamespace(pkgname) 50 | ## Uncomment after the release 51 | if(grepl("CHR",x) && .kosherPkg(pkgname)){ 52 | assign(x, value, envir=dc) ## stash it, for later retrieval 53 | makeActiveBinding(sym=x, fun=warnIfDep, env=ns) 54 | }else 55 | if(any(grepl("PFAM",x), grepl("PROSITE",x)) && .kosherPkg(pkgname)){ 56 | assign(x, value, envir=dc) ## stash it 57 | makeActiveBinding(sym=x, fun=warnIfDef, env=ns) 58 | }else{ 59 | assign(x, value, envir=ns) ## Older way of doing this. 60 | } 61 | namespaceExport(ns, x) 62 | } 63 | 64 | mergeToNamespaceAndExport <- function(envir, pkgname) 65 | { 66 | keys <- ls(envir, all.names=TRUE) 67 | for (key in keys) 68 | addToNamespaceAndExport(key, envir[[key]], pkgname) 69 | } 70 | 71 | 72 | ## debug(AnnotationDbi:::mergeToNamespaceAndExport); 73 | ## debug(AnnotationDbi:::addToNamespaceAndExport); 74 | ## library(org.Hs.eg.db) 75 | ## I am stuck on how to use makeActiveBinding() correctly 76 | 77 | ## It's clear I need to use it INSTEAD of assign(). But the problem 78 | ## is that x is currently pointing to a character vector and no value is available for 79 | 80 | ## So basically, I think that warnIf needs to re-run the code that 81 | ## produces the symbols (so as to re-create them on the fly). BUT: I 82 | ## can't do that without a mountain of refactoring (templating system 83 | ## is in way). 84 | 85 | ## SO: I need a way to stash the initial envs so that I can read them 86 | ## in later on... (Save the initial env as well as the key names). 87 | 88 | ## BUT: if I have to do that, how can I hide the envir with the 89 | ## goodies in it? Anonymous env? 90 | ## new.env(parent=emptyenv()) 91 | 92 | ## Hervé reminded me that we have this datacache env already. So I will just use that... 93 | 94 | ## 95 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.0/PFAM_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata ( 2 | name TEXT, 3 | value TEXT 4 | ); 5 | CREATE TABLE cazy ( 6 | ac VARCHAR(12) NOT NULL, --AC ID 7 | cazy VARCHAR(6) NOT NULL --CAZY ID 8 | ); 9 | CREATE TABLE homstrad ( 10 | ac VARCHAR(12) NOT NULL, --AC ID 11 | homstrad VARCHAR(20) NOT NULL --HOMSTRAD ID 12 | ); 13 | CREATE TABLE interpro ( 14 | ac VARCHAR(12) NOT NULL, --AC ID 15 | interpro VARCHAR(9) NOT NULL --INTERPRO ID 16 | ); 17 | CREATE TABLE load ( 18 | ac VARCHAR(12) NOT NULL, --AC ID 19 | load VARCHAR(15) NOT NULL --LOAD ID 20 | ); 21 | CREATE TABLE merops ( 22 | ac VARCHAR(12) NOT NULL, --AC ID 23 | merops VARCHAR(3) NOT NULL --MEROPS ID 24 | ); 25 | CREATE TABLE mim ( 26 | ac VARCHAR(12) NOT NULL, --AC ID 27 | mim VARCHAR(6) NOT NULL --MIM ID 28 | ); 29 | CREATE TABLE pdb ( 30 | ac VARCHAR(12) NOT NULL, --AC ID 31 | pdb VARCHAR(6) NOT NULL, --PDB ID 32 | start_point INTEGER, --start of alignment 33 | end_point INTEGER --end of alignment 34 | ); 35 | CREATE TABLE prints ( 36 | ac VARCHAR(12) NOT NULL, --AC ID 37 | prints VARCHAR(7) NOT NULL --PRINTS ID 38 | ); 39 | CREATE TABLE prosite ( 40 | ac VARCHAR(12) NOT NULL, --AC ID 41 | prosite VARCHAR(9) NOT NULL --PROSITE ID 42 | ); 43 | CREATE TABLE prosite_profile ( 44 | ac VARCHAR(12) NOT NULL, --AC ID 45 | prosite_profile VARCHAR(7) NOT NULL --PROSITE_PROFILE ID 46 | ); 47 | CREATE TABLE rm ( 48 | ac VARCHAR(12) NOT NULL, --AC ID 49 | rm VARCHAR(8) NOT NULL --RM ID 50 | ); 51 | CREATE TABLE scop ( 52 | ac VARCHAR(12) NOT NULL, --AC ID 53 | scop VARCHAR(4) NOT NULL, --SCOP ID 54 | placement VARCHAR(2) NOT NULL --SCOP placement 55 | ); 56 | CREATE TABLE smart ( 57 | ac VARCHAR(12) NOT NULL, --AC ID 58 | smart VARCHAR(9) NOT NULL --SMART ID 59 | ); 60 | CREATE TABLE tc ( 61 | ac VARCHAR(12) NOT NULL, --AC ID 62 | tc VARCHAR(6) NOT NULL --TC ID 63 | ); 64 | CREATE TABLE url ( 65 | ac VARCHAR(12) NOT NULL, --AC ID 66 | url VARCHAR(80) NOT NULL --URL ID 67 | ); 68 | CREATE TABLE id ( 69 | ac VARCHAR(12) NOT NULL, --AC ID 70 | id VARCHAR(15) NOT NULL --ID ID 71 | ); 72 | CREATE TABLE de ( 73 | ac VARCHAR(12) NOT NULL, --AC ID 74 | de VARCHAR(80) NOT NULL --DE ID 75 | ); 76 | CREATE TABLE tp ( 77 | ac VARCHAR(12) NOT NULL, --AC ID 78 | tp VARCHAR(6) NOT NULL --TP ID 79 | ); 80 | CREATE TABLE map_metadata ( 81 | map_name VARCHAR(80) NOT NULL, 82 | source_name VARCHAR(80) NOT NULL, 83 | source_url VARCHAR(255) NOT NULL, 84 | source_date VARCHAR(20) NOT NULL 85 | ); 86 | CREATE TABLE map_counts ( 87 | map_name VARCHAR(80) PRIMARY KEY, 88 | count INTEGER NOT NULL 89 | ); 90 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 91 | 92 | -- Explicit index creation on the referencing column of all the foreign keys. 93 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 94 | -- indexes automatically. 95 | CREATE INDEX cazy_ac ON cazy(ac); 96 | CREATE INDEX homstrad_ac ON homstrad(ac); 97 | CREATE INDEX interpro_ac ON interpro(ac); 98 | CREATE INDEX load_ac ON load(ac); 99 | CREATE INDEX merops_ac ON merops(ac); 100 | CREATE INDEX mim_ac ON mim(ac); 101 | CREATE INDEX pdb_ac ON pdb(ac); 102 | CREATE INDEX prints_ac ON prints(ac); 103 | CREATE INDEX prosite_ac ON prosite(ac); 104 | CREATE INDEX prosite_profile_ac ON prosite_profile(ac); 105 | CREATE INDEX rm_ac ON rm(ac); 106 | CREATE INDEX scop_ac ON scop(ac); 107 | CREATE INDEX smart_ac ON smart(ac); 108 | CREATE INDEX tc_ac ON tc(ac); 109 | CREATE INDEX url_ac ON url(ac); 110 | CREATE INDEX id_ac ON id(ac); 111 | CREATE INDEX de_ac ON de(ac); 112 | CREATE INDEX tp_ac ON tp(ac); 113 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.1/PFAM_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata ( 2 | name TEXT, 3 | value TEXT 4 | ); 5 | CREATE TABLE cazy ( 6 | ac VARCHAR(12) NOT NULL, --AC ID 7 | cazy VARCHAR(6) NOT NULL --CAZY ID 8 | ); 9 | CREATE TABLE homstrad ( 10 | ac VARCHAR(12) NOT NULL, --AC ID 11 | homstrad VARCHAR(20) NOT NULL --HOMSTRAD ID 12 | ); 13 | CREATE TABLE interpro ( 14 | ac VARCHAR(12) NOT NULL, --AC ID 15 | interpro VARCHAR(9) NOT NULL --INTERPRO ID 16 | ); 17 | CREATE TABLE load ( 18 | ac VARCHAR(12) NOT NULL, --AC ID 19 | load VARCHAR(15) NOT NULL --LOAD ID 20 | ); 21 | CREATE TABLE merops ( 22 | ac VARCHAR(12) NOT NULL, --AC ID 23 | merops VARCHAR(3) NOT NULL --MEROPS ID 24 | ); 25 | CREATE TABLE mim ( 26 | ac VARCHAR(12) NOT NULL, --AC ID 27 | mim VARCHAR(6) NOT NULL --MIM ID 28 | ); 29 | CREATE TABLE pdb ( 30 | ac VARCHAR(12) NOT NULL, --AC ID 31 | pdb VARCHAR(6) NOT NULL, --PDB ID 32 | start_point INTEGER, --start of alignment 33 | end_point INTEGER --end of alignment 34 | ); 35 | CREATE TABLE prints ( 36 | ac VARCHAR(12) NOT NULL, --AC ID 37 | prints VARCHAR(7) NOT NULL --PRINTS ID 38 | ); 39 | CREATE TABLE prosite ( 40 | ac VARCHAR(12) NOT NULL, --AC ID 41 | prosite VARCHAR(9) NOT NULL --PROSITE ID 42 | ); 43 | CREATE TABLE prosite_profile ( 44 | ac VARCHAR(12) NOT NULL, --AC ID 45 | prosite_profile VARCHAR(7) NOT NULL --PROSITE_PROFILE ID 46 | ); 47 | CREATE TABLE rm ( 48 | ac VARCHAR(12) NOT NULL, --AC ID 49 | rm VARCHAR(8) NOT NULL --RM ID 50 | ); 51 | CREATE TABLE scop ( 52 | ac VARCHAR(12) NOT NULL, --AC ID 53 | scop VARCHAR(4) NOT NULL, --SCOP ID 54 | placement VARCHAR(2) NOT NULL --SCOP placement 55 | ); 56 | CREATE TABLE smart ( 57 | ac VARCHAR(12) NOT NULL, --AC ID 58 | smart VARCHAR(9) NOT NULL --SMART ID 59 | ); 60 | CREATE TABLE tc ( 61 | ac VARCHAR(12) NOT NULL, --AC ID 62 | tc VARCHAR(6) NOT NULL --TC ID 63 | ); 64 | CREATE TABLE url ( 65 | ac VARCHAR(12) NOT NULL, --AC ID 66 | url VARCHAR(80) NOT NULL --URL ID 67 | ); 68 | CREATE TABLE id ( 69 | ac VARCHAR(12) NOT NULL, --AC ID 70 | id VARCHAR(15) NOT NULL --ID ID 71 | ); 72 | CREATE TABLE de ( 73 | ac VARCHAR(12) NOT NULL, --AC ID 74 | de VARCHAR(80) NOT NULL --DE ID 75 | ); 76 | CREATE TABLE tp ( 77 | ac VARCHAR(12) NOT NULL, --AC ID 78 | tp VARCHAR(6) NOT NULL --TP ID 79 | ); 80 | CREATE TABLE map_metadata ( 81 | map_name VARCHAR(80) NOT NULL, 82 | source_name VARCHAR(80) NOT NULL, 83 | source_url VARCHAR(255) NOT NULL, 84 | source_date VARCHAR(20) NOT NULL 85 | ); 86 | CREATE TABLE map_counts ( 87 | map_name VARCHAR(80) PRIMARY KEY, 88 | count INTEGER NOT NULL 89 | ); 90 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 91 | 92 | -- Explicit index creation on the referencing column of all the foreign keys. 93 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 94 | -- indexes automatically. 95 | CREATE INDEX cazy_ac ON cazy(ac); 96 | CREATE INDEX homstrad_ac ON homstrad(ac); 97 | CREATE INDEX interpro_ac ON interpro(ac); 98 | CREATE INDEX load_ac ON load(ac); 99 | CREATE INDEX merops_ac ON merops(ac); 100 | CREATE INDEX mim_ac ON mim(ac); 101 | CREATE INDEX pdb_ac ON pdb(ac); 102 | CREATE INDEX prints_ac ON prints(ac); 103 | CREATE INDEX prosite_ac ON prosite(ac); 104 | CREATE INDEX prosite_profile_ac ON prosite_profile(ac); 105 | CREATE INDEX rm_ac ON rm(ac); 106 | CREATE INDEX scop_ac ON scop(ac); 107 | CREATE INDEX smart_ac ON smart(ac); 108 | CREATE INDEX tc_ac ON tc(ac); 109 | CREATE INDEX url_ac ON url(ac); 110 | CREATE INDEX id_ac ON id(ac); 111 | CREATE INDEX de_ac ON de(ac); 112 | CREATE INDEX tp_ac ON tp(ac); 113 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_1.0/MALARIA_DB.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- MALARIA_DB schema 3 | -- =============== 4 | -- 5 | 6 | -- The "genes" table is the central table. 7 | CREATE TABLE genes ( 8 | _id INTEGER PRIMARY KEY, 9 | gene_id VARCHAR(10) NOT NULL UNIQUE -- Entrez Gene ID 10 | ); 11 | 12 | CREATE TABLE alias ( 13 | _id INTEGER NOT NULL, -- REFERENCES genes 14 | alias_symbol VARCHAR(80) NOT NULL, -- gene symbol or alias 15 | FOREIGN KEY (_id) REFERENCES genes (_id) 16 | ); 17 | CREATE TABLE ec ( 18 | _id INTEGER NOT NULL, -- REFERENCES genes 19 | ec_number VARCHAR(13) NOT NULL, -- EC number (no "EC:" prefix) 20 | FOREIGN KEY (_id) REFERENCES genes (_id) 21 | ); 22 | CREATE TABLE gene_info ( 23 | _id INTEGER NOT NULL UNIQUE, -- REFERENCES genes 24 | gene_name VARCHAR(255) NOT NULL, -- gene name 25 | symbol VARCHAR(80) NOT NULL, -- gene symbol 26 | FOREIGN KEY (_id) REFERENCES genes (_id) 27 | ); 28 | CREATE TABLE go_bp ( 29 | _id INTEGER NOT NULL, -- REFERENCES genes 30 | go_id CHAR(10) NOT NULL, -- GO ID 31 | evidence CHAR(3) NOT NULL, -- GO evidence code 32 | FOREIGN KEY (_id) REFERENCES genes (_id) 33 | ); 34 | CREATE TABLE go_bp_all ( 35 | _id INTEGER NOT NULL, -- REFERENCES genes 36 | go_id CHAR(10) NOT NULL, -- GO ID 37 | evidence CHAR(3) NOT NULL, -- GO evidence code 38 | FOREIGN KEY (_id) REFERENCES genes (_id) 39 | ); 40 | CREATE TABLE go_cc ( 41 | _id INTEGER NOT NULL, -- REFERENCES genes 42 | go_id CHAR(10) NOT NULL, -- GO ID 43 | evidence CHAR(3) NOT NULL, -- GO evidence code 44 | FOREIGN KEY (_id) REFERENCES genes (_id) 45 | ); 46 | CREATE TABLE go_cc_all ( 47 | _id INTEGER NOT NULL, -- REFERENCES genes 48 | go_id CHAR(10) NOT NULL, -- GO ID 49 | evidence CHAR(3) NOT NULL, -- GO evidence code 50 | FOREIGN KEY (_id) REFERENCES genes (_id) 51 | ); 52 | CREATE TABLE go_mf ( 53 | _id INTEGER NOT NULL, -- REFERENCES genes 54 | go_id CHAR(10) NOT NULL, -- GO ID 55 | evidence CHAR(3) NOT NULL, -- GO evidence code 56 | FOREIGN KEY (_id) REFERENCES genes (_id) 57 | ); 58 | CREATE TABLE go_mf_all ( 59 | _id INTEGER NOT NULL, -- REFERENCES genes 60 | go_id CHAR(10) NOT NULL, -- GO ID 61 | evidence CHAR(3) NOT NULL, -- GO evidence code 62 | FOREIGN KEY (_id) REFERENCES genes (_id) 63 | ); 64 | CREATE TABLE kegg ( 65 | _id INTEGER NOT NULL, -- REFERENCES genes 66 | path_id CHAR(5) NOT NULL, -- KEGG pathway short ID 67 | FOREIGN KEY (_id) REFERENCES genes (_id) 68 | ); 69 | 70 | -- Metadata tables. 71 | CREATE TABLE metadata ( 72 | name VARCHAR(80) PRIMARY KEY, 73 | value VARCHAR(255) 74 | ); 75 | CREATE TABLE map_counts ( 76 | map_name VARCHAR(80) PRIMARY KEY, 77 | count INTEGER NOT NULL 78 | ); 79 | CREATE TABLE map_metadata ( 80 | map_name VARCHAR(80) NOT NULL, 81 | source_name VARCHAR(80) NOT NULL, 82 | source_url VARCHAR(255) NOT NULL, 83 | source_date VARCHAR(20) NOT NULL 84 | ); 85 | 86 | -- Explicit index creation on the referencing column of all the foreign keys. 87 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 88 | -- indexes automatically. 89 | CREATE INDEX Falias ON alias (_id); 90 | CREATE INDEX Fec ON ec (_id); 91 | CREATE INDEX Fgo_bp ON go_bp (_id); 92 | CREATE INDEX Fgo_bp_all ON go_bp_all (_id); 93 | CREATE INDEX Fgo_cc ON go_cc (_id); 94 | CREATE INDEX Fgo_cc_all ON go_cc_all (_id); 95 | CREATE INDEX Fgo_mf ON go_mf (_id); 96 | CREATE INDEX Fgo_mf_all ON go_mf_all (_id); 97 | CREATE INDEX Fkegg ON kegg (_id); 98 | 99 | -------------------------------------------------------------------------------- /man/Bimap-envirAPI.Rd: -------------------------------------------------------------------------------- 1 | \name{Bimap-envirAPI} 2 | 3 | \alias{Bimap-envirAPI} 4 | 5 | \alias{ls} 6 | \alias{ls,Bimap-method} 7 | 8 | \alias{exists} 9 | \alias{exists,ANY,ANY,Bimap-method} 10 | \alias{exists,ANY,Bimap,missing-method} 11 | 12 | 13 | \alias{get} 14 | \alias{get,ANY,ANY,Bimap-method} 15 | \alias{get,ANY,Bimap,missing-method} 16 | 17 | \alias{[[,Bimap-method} 18 | 19 | \alias{$,Bimap-method} 20 | 21 | \alias{mget} 22 | \alias{mget,Bimap-method} 23 | \alias{mget,ANY,Bimap-method} 24 | 25 | \alias{eapply} 26 | \alias{eapply,Bimap-method} 27 | 28 | \alias{contents,Bimap-method} 29 | 30 | \alias{sample} 31 | \alias{sample,Bimap-method} 32 | \alias{sample,environment-method} 33 | 34 | 35 | \title{Environment-like API for Bimap objects} 36 | 37 | \description{ 38 | These methods allow the user to manipulate any \link{Bimap} object as 39 | if it was an environment. This environment-like API is provided for 40 | backward compatibility with the traditional environment-based maps. 41 | } 42 | 43 | \usage{ 44 | ls(name, pos = -1L, envir = as.environment(pos), all.names = FALSE, 45 | pattern, sorted = TRUE) 46 | exists(x, where, envir, frame, mode, inherits) 47 | get(x, pos, envir, mode, inherits) 48 | #x[[i]] 49 | #x$name 50 | 51 | ## Converting to a list 52 | mget(x, envir, mode, ifnotfound, inherits) 53 | eapply(env, FUN, ..., all.names, USE.NAMES) 54 | 55 | ## Additional convenience method 56 | sample(x, size, replace=FALSE, prob=NULL, ...) 57 | } 58 | 59 | \arguments{ 60 | \item{name}{ 61 | A \link{Bimap} object for \code{ls}. 62 | A key as a literal character string or a name (possibly backtick quoted) 63 | for \code{x$name}. 64 | } 65 | \item{pos, all.names, USE.NAMES, where, frame, mode, inherits}{ 66 | Ignored. 67 | } 68 | \item{envir}{ 69 | Ignored for \code{ls}. A \link{Bimap} object for \code{mget}, 70 | \code{get} and \code{exists}. 71 | } 72 | \item{pattern}{ 73 | An optional regular expression. Only keys matching 'pattern' are returned. 74 | } 75 | \item{x}{ 76 | The key(s) to search for for \code{exists}, \code{get} and \code{mget}. 77 | A \link{Bimap} object for \code{[[} and \code{x$name}. 78 | A \link{Bimap} object or an environment for \code{sample}. 79 | } 80 | \item{i}{ 81 | Single key specifying the map element to extract. 82 | } 83 | \item{ifnotfound}{ 84 | A value to be used if the key is not found. Only \code{NA} is currently 85 | supported. 86 | } 87 | \item{env}{ 88 | A \link{Bimap} object. 89 | } 90 | \item{FUN}{ 91 | The function to be applied (see original \code{\link[base:eapply]{eapply}} 92 | for environments for the details). 93 | } 94 | \item{...}{ 95 | Optional arguments to \code{FUN}. 96 | } 97 | \item{size}{ 98 | Non-negative integer giving the number of map elements to choose. 99 | } 100 | \item{replace}{ 101 | Should sampling be with replacement? 102 | } 103 | \item{prob}{ 104 | A vector of probability weights for obtaining the elements of the map 105 | being sampled. 106 | } 107 | \item{sorted}{ 108 | \code{logical(1)}. When TRUE (default), return primary keys in 109 | sorted order. 110 | } 111 | } 112 | 113 | \seealso{ 114 | \code{\link[base:ls]{ls}}, 115 | \code{\link[base:exists]{exists}}, 116 | \code{\link[base:get]{get}}, 117 | \code{\link[base:get]{mget}}, 118 | \code{\link[base:eapply]{eapply}}, 119 | \code{\link[base:sample]{sample}}, 120 | \link{BimapFormatting}, 121 | \link{Bimap} 122 | } 123 | 124 | \examples{ 125 | library(hgu95av2.db) 126 | x <- hgu95av2CHRLOC 127 | 128 | ls(x)[1:3] 129 | exists(ls(x)[1], x) 130 | exists("titi", x) 131 | get(ls(x)[1], x) 132 | x[[ls(x)[1]]] 133 | x$titi # NULL 134 | 135 | mget(ls(x)[1:3], x) 136 | eapply(x, length) 137 | 138 | sample(x, 3) 139 | } 140 | 141 | \keyword{methods} 142 | \keyword{interface} 143 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_1.0/PIG_DB.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- PIG_DB schema 3 | -- =============== 4 | -- 5 | 6 | -- The "genes" table is the central table. 7 | CREATE TABLE genes ( 8 | _id INTEGER PRIMARY KEY, 9 | gene_id VARCHAR(10) NOT NULL UNIQUE -- Entrez Gene ID 10 | ); 11 | 12 | -- Data linked to the "genes" table. 13 | CREATE TABLE accessions ( 14 | _id INTEGER NOT NULL, -- REFERENCES genes 15 | accession VARCHAR(20) NOT NULL, -- GenBank accession number 16 | FOREIGN KEY (_id) REFERENCES genes (_id) 17 | ); 18 | CREATE TABLE alias ( 19 | _id INTEGER NOT NULL, -- REFERENCES genes 20 | alias_symbol VARCHAR(80) NOT NULL, -- gene symbol or alias 21 | FOREIGN KEY (_id) REFERENCES genes (_id) 22 | ); 23 | CREATE TABLE chromosomes ( 24 | _id INTEGER NOT NULL, -- REFERENCES genes 25 | chromosome VARCHAR(2) NOT NULL, -- chromosome name 26 | FOREIGN KEY (_id) REFERENCES genes (_id) 27 | ); 28 | CREATE TABLE chromosome_locations ( 29 | _id INTEGER NOT NULL, -- REFERENCES genes 30 | seqname VARCHAR(20) NOT NULL, -- sequence name 31 | start_location INTEGER NOT NULL, 32 | FOREIGN KEY (_id) REFERENCES genes (_id) 33 | ); 34 | CREATE TABLE ec ( 35 | _id INTEGER NOT NULL, -- REFERENCES genes 36 | ec_number VARCHAR(13) NOT NULL, -- EC number (no "EC:" prefix) 37 | FOREIGN KEY (_id) REFERENCES genes (_id) 38 | ); 39 | CREATE TABLE gene_info ( 40 | _id INTEGER NOT NULL UNIQUE, -- REFERENCES genes 41 | gene_name VARCHAR(255) NOT NULL, -- gene name 42 | symbol VARCHAR(80) NOT NULL, -- gene symbol 43 | FOREIGN KEY (_id) REFERENCES genes (_id) 44 | ); 45 | CREATE TABLE kegg ( 46 | _id INTEGER NOT NULL, -- REFERENCES genes 47 | path_id CHAR(5) NOT NULL, -- KEGG pathway short ID 48 | FOREIGN KEY (_id) REFERENCES genes (_id) 49 | ); 50 | CREATE TABLE pubmed ( 51 | _id INTEGER NOT NULL, -- REFERENCES genes 52 | pubmed_id VARCHAR(10) NOT NULL, -- PubMed ID 53 | FOREIGN KEY (_id) REFERENCES genes (_id) 54 | ); 55 | CREATE TABLE refseq ( 56 | _id INTEGER NOT NULL, -- REFERENCES genes 57 | accession VARCHAR(20) NOT NULL, -- RefSeq accession number 58 | FOREIGN KEY (_id) REFERENCES genes (_id) 59 | ); 60 | CREATE TABLE unigene ( 61 | _id INTEGER NOT NULL, -- REFERENCES genes 62 | unigene_id VARCHAR(10) NOT NULL, -- UniGene ID 63 | FOREIGN KEY (_id) REFERENCES genes (_id) 64 | ); 65 | 66 | -- Standalone data tables. 67 | CREATE TABLE chrlengths ( 68 | chromosome VARCHAR(2) PRIMARY KEY, -- chromosome name 69 | length INTEGER NOT NULL 70 | ); 71 | 72 | -- Metadata tables. 73 | CREATE TABLE metadata ( 74 | name VARCHAR(80) PRIMARY KEY, 75 | value VARCHAR(255) 76 | ); 77 | CREATE TABLE map_counts ( 78 | map_name VARCHAR(80) PRIMARY KEY, 79 | count INTEGER NOT NULL 80 | ); 81 | CREATE TABLE map_metadata ( 82 | map_name VARCHAR(80) NOT NULL, 83 | source_name VARCHAR(80) NOT NULL, 84 | source_url VARCHAR(255) NOT NULL, 85 | source_date VARCHAR(20) NOT NULL 86 | ); 87 | 88 | -- Explicit index creation on the referencing column of all the foreign keys. 89 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 90 | -- indexes automatically. 91 | CREATE INDEX Faccessions ON accessions (_id); 92 | CREATE INDEX Falias ON alias (_id); 93 | CREATE INDEX Fchromosomes ON chromosomes (_id); 94 | CREATE INDEX Fchromosome_locations ON chromosome_locations (_id); 95 | CREATE INDEX Fec ON ec (_id); 96 | CREATE INDEX Fkegg ON kegg (_id); 97 | CREATE INDEX Fpubmed ON pubmed (_id); 98 | CREATE INDEX Frefseq ON refseq (_id); 99 | CREATE INDEX Funigene ON unigene (_id); 100 | 101 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_1.0/CANINE_DB.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- CANINE_DB schema 3 | -- =============== 4 | -- 5 | 6 | -- The "genes" table is the central table. 7 | CREATE TABLE genes ( 8 | _id INTEGER PRIMARY KEY, 9 | gene_id VARCHAR(10) NOT NULL UNIQUE -- Entrez Gene ID 10 | ); 11 | 12 | -- Data linked to the "genes" table. 13 | CREATE TABLE accessions ( 14 | _id INTEGER NOT NULL, -- REFERENCES genes 15 | accession VARCHAR(20) NOT NULL, -- GenBank accession number 16 | FOREIGN KEY (_id) REFERENCES genes (_id) 17 | ); 18 | CREATE TABLE alias ( 19 | _id INTEGER NOT NULL, -- REFERENCES genes 20 | alias_symbol VARCHAR(80) NOT NULL, -- gene symbol or alias 21 | FOREIGN KEY (_id) REFERENCES genes (_id) 22 | ); 23 | CREATE TABLE chromosomes ( 24 | _id INTEGER NOT NULL, -- REFERENCES genes 25 | chromosome VARCHAR(2) NOT NULL, -- chromosome name 26 | FOREIGN KEY (_id) REFERENCES genes (_id) 27 | ); 28 | CREATE TABLE chromosome_locations ( 29 | _id INTEGER NOT NULL, -- REFERENCES genes 30 | seqname VARCHAR(20) NOT NULL, -- sequence name 31 | start_location INTEGER NOT NULL, 32 | FOREIGN KEY (_id) REFERENCES genes (_id) 33 | ); 34 | CREATE TABLE ec ( 35 | _id INTEGER NOT NULL, -- REFERENCES genes 36 | ec_number VARCHAR(13) NOT NULL, -- EC number (no "EC:" prefix) 37 | FOREIGN KEY (_id) REFERENCES genes (_id) 38 | ); 39 | CREATE TABLE gene_info ( 40 | _id INTEGER NOT NULL UNIQUE, -- REFERENCES genes 41 | gene_name VARCHAR(255) NOT NULL, -- gene name 42 | symbol VARCHAR(80) NOT NULL, -- gene symbol 43 | FOREIGN KEY (_id) REFERENCES genes (_id) 44 | ); 45 | CREATE TABLE kegg ( 46 | _id INTEGER NOT NULL, -- REFERENCES genes 47 | path_id CHAR(5) NOT NULL, -- KEGG pathway short ID 48 | FOREIGN KEY (_id) REFERENCES genes (_id) 49 | ); 50 | CREATE TABLE pubmed ( 51 | _id INTEGER NOT NULL, -- REFERENCES genes 52 | pubmed_id VARCHAR(10) NOT NULL, -- PubMed ID 53 | FOREIGN KEY (_id) REFERENCES genes (_id) 54 | ); 55 | CREATE TABLE refseq ( 56 | _id INTEGER NOT NULL, -- REFERENCES genes 57 | accession VARCHAR(20) NOT NULL, -- RefSeq accession number 58 | FOREIGN KEY (_id) REFERENCES genes (_id) 59 | ); 60 | CREATE TABLE unigene ( 61 | _id INTEGER NOT NULL, -- REFERENCES genes 62 | unigene_id VARCHAR(10) NOT NULL, -- UniGene ID 63 | FOREIGN KEY (_id) REFERENCES genes (_id) 64 | ); 65 | 66 | -- Standalone data tables. 67 | CREATE TABLE chrlengths ( 68 | chromosome VARCHAR(2) PRIMARY KEY, -- chromosome name 69 | length INTEGER NOT NULL 70 | ); 71 | 72 | -- Metadata tables. 73 | CREATE TABLE metadata ( 74 | name VARCHAR(80) PRIMARY KEY, 75 | value VARCHAR(255) 76 | ); 77 | CREATE TABLE map_counts ( 78 | map_name VARCHAR(80) PRIMARY KEY, 79 | count INTEGER NOT NULL 80 | ); 81 | CREATE TABLE map_metadata ( 82 | map_name VARCHAR(80) NOT NULL, 83 | source_name VARCHAR(80) NOT NULL, 84 | source_url VARCHAR(255) NOT NULL, 85 | source_date VARCHAR(20) NOT NULL 86 | ); 87 | 88 | -- Explicit index creation on the referencing column of all the foreign keys. 89 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 90 | -- indexes automatically. 91 | CREATE INDEX Faccessions ON accessions (_id); 92 | CREATE INDEX Falias ON alias (_id); 93 | CREATE INDEX Fchromosomes ON chromosomes (_id); 94 | CREATE INDEX Fchromosome_locations ON chromosome_locations (_id); 95 | CREATE INDEX Fec ON ec (_id); 96 | CREATE INDEX Fkegg ON kegg (_id); 97 | CREATE INDEX Fpubmed ON pubmed (_id); 98 | CREATE INDEX Frefseq ON refseq (_id); 99 | CREATE INDEX Funigene ON unigene (_id); 100 | 101 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_1.0/PIGCHIP_DB.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- PIGCHIP_DB schema 3 | -- =================== 4 | -- 5 | 6 | -- The "genes" table is the central table. 7 | CREATE TABLE genes ( 8 | _id INTEGER PRIMARY KEY, 9 | gene_id VARCHAR(10) NOT NULL UNIQUE -- Entrez Gene ID 10 | ); 11 | 12 | -- Data linked to the "genes" table. 13 | CREATE TABLE probes ( 14 | probe_id VARCHAR(80) PRIMARY KEY, -- manufacturer ID 15 | accession VARCHAR(20) NULL, -- GenBank accession number 16 | _id INTEGER NULL, -- REFERENCES genes 17 | FOREIGN KEY (_id) REFERENCES genes (_id) 18 | ); 19 | CREATE TABLE alias ( 20 | _id INTEGER NOT NULL, -- REFERENCES genes 21 | alias_symbol VARCHAR(80) NOT NULL, -- gene symbol or alias 22 | FOREIGN KEY (_id) REFERENCES genes (_id) 23 | ); 24 | CREATE TABLE chromosomes ( 25 | _id INTEGER NOT NULL, -- REFERENCES genes 26 | chromosome VARCHAR(2) NOT NULL, -- chromosome name 27 | FOREIGN KEY (_id) REFERENCES genes (_id) 28 | ); 29 | CREATE TABLE chromosome_locations ( 30 | _id INTEGER NOT NULL, -- REFERENCES genes 31 | seqname VARCHAR(20) NOT NULL, -- sequence name 32 | start_location INTEGER NOT NULL, 33 | FOREIGN KEY (_id) REFERENCES genes (_id) 34 | ); 35 | CREATE TABLE ec ( 36 | _id INTEGER NOT NULL, -- REFERENCES genes 37 | ec_number VARCHAR(13) NOT NULL, -- EC number (no "EC:" prefix) 38 | FOREIGN KEY (_id) REFERENCES genes (_id) 39 | ); 40 | CREATE TABLE gene_info ( 41 | _id INTEGER NOT NULL UNIQUE, -- REFERENCES genes 42 | gene_name VARCHAR(255) NOT NULL, -- gene name 43 | symbol VARCHAR(80) NOT NULL, -- gene symbol 44 | FOREIGN KEY (_id) REFERENCES genes (_id) 45 | ); 46 | CREATE TABLE kegg ( 47 | _id INTEGER NOT NULL, -- REFERENCES genes 48 | path_id CHAR(5) NOT NULL, -- KEGG pathway short ID 49 | FOREIGN KEY (_id) REFERENCES genes (_id) 50 | ); 51 | CREATE TABLE pubmed ( 52 | _id INTEGER NOT NULL, -- REFERENCES genes 53 | pubmed_id VARCHAR(10) NOT NULL, -- PubMed ID 54 | FOREIGN KEY (_id) REFERENCES genes (_id) 55 | ); 56 | CREATE TABLE refseq ( 57 | _id INTEGER NOT NULL, -- REFERENCES genes 58 | accession VARCHAR(20) NOT NULL, -- RefSeq accession number 59 | FOREIGN KEY (_id) REFERENCES genes (_id) 60 | ); 61 | CREATE TABLE unigene ( 62 | _id INTEGER NOT NULL, -- REFERENCES genes 63 | unigene_id VARCHAR(10) NOT NULL, -- UniGene ID 64 | FOREIGN KEY (_id) REFERENCES genes (_id) 65 | ); 66 | 67 | -- Standalone data tables. 68 | CREATE TABLE chrlengths ( 69 | chromosome VARCHAR(2) PRIMARY KEY, -- chromosome name 70 | length INTEGER NOT NULL 71 | ); 72 | 73 | -- Metadata tables. 74 | CREATE TABLE metadata ( 75 | name VARCHAR(80) PRIMARY KEY, 76 | value VARCHAR(255) 77 | ); 78 | CREATE TABLE map_counts ( 79 | map_name VARCHAR(80) PRIMARY KEY, 80 | count INTEGER NOT NULL 81 | ); 82 | CREATE TABLE map_metadata ( 83 | map_name VARCHAR(80) NOT NULL, 84 | source_name VARCHAR(80) NOT NULL, 85 | source_url VARCHAR(255) NOT NULL, 86 | source_date VARCHAR(20) NOT NULL 87 | ); 88 | 89 | -- Explicit index creation on the referencing column of all the foreign keys. 90 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 91 | -- indexes automatically. 92 | CREATE INDEX Fprobes ON probes (_id); 93 | CREATE INDEX Falias ON alias (_id); 94 | CREATE INDEX Fchromosomes ON chromosomes (_id); 95 | CREATE INDEX Fchromosome_locations ON chromosome_locations (_id); 96 | CREATE INDEX Fec ON ec (_id); 97 | CREATE INDEX Fkegg ON kegg (_id); 98 | CREATE INDEX Fpubmed ON pubmed (_id); 99 | CREATE INDEX Frefseq ON refseq (_id); 100 | CREATE INDEX Funigene ON unigene (_id); 101 | 102 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_1.0/CANINECHIP_DB.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- CANINECHIP_DB schema 3 | -- =================== 4 | -- 5 | 6 | -- The "genes" table is the central table. 7 | CREATE TABLE genes ( 8 | _id INTEGER PRIMARY KEY, 9 | gene_id VARCHAR(10) NOT NULL UNIQUE -- Entrez Gene ID 10 | ); 11 | 12 | -- Data linked to the "genes" table. 13 | CREATE TABLE probes ( 14 | probe_id VARCHAR(80) PRIMARY KEY, -- manufacturer ID 15 | accession VARCHAR(20) NULL, -- GenBank accession number 16 | _id INTEGER NULL, -- REFERENCES genes 17 | FOREIGN KEY (_id) REFERENCES genes (_id) 18 | ); 19 | CREATE TABLE alias ( 20 | _id INTEGER NOT NULL, -- REFERENCES genes 21 | alias_symbol VARCHAR(80) NOT NULL, -- gene symbol or alias 22 | FOREIGN KEY (_id) REFERENCES genes (_id) 23 | ); 24 | CREATE TABLE chromosomes ( 25 | _id INTEGER NOT NULL, -- REFERENCES genes 26 | chromosome VARCHAR(2) NOT NULL, -- chromosome name 27 | FOREIGN KEY (_id) REFERENCES genes (_id) 28 | ); 29 | CREATE TABLE chromosome_locations ( 30 | _id INTEGER NOT NULL, -- REFERENCES genes 31 | seqname VARCHAR(20) NOT NULL, -- sequence name 32 | start_location INTEGER NOT NULL, 33 | FOREIGN KEY (_id) REFERENCES genes (_id) 34 | ); 35 | CREATE TABLE ec ( 36 | _id INTEGER NOT NULL, -- REFERENCES genes 37 | ec_number VARCHAR(13) NOT NULL, -- EC number (no "EC:" prefix) 38 | FOREIGN KEY (_id) REFERENCES genes (_id) 39 | ); 40 | CREATE TABLE gene_info ( 41 | _id INTEGER NOT NULL UNIQUE, -- REFERENCES genes 42 | gene_name VARCHAR(255) NOT NULL, -- gene name 43 | symbol VARCHAR(80) NOT NULL, -- gene symbol 44 | FOREIGN KEY (_id) REFERENCES genes (_id) 45 | ); 46 | CREATE TABLE kegg ( 47 | _id INTEGER NOT NULL, -- REFERENCES genes 48 | path_id CHAR(5) NOT NULL, -- KEGG pathway short ID 49 | FOREIGN KEY (_id) REFERENCES genes (_id) 50 | ); 51 | CREATE TABLE pubmed ( 52 | _id INTEGER NOT NULL, -- REFERENCES genes 53 | pubmed_id VARCHAR(10) NOT NULL, -- PubMed ID 54 | FOREIGN KEY (_id) REFERENCES genes (_id) 55 | ); 56 | CREATE TABLE refseq ( 57 | _id INTEGER NOT NULL, -- REFERENCES genes 58 | accession VARCHAR(20) NOT NULL, -- RefSeq accession number 59 | FOREIGN KEY (_id) REFERENCES genes (_id) 60 | ); 61 | CREATE TABLE unigene ( 62 | _id INTEGER NOT NULL, -- REFERENCES genes 63 | unigene_id VARCHAR(10) NOT NULL, -- UniGene ID 64 | FOREIGN KEY (_id) REFERENCES genes (_id) 65 | ); 66 | 67 | -- Standalone data tables. 68 | CREATE TABLE chrlengths ( 69 | chromosome VARCHAR(2) PRIMARY KEY, -- chromosome name 70 | length INTEGER NOT NULL 71 | ); 72 | 73 | -- Metadata tables. 74 | CREATE TABLE metadata ( 75 | name VARCHAR(80) PRIMARY KEY, 76 | value VARCHAR(255) 77 | ); 78 | CREATE TABLE map_counts ( 79 | map_name VARCHAR(80) PRIMARY KEY, 80 | count INTEGER NOT NULL 81 | ); 82 | CREATE TABLE map_metadata ( 83 | map_name VARCHAR(80) NOT NULL, 84 | source_name VARCHAR(80) NOT NULL, 85 | source_url VARCHAR(255) NOT NULL, 86 | source_date VARCHAR(20) NOT NULL 87 | ); 88 | 89 | -- Explicit index creation on the referencing column of all the foreign keys. 90 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 91 | -- indexes automatically. 92 | CREATE INDEX Fprobes ON probes (_id); 93 | CREATE INDEX Falias ON alias (_id); 94 | CREATE INDEX Fchromosomes ON chromosomes (_id); 95 | CREATE INDEX Fchromosome_locations ON chromosome_locations (_id); 96 | CREATE INDEX Fec ON ec (_id); 97 | CREATE INDEX Fkegg ON kegg (_id); 98 | CREATE INDEX Fpubmed ON pubmed (_id); 99 | CREATE INDEX Frefseq ON refseq (_id); 100 | CREATE INDEX Funigene ON unigene (_id); 101 | 102 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.1/COELICOLOR_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE gene_info ( 2 | _id INTEGER REFERENCES genes(_id), 3 | gene_name TEXT, 4 | symbol TEXT 5 | ); 6 | CREATE TABLE refseq ( 7 | _id INTEGER REFERENCES genes(_id), 8 | accession TEXT 9 | ); 10 | CREATE TABLE ec ( 11 | _id INTEGER REFERENCES genes(_id), 12 | ec_number TEXT 13 | ); 14 | CREATE TABLE kegg ( 15 | _id INTEGER REFERENCES genes(_id), 16 | path_id TEXT 17 | ); 18 | CREATE TABLE map_metadata ( 19 | map_name TEXT, 20 | source_name TEXT, 21 | source_url TEXT, 22 | source_date TEXT 23 | ); 24 | CREATE TABLE pubmed ( 25 | _id INTEGER REFERENCES genes(_id), 26 | pubmed_id TEXT 27 | ); 28 | CREATE TABLE locus ( 29 | _id INTEGER REFERENCES genes(_id), 30 | locus_tag TEXT -- SCO IDs 31 | ); 32 | CREATE TABLE genes ( 33 | _id INTEGER PRIMARY KEY, 34 | gene_id TEXT -- Entrez_Gene IDs 35 | ); 36 | CREATE TABLE accessions ( 37 | _id INTEGER NOT NULL, 38 | accession TEXT, -- RefSeq accessions 39 | FOREIGN KEY (_id) REFERENCES genes(_id) 40 | ); 41 | CREATE TABLE protein ( 42 | _id INTEGER REFERENCES genes(_id), 43 | protein_gi TEXT 44 | ); 45 | CREATE TABLE chrlengths ( 46 | chromosome VARCHAR(1) PRIMARY KEY, -- chromosome name [0: chromosome, 1: plasmid SCP1, 2: plasmid SCP2] 47 | length INTEGER NOT NULL 48 | ); 49 | CREATE TABLE chromosomes ( 50 | _id INTEGER NOT NULL, -- REFERENCES genes 51 | chromosome VARCHAR(1), -- chromosome name 52 | FOREIGN KEY (_id) REFERENCES genes (_id) 53 | ); 54 | CREATE TABLE alias ( 55 | _id INTEGER NOT NULL, -- REFERENCES genes 56 | alias_symbol VARCHAR(80) NOT NULL, -- gene symbol or alias (synonyms) 57 | FOREIGN KEY (_id) REFERENCES genes (_id) 58 | ); 59 | CREATE TABLE metadata ( 60 | name VARCHAR(80) PRIMARY KEY, 61 | value VARCHAR(255) 62 | ); 63 | CREATE TABLE go_bp ( 64 | _id INTEGER REFERENCES genes(_id), 65 | go_id TEXT, 66 | evidence TEXT 67 | ); 68 | CREATE TABLE go_cc ( 69 | _id INTEGER REFERENCES genes(_id), 70 | go_id TEXT, 71 | evidence TEXT 72 | ); 73 | CREATE TABLE go_mf ( 74 | _id INTEGER REFERENCES genes(_id), 75 | go_id TEXT, 76 | evidence TEXT 77 | ); 78 | CREATE TABLE go_bp_all (_id INTEGER REFERENCES genes(_id),go_id TEXT,evidence TEXT); 79 | CREATE TABLE go_cc_all (_id INTEGER REFERENCES genes(_id),go_id TEXT,evidence TEXT); 80 | CREATE TABLE go_mf_all (_id INTEGER REFERENCES genes(_id),go_id TEXT,evidence TEXT); 81 | CREATE TABLE map_counts ( 82 | map_name VARCHAR(80) PRIMARY KEY, 83 | count INTEGER NOT NULL 84 | ); 85 | CREATE TABLE chromosome_locations ( 86 | _id INTEGER NOT NULL, -- REFERENCES genes 87 | seqname VARCHAR(20) NOT NULL, -- chromosome name 88 | start_location INTEGER NOT NULL, 89 | end_location INTEGER NOT NULL, 90 | FOREIGN KEY (_id) REFERENCES genes (_id) 91 | ); 92 | CREATE TABLE symbol ( 93 | _id INTEGER REFERENCES genes(_id), 94 | symbol TEXT 95 | ); 96 | 97 | -- Explicit index creation on the referencing column of all the foreign keys. 98 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 99 | -- indexes automatically. 100 | CREATE INDEX en1 ON ec(_id); 101 | CREATE INDEX gi1 ON gene_info(_id); 102 | CREATE INDEX k1 ON kegg(_id); 103 | CREATE INDEX pu1 ON pubmed(_id); 104 | CREATE INDEX rs1 on refseq(_id); 105 | CREATE INDEX lt1 ON locus(_id); 106 | CREATE INDEX lt2 ON locus(locus_tag); 107 | CREATE INDEX ge2 ON genes(gene_id); 108 | CREATE INDEX ge1 on genes(_id); 109 | CREATE INDEX ac1 ON accessions(_id); 110 | CREATE INDEX ac2 ON accessions(accession); 111 | CREATE INDEX pr1 ON protein(_id); 112 | CREATE INDEX al1 ON alias(_id); 113 | CREATE INDEX ch ON chromosomes (_id); 114 | CREATE INDEX go1 ON go_bp(_id); 115 | CREATE INDEX go2 ON go_mf(_id); 116 | CREATE INDEX go3 ON go_cc(_id); 117 | CREATE INDEX go4 ON go_bp(go_id); 118 | CREATE INDEX go5 ON go_mf(go_id); 119 | CREATE INDEX go6 ON go_cc(go_id); 120 | CREATE INDEX chl ON chromosome_locations (_id); 121 | CREATE INDEX gisymbol ON symbol(_id); 122 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_1.0/PFAM_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata ( 2 | name TEXT, 3 | value TEXT 4 | ); 5 | 6 | CREATE TABLE cazy ( 7 | ac VARCHAR(12) NOT NULL, --AC ID 8 | cazy VARCHAR(6) NOT NULL --CAZY ID 9 | ); 10 | 11 | CREATE TABLE homstrad ( 12 | ac VARCHAR(12) NOT NULL, --AC ID 13 | homstrad VARCHAR(20) NOT NULL --HOMSTRAD ID 14 | ); 15 | 16 | CREATE TABLE interpro ( 17 | ac VARCHAR(12) NOT NULL, --AC ID 18 | interpro VARCHAR(9) NOT NULL --INTERPRO ID 19 | ); 20 | 21 | CREATE TABLE load ( 22 | ac VARCHAR(12) NOT NULL, --AC ID 23 | load VARCHAR(15) NOT NULL --LOAD ID 24 | ); 25 | 26 | CREATE TABLE merops ( 27 | ac VARCHAR(12) NOT NULL, --AC ID 28 | merops VARCHAR(3) NOT NULL --MEROPS ID 29 | ); 30 | 31 | CREATE TABLE mim ( 32 | ac VARCHAR(12) NOT NULL, --AC ID 33 | mim VARCHAR(6) NOT NULL --MIM ID 34 | ); 35 | 36 | CREATE TABLE pdb ( 37 | ac VARCHAR(12) NOT NULL, --AC ID 38 | pdb VARCHAR(6) NOT NULL, --PDB ID 39 | start_point INTEGER, --start of alignment 40 | end_point INTEGER --end of alignment 41 | ); 42 | 43 | CREATE TABLE pfamb ( 44 | ac VARCHAR(12) NOT NULL, --AC ID 45 | pfamb VARCHAR(8) NOT NULL --PFAMB ID 46 | ); 47 | 48 | CREATE TABLE prints ( 49 | ac VARCHAR(12) NOT NULL, --AC ID 50 | prints VARCHAR(7) NOT NULL --PRINTS ID 51 | ); 52 | 53 | CREATE TABLE prosite ( 54 | ac VARCHAR(12) NOT NULL, --AC ID 55 | prosite VARCHAR(9) NOT NULL --PROSITE ID 56 | ); 57 | 58 | CREATE TABLE prosite_profile ( 59 | ac VARCHAR(12) NOT NULL, --AC ID 60 | prosite_profile VARCHAR(7) NOT NULL --PROSITE_PROFILE ID 61 | ); 62 | 63 | CREATE TABLE rm ( 64 | ac VARCHAR(12) NOT NULL, --AC ID 65 | rm VARCHAR(8) NOT NULL --RM ID 66 | ); 67 | 68 | CREATE TABLE scop ( 69 | ac VARCHAR(12) NOT NULL, --AC ID 70 | scop VARCHAR(4) NOT NULL, --SCOP ID 71 | placement VARCHAR(2) NOT NULL --SCOP placement 72 | ); 73 | 74 | CREATE TABLE smart ( 75 | ac VARCHAR(12) NOT NULL, --AC ID 76 | smart VARCHAR(9) NOT NULL --SMART ID 77 | ); 78 | 79 | CREATE TABLE tc ( 80 | ac VARCHAR(12) NOT NULL, --AC ID 81 | tc VARCHAR(6) NOT NULL --TC ID 82 | ); 83 | 84 | CREATE TABLE url ( 85 | ac VARCHAR(12) NOT NULL, --AC ID 86 | url VARCHAR(80) NOT NULL --URL ID 87 | ); 88 | 89 | CREATE TABLE id ( 90 | ac VARCHAR(12) NOT NULL, --AC ID 91 | id VARCHAR(15) NOT NULL --PFAM ID ID 92 | ); 93 | 94 | CREATE TABLE de ( 95 | ac VARCHAR(12) NOT NULL, --AC ID 96 | de VARCHAR(80) NOT NULL --DE ID 97 | ); 98 | 99 | CREATE TABLE tp ( 100 | ac VARCHAR(12) NOT NULL, --AC ID 101 | tp VARCHAR(6) NOT NULL --TP ID 102 | ); 103 | 104 | 105 | -- Metadata tables. 106 | CREATE TABLE metadata ( 107 | name VARCHAR(80) PRIMARY KEY, 108 | value VARCHAR(255) 109 | ); 110 | CREATE TABLE map_counts ( 111 | map_name VARCHAR(80) PRIMARY KEY, 112 | count INTEGER NOT NULL 113 | ); 114 | CREATE TABLE map_metadata ( 115 | map_name VARCHAR(80) NOT NULL, 116 | source_name VARCHAR(80) NOT NULL, 117 | source_url VARCHAR(255) NOT NULL, 118 | source_date VARCHAR(20) NOT NULL 119 | ); 120 | 121 | 122 | -- Explicit index creation on the referencing column of all the foreign keys. 123 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 124 | -- indexes automatically. 125 | CREATE INDEX cazy_ac ON cazy(ac); 126 | CREATE INDEX homstrad_ac ON homstrad(ac); 127 | CREATE INDEX interpro_ac ON interpro(ac); 128 | CREATE INDEX load_ac ON load(ac); 129 | CREATE INDEX merops_ac ON merops(ac); 130 | CREATE INDEX mim_ac ON mim(ac); 131 | CREATE INDEX pdb_ac ON pdb(ac); 132 | CREATE INDEX pfamb_ac ON pfamb(ac); 133 | CREATE INDEX prints_ac ON prints(ac); 134 | CREATE INDEX prosite_ac ON prosite(ac); 135 | CREATE INDEX prosite_profile_ac ON prosite_profile(ac); 136 | CREATE INDEX rm_ac ON rm(ac); 137 | CREATE INDEX scop_ac ON scop(ac); 138 | CREATE INDEX smart_ac ON smart(ac); 139 | CREATE INDEX tc_ac ON tc(ac); 140 | CREATE INDEX url_ac ON url(ac) 141 | CREATE INDEX id_ac ON id(ac); 142 | CREATE INDEX de_ac ON de(ac); 143 | CREATE INDEX tp_ac ON tp(ac); 144 | 145 | -------------------------------------------------------------------------------- /man/BimapFiltering.Rd: -------------------------------------------------------------------------------- 1 | \name{toggleProbes} 2 | 3 | % \alias{exposeAllProbes} 4 | % \alias{exposeAllProbes,AnnDbBimap-method} 5 | % \alias{maskMultiProbes} 6 | % \alias{maskMultiProbes,AnnDbBimap-method} 7 | % \alias{maskSingleProbes} 8 | % \alias{maskSingleProbes,AnnDbBimap-method} 9 | 10 | \alias{toggleProbes} 11 | \alias{toggleProbes,ProbeAnnDbBimap-method} 12 | \alias{toggleProbes,ProbeAnnDbMap-method} 13 | \alias{toggleProbes,ProbeIpiAnnDbMap-method} 14 | \alias{toggleProbes,ProbeGo3AnnDbBimap-method} 15 | 16 | \alias{hasMultiProbes} 17 | \alias{hasMultiProbes,ProbeAnnDbBimap-method} 18 | \alias{hasMultiProbes,ProbeAnnDbMap-method} 19 | \alias{hasMultiProbes,ProbeIpiAnnDbMap-method} 20 | \alias{hasMultiProbes,ProbeGo3AnnDbBimap-method} 21 | 22 | \alias{hasSingleProbes} 23 | \alias{hasSingleProbes,ProbeAnnDbBimap-method} 24 | \alias{hasSingleProbes,ProbeAnnDbMap-method} 25 | \alias{hasSingleProbes,ProbeIpiAnnDbMap-method} 26 | \alias{hasSingleProbes,ProbeGo3AnnDbBimap-method} 27 | 28 | \alias{getBimapFilters} 29 | \alias{getBimapFilters,AnnDbBimap-method} 30 | 31 | 32 | \title{Methods for getting/setting the filters on a Bimap object} 33 | 34 | \description{ 35 | These methods are part of the \link{Bimap} interface (see 36 | \code{?\link{Bimap}} for a quick overview of the \link{Bimap} objects 37 | and their interface). 38 | 39 | Some of these methods are for getting or setting the filtering status 40 | on a \link{Bimap} object so that the mapping object can toggle between 41 | displaying all probes, only single probes (the defualt) or only 42 | multiply matching probes. 43 | 44 | Other methods are for viewing or setting the filter threshold value on 45 | a InpAnnDbBimap object. 46 | } 47 | 48 | \usage{ 49 | ## Making a Bimap object that does not prefilter to remove probes that 50 | ## match multiple genes: 51 | toggleProbes(x, value) 52 | hasMultiProbes(x) ##T/F test for exposure of single probes 53 | hasSingleProbes(x) ##T/F test for exposure of mulitply matched probes 54 | 55 | ## Looking at the SQL filter values for a Bimap 56 | getBimapFilters(x) 57 | } 58 | 59 | \arguments{ 60 | \item{x}{ 61 | A \link{Bimap} object. 62 | } 63 | \item{value}{ 64 | A character vector containing the new value that the Bimap should 65 | use as the filter. Or the value to toggle a probe mapping to: 66 | "all", "single", or "multiple". 67 | } 68 | } 69 | 70 | \details{ 71 | \code{toggleProbes(x)} is a methods for creating Bimaps that have an 72 | alternate filter for which probes get exposed based upon whether these 73 | probes map to multiple genes or not. 74 | 75 | \code{hasMultiProbes(x)} and \code{hasSingleProbes(x)} are provided to 76 | give a quick test about whether or not such probes are exposed in a 77 | given mapping. 78 | 79 | \code{getBimapFilters(x)} will list all the SQL filters applied to a 80 | Bimap object. 81 | } 82 | 83 | \value{ 84 | A \link{Bimap} object of the same subtype as \code{x} for 85 | \code{exposeAllProbes(x)}, \code{maskMultiProbes(x)} and 86 | \code{maskSingleProbes(x)}. 87 | 88 | A TRUE or FALSE value in the case of \code{hasMultiProbes(x)} and 89 | \code{hasSingleProbes(x)}. 90 | } 91 | 92 | \author{M. Carlson} 93 | 94 | \seealso{ 95 | \link{Bimap}, 96 | \link{Bimap-keys}, 97 | \link{Bimap-direction}, 98 | \link{BimapFormatting}, 99 | \link{Bimap-envirAPI}, 100 | \code{\link{nhit}} 101 | } 102 | 103 | \examples{ 104 | ## Make a Bimap that contains all the probes 105 | require("hgu95av2.db") 106 | mapWithMultiProbes <- toggleProbes(hgu95av2ENTREZID, "all") 107 | count.mappedLkeys(hgu95av2ENTREZID) 108 | count.mappedLkeys(mapWithMultiProbes) 109 | 110 | ## Check that it has both multiply and singly matching probes: 111 | hasMultiProbes(mapWithMultiProbes) 112 | hasSingleProbes(mapWithMultiProbes) 113 | 114 | ## Make it have Multi probes ONLY: 115 | OnlyMultiProbes = toggleProbes(mapWithMultiProbes, "multiple") 116 | hasMultiProbes(OnlyMultiProbes) 117 | hasSingleProbes(OnlyMultiProbes) 118 | 119 | ## Convert back to a default map with only single probes exposed 120 | OnlySingleProbes = toggleProbes(OnlyMultiProbes, "single") 121 | hasMultiProbes(OnlySingleProbes) 122 | hasSingleProbes(OnlySingleProbes) 123 | } 124 | 125 | \keyword{methods} 126 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.0/MALARIA_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE genes ( 13 | _id INTEGER PRIMARY KEY, 14 | gene_id VARCHAR(10) NOT NULL UNIQUE -- Entrez Gene ID 15 | ); 16 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 17 | CREATE TABLE gene_info ( 18 | _id INTEGER NOT NULL UNIQUE, -- REFERENCES genes 19 | gene_name VARCHAR(255) NOT NULL, -- gene name 20 | symbol VARCHAR(80) NOT NULL, -- gene symbol 21 | FOREIGN KEY (_id) REFERENCES genes (_id) 22 | ); 23 | CREATE TABLE go_bp ( 24 | _id INTEGER NOT NULL, -- REFERENCES genes 25 | go_id CHAR(10) NOT NULL, -- GO ID 26 | evidence CHAR(3) NOT NULL, -- GO evidence code 27 | FOREIGN KEY (_id) REFERENCES genes (_id) 28 | ); 29 | CREATE TABLE go_mf ( 30 | _id INTEGER NOT NULL, -- REFERENCES genes 31 | go_id CHAR(10) NOT NULL, -- GO ID 32 | evidence CHAR(3) NOT NULL, -- GO evidence code 33 | FOREIGN KEY (_id) REFERENCES genes (_id) 34 | ); 35 | CREATE TABLE go_cc ( 36 | _id INTEGER NOT NULL, -- REFERENCES genes 37 | go_id CHAR(10) NOT NULL, -- GO ID 38 | evidence CHAR(3) NOT NULL, -- GO evidence code 39 | FOREIGN KEY (_id) REFERENCES genes (_id) 40 | ); 41 | CREATE TABLE go_bp_all ( 42 | _id INTEGER NOT NULL, -- REFERENCES genes 43 | go_id CHAR(10) NOT NULL, -- GO ID 44 | evidence CHAR(3) NOT NULL, -- GO evidence code 45 | FOREIGN KEY (_id) REFERENCES genes (_id) 46 | ); 47 | CREATE TABLE go_mf_all ( 48 | _id INTEGER NOT NULL, -- REFERENCES genes 49 | go_id CHAR(10) NOT NULL, -- GO ID 50 | evidence CHAR(3) NOT NULL, -- GO evidence code 51 | FOREIGN KEY (_id) REFERENCES genes (_id) 52 | ); 53 | CREATE TABLE go_cc_all ( 54 | _id INTEGER NOT NULL, -- REFERENCES genes 55 | go_id CHAR(10) NOT NULL, -- GO ID 56 | evidence CHAR(3) NOT NULL, -- GO evidence code 57 | FOREIGN KEY (_id) REFERENCES genes (_id) 58 | ); 59 | CREATE TABLE kegg ( 60 | _id INTEGER NOT NULL, -- REFERENCES genes 61 | path_id CHAR(5) NOT NULL, -- KEGG pathway short ID 62 | FOREIGN KEY (_id) REFERENCES genes (_id) 63 | ); 64 | CREATE TABLE ec ( 65 | _id INTEGER NOT NULL, -- REFERENCES genes 66 | ec_number VARCHAR(13) NOT NULL, -- EC number 67 | FOREIGN KEY (_id) REFERENCES genes (_id) 68 | ); 69 | CREATE TABLE alias ( 70 | _id INTEGER NOT NULL, -- REFERENCES genes 71 | alias_symbol VARCHAR(80) NOT NULL, -- gene symbol or alias 72 | FOREIGN KEY (_id) REFERENCES genes (_id) 73 | ); 74 | 75 | -- Explicit index creation on the referencing column of all the foreign keys. 76 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 77 | -- indexes automatically. 78 | CREATE INDEX Fgo_bp ON go_bp (_id); 79 | CREATE INDEX Fgo_bp_go_id ON go_bp (go_id); 80 | CREATE INDEX Fgo_mf ON go_mf (_id); 81 | CREATE INDEX Fgo_mf_go_id ON go_mf (go_id); 82 | CREATE INDEX Fgo_cc ON go_cc (_id); 83 | CREATE INDEX Fgo_cc_go_id ON go_cc (go_id); 84 | CREATE INDEX Fgo_bp_all ON go_bp_all (_id); 85 | CREATE INDEX Fgo_bp_all_go_id ON go_bp_all (go_id); 86 | CREATE INDEX Fgo_mf_all ON go_mf_all (_id); 87 | CREATE INDEX Fgo_mf_all_go_id ON go_mf_all (go_id); 88 | CREATE INDEX Fgo_cc_all ON go_cc_all (_id); 89 | CREATE INDEX Fgo_cc_all_go_id ON go_cc_all (go_id); 90 | CREATE INDEX Fkegg ON kegg (_id); 91 | CREATE INDEX Fec ON ec (_id); 92 | CREATE INDEX Falias ON alias (_id); 93 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.1/MALARIA_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE genes ( 13 | _id INTEGER PRIMARY KEY, 14 | gene_id VARCHAR(10) NOT NULL UNIQUE -- Entrez Gene ID 15 | ); 16 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 17 | CREATE TABLE gene_info ( 18 | _id INTEGER NOT NULL UNIQUE, -- REFERENCES genes 19 | gene_name VARCHAR(255) NOT NULL, -- gene name 20 | symbol VARCHAR(80) NOT NULL, -- gene symbol 21 | FOREIGN KEY (_id) REFERENCES genes (_id) 22 | ); 23 | CREATE TABLE go_bp ( 24 | _id INTEGER NOT NULL, -- REFERENCES genes 25 | go_id CHAR(10) NOT NULL, -- GO ID 26 | evidence CHAR(3) NOT NULL, -- GO evidence code 27 | FOREIGN KEY (_id) REFERENCES genes (_id) 28 | ); 29 | CREATE TABLE go_mf ( 30 | _id INTEGER NOT NULL, -- REFERENCES genes 31 | go_id CHAR(10) NOT NULL, -- GO ID 32 | evidence CHAR(3) NOT NULL, -- GO evidence code 33 | FOREIGN KEY (_id) REFERENCES genes (_id) 34 | ); 35 | CREATE TABLE go_cc ( 36 | _id INTEGER NOT NULL, -- REFERENCES genes 37 | go_id CHAR(10) NOT NULL, -- GO ID 38 | evidence CHAR(3) NOT NULL, -- GO evidence code 39 | FOREIGN KEY (_id) REFERENCES genes (_id) 40 | ); 41 | CREATE TABLE go_bp_all ( 42 | _id INTEGER NOT NULL, -- REFERENCES genes 43 | go_id CHAR(10) NOT NULL, -- GO ID 44 | evidence CHAR(3) NOT NULL, -- GO evidence code 45 | FOREIGN KEY (_id) REFERENCES genes (_id) 46 | ); 47 | CREATE TABLE go_mf_all ( 48 | _id INTEGER NOT NULL, -- REFERENCES genes 49 | go_id CHAR(10) NOT NULL, -- GO ID 50 | evidence CHAR(3) NOT NULL, -- GO evidence code 51 | FOREIGN KEY (_id) REFERENCES genes (_id) 52 | ); 53 | CREATE TABLE go_cc_all ( 54 | _id INTEGER NOT NULL, -- REFERENCES genes 55 | go_id CHAR(10) NOT NULL, -- GO ID 56 | evidence CHAR(3) NOT NULL, -- GO evidence code 57 | FOREIGN KEY (_id) REFERENCES genes (_id) 58 | ); 59 | CREATE TABLE kegg ( 60 | _id INTEGER NOT NULL, -- REFERENCES genes 61 | path_id CHAR(5) NOT NULL, -- KEGG pathway short ID 62 | FOREIGN KEY (_id) REFERENCES genes (_id) 63 | ); 64 | CREATE TABLE ec ( 65 | _id INTEGER NOT NULL, -- REFERENCES genes 66 | ec_number VARCHAR(13) NOT NULL, -- EC number 67 | FOREIGN KEY (_id) REFERENCES genes (_id) 68 | ); 69 | CREATE TABLE alias ( 70 | _id INTEGER NOT NULL, -- REFERENCES genes 71 | alias_symbol VARCHAR(80) NOT NULL, -- gene symbol or alias 72 | FOREIGN KEY (_id) REFERENCES genes (_id) 73 | ); 74 | 75 | -- Explicit index creation on the referencing column of all the foreign keys. 76 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 77 | -- indexes automatically. 78 | CREATE INDEX Fgo_bp ON go_bp (_id); 79 | CREATE INDEX Fgo_bp_go_id ON go_bp (go_id); 80 | CREATE INDEX Fgo_mf ON go_mf (_id); 81 | CREATE INDEX Fgo_mf_go_id ON go_mf (go_id); 82 | CREATE INDEX Fgo_cc ON go_cc (_id); 83 | CREATE INDEX Fgo_cc_go_id ON go_cc (go_id); 84 | CREATE INDEX Fgo_bp_all ON go_bp_all (_id); 85 | CREATE INDEX Fgo_bp_all_go_id ON go_bp_all (go_id); 86 | CREATE INDEX Fgo_mf_all ON go_mf_all (_id); 87 | CREATE INDEX Fgo_mf_all_go_id ON go_mf_all (go_id); 88 | CREATE INDEX Fgo_cc_all ON go_cc_all (_id); 89 | CREATE INDEX Fgo_cc_all_go_id ON go_cc_all (go_id); 90 | CREATE INDEX Fkegg ON kegg (_id); 91 | CREATE INDEX Fec ON ec (_id); 92 | CREATE INDEX Falias ON alias (_id); 93 | -------------------------------------------------------------------------------- /inst/unitTests/test_select_reactome.R: -------------------------------------------------------------------------------- 1 | ## unit tests for methods associated with reactome.db 2 | require(reactome.db) 3 | r <- reactome.db 4 | 5 | 6 | test_cols <- function(){ 7 | res <- columns(r) 8 | checkTrue(length(res) >4) 9 | checkTrue("ENTREZID" %in% res) 10 | checkTrue("GO" %in% res) 11 | checkTrue("PATHNAME" %in% res) 12 | checkTrue("REACTOMEID" %in% res) 13 | } 14 | 15 | test_keytypes <- function(){ 16 | res <- keytypes(r) 17 | checkTrue(length(res) >4) 18 | checkTrue("ENTREZID" %in% res) 19 | checkTrue("GO" %in% res) 20 | checkTrue("PATHNAME" %in% res) 21 | checkTrue("REACTOMEID" %in% res) 22 | } 23 | 24 | test_keys <- function(){ 25 | res <- head(keys(r, keytype="ENTREZID")) 26 | checkTrue(length(res) > 0) 27 | checkTrue(length(res) == length(unique(res))) 28 | res2 <- head(keys(r, keytype="PATHNAME")) 29 | checkTrue(is.character(res2)) 30 | checkTrue(length(res2) == length(unique(res2))) 31 | } 32 | 33 | ## test function that gets table names 34 | test_getTables <- function(){ 35 | c <- c("ENTREZID", "PATHNAME") 36 | res <- AnnotationDbi:::.getTables(c, retVal="table") ##default for retVal 37 | checkTrue(length(res) ==2) 38 | checkIdentical(res, c("pathway2gene","pathway2name")) 39 | 40 | res2 <- AnnotationDbi:::.getTables(c, retVal="colname") 41 | checkTrue(length(res2) ==2) 42 | checkIdentical(res2, c("gene_id","path_name")) 43 | } 44 | 45 | ## Tests ability to get one table/query out. 46 | test_extractWithSimpleQuery <- function(){ 47 | table <- "pathway2gene" ## a table (in this case). (Could also be subquery) 48 | colType <- "gene_id" ## column we are interested in. 49 | k <- head(keys(r, keytype="ENTREZID"), n=2) 50 | res <- AnnotationDbi:::.extractWithSimpleQuery(r, table, colType, k) 51 | checkTrue(dim(res)[1]>0) 52 | checkTrue(dim(res)[2]==2) 53 | checkIdentical(c("DB_ID","gene_id"), colnames(res)) 54 | } 55 | 56 | ## Test ability to pull data out in vectorized fashion 57 | test_collateQueryResults <- function(){ 58 | tables <- c("pathway2gene", "reactome2go", "pathway2name") 59 | colType <- "gene_id" 60 | k <- head(keys(r, keytype="ENTREZID"), n=2) 61 | mergeID = "DB_ID" 62 | res <- AnnotationDbi:::.collateQueryResults(r, tables, colType, k, mergeID) 63 | checkTrue(dim(res)[1]>0) 64 | checkTrue(dim(res)[2]==4) 65 | checkIdentical(c("DB_ID","gene_id","go_id","path_name"), colnames(res)) 66 | } 67 | 68 | 69 | 70 | 71 | 72 | ## and tests for select: 73 | test_select_TYPICAL <- function(){ 74 | k <- head(keys(r, keytype="ENTREZID")) 75 | c <- c("ENTREZID","PATHNAME","GO","REACTOMEID") 76 | res <- select(r, keys=k, columns=c, keytype="ENTREZID") 77 | checkTrue(dim(res)[1]>0) 78 | checkTrue(dim(res)[2]==4) 79 | checkIdentical(c("ENTREZID","PATHNAME","GO","REACTOMEID"), colnames(res)) 80 | } 81 | 82 | test_select_MISSING_EG <- function(){ 83 | k <- head(keys(r, keytype="ENTREZID")) 84 | c <- c("PATHNAME","GO") 85 | res <- select(r, keys=k, columns=c, keytype="ENTREZID") 86 | checkTrue(dim(res)[1]>0) 87 | checkTrue(dim(res)[2]==3) 88 | checkIdentical(c("ENTREZID","PATHNAME","GO"), colnames(res)) 89 | } 90 | 91 | 92 | test_select_ONE_COL <- function(){ 93 | k <- head(keys(r, keytype="ENTREZID")) 94 | c <- c("ENTREZID") 95 | res <- select(r, keys=k, columns=c, keytype="ENTREZID") ## Boom no warning 96 | checkTrue(dim(res)[1]>0) 97 | checkTrue(dim(res)[2]==1) 98 | checkIdentical(c("ENTREZID"), colnames(res)) 99 | } 100 | 101 | 102 | test_select_OTHERKEYTYPE <- function(){ 103 | ## This also checks if that we handle "BS keys" OK 104 | k <- head(keys(r, keytype="REACTOMEID")) 105 | k <- c(k[1:4], "109688") 106 | c <- c("ENTREZID","PATHNAME","GO") 107 | res <- select(r, keys=k, columns=c, keytype="REACTOMEID") 108 | checkTrue(dim(res)[1]>0) 109 | checkTrue(dim(res)[2]==4) 110 | checkIdentical(c("REACTOMEID","ENTREZID","PATHNAME","GO"), colnames(res)) 111 | } 112 | 113 | test_select_PATHNAME <- function(){ 114 | k <- head(keys(r, "PATHNAME")) 115 | suppressWarnings(res <- select(r, k, "ENTREZID", "PATHNAME")) 116 | checkTrue(dim(res)[1]>0) 117 | checkTrue(dim(res)[2]==2) 118 | checkIdentical(c("PATHNAME","ENTREZID"), colnames(res)) 119 | } 120 | 121 | 122 | 123 | 124 | ## for convenience... 125 | ## debug(AnnotationDbi:::.selectReact) 126 | ## debug(AnnotationDbi:::.collateQueryResults) 127 | ## debug(AnnotationDbi:::.extractWithSimpleQuery) 128 | -------------------------------------------------------------------------------- /R/createAnnObjs.MALARIA_DB.R: -------------------------------------------------------------------------------- 1 | ### ========================================================================= 2 | ### An SQLite-based ann data package (AnnDbPkg) provides a set of pre-defined 3 | ### AnnObj objects that are created at load-time. This set depends only on 4 | ### the underlying db schema i.e. all the SQLite-based ann data packages that 5 | ### share the same underlying db schema will provide the same set of AnnObj 6 | ### objects. 7 | ### 8 | ### This file describes the set of AnnObj objects provided by any 9 | ### MALARIA_DB-based package i.e. any SQLite-based ann data package based 10 | ### on the MALARIA_DB schema. 11 | ### The createAnnObjs.MALARIA_DB() function is the main entry point for 12 | ### this file: it is called by any MALARIA_DB-based package at load-time. 13 | ### ------------------------------------------------------------------------- 14 | 15 | 16 | MALARIA_DB_L2Rlink1 <- list(tablename="genes", Lcolname="gene_id", Rcolname="_id") 17 | 18 | ### Mandatory fields: objName, Class and L2Rchain 19 | MALARIA_DB_AnnDbBimap_seeds <- list( 20 | list( 21 | objName="ALIAS2ORF", 22 | Class="AnnDbBimap", 23 | L2Rchain=list( 24 | MALARIA_DB_L2Rlink1, 25 | list( 26 | tablename="alias", 27 | Lcolname="_id", 28 | Rcolname="alias_symbol" 29 | ) 30 | ), 31 | direction=-1L 32 | ), 33 | list( 34 | objName="ENZYME", 35 | Class="AnnDbBimap", 36 | L2Rchain=list( 37 | MALARIA_DB_L2Rlink1, 38 | list( 39 | tablename="ec", 40 | Lcolname="_id", 41 | Rcolname="ec_number" 42 | ) 43 | ) 44 | ), 45 | list( 46 | objName="GENENAME", 47 | Class="AnnDbBimap", 48 | L2Rchain=list( 49 | MALARIA_DB_L2Rlink1, 50 | list( 51 | tablename="gene_info", 52 | Lcolname="_id", 53 | Rcolname="gene_name" 54 | ) 55 | ) 56 | ), 57 | list( 58 | objName="PATH", 59 | Class="AnnDbBimap", 60 | L2Rchain=list( 61 | MALARIA_DB_L2Rlink1, 62 | list( 63 | tablename="kegg", 64 | Lcolname="_id", 65 | Rcolname="path_id" 66 | ) 67 | ) 68 | ), 69 | list( 70 | objName="SYMBOL", 71 | Class="AnnDbBimap", 72 | L2Rchain=list( 73 | MALARIA_DB_L2Rlink1, 74 | list( 75 | tablename="gene_info", 76 | Lcolname="_id", 77 | Rcolname="symbol" 78 | ) 79 | ) 80 | ), 81 | list( 82 | objName="GO", 83 | Class="Go3AnnDbBimap", 84 | L2Rchain=list( 85 | MALARIA_DB_L2Rlink1, 86 | list( 87 | #tablename="go_term", # no rightmost table for a Go3AnnDbBimap 88 | Lcolname="_id", 89 | tagname=c(Evidence="{evidence}"), 90 | Rcolname="go_id", 91 | Rattribnames=c(Ontology="NULL") 92 | ) 93 | ), 94 | rightTables=Go3tablenames() 95 | ) 96 | ) 97 | 98 | createAnnObjs.MALARIA_DB <- function(prefix, objTarget, dbconn, datacache) 99 | { 100 | checkDBSCHEMA(dbconn, "MALARIA_DB") 101 | 102 | ## AnnDbBimap objects 103 | seed0 <- list( 104 | objTarget=objTarget, 105 | datacache=datacache 106 | ) 107 | ann_objs <- createAnnDbBimaps(MALARIA_DB_AnnDbBimap_seeds, seed0) 108 | 109 | ## Reverse maps 110 | ann_objs$ENZYME2ORF <- revmap(ann_objs$ENZYME, objName="ENZYME2ORF") 111 | ann_objs$PATH2ORF <- revmap(ann_objs$PATH, objName="PATH2ORF") 112 | ann_objs$SYMBOL2ORF <- revmap(ann_objs$SYMBOL, objName="SYMBOL2ORF") 113 | ann_objs$GO2ORF <- revmap(ann_objs$GO, objName="GO2ORF") 114 | map <- ann_objs$GO2ORF 115 | map@rightTables <- Go3tablenames(all=TRUE) 116 | map@objName <- "GO2ALLORFS" 117 | ann_objs$GO2ALLORFS <- map 118 | 119 | ## 2 special maps that are not AnnDbBimap objects (just named integer vectors) 120 | ann_objs$MAPCOUNTS <- createMAPCOUNTS(dbconn, prefix) 121 | 122 | ## Some pre-caching 123 | Lkeys(ann_objs$GO) 124 | #mappedLkeys(ann_objs$GO) 125 | #Rkeys(ann_objs$GO2ORF) 126 | #mappedRkeys(ann_objs$GO2ORF) 127 | 128 | prefixAnnObjNames(ann_objs, prefix) 129 | } 130 | 131 | -------------------------------------------------------------------------------- /R/methods-AnnotationDb.R: -------------------------------------------------------------------------------- 1 | AnnotationDb <- 2 | function(conn, ...) 3 | { 4 | .AnnotationDb$new(conn=conn, ...) 5 | } 6 | 7 | ## setMethod(show, "AnnotationDb", 8 | ## function(object) 9 | ## { 10 | ## cat("class:", class(object), "\n") 11 | ## }) 12 | 13 | ### - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - 14 | ### Low-level accessor (not exported). 15 | ### 16 | 17 | 18 | ## These two things should just go away and be replaced with:x$conn 19 | ## .getConn <- function(envir) get("conn", envir=envir, inherits=FALSE) 20 | ## txdbConn <- function(txdb) .getConn(txdb@envir) 21 | 22 | 23 | # ## On the fence about whether or not to export dbconn(), it could be useful, 24 | # ## but it is also quite similar to say: org.Hs.eg_dbconn(), so if we export 25 | # ## it, it will have to deprecate the older ways. For now, I will just call it 26 | # ## using AnnotationDbi:::dbconn(db), Also AnnDbBiMaps have something called 27 | # ## dbconn() (lowercase "c") - blergh... 28 | # setMethod("dbconn", "AnnotationDb", 29 | # function(x) x$conn 30 | # ) 31 | 32 | ## Accesor for packageName 33 | setMethod("packageName", "AnnotationDb", 34 | function(x) x$packageName 35 | ) 36 | 37 | ## Overload metadata for AnnotationDb 38 | setMethod("metadata", "AnnotationDb", 39 | function(x) dbReadTable(dbconn(x), "metadata") 40 | ) 41 | 42 | 43 | ## Get the species AnnotationDb 44 | setMethod("species", "AnnotationDb", 45 | function(object){ 46 | res <- as.character(dbEasyQuery(dbconn(object), 47 | "SELECT value FROM metadata WHERE name='ORGANISM'")) 48 | if(res == "character(0)"){ ## then try again. 49 | res <- as.character(dbEasyQuery(dbconn(object), 50 | "SELECT value FROM metadata WHERE name='Organism'")) 51 | } 52 | if(res == "character(0)"){ ## then try again. 53 | res <- as.character(dbEasyQuery(dbconn(object), 54 | "SELECT value FROM metadata WHERE name='Genus and Species'")) 55 | } 56 | res 57 | } 58 | ) 59 | 60 | 61 | ## Try to make this generic 62 | setMethod("show", "AnnotationDb", 63 | function(object) 64 | { 65 | cat(class(object), "object:\n") 66 | metadata <- metadata(object) 67 | for (i in seq_len(nrow(metadata))) { 68 | cat("| ", metadata[i, "name"], ": ", metadata[i, "value"], 69 | "\n", sep="") 70 | } 71 | message("\n","Please see: help('select') for usage information", sep="") 72 | } 73 | ) 74 | 75 | setMethod("saveDb", "AnnotationDb", 76 | function(x, file) 77 | { 78 | if (!isSingleString(file)) 79 | stop("'file' must be a single string") 80 | sqliteCopyDatabase(dbconn(x), file) 81 | return(x) ## return the thing you just saved. 82 | } 83 | ) 84 | 85 | setMethod("columns", "AnnotationDb", 86 | function(x) 87 | { 88 | tables <- dbListTables(x$conn) 89 | sapply(tables, dbListFields, conn=x$conn) 90 | } 91 | ) 92 | 93 | cols <- function(x) 94 | .Deprecated("columns") 95 | 96 | .selectWarnReact <- function(x, keys, columns, keytype, ...){ 97 | extraArgs <- list(...) 98 | if(missing(keytype)){ 99 | .selectReact(x, keys, columns, keytype=extraArgs[["kt"]]) 100 | }else{ 101 | .selectReact(x, keys, columns, keytype) 102 | } 103 | } 104 | 105 | ## library(AnnotationDbi) 106 | ## library(RSQLite) 107 | ## library(GenomicFeatures); fl = system.file("extdata", "UCSC_knownGene_sample.sqlite", package="GenomicFeatures") 108 | ## conn = dbConnect(SQLite(), fl) 109 | ## loadDb(fl) ## bug 110 | ## loadFeatures(fl) ## other bug 111 | ## GenomicFeatures:::TxDb(conn) ## bug 112 | ## AnnotationDbi:::loadDb(fl) ## other bug 113 | 114 | 115 | ## TODO: add option to replace multi-matches with NAs or to just remove them. 116 | ## To cleanly handle having 'multiVals' being EITHER a FUN or something else: 117 | ## DO like: if(is.function(multiVals)){}else{match.arg(multiVals)} 118 | 119 | ############################################################################### 120 | ## New method just to make it easier to access the sqlite file (and thus make 121 | ## it easier to make use of great new stuff like dplyr) 122 | 123 | ## Basically I want this thing to return the sqlite file name path as a string 124 | 125 | ## make dbconn() and dbfile() methods for AnnotationDb objects (and export it) 126 | setMethod("dbconn", "AnnotationDb", function(x) x$conn) 127 | setMethod("dbfile", "AnnotationDb", function(x) dbfile(dbconn(x))) 128 | -------------------------------------------------------------------------------- /NAMESPACE: -------------------------------------------------------------------------------- 1 | import(methods) 2 | importFrom(stats, setNames) 3 | importFrom(stats4, summary) 4 | import(DBI) 5 | import(RSQLite) 6 | import(BiocGenerics) 7 | import(Biobase) 8 | import(S4Vectors) 9 | import(IRanges) 10 | importFrom(KEGGREST, keggList) 11 | 12 | exportClasses( 13 | ## from R/AllClasses.R 14 | "Bimap", 15 | "FlatBimap", 16 | "AnnObj", 17 | "AnnDbObj", 18 | #"AnnDbTable", 19 | "L2Rlink", 20 | "AnnDbBimap", 21 | "GoAnnDbBimap", 22 | "Go3AnnDbBimap", 23 | "GOTermsAnnDbBimap", 24 | "AnnDbMap", 25 | "IpiAnnDbMap", 26 | "AgiAnnDbMap", 27 | "ProbeAnnDbBimap", 28 | "ProbeAnnDbMap", 29 | "ProbeIpiAnnDbMap", 30 | "ProbeGo3AnnDbBimap", 31 | 32 | ## Virtual mother-class for all Annoations 33 | "AnnotationDb", 34 | "OrgDb", 35 | "ChipDb", 36 | "GODb", 37 | "ReactomeDb", 38 | 39 | ## ## Class for faux-bimaps (select based bimaps) 40 | ## "AnnotationDbMap", 41 | 42 | ## from R/GOTerms.R 43 | "GOTerms", 44 | 45 | ## Special Frame objects 46 | "GOFrame", 47 | "GOAllFrame", 48 | "KEGGFrame" 49 | 50 | ) 51 | 52 | exportMethods( 53 | ## from R/AnnDbObj-lowAPI.R 54 | "dbconn", 55 | "dbfile", 56 | "taxonomyId", 57 | "dbmeta", 58 | "dbschema", 59 | "dbInfo", 60 | #"Ltablename", "Rtablename", 61 | #"Lfilter", "Rfilter", 62 | #"flatten", 63 | 64 | ## from R/Bimap.R (the Bimap interface) 65 | "direction", "direction<-", 66 | "revmap", 67 | "colnames", "colmetanames", 68 | "Lkeyname", "Rkeyname", "keyname", 69 | "tagname", 70 | "Rattribnames", "Rattribnames<-", 71 | "Lkeys", "Rkeys", "keys", 72 | "Lkeys<-", "Rkeys<-", "keys<-", 73 | "subset", 74 | "[", 75 | "Llength", "Rlength", "length", 76 | "isNA", 77 | "mappedLkeys", "mappedRkeys", "mappedkeys", 78 | "count.mappedLkeys", "count.mappedRkeys", "count.mappedkeys", 79 | "show", 80 | "summary", 81 | "toTable","as.data.frame", 82 | "head", "tail", 83 | "nrow", 84 | "links", 85 | "count.links", 86 | "nhit", 87 | "ncol", "dim", 88 | "toggleProbes", 89 | "hasMultiProbes","hasSingleProbes", 90 | "getBimapFilters", 91 | 92 | ## from R/GOTerms.R 93 | "GOID", 94 | "Term", 95 | "Ontology", 96 | "Synonym", 97 | "Secondary", 98 | "Definition", 99 | 100 | ## Special Frame Methods 101 | "GOFrame", 102 | "GOAllFrame", 103 | "getGOFrameData", 104 | "KEGGFrame", 105 | "getKEGGFrameData", 106 | 107 | ## from R/BimapFormatting.R 108 | "as.list", 109 | #"toLList", "toRList", "toList", 110 | "as.character", 111 | 112 | ## from R/Bimap-envirAPI.R 113 | "ls", 114 | "mget", 115 | "eapply", 116 | "get", 117 | "exists", 118 | "[[", 119 | "$", 120 | "contents", 121 | "sample", 122 | 123 | ## more... 124 | "initialize", 125 | 126 | ##Methods for AnnotationDb 127 | "saveDb", 128 | "species", 129 | "columns", 130 | "keytypes", 131 | "select", 132 | "mapIds", 133 | "orgPackageName" 134 | ) 135 | 136 | export( 137 | unlist2, 138 | 139 | ## from R/AnnDbObj-lowAPI.R 140 | showQCData, 141 | 142 | ## from R/SQL.R 143 | debugSQL, dbGetTable, 144 | 145 | ## from R/GOTerms.R 146 | GOTerms, 147 | makeGOGraph, 148 | 149 | ## from R/AnnDbPkg-templates-common.R 150 | dbFileConnect, 151 | dbFileDisconnect, 152 | #addToNamespaceAndExport, 153 | mergeToNamespaceAndExport, 154 | 155 | ## from methods-geneCentricDbs 156 | getOrgPkgForSchema, chooseCentralOrgPkgSymbol, 157 | mapIds_base, resort_base, 158 | testForValidKeytype, testSelectArgs, 159 | 160 | ## from R/loadDb.R 161 | loadDb, 162 | 163 | ## from the R/createAnnObjs.*_DB.R files 164 | createAnnObjs.SchemaChoice, NCBICHIP_DB_SeedGenerator, filterSeeds, 165 | 166 | ## from R/AnnDbPkg-checker.R 167 | #checkProperty0, 168 | checkMAPCOUNTS, 169 | 170 | ## helpers for map creation, temporary 171 | ## until pluggable maps come online 172 | make_eg_to_go_map, 173 | make_go_to_eg_map, 174 | toSQLStringSet, 175 | organismKEGGFrame, 176 | 177 | #Convenience function to allow automatic mapping of IDs: 178 | inpIDMapper, 179 | intraIDMapper, 180 | idConverter, 181 | 182 | ## AnnotationDb 183 | metadata, 184 | 185 | createSimpleBimap, 186 | 187 | ## S3 methods 188 | as.list.Bimap, 189 | as.data.frame.Bimap 190 | ) 191 | 192 | S3method(as.list, Bimap) 193 | S3method(as.data.frame, Bimap) 194 | -------------------------------------------------------------------------------- /man/GOTerms-class.Rd: -------------------------------------------------------------------------------- 1 | \name{GOTerms-class} 2 | \docType{class} 3 | 4 | \alias{class:GOTerms} 5 | \alias{GOTerms-class} 6 | 7 | \alias{GOTerms} 8 | 9 | \alias{initialize,GOTerms-method} 10 | 11 | % \alias{GOID} 12 | \alias{GOID,GOTerms-method} 13 | \alias{GOID,GOTermsAnnDbBimap-method} 14 | \alias{GOID,character-method} 15 | \alias{Term} 16 | \alias{Term,GOTerms-method} 17 | \alias{Term,GOTermsAnnDbBimap-method} 18 | \alias{Term,character-method} 19 | \alias{Ontology} 20 | \alias{Ontology,GOTerms-method} 21 | \alias{Ontology,GOTermsAnnDbBimap-method} 22 | \alias{Ontology,character-method} 23 | \alias{Definition} 24 | \alias{Definition,GOTerms-method} 25 | \alias{Definition,GOTermsAnnDbBimap-method} 26 | \alias{Definition,character-method} 27 | \alias{Synonym} 28 | \alias{Synonym,GOTerms-method} 29 | \alias{Synonym,GOTermsAnnDbBimap-method} 30 | \alias{Synonym,character-method} 31 | \alias{Secondary} 32 | \alias{Secondary,GOTerms-method} 33 | \alias{Secondary,GOTermsAnnDbBimap-method} 34 | \alias{Secondary,character-method} 35 | 36 | \alias{show,GOTerms-method} 37 | 38 | \title{Class "GOTerms"} 39 | 40 | \description{A class to represent Gene Ontology nodes} 41 | 42 | \section{Objects from the Class}{ 43 | Objects can be created by calls of the form 44 | \code{GOTerms(GOId, term, ontology, definition, synonym, secondary)}. 45 | GOId, term, and ontology are required. 46 | } 47 | 48 | \section{Slots}{ 49 | \describe{ 50 | \item{\code{GOID}:}{Object of class \code{"character"} A character 51 | string for the GO id of a primary node.} 52 | \item{\code{Term}:}{Object of class \code{"character"} A 53 | character string that defines the role of gene product 54 | corresponding to the primary GO id.} 55 | \item{\code{Ontology}:}{Object of class \code{"character"} Gene 56 | Ontology category. Can be MF - molecular function, CC - cellular 57 | component, or BP - biological process.} 58 | \item{\code{Definition}:}{Object of class \code{"character"} Further 59 | definition of the ontology of the primary GO id.} 60 | \item{\code{Synonym}:}{Object of class \code{"character"} other 61 | ontology terms that are considered to be synonymous to the primary 62 | term attached to the GO id (e.g. "type I programmed cell death" is a 63 | synonym of "apoptosis"). Synonymous here can mean that the 64 | synonym is an exact synonym of the primary term, is related to the 65 | primary term, is broader than the primary term, is more precise 66 | than the primary term, or name is related to the term, but is not 67 | exact, broader or narrower.} 68 | \item{\code{Secondary}:}{Object of class \code{"character"} GO ids 69 | that are secondary to the primary GO id as results of merging GO 70 | terms so that One GO id becomes the primary GO id and the rest 71 | become the secondary.} 72 | } 73 | } 74 | 75 | \section{Methods}{ 76 | \describe{ 77 | \item{GOID}{\code{signature(object = "GOTerms")}: 78 | The get method for slot GOID.} 79 | \item{Term}{\code{signature(object = "GOTerms")}: 80 | The get method for slot Term.} 81 | \item{Ontology}{\code{signature(object = "GOTerms")}: 82 | The get method for slot Ontology.} 83 | \item{Definition}{\code{signature(object = "GOTerms")}: 84 | The get method for slot Definition.} 85 | \item{Synonym}{\code{signature(object = "GOTerms")}: 86 | The get method for slot Synonym.} 87 | \item{Secondary}{\code{signature(object = "GOTerms")}: 88 | The get method for slot Secondary.} 89 | \item{show}{\code{signature(x = "GOTerms")}: 90 | The method for pretty print.} 91 | } 92 | } 93 | 94 | \references{\url{http://www.geneontology.org/}} 95 | 96 | \seealso{ 97 | \code{\link{makeGOGraph}} shows how to make GO mappings into graphNEL objects. 98 | } 99 | 100 | \note{GOTerms objects are used to represent primary GO nodes in the 101 | SQLite-based annotation data package GO.db} 102 | 103 | \examples{ 104 | gonode <- new("GOTerms", GOID="GO:1234567", Term="Test", Ontology="MF", 105 | Definition="just for testing") 106 | GOID(gonode) 107 | Term(gonode) 108 | Ontology(gonode) 109 | 110 | ##Or you can just use these methods on a GOTermsAnnDbBimap 111 | \dontrun{##I want to show an ex., but don't want to require GO.db 112 | require(GO.db) 113 | FirstTenGOBimap <- GOTERM[1:10] ##grab the 1st ten 114 | Term(FirstTenGOBimap) 115 | 116 | ##Or you can just use GO IDs directly 117 | ids = keys(FirstTenGOBimap) 118 | Term(ids) 119 | } 120 | } 121 | 122 | \keyword{methods} 123 | \keyword{classes} 124 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_1.0/ECOLI_DB.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- ECOLI_DB schema 3 | -- =============== 4 | -- 5 | 6 | -- The "genes" table is the central table. 7 | CREATE TABLE genes ( 8 | _id INTEGER PRIMARY KEY, 9 | gene_id VARCHAR(10) NOT NULL UNIQUE -- Entrez Gene ID 10 | ); 11 | 12 | -- Data linked to the "genes" table. 13 | CREATE TABLE accessions ( 14 | _id INTEGER NOT NULL, -- REFERENCES genes 15 | accession VARCHAR(20) NOT NULL, -- GenBank accession number 16 | FOREIGN KEY (_id) REFERENCES genes (_id) 17 | ); 18 | CREATE TABLE alias ( 19 | _id INTEGER NOT NULL, -- REFERENCES genes 20 | alias_symbol VARCHAR(80) NOT NULL, -- gene symbol or alias 21 | FOREIGN KEY (_id) REFERENCES genes (_id) 22 | ); 23 | CREATE TABLE ec ( 24 | _id INTEGER NOT NULL, -- REFERENCES genes 25 | ec_number VARCHAR(13) NOT NULL, -- EC number (no "EC:" prefix) 26 | FOREIGN KEY (_id) REFERENCES genes (_id) 27 | ); 28 | CREATE TABLE gene_info ( 29 | _id INTEGER NOT NULL UNIQUE, -- REFERENCES genes 30 | gene_name VARCHAR(255) NOT NULL, -- gene name 31 | symbol VARCHAR(80) NOT NULL, -- gene symbol 32 | FOREIGN KEY (_id) REFERENCES genes (_id) 33 | ); 34 | CREATE TABLE go_bp ( 35 | _id INTEGER NOT NULL, -- REFERENCES genes 36 | go_id CHAR(10) NOT NULL, -- GO ID 37 | evidence CHAR(3) NOT NULL, -- GO evidence code 38 | FOREIGN KEY (_id) REFERENCES genes (_id) 39 | ); 40 | CREATE TABLE go_bp_all ( 41 | _id INTEGER NOT NULL, -- REFERENCES genes 42 | go_id CHAR(10) NOT NULL, -- GO ID 43 | evidence CHAR(3) NOT NULL, -- GO evidence code 44 | FOREIGN KEY (_id) REFERENCES genes (_id) 45 | ); 46 | CREATE TABLE go_cc ( 47 | _id INTEGER NOT NULL, -- REFERENCES genes 48 | go_id CHAR(10) NOT NULL, -- GO ID 49 | evidence CHAR(3) NOT NULL, -- GO evidence code 50 | FOREIGN KEY (_id) REFERENCES genes (_id) 51 | ); 52 | CREATE TABLE go_cc_all ( 53 | _id INTEGER NOT NULL, -- REFERENCES genes 54 | go_id CHAR(10) NOT NULL, -- GO ID 55 | evidence CHAR(3) NOT NULL, -- GO evidence code 56 | FOREIGN KEY (_id) REFERENCES genes (_id) 57 | ); 58 | CREATE TABLE go_mf ( 59 | _id INTEGER NOT NULL, -- REFERENCES genes 60 | go_id CHAR(10) NOT NULL, -- GO ID 61 | evidence CHAR(3) NOT NULL, -- GO evidence code 62 | FOREIGN KEY (_id) REFERENCES genes (_id) 63 | ); 64 | CREATE TABLE go_mf_all ( 65 | _id INTEGER NOT NULL, -- REFERENCES genes 66 | go_id CHAR(10) NOT NULL, -- GO ID 67 | evidence CHAR(3) NOT NULL, -- GO evidence code 68 | FOREIGN KEY (_id) REFERENCES genes (_id) 69 | ); 70 | CREATE TABLE kegg ( 71 | _id INTEGER NOT NULL, -- REFERENCES genes 72 | path_id CHAR(5) NOT NULL, -- KEGG pathway short ID 73 | FOREIGN KEY (_id) REFERENCES genes (_id) 74 | ); 75 | CREATE TABLE pubmed ( 76 | _id INTEGER NOT NULL, -- REFERENCES genes 77 | pubmed_id VARCHAR(10) NOT NULL, -- PubMed ID 78 | FOREIGN KEY (_id) REFERENCES genes (_id) 79 | ); 80 | CREATE TABLE refseq ( 81 | _id INTEGER NOT NULL, -- REFERENCES genes 82 | accession VARCHAR(20) NOT NULL, -- RefSeq accession number 83 | FOREIGN KEY (_id) REFERENCES genes (_id) 84 | ); 85 | 86 | 87 | -- Metadata tables. 88 | CREATE TABLE metadata ( 89 | name VARCHAR(80) PRIMARY KEY, 90 | value VARCHAR(255) 91 | ); 92 | CREATE TABLE map_counts ( 93 | map_name VARCHAR(80) PRIMARY KEY, 94 | count INTEGER NOT NULL 95 | ); 96 | CREATE TABLE map_metadata ( 97 | map_name VARCHAR(80) NOT NULL, 98 | source_name VARCHAR(80) NOT NULL, 99 | source_url VARCHAR(255) NOT NULL, 100 | source_date VARCHAR(20) NOT NULL 101 | ); 102 | 103 | -- Explicit index creation on the referencing column of all the foreign keys. 104 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 105 | -- indexes automatically. 106 | CREATE INDEX Faccessions ON accessions (_id); 107 | CREATE INDEX Falias ON alias (_id); 108 | CREATE INDEX Fec ON ec (_id); 109 | CREATE INDEX Fgo_bp ON go_bp (_id); 110 | CREATE INDEX Fgo_bp_all ON go_bp_all (_id); 111 | CREATE INDEX Fgo_cc ON go_cc (_id); 112 | CREATE INDEX Fgo_cc_all ON go_cc_all (_id); 113 | CREATE INDEX Fgo_mf ON go_mf (_id); 114 | CREATE INDEX Fgo_mf_all ON go_mf_all (_id); 115 | CREATE INDEX Fkegg ON kegg (_id); 116 | CREATE INDEX Fpubmed ON pubmed (_id); 117 | CREATE INDEX Frefseq ON refseq (_id); 118 | 119 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_0.9/YEASTCHIP_DB.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- YEASTCHIP_DB schema 3 | -- =================== 4 | -- 5 | 6 | -- The "sgd" table is the central table. 7 | CREATE TABLE sgd ( 8 | id INTEGER PRIMARY KEY, 9 | systematic_name VARCHAR(14) NULL UNIQUE, -- Yeast ORF ID 10 | gene_name VARCHAR(14) NULL UNIQUE, -- Yeast gene name 11 | sgd_id CHAR(10) NOT NULL UNIQUE -- SGD ID 12 | ); 13 | 14 | -- Data linked to the "sgd" table. 15 | CREATE TABLE probes ( 16 | id INTEGER NULL, -- REFERENCES sgd 17 | probe_id VARCHAR(80) PRIMARY KEY, -- manufacturer ID 18 | FOREIGN KEY (id) REFERENCES sgd (id) 19 | ); 20 | CREATE TABLE chromosome_features ( 21 | id INTEGER NOT NULL, -- REFERENCES sgd 22 | chromosome VARCHAR(2) NULL, -- chromosome name 23 | start INTEGER NULL, 24 | feature_description TEXT NULL, -- Yeast feature description 25 | FOREIGN KEY (id) REFERENCES sgd (id) 26 | ); 27 | CREATE TABLE ec ( 28 | id INTEGER NOT NULL, -- REFERENCES sgd 29 | ec_number VARCHAR(13) NOT NULL, -- EC number (no "EC:" prefix) 30 | FOREIGN KEY (id) REFERENCES sgd (id) 31 | ); 32 | CREATE TABLE gene2alias ( 33 | id INTEGER NOT NULL, -- REFERENCES sgd 34 | alias VARCHAR(13) NOT NULL, -- Yeast gene alias 35 | FOREIGN KEY (id) REFERENCES sgd (id) 36 | ); 37 | CREATE TABLE go_bp ( 38 | id INTEGER NOT NULL, -- REFERENCES sgd 39 | go_id CHAR(10) NOT NULL, -- GO ID 40 | evidence CHAR(3) NOT NULL, -- GO evidence code 41 | FOREIGN KEY (id) REFERENCES sgd (id) 42 | ); 43 | CREATE TABLE go_bp_all ( 44 | id INTEGER NOT NULL, -- REFERENCES sgd 45 | go_id CHAR(10) NOT NULL, -- GO ID 46 | evidence CHAR(3) NOT NULL, -- GO evidence code 47 | FOREIGN KEY (id) REFERENCES sgd (id) 48 | ); 49 | CREATE TABLE go_cc ( 50 | id INTEGER NOT NULL, -- REFERENCES sgd 51 | go_id CHAR(10) NOT NULL, -- GO ID 52 | evidence CHAR(3) NOT NULL, -- GO evidence code 53 | FOREIGN KEY (id) REFERENCES sgd (id) 54 | ); 55 | CREATE TABLE go_cc_all ( 56 | id INTEGER NOT NULL, -- REFERENCES sgd 57 | go_id CHAR(10) NOT NULL, -- GO ID 58 | evidence CHAR(3) NOT NULL, -- GO evidence code 59 | FOREIGN KEY (id) REFERENCES sgd (id) 60 | ); 61 | CREATE TABLE go_mf ( 62 | id INTEGER NOT NULL, -- REFERENCES sgd 63 | go_id CHAR(10) NOT NULL, -- GO ID 64 | evidence CHAR(3) NOT NULL, -- GO evidence code 65 | FOREIGN KEY (id) REFERENCES sgd (id) 66 | ); 67 | CREATE TABLE go_mf_all ( 68 | id INTEGER NOT NULL, -- REFERENCES sgd 69 | go_id CHAR(10) NOT NULL, -- GO ID 70 | evidence CHAR(3) NOT NULL, -- GO evidence code 71 | FOREIGN KEY (id) REFERENCES sgd (id) 72 | ); 73 | CREATE TABLE kegg ( 74 | id INTEGER NOT NULL, -- REFERENCES sgd 75 | kegg_id CHAR(5) NOT NULL, -- KEGG pathway short ID 76 | FOREIGN KEY (id) REFERENCES sgd (id) 77 | ); 78 | CREATE TABLE pubmed ( 79 | id INTEGER NOT NULL, -- REFERENCES sgd 80 | pubmed_id VARCHAR(10) NOT NULL, -- PubMed ID 81 | FOREIGN KEY (id) REFERENCES sgd (id) 82 | ); 83 | 84 | -- Standalone data tables. 85 | CREATE TABLE chrlengths ( 86 | chr VARCHAR(2) PRIMARY KEY, -- chromosome name 87 | length INTEGER NOT NULL 88 | ); 89 | 90 | -- Metadata tables. 91 | CREATE TABLE metadata ( 92 | name VARCHAR(80) PRIMARY KEY, 93 | value VARCHAR(255) 94 | ); 95 | CREATE TABLE qcdata ( 96 | map_name VARCHAR(80) PRIMARY KEY, 97 | count INTEGER NOT NULL 98 | ); 99 | CREATE TABLE map_metadata ( 100 | map_name VARCHAR(80) NOT NULL, 101 | source_name VARCHAR(80) NOT NULL, 102 | source_url VARCHAR(255) NOT NULL, 103 | source_date VARCHAR(20) NOT NULL 104 | ); 105 | 106 | -- Explicit index creation on the referencing column of all the foreign keys. 107 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 108 | -- indexes automatically. 109 | CREATE INDEX Fprobes ON probes (id); 110 | CREATE INDEX Fchromosome_features ON chromosome_features (id); 111 | CREATE INDEX Fec ON ec (id); 112 | CREATE INDEX Fgene2alias ON gene2alias (id); 113 | CREATE INDEX Fgo_bp ON go_bp (id); 114 | CREATE INDEX Fgo_bp_all ON go_bp_all (id); 115 | CREATE INDEX Fgo_cc ON go_cc (id); 116 | CREATE INDEX Fgo_cc_all ON go_cc_all (id); 117 | CREATE INDEX Fgo_mf ON go_mf (id); 118 | CREATE INDEX Fgo_mf_all ON go_mf_all (id); 119 | CREATE INDEX Fkegg ON kegg (id); 120 | CREATE INDEX Fpubmed ON pubmed (id); 121 | 122 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_1.0/ECOLICHIP_DB.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- ECOLICHIP_DB schema 3 | -- =================== 4 | -- 5 | 6 | -- The "genes" table is the central table. 7 | CREATE TABLE genes ( 8 | _id INTEGER PRIMARY KEY, 9 | gene_id VARCHAR(10) NOT NULL UNIQUE -- Entrez Gene ID 10 | ); 11 | 12 | -- Data linked to the "genes" table. 13 | CREATE TABLE probes ( 14 | probe_id VARCHAR(80) PRIMARY KEY, -- manufacturer ID 15 | accession VARCHAR(20) NULL, -- GenBank accession number 16 | _id INTEGER NULL, -- REFERENCES genes 17 | FOREIGN KEY (_id) REFERENCES genes (_id) 18 | ); 19 | CREATE TABLE alias ( 20 | _id INTEGER NOT NULL, -- REFERENCES genes 21 | alias_symbol VARCHAR(80) NOT NULL, -- gene symbol or alias 22 | FOREIGN KEY (_id) REFERENCES genes (_id) 23 | ); 24 | CREATE TABLE ec ( 25 | _id INTEGER NOT NULL, -- REFERENCES genes 26 | ec_number VARCHAR(13) NOT NULL, -- EC number (no "EC:" prefix) 27 | FOREIGN KEY (_id) REFERENCES genes (_id) 28 | ); 29 | CREATE TABLE gene_info ( 30 | _id INTEGER NOT NULL UNIQUE, -- REFERENCES genes 31 | gene_name VARCHAR(255) NOT NULL, -- gene name 32 | symbol VARCHAR(80) NOT NULL, -- gene symbol 33 | FOREIGN KEY (_id) REFERENCES genes (_id) 34 | ); 35 | CREATE TABLE go_bp ( 36 | _id INTEGER NOT NULL, -- REFERENCES genes 37 | go_id CHAR(10) NOT NULL, -- GO ID 38 | evidence CHAR(3) NOT NULL, -- GO evidence code 39 | FOREIGN KEY (_id) REFERENCES genes (_id) 40 | ); 41 | CREATE TABLE go_bp_all ( 42 | _id INTEGER NOT NULL, -- REFERENCES genes 43 | go_id CHAR(10) NOT NULL, -- GO ID 44 | evidence CHAR(3) NOT NULL, -- GO evidence code 45 | FOREIGN KEY (_id) REFERENCES genes (_id) 46 | ); 47 | CREATE TABLE go_cc ( 48 | _id INTEGER NOT NULL, -- REFERENCES genes 49 | go_id CHAR(10) NOT NULL, -- GO ID 50 | evidence CHAR(3) NOT NULL, -- GO evidence code 51 | FOREIGN KEY (_id) REFERENCES genes (_id) 52 | ); 53 | CREATE TABLE go_cc_all ( 54 | _id INTEGER NOT NULL, -- REFERENCES genes 55 | go_id CHAR(10) NOT NULL, -- GO ID 56 | evidence CHAR(3) NOT NULL, -- GO evidence code 57 | FOREIGN KEY (_id) REFERENCES genes (_id) 58 | ); 59 | CREATE TABLE go_mf ( 60 | _id INTEGER NOT NULL, -- REFERENCES genes 61 | go_id CHAR(10) NOT NULL, -- GO ID 62 | evidence CHAR(3) NOT NULL, -- GO evidence code 63 | FOREIGN KEY (_id) REFERENCES genes (_id) 64 | ); 65 | CREATE TABLE go_mf_all ( 66 | _id INTEGER NOT NULL, -- REFERENCES genes 67 | go_id CHAR(10) NOT NULL, -- GO ID 68 | evidence CHAR(3) NOT NULL, -- GO evidence code 69 | FOREIGN KEY (_id) REFERENCES genes (_id) 70 | ); 71 | CREATE TABLE kegg ( 72 | _id INTEGER NOT NULL, -- REFERENCES genes 73 | path_id CHAR(5) NOT NULL, -- KEGG pathway short ID 74 | FOREIGN KEY (_id) REFERENCES genes (_id) 75 | ); 76 | CREATE TABLE pubmed ( 77 | _id INTEGER NOT NULL, -- REFERENCES genes 78 | pubmed_id VARCHAR(10) NOT NULL, -- PubMed ID 79 | FOREIGN KEY (_id) REFERENCES genes (_id) 80 | ); 81 | CREATE TABLE refseq ( 82 | _id INTEGER NOT NULL, -- REFERENCES genes 83 | accession VARCHAR(20) NOT NULL, -- RefSeq accession number 84 | FOREIGN KEY (_id) REFERENCES genes (_id) 85 | ); 86 | 87 | 88 | -- Metadata tables. 89 | CREATE TABLE metadata ( 90 | name VARCHAR(80) PRIMARY KEY, 91 | value VARCHAR(255) 92 | ); 93 | CREATE TABLE map_counts ( 94 | map_name VARCHAR(80) PRIMARY KEY, 95 | count INTEGER NOT NULL 96 | ); 97 | CREATE TABLE map_metadata ( 98 | map_name VARCHAR(80) NOT NULL, 99 | source_name VARCHAR(80) NOT NULL, 100 | source_url VARCHAR(255) NOT NULL, 101 | source_date VARCHAR(20) NOT NULL 102 | ); 103 | 104 | -- Explicit index creation on the referencing column of all the foreign keys. 105 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 106 | -- indexes automatically. 107 | CREATE INDEX Fprobes ON probes (_id); 108 | CREATE INDEX Falias ON alias (_id); 109 | CREATE INDEX Fec ON ec (_id); 110 | CREATE INDEX Fgo_bp ON go_bp (_id); 111 | CREATE INDEX Fgo_bp_all ON go_bp_all (_id); 112 | CREATE INDEX Fgo_cc ON go_cc (_id); 113 | CREATE INDEX Fgo_cc_all ON go_cc_all (_id); 114 | CREATE INDEX Fgo_mf ON go_mf (_id); 115 | CREATE INDEX Fgo_mf_all ON go_mf_all (_id); 116 | CREATE INDEX Fkegg ON kegg (_id); 117 | CREATE INDEX Fpubmed ON pubmed (_id); 118 | CREATE INDEX Frefseq ON refseq (_id); 119 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_1.0/YEASTCHIP_DB.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- YEASTCHIP_DB schema 3 | -- =================== 4 | -- 5 | 6 | -- The "sgd" table is the central table. 7 | CREATE TABLE sgd ( 8 | _id INTEGER PRIMARY KEY, 9 | systematic_name VARCHAR(14) NULL UNIQUE, -- Yeast ORF ID 10 | gene_name VARCHAR(14) NULL UNIQUE, -- Yeast gene name 11 | sgd_id CHAR(10) NOT NULL UNIQUE -- SGD ID 12 | ); 13 | 14 | -- Data linked to the "sgd" table. 15 | CREATE TABLE probes ( 16 | probe_id VARCHAR(80) PRIMARY KEY, -- manufacturer ID 17 | _id INTEGER NULL, -- REFERENCES sgd 18 | FOREIGN KEY (_id) REFERENCES sgd (_id) 19 | ); 20 | CREATE TABLE chromosome_features ( 21 | _id INTEGER NOT NULL, -- REFERENCES sgd 22 | chromosome VARCHAR(2) NULL, -- chromosome name 23 | start INTEGER NULL, 24 | feature_description TEXT NULL, -- Yeast feature description 25 | FOREIGN KEY (_id) REFERENCES sgd (_id) 26 | ); 27 | CREATE TABLE ec ( 28 | _id INTEGER NOT NULL, -- REFERENCES sgd 29 | ec_number VARCHAR(13) NOT NULL, -- EC number (no "EC:" prefix) 30 | FOREIGN KEY (_id) REFERENCES sgd (_id) 31 | ); 32 | CREATE TABLE gene2alias ( 33 | _id INTEGER NOT NULL, -- REFERENCES sgd 34 | alias VARCHAR(13) NOT NULL, -- Yeast gene alias 35 | FOREIGN KEY (_id) REFERENCES sgd (_id) 36 | ); 37 | CREATE TABLE go_bp ( 38 | _id INTEGER NOT NULL, -- REFERENCES sgd 39 | go_id CHAR(10) NOT NULL, -- GO ID 40 | evidence CHAR(3) NOT NULL, -- GO evidence code 41 | FOREIGN KEY (_id) REFERENCES sgd (_id) 42 | ); 43 | CREATE TABLE go_bp_all ( 44 | _id INTEGER NOT NULL, -- REFERENCES sgd 45 | go_id CHAR(10) NOT NULL, -- GO ID 46 | evidence CHAR(3) NOT NULL, -- GO evidence code 47 | FOREIGN KEY (_id) REFERENCES sgd (_id) 48 | ); 49 | CREATE TABLE go_cc ( 50 | _id INTEGER NOT NULL, -- REFERENCES sgd 51 | go_id CHAR(10) NOT NULL, -- GO ID 52 | evidence CHAR(3) NOT NULL, -- GO evidence code 53 | FOREIGN KEY (_id) REFERENCES sgd (_id) 54 | ); 55 | CREATE TABLE go_cc_all ( 56 | _id INTEGER NOT NULL, -- REFERENCES sgd 57 | go_id CHAR(10) NOT NULL, -- GO ID 58 | evidence CHAR(3) NOT NULL, -- GO evidence code 59 | FOREIGN KEY (_id) REFERENCES sgd (_id) 60 | ); 61 | CREATE TABLE go_mf ( 62 | _id INTEGER NOT NULL, -- REFERENCES sgd 63 | go_id CHAR(10) NOT NULL, -- GO ID 64 | evidence CHAR(3) NOT NULL, -- GO evidence code 65 | FOREIGN KEY (_id) REFERENCES sgd (_id) 66 | ); 67 | CREATE TABLE go_mf_all ( 68 | _id INTEGER NOT NULL, -- REFERENCES sgd 69 | go_id CHAR(10) NOT NULL, -- GO ID 70 | evidence CHAR(3) NOT NULL, -- GO evidence code 71 | FOREIGN KEY (_id) REFERENCES sgd (_id) 72 | ); 73 | CREATE TABLE kegg ( 74 | _id INTEGER NOT NULL, -- REFERENCES sgd 75 | path_id CHAR(5) NOT NULL, -- KEGG pathway short ID 76 | FOREIGN KEY (_id) REFERENCES sgd (_id) 77 | ); 78 | CREATE TABLE pubmed ( 79 | _id INTEGER NOT NULL, -- REFERENCES sgd 80 | pubmed_id VARCHAR(10) NOT NULL, -- PubMed ID 81 | FOREIGN KEY (_id) REFERENCES sgd (_id) 82 | ); 83 | 84 | -- Standalone data tables. 85 | CREATE TABLE chrlengths ( 86 | chromosome VARCHAR(2) PRIMARY KEY, -- chromosome name 87 | length INTEGER NOT NULL 88 | ); 89 | 90 | -- Metadata tables. 91 | CREATE TABLE metadata ( 92 | name VARCHAR(80) PRIMARY KEY, 93 | value VARCHAR(255) 94 | ); 95 | CREATE TABLE map_counts ( 96 | map_name VARCHAR(80) PRIMARY KEY, 97 | count INTEGER NOT NULL 98 | ); 99 | CREATE TABLE map_metadata ( 100 | map_name VARCHAR(80) NOT NULL, 101 | source_name VARCHAR(80) NOT NULL, 102 | source_url VARCHAR(255) NOT NULL, 103 | source_date VARCHAR(20) NOT NULL 104 | ); 105 | 106 | -- Explicit index creation on the referencing column of all the foreign keys. 107 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 108 | -- indexes automatically. 109 | CREATE INDEX Fprobes ON probes (_id); 110 | CREATE INDEX Fchromosome_features ON chromosome_features (_id); 111 | CREATE INDEX Fec ON ec (_id); 112 | CREATE INDEX Fgene2alias ON gene2alias (_id); 113 | CREATE INDEX Fgo_bp ON go_bp (_id); 114 | CREATE INDEX Fgo_bp_all ON go_bp_all (_id); 115 | CREATE INDEX Fgo_cc ON go_cc (_id); 116 | CREATE INDEX Fgo_cc_all ON go_cc_all (_id); 117 | CREATE INDEX Fgo_mf ON go_mf (_id); 118 | CREATE INDEX Fgo_mf_all ON go_mf_all (_id); 119 | CREATE INDEX Fkegg ON kegg (_id); 120 | CREATE INDEX Fpubmed ON pubmed (_id); 121 | 122 | -------------------------------------------------------------------------------- /inst/unitTests/test_select_NOSCHEMA.R: -------------------------------------------------------------------------------- 1 | ## this will install a testDb stashed in the 2 | 3 | ## ## this is the package name 4 | ## pkgName <- "org.testing.db" 5 | 6 | ## ## Get the package path 7 | ## pkgPath <- system.file("extdata", pkgName, package="AnnotationDbi") 8 | 9 | ## ## Then install it 10 | ## install.packages(pkgPath, repos=NULL) 11 | ## and load it 12 | #####install.packages(system.file('extdata','org.testing.db', package='AnnotationDbi'), repos=NULL) 13 | 14 | 15 | dir.create(testlib <- tempfile()) 16 | old_libPaths <- NULL 17 | 18 | .setUp <- function() 19 | { 20 | installed <- rownames(installed.packages(testlib)) 21 | if ("org.testing.db" %in% installed) 22 | return() 23 | pkg <- system.file("extdata", "org.testing.db", package="AnnotationDbi") 24 | suppressPackageStartupMessages(install.packages( 25 | pkg, lib = testlib, repos=NULL, type="source", 26 | INSTALL_opts="--no-test-load", verbose = FALSE, quiet = TRUE 27 | )) 28 | old_libPaths <<- .libPaths() 29 | .libPaths(c(testlib, old_libPaths)) 30 | finchCsomes <<- c(as.character(1:15),as.character(17:28), 31 | "MT","Un","W","Z","4A","1A","1B") 32 | finchCols <<- c("CHROMOSOME","SYMBOL","GENENAME","GID","GO","EVIDENCE", 33 | "ONTOLOGY","GOALL","EVIDENCEALL","ONTOLOGYALL") 34 | } 35 | 36 | .tearDown <- function() 37 | .libPaths(old_libPaths) 38 | 39 | ## lower level tests (more useful) 40 | test_keysLow <- function(){ 41 | x <- org.testing.db::org.testing.db 42 | res <- unique(AnnotationDbi:::.noSchemaKeys(x, "CHROMOSOME")) 43 | checkTrue(all(sort(res) == sort(finchCsomes))) 44 | } 45 | 46 | 47 | test_selectLow <- function(){ 48 | x <- org.testing.db::org.testing.db 49 | keys <- "100008579" 50 | cols <- "SYMBOL" 51 | keytype <- "GID" 52 | res <- AnnotationDbi:::.noSchemaSelect(x, keys, cols, keytype) 53 | checkTrue(all(res==c("100008579","EGR1"))) 54 | checkTrue(all(colnames(res)==c("GID","SYMBOL"))) 55 | 56 | keys <- "brain-derived neurotrophic factor" 57 | cols <- c("SYMBOL","GID") 58 | keytype <- "GENENAME" 59 | res <- AnnotationDbi:::.noSchemaSelect(x, keys, cols, keytype) 60 | checkTrue(all(res==c("brain-derived neurotrophic factor","BDNF","751584"))) 61 | checkTrue(all(colnames(res)==c("GENENAME","SYMBOL","GID"))) 62 | 63 | keys <- "brain-derived neurotrophic factor" 64 | cols <- c("GO","GID") 65 | keytype <- "GENENAME" 66 | res <- head(AnnotationDbi:::.noSchemaSelect(x, keys, cols, keytype),n=1) 67 | checkTrue(all(res==c("brain-derived neurotrophic factor","GO:0001657", 68 | "751584"))) 69 | checkTrue(all(colnames(res)==c("GENENAME","GO","GID"))) 70 | } 71 | 72 | 73 | ## high level tests (does this dispatch right etc.?) 74 | test_columns <- function(){ 75 | x <- org.testing.db::org.testing.db 76 | res <- columns(x) 77 | checkTrue(all(sort(res) == sort(finchCols))) 78 | } 79 | 80 | test_keytypes <- function(){ 81 | x <- org.testing.db::org.testing.db 82 | res <- keytypes(x) 83 | checkTrue(all(sort(res) == sort(finchCols))) 84 | } 85 | 86 | test_keys<- function(){ ## BOOM 87 | x <- org.testing.db::org.testing.db 88 | ## most basic case 89 | res <- keys(x, "CHROMOSOME") 90 | checkTrue(all(sort(res) == sort(finchCsomes))) 91 | 92 | res <- head(keys(x, "GID"), n=2) 93 | checkTrue(all(res==c("751582", "751583"))) 94 | 95 | res <- head(keys(x, "SYMBOL", pattern="BDNF")) 96 | checkTrue(res=="BDNF") 97 | 98 | res <- head(keys(x, "GID", pattern="BDNF", column="SYMBOL")) 99 | checkTrue(res=="751584") 100 | 101 | res <- head(keys(x, "SYMBOL", column="GID"),n=2) 102 | checkTrue(all(res==c("ACT5C","AHSA2"))) 103 | } 104 | 105 | 106 | test_select <- function(){ 107 | x <- org.testing.db::org.testing.db 108 | ## most basic case 109 | res <- select(x, keys="100008579", 110 | columns="SYMBOL", keytype="GID") 111 | checkTrue(all(res==c("100008579","EGR1"))) 112 | checkTrue(all(colnames(res)==c("GID","SYMBOL"))) 113 | 114 | ## return more than one column 115 | res <- select(x, keys="100008579", 116 | columns=c("SYMBOL","CHROMOSOME"), keytype="GID") 117 | checkTrue(all(res==c("100008579","EGR1","13"))) 118 | checkTrue(all(colnames(res)==c("GID","SYMBOL","CHROMOSOME"))) 119 | 120 | ## return GO and evidence codes 121 | suppressWarnings(res <- head(select(x, keys="100008579", 122 | columns=c("GO","EVIDENCE"), keytype="GID"),n=1)) 123 | checkTrue(all(res==c("100008579","GO:0000122","IEA"))) 124 | checkTrue(all(colnames(res)==c("GID","GO","EVIDENCE"))) 125 | 126 | ## test lookup from alt-key 127 | res <- select(x, keys="BDNF", 128 | columns="GENENAME", keytype="SYMBOL") 129 | checkTrue(all(res==c("BDNF","brain-derived neurotrophic factor"))) 130 | checkTrue(all(colnames(res)==c("SYMBOL","GENENAME"))) 131 | 132 | } 133 | -------------------------------------------------------------------------------- /R/flatten.R: -------------------------------------------------------------------------------- 1 | ### 2 | ### Flattening different kinds of environments and maps 3 | ### 4 | ### A toCV. function takes a vector (or a single NA) and returns 5 | ### a character vector of the same length (or NULL). 6 | ### A _CVL object is a list of character vector or NULL elements. 7 | ### 8 | 9 | ### Flatten the GO envir found in HUMANCHIP, MOUSECHIP and RATCHIP packages. 10 | flatten.GOenvir <- function(env) 11 | { 12 | ## 'x' is a named list of "GO triplets". The names are the GO ids. 13 | ## A "GO triplet" is itself a list with 3 elements (GOID, Evidence, 14 | ## Ontology). 15 | toCV.go_id <- function(x) 16 | { 17 | if (!is.list(x)) { 18 | if (!isTRUE(is.na(x))) 19 | warning("right value in GO map is neither a list or a single NA") 20 | return(NULL) 21 | } 22 | names(x) 23 | } 24 | toCV.Evidence <- function(x) 25 | { 26 | if (!is.list(x)) { 27 | if (!isTRUE(is.na(x))) 28 | warning("right value in GO map is neither a list or a single NA") 29 | return(NULL) 30 | } 31 | sapply(x, function(goelt) goelt$Evidence, USE.NAMES=FALSE) 32 | } 33 | toCV.Ontology <- function(x) 34 | { 35 | if (!is.list(x)) { 36 | if (!isTRUE(is.na(x))) 37 | warning("right value in GO map is neither a list or a single NA") 38 | return(NULL) 39 | } 40 | sapply(x, function(goelt) goelt$Ontology, USE.NAMES=FALSE) 41 | } 42 | go_id_CVL <- eapply(env, toCV.go_id, all.names=TRUE) 43 | Evidence_CVL <- eapply(env, toCV.Evidence, all.names=TRUE) 44 | Ontology_CVL <- eapply(env, toCV.Ontology, all.names=TRUE) 45 | 46 | lens <- sapply(go_id_CVL, length) 47 | probe_id <- rep.int(names(go_id_CVL), lens) 48 | go_id <- unlist(go_id_CVL, recursive=FALSE, use.names=FALSE) 49 | Evidence <- unlist(Evidence_CVL, recursive=FALSE, use.names=FALSE) 50 | Ontology <- unlist(Ontology_CVL, recursive=FALSE, use.names=FALSE) 51 | 52 | data.frame(probe_id=probe_id, Evidence=Evidence, go_id=go_id, 53 | Ontology=Ontology, stringsAsFactors=FALSE) 54 | } 55 | 56 | ### Flatten the GO2PROBE and GO2ALLPROBES envir found in HUMANCHIP, 57 | ### MOUSECHIP and RATCHIP packages. 58 | flatten.GO2PROBEenvir <- function(env) 59 | { 60 | ## 'x' is a named character vector of probe ids. The names are the 61 | ## Evidence codes. 62 | toCV.probe_id <- function(x) 63 | { 64 | if (any(is.na(x))) 65 | warning("left value in GO2PROBE map contains NAs") 66 | x 67 | } 68 | toCV.Evidence <- function(x) 69 | { 70 | Evidence <- names(x) 71 | if (any(is.na(Evidence))) 72 | warning("left value in GO2PROBE map contains NAs") 73 | Evidence 74 | } 75 | probe_id_CVL <- eapply(env, toCV.probe_id, all.names=TRUE) 76 | Evidence_CVL <- eapply(env, toCV.Evidence, all.names=TRUE) 77 | 78 | lens <- sapply(probe_id_CVL, length) 79 | go_id <- rep.int(names(probe_id_CVL), lens) 80 | probe_id <- unlist(probe_id_CVL, recursive=FALSE, use.names=FALSE) 81 | Evidence <- unlist(Evidence_CVL, recursive=FALSE, use.names=FALSE) 82 | 83 | data.frame(probe_id=probe_id, Evidence=Evidence, go_id=go_id, 84 | stringsAsFactors=FALSE) 85 | } 86 | 87 | ### Some sanity checking 88 | checkPROBE2GOmappings <- function(GO, GO2PROBE, GO2ALLPROBES) 89 | { 90 | cat("Checking PROBE2GO mappings:\n") 91 | 92 | is_mapped <- eapply(GO, function(x) !(is.atomic(x) && is.vector(x) && isTRUE(is.na(x))), all.names=TRUE) 93 | is_mapped <- unlist(is_mapped, recursive=FALSE, use.names=TRUE) 94 | mapped_probe_id <- sort(names(is_mapped)[is_mapped]) 95 | cat(length(mapped_probe_id), " probe ids are mapped to at least 1 GO id\n", sep="") 96 | 97 | GOflat <- flatten.GOenvir(GO) 98 | ii <- order(GOflat$probe_id, GOflat$go_id, GOflat$Evidence) 99 | GOflat <- GOflat[ii, ] 100 | if (!identical(unique(GOflat$probe_id), mapped_probe_id)) 101 | stop("unexpected or missing probe ids in flat representation of GO") 102 | 103 | GO2PROBEflat <- flatten.GO2PROBEenvir(GO2PROBE) 104 | ii <- order(GO2PROBEflat$probe_id, GO2PROBEflat$go_id, GO2PROBEflat$Evidence) 105 | GO2PROBEflat <- GO2PROBEflat[ii, ] 106 | if (!identical(unique(GO2PROBEflat$probe_id), mapped_probe_id)) 107 | stop("unexpected or missing probe ids in flat representation of GO2PROBE") 108 | 109 | if (!all(GOflat[ , c("probe_id", "Evidence", "go_id")] == GO2PROBEflat)) 110 | stop("flat representations of GO and GO2PROBE differ") 111 | 112 | GO2ALLPROBESflat <- flatten.GO2PROBEenvir(GO2ALLPROBES) 113 | ii <- order(GO2ALLPROBESflat$probe_id, GO2ALLPROBESflat$go_id, GO2ALLPROBESflat$Evidence) 114 | GO2ALLPROBESflat <- GO2ALLPROBESflat[ii, ] 115 | if (!identical(unique(GO2ALLPROBESflat$probe_id), mapped_probe_id)) 116 | stop("unexpected or missing probe ids in flat representation of GO2ALLPROBESflat") 117 | 118 | 119 | } 120 | 121 | -------------------------------------------------------------------------------- /R/AllGenerics.R: -------------------------------------------------------------------------------- 1 | ### Bimap interface 2 | ### (Please don't sort this section in alphabetical order) 3 | setGeneric("direction", function(x) standardGeneric("direction")) 4 | setGeneric("direction<-", signature="x", function(x, value) standardGeneric("direction<-")) 5 | setGeneric("revmap", function(x, ...) standardGeneric("revmap")) 6 | setGeneric("colmetanames", function(x) standardGeneric("colmetanames")) 7 | setGeneric("Lkeyname", function(x) standardGeneric("Lkeyname")) 8 | setGeneric("Rkeyname", function(x) standardGeneric("Rkeyname")) 9 | setGeneric("keyname", function(x) standardGeneric("keyname")) 10 | setGeneric("tagname", function(x) standardGeneric("tagname")) 11 | setGeneric("Rattribnames", function(x) standardGeneric("Rattribnames")) 12 | setGeneric("Rattribnames<-", signature="x", function(x, value) standardGeneric("Rattribnames<-")) 13 | setGeneric("Lkeys", function(x) standardGeneric("Lkeys")) 14 | setGeneric("Rkeys", function(x) standardGeneric("Rkeys")) 15 | setGeneric("keys", signature="x", 16 | function(x, keytype, ...) standardGeneric("keys")) 17 | setGeneric("Lkeys<-", signature="x", function(x, value) standardGeneric("Lkeys<-")) 18 | setGeneric("Rkeys<-", signature="x", function(x, value) standardGeneric("Rkeys<-")) 19 | setGeneric("keys<-", signature="x", function(x, value) standardGeneric("keys<-")) 20 | setGeneric("Llength", function(x) standardGeneric("Llength")) 21 | setGeneric("Rlength", function(x) standardGeneric("Rlength")) 22 | setGeneric("isNA", function(x) standardGeneric("isNA")) 23 | setGeneric("mappedLkeys", function(x) standardGeneric("mappedLkeys")) 24 | setGeneric("mappedRkeys", function(x) standardGeneric("mappedRkeys")) 25 | setGeneric("mappedkeys", function(x) standardGeneric("mappedkeys")) 26 | setGeneric("count.mappedLkeys", function(x) standardGeneric("count.mappedLkeys")) 27 | setGeneric("count.mappedRkeys", function(x) standardGeneric("count.mappedRkeys")) 28 | setGeneric("count.mappedkeys", function(x) standardGeneric("count.mappedkeys")) 29 | setGeneric("links", function(x) standardGeneric("links")) 30 | setGeneric("count.links", function(x) standardGeneric("count.links")) 31 | setGeneric("nhit", function(x) standardGeneric("nhit")) 32 | setGeneric("toggleProbes", signature="x", function(x, value) standardGeneric("toggleProbes")) 33 | setGeneric("hasMultiProbes", function(x) standardGeneric("hasMultiProbes")) 34 | setGeneric("hasSingleProbes", function(x) standardGeneric("hasSingleProbes")) 35 | setGeneric("getBimapFilters", function(x) standardGeneric("getBimapFilters")) 36 | setGeneric("toLList", function(x) standardGeneric("toLList")) 37 | setGeneric("toRList", function(x) standardGeneric("toRList")) 38 | setGeneric("toList", function(x) standardGeneric("toList")) 39 | setGeneric("GOFrame", function(x, organism) standardGeneric("GOFrame")) 40 | setGeneric("GOAllFrame", function(x) standardGeneric("GOAllFrame")) 41 | setGeneric("getGOFrameData", function(x) standardGeneric("getGOFrameData")) 42 | setGeneric("KEGGFrame", function(x, organism) standardGeneric("KEGGFrame")) 43 | setGeneric("getKEGGFrameData", function(x) standardGeneric("getKEGGFrameData")) 44 | 45 | setGeneric("GOID", function(object) standardGeneric("GOID")) 46 | setGeneric("Term", function(object) standardGeneric("Term")) 47 | setGeneric("Definition", function(object) standardGeneric("Definition")) 48 | setGeneric("Synonym", function(object) standardGeneric("Synonym")) 49 | setGeneric("Secondary", function(object) standardGeneric("Secondary")) 50 | 51 | 52 | ### Others (do whatever you want with them ;-) 53 | setGeneric("taxonomyId", function(x) standardGeneric("taxonomyId")) 54 | setGeneric("dbmeta", signature="x", function(x, name) standardGeneric("dbmeta")) 55 | setGeneric("dbschema", signature="x", function(x, file="", show.indices=FALSE) standardGeneric("dbschema")) 56 | setGeneric("dbInfo", function(x) standardGeneric("dbInfo")) 57 | setGeneric("Ltablename", function(x) standardGeneric("Ltablename")) 58 | setGeneric("Rtablename", function(x) standardGeneric("Rtablename")) 59 | setGeneric("Lfilter", function(x) standardGeneric("Lfilter")) 60 | setGeneric("Rfilter", function(x) standardGeneric("Rfilter")) 61 | setGeneric("flatten", function(x, ...) standardGeneric("flatten")) 62 | setGeneric("orgPackageName", function(x, ...) standardGeneric("orgPackageName")) 63 | 64 | ## AnnotationDb 65 | setGeneric("saveDb", signature="x", 66 | function(x, file) standardGeneric("saveDb")) 67 | 68 | ## Don't do this. There is already a dbconn() method. So use that one. 69 | ##setGeneric("dbConn", function(x) standardGeneric("dbConn")) 70 | 71 | setGeneric("packageName", function(x) standardGeneric("packageName")) 72 | 73 | setGeneric("columns", signature="x", function(x) { 74 | value <- standardGeneric("columns") 75 | sort(value) 76 | }) 77 | 78 | setGeneric("keytypes", signature="x", function(x) { 79 | value <- standardGeneric("keytypes") 80 | sort(value) 81 | }) 82 | 83 | setGeneric("select", signature="x", 84 | function(x, keys, columns, keytype, ...) standardGeneric("select")) 85 | 86 | setGeneric("mapIds", signature="x", 87 | function(x, keys, column, keytype, ..., multiVals) 88 | standardGeneric("mapIds")) 89 | -------------------------------------------------------------------------------- /man/Bimap-keys.Rd: -------------------------------------------------------------------------------- 1 | \name{Bimap-keys} 2 | 3 | \alias{Bimap-keys} 4 | 5 | \alias{keys,Bimap-method} 6 | 7 | \alias{length,Bimap-method} 8 | 9 | \alias{mappedkeys} 10 | \alias{mappedkeys,Bimap-method} 11 | \alias{mappedkeys,environment-method} 12 | \alias{mappedkeys,vector-method} 13 | 14 | \alias{count.mappedkeys} 15 | \alias{count.mappedkeys,Bimap-method} 16 | \alias{count.mappedkeys,ANY-method} 17 | 18 | \alias{isNA} 19 | \alias{isNA,Bimap-method} 20 | \alias{isNA,environment-method} 21 | \alias{isNA,ANY-method} 22 | 23 | \alias{keys<-} 24 | \alias{keys<-,Bimap-method} 25 | 26 | \alias{[,Bimap-method} 27 | 28 | \alias{show,AnnDbTable-method} 29 | 30 | 31 | \title{Methods for manipulating the keys of a Bimap object} 32 | 33 | \description{ 34 | These methods are part of the \link{Bimap} interface 35 | (see \code{?\link{Bimap}} for a quick overview of the \link{Bimap} 36 | objects and their interface). 37 | } 38 | 39 | \usage{ 40 | #length(x) 41 | isNA(x) 42 | mappedkeys(x) 43 | count.mappedkeys(x) 44 | keys(x) <- value 45 | #x[i] 46 | } 47 | 48 | \arguments{ 49 | \item{x}{ 50 | A \link{Bimap} object. If the method being caled is 51 | \code{keys(x)}, then x can also be a AnnotationDb object or one of 52 | that objects progeny. 53 | } 54 | \item{value}{ 55 | A character vector containing the new keys (must be a subset of the 56 | current keys). 57 | } 58 | \item{i}{ 59 | A character vector containing the keys of the map elements to extract. 60 | } 61 | } 62 | 63 | \details{ 64 | \code{keys(x)} returns the set of all valid keys for map \code{x}. 65 | For example, \code{keys(hgu95av2GO)} is the set of all probe set IDs 66 | for chip hgu95av2 from Affymetrix. 67 | 68 | Please Note that in addition to \code{Bimap} objest, \code{keys(x)} 69 | will also work for \code{AnnotationDb} objects and related objects 70 | such as \code{OrgDb} and \code{ChipDb} objects. 71 | 72 | Note also that the double bracket operator \code{[[} for \link{Bimap} 73 | objects is guaranteed to work only with a valid key and will raise 74 | an error if the key is invalid. 75 | (See \code{?`\link{Bimap-envirAPI}`} for more information 76 | about this operator.) 77 | 78 | \code{length(x)} is equivalent to (but more efficient than) 79 | \code{length(keys(x))}. 80 | 81 | A valid key is not necessarily mapped (\code{[[} will return an 82 | \code{NA} on an unmapped key). 83 | 84 | \code{isNA(x)} returns a logical vector of the same length as \code{x} 85 | where the \code{TRUE} value is used to mark keys that are NOT mapped 86 | and the \code{FALSE} value to mark keys that ARE mapped. 87 | 88 | \code{mappedkeys(x)} returns the subset of \code{keys(x)} where only 89 | mapped keys were kept. 90 | 91 | \code{count.mappedkeys(x)} is equivalent to (but more efficient than) 92 | \code{length(mappedkeys(x))}. 93 | 94 | Two (almost) equivalent forms of subsetting a \link{Bimap} object 95 | are provided: (1) by setting the keys explicitely and (2) by using 96 | the single bracket operator \code{[} for \link{Bimap} objects. 97 | Let's say the user wants to restrict the mapping to the subset of 98 | valid keys stored in character vector \code{mykeys}. This can be 99 | done either with \code{keys(x) <- mykeys} (form (1)) or with 100 | \code{y <- x[mykeys]} (form (2)). 101 | Please note that form (1) alters object \code{x} in an irreversible 102 | way (the original keys are lost) so form (2) should be preferred. 103 | 104 | All the methods described on this pages are "directed methods" 105 | i.e. what they return DOES depend on the direction of the \link{Bimap} 106 | object that they are applied to (see \code{?\link{direction}} for 107 | more information about this). 108 | } 109 | 110 | \value{ 111 | A character vector for \code{keys} and \code{mappedkeys}. 112 | 113 | A single non-negative integer for \code{length} and 114 | \code{count.mappedkeys}. 115 | 116 | A logical vector for \code{isNA}. 117 | 118 | A \link{Bimap} object of the same subtype as \code{x} for \code{x[i]}. 119 | } 120 | 121 | \author{H. Pagès} 122 | 123 | \seealso{ 124 | \link{Bimap}, 125 | \link{Bimap-envirAPI}, 126 | \link{Bimap-toTable}, 127 | \link{BimapFormatting}, 128 | \link{AnnotationDb}, 129 | \link{select}, 130 | \link{columns} 131 | } 132 | 133 | \examples{ 134 | library(hgu95av2.db) 135 | x <- hgu95av2GO 136 | x 137 | length(x) 138 | count.mappedkeys(x) 139 | x[1:3] 140 | links(x[1:3]) 141 | 142 | ## Keep only the mapped keys 143 | keys(x) <- mappedkeys(x) 144 | length(x) 145 | count.mappedkeys(x) 146 | x # now it is a submap 147 | 148 | ## The above subsetting can also be achieved with 149 | x <- hgu95av2GO[mappedkeys(hgu95av2GO)] 150 | 151 | ## mappedkeys() and count.mappedkeys() also work with an environment 152 | ## or a list 153 | z <- list(k1=NA, k2=letters[1:4], k3="x") 154 | mappedkeys(z) 155 | count.mappedkeys(z) 156 | 157 | ## retrieve the set of primary keys for the ChipDb object named 'hgu95av2.db' 158 | keys <- keys(hgu95av2.db) 159 | head(keys) 160 | } 161 | 162 | \keyword{methods} 163 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.0/ECOLI_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE genes ( 13 | _id INTEGER PRIMARY KEY, 14 | gene_id VARCHAR(10) NOT NULL UNIQUE -- Entrez Gene ID 15 | ); 16 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 17 | CREATE TABLE gene_info ( 18 | _id INTEGER NOT NULL UNIQUE, -- REFERENCES genes 19 | gene_name VARCHAR(255) NOT NULL, -- gene name 20 | symbol VARCHAR(80) NOT NULL, -- gene symbol 21 | FOREIGN KEY (_id) REFERENCES genes (_id) 22 | ); 23 | CREATE TABLE accessions ( 24 | _id INTEGER NOT NULL, -- REFERENCES genes 25 | accession VARCHAR(20) NOT NULL, -- GenBank accession number 26 | FOREIGN KEY (_id) REFERENCES genes (_id) 27 | ); 28 | CREATE TABLE refseq ( 29 | _id INTEGER NOT NULL, -- REFERENCES genes 30 | accession VARCHAR(20) NOT NULL, -- RefSeq accession number 31 | FOREIGN KEY (_id) REFERENCES genes (_id) 32 | ); 33 | CREATE TABLE pubmed ( 34 | _id INTEGER NOT NULL, -- REFERENCES genes 35 | pubmed_id VARCHAR(10) NOT NULL, -- PubMed ID 36 | FOREIGN KEY (_id) REFERENCES genes (_id) 37 | ); 38 | CREATE TABLE go_bp ( 39 | _id INTEGER NOT NULL, -- REFERENCES genes 40 | go_id CHAR(10) NOT NULL, -- GO ID 41 | evidence CHAR(3) NOT NULL, -- GO evidence code 42 | FOREIGN KEY (_id) REFERENCES genes (_id) 43 | ); 44 | CREATE TABLE go_mf ( 45 | _id INTEGER NOT NULL, -- REFERENCES genes 46 | go_id CHAR(10) NOT NULL, -- GO ID 47 | evidence CHAR(3) NOT NULL, -- GO evidence code 48 | FOREIGN KEY (_id) REFERENCES genes (_id) 49 | ); 50 | CREATE TABLE go_cc ( 51 | _id INTEGER NOT NULL, -- REFERENCES genes 52 | go_id CHAR(10) NOT NULL, -- GO ID 53 | evidence CHAR(3) NOT NULL, -- GO evidence code 54 | FOREIGN KEY (_id) REFERENCES genes (_id) 55 | ); 56 | CREATE TABLE go_bp_all ( 57 | _id INTEGER NOT NULL, -- REFERENCES genes 58 | go_id CHAR(10) NOT NULL, -- GO ID 59 | evidence CHAR(3) NOT NULL, -- GO evidence code 60 | FOREIGN KEY (_id) REFERENCES genes (_id) 61 | ); 62 | CREATE TABLE go_mf_all ( 63 | _id INTEGER NOT NULL, -- REFERENCES genes 64 | go_id CHAR(10) NOT NULL, -- GO ID 65 | evidence CHAR(3) NOT NULL, -- GO evidence code 66 | FOREIGN KEY (_id) REFERENCES genes (_id) 67 | ); 68 | CREATE TABLE go_cc_all ( 69 | _id INTEGER NOT NULL, -- REFERENCES genes 70 | go_id CHAR(10) NOT NULL, -- GO ID 71 | evidence CHAR(3) NOT NULL, -- GO evidence code 72 | FOREIGN KEY (_id) REFERENCES genes (_id) 73 | ); 74 | CREATE TABLE kegg ( 75 | _id INTEGER NOT NULL, -- REFERENCES genes 76 | path_id CHAR(5) NOT NULL, -- KEGG pathway short ID 77 | FOREIGN KEY (_id) REFERENCES genes (_id) 78 | ); 79 | CREATE TABLE ec ( 80 | _id INTEGER NOT NULL, -- REFERENCES genes 81 | ec_number VARCHAR(13) NOT NULL, -- EC number 82 | FOREIGN KEY (_id) REFERENCES genes (_id) 83 | ); 84 | CREATE TABLE alias ( 85 | _id INTEGER NOT NULL, -- REFERENCES genes 86 | alias_symbol VARCHAR(80) NOT NULL, -- gene symbol or alias 87 | FOREIGN KEY (_id) REFERENCES genes (_id) 88 | ); 89 | 90 | -- Explicit index creation on the referencing column of all the foreign keys. 91 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 92 | -- indexes automatically. 93 | CREATE INDEX Faccessions ON accessions (_id); 94 | CREATE INDEX Frefseq ON refseq (_id); 95 | CREATE INDEX Fpubmed ON pubmed (_id); 96 | CREATE INDEX Fgo_bp ON go_bp (_id); 97 | CREATE INDEX Fgo_bp_go_id ON go_bp (go_id); 98 | CREATE INDEX Fgo_mf ON go_mf (_id); 99 | CREATE INDEX Fgo_mf_go_id ON go_mf (go_id); 100 | CREATE INDEX Fgo_cc ON go_cc (_id); 101 | CREATE INDEX Fgo_cc_go_id ON go_cc (go_id); 102 | CREATE INDEX Fgo_bp_all ON go_bp_all (_id); 103 | CREATE INDEX Fgo_bp_all_go_id ON go_bp_all (go_id); 104 | CREATE INDEX Fgo_mf_all ON go_mf_all (_id); 105 | CREATE INDEX Fgo_mf_all_go_id ON go_mf_all (go_id); 106 | CREATE INDEX Fgo_cc_all ON go_cc_all (_id); 107 | CREATE INDEX Fgo_cc_all_go_id ON go_cc_all (go_id); 108 | CREATE INDEX Fkegg ON kegg (_id); 109 | CREATE INDEX Fec ON ec (_id); 110 | CREATE INDEX Falias ON alias (_id); 111 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_2.1/ECOLI_DB.sql: -------------------------------------------------------------------------------- 1 | CREATE TABLE metadata (name VARCHAR(80) PRIMARY KEY, value VARCHAR(255) ); 2 | CREATE TABLE map_metadata ( 3 | map_name VARCHAR(80) NOT NULL, 4 | source_name VARCHAR(80) NOT NULL, 5 | source_url VARCHAR(255) NOT NULL, 6 | source_date VARCHAR(20) NOT NULL 7 | ); 8 | CREATE TABLE map_counts ( 9 | map_name VARCHAR(80) PRIMARY KEY, 10 | count INTEGER NOT NULL 11 | ); 12 | CREATE TABLE genes ( 13 | _id INTEGER PRIMARY KEY, 14 | gene_id VARCHAR(10) NOT NULL UNIQUE -- Entrez Gene ID 15 | ); 16 | CREATE TABLE sqlite_stat1(tbl,idx,stat); 17 | CREATE TABLE gene_info ( 18 | _id INTEGER NOT NULL UNIQUE, -- REFERENCES genes 19 | gene_name VARCHAR(255) NOT NULL, -- gene name 20 | symbol VARCHAR(80) NOT NULL, -- gene symbol 21 | FOREIGN KEY (_id) REFERENCES genes (_id) 22 | ); 23 | CREATE TABLE accessions ( 24 | _id INTEGER NOT NULL, -- REFERENCES genes 25 | accession VARCHAR(20) NOT NULL, -- GenBank accession number 26 | FOREIGN KEY (_id) REFERENCES genes (_id) 27 | ); 28 | CREATE TABLE refseq ( 29 | _id INTEGER NOT NULL, -- REFERENCES genes 30 | accession VARCHAR(20) NOT NULL, -- RefSeq accession number 31 | FOREIGN KEY (_id) REFERENCES genes (_id) 32 | ); 33 | CREATE TABLE pubmed ( 34 | _id INTEGER NOT NULL, -- REFERENCES genes 35 | pubmed_id VARCHAR(10) NOT NULL, -- PubMed ID 36 | FOREIGN KEY (_id) REFERENCES genes (_id) 37 | ); 38 | CREATE TABLE go_bp ( 39 | _id INTEGER NOT NULL, -- REFERENCES genes 40 | go_id CHAR(10) NOT NULL, -- GO ID 41 | evidence CHAR(3) NOT NULL, -- GO evidence code 42 | FOREIGN KEY (_id) REFERENCES genes (_id) 43 | ); 44 | CREATE TABLE go_mf ( 45 | _id INTEGER NOT NULL, -- REFERENCES genes 46 | go_id CHAR(10) NOT NULL, -- GO ID 47 | evidence CHAR(3) NOT NULL, -- GO evidence code 48 | FOREIGN KEY (_id) REFERENCES genes (_id) 49 | ); 50 | CREATE TABLE go_cc ( 51 | _id INTEGER NOT NULL, -- REFERENCES genes 52 | go_id CHAR(10) NOT NULL, -- GO ID 53 | evidence CHAR(3) NOT NULL, -- GO evidence code 54 | FOREIGN KEY (_id) REFERENCES genes (_id) 55 | ); 56 | CREATE TABLE go_bp_all ( 57 | _id INTEGER NOT NULL, -- REFERENCES genes 58 | go_id CHAR(10) NOT NULL, -- GO ID 59 | evidence CHAR(3) NOT NULL, -- GO evidence code 60 | FOREIGN KEY (_id) REFERENCES genes (_id) 61 | ); 62 | CREATE TABLE go_mf_all ( 63 | _id INTEGER NOT NULL, -- REFERENCES genes 64 | go_id CHAR(10) NOT NULL, -- GO ID 65 | evidence CHAR(3) NOT NULL, -- GO evidence code 66 | FOREIGN KEY (_id) REFERENCES genes (_id) 67 | ); 68 | CREATE TABLE go_cc_all ( 69 | _id INTEGER NOT NULL, -- REFERENCES genes 70 | go_id CHAR(10) NOT NULL, -- GO ID 71 | evidence CHAR(3) NOT NULL, -- GO evidence code 72 | FOREIGN KEY (_id) REFERENCES genes (_id) 73 | ); 74 | CREATE TABLE kegg ( 75 | _id INTEGER NOT NULL, -- REFERENCES genes 76 | path_id CHAR(5) NOT NULL, -- KEGG pathway short ID 77 | FOREIGN KEY (_id) REFERENCES genes (_id) 78 | ); 79 | CREATE TABLE ec ( 80 | _id INTEGER NOT NULL, -- REFERENCES genes 81 | ec_number VARCHAR(13) NOT NULL, -- EC number 82 | FOREIGN KEY (_id) REFERENCES genes (_id) 83 | ); 84 | CREATE TABLE alias ( 85 | _id INTEGER NOT NULL, -- REFERENCES genes 86 | alias_symbol VARCHAR(80) NOT NULL, -- gene symbol or alias 87 | FOREIGN KEY (_id) REFERENCES genes (_id) 88 | ); 89 | 90 | -- Explicit index creation on the referencing column of all the foreign keys. 91 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 92 | -- indexes automatically. 93 | CREATE INDEX Faccessions ON accessions (_id); 94 | CREATE INDEX Frefseq ON refseq (_id); 95 | CREATE INDEX Fpubmed ON pubmed (_id); 96 | CREATE INDEX Fgo_bp ON go_bp (_id); 97 | CREATE INDEX Fgo_bp_go_id ON go_bp (go_id); 98 | CREATE INDEX Fgo_mf ON go_mf (_id); 99 | CREATE INDEX Fgo_mf_go_id ON go_mf (go_id); 100 | CREATE INDEX Fgo_cc ON go_cc (_id); 101 | CREATE INDEX Fgo_cc_go_id ON go_cc (go_id); 102 | CREATE INDEX Fgo_bp_all ON go_bp_all (_id); 103 | CREATE INDEX Fgo_bp_all_go_id ON go_bp_all (go_id); 104 | CREATE INDEX Fgo_mf_all ON go_mf_all (_id); 105 | CREATE INDEX Fgo_mf_all_go_id ON go_mf_all (go_id); 106 | CREATE INDEX Fgo_cc_all ON go_cc_all (_id); 107 | CREATE INDEX Fgo_cc_all_go_id ON go_cc_all (go_id); 108 | CREATE INDEX Fkegg ON kegg (_id); 109 | CREATE INDEX Fec ON ec (_id); 110 | CREATE INDEX Falias ON alias (_id); 111 | -------------------------------------------------------------------------------- /inst/DBschemas/schemas_1.0/GO_DB.sql: -------------------------------------------------------------------------------- 1 | -- 2 | -- GO_DB schema 3 | -- ============ 4 | -- 5 | 6 | CREATE TABLE go_ontology ( 7 | ontology VARCHAR(9) PRIMARY KEY, -- GO ontology (short label) 8 | term_type VARCHAR(18) NOT NULL UNIQUE -- GO ontology (full label) 9 | ); 10 | CREATE TABLE go_obsolete ( 11 | go_id CHAR(10) PRIMARY KEY, -- GO ID 12 | term VARCHAR(255) NOT NULL, -- textual label for the GO term 13 | ontology VARCHAR(9) NOT NULL, -- REFERENCES go_ontology 14 | definition TEXT NULL, -- textual definition for the GO term 15 | FOREIGN KEY (ontology) REFERENCES go_ontology (ontology) 16 | ); 17 | 18 | -- The "go_term" table is the central table. 19 | CREATE TABLE go_term ( 20 | _id INTEGER PRIMARY KEY, 21 | go_id CHAR(10) NOT NULL UNIQUE, -- GO ID 22 | term VARCHAR(255) NOT NULL, -- textual label for the GO term 23 | ontology VARCHAR(9) NOT NULL, -- REFERENCES go_ontology 24 | definition TEXT NULL, -- textual definition for the GO term 25 | FOREIGN KEY (ontology) REFERENCES go_ontology (ontology) 26 | ); 27 | 28 | -- Data linked to the "go_term" table. 29 | CREATE TABLE go_synonym ( 30 | _id INTEGER NOT NULL, -- REFERENCES go_term 31 | synonym VARCHAR(255) NOT NULL, -- label or GO ID 32 | secondary CHAR(10) NULL, -- GO ID 33 | like_go_id SMALLINT, -- boolean (1 or 0) 34 | FOREIGN KEY (_id) REFERENCES go_term (_id) 35 | ); 36 | 37 | -- child-parent relationship. 38 | CREATE TABLE go_bp_parents ( 39 | _id INTEGER NOT NULL, -- REFERENCES go_term 40 | _parent_id INTEGER NOT NULL, -- REFERENCES go_term 41 | relationship_type VARCHAR(7) NOT NULL, -- type of GO child-parent relationship 42 | FOREIGN KEY (_id) REFERENCES go_term (_id), 43 | FOREIGN KEY (_parent_id) REFERENCES go_term (_id) 44 | ); 45 | CREATE TABLE go_cc_parents ( 46 | _id INTEGER NOT NULL, -- REFERENCES go_term 47 | _parent_id INTEGER NOT NULL, -- REFERENCES go_term 48 | relationship_type VARCHAR(7) NOT NULL, -- type of GO child-parent relationship 49 | FOREIGN KEY (_id) REFERENCES go_term (_id), 50 | FOREIGN KEY (_parent_id) REFERENCES go_term (_id) 51 | ); 52 | CREATE TABLE go_mf_parents ( 53 | _id INTEGER NOT NULL, -- REFERENCES go_term 54 | _parent_id INTEGER NOT NULL, -- REFERENCES go_term 55 | relationship_type VARCHAR(7) NOT NULL, -- type of GO child-parent relationship 56 | FOREIGN KEY (_id) REFERENCES go_term (_id), 57 | FOREIGN KEY (_parent_id) REFERENCES go_term (_id) 58 | ); 59 | 60 | -- parent-offspring relationship. 61 | CREATE TABLE go_bp_offspring ( 62 | _id INTEGER NOT NULL, -- REFERENCES go_term 63 | _offspring_id INTEGER NOT NULL, -- REFERENCES go_term 64 | FOREIGN KEY (_id) REFERENCES go_term (_id), 65 | FOREIGN KEY (_offspring_id) REFERENCES go_term (_id) 66 | ); 67 | CREATE TABLE go_cc_offspring ( 68 | _id INTEGER NOT NULL, -- REFERENCES go_term 69 | _offspring_id INTEGER NOT NULL, -- REFERENCES go_term 70 | FOREIGN KEY (_id) REFERENCES go_term (_id), 71 | FOREIGN KEY (_offspring_id) REFERENCES go_term (_id) 72 | ); 73 | CREATE TABLE go_mf_offspring ( 74 | _id INTEGER NOT NULL, -- REFERENCES go_term 75 | _offspring_id INTEGER NOT NULL, -- REFERENCES go_term 76 | FOREIGN KEY (_id) REFERENCES go_term (_id), 77 | FOREIGN KEY (_offspring_id) REFERENCES go_term (_id) 78 | ); 79 | 80 | -- Metadata tables. 81 | CREATE TABLE metadata ( 82 | name VARCHAR(80) PRIMARY KEY, 83 | value VARCHAR(255) 84 | ); 85 | CREATE TABLE map_counts ( 86 | map_name VARCHAR(80) PRIMARY KEY, 87 | count INTEGER NOT NULL 88 | ); 89 | CREATE TABLE map_metadata ( 90 | map_name VARCHAR(80) NOT NULL, 91 | source_name VARCHAR(80) NOT NULL, 92 | source_url VARCHAR(255) NOT NULL, 93 | source_date VARCHAR(20) NOT NULL 94 | ); 95 | 96 | -- Explicit index creation on the referencing column of all the foreign keys. 97 | -- Note that this is only needed for SQLite: PostgreSQL and MySQL create those 98 | -- indexes automatically. 99 | CREATE INDEX Fgo_term ON go_term (ontology); 100 | CREATE INDEX Fgo_synonym ON go_synonym (_id); 101 | CREATE INDEX Fgo_obsolete ON go_obsolete (ontology); 102 | CREATE INDEX F1go_bp_parents ON go_bp_parents (_id); 103 | CREATE INDEX F2go_bp_parents ON go_bp_parents (_parent_id); 104 | CREATE INDEX F1go_cc_parents ON go_cc_parents (_id); 105 | CREATE INDEX F2go_cc_parents ON go_cc_parents (_parent_id); 106 | CREATE INDEX F1go_mf_parents ON go_mf_parents (_id); 107 | CREATE INDEX F2go_mf_parents ON go_mf_parents (_parent_id); 108 | CREATE INDEX F1go_bp_offspring ON go_bp_offspring (_id); 109 | CREATE INDEX F2go_bp_offspring ON go_bp_offspring (_offspring_id); 110 | CREATE INDEX F1go_cc_offspring ON go_cc_offspring (_id); 111 | CREATE INDEX F2go_cc_offspring ON go_cc_offspring (_offspring_id); 112 | CREATE INDEX F1go_mf_offspring ON go_mf_offspring (_id); 113 | CREATE INDEX F2go_mf_offspring ON go_mf_offspring (_offspring_id); 114 | 115 | --------------------------------------------------------------------------------