File: compare_FL_stats.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 (70 lines) | stat: -rwxr-xr-x 1,336 bytes parent folder | download | duplicates (2)
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
58
59
60
61
62
63
64
65
66
67
68
69
70
#!/usr/bin/env perl

use strict;
use warnings;

my $usage = "\n\tusage: $0 A.FL_selected B.FL_selected [RESTRICT_TO_FAILURES]\n\n";

my $A_stats_file = $ARGV[0] or die $usage;
my $B_stats_file = $ARGV[1] or die $usage;

my $RESTRICT_TO_FAILURES = $ARGV[2] || 0;

my $MIN_PER_LEN = 99;
my $MAX_PER_GAP = 1;

main: {
    
    my %A_stats = &parse_stats($A_stats_file);
    my %B_stats = &parse_stats($B_stats_file);

    my %trans = map { + $_ => 1 } (keys %A_stats, keys %B_stats);

    foreach my $trans_acc (keys %trans) {

        my $A_FL = $A_stats{$trans_acc} || ".";
        
        my $B_FL = $B_stats{$trans_acc} || ".";
        
        if ($RESTRICT_TO_FAILURES) {
            unless ($A_FL eq "." || $B_FL eq ".") {
                next;
            }
        }
        
        my ($trans, $gene) = split(/;/, $trans_acc);

        print join("\t", $gene, $trans, $trans_acc, $A_FL, $B_FL) . "\n";
        
    }
    
    exit(0);
        
}

####
sub parse_stats {
    my ($stats_file) = @_;

    my %trans_to_stats;
    
    open (my $fh, $stats_file) or die $!;
    while (<$fh>) {
        chomp;

        my $line = $_;
        
        my @x = split(/\t/);
        

        my $trans = $x[0];
        my $reco = $x[1];

        $trans_to_stats{$trans} = $reco;

    }
    close $fh;

    return (%trans_to_stats);
}