-
Notifications
You must be signed in to change notification settings - Fork 5
/
Gff3.convert.bed.mcscan.pl
49 lines (46 loc) · 1003 Bytes
/
Gff3.convert.bed.mcscan.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
46
47
48
49
#! perl
use warnings;
use strict;
use File::Basename;
print STDERR "USAGE : perl $0 gff [0,1,2][0:all 1:mcscanx 2:mcscanx-python] [extend bp]\n";
my $gff = shift or die "need gff\n";
my $jud = shift;
my $ex = shift;
$jud //= 0;
$ex //= 0;
open IN,'<',$gff;
my $m;
my $mp;
while(<IN>){
chomp;
next if /^#/;
my @l = split/\t/;
next unless $l[2] eq "mRNA";
if($l[8] =~ /;/){
$l[8] =~ s/.*ID=(.*?);.*/$1/;
}else{
$l[8] =~ s/ID=//;
}
$l[3] = $l[3] - $ex;
$l[3] = 0 if $l[3]<0;
$l[4] = $l[4] + $ex;
$m .= "$l[0]\t$l[8]\t$l[3]\t$l[4]\n";
$mp .= "$l[0]\t$l[3]\t$l[4]\t$l[8]\t$l[6]\t$l[7]\n";
}
(my $base = basename $gff) =~ s/(.*)\..*/$1/;
my $mp_o = "$base.python_mcscanx.gff";
my $m_o = "$base.mcscanx.gff";
if($jud == 0){
open MP ,'>',$mp_o;
print MP $mp;
open M ,'>',$m_o;
print M $m;
}elsif($jud == 1){
open M ,'>',$m_o;
print M $m;
}elsif($jud == 2){
open MP ,'>',$mp_o;
print MP $mp;
}
close MP;
close M;