-
Notifications
You must be signed in to change notification settings - Fork 3
/
detect_dup_modes_for_a_gene.pl
executable file
·87 lines (87 loc) · 1.82 KB
/
detect_dup_modes_for_a_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
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
82
83
84
85
86
87
use Getopt::Std;
%options=();
getopts("i:d:o:", \%options);
if(! exists $options{i}||! exists $options{d})
{
print "Usage:\nperl detect_dup_modes_for_a_gene.pl -i gene_name -d output_directory_of_MCScanX-transposed\/target_species\n";
print "optional: -o output_file\n";
exit;
}
$write_file=0;
if(exists $options{o})
{
open(output,">$options{o}") or die "Cannot open output_file!\n";
$write_file=1;
}
print "Duplicate 1\tLocation\tDuplicate 2\tLocation\tE-value\tMode\n";
if($write_file==1)
{
print output "Duplicate 1\tLocation\tDuplicate 2\tLocation\tE-value\tMode\n";
}
@mode=("segmental","tandem","proximal","transposed");
for($i=0;$i<4;$i++)
{
$dir=$options{d}."\.".$mode[$i]."\.pairs";
$tag="mode$i";
open($tag,$dir) or die "Cannot open $mode[$i]_duplication_file!\n";
$line=<$tag>;
while($line=<$tag>)
{
chomp($line);
if($line=~/$options{i}/)
{
print "$line\t$mode[$i]\n";
if($write_file==1)
{
print output "$line\t$mode[$i]\n";
}
}
}
}
######################################################
$b=`ls $options{d}.transposed_*.pairs`;
chomp($b);
if($b eq "")
{
print "Transposed duplciations are not classified into different epochs\n";
exit;
}
else
{
print "#################epochs for transposed dupliclations######\n";
if($write_file==1)
{
print output "#################epochs for transposed dupliclations######\n";
}
}
print "Transposed\tLocation\tParental\tLocation\tE-value\tEpoch\n";
if($write_file==1)
{
print output "Transposed\tLocation\tParental\tLocation\tE-value\tEpoch\n";
}
@f=split("\n",$b);
for($i=0;$i<=$#f;$i++)
{
$pos=index($f[$i],"\.transposed_");
$tmp=substr($f[$i],$pos+1);
$tmp=~s/\.pairs//;
$mode[$i]=$tmp;
}
for($i=0;$i<=$#f;$i++)
{
$tag=$mode[$i];
open($tag,$f[$i]);
$line=<$tag>;
while($line=<$tag>)
{
chomp($line);
if($line=~/$options{i}/)
{
print "$line\t$mode[$i]\n";
if($write_file==1)
{
print output "$line\t$mode[$i]\n";
}
}
}
}