File: extract_venn_agree_from_summaries.pl

package info (click to toggle)
trinityrnaseq 2.11.0%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 417,528 kB
  • sloc: perl: 48,420; cpp: 17,749; java: 12,695; python: 3,124; sh: 1,030; ansic: 983; makefile: 688; xml: 62
file content (57 lines) | stat: -rwxr-xr-x 1,225 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#!/usr/bin/env perl

use strict;
use warnings;


## Given a subset of the venn, extracts all entries from the original files containing the pairwise DE data.

my $usage = "\n\nusage: $0 venn.selected pw1.summary pw2.summary ...\n\n";

my $selected_file = $ARGV[0] or die $usage;
shift @ARGV;

my @pw_summaries = @ARGV;
unless (scalar @pw_summaries > 1) { die $usage; }


main: {

    my %keys_want;
    {
        open (my $fh, $selected_file) or die "Error, cannot open file $selected_file";
        while (<$fh>) {
            chomp;
            my ($acc, $sampleA, $sampleB, @rest) = split(/\t/);
            
            my $key = join("$;", $acc, sort ($sampleA, $sampleB));

            $keys_want{$key} = 1;
            
        }
        close $fh;
    }

    foreach my $pw_summary (@pw_summaries) {
        
        open (my $fh, $pw_summary) or die $!;
        while (<$fh>) {
            my  $line = $_;
            chomp;
            
            my ($acc, $sampleA, $sampleB, @rest) = split(/\t/);
            my $key = join("$;", $acc, sort ($sampleA, $sampleB));

            
            if ($keys_want{$key}) {
                print $line;
            }
        }
        close $fh;

    }

    exit(0);
}