Skip to content

Commit 917f8a6

Browse files
authored
Merge pull request #29 from dienerlab/fix/superkingdom
make compatible with new NCBI ranks
2 parents d5f98dc + 26b2bc1 commit 917f8a6

File tree

2 files changed

+14
-7
lines changed

2 files changed

+14
-7
lines changed

bin/fixk2report.R

Lines changed: 13 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,28 @@
33
# Fixes missing ranks in Kraken2 reports
44

55
library(data.table)
6+
library(futile.logger)
7+
8+
domains <- c("Archaea", "Bacteria", "Eukaryota")
69

710
args <- commandArgs(trailingOnly = TRUE)
811
report <- fread(args[1], sep="\t", header=FALSE, strip.white=FALSE)
912

1013
fix <- function(name) {
1114
name <- trimws(name)
15+
16+
out <- "D1"
1217
if (name == "root") {
13-
return("R")
18+
out <- "R"
1419
} else if (name == "cellular organisms") {
15-
return("R1")
16-
} else {
17-
return("D")
20+
out <- "R1"
21+
} else if (name %in% domains) {
22+
out <- "D"
1823
}
24+
25+
flog.info("Mapping %s -> rank: %s", name, out)
26+
return(out)
1927
}
2028

21-
report[V4 == "" | V4 == "1", V4 := sapply(V6, fix)]
22-
report[V4 == "1", V4 := "D1"]
29+
report[V4 == "" | (V4 %chin% as.character(0:9)), V4 := sapply(V6, fix)]
2330
fwrite(report, args[2], sep="\t", quote=FALSE, col.names=FALSE)

medi.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,5 +23,5 @@ dependencies:
2323
- r-futile.logger
2424
- bioconductor-biostrings
2525
- taxonkit
26-
- architeuthis>=0.2.1
26+
- architeuthis>=0.4.0
2727
- gxx

0 commit comments

Comments
 (0)