File: print_butterfly_assemblies.pl

package info (click to toggle)
trinityrnaseq 2.15.2%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, 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 (56 lines) | stat: -rwxr-xr-x 1,467 bytes parent folder | download
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
#!/usr/bin/env perl

use strict;
use warnings;
use FindBin;
use lib ("$FindBin::Bin/../../PerlLib");
use Fasta_reader;

my $usage = "usage: $0 chrysalis_component_listing.txt min_seq_length\n\n";

my $comp_list_file = $ARGV[0] or die $usage;
my $min_seq_length = $ARGV[1] or die $usage;


main: {

    my $ret_val = 0;

    my %seen;
    
    open (my $fh, $comp_list_file) or die "Error, cannot open file $comp_list_file";
    while (<$fh>) {
        chomp;
        my ($comp_id, $comp_base) = split(/\t/);
        my $butterfly_fasta_file = "$comp_base.graph.allProbPaths.fasta";
        
        if (-e $butterfly_fasta_file) {

            my $fasta_reader = new Fasta_reader($butterfly_fasta_file);
            while (my $seq_obj = $fasta_reader->next()) {
                my $sequence = $seq_obj->get_sequence();
                if (length($sequence) >= $min_seq_length) {

                    if ($seen{$sequence}) {
                        print STDERR "-duplicate sequence detected, excluding it.\n";
                        next;
                    }
                    else {
                        $seen{$sequence} = 1;
                    }
                    
                    print $seq_obj->get_FASTA_format();
                }
            }
        }
        else {
            print STDERR "Error, no fasta file reported as: $butterfly_fasta_file\n";
            $ret_val = 1;
        }
    }
    
    close $fh;
    
    exit($ret_val);
}