Debian Codegraph @

bin/abyss-joindist

raw
1 #!/usr/bin/env perl
2 # Join multiple ABySS distance estimate files.
3 # Written by Shaun Jackman <[email protected]>.
4 use strict;
5 use Getopt::Long;
6 use Pod::Usage;
7
8 my %opt;
9 GetOptions(\%opt, qw'help man');
10 pod2usage(-verbose => 1) if $opt{help};
11 pod2usage(-verbose => 2) if $opt{man};
12
13 my (%id, %a, %b);
14
15 while (<>) {
16 chomp;
17 my ($id, $rest) = split ' ', $_, 2;
18 my ($a, $b) = split ';', $rest, 2;
19 my @a = split ' ', $a;
20 my @b = split ' ', $b;
21 $id{$id} = 1;
22
23 for (@a) {
24 my ($to, $d, $n, $sd) = split ',';
25 if (!exists $a{$id}{$to} || $sd < $a{$id}{$to}) {
26 $a{$id}{$to} = "$sd $d $n";
27 }
28 }
29
30 for (@b) {
31 my ($to, $d, $n, $sd) = split ',';
32 if (!exists $b{$id}{$to} || $sd < $b{$id}{$to}) {
33 $b{$id}{$to} = "$sd $d $n";
34 }
35 }
36 }
37
38 for my $id (sort {$a<=>$b} keys %id) {
39 print $id;
40 for my $to (sort {$a<=>$b} keys %{$a{$id}}) {
41 my ($sd, $d, $n) = split ' ', $a{$id}{$to};
42 print " $to,$d,$n,$sd";
43 }
44 print ' ;';
45 for my $to (sort {$a<=>$b} keys %{$b{$id}}) {
46 my ($sd, $d, $n) = split ' ', $b{$id}{$to};
47 print " $to,$d,$n,$sd";
48 }
49 print "\n";
50 }
51
52 =pod
53
54 =head1 NAME
55
56 abyss-joindist -
57 Join multiple ABySS distance estimate files.
58
59 =head1 SYNOPSIS
60
61 B<abyss-joindist> F<in.dist>... >F<out.dist>
62
63 =head1 AUTHOR
64
65 Written by Shaun Jackman.
66
67 =head1 REPORTING BUGS
68
69 Report bugs to <[email protected]>.
70
71 =head1 COPYRIGHT
72
73 Copyright 2009 Canada's Michael Smith Genome Science Centre
74
75 =head1 SEE ALSO
76
77 L<ABYSS(1)>
78
79 http://www.bcgsc.ca/platform/bioinfo/software/abyss