Mercurial > repos > jdv > nanopolish
comparison nanopolish_variants.pl @ 8:b437c0a7ca04 draft
planemo upload for repository https://github.com/jvolkening/galaxy-tools/tree/master/tools/nanopolish commit 419298c744d71488d78e1dadb868a4d8b933618e
author | jdv |
---|---|
date | Mon, 12 Feb 2018 03:06:42 -0500 |
parents | 32cb27adeb34 |
children | f1141f6a2d65 |
comparison
equal
deleted
inserted
replaced
7:32cb27adeb34 | 8:b437c0a7ca04 |
---|---|
5 use 5.012; | 5 use 5.012; |
6 | 6 |
7 use Cwd qw/getcwd abs_path/; | 7 use Cwd qw/getcwd abs_path/; |
8 use File::Copy qw/copy/; | 8 use File::Copy qw/copy/; |
9 use Getopt::Long qw/:config pass_through/; | 9 use Getopt::Long qw/:config pass_through/; |
10 use List::Util qw/min/; | |
10 use threads; | 11 use threads; |
11 use threads::shared; | 12 use threads::shared; |
12 use BioX::Seq::Stream; | 13 use BioX::Seq::Stream; |
13 | 14 |
14 my $fn_genome; | 15 my $fn_genome; |
35 my $ret; | 36 my $ret; |
36 | 37 |
37 my $fn_link = 'reads'; | 38 my $fn_link = 'reads'; |
38 my $tmp_dir = 'tmp_dir'; | 39 my $tmp_dir = 'tmp_dir'; |
39 mkdir $tmp_dir; | 40 mkdir $tmp_dir; |
41 | |
42 # divide available threads between actual threads and regions | |
43 # | |
44 # testing suggests minimal speed-up past 4-8 actual threads per region, so use | |
45 # remaining threads for running parallel regions | |
46 my $n_threads = min( 4, $threads ); | |
47 my $n_workers = int($threads/$n_threads); | |
48 | |
40 | 49 |
41 $fn_fast5 = abs_path($fn_fast5); | 50 $fn_fast5 = abs_path($fn_fast5); |
42 | 51 |
43 # extract FAST5 files to path where they are expected | 52 # extract FAST5 files to path where they are expected |
44 # use system 'tar' to transparently and safely handle absolute paths | 53 # use system 'tar' to transparently and safely handle absolute paths |
80 if ($ret); | 89 if ($ret); |
81 } | 90 } |
82 | 91 |
83 my @cmd = @ARGV; | 92 my @cmd = @ARGV; |
84 unshift @cmd, 'nanopolish'; | 93 unshift @cmd, 'nanopolish'; |
85 push @cmd, '--genome', $fn_genome; | 94 push @cmd, '--genome', $fn_genome; |
86 push @cmd, '--reads', $fn_link; | 95 push @cmd, '--reads', $fn_link; |
96 push @cmd, '--threads', $n_threads; | |
87 | 97 |
88 my @regions :shared; | 98 my @regions :shared; |
89 | 99 |
90 # build region tags to pass to nanopolish | 100 # build region tags to pass to nanopolish |
91 my $parser = BioX::Seq::Stream->new($fn_genome); | 101 my $parser = BioX::Seq::Stream->new($fn_genome); |
94 join( '-', 1, length($seq) ), | 104 join( '-', 1, length($seq) ), |
95 ); | 105 ); |
96 } | 106 } |
97 | 107 |
98 my @workers; | 108 my @workers; |
99 for (1..$threads) { | 109 for (1..$n_workers) { |
100 push @workers, threads->create(\&run); | 110 push @workers, threads->create(\&run); |
101 } | 111 } |
102 | 112 |
103 $_->join() for (@workers); | 113 $_->join() for (@workers); |
104 | 114 |