File: partitioned_trinity_aggregator.pl

package info (click to toggle)
trinityrnaseq 2.6.6%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: buster
  • size: 346,416 kB
  • sloc: perl: 47,542; cpp: 20,209; java: 12,484; python: 2,766; sh: 1,665; makefile: 895; ansic: 90; xml: 83
file content (36 lines) | stat: -rwxr-xr-x 847 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
#!/usr/bin/env perl

use strict;
use warnings;


my $usage = "usage: $0 token < trinity_fasta_files_listing\n\n";

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

while (<STDIN>) {
    my $filename = $_;
    chomp $filename;
    unless (-e $filename) {
        print STDERR "ERROR, filename: $filename is indicated to not exist.\n";
        next;
    }
    if (-s $filename) {
        
        # ie. read_partitions/Fb_0/CBin_161/c16167.trinity.reads.fa
        
        $filename =~ m|c(\d+)\.trinity\.reads| or die "Error, cannot parse Trinity component value from filename: $filename";
        my $component = $1;
        
        open (my $fh, $filename) or die "Error, cannot open file $filename";
        while (<$fh>) {
            if (/>/) {
                s/>/>${token}${component}\_/;
            }
            print;
        }
    }
}

exit(0);