annotate find_peaks @ 0:f3f7d52a9b1f draft default tip

planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
author mvdbeek
date Fri, 20 Apr 2018 04:33:06 -0400
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
f3f7d52a9b1f 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
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
2
f3f7d52a9b1f 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
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
4
f3f7d52a9b1f 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
f3f7d52a9b1f 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
f3f7d52a9b1f 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
f3f7d52a9b1f 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.
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
9 #
f3f7d52a9b1f 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
f3f7d52a9b1f 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
f3f7d52a9b1f 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
f3f7d52a9b1f 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.
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
14 #
f3f7d52a9b1f 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
f3f7d52a9b1f 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
f3f7d52a9b1f 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
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
18 # USA
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
19
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
20 use strict;
f3f7d52a9b1f 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;
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
23 $|++;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
24
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
26
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
28
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
29 my %vars = (
f3f7d52a9b1f 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,
f3f7d52a9b1f 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,
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
32 'n' => 100,
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
33 'frac' => 0,
f3f7d52a9b1f 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,
f3f7d52a9b1f 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,
f3f7d52a9b1f 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',
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
37 );
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
38
f3f7d52a9b1f 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 = (
f3f7d52a9b1f 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',
f3f7d52a9b1f 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',
f3f7d52a9b1f 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',
f3f7d52a9b1f 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',
f3f7d52a9b1f 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',
f3f7d52a9b1f 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',
f3f7d52a9b1f 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",
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
47 );
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
48
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
49
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
51 process_cli();
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
52
f3f7d52a9b1f 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
f3f7d52a9b1f 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();
f3f7d52a9b1f 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);
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
56
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
58
f3f7d52a9b1f 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) {
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
60 my @in;
f3f7d52a9b1f 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;
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
63 my @peakmins;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
64
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
65 my %peaks;
f3f7d52a9b1f 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;
f3f7d52a9b1f 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;
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
69 my %regression;
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
71 my %fdr;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
72
f3f7d52a9b1f 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
f3f7d52a9b1f 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/\.[^.]*/);
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
75
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
76 # filenames
f3f7d52a9b1f 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";
f3f7d52a9b1f 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/";
f3f7d52a9b1f 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'}";
f3f7d52a9b1f 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";
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
82
f3f7d52a9b1f 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
f3f7d52a9b1f 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);
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
85
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
87
f3f7d52a9b1f 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);
f3f7d52a9b1f 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);
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
90
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
91 # Make directory
f3f7d52a9b1f 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);
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
93
f3f7d52a9b1f 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
f3f7d52a9b1f 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";
f3f7d52a9b1f 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";
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
98
f3f7d52a9b1f 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);
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
100
f3f7d52a9b1f 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);
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
102
f3f7d52a9b1f 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);
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
104
f3f7d52a9b1f 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);
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
106
f3f7d52a9b1f 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'});
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
108
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
110
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
111 close OUTP;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
112 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
113
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
115 exit 0;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
116
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
117
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
118 ######################
f3f7d52a9b1f 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
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
120 #
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
121
f3f7d52a9b1f 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 {
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
123 my (%opts) = @_;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
124
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
130
f3f7d52a9b1f 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
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
133
f3f7d52a9b1f 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) {
f3f7d52a9b1f 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}}) {
f3f7d52a9b1f 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] };
f3f7d52a9b1f 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}) {
f3f7d52a9b1f 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] ]);
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
139 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
140 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
141 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
142
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
144 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
145
f3f7d52a9b1f 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 {
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
147 my (%opts) = @_;
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
156
f3f7d52a9b1f 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) {
f3f7d52a9b1f 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
f3f7d52a9b1f 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];
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
160
f3f7d52a9b1f 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}}) {
f3f7d52a9b1f 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];
f3f7d52a9b1f 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);
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
164
f3f7d52a9b1f 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];
f3f7d52a9b1f 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;
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
168 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
169 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
170
f3f7d52a9b1f 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
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
173
f3f7d52a9b1f 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) {
f3f7d52a9b1f 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";
f3f7d52a9b1f 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}}) {
f3f7d52a9b1f 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]);
f3f7d52a9b1f 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";
f3f7d52a9b1f 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}));
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
180 }
f3f7d52a9b1f 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
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
183 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
184
f3f7d52a9b1f 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) {
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
187 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
188 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
189
f3f7d52a9b1f 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 {
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
191 my (%opts) = @_;
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
198
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
200
f3f7d52a9b1f 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) {
f3f7d52a9b1f 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";
f3f7d52a9b1f 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}}) {
f3f7d52a9b1f 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];
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
206
f3f7d52a9b1f 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'}) {
f3f7d52a9b1f 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'};
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
209 }
f3f7d52a9b1f 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);
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
212 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
213
f3f7d52a9b1f 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
f3f7d52a9b1f 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)
f3f7d52a9b1f 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);
f3f7d52a9b1f 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;
f3f7d52a9b1f 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}}) {
f3f7d52a9b1f 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];
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
220 $n++;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
221 $sumx += $i;
f3f7d52a9b1f 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];
f3f7d52a9b1f 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;
f3f7d52a9b1f 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];
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
225 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
226
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
228
f3f7d52a9b1f 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;
f3f7d52a9b1f 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;
f3f7d52a9b1f 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;
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
233
f3f7d52a9b1f 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));
f3f7d52a9b1f 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);
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
236
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
237 # store values
f3f7d52a9b1f 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];
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
240
f3f7d52a9b1f 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}}) {
f3f7d52a9b1f 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];
f3f7d52a9b1f 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}};
f3f7d52a9b1f 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);
f3f7d52a9b1f 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;
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
247 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
248
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
250 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
251 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
252
f3f7d52a9b1f 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 {
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
254 my (%opts) = @_;
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
259
f3f7d52a9b1f 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";
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
262
f3f7d52a9b1f 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
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
265
f3f7d52a9b1f 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'}) {
f3f7d52a9b1f 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";
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
269
f3f7d52a9b1f 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'}) {
f3f7d52a9b1f 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
f3f7d52a9b1f 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'});
f3f7d52a9b1f 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);
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
274 } else {
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
275 shuffle(\@inr);
f3f7d52a9b1f 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);
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
277 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
278 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
279
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
280 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
281
f3f7d52a9b1f 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 {
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
283 my (%opts) = @_;
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
291
f3f7d52a9b1f 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);
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
294
f3f7d52a9b1f 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;
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
297
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
298 if ($real) {
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
300 } else {
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
302 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
303
f3f7d52a9b1f 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="";
f3f7d52a9b1f 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) {
f3f7d52a9b1f 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) {
f3f7d52a9b1f 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] };
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
309
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
310 if ($real) {
f3f7d52a9b1f 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) {
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
312 # Next chromosome
f3f7d52a9b1f 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)
f3f7d52a9b1f 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;
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
316 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
317 }
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
319
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
320 unless ($inpeak) {
f3f7d52a9b1f 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;
f3f7d52a9b1f 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
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
323 $pstart = $start;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
324 $pend = $end;
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
326 $count++;
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
328 $inpeak = 1;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
329 } else {
f3f7d52a9b1f 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) {
f3f7d52a9b1f 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
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
332 $count++;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
333
f3f7d52a9b1f 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
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
336
f3f7d52a9b1f 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;
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
339 $pend = $end;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
340 } else {
f3f7d52a9b1f 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
f3f7d52a9b1f 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'}) {
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
343 # record peak
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
344 if ($real) {
f3f7d52a9b1f 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]++;
f3f7d52a9b1f 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)));
f3f7d52a9b1f 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))]);
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
348 } else {
f3f7d52a9b1f 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]++;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
350 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
351 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
352
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
353 # reset
f3f7d52a9b1f 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;
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
356 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
357 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
358 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
359 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
360 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
361
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
362
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
363 sub shuffle {
f3f7d52a9b1f 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)
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
365 my ($array) = @_;
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
367 while ( --$i ) {
f3f7d52a9b1f 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 );
f3f7d52a9b1f 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];
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
370 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
371 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
372
f3f7d52a9b1f 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 {
f3f7d52a9b1f 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) = @_;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
375 my @a;
f3f7d52a9b1f 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) {
f3f7d52a9b1f 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 );
f3f7d52a9b1f 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) {
f3f7d52a9b1f 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]
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
380 }
f3f7d52a9b1f 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]
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
382 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
383 return @a;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
384 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
385
f3f7d52a9b1f 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 {
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
387 my (%opts) = @_;
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
390
f3f7d52a9b1f 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";
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
393
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
394 my $i;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
395 while (<IN>) {
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
396 $i++;
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
398 chomp;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
399
f3f7d52a9b1f 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');
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
401
f3f7d52a9b1f 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);
f3f7d52a9b1f 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) {
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
404 # bedgraph
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
406 } else {
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
407 # GFF
f3f7d52a9b1f 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];
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
409 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
410
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
412
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
414
f3f7d52a9b1f 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]);
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
416 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
417
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
418 close (IN);
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
419
f3f7d52a9b1f 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";
f3f7d52a9b1f 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;
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
423 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
424
f3f7d52a9b1f 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 {
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
426 my (%opts) = @_;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
427
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
430
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
431 my %seg;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
432 my @frags;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
433
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
435
f3f7d52a9b1f 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) {
f3f7d52a9b1f 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;
f3f7d52a9b1f 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;
f3f7d52a9b1f 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";
f3f7d52a9b1f 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;
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
442 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
443
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
445
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
447
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
448 my @quants;
f3f7d52a9b1f 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'}) {
f3f7d52a9b1f 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'};
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
451 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
452
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
453 foreach (@quants) {
f3f7d52a9b1f 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];
f3f7d52a9b1f 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]];
f3f7d52a9b1f 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);
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
458 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
459
f3f7d52a9b1f 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) {
f3f7d52a9b1f 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});
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
462 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
463 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
464
f3f7d52a9b1f 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 {
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
466 my (%opts) = @_;
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f 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};
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
472
f3f7d52a9b1f 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
f3f7d52a9b1f 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;
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
476
f3f7d52a9b1f 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
f3f7d52a9b1f 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 )) {
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
480
f3f7d52a9b1f 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;
f3f7d52a9b1f 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) {
f3f7d52a9b1f 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) {
f3f7d52a9b1f 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);
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
486 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
487
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
489
f3f7d52a9b1f 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
f3f7d52a9b1f 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 {
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
492 @{$_}[3] < $end
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
493 && @{$_}[4] > $start
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
495
f3f7d52a9b1f 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
f3f7d52a9b1f 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 {
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
498 @{$_}[1] < $end
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
499 && @{$_}[2] > $start
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
500 } @c;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
501
f3f7d52a9b1f 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) {
f3f7d52a9b1f 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]};
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
504
f3f7d52a9b1f 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;
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
507
f3f7d52a9b1f 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') {
f3f7d52a9b1f 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);
f3f7d52a9b1f 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);
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
511 } else {
f3f7d52a9b1f 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);
f3f7d52a9b1f 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);
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
514 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
515
f3f7d52a9b1f 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);
f3f7d52a9b1f 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);
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
518 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
519
f3f7d52a9b1f 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")];
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
521 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
522
f3f7d52a9b1f 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);
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
524 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
525
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
527
f3f7d52a9b1f 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";
f3f7d52a9b1f 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;
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
531
f3f7d52a9b1f 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";
f3f7d52a9b1f 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";
f3f7d52a9b1f 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) {
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
536 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
537 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
538
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
539 sub max {
f3f7d52a9b1f 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) = @_;
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
542 $max||=0;
f3f7d52a9b1f 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) {
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
545 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
546 return $max;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
547 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
548
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
549 sub min {
f3f7d52a9b1f 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) = @_;
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
552 $min||=0;
f3f7d52a9b1f 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) {
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
555 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
556 return $min;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
557 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
558
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
559 sub uniq {
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
560 my %seen;
f3f7d52a9b1f 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{$_}++ } @_;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
562 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
563
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
564
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
565
f3f7d52a9b1f 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 {
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
567 foreach (@ARGV) {
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
568 if (/--(.*)=(.*)/) {
f3f7d52a9b1f 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})) {
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
571 help();
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
572 }
f3f7d52a9b1f 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);
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
575 next;
f3f7d52a9b1f 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]*/) {
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
577 help();
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
578 } elsif (/--(.*)/) {
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
580 exit 1;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
581 }
f3f7d52a9b1f 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, $_;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
583 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
584 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
585
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
586
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
587 sub help {
f3f7d52a9b1f 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;
f3f7d52a9b1f 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
f3f7d52a9b1f 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]
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
591
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
592 Options:
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
593 EOT
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
594
f3f7d52a9b1f 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;
f3f7d52a9b1f 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) {
f3f7d52a9b1f 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($_);
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
599 }
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
600
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
602
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
604
f3f7d52a9b1f 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);
f3f7d52a9b1f 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"
f3f7d52a9b1f 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"
f3f7d52a9b1f 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"
f3f7d52a9b1f 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"
f3f7d52a9b1f 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"
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
611 .".\n";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
612
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
614 die $@ if $@;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
615
f3f7d52a9b1f 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)) {
f3f7d52a9b1f 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});
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
618 $def||="";
f3f7d52a9b1f 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;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
620 $v = "--$v";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
621 # format =
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
622 # ^<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
f3f7d52a9b1f 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
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
624 # ^<<<<<<<<<<<<<<<<<<<< ^<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< ~~
f3f7d52a9b1f 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
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
626 #.
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
627
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
628 write();
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
629
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
630 }
f3f7d52a9b1f 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";
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
632 exit 1;
f3f7d52a9b1f planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/damidseq_findpeaks commit 87c99a97cb2ce55640afdd2e55c8b3ae5ad99324
mvdbeek
parents:
diff changeset
633 }