Commit f69ad69a authored by nchernia's avatar nchernia
Browse files

modified cleanup script; fixed bug in split rmdups

parent 8516edef
Loading
Loading
Loading
Loading
+18 −2
Changes for SLURM/scripts/cleanup.sh: 18 added lines, 2 removed lines.
Original line number Diff line number Diff line
@@ -27,5 +27,21 @@
# Juicer version 1.5
total=`ls -l aligned/merged_sort.txt | awk '{print $5}'`
total2=`ls -l aligned/merged_nodups.txt aligned/dups.txt aligned/opt_dups.txt | awk '{sum = sum + $5}END{print sum}'`
if [ $total -eq $total2 ]; then rm aligned/merged_sort.txt; rm -r splits; else echo "Problem: The sum of merged_nodups and the dups files is not the same size as merged_sort.txt"; fi
#bzip2 fastq/*.fastq
if [ $total -eq $total2 ] 
then 
    rm aligned/merged_sort.txt 
    rm -r splits 
    for i in fastq/*.fastq
    do
        gzip $i
    done
    gzip aligned/merged_nodups.txt
    gzip aligned/dups.txt
    gzip aligned/opt_dups.txt
    gzip aligned/abnormal.sam
    gzip aligned/collisions.txt
    gzip aligned/unmapped.sam
else 
    echo "Problem: The sum of merged_nodups and the dups files is not the same size as merged_sort.txt"
    echo "Did NOT clean up";
fi
+38 −2
Changes for SLURM/scripts/split_rmdups.awk: 38 added lines, 2 removed lines.
Original line number Diff line number Diff line
#!/usr/bin/awk -f
##########
#The MIT License (MIT)
#
# Copyright (c) 2015 Aiden Lab
#
# Permission is hereby granted, free of charge, to any person obtaining a copy
# of this software and associated documentation files (the "Software"), to deal
# in the Software without restriction, including without limitation the rights
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
# copies of the Software, and to permit persons to whom the Software is
# furnished to do so, subject to the following conditions:
#
# The above copyright notice and this permission notice shall be included in
# all copies or substantial portions of the Software.
#
#  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
#  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
#  FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
#  AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
#  LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
#  OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
#  THE SOFTWARE.
##########

# Dedup script that submits deduping jobs after splitting at known 
# non-duplicate
# Juicer version 1.5
BEGIN{
	tot=0;
	name=0;
@@ -8,9 +35,13 @@ BEGIN{
		if (p1 != $1 || p2 != $2 || p4 != $4 || p5 != $5 || p8 != $8) {
			sname = sprintf("%s_msplit%04d_", groupname, name);
			sscriptname = sprintf("%s/.%s.slurm", outDir, sname);
			printf("#!/bin/bash -l\n#SBATCH -o %s/dup-split-%s.out\n#SBATCH -e %s/dup-split-%s.err\n#SBATCH -p %s\n#SBATCH -J %s_msplit0\n#SBATCH -t 1440\n#SBATCH -c 1\n#SBATCH --ntasks=1\ndate;awk -f %s/scripts/dups.awk -v name=%s/%s %s/split%04d;\ndate\n", outDir, name, outDir, name, queue, groupname, juicedir, dir, sname, dir, name) > sscriptname;
			printf("#!/bin/bash -l\n#SBATCH -o %s/dup-split-%s.out\n#SBATCH -e %s/dup-split-%s.err\n#SBATCH -p %s\n#SBATCH -J %s_msplit0\n#SBATCH -t 1440\n#SBATCH -c 1\n#SBATCH --ntasks=1\ndate;awk -f %s/scripts/dups.awk -v name=%s/%s %s/split%04d;\necho Reads:%s\ndate\n", outDir, name, outDir, name, queue, groupname, juicedir, dir, sname, dir, name, tot) > sscriptname;
			sysstring = sprintf("sbatch %s", sscriptname);
			system(sysstring);
			outname = sprintf("%s/split%04d", dir, name);
			close(outname);
			close(sscriptname);

			name++;
			tot=0;
		}
@@ -23,19 +54,22 @@ BEGIN{
END {
	sname = sprintf("%s_msplit%04d_", groupname, name);
	sscriptname = sprintf("%s/.%s.slurm", outDir, sname);
	printf("#!/bin/bash -l\n#SBATCH -o %s/dup-split-%s.out\n#SBATCH -e %s/dup-split-%s.err\n#SBATCH -p %s\n#SBATCH -J %s_msplit0\n#SBATCH -t 1440\n#SBATCH -c 1\n#SBATCH --ntasks=1\ndate;awk -f %s/scripts/dups.awk -v name=%s/%s %s/split%04d;\ndate\n", outDir, name, outDir, name, queue, groupname, juicedir, dir, sname, dir, name) > sscriptname;
	printf("#!/bin/bash -l\n#SBATCH -o %s/dup-split-%s.out\n#SBATCH -e %s/dup-split-%s.err\n#SBATCH -p %s\n#SBATCH -J %s_msplit0\n#SBATCH -t 1440\n#SBATCH -c 1\n#SBATCH --ntasks=1\ndate;awk -f %s/scripts/dups.awk -v name=%s/%s %s/split%04d;\necho Reads:%s\ndate\n", outDir, name, outDir, name, queue, groupname, juicedir, dir, sname, dir, name, tot) > sscriptname;
	sysstring = sprintf("sbatch %s", sscriptname);
	system(sysstring);
	close(sscriptname);

	sscriptname = sprintf("%s/.%s_msplit.slurm", outDir, groupname);
	printf("#!/bin/bash -l\n#SBATCH -o %s/dup-merge.out\n#SBATCH -e %s/dup-merge.err\n#SBATCH -p %s\n#SBATCH -J %s_msplit0\n#SBATCH -d singleton\n#SBATCH -t 1440\n#SBATCH -c 1\n#SBATCH --ntasks=1\ndate;\necho \"\"; cat %s/%s_msplit*_optdups.txt > %s/opt_dups.txt;cat %s/%s_msplit*_dups.txt > %s/dups.txt;cat %s/%s_msplit*_merged_nodups.txt > %s/merged_nodups.txt;\ndate\n", outDir, outDir, queue, groupname, dir, groupname, dir, dir, groupname, dir, dir, groupname, dir) > sscriptname;
	sysstring = sprintf("sbatch %s", sscriptname);
	system(sysstring);
	close(sscriptname);

	sscriptname = sprintf("%s/.%s_rmsplit.slurm", outDir, groupname);
	printf("#!/bin/bash -l\n#SBATCH -o %s/dup-rm.out\n#SBATCH -e %s/dup-rm.err\n#SBATCH -p %s\n#SBATCH -J %s_msplit0\n#SBATCH -d singleton\n#SBATCH -t 1440\n#SBATCH -c 1\n#SBATCH --ntasks=1\ndate;\nrm %s/*_msplit*_optdups.txt; rm %s/*_msplit*_dups.txt; rm %s/*_msplit*_merged_nodups.txt;rm %s/split*;\ndate\n", outDir, outDir, queue, groupname, dir, dir, dir, dir) > sscriptname;
	sysstring = sprintf("sbatch %s", sscriptname);
	system(sysstring);
	close(sscriptname);

	sscriptname = sprintf("%s/.%s_finalize.slurm", outDir, groupname);
	printf("#!/bin/bash -l\n#SBATCH -o %s/dup-guard-trigger.out\n#SBATCH -e %s/dup-guard-trigger.err\n#SBATCH -p %s\n#SBATCH -J %s_msplit0\n#SBATCH -d singleton\n#SBATCH -t 1440\n#SBATCH -c 1\n#SBATCH --ntasks=1\necho %s %s %s %s;\nsqueue -u %s;\ndate\n", outDir, outDir, queue, groupname, topDir, site, genomeID, genomePath, user, user) > sscriptname;
@@ -45,10 +79,12 @@ END {
	var = gensub("[^0-9]", "", "g", maildupid);
	sysstring = sprintf("scontrol update JobID=%s dependency=afterok:%s", guardjid, var);
	system(sysstring);
	close(sscriptname);

	sscriptname = sprintf("%s/.%s_mail.slurm", outDir, groupname);
	printf("#!/bin/bash -l\n#SBATCH -o %s/dup-mail.out\n#SBATCH -e %s/dup-mail.err\n#SBATCH -p %s\n#SBATCH -J %s_msplit0\n#SBATCH -d singleton\n#SBATCH -t 1440\n#SBATCH -c 1\n#SBATCH --ntasks=1\ndate;\necho %s %s %s %s | mail -r Juicer@rice.edu -s \"Juicer pipeline finished successfully @ Rice\" -t %s@rice.edu;\ndate\n", outDir, outDir, queue, groupname, topDir, site, genomeID, genomePath, user) > sscriptname;
	sysstring = sprintf("sbatch %s", sscriptname);
	system(sysstring);
	close(sscriptname);
}