Mercurial > repos > iuc > windowmasker
annotate windowmasker_to_bed.pl @ 0:d90ae4a02efd draft default tip
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
author | iuc |
---|---|
date | Thu, 14 Dec 2023 16:04:27 +0000 |
parents | |
children |
rev | line source |
---|---|
0
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
1 #!/usr/bin/env perl |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
2 use warnings; |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
3 use strict; |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
4 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
5 =head1 NAME |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
6 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
7 windowmasker_to_bed.pl - Convert WindowMasker output to BED format |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
8 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
9 =head1 SYNOPSIS |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
10 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
11 windowmasker_to_bed.pl < ${input.interval} > ${output.bed} |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
12 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
13 =head1 DESCRIPTION |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
14 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
15 This scripts converts the interval output from WindowMasker ustat |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
16 to bed 4 format. |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
17 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
18 =head1 VERSION |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
19 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
20 Last update: 2017-04-28 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
21 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
22 =cut |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
23 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
24 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
25 #==================== |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
26 # Libraries |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
27 #==================== |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
28 use Getopt::Long; |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
29 use Pod::Usage; |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
30 use Carp; |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
31 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
32 sub main { |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
33 parse_arguments(); |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
34 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
35 my $chrom; |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
36 my $idx = 0; |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
37 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
38 while ( defined(my $line = <>) ) { |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
39 next if ($line =~ /^\s*$/x); |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
40 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
41 if ($line =~ /^>(\S+)/x) { |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
42 $chrom = $1; |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
43 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
44 } elsif ($line =~ /(\d+)\s+\-\s+(\d+)/x) { |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
45 # interval coordinates are 0-based |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
46 my $start = $1; |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
47 my $end = $2 + 1; |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
48 my $name = sprintf("wm_%d", $idx++); |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
49 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
50 print join("\t", $chrom, $start, $end, $name), "\n"; |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
51 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
52 } else { |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
53 croak("Invalid line: ${line}"); |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
54 } |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
55 } |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
56 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
57 return; |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
58 } |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
59 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
60 main(); |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
61 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
62 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
63 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
64 #==================== |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
65 # Parse command-line arguments |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
66 #==================== |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
67 sub parse_arguments { |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
68 my $help = 0; |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
69 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
70 GetOptions('help|?' => \$help) or usage(); |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
71 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
72 pod2usage({ verbose => 2 }) if ($help); |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
73 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
74 return; |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
75 } |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
76 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
77 sub usage { |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
78 my $msg = shift; |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
79 |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
80 pod2usage({ verbose => 1, message => $msg || "" }); |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
81 exit 1; |
d90ae4a02efd
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/main/tools/windowmasker/ commit d529dafd5a2d3a017de226cd59e42cf630348e06
iuc
parents:
diff
changeset
|
82 } |