-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathevmFormatAln.pl
More file actions
executable file
·81 lines (75 loc) · 1.38 KB
/
evmFormatAln.pl
File metadata and controls
executable file
·81 lines (75 loc) · 1.38 KB
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
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
#!/usr/bin/env perl
#
# author = David Jebb, 2019
#
use warnings;
use strict ;
my @headers ;
my @glines ;
my $fh ;
if (scalar(@ARGV)>0){
open $fh, "<$ARGV[0]";
}
else{
$fh = *STDIN ;
}
while (<$fh>){
my $line = $_ ;
### get all the seq info and gff version lines
if ($line =~ /^##( |\w+)/){
push @headers, $line
}
### ignore comment lines
elsif ($line =~ /^#[^#]/){
next
}
### get all the annotation lines
else{
push @glines, $line
}
}
my @genes = split(/###\n/,join('',@glines)) ;
if ($glines[scalar(@glines)-1]eq "###"){
pop @genes ;
}
my $aln_type;
if ($ARGV[1]){
$aln_type = "cDNA_match"
}
else{
$aln_type = "nucleotide_to_protein_match"
}
chomp @headers ;
print join("\n",@headers)."\n" ;
my $count = 0 ;
foreach my $g (@genes){
$count++ ;
my @aln = split(/\n/,$g) ;
# shift @aln ;
my ($mrna) = grep /\tmRNA\t/, @aln ;
my $target ;
if ($mrna =~/Target/){
($target)=$mrna=~/Target=([\w.\/]+)/ ;
}
else{
my $dodge ;
($dodge,$target)=$mrna=~/(transcript_id|[Nn]ame)=([\w.\/]+)/
}
my $start = 1;
my $end ;
foreach my $line(@aln){
if ($line=~/\texon\t/){
chomp $line ;
my @info = split(/\t/,$line) ;
my ($l,$r)= (@info)[3,4] ;
$info[2] = "$aln_type" ;
pop @info ;
my $diff = $r -$l ;
$end = $start +$diff ;
my $t = "ID=CDS$count;Target=$target $start $end\n" ;
print join("\t",@info)."\t".$t ;
$start = $end +1 ;
}
}
print "###\n"
}