-
Notifications
You must be signed in to change notification settings - Fork 3
/
summary_breakpoint.pl
140 lines (113 loc) · 3.27 KB
/
summary_breakpoint.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
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
#!/usr/bin/perl
use strict;
use warnings;
#core Perl modules
use Getopt::Long;
#locally-written modules
BEGIN {
select(STDERR);
$| = 1;
select(STDOUT);
$| = 1;
}
# get input params
my $global_options = checkParams();
my $inputdir;
my $outputfile;
$inputdir = &overrideDefault("inputfile.dir",'inputdir');
$outputfile = &overrideDefault("outputfile.txt",'outputfile');
######################################################################
# CODE
######################################################################
my $dir = "./"."$inputdir";
my $name = '';
opendir(DIR, $dir) || die "Can't open directory $dir\n";
my @array = ();
@array = readdir(DIR);
open (OUT, ">$outputfile") or die;
print OUT "OG_ID\tLength (bp)\tBreakpoint sites\tNumber of Breakpoint\n";
foreach my $file (@array){
next unless ($file =~ /^\S+.SH.txt$/);
if ($file =~ /^(\S.*?)\./){
$name = $1;
print OUT "$name\t";
}
my $alnlen = 0;
my $bp = '';
my $lhs = 0;
my $rhs = 0;
my $count = 0;
open (IN, "$dir/$file") or die;
while(<IN>){
chomp;
if(/^Sites\s{5}:(\d+)/){
$alnlen = $1;
print OUT "$alnlen\t";
}
if(/^\s{7}(\d+)\s+\|\s+\S+\s+\|\s+(\S+)\s+\|\s+\S+\s+\|\s+(\S+)\s*$/){
$bp = $1;
$lhs = $2;
$rhs = $3;
if(($lhs < 0.05) && ($rhs < 0.05)){
print OUT "$bp ";
$count++;
}
}
if(/^Mean splits identify:/){
if($count == 0){
print OUT "None\t$count\n";
}else{
print OUT "\t$count\n";
}
}
}
}
closedir (DIR);
######################################################################
# The corrected p-values of SH-test
#Breakpoint | LHS Raw p | LHS adjusted p | RHS Raw p | RHS adjusted p
# 291 | 0.00140 | 0.00840 | 0.00010 | 0.00060
# 411 | 0.01210 | 0.07260 | 0.00010 | 0.00060
# 517 | 0.00010 | 0.00060 | 0.01740 | 0.10440
#####################################################################
######################################################################
# TEMPLATE SUBS
######################################################################
sub checkParams {
#-----
# Do any and all options checking here...
#
my @standard_options = ( "help|h+", "inputdir|i:s", "outputfile|o:s");
my %options;
# Add any other command line options, and the code to handle them
#
GetOptions( \%options, @standard_options );
#if no arguments supplied print the usage and exit
#
exec("pod2usage $0") if (0 == (keys (%options) ));
# If the -help option is set, print the usage and exit
#
exec("pod2usage $0") if $options{'help'};
# Compulsosy items
#if(!exists $options{'infile'} ) { print "**ERROR: $0 : \n"; exec("pod2usage $0"); }
return \%options;
}
sub overrideDefault
{
#-----
# Set and override default values for parameters
#
my ($default_value, $option_name) = @_;
if(exists $global_options->{$option_name})
{
return $global_options->{$option_name};
}
return $default_value;
}
=head1 DESCRIPTION
Summary significant breakpoints by the SH test.
=head1 SYNOPSIS
script.pl -i -o [-h]
[-help -h] Displays this basic usage information
[-inputdir -i] Input directory containing the text report of SH test
[-outputfile -o] Output file