Skip to content

Instantly share code, notes, and snippets.

@zdk123
Last active May 22, 2017 20:45
Show Gist options
  • Save zdk123/cb7fb8bffec70a6d8058c5fbee6ddf3c to your computer and use it in GitHub Desktop.
Save zdk123/cb7fb8bffec70a6d8058c5fbee6ddf3c to your computer and use it in GitHub Desktop.
load_blast <- function(blastfile, indexcols = c("queryID"),
column_names = c("queryID", "subjectID", "percent.identity", "alignment.length", "mismatches",
"gap.openings", "qstart", "qend", "sstart", "send", "evalue", "bitscore")) {
# check index columns
for (ival in indexcols) {
if (!ival %in% column_names) {
stop(paste("bad values in the indexcols. only valid column names can be used:", paste(column_names, collapse = " ")))
}
}
dt <- data.table::fread(input=blastfile, header=FALSE, col.names = column_names, sep="\t")
data.table::setkeyv(dt, cols = indexcols)
return(dt)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment