annotate plasmidprofile.R @ 1:fc63bfd55903 draft

Uploaded
author nml
date Fri, 03 Feb 2017 16:34:16 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1
fc63bfd55903 Uploaded
nml
parents:
diff changeset
1 #' RScript capable
fc63bfd55903 Uploaded
nml
parents:
diff changeset
2 #' Rscript plasmidprofile.R -b blast_runG.tsv -s srst2_runG.tsv -u 0.75 -l 10000 -t "This is a test" -a
fc63bfd55903 Uploaded
nml
parents:
diff changeset
3
fc63bfd55903 Uploaded
nml
parents:
diff changeset
4
fc63bfd55903 Uploaded
nml
parents:
diff changeset
5 suppressPackageStartupMessages(library("optparse"))
fc63bfd55903 Uploaded
nml
parents:
diff changeset
6 suppressPackageStartupMessages(library("Plasmidprofiler"))
fc63bfd55903 Uploaded
nml
parents:
diff changeset
7 options(bitmapType='cairo')
fc63bfd55903 Uploaded
nml
parents:
diff changeset
8
fc63bfd55903 Uploaded
nml
parents:
diff changeset
9 cl_arguments <- function(){
fc63bfd55903 Uploaded
nml
parents:
diff changeset
10 # CL arguments ####
fc63bfd55903 Uploaded
nml
parents:
diff changeset
11 option_list = list(
fc63bfd55903 Uploaded
nml
parents:
diff changeset
12 make_option(c("-b", "--blastfile"), type="character", default=NULL,
fc63bfd55903 Uploaded
nml
parents:
diff changeset
13 help="BLAST TSV file name", metavar="character"),
fc63bfd55903 Uploaded
nml
parents:
diff changeset
14 make_option(c("-s", "--srst2file"), type="character", default=NULL,
fc63bfd55903 Uploaded
nml
parents:
diff changeset
15 help="SRST2 TSV file name", metavar="character"),
fc63bfd55903 Uploaded
nml
parents:
diff changeset
16 make_option(c("-u", "--sureness"), type="numeric", default=NA,
fc63bfd55903 Uploaded
nml
parents:
diff changeset
17 help="Sureness cut off [default = %default]", metavar="numeric"),
fc63bfd55903 Uploaded
nml
parents:
diff changeset
18 make_option(c("-c", "--coverage"), type="numeric", default=NA,
fc63bfd55903 Uploaded
nml
parents:
diff changeset
19 help="Percent coverage cut off", metavar="numeric"),
fc63bfd55903 Uploaded
nml
parents:
diff changeset
20 make_option(c("-l", "--length"), type="numeric", default=NA,
fc63bfd55903 Uploaded
nml
parents:
diff changeset
21 help="Plasmid length cut off", metavar="numeric"),
fc63bfd55903 Uploaded
nml
parents:
diff changeset
22 make_option(c("-a", "--anonymize"), action="store_true", default=NA,
fc63bfd55903 Uploaded
nml
parents:
diff changeset
23 help="Anonymize plasmid and sample names"),
fc63bfd55903 Uploaded
nml
parents:
diff changeset
24 make_option(c("-o", "--outfile"), type="character", default="P2Run_",
fc63bfd55903 Uploaded
nml
parents:
diff changeset
25 help="Output filename prefix [default= %default]", metavar="character"),
fc63bfd55903 Uploaded
nml
parents:
diff changeset
26 make_option(c("-t", "--title"), type="character", default="Plasmid Profiles",
fc63bfd55903 Uploaded
nml
parents:
diff changeset
27 help="Title of image [default = %default]", metavar="character"),
fc63bfd55903 Uploaded
nml
parents:
diff changeset
28 make_option(c("-C", "--combineincs"), action="store_true", default=NA,
fc63bfd55903 Uploaded
nml
parents:
diff changeset
29 help="Combine very closely related incompatibility groups. eg. ")
fc63bfd55903 Uploaded
nml
parents:
diff changeset
30 # make_option(c("-T", "--Test"), action="store_true", default=NA,
fc63bfd55903 Uploaded
nml
parents:
diff changeset
31 # help="Test filecache")
fc63bfd55903 Uploaded
nml
parents:
diff changeset
32
fc63bfd55903 Uploaded
nml
parents:
diff changeset
33 );
fc63bfd55903 Uploaded
nml
parents:
diff changeset
34
fc63bfd55903 Uploaded
nml
parents:
diff changeset
35 opt_parser <- OptionParser(option_list=option_list);
fc63bfd55903 Uploaded
nml
parents:
diff changeset
36 opt <- parse_args(opt_parser);
fc63bfd55903 Uploaded
nml
parents:
diff changeset
37
fc63bfd55903 Uploaded
nml
parents:
diff changeset
38 if (is.null(opt$blastfile) | is.null(opt$srst2file)){
fc63bfd55903 Uploaded
nml
parents:
diff changeset
39 print_help(opt_parser)
fc63bfd55903 Uploaded
nml
parents:
diff changeset
40 stop("SRST2 and BLAST files must be supplied.", call.=FALSE)
fc63bfd55903 Uploaded
nml
parents:
diff changeset
41 }
fc63bfd55903 Uploaded
nml
parents:
diff changeset
42 opt
fc63bfd55903 Uploaded
nml
parents:
diff changeset
43 }
fc63bfd55903 Uploaded
nml
parents:
diff changeset
44
fc63bfd55903 Uploaded
nml
parents:
diff changeset
45
fc63bfd55903 Uploaded
nml
parents:
diff changeset
46 opt <- cl_arguments()
fc63bfd55903 Uploaded
nml
parents:
diff changeset
47
fc63bfd55903 Uploaded
nml
parents:
diff changeset
48 filecache <<- new.env(parent = .GlobalEnv)
fc63bfd55903 Uploaded
nml
parents:
diff changeset
49 assign("name", opt$outfile, envir = filecache)
fc63bfd55903 Uploaded
nml
parents:
diff changeset
50 assign("mods", "Subsampling applied: ", envir = filecache)
fc63bfd55903 Uploaded
nml
parents:
diff changeset
51
fc63bfd55903 Uploaded
nml
parents:
diff changeset
52 main(blast.file = opt$blastfile,
fc63bfd55903 Uploaded
nml
parents:
diff changeset
53 srst2.file = opt$srst2file,
fc63bfd55903 Uploaded
nml
parents:
diff changeset
54 coverage.filter = opt$coverage,
fc63bfd55903 Uploaded
nml
parents:
diff changeset
55 sureness.filter = opt$sureness,
fc63bfd55903 Uploaded
nml
parents:
diff changeset
56 length.filter = opt$length,
fc63bfd55903 Uploaded
nml
parents:
diff changeset
57 anonymize = opt$anonymize,
fc63bfd55903 Uploaded
nml
parents:
diff changeset
58 combine.inc = opt$combineincs,
fc63bfd55903 Uploaded
nml
parents:
diff changeset
59 main.title = opt$title)