-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathrecursion_modified_gff_file_add_gene.pl
38 lines (36 loc) · 1.48 KB
/
recursion_modified_gff_file_add_gene.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
#!/usr/bin/perl -w
use strict;
use warnings;
open(IN,"$ARGV[0]") or die "$!";
open(OUT,">$ARGV[1]");
#comment:inputfile not allow the "#",besides the header descriptions,delete the header must be fine on this scripts
while(<IN>){
&readgff($_);
}
sub readgff{
my $line=shift;
if($line =~/mRNA/){
my @array=split /\s+/,$line;
print OUT $array[0],"\t",$array[1],"\t","gene","\t",$array[3],"\t",$array[4],"\t",$array[5],"\t",$array[6],"\t",$array[7],"\t",$array[8],"\n";
$array[8]=~s/(ID\=Bras_T[0-9]+)(.*)/$1\.1$2/g;
$array[8]=~m/ID\=(Bras_T[0-9]+)(.*)/;
print OUT $array[0],"\t",$array[1],"\t",$array[2],"\t",$array[3],"\t",$array[4],"\t",$array[5],"\t",$array[6],"\t",$array[7],"\t","$array[8]",";","Parent=$1\.1","\n";
}else{
my @array1=split /\s+/,$line;
if(@array1 !=9){
print OUT $line;
}else{
if($line !~/gene/){
$array1[8]=~s/(ID\=Bras_T[0-9]+)(.*)/$1\.1$2/g;
print OUT $array1[0],"\t",$array1[1],"\t",$array1[2],"\t",$array1[3],"\t",$array1[4],"\t",$array1[5],"\t",$array1[6],"\t",$array1[7],"\t","$array1[8]\.1","\n";
}
}
$line=<IN>;
if(eof(IN)){
exit;
}
&readgff($line);
}
}
close IN;
close OUT;