annotate find_peaks @ 9:8fd3191302d0 draft

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 5bf4f4dbd82988d1612d951d69125bc5f5b439be
author mvdbeek
date Wed, 13 Jun 2018 12:41:00 -0400
parents be830200e987
children 7b0ca503bb95
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
1 #!/usr/bin/perl -w
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
2
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
3 # Copyright © 2012-2015, Owen Marshall
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
4
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
5 # This program is free software; you can redistribute it and/or modify
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
6 # it under the terms of the GNU General Public License as published by
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
7 # the Free Software Foundation; either version 2 of the License, or (at
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
8 # your option) any later version.
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
9 #
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
10 # This program is distributed in the hope that it will be useful, but
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
11 # WITHOUT ANY WARRANTY; without even the implied warranty of
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
12 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
13 # General Public License for more details.
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
14 #
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
15 # You should have received a copy of the GNU General Public License
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
16 # along with this program; if not, write to the Free Software
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
17 # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
18 # USA
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
19
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
20 use strict;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
21 use File::Basename;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
22 use 5.010;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
23 $|++;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
24
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
25 my $version = "1.0.1";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
26
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
27 print STDERR "\nfind_peaks v$version\nCopyright © 2012-15, Owen Marshall\n\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
28
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
29 my %vars = (
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
30 'fdr' => 0.01,
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
31 'min_count' => 2,
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
32 'n' => 100,
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
33 'frac' => 0,
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
34 'min_quant' => 0.95,
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
35 'step' => 0.01,
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
36 'unified_peaks' => 'max',
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
37 );
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
38
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
39 my %vars_details = (
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
40 'fdr' => 'False discovery rate value',
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
41 'min_count' => 'Minimum number of fragments to consider as a peak',
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
42 'n' => 'Number of iterations',
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
43 'frac' => 'Number of random fragments to consider per iteration',
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
44 'min_quant' => 'Minimum quantile for considering peaks',
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
45 'step' => 'Stepping for quantiles',
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
46 'unified_peaks' => "Method for calling peak overlaps (two options):\n\r'min': call minimum overlapping peak area\n\r'max': call maximum overlap as peak",
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
47 );
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
48
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
49
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
50 my @in_files;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
51 process_cli();
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
52
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
53 # Time and date
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
54 my ($sec,$min,$hour,$mday,$mon,$year) = localtime();
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
55 my $date = sprintf("%04d-%02d-%02d.%02d-%02d-%02d",$year+1900,$mon+1,$mday,$hour,$min,$sec);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
56
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
57 help() unless @in_files;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
58
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
59 foreach my $fn (@in_files) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
60 my @in;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
61 my @unified_peaks;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
62 my @sig_peaks;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
63 my @peakmins;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
64
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
65 my %peaks;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
66 my %peak_count;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
67 my %peak_count_real;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
68 my %log_scores;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
69 my %regression;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
70 my %peak_fdr_cutoff;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
71 my %fdr;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
72
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
73 # Output file names
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
74 my ($name,$dir,$ext) = fileparse($fn, qr/\.[^.]*/);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
75
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
76 # filenames
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
77 my $fn_base_date = "peak_analysis.".$name.".$date";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
78 my $base_dir = "$fn_base_date/";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
79 my $out = "$base_dir"."$name-FDR$vars{'fdr'}";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
80 my $out_peak_unified_track = $out.".peaks.gff";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
81 my $out_peaks = $out."_FDR-data";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
82
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
83 # Load gff data files
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
84 load_gff(FILE=>$fn, IN_REF=>\@in);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
85
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
86 my $probes = @in;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
87
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
88 find_quants(IN_REF=>\@in, PEAKMINS_REF=>\@peakmins);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
89 find_randomised_peaks(IN_REF=>\@in, PEAKMINS_REF=>\@peakmins, PEAK_COUNT=>\%peak_count, PEAKS=>\%peaks);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
90
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
91 # Make directory
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
92 mkdir($base_dir);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
93
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
94 # Open peaks file for writing
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
95 open(OUTP, ">$out_peaks")|| die "Cannot open peak file for writing: $!\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
96 print OUTP "FDR peak call v$version\n\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
97 print OUTP "Input file: $fn\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
98
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
99 calculate_regressions(IN_REF=>\@in, PEAKMINS_REF=>\@peakmins, PEAK_COUNT=>\%peak_count, PEAKS=>\%peaks, LOG_SCORES=>\%log_scores, REGRESSION=>\%regression);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
100
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
101 call_peaks_unified_redux(ITER=>1, REAL=>1, AREF=>\@in, PEAKMINS_REF=>\@peakmins, PEAK_COUNT=>\%peak_count, PEAK_COUNT_REAL=>\%peak_count_real, PEAKS=>\%peaks);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
102
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
103 calculate_fdr(IN_REF=>\@in, PEAKMINS_REF=>\@peakmins, PEAK_COUNT=>\%peak_count, PEAK_COUNT_REAL=>\%peak_count_real, PEAK_FDR_CUTOFF=>\%peak_fdr_cutoff, FDR=>\%fdr, LOG_SCORES=>\%log_scores, REGRESSION=>\%regression);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
104
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
105 find_significant_peaks(PEAKMINS=>\@peakmins, SIG_PEAKS=>\@sig_peaks, PEAKS=>\%peaks, PEAK_FDR_CUTOFF=>\%peak_fdr_cutoff, FDR=>\%fdr);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
106
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
107 make_unified_peaks(SIG_PEAKS=>\@sig_peaks, UNIFIED_PEAKS=>\@unified_peaks, OUT=>$out_peak_unified_track, TYPE=>$vars{'unified_peaks'});
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
108
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
109 print STDERR "$#unified_peaks peaks found.\n\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
110
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
111 close OUTP;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
112 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
113
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
114 print STDERR "All done.\n\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
115 exit 0;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
116
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
117
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
118 ######################
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
119 # Subroutines start here
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
120 #
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
121
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
122 sub find_significant_peaks {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
123 my (%opts) = @_;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
124
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
125 my $peakmins = $opts{PEAKMINS};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
126 my $peaks = $opts{PEAKS};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
127 my $sig_peaks = $opts{SIG_PEAKS};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
128 my $fdr = $opts{FDR};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
129 my $peak_fdr_cutoff = $opts{PEAK_FDR_CUTOFF};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
130
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
131 # Generate significant peaks and unify peaks
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
132 print STDERR "Selecting significant peaks ... \n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
133
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
134 foreach my $pm (@$peakmins) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
135 for my $i (0 .. $#{$$peaks{$pm}}) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
136 my ($chr, $pstart, $pend, $mean_pscore, $pscore, $count, $size) = @{ $$peaks{$pm}[$i] };
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
137 if ($count >= $$peak_fdr_cutoff{$pm}) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
138 push (@$sig_peaks, [ @{$$peaks{$pm}[$i]}, $$fdr{$pm}[$count] ]);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
139 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
140 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
141 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
142
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
143 print OUTP "\nNumber of peaks: $#$sig_peaks\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
144 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
145
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
146 sub calculate_fdr {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
147 my (%opts) = @_;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
148 my $in_ref = $opts{IN_REF};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
149 my $peakmins = $opts{PEAKMINS_REF};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
150 my $peak_count = $opts{PEAK_COUNT};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
151 my $log_scores = $opts{LOG_SCORES};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
152 my $regression = $opts{REGRESSION};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
153 my $fdr = $opts{FDR};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
154 my $peak_fdr_cutoff = $opts{PEAK_FDR_CUTOFF};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
155 my $peak_count_real = $opts{PEAK_COUNT_REAL};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
156
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
157 foreach my $pm (@$peakmins) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
158 # get regression variables
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
159 my ($m,$b) = @{$$regression{$pm}} if $$regression{$pm}[0];
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
160
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
161 for my $i (0 .. $#{$$peak_count_real{$pm}}) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
162 next unless $$peak_count_real{$pm}[$i];
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
163 my $expect = 10**($m*$i + $b);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
164
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
165 my $real_count = $$peak_count_real{$pm}[$i];
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
166 my $fdr_conservative = $expect/$real_count;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
167 $$fdr{$pm}[$i]= $fdr_conservative;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
168 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
169 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
170
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
171 # print FDR rates
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
172 print OUTP "\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
173
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
174 foreach my $pm (@$peakmins) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
175 print OUTP "Peak min = $pm\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
176 for my $c (0 .. $#{$$fdr{$pm}}) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
177 next unless defined($$fdr{$pm}[$c]);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
178 print OUTP "Peak size: $c\tCount: $$peak_count_real{$pm}[$c]\tFDR: $$fdr{$pm}[$c]\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
179 $$peak_fdr_cutoff{$pm} = $c if (($$fdr{$pm}[$c]<$vars{'fdr'}) && (!$$peak_fdr_cutoff{$pm}));
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
180 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
181 $$peak_fdr_cutoff{$pm}||= 10**10; # clumsy hack to prevent errors
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
182 print OUTP "\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
183 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
184
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
185 foreach my $pm (@$peakmins) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
186 print OUTP "Peak min $pm: peak cutoff size for alpha = $vars{'fdr'} was $$peak_fdr_cutoff{$pm}\n\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
187 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
188 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
189
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
190 sub calculate_regressions {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
191 my (%opts) = @_;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
192 my $in_ref = $opts{IN_REF};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
193 my $peakmins = $opts{PEAKMINS_REF};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
194 my $peaks = $opts{PEAKS};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
195 my $peak_count = $opts{PEAK_COUNT};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
196 my $log_scores = $opts{LOG_SCORES};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
197 my $regression = $opts{REGRESSION};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
198
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
199 my $in_num = @$in_ref;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
200
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
201 foreach my $pm (@$peakmins) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
202 print OUTP "Peak min = $pm\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
203 for my $c (0 .. $#{$$peak_count{$pm}}) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
204 my $peak_count_avg = $$peak_count{$pm}[$c]/$vars{'n'} if $$peak_count{$pm}[$c];
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
205 next unless $peak_count_avg;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
206
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
207 if ($vars{'frac'}) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
208 $peak_count_avg = $peak_count_avg * $in_num/$vars{'frac'};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
209 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
210 $$log_scores{$pm}[$c] = log($peak_count_avg)/log(10);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
211 print OUTP "Peak size: $c\tCount:$peak_count_avg\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
212 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
213
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
214 # calculate exponential decay rates
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
215 # y= a+bx for log(y)
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
216 my ($sumx, $sumy, $sumxsq, $sumxy);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
217 my $n=0;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
218 for my $i (0 .. $#{$$peak_count{$pm}}) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
219 next unless $$peak_count{$pm}[$i];
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
220 $n++;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
221 $sumx += $i;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
222 $sumy += $$log_scores{$pm}[$i];
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
223 $sumxsq += $i ** 2;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
224 $sumxy += $i * $$log_scores{$pm}[$i];
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
225 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
226
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
227 next unless $n > 1;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
228
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
229 my $mean_x = $sumx/$n;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
230 my $mean_y = $sumy/$n;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
231 my $mean_xsq = $sumxsq/$n;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
232 my $mean_xy = $sumxy/$n;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
233
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
234 my $b = ($mean_xy - ($mean_x * $mean_y)) / ($mean_xsq - ($mean_x **2));
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
235 my $a = $mean_y - ($b * $mean_x);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
236
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
237 # store values
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
238 $$regression{$pm}=[$b, $a];
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
239 print OUTP "regression: log(y) = $b(x) + $a\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
240
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
241 for my $i (0 .. $#{$$peak_count{$pm}}) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
242 next unless $$peak_count{$pm}[$i];
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
243 my ($b,$a) = @{$$regression{$pm}};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
244 my $logval = ($b*$i + $a);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
245 my $val = 10**$logval;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
246 print OUTP "lin regress: $i\t$$log_scores{$pm}[$i]\t$logval\t$val\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
247 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
248
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
249 print OUTP "\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
250 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
251 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
252
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
253 sub find_randomised_peaks {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
254 my (%opts) = @_;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
255 my $in_ref = $opts{IN_REF};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
256 my $peakmins_ref = $opts{PEAKMINS_REF};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
257 my $peaks = $opts{PEAKS};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
258 my $peak_count = $opts{PEAK_COUNT};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
259
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
260 print STDERR "Duplicating ... \n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
261 my @inr = @$in_ref;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
262
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
263 # Call peaks on input file
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
264 print STDERR "Calling peaks on input file ...\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
265
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
266 for my $iter (1 .. $vars{'n'}) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
267 #print STDERR "Iteration $iter ... \r";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
268 print STDERR "Iteration $iter: [shuffling] \r";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
269
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
270 if ($vars{'frac'}) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
271 # only use a fraction of the array per rep
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
272 my @a = inside_out(\@inr, $vars{'frac'});
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
273 call_peaks_unified_redux(ITER=>$iter, AREF=>\@a, PEAKMINS_REF=>$peakmins_ref, PEAK_COUNT=>$peak_count);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
274 } else {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
275 shuffle(\@inr);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
276 call_peaks_unified_redux(ITER=>$iter, AREF=>\@inr, PEAKMINS_REF=>$peakmins_ref, PEAK_COUNT=>$peak_count);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
277 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
278 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
279
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
280 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
281
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
282 sub call_peaks_unified_redux {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
283 my (%opts) = @_;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
284 my $iter = $opts{ITER};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
285 my $real = $opts{REAL};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
286 my $a = $opts{AREF};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
287 my $peakmins_ref = $opts{PEAKMINS_REF};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
288 my $peak_count_real = $opts{PEAK_COUNT_REAL};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
289 my $peaks = $opts{PEAKS};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
290 my $peak_count = $opts{PEAK_COUNT};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
291
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
292 my ($pstart, $pend, $inpeak, $pscore, $count);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
293 $pstart=$pend=$pscore=$inpeak=$count=0;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
294
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
295 my @tmp_peak;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
296 my $total = $#$a;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
297
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
298 if ($real) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
299 print STDERR "Calling real peaks ... \r";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
300 } else {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
301 print STDERR "Iteration $iter: [processing ...] \r";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
302 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
303
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
304 my $old_chr="";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
305 foreach my $pm (@$peakmins_ref) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
306 for my $i (0 .. $total) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
307 my ($chr, $start, $end, $score) = @{ @$a[$i] };
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
308 next unless $score;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
309
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
310 if ($real) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
311 unless ($chr eq $old_chr) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
312 # Next chromosome
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
313 # (Peaks can't carry over chromosomes, but we don't use this shortcut when randomly shuffling)
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
314 $pstart=$pend=$pscore=$inpeak=$count=0;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
315 @tmp_peak = () if $real;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
316 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
317 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
318 $old_chr = $chr if $real;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
319
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
320 unless ($inpeak) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
321 next unless $score >= $pm;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
322 # record new peak
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
323 $pstart = $start;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
324 $pend = $end;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
325 $pscore = $score * ($end-$start)/1000;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
326 $count++;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
327 push @tmp_peak, $score if $real;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
328 $inpeak = 1;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
329 } else {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
330 if ($score >= $pm) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
331 # still in peak
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
332 $count++;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
333
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
334 # Fragment score to deal with scoring peaks made from uneven sized fragments
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
335 my $fragment_score = $score * ($end-$start)/1000;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
336
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
337 push @tmp_peak, $score if $real;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
338 $pscore += $fragment_score;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
339 $pend = $end;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
340 } else {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
341 # out of a peak
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
342 if ($count >= $vars{'min_count'}) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
343 # record peak
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
344 if ($real) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
345 $$peak_count_real{$pm}[$count]++;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
346 my $mean_pscore = sprintf('%0.2f',($pscore/(($pend-$pstart)/1000)));
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
347 push (@{$$peaks{$pm}},[($chr, $pstart, $pend, $mean_pscore, $pscore, $count, ($pend-$pstart))]);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
348 } else {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
349 $$peak_count{$pm}[$count]++;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
350 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
351 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
352
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
353 # reset
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
354 $pstart=$pend=$pscore=$inpeak=$count=0;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
355 @tmp_peak = () if $real;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
356 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
357 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
358 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
359 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
360 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
361
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
362
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
363 sub shuffle {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
364 # Fisher-Yates shuffle (Knuth shuffle)
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
365 my ($array) = @_;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
366 my $i = @$array;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
367 while ( --$i ) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
368 my $j = int rand( $i+1 );
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
369 @$array[$i,$j] = @$array[$j,$i];
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
370 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
371 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
372
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
373 sub inside_out {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
374 my ($array, $frac) = @_;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
375 my @a;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
376 for my $i (0 .. $frac-1) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
377 my $j = int rand( $i+1 );
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
378 if ($j != $i) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
379 $a[$i] = $a[$j]
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
380 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
381 $a[$j] = @$array[$i]
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
382 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
383 return @a;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
384 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
385
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
386 sub load_gff {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
387 my (%opts) = @_;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
388 my $fn = $opts{FILE};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
389 my $in_ref = $opts{IN_REF};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
390
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
391 print STDERR "Reading input file: $fn ...\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
392 open (IN, "<$fn") || die "Unable to read $fn: $!\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
393
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
394 my $i;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
395 while (<IN>) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
396 $i++;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
397 print STDERR "Read $i lines ...\r" if $i%10000 == 0;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
398 chomp;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
399
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
400 my @line = split('\t');
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
401
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
402 my ($chr, $start, $end, $score);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
403 if ($#line == 3) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
404 # bedgraph
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
405 ($chr, $start, $end, $score) = @line;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
406 } else {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
407 # GFF
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
408 ($chr, $start, $end, $score) = @line[0,3,4,5];
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
409 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
410
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
411 next unless $start;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
412
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
413 $score = 0 if $score eq "NA";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
414
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
415 push (@$in_ref, [$chr, $start, $end, $score]);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
416 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
417
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
418 close (IN);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
419
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
420 print STDERR "Sorting ... \n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
421 @$in_ref = sort { $a->[1] <=> $b->[1] } @$in_ref;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
422 @$in_ref = sort { $a->[0] cmp $b->[0] } @$in_ref;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
423 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
424
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
425 sub find_quants {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
426 my (%opts) = @_;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
427
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
428 my $in_ref = $opts{IN_REF};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
429 my $peakmins_ref = $opts{PEAKMINS_REF};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
430
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
431 my %seg;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
432 my @frags;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
433
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
434 my $total_coverage;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
435
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
436 foreach my $l (@$in_ref) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
437 my ($chr, $start, $end, $score) = @$l;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
438 next unless $score;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
439 $score = 0 if $score eq "NA";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
440 $total_coverage += $end-$start;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
441 push @frags, $score;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
442 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
443
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
444 @frags = sort {$a <=> $b} @frags;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
445
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
446 print STDERR "Total coverage was $total_coverage bp\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
447
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
448 my @quants;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
449 for (my $q=0;$q<=1;$q+=$vars{'step'}) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
450 push @quants, [$q, int($q * @frags)] if $q > $vars{'min_quant'};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
451 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
452
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
453 foreach (@quants) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
454 my $cut_off = @{$_}[0];
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
455 my $score = $frags[@{$_}[1]];
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
456 printf(" Quantile %0.2f: %0.2f\n",$cut_off,$score);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
457 $seg{$cut_off} = $score;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
458 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
459
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
460 foreach my $c (sort {$a <=> $b} keys %seg) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
461 push (@$peakmins_ref, $seg{$c});
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
462 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
463 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
464
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
465 sub make_unified_peaks {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
466 my (%opts) = @_;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
467 my $ref = $opts{SIG_PEAKS};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
468 my $out_peak_unified_track = $opts{OUT};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
469 my $unified_peaks = $opts{UNIFIED_PEAKS};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
470 my $type = $opts{TYPE};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
471 my $total = @$ref;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
472
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
473 # Unify overlapping peaks, and make significant peaks file
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
474 my $skipped_peaks;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
475 print STDERR "Combining significant peaks ...\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
476
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
477 # unroll chromosomes for speed
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
478 foreach my $chr (uniq( map @{$_}[0], @$ref )) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
479 my @c = grep {@{$_}[0] eq $chr} @$ref;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
480
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
481 my @unified_peaks_chr;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
482 foreach my $ar (@c) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
483 if (state $i++ % 100 == 0) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
484 my $pc = sprintf("%0.2f",($i*100)/$total);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
485 print STDERR "$pc\% processed ...\r";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
486 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
487
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
488 my ($chra, $start, $end, $score, $total_score, $count, $peaklen, $fdr) = @$ar;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
489
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
490 # next if @unified_peaks_chr already overlaps
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
491 next if grep {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
492 @{$_}[3] < $end
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
493 && @{$_}[4] > $start
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
494 } @unified_peaks_chr;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
495
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
496 # Grab all elements that overlap
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
497 my @test = grep {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
498 @{$_}[1] < $end
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
499 && @{$_}[2] > $start
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
500 } @c;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
501
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
502 for my $j (0 .. $#test) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
503 my ($chr1, $start1, $end1, $score1, $total_score1, $count1, $peaklen1, $fdr1) = @{$test[$j]};
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
504
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
505 next unless $start1 < $end;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
506 next unless $end1 > $start;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
507
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
508 if ($type eq 'min') {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
509 $start = max($start, $start1);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
510 $end = min($end, $end1);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
511 } else {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
512 $start = min($start, $start1);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
513 $end = max($end, $end1);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
514 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
515
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
516 $score = max($score, $score1);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
517 $fdr = min($fdr, $fdr1);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
518 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
519
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
520 push @unified_peaks_chr, [($chr, '.', '.', $start, $end, $score, '.', '.', "FDR=$fdr")];
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
521 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
522
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
523 @$unified_peaks = (@$unified_peaks, @unified_peaks_chr);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
524 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
525
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
526 $total = $#$unified_peaks;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
527
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
528 print STDERR "Sorting unified peaks ...\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
529 @$unified_peaks = sort { $a->[3] <=> $b->[3] } @$unified_peaks;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
530 @$unified_peaks = sort { $a->[0] cmp $b->[0] } @$unified_peaks;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
531
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
532 print STDERR "Writing unified peaks file ...\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
533 open(PEAKOUTUNI, ">$out_peak_unified_track") || die "Unable to open peak output track for writing: $!\n\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
534 for my $j (0 .. $#$unified_peaks) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
535 print PEAKOUTUNI join("\t", @{$$unified_peaks[$j]}), "\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
536 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
537 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
538
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
539 sub max {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
540 my ($max, @vars) = @_;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
541 my $index=0;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
542 $max||=0;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
543 for my $i (0..$#vars) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
544 ($max, $index) = ($vars[$i], $i+1) if $vars[$i] > $max;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
545 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
546 return $max;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
547 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
548
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
549 sub min {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
550 my ($min, @vars) = @_;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
551 my $index=0;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
552 $min||=0;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
553 for my $i (0..$#vars) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
554 ($min, $index) = ($vars[$i],$i+1) if $vars[$i] < $min;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
555 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
556 return $min;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
557 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
558
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
559 sub uniq {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
560 my %seen;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
561 return grep { !$seen{$_}++ } @_;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
562 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
563
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
564
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
565
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
566 sub process_cli {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
567 foreach (@ARGV) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
568 if (/--(.*)=(.*)/) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
569 unless (defined($vars{$1})) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
570 print STDERR "Did not understand $_ ...\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
571 help();
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
572 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
573 my ($v, $opt) = ($1,$2);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
574 $vars{$v} = $opt;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
575 next;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
576 } elsif (/--h[elp]*/) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
577 help();
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
578 } elsif (/--(.*)/) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
579 print STDERR "Please add a parameter to $_ ...\n\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
580 exit 1;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
581 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
582 push @in_files, $_;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
583 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
584 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
585
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
586
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
587 sub help {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
588 print STDOUT <<EOT;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
589 Simple FDR random permutation peak caller
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
590 Usage: [options] [files in bedgraph or GFF format]
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
591
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
592 Options:
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
593 EOT
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
594
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
595 my $opt_len = 0;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
596 foreach (keys %vars) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
597 my $l = length($_);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
598 $opt_len = $l if $l > $opt_len;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
599 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
600
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
601 $opt_len+=2;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
602
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
603 my $cols= `tput cols` || 80;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
604
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
605 my ($v, $val, $def, $def_format);
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
606 my $help_format = "format STDOUT =\n"
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
607 .' '.'^'.'<'x$opt_len . ' '. '^' . '<'x($cols-$opt_len-4) . "\n"
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
608 .'$v, $def_format'."\n"
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
609 .' '.'^'.'<'x$opt_len . ' '. '^' . '<'x($cols-$opt_len-6) . "~~\n"
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
610 .'$v, $def_format'."\n"
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
611 .".\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
612
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
613 eval $help_format;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
614 die $@ if $@;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
615
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
616 foreach my $k (sort (keys %vars)) {
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
617 ($v, $val, $def) = ($k, $vars{$k}, $vars_details{$k});
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
618 $def||="";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
619 $def_format = $val ? "$def\n\r[Current value: $val]" : $def;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
620 $v = "--$v";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
621 # format =
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
622 # ^<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
623 #$v, $def_format
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
624 # ^<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
625 #$v, $def_format
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
626 #.
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
627
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
628 write();
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
629
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
630 }
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
631 print STDOUT "\n";
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
632 exit 1;
be830200e987 planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
633 }