forked from tianshilu/QBRC-Somatic-Pipeline
-
Notifications
You must be signed in to change notification settings - Fork 1
/
job_cnv.pl
76 lines (65 loc) · 2.07 KB
/
job_cnv.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
########### sbatch wrapper for CNV #############
# for other job submission system, you should be able to easily change "sbatch" to the appropriate command
# all paths must be absolute
#
# The instructions must be followed exactly!!!
# input format:
# jobs: the batch job design file, it has 7 columns separated by \t. Commented lines ("#" at the front) are skipped
# The first four are fastq files or bam files (normal+tumor),
# Next is the somatic mutation calling output file
# Next is the output folder.
# Last is "PDX" or "human" or "mouse"
# example: the demo job submission shell script. A default one is in this folder
# thread,index,disambiguate: follow those in cnv.pl
# n: bundle $n CNV calling jobs into one submission
#!/usr/bin/perl
use strict;
use warnings;
use Cwd 'abs_path';
my ($jobs,$example,$thread,$index,$disambiguate,$n)=@ARGV;
my ($line,$line1,@items,$i,$job);
my $path=abs_path($0);
$path=~s/job_cnv\.pl//;
open(JOB,$jobs) or die "Cannot find the design file!\n";
$i=0;
while ($line=<JOB>)
{
$line=~s/(\r|\n)//g;
if ($line eq "" || $line=~/^#/) {next;}
if ($i++ % $n==0)
{
$job="cnv_".$i.".sh";
open(SCRIPT,">".$job) or die "Cannot write to the shell submission script!\n";
# write header
open(HEADER,$example) or die "Cannot find the example shell script!\n";
while ($line1=<HEADER>)
{
if ($line1=~/JOBSTART/) {last;}
print SCRIPT $line1;
}
close(HEADER);
}
# write submission job
@items=split("\t",$line);
print SCRIPT "perl ".$path."/cnv.pl ".$items[0]." ".$items[1]." ".$items[2]." ".$items[3].
" ".$thread." ".$index." ".$items[4]." ".$items[5]." ".$items[6]." ".$disambiguate."\n";
if ($i % $n==0)
{
close(SCRIPT);
system("sbatch ".$job);
unlink($job);
sleep(1);
}
}
close(JOB);
if ($i % $n!=0)
{
close(SCRIPT);
system("sbatch ".$job);
unlink($job);
}
#perl /home2/twang6/software/cancer/somatic/job_cnv.pl \
#design.txt \
#~/example.sh 32 \
#/project/shared/xiao_wang/data/hg38/hs38d1.fa \
#/project/shared/xiao_wang/software/disambiguate_pipeline 2