annotate lib/tarean/tarean.R @ 0:1d1b9e1b2e2f draft

Uploaded
author petr-novak
date Thu, 19 Dec 2019 10:24:45 -0500
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
1 #!/usr/bin/env Rscript
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
2 library(optparse, quiet = TRUE)
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
3 library(parallel)
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
4 if (interactive()){
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
5 ## define functions only and exit
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
6 ## assume that working directory was changes with source( chdir=TRUE)!!!
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
7 script.dir=normalizePath('.')
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
8 source('methods.R')
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
9 source('logo_methods.R')
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
10 source('htmlheader.R')
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
11 options(OGDF = paste0(script.dir,"/OGDF/runOGDFlayout"))
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
12
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
13 }else{
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
14 ## get options from command line
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
15 initial.options <- commandArgs(trailingOnly = FALSE)
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
16 file.arg.name <- "--file="
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
17 script.name <- sub(file.arg.name, "", initial.options[grep(file.arg.name, initial.options)])
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
18 script.dir <- normalizePath(dirname(script.name))
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
19 oridir=getwd()
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
20 ## parse arguments
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
21 option_list = list(
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
22 make_option(c('-i', '--input_sequences'),action='store',type='character',help='fasta file with input sequences',default=NA),
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
23 make_option(c('-o', '--output_dir'),action='store',type='character',help='output directory',default="./kmer_analysis"),
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
24 make_option(c('-m', '--min_kmer_length'),action='store',type='numeric',help='min kmer length',default=11),
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
25 make_option(c('-x', '--max_kmer_length'),action='store',type='numeric',help='min kmer length',default=27),
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
26 make_option(c('-n', '--cpu'),action='store',type='numeric',help='number of cpu to use',default=NULL),
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
27 make_option(c('-s', '--sample_size'),action='store',type='numeric',help='number of sequences to use for analysis, is set to 0 all sequences are used',default=10000),
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
28 make_option(c('-r', '--reorient_reads'),action='store_true',type='logical',help='number of cpu to use',default=FALSE),
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
29 make_option(c('-l', '--no_layout'),action='store_true',type='logical',help='do not calculate graph layout',default=FALSE),
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
30 make_option(c('-p', '--paired'),action='store_true',type='logical',help='reads are paired',default=FALSE),
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
31 make_option(c('-t', '--tRNA_database='), action='store',type='character',help='path to tRNA database, is set PBS detection is performed',default=NULL)
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
32
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
33 )
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
34
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
35 description = paste (strwrap(" put decription here"), collapse ="\n")
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
36 epilogue = paste (strwrap(" put epilogue here"), collapse ="\n")
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
37 parser=OptionParser(
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
38 option_list=option_list,
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
39 epilogue=epilogue,
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
40 description=description,
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
41 )
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
42 opt = parse_args(parser, args=commandArgs(TRUE))
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
43 ## as Rscript
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
44 options(OGDF = paste0(script.dir,"/OGDF/runOGDFlayout"))
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
45 CPU = ifelse(is.null(opt$cpu), detectCores(), opt$cpu)
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
46 source(paste(script.dir,"/","methods.R", sep=''))
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
47 source(paste(script.dir,"/","logo_methods.R", sep=''))
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
48 source(paste(script.dir,"/","htmlheader.R", sep=''))
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
49 ## set number of CPU to use
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
50
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
51
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
52
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
53 ## run tarean:
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
54 tarean(
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
55 opt$input_sequences,
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
56 opt$output_dir,
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
57 opt$min_kmer_length,
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
58 opt$max_kmer_length,
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
59 CPU,
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
60 opt$sample_size,
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
61 opt$reorient_reads,
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
62 opt$tRNA_database,
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
63 !opt$no_layout,
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
64 paired = opt$paired
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
65 )
1d1b9e1b2e2f Uploaded
petr-novak
parents:
diff changeset
66 }