Mercurial > repos > greg > ideas_preprocessor
changeset 9:0cf23f33d13d draft
Uploaded
author | greg |
---|---|
date | Wed, 24 Jan 2018 10:16:11 -0500 |
parents | 860b59cae5df |
children | f45e461b0557 |
files | ideas_preprocessor.R |
diffstat | 1 files changed, 11 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- a/ideas_preprocessor.R Wed Jan 24 10:16:04 2018 -0500 +++ b/ideas_preprocessor.R Wed Jan 24 10:16:11 2018 -0500 @@ -1,10 +1,11 @@ +(.venv) [galaxy@IDEAS ideas_preprocessor]$ cat ideas_preprocessor.R #!/usr/bin/env Rscript suppressPackageStartupMessages(library("data.table")) suppressPackageStartupMessages(library("optparse")) option_list <- list( - make_option(c("--chrom_bed_input"), action="store", dest="chrom_bed_input", defaul=NULL, help="Chromosome windows positions file"), + make_option(c("--bed_input"), action="store", dest="bed_input", defaul=NULL, help="Chromosome windows positions file"), make_option(c("--exclude_input"), action="store", dest="exclude_input", defaul=NULL, help="File(s) containing regions to exclude"), make_option(c("--bychr"), action="store_true", dest="bychr", defaul=FALSE, help="Separate files by chromosome"), make_option(c("--chrom_len_file"), action="store", dest="chrom_len_file", default=NULL, help="Chromosome lengths file"), @@ -59,27 +60,27 @@ } bed_file_name = paste(file_name, "bed", sep="."); bed_file_path = paste("tmp", bed_file_name, sep="/"); - cmd = paste("bigWigAverageOverBed", bigwig_file_name, opt$chrom_bed_input, "stdout | cut -f5 >", bed_file_path); + cmd = paste("bigWigAverageOverBed", bigwig_file_name, opt$bed_input, "stdout | cut -f5 >", bed_file_path); system(cmd); cmd = paste("gzip -f", bed_file_path); system(cmd); } -# Create temporary file1.txt. +# Create file1.txt. cmd = paste("cut -d' '", opt$ideaspre_input_config, "-f1,2 > file1.txt", sep=" "); system(cmd); # Compress the bed files in the tmp directory. tmp_gzipped_files = paste(tmp_dir, "*.bed.gz", sep="/"); -# Create temporary file2.txt. +# Create file2.txt. cmd = paste("ls", tmp_gzipped_files, "> file2.txt", sep=" "); system(cmd); -# Create IDEAS_input_config.txt with the format required by IDEAS. +# Create the ideas_input_config with the format required by IDEAS. cmd = paste("paste -d' ' file1.txt file2.txt >", opt$ideas_input_config, sep=" "); system(cmd); -# Move IDEAS_input_config.txt to the output directory. +# Move the ideas_input_config to the output directory. to_path = paste(opt$output_files_path, opt$ideas_input_config, sep="/"); file.rename(opt$ideas_input_config, to_path); -# Move all compressed bed files in the tmp +# Move the compressed bed files in the tmp # directory to the output tmp directory. tmp_files = list.files(path=tmp_dir); for (i in 1:length(tmp_files)) { @@ -87,14 +88,10 @@ to_path = paste(output_tmp_dir, tmp_files[i], sep="/"); file.rename(from_path, to_path); } -if (!is.null(opt$chrom_bed_input) && !is.null(opt$chromosome_windows)) { - # Rename chrom_bed_input to chromosomes.txt - # and move it to the output directory. - to_path = paste(opt$output_files_path, "chromosomes.bed", sep="/"); - file.rename(opt$chrom_bed_input, to_path) - # Move chromosome_windows.txt to the output directory. +if (!is.null(opt$chromosome_windows)) { + # Move the chromosome_windows to the output directory. to_path = paste(opt$output_files_path, opt$chromosome_windows, sep="/"); file.rename(opt$chromosome_windows, to_path); } # Create the primary HTML dataset. -create_primary_html(opt$output, opt$output_hid, opt$output_files_path); \ No newline at end of file +create_primary_html(opt$output, opt$output_hid, opt$output_files_path);