annotate ribowaltz.R @ 0:6d4c94373bba draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
author iuc
date Thu, 22 Sep 2022 20:30:54 +0000
parents
children 042cab870a39
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
1 # setup R error handling to go to stderr
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
2 options(show.error.messages = FALSE, error = function() {
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
3 cat(geterrmessage(), file = stderr())
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
4 q("no", 1, FALSE)
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
5 })
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
6
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
7 # we need that to not crash galaxy with an UTF8 error on German LC settings.
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
8 loc <- Sys.setlocale("LC_MESSAGES", "en_US.UTF-8")
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
9 library("getopt")
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
10 options(stringAsFactors = FALSE, useFancyQuotes = FALSE)
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
11 args <- commandArgs(trailingOnly = TRUE)
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
12
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
13 # get options, using the spec as defined by the enclosed list.
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
14 # we read the options from the default: commandArgs(TRUE).
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
15 spec <- matrix(c(
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
16 "quiet", "q", 0, "logical",
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
17 "help", "h", 0, "logical",
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
18 "bamdir", "b", 1, "character",
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
19 "gtffile", "g", 1, "character",
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
20 "codon_coverage_info", "Y", 1, "character",
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
21 "cds_coverage_info", "Z", 1, "character",
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
22 "psite_info_rdata", "O", 0, "character",
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
23 "refseq_sep", "s", 0, "character",
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
24 "params_duplicate_filterting", "d", 0, "character",
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
25 "params_peridiocity_filterting", "l", 0, "character",
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
26 "params_custom_filterting", "c", 0, "character",
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
27 "params_psite_additional", "p", 0, "character",
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
28 "params_coverage_additional", "C", 0, "character"
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
29 ), byrow = TRUE, ncol = 4)
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
30 opt <- getopt(spec)
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
31
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
32 # if help was asked for print a friendly message
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
33 # and exit with a non-zero error code
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
34 if (!is.null(opt$help)) {
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
35 cat(getopt(spec, usage = TRUE))
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
36 q(status = 1)
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
37 }
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
38
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
39 verbose <- is.null(opt$quiet)
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
40
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
41 library("riboWaltz")
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
42
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
43 # create annotation data table
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
44 annotation_dt <- create_annotation(opt$gtffile)
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
45
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
46 sep <- opt$refseq_sep
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
47 if (opt$refseq_sep == "") {
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
48 sep <- NULL
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
49 }
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
50 # convert alignments in BAM files into list of data tables
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
51 reads_list <- bamtolist(bamfolder = opt$bamdir, annotation = annotation_dt, refseq_sep = sep)
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
52
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
53 library("jsonlite")
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
54 # remove duplicate reads
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
55 if (!is.null(opt$params_duplicate_filterting)) {
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
56 json_duplicate_filterting <- fromJSON(opt$params_duplicate_filterting)
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
57 reads_list <- duplicates_filter(
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
58 data = reads_list,
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
59 extremity = json_duplicate_filterting$extremity,
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
60 keep = json_duplicate_filterting$keep
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
61 )
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
62 }
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
63
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
64 # selection of read lengths - periodicity filtering
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
65 if (!is.null(opt$params_peridiocity_filterting)) {
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
66 json_peridiocity_filterting <- fromJSON(opt$params_peridiocity_filterting)
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
67 reads_list <- length_filter(
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
68 data = reads_list,
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
69 length_filter_mode = "periodicity",
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
70 periodicity_threshold = json_peridiocity_filterting$periodicity_threshold
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
71 )
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
72 }
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
73 # selection of read lengths - length range filtering
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
74 if (!is.null(opt$params_custom_filterting)) {
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
75 json_custom_filterting <- fromJSON(opt$params_custom_filterting)
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
76 reads_list <- length_filter(
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
77 data = reads_list,
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
78 length_filter_mode = "custom",
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
79 length_range = json_custom_filterting$length_range
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
80 )
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
81 }
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
82
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
83 # compute P-site offset
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
84 json_psite_additional <- fromJSON(opt$params_psite_additional)
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
85 psite_offset <- psite(
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
86 reads_list,
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
87 start = json_psite_additional$use_start,
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
88 flanking = json_psite_additional$flanking,
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
89 extremity = json_psite_additional$psite_extrimity,
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
90 plot = TRUE,
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
91 cl = json_psite_additional$cl,
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
92 plot_format = "pdf",
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
93 plot_dir = "plots"
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
94 )
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
95 psite_offset
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
96
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
97 reads_psite_list <- psite_info(reads_list, psite_offset)
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
98 reads_psite_list
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
99 # write a separate P-site offset info table for each sample
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
100 for (sample in names(reads_psite_list)) {
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
101 write.table(
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
102 reads_psite_list[[sample]],
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
103 file = paste(sample, "psite_info.tsv", sep = "_"),
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
104 sep = "\t", row.names = FALSE, quote = FALSE
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
105 )
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
106 print(paste(sample, "psite_info.tsv", sep = "_"))
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
107 }
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
108
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
109 # write R object to a file
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
110 if (!is.null(opt$psite_info_rdata)) {
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
111 save(reads_psite_list, annotation_dt, file = opt$psite_info_rdata)
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
112 }
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
113
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
114 json_coverage_additional <- fromJSON(opt$params_coverage_additional)
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
115 # codon coverage
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
116 codon_coverage_out <- codon_coverage(
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
117 reads_psite_list,
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
118 annotation_dt,
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
119 psite = json_coverage_additional$psites_per_region,
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
120 min_overlap = json_coverage_additional$min_overlap
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
121 )
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
122 write.table(codon_coverage_out, file = opt$codon_coverage_info, sep = "\t", row.names = FALSE, quote = FALSE)
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
123
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
124 # CDS coverage
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
125 cds_coverage_out <- cds_coverage(
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
126 reads_psite_list,
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
127 annotation_dt,
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
128 start_nts = json_coverage_additional$start_nts,
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
129 stop_nts = json_coverage_additional$stop_nts
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
130 )
6d4c94373bba planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/ribowaltz commit ff002df702f544829d1b500ac4b517c1e70ad14d
iuc
parents:
diff changeset
131 write.table(cds_coverage_out, file = opt$cds_coverage_info, sep = "\t", row.names = FALSE, quote = FALSE)