forked from tianshilu/QBRC-Somatic-Pipeline
-
Notifications
You must be signed in to change notification settings - Fork 1
/
job_somatic.pl
79 lines (68 loc) · 2.41 KB
/
job_somatic.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
77
78
79
########### nucleus-specific sbatch wrapper for calling somatic mutations #############
# for other job submission system, you should be able to easily change "sbatch" to the appropriate command
#
# The instructions must be followed exactly!!!
# input format:
# jobs: the batch job design file, it has 6 columns separated by \t, the first four are fastq files or bam files (normal+tumor),
# the fifth is the output folder, and the last is "PDX" or "human" or "mouse". Commented lines ("#" at the front) are skipped
# example: the demo job submission shell script. A default one is in this folder
# thread,build,index,java17,keep_coverage: follow those in somatic.pl
# n: bundle $n somatic calling jobs into one submission
# disambiguate: follow those in somatic.pl
#!/usr/bin/perl
use strict;
use warnings;
use Cwd 'abs_path';
my ($jobs,$example,$thread,$build,$index,$java17,$keep_coverage,$n,$disambiguate)=@ARGV;
my ($line,$line1,@items,$i,$job);
my $path=abs_path($0);
$path=~s/job_somatic\.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="somatic_calling_".$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);
system("rm -f -r ".$items[4]);
system("mkdir ".$items[4]);
print SCRIPT "perl ".$path."/somatic.pl ".$items[0]." ".$items[1]." ".$items[2]." ".$items[3].
" ".$thread." ".$build." ".$index." ".$java17." ".$items[4]." ".$items[5]." ".
$keep_coverage." ".$disambiguate." 2> ".$items[4]."/job_error.txt 1> ".$items[4]."/job_output.txt\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_somatic.pl \
#design.txt \
#/project/DPDS/Xiao_lab/shared/neoantigen/code/somatic/example/example.sh \
#32 hg38 \
#/project/shared/xiao_wang/data/hg38/hs38d1.fa \
#/cm/shared/apps/java/oracle/jdk1.7.0_51/bin/java \
#0 2 \
#/project/shared/xiao_wang/software/disambiguate_pipeline