-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathsprai-wrapper.pl
executable file
·221 lines (175 loc) · 5.93 KB
/
sprai-wrapper.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
#!/usr/bin/env perl
use strict;
use warnings;
use Getopt::Long;
use File::Which;
use File::Basename;
use File::Spec;
my %options = (
min_len_for_query => 500,
memory => 8000,
threads => 1,
);
my $options_ok = GetOptions(\%options,
'min_len_for_query=i',
'memory=i',
'threads=i',
);
if (($#ARGV != 4) or !($options_ok)) {
print STDERR "usage: $0 [options] <celera bin/> <sprai bin/> <genome size> <reads> <output dir>
Runs SPRAI in single-node mode.
Assumes blastn is in your path and that makeblastdb is in the same directory as blastn
Options:
--min_len_for_query
'the subreads longer than or equal to this value will be corrected' [$options{min_len_for_query}]
--memory
Memory in MB that is passed to some celera options in the spec file [$options{memory}]
--threads
Number of threads to use [$options{threads}]
";
exit 1;
}
my $celera_bin = File::Spec->rel2abs($ARGV[0]);
my $sprai_bin = File::Spec->rel2abs($ARGV[1]);
my $genome_size = $ARGV[2];
my $reads = File::Spec->rel2abs($ARGV[3]);
my $outdir = $ARGV[4];
my $ec_spec = "ec.spec";
my $pbasm_spec = "pbasm.spec";
my $blastn = which 'blastn';
my($filename, $blastn_dir, $suffix) = fileparse($blastn);
mkdir $outdir or die $!;
chdir $outdir or die $!;
open F, ">$ec_spec" or die $!;
print F "
#### common ####
# input_for_database: filtered subreads in fasta or fastq format
input_for_database $reads
# min_len_for_query: the subreads longer than or equal to this value will be corrected
min_len_for_query $options{min_len_for_query}
#if you don't know the estimated genome size, give a large number
estimated_genome_size $genome_size
#if you don't know the estimated depth of coverage, give 0
estimated_depth 0
# ca_path: where Celera Assembler exist in
ca_path $celera_bin
# the number of processes used by all vs. all alignment
# = 'partition' (in single node mode)
# = 'pre_partition' * 'partition' (in many node mode)
pre_partition 2
partition $options{threads}
# sprai prefer full paths
# if you use ezez4qsub*.pl. you MUST specify blast_path & sprai_path
# blast_path: where blastn and makeblastdb exist in
blast_path $blastn_dir
# sprai_path: where binaries of sprai (bfmt72s, nss2v_v3 and so on) exist in
sprai_path $sprai_bin
#### many node mode (advanced) ####
#sge: options for all the SGE jobs
#sge -soft -l ljob,lmem,sjob
#queue_req: additional options for all the SGE jobs
#queue_req -l s_vmem=4G -l mem_req=4
#longestXx_queue_req: if valid, displaces queue_req
#longestXx_queue_req -l s_vmem=64G -l mem_req=64
#BLAST_RREQ: additional options for SGE jobs of all vs. all alignment
#BLAST_RREQ -pe def_slot 4
#### common (advanced) ####
# used by blastn
word_size 18
evalue 1e-50
num_threads 1
max_target_seqs 100
#valid_voters 11
#trim: both ends of each alignment by blastn will be trimmed 'trim' bases to detect chimeric reads
trim 42
";
close F or die $!;
open F, ">$pbasm_spec" or die $!;
print F "# Copyright (c) 2011-2013, Pacific Biosciences of California, Inc.
#
# All rights reserved.
#
# Redistribution and use in source and binary forms, with or without
# modification, are permitted (subject to the limitations in the
# disclaimer below) provided that the following conditions are met:
#
# * Redistributions of source code must retain the above copyright
# notice, this list of conditions and the following disclaimer.
#
# * Redistributions in binary form must reproduce the above
# copyright notice, this list of conditions and the following
# disclaimer in the documentation and/or other materials provided
# with the distribution.
#
# * Neither the name of Pacific Biosciences nor the names of its
# contributors may be used to endorse or promote products derived
# from this software without specific prior written permission.
#
# NO EXPRESS OR IMPLIED LICENSES TO ANY PARTY'S PATENT RIGHTS ARE
# GRANTED BY THIS LICENSE. THIS SOFTWARE IS PROVIDED BY PACIFIC
# BIOSCIENCES AND ITS CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED
# WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
# OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
# DISCLAIMED. IN NO EVENT SHALL PACIFIC BIOSCIENCES OR ITS
# CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
# SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
# LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF
# USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
# ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT
# OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
# SUCH DAMAGE.
#
unitigger = bogart
#utgErrorRate = 0.015
#utgErrorLimit = 4.5
cnsErrorRate = 0.25
cgwErrorRate = 0.25
ovlErrorRate = 0.015
frgMinLen = 1000
ovlMinLen = 40
merSize=14
merylMemory = $options{memory}
merylThreads = $options{threads}
ovlStoreMemory = $options{memory}
# grid info
useGrid = 0
scriptOnGrid = 0
frgCorrOnGrid = 0
ovlCorrOnGrid = 0
sge = -S /bin/bash -V -q all.q
#sge = -S /bin/bash -sync y -V -q all.q
sgeScript = -pe threads 1
sgeConsensus = -pe threads 1
sgeOverlap = -pe threads 4
sgeFragmentCorrection = -pe threads 4
sgeOverlapCorrection = -pe threads 1
#ovlHashBits = 22
#ovlHashBlockLength = 46871347
#ovlRefBlockSize = 537
ovlHashBits = 25
ovlThreads = $options{threads}
ovlHashBlockLength = 50000000
ovlRefBlockSize = 100000000
ovlConcurrency = $options{threads}
frgCorrThreads = $options{threads}
frgCorrBatchSize = 100000
ovlCorrBatchSize = 100000
cnsMinFrags = 7500
cnsConcurrency = $options{threads}
# change sgeName every time if you do not want to wait for the jobs not necessary to wait
sgeName = iroha
";
close F;
my $script = 'run.sh';
open F, ">$script" or die $!;
print F "#!/usr/bin/env bash
set -e
export PATH=$sprai_bin:\$PATH
ezez_vx1.pl $ec_spec $pbasm_spec
cp -s result_*/CA/9-terminator/asm_*.scf.fasta scaffolds.fasta
";
close F;
chmod 0755, $script;
my $cmd = "./$script";
exec($cmd) or die "error running $cmd: $!";