Mercurial > repos > jdv > nanopolish
comparison nanopolish_variants.pl @ 3:a1d433401bc2 draft
planemo upload for repository https://github.com/jvolkening/galaxy-tools/tree/master/tools/nanopolish commit e9238df905c413aaab086ea146cb1b97e3ffa0fd
author | jdv |
---|---|
date | Sat, 14 Oct 2017 00:05:43 -0400 |
parents | 2136c2725fc4 |
children | bdd6c1ab07c5 |
comparison
equal
deleted
inserted
replaced
2:e4b6d4a53f2e | 3:a1d433401bc2 |
---|---|
15 my $fn_genome; | 15 my $fn_genome; |
16 my $threads = 1; | 16 my $threads = 1; |
17 my $fn_outfile; | 17 my $fn_outfile; |
18 my $fn_consensus; | 18 my $fn_consensus; |
19 my $fn_fast5; | 19 my $fn_fast5; |
20 my $fn_reads; | |
20 | 21 |
21 # remember full command string (with proper binary) | 22 # remember full command string (with proper binary) |
22 | 23 |
23 # parse genome filename and add back to arg stack | 24 # parse genome filename and add back to arg stack |
24 GetOptions( | 25 GetOptions( |
25 'genome=s' => \$fn_genome, | 26 'genome=s' => \$fn_genome, |
26 'threads=i' => \$threads, | 27 'threads=i' => \$threads, |
27 'outfile=s' => \$fn_outfile, | 28 'outfile=s' => \$fn_outfile, |
28 'consensus=s' => \$fn_consensus, | 29 'consensus=s' => \$fn_consensus, |
29 'fast5=s' => \$fn_fast5, | 30 'fast5=s' => \$fn_fast5, |
31 'reads=s' => \$fn_reads, | |
30 ); | 32 ); |
31 | 33 |
32 my $tmp_dir = 'tmp_dir'; | 34 my $tmp_dir = 'tmp_dir'; |
33 mkdir $tmp_dir; | 35 mkdir $tmp_dir; |
34 | 36 |
35 #extract FAST5 files to path where they are expected | 37 $fn_fast5 = abs_path($fn_fast5); |
36 my $in_dir = 'in_dir'; | 38 |
37 mkdir $in_dir; | 39 # extract FAST5 files to path where they are expected |
40 my $fast5_dir = 'fast5'; | |
41 mkdir $fast5_dir; | |
38 my $cwd = abs_path( getcwd() ); | 42 my $cwd = abs_path( getcwd() ); |
39 chdir $in_dir; | 43 chdir $fast5_dir; |
40 my $tar = Archive::Tar->new(); | 44 my $tar = Archive::Tar->new(); |
41 $tar->read($fn_fast5); | 45 $tar->read($fn_fast5); |
42 $tar->extract(); | 46 $tar->extract(); |
47 say "done extracting $fn_fast5 here"; | |
43 chdir $cwd; | 48 chdir $cwd; |
49 | |
50 | |
51 # index reads | |
52 my $ret = system( | |
53 'nanopolish', | |
54 'index', | |
55 '--directory' => $fast5_dir, | |
56 $fn_reads, | |
57 ); | |
58 die "Failed nanopolish indexing: $!\n" | |
59 if ($ret); | |
44 | 60 |
45 my @cmd = @ARGV; | 61 my @cmd = @ARGV; |
46 unshift @cmd, 'nanopolish'; | 62 unshift @cmd, 'nanopolish'; |
47 push @cmd, '--genome', $fn_genome; | 63 push @cmd, '--genome', $fn_genome; |
48 | 64 push @cmd, '--reads', $fn_reads; |
49 say join ' ', @cmd; | |
50 | 65 |
51 my @regions :shared; | 66 my @regions :shared; |
52 | 67 |
53 # build region tags to pass to nanopolish | 68 # build region tags to pass to nanopolish |
54 my $parser = BioX::Seq::Stream->new($fn_genome); | 69 my $parser = BioX::Seq::Stream->new($fn_genome); |
114 push @cmd_local, '--window', $tag; | 129 push @cmd_local, '--window', $tag; |
115 push @cmd_local, '--outfile', $fn_out; | 130 push @cmd_local, '--outfile', $fn_out; |
116 push @cmd_local, '--consensus', $fn_cons; | 131 push @cmd_local, '--consensus', $fn_cons; |
117 | 132 |
118 my $ret = system @cmd_local; | 133 my $ret = system @cmd_local; |
119 warn "RET: $ret ($!)\n"; | |
120 | 134 |
121 my $cmd_string = join ' ', @cmd_local; | 135 my $cmd_string = join ' ', @cmd_local; |
122 die "Non-zero exit value for command: $cmd_string\n" | 136 die "Non-zero exit value for command: $cmd_string\n" |
123 if ($ret); | 137 if ($ret); |
124 | 138 |