Skip to content

Commit f2a469a

Browse files
authored
Merge pull request #76 from cancerit/develop
3.5.4 error handling
2 parents e831575 + e25d0d1 commit f2a469a

File tree

3 files changed

+13
-20
lines changed

3 files changed

+13
-20
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
bugfix-scratch/

R/nanoseq_results_plotter.R

Lines changed: 10 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -43,35 +43,27 @@ READ_LENGTH = 151
4343

4444
args = commandArgs(TRUE)
4545

46-
if (length(args) == 0) {
47-
cat("nanoseq_results_plotter.R directory output_prefix [trinucleotide_frequencies_file]\n\n")
48-
cat("Must specify a directory with the various CSV files and a prefix for the output files.\n")
49-
cat("Optionally a file containing the background genomic (pyrimidine-based) trinucleotide absolute counts (for normalization purposes). If not provided, human frequencies will be assumed.\n\n")
50-
cat("This script generates a series of plots and tables summarizing the results of the variantcaller.\n\n")
51-
quit(save = "no", status = 0)
52-
}
53-
54-
if (length(args) < 2 || length(args) > 3) {
55-
cat("nanoseq_results_plotter.R directory output_prefix [trinucleotide_frequencies_file]\n\n")
56-
cat("Must specify a directory with the various CSV files and a prefix for the output files.\n")
57-
cat("Optionally a file containing the background genomic (pyrimidine-based) trinucleotide absolute counts (for normalization purposes). If not provided, human frequencies will be assumed.\n\n")
58-
cat("This script generates a series of plots and tables summarizing the results of the variantcaller.\n\n")
46+
if (length(args) == 0 || length(args) < 2 || length(args) > 3) {
47+
message("nanoseq_results_plotter.R directory output_prefix [trinucleotide_frequencies_file]\n\n")
48+
message("Must specify a directory with the various CSV files and a prefix for the output files.\n")
49+
message("Optionally a file containing the background genomic (pyrimidine-based) trinucleotide absolute counts (for normalization purposes). If not provided, human frequencies will be assumed.\n\n")
50+
message("This script generates a series of plots and tables summarizing the results of the variantcaller.\n\n")
5951
quit(save = "no", status = 1)
6052
}
6153

6254
dir_res = args[1]
6355
out_name = args[2]
6456
if (length(args) == 3) {
65-
cat("Reading genomic trinucleotide absolute counts from file: ", args[3], "\n", sep = "")
57+
message(sprintf("Reading genomic trinucleotide absolute counts from file: %s\n", args[3]))
6658
order = c("ACA", "ACC", "ACG", "ACT", "ATA", "ATC", "ATG", "ATT", "CCA", "CCC", "CCG", "CCT", "CTA", "CTC", "CTG", "CTT",
6759
"GCA", "GCC", "GCG", "GCT", "GTA", "GTC", "GTG", "GTT", "TCA", "TCC", "TCG", "TCT", "TTA", "TTC", "TTG", "TTT")
6860
genome_counts_tmp = read.table(args[3], sep = "\t", stringsAsFactors = F, header = F, row.names = 1)
6961
if (nrow(genome_counts_tmp) != length(order)) {
70-
cat(args[3], " not properly formatted. Expected ", length(order), " rows, one for each pyrimidine trinucleotide\n", sep = "")
62+
message(sprintf("%s not properly formatted. Expected %d rows, one for each pyrimidine trinucleotide\n", args[3], length(order)))
7163
quit(save = "no", status = 0)
7264
}
7365
if (sum(genome_counts_tmp[, 1]) < 1e6) {
74-
cat(args[3], " does not seem to contain absolute counts.\n", sep = "")
66+
message(sprintf("%s does not seem to contain absolute counts.\n", args[3]))
7567
quit(save = "no", status = 0)
7668
}
7769
genome_counts = vector()
@@ -224,7 +216,7 @@ dev.off()
224216
##########################################################################################
225217
# Second: the subst type asymmetries by bins
226218
if (n_variants > 0) {
227-
cat(" Calculating conf int for sub types...\n")
219+
message(" Calculating conf int for sub types...\n")
228220
pdf(width = 9, height = 7, file = paste(out_name, ".subst_asym_and_rates_binned.pdf", sep = ""))
229221
BIN_SIZE = 10
230222

@@ -324,7 +316,7 @@ if (n_variants > 0) {
324316
bin_mat[bin, "rate_uci"] <- conf.ints[2]
325317
}
326318

327-
cat(" Plotting results...\n")
319+
message(" Plotting results...\n")
328320
plotting_order <- c("C>A", "G>T", "C>G", "G>C", "C>T", "G>A", "T>A", "A>T", "T>C", "A>G", "T>G", "A>C")
329321
colors <- rep(c("deepskyblue", "black", "firebrick2", "gray", "darkolivegreen3", "rosybrown2"), each = 2)
330322

python/runNanoSeq.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@
4747
import tempfile
4848
import copy
4949

50-
version = '3.5.2'
50+
version = '3.5.4'
5151

5252
parser = argparse.ArgumentParser()
5353
# arguments for all subcommands
@@ -1151,7 +1151,7 @@ def vcfHeader(args):
11511151
tmpDir, tmpDir)
11521152
runCommand(cmd)
11531153

1154-
cmd = "nanoseq_results_plotter.R %s/post %s/post/%s %s || true" % (
1154+
cmd = "nanoseq_results_plotter.R %s/post %s/post/%s %s" % (
11551155
tmpDir, tmpDir, args.name, args.triNuc or "")
11561156
runCommand(cmd)
11571157

0 commit comments

Comments
 (0)