Mercurial > repos > greg > ideas_preprocessor
changeset 21:99102499271a draft
Uploaded
author | greg |
---|---|
date | Wed, 31 Jan 2018 08:22:43 -0500 |
parents | 237ee7319452 |
children | 3651f1592f3f |
files | ideas_preprocessor.R |
diffstat | 1 files changed, 6 insertions(+), 20 deletions(-) [+] |
line wrap: on
line diff
--- a/ideas_preprocessor.R Wed Jan 31 08:22:34 2018 -0500 +++ b/ideas_preprocessor.R Wed Jan 31 08:22:43 2018 -0500 @@ -41,14 +41,10 @@ for (i in 1:length(files)) { s <- paste(s, '<li><a href="', files[i], '">', files[i], '</a></li>\n', sep=""); } - s <- paste(s, '</ul>\n</body>\n</html>', sep=""); + s <- paste(s, '</ul></body></html>', sep=""); cat(s, file=output); } -tmp_dir = "tmp"; -output_tmp_dir = paste(opt$output_files_path, tmp_dir, sep="/"); -dir.create(output_tmp_dir, showWarnings=FALSE); - # Read the ideaspre_input_config text file which has this format: # "cell type name" "epigenetic factor name" "file path" "file name" "datatype" ideaspre_input_config = as.matrix(read.table(opt$ideaspre_input_config)); @@ -75,10 +71,9 @@ bigwig_file_name = file_path; } 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$chrom_bed_input, "stdout | cut -f5 >", bed_file_name); system(cmd); - cmd = paste("gzip -f", bed_file_path); + cmd = paste("gzip -f", bed_file_name); system(cmd); } } @@ -86,10 +81,8 @@ # 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 file2.txt. -cmd = paste("ls", tmp_gzipped_files, "> file2.txt", sep=" "); +# Compress the bed files and create file2.txt. +cmd = "ls *.bed.gz > file2.txt"; system(cmd); # Create IDEAS_input_config.txt with the format required by IDEAS. ideas_input_config = "IDEAS_input_config.txt" @@ -98,14 +91,7 @@ # Move IDEAS_input_config.txt to the output directory. to_path = paste(opt$output_files_path, ideas_input_config, sep="/"); file.rename(ideas_input_config, to_path); -# 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)) { - from_path = paste(tmp_dir, tmp_files[i], sep="/"); - to_path = paste(output_tmp_dir, tmp_files[i], sep="/"); - file.rename(from_path, to_path); -} +# Handle optional chrom_bed_input.txt and chromosomes.bed files. if (!is.null(opt$chrom_bed_input) && !is.null(opt$chromosome_windows)) { # Renane opt$chrom_bed_input to be chromosomes.bed # and make a copy of it in the output directory.