File: check_chrysalis_graph_reciprocal_edges.pl

package info (click to toggle)
trinityrnaseq 2.15.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 468,004 kB
  • sloc: perl: 49,905; cpp: 17,993; java: 12,489; python: 3,282; sh: 1,989; ansic: 985; makefile: 717; xml: 62
file content (53 lines) | stat: -rwxr-xr-x 1,008 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
#!/usr/bin/env perl

use strict;
use warnings;

my $usage = "\n\n\tusage: $0 graphFromIwormFasta.out\n\n";

my $file = $ARGV[0] or die $usage;

main: {

    my %graph;
    
    open(my $fh, $file) or die $!;
    while (<$fh>) {
        chomp;
        my @x = split(/\t/);

        my $node_id = shift @x;
        my $spacer = shift @x;

        foreach my $other_node (@x) {
            $graph{$node_id}->{$other_node}++;
        }
    }
    close $fh;


    my $found_missing_recip = 0;
    foreach my $node (keys %graph) {

        foreach my $other_node (keys %{$graph{$node}}) {

            if (! exists $graph{$other_node}->{$node}) {
                $found_missing_recip = 1;

                print STDERR "Error, have $node\->$other_node, but missing $other_node\->$node\n";
            
            }
        }
    }

    if ($found_missing_recip) {
        die "Error, missing recips found.\n";
    }
    else {
        print STDERR "\n\nAll good. :-)\n\n";
        
        exit(0);
    }

    
}