| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# -*-CPerl-*- |
|
2
|
|
|
|
|
|
|
# Last changed Time-stamp: <2017-05-28 17:05:51 mtw> |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# Bio::RNA::RNAaliSplit::WrapRNAz.pm: A versatile object-oriented |
|
5
|
|
|
|
|
|
|
# wrapper for RNAz |
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
# Requires RNAz executable available to the Perl interpreter. |
|
8
|
|
|
|
|
|
|
# This package contains code fragments from the original RNAz Perl module |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package Bio::RNA::RNAaliSplit::WrapRNAz; |
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
1366
|
use version; our $VERSION = qv('0.05'); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
9
|
|
|
13
|
1
|
|
|
1
|
|
161
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
70
|
|
|
14
|
1
|
|
|
1
|
|
6
|
use Data::Dumper; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
37
|
|
|
15
|
1
|
|
|
1
|
|
6
|
use Moose; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
8
|
|
|
16
|
1
|
|
|
1
|
|
6695
|
use Path::Class; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
62
|
|
|
17
|
1
|
|
|
1
|
|
6
|
use IPC::Cmd qw(can_run run); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
51
|
|
|
18
|
1
|
|
|
1
|
|
6
|
use File::Path qw(make_path); |
|
|
1
|
|
|
|
|
1
|
|
|
|
1
|
|
|
|
|
1067
|
|
|
19
|
|
|
|
|
|
|
#use diagnostics; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my ($rnaz,$oodir); |
|
22
|
|
|
|
|
|
|
|
|
23
|
|
|
|
|
|
|
has 'basename' => ( |
|
24
|
|
|
|
|
|
|
is => 'rw', |
|
25
|
|
|
|
|
|
|
isa => 'Str', |
|
26
|
|
|
|
|
|
|
predicate => 'has_basename', |
|
27
|
|
|
|
|
|
|
documentation => q(Set this to override output basename), |
|
28
|
|
|
|
|
|
|
); |
|
29
|
|
|
|
|
|
|
|
|
30
|
|
|
|
|
|
|
has 'P' => ( |
|
31
|
|
|
|
|
|
|
is => 'rw', |
|
32
|
|
|
|
|
|
|
isa => 'Num', |
|
33
|
|
|
|
|
|
|
init_arg => undef, |
|
34
|
|
|
|
|
|
|
documentation => q(SVM RNA-class probability), |
|
35
|
|
|
|
|
|
|
); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has 'z' => ( |
|
38
|
|
|
|
|
|
|
is => 'rw', |
|
39
|
|
|
|
|
|
|
isa => 'Num', |
|
40
|
|
|
|
|
|
|
init_arg => undef, |
|
41
|
|
|
|
|
|
|
documentation => q(Mean z-score), |
|
42
|
|
|
|
|
|
|
); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has 'sci' => ( |
|
45
|
|
|
|
|
|
|
is => 'rw', |
|
46
|
|
|
|
|
|
|
isa => 'Num', |
|
47
|
|
|
|
|
|
|
init_arg => undef, |
|
48
|
|
|
|
|
|
|
documentation => q(Structure conservation index), |
|
49
|
|
|
|
|
|
|
); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
with 'FileDirUtil'; |
|
52
|
|
|
|
|
|
|
with 'Bio::RNA::RNAaliSplit::Roles'; |
|
53
|
|
|
|
|
|
|
|
|
54
|
|
|
|
|
|
|
sub BUILD { |
|
55
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
56
|
0
|
|
|
|
|
|
my $this_function = (caller(0))[3]; |
|
57
|
0
|
0
|
|
|
|
|
confess "ERROR [$this_function] \$self->ifile not available" |
|
58
|
|
|
|
|
|
|
unless ($self->has_ifile); |
|
59
|
0
|
0
|
|
|
|
|
$rnaz = can_run('RNAz') or |
|
60
|
|
|
|
|
|
|
croak "ERROR [$this_function] RNAz not found"; |
|
61
|
0
|
0
|
|
|
|
|
unless($self->has_odir){ |
|
62
|
0
|
0
|
|
|
|
|
unless($self->has_dirnam){self->dirnam("as")} |
|
|
0
|
|
|
|
|
|
|
|
63
|
0
|
|
|
|
|
|
$self->odir( [$self->ifile->dir,$self->dirnam] ); |
|
64
|
|
|
|
|
|
|
} |
|
65
|
0
|
|
|
|
|
|
$oodir = $self->odir->subdir("rnaz"); |
|
66
|
0
|
|
|
|
|
|
my @created = make_path($oodir, {error => \my $err}); |
|
67
|
0
|
0
|
|
|
|
|
confess "ERROR [$this_function] could not create output directory $self->oodir" |
|
68
|
|
|
|
|
|
|
if (@$err); |
|
69
|
0
|
|
|
|
|
|
$self->set_ifilebn; |
|
70
|
0
|
|
|
|
|
|
$self->run_rnaz(); |
|
71
|
|
|
|
|
|
|
} |
|
72
|
|
|
|
|
|
|
|
|
73
|
|
|
|
|
|
|
sub run_rnaz { |
|
74
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
75
|
0
|
|
|
|
|
|
my $this_function = (caller(0))[3]; |
|
76
|
0
|
|
|
|
|
|
my ($rnaz_outfilename,$rnaz_out); |
|
77
|
0
|
0
|
|
|
|
|
if ($self->has_basename){$rnaz_outfilename = $self->basename.".rnaz.out"} |
|
|
0
|
0
|
|
|
|
|
|
|
78
|
0
|
|
|
|
|
|
elsif ($self->has_ifilebn){$rnaz_outfilename = $self->ifilebn.".rnaz.out"} |
|
79
|
0
|
|
|
|
|
|
else{$rnaz_outfilename = "rnaz.out"} |
|
80
|
0
|
|
|
|
|
|
$rnaz_out = file($oodir,$rnaz_outfilename); |
|
81
|
0
|
|
|
|
|
|
open my $fh, ">", $rnaz_out; |
|
82
|
0
|
|
|
|
|
|
my $rnaz_cmd = $rnaz." -l -d < ".$self->ifile; |
|
83
|
0
|
|
|
|
|
|
my ( $success, $error_message, $full_buf, $stdout_buf, $stderr_buf ) = |
|
84
|
|
|
|
|
|
|
run( command => $rnaz_cmd, verbose => 0 ); |
|
85
|
0
|
0
|
|
|
|
|
if( !$success ) { |
|
86
|
0
|
|
|
|
|
|
print STDERR "ERROR [$this_function] Call to $rnaz unsuccessful\n"; |
|
87
|
0
|
|
|
|
|
|
print STDERR "ERROR: this is what the command printed:\n"; |
|
88
|
0
|
|
|
|
|
|
print join "", @$full_buf; |
|
89
|
0
|
|
|
|
|
|
croak $!; |
|
90
|
|
|
|
|
|
|
} |
|
91
|
0
|
|
|
|
|
|
my $stdout_buffer = join "", @$stdout_buf; |
|
92
|
0
|
|
|
|
|
|
my @out = split /\n/, $stdout_buffer; |
|
93
|
0
|
|
|
|
|
|
foreach my $line( @out){print $fh $line,"\n"} |
|
|
0
|
|
|
|
|
|
|
|
94
|
0
|
|
|
|
|
|
close($fh); |
|
95
|
0
|
|
|
|
|
|
$self->_parse_rnaz($stdout_buffer); |
|
96
|
|
|
|
|
|
|
} |
|
97
|
|
|
|
|
|
|
|
|
98
|
|
|
|
|
|
|
# parse RNAz output |
|
99
|
|
|
|
|
|
|
sub _parse_rnaz { |
|
100
|
0
|
|
|
0
|
|
|
my ($self,$rnaz) = @_; |
|
101
|
0
|
|
|
|
|
|
my $this_function = (caller(0))[3]; |
|
102
|
0
|
|
|
|
|
|
my @rnaz=split(/^/, $rnaz); |
|
103
|
0
|
|
|
|
|
|
my ($N,$identity,$columns,$decValue,$P,$z,$sci,$energy,$strand, |
|
104
|
|
|
|
|
|
|
$covariance,$combPerPair,$meanMFE,$consensusMFE,$consensusSeq, |
|
105
|
|
|
|
|
|
|
$consensusFold, $GCcontent, $ShannonEntropy); |
|
106
|
0
|
|
|
|
|
|
my @aln=(); |
|
107
|
|
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
foreach my $i (0..$#rnaz){ |
|
109
|
0
|
|
|
|
|
|
my $line=$rnaz[$i]; |
|
110
|
0
|
0
|
|
|
|
|
$identity=$1 if ($line=~/Mean pairwise identity:\s*(-?\d+.\d+)/); |
|
111
|
0
|
0
|
|
|
|
|
$N=$1 if ($line=~/Sequences:\s*(\d+)/); |
|
112
|
0
|
0
|
|
|
|
|
if ($line=~/Reading direction:\s*(forward|reverse)/){ |
|
113
|
0
|
0
|
|
|
|
|
$strand=($1 eq 'forward')?'+':'-'; |
|
114
|
|
|
|
|
|
|
} |
|
115
|
0
|
0
|
|
|
|
|
$columns=$1 if ($line=~/Columns:\s*(\d+)/); |
|
116
|
0
|
0
|
|
|
|
|
$decValue=$1 if ($line=~/SVM decision value:\s*(-?\d+.\d+)/); |
|
117
|
0
|
0
|
|
|
|
|
$P=$1 if ($line=~/SVM RNA-class probability:\s*(-?\d+.\d+)/); |
|
118
|
0
|
0
|
|
|
|
|
$z=$1 if ($line=~/Mean z-score:\s*(-?\d+.\d+)/); |
|
119
|
0
|
0
|
|
|
|
|
$sci=$1 if ($line=~/Structure conservation index:\s*(-?\d+.\d+)/); |
|
120
|
0
|
0
|
|
|
|
|
$energy=$1 if ($line=~/Energy contribution:\s*(-?\d+.\d+)/); |
|
121
|
0
|
0
|
|
|
|
|
$covariance=$1 if ($line=~/Covariance contribution:\s*(-?\d+.\d+)/); |
|
122
|
0
|
0
|
|
|
|
|
$combPerPair=$1 if ($line=~/Combinations\/Pair:\s*(-?\d+.\d+)/); |
|
123
|
0
|
0
|
|
|
|
|
$consensusMFE=$1 if ($line=~/Consensus MFE:\s*(-?\d+.\d+)/); |
|
124
|
0
|
0
|
|
|
|
|
$meanMFE=$1 if ($line=~/Mean single sequence MFE:\s*(-?\d+.\d+)/); |
|
125
|
0
|
0
|
|
|
|
|
$GCcontent=$1 if ($line=~/G\+C content:\s(\d+.\d+)/); |
|
126
|
0
|
0
|
|
|
|
|
$ShannonEntropy=$1 if ($line=~/Shannon entropy:\s*(\d+.\d+)/); |
|
127
|
|
|
|
|
|
|
|
|
128
|
0
|
0
|
|
|
|
|
if ($line=~/^>/){ |
|
129
|
0
|
|
|
|
|
|
chomp($rnaz[$i+1]); |
|
130
|
0
|
|
|
|
|
|
chomp($rnaz[$i+2]); |
|
131
|
0
|
0
|
|
|
|
|
if ($line=~/^>consensus/){ |
|
132
|
0
|
|
|
|
|
|
$consensusSeq=$rnaz[$i+1]; |
|
133
|
0
|
|
|
|
|
|
$consensusFold=substr($rnaz[$i+2],0,length($rnaz[$i+1])); |
|
134
|
0
|
|
|
|
|
|
last; |
|
135
|
|
|
|
|
|
|
} else { |
|
136
|
0
|
0
|
|
|
|
|
if ($line=~/>(.*?) (\d+) (\d+) (\+|\-) (\d+)/){ |
|
|
|
0
|
|
|
|
|
|
|
137
|
0
|
|
|
|
|
|
push @aln, {name=>$1, |
|
138
|
|
|
|
|
|
|
start=>$2, |
|
139
|
|
|
|
|
|
|
end=>$2+$3, |
|
140
|
|
|
|
|
|
|
strand=>$4, |
|
141
|
|
|
|
|
|
|
fullLength=>$5, |
|
142
|
|
|
|
|
|
|
seq=>$rnaz[$i+1], |
|
143
|
|
|
|
|
|
|
fold=>substr($rnaz[$i+2],0,length($rnaz[$i+1]))}; |
|
144
|
0
|
|
|
|
|
|
$i+=2; |
|
145
|
|
|
|
|
|
|
} elsif ($line=~/^(.*)\/(\d+)-(\d+)$/){ |
|
146
|
0
|
|
|
|
|
|
push @aln, {name=>$1, |
|
147
|
|
|
|
|
|
|
start=>$2, |
|
148
|
|
|
|
|
|
|
end=>$3, |
|
149
|
|
|
|
|
|
|
strand=>$strand, |
|
150
|
|
|
|
|
|
|
fullLength=>'', |
|
151
|
|
|
|
|
|
|
seq=>$rnaz[$i+1], |
|
152
|
|
|
|
|
|
|
fold=>substr($rnaz[$i+2],0,length($rnaz[$i+1]))}; |
|
153
|
0
|
|
|
|
|
|
$i+=2; |
|
154
|
|
|
|
|
|
|
} |
|
155
|
|
|
|
|
|
|
} |
|
156
|
|
|
|
|
|
|
} |
|
157
|
|
|
|
|
|
|
} |
|
158
|
|
|
|
|
|
|
|
|
159
|
0
|
|
|
|
|
|
$self->P($P); |
|
160
|
0
|
|
|
|
|
|
$self->z($z); |
|
161
|
0
|
|
|
|
|
|
$self->sci($sci); |
|
162
|
|
|
|
|
|
|
} |
|
163
|
|
|
|
|
|
|
|
|
164
|
|
|
|
|
|
|
1; |