-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathian_txt2gff.pl
45 lines (37 loc) · 1.08 KB
/
ian_txt2gff.pl
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
#!/usr/bin/perl -w
use strict;
my $intxt=shift;
my $anno_version=shift;
my $genome_version=shift;
$anno_version ||="Test";
$genome_version ||="AP000423.1";
my %exon_hash;
open IN, "$intxt" || die "$!\n";
while(<IN>){
chomp;
my @info=split;
if($info[1] eq "exon"){
#print "$_\n";
if($info[3] eq "+"){
$info[4]++;
$info[5]++;
}
push @{$exon_hash{$info[0]}{$info[3]}}, [@info];
}
}
close IN;
foreach my $gene(sort keys %exon_hash){
#print "$gene\n";
foreach my $s(sort keys %{$exon_hash{$gene}}){
#print "$gene\t$s\n";
@{$exon_hash{$gene}{$s}} = sort {$a -> [4] <=> $b -> [4]} @{$exon_hash{$gene}{$s}};
my $gene_start=$exon_hash{$gene}{$s}[0][4];
my $gene_end=$exon_hash{$gene}{$s}[-1][5];
my $gid="$gene\_$s";
#print "$gid\n";
print "$genome_version\t$anno_version\tgene\t$gene_start\t$gene_end\t\.\t$s\t\.\tID=$gid;\n";
for (my $i=0; $i<@{$exon_hash{$gene}{$s}}; $i++){
print "$genome_version\t$anno_version\texon\t$exon_hash{$gene}{$s}[$i]->[4]\t$exon_hash{$gene}{$s}[$i]->[5]\t\.\t$s\t\.\tParent=$gid;\n";
}
}
}