From 14df931f3e3f950dc8c9b213c8802330ee1eb74c Mon Sep 17 00:00:00 2001 From: Georgi Tushev Date: Tue, 5 Feb 2019 10:49:29 +0100 Subject: [PATCH] add genome coverage --- batchGenomeCoverage.pl | 43 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 batchGenomeCoverage.pl diff --git a/batchGenomeCoverage.pl b/batchGenomeCoverage.pl new file mode 100644 index 0000000..1e6a1ef --- /dev/null +++ b/batchGenomeCoverage.pl @@ -0,0 +1,43 @@ +#!/usr/bin/perl + +use warnings; +use strict; +use File::Basename; + +my $pathSource = shift; +my $pathDest = shift; + +my $nodes = 1; +my $partition = "bedtools genomecov"; +my $time = "100:00:00"; +my $ntasks = 1; +my $cpus = 128; +my $name = "braintest"; + +# print header +print "#!/bin/bash\n"; +print "\n"; +print "#SBATCH --nodes=$nodes\n"; +print "#SBATCH --partition=$partition\n"; +print "#SBATCH --time=$time\n"; +print "#SBATCH --ntasks=$ntasks\n"; +print "#SBATCH --cpus-per-task=$cpus\n"; +print "#SBATCH --job-name=$name\n"; +print "#SBATCH --error=error_\%j.out\n"; +print "#SBATCH --output=output_\%j.out\n"; +print "\n"; +print "echo \$SLURM_SUBMIT_DIR\n"; +print "echo \"Running on \`hostname\`\"\n"; +print "\n"; + +my @fileList = glob($pathSource . "/*.bam"); +foreach my $file (@fileList) { + + my $fileName = fileparse($file, ".bam"); + my $fileOut = $pathDest . "/" . $fileName . ".gbed"; + print "bedtools genomecov -ibam " . $file . " -bg -split | sort -k1,1 -k2,2n -k3,3n | bgzip > " . $fileOut . "\n"; + print "tabix --zero-based --sequence 1 --begin 2 --end 3 " . $fileOut . "\n"; +} + + +