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