if(file.exists('SRAmetadb.sqlite')) {
library(SRAdb)
sra_dbname <- 'SRAmetadb.sqlite'
sra_con <- dbConnect(dbDriver("SQLite"), sra_dbname)
## Fulltext search SRA meta data using SQLite fts3 module:
# find all records with words of 'breast' and 'cancer' in a filed and there could be one to many words between 'breast' and 'cancer':
rs <- getSRA (search_terms ='breast cancer', out_types=c('run','study'), sra_con=sra_con)
# find all records with exact phrase of 'breast cancer' in a filed:
rs <- getSRA (search_terms ='"breast cancer"', out_types=c('run','study'), sra_con=sra_con)
# find records with words beginning with 'braes' and 'can', and the distance between them is equal or less than two words:
rs <- getSRA (search_terms ='breas* NEAR/2 can*', out_types=c('run','study'), sra_con=sra_con)
# the same as above except that only one space between the two words
rs <- getSRA (search_terms ='"breas* can*"', out_types=c('study'), sra_con=sra_con)
# find records with 'MCF7' or 'MCF-7' - adding double quote to avoid the SQLite to break down 'MCF-7' to 'MCF' and '7':
rs <- getSRA (search_terms ='MCF7 OR "MCF-7"', out_types=c('sample'), sra_con=sra_con)
# the same as above, but only search the field of 'study_title':
rs <- getSRA (search_terms ='study_title: brea* can*', out_types=c('run','study'), sra_con=sra_con)
# the same as above, but only search the field of 'study_title' and return only accessions:
rs <- getSRA (search_terms ='study_title: brea* can*', out_types=c('run','study'), sra_con=sra_con, acc_only=TRUE)
} else {
print("use getSRAdbFile() to get a copy of the SRAmetadb.sqlite file and then rerun the example")
}
Run the code above in your browser using DataLab