File: extract-transcript-to-gene-map-from-trinity

package info (click to toggle)
rsem 1.3.3%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 37,664 kB
  • sloc: cpp: 19,230; perl: 1,326; python: 1,245; ansic: 547; makefile: 186; sh: 154
file content (34 lines) | stat: -rwxr-xr-x 791 bytes parent folder | download | duplicates (5)
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
#!/usr/bin/env perl

use strict;

if (scalar(@ARGV) != 2) {
    print "Usage: extract-transcript-to-gene-map-from-trinity trinity_fasta_file map_file\n";
    exit(-1);
}

open(INPUT, $ARGV[0]);
open(OUTPUT, ">$ARGV[1]");

my ($tag, $line);
$tag = <INPUT>; chomp($tag);
while (substr($tag, 0, 1) eq ">") {
    $tag = substr($tag, 1);
    my $cnt = 0;
    while (($line = <INPUT>) && substr($line, 0, 1) ne ">") {
	$cnt++;
    }
    if ($cnt == 0) { print "Warning: Fasta entry $tag has an empty sequence, it is omitted.\n"; }
    else {
	my ($tid, @tmp) = split(/ /, $tag);
	my $pos = rindex($tid, "_");
	my $gid = "";
	if ($pos >= 0) { $gid = substr($tid, 0, $pos); }
	else { $gid = $tid; }
	print OUTPUT "$gid\t$tid\n";
    }
    $tag = $line; chomp($tag);
} 

close(INPUT);
close(OUTPUT);