| line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
|
1
|
|
|
|
|
|
|
# -*-CPerl-*- |
|
2
|
|
|
|
|
|
|
# Last changed Time-stamp: <2017-05-28 17:05:29 mtw> |
|
3
|
|
|
|
|
|
|
|
|
4
|
|
|
|
|
|
|
# Bio::RNA::RNAaliSplit::WrapRNAalifold.pm: A versatile object-oriented |
|
5
|
|
|
|
|
|
|
# wrapper for RNAalifold |
|
6
|
|
|
|
|
|
|
# |
|
7
|
|
|
|
|
|
|
# Requires RNAalifold executable from the ViennaRNA package available |
|
8
|
|
|
|
|
|
|
# to the Perl interpreter. |
|
9
|
|
|
|
|
|
|
|
|
10
|
|
|
|
|
|
|
package Bio::RNA::RNAaliSplit::WrapRNAalifold; |
|
11
|
|
|
|
|
|
|
|
|
12
|
1
|
|
|
1
|
|
1400
|
use version; our $VERSION = qv('0.05'); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
10
|
|
|
13
|
1
|
|
|
1
|
|
97
|
use Carp; |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
68
|
|
|
14
|
1
|
|
|
1
|
|
6
|
use Data::Dumper; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
38
|
|
|
15
|
1
|
|
|
1
|
|
5
|
use Moose; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
8
|
|
|
16
|
1
|
|
|
1
|
|
6724
|
use Path::Class; |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
68
|
|
|
17
|
1
|
|
|
1
|
|
7
|
use IPC::Cmd qw(can_run run); |
|
|
1
|
|
|
|
|
2
|
|
|
|
1
|
|
|
|
|
58
|
|
|
18
|
1
|
|
|
1
|
|
6
|
use File::Path qw(make_path); |
|
|
1
|
|
|
|
|
3
|
|
|
|
1
|
|
|
|
|
942
|
|
|
19
|
|
|
|
|
|
|
#use diagnostics; |
|
20
|
|
|
|
|
|
|
|
|
21
|
|
|
|
|
|
|
my ($rnaalifold,$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 'ribosum' => ( |
|
31
|
|
|
|
|
|
|
is => 'rw', |
|
32
|
|
|
|
|
|
|
isa => 'Num', |
|
33
|
|
|
|
|
|
|
predicate => 'has_ribosum', |
|
34
|
|
|
|
|
|
|
documentation => q(Ribosum scoring), |
|
35
|
|
|
|
|
|
|
); |
|
36
|
|
|
|
|
|
|
|
|
37
|
|
|
|
|
|
|
has 'sci' => ( |
|
38
|
|
|
|
|
|
|
is => 'rw', |
|
39
|
|
|
|
|
|
|
isa => 'Num', |
|
40
|
|
|
|
|
|
|
init_arg => undef, |
|
41
|
|
|
|
|
|
|
documentation => q(Structure conservation index), |
|
42
|
|
|
|
|
|
|
); |
|
43
|
|
|
|
|
|
|
|
|
44
|
|
|
|
|
|
|
has 'consensus_struc' => ( |
|
45
|
|
|
|
|
|
|
is => 'rw', |
|
46
|
|
|
|
|
|
|
isa => 'Str', |
|
47
|
|
|
|
|
|
|
predicate => 'has_consensus_struc', |
|
48
|
|
|
|
|
|
|
init_arg => undef, |
|
49
|
|
|
|
|
|
|
); |
|
50
|
|
|
|
|
|
|
|
|
51
|
|
|
|
|
|
|
has 'consensus_mfe' => ( |
|
52
|
|
|
|
|
|
|
is => 'rw', |
|
53
|
|
|
|
|
|
|
isa => 'Num', |
|
54
|
|
|
|
|
|
|
predicate => 'has_consensus_mfe', |
|
55
|
|
|
|
|
|
|
init_arg => undef, |
|
56
|
|
|
|
|
|
|
); |
|
57
|
|
|
|
|
|
|
|
|
58
|
|
|
|
|
|
|
has 'consensus_energy' => ( |
|
59
|
|
|
|
|
|
|
is => 'rw', |
|
60
|
|
|
|
|
|
|
isa => 'Num', |
|
61
|
|
|
|
|
|
|
predicate => 'has_consensus_energy', |
|
62
|
|
|
|
|
|
|
init_arg => undef, |
|
63
|
|
|
|
|
|
|
); |
|
64
|
|
|
|
|
|
|
|
|
65
|
|
|
|
|
|
|
has 'consensus_covar_terms' => ( |
|
66
|
|
|
|
|
|
|
is => 'rw', |
|
67
|
|
|
|
|
|
|
isa => 'Num', |
|
68
|
|
|
|
|
|
|
predicate => 'has_consensus_covar_terms', |
|
69
|
|
|
|
|
|
|
init_arg => undef, |
|
70
|
|
|
|
|
|
|
); |
|
71
|
|
|
|
|
|
|
|
|
72
|
|
|
|
|
|
|
has 'RNAalifold_version' => ( |
|
73
|
|
|
|
|
|
|
is => 'rw', |
|
74
|
|
|
|
|
|
|
isa => 'String', |
|
75
|
|
|
|
|
|
|
init_arg => undef, |
|
76
|
|
|
|
|
|
|
); |
|
77
|
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
with 'FileDirUtil'; |
|
79
|
|
|
|
|
|
|
with 'Bio::RNA::RNAaliSplit::Roles'; |
|
80
|
|
|
|
|
|
|
|
|
81
|
|
|
|
|
|
|
sub BUILD { |
|
82
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
83
|
0
|
|
|
|
|
|
my $this_function = (caller(0))[3]; |
|
84
|
0
|
0
|
|
|
|
|
confess "ERROR [$this_function] \$self->ifile not available" |
|
85
|
|
|
|
|
|
|
unless ($self->has_ifile); |
|
86
|
0
|
0
|
|
|
|
|
$rnaalifold = can_run('RNAalifold') or |
|
87
|
|
|
|
|
|
|
croak "ERROR [$this_function] RNAalifold not found"; |
|
88
|
0
|
0
|
|
|
|
|
unless($self->has_odir){ |
|
89
|
0
|
0
|
|
|
|
|
unless($self->has_dirnam){self->dirnam("as")} |
|
|
0
|
|
|
|
|
|
|
|
90
|
0
|
|
|
|
|
|
$self->odir( [$self->ifile->dir,$self->dirnam] ); |
|
91
|
|
|
|
|
|
|
} |
|
92
|
0
|
|
|
|
|
|
$oodir = $self->odir->subdir("alifold"); |
|
93
|
0
|
|
|
|
|
|
my @created = make_path($oodir, {error => \my $err}); |
|
94
|
0
|
0
|
|
|
|
|
confess "ERROR [$this_function] could not create output directory $self->oodir" |
|
95
|
|
|
|
|
|
|
if (@$err); |
|
96
|
0
|
|
|
|
|
|
$self->set_ifilebn; |
|
97
|
0
|
|
|
|
|
|
$self->run_rnaalifold(); |
|
98
|
|
|
|
|
|
|
} |
|
99
|
|
|
|
|
|
|
|
|
100
|
|
|
|
|
|
|
sub run_rnaalifold { |
|
101
|
0
|
|
|
0
|
0
|
|
my $self = shift; |
|
102
|
0
|
|
|
|
|
|
my $this_function = (caller(0))[3]; |
|
103
|
0
|
|
|
|
|
|
my ($out_fn,$out,$alnps_fn,$alnps,$alirnaps_fn,$stk_fn); |
|
104
|
0
|
|
|
|
|
|
my ($alirnaps,$alidotps_fn,$alidotps,$alifoldstk); |
|
105
|
0
|
|
|
|
|
|
my $tag = ""; |
|
106
|
0
|
0
|
|
|
|
|
if ($self->has_ribosum){$tag = ".risobum"} |
|
|
0
|
|
|
|
|
|
|
|
107
|
0
|
0
|
|
|
|
|
if ($self->has_basename){ |
|
|
|
0
|
|
|
|
|
|
|
108
|
0
|
|
|
|
|
|
$out_fn = $self->bn.$tag."."."alifold.out"; |
|
109
|
0
|
|
|
|
|
|
$alnps_fn = $self->bn.$tag."."."aln.ps"; |
|
110
|
0
|
|
|
|
|
|
$alirnaps_fn = $self->bn.$tag."."."alirna.ps"; |
|
111
|
0
|
|
|
|
|
|
$alidotps_fn = $self->bn.$tag."."."alidot.ps"; |
|
112
|
0
|
|
|
|
|
|
$stk_fn = $self->bn.$tag."."."alifold.stk"; |
|
113
|
|
|
|
|
|
|
} |
|
114
|
|
|
|
|
|
|
elsif ($self->has_ifilebn){ |
|
115
|
0
|
|
|
|
|
|
$out_fn = $self->ifilebn.$tag."."."alifold.out"; |
|
116
|
0
|
|
|
|
|
|
$alnps_fn = $self->ifilebn.$tag."."."aln.ps"; |
|
117
|
0
|
|
|
|
|
|
$alirnaps_fn = $self->ifilebn.$tag."."."alirna.ps"; |
|
118
|
0
|
|
|
|
|
|
$alidotps_fn = $self->ifilebn.$tag."."."alidot.ps"; |
|
119
|
0
|
|
|
|
|
|
$stk_fn = $self->ifilebn.$tag."."."alifold.stk"; |
|
120
|
|
|
|
|
|
|
} |
|
121
|
|
|
|
|
|
|
else{ |
|
122
|
0
|
|
|
|
|
|
$out_fn = $tag."alifold.out"; |
|
123
|
0
|
|
|
|
|
|
$alnps_fn = $tag."aln.ps"; |
|
124
|
0
|
|
|
|
|
|
$alirnaps_fn = $tag."alirna.ps"; |
|
125
|
0
|
|
|
|
|
|
$alidotps_fn = $tag."alidot.ps"; |
|
126
|
|
|
|
|
|
|
} |
|
127
|
0
|
|
|
|
|
|
$out = file($oodir,$out_fn); # RNAalifold stdout |
|
128
|
0
|
|
|
|
|
|
$alnps = file($oodir,$alnps_fn); # RNAalifold aln.ps |
|
129
|
0
|
|
|
|
|
|
$alirnaps = file($oodir,$alirnaps_fn); # RNAalifold alirna.ps |
|
130
|
0
|
|
|
|
|
|
$alidotps = file($oodir,$alidotps_fn); # RNAalifold alidot.ps |
|
131
|
0
|
|
|
|
|
|
$alifoldstk = file($oodir,$stk_fn); # RNAalifold generated Stockholm file with new CS |
|
132
|
|
|
|
|
|
|
|
|
133
|
0
|
|
|
|
|
|
open my $fh, ">", $out; |
|
134
|
0
|
|
|
|
|
|
my $alifold_options = " --aln --color --cfactor 0.6 --nfactor 0.5 -p --sci --aln-stk "; |
|
135
|
0
|
0
|
|
|
|
|
if ($self->has_ribosum){$alifold_options.=" -r "} |
|
|
0
|
|
|
|
|
|
|
|
136
|
0
|
|
|
|
|
|
my $cmd = $rnaalifold.$alifold_options.$self->ifile; |
|
137
|
0
|
|
|
|
|
|
my ( $success, $error_message, $full_buf, $stdout_buf, $stderr_buf ) = |
|
138
|
|
|
|
|
|
|
run( command => $cmd, verbose => 0 ); |
|
139
|
0
|
0
|
|
|
|
|
if( !$success ) { |
|
140
|
0
|
|
|
|
|
|
print STDERR "ERROR [$this_function] Call to $rnaalifold unsuccessful\n"; |
|
141
|
0
|
|
|
|
|
|
print STDERR "ERROR: $cmd\n"; |
|
142
|
0
|
|
|
|
|
|
print STDERR "ERROR: this is what the command printed:\n"; |
|
143
|
0
|
|
|
|
|
|
print join "", @$full_buf; |
|
144
|
0
|
|
|
|
|
|
croak $!; |
|
145
|
|
|
|
|
|
|
} |
|
146
|
0
|
|
|
|
|
|
my $stdout_buffer = join "", @$stdout_buf; |
|
147
|
0
|
|
|
|
|
|
my @rnaalifoldout = split /\n/, $stdout_buffer; |
|
148
|
0
|
|
|
|
|
|
foreach my $line( @rnaalifoldout){ |
|
149
|
0
|
|
|
|
|
|
print $fh $line,"\n"; |
|
150
|
|
|
|
|
|
|
} |
|
151
|
0
|
|
|
|
|
|
close($fh); |
|
152
|
|
|
|
|
|
|
|
|
153
|
0
|
|
|
|
|
|
$self->_parse_rnaalifold($stdout_buffer); |
|
154
|
0
|
|
|
|
|
|
rename "aln.ps", $alnps; |
|
155
|
0
|
|
|
|
|
|
rename "alirna.ps", $alirnaps; |
|
156
|
0
|
|
|
|
|
|
rename "alidot.ps", $alidotps; |
|
157
|
0
|
|
|
|
|
|
rename "RNAalifold_results.stk", $alifoldstk; |
|
158
|
0
|
|
|
|
|
|
unlink "alifold.out"; |
|
159
|
|
|
|
|
|
|
} |
|
160
|
|
|
|
|
|
|
|
|
161
|
|
|
|
|
|
|
# parse RNAalifold output |
|
162
|
|
|
|
|
|
|
sub _parse_rnaalifold { |
|
163
|
0
|
|
|
0
|
|
|
my ($self,$out) = @_; |
|
164
|
0
|
|
|
|
|
|
my $this_function = (caller(0))[3]; |
|
165
|
0
|
|
|
|
|
|
my @buffer=split(/^/, $out); |
|
166
|
|
|
|
|
|
|
|
|
167
|
0
|
|
|
|
|
|
foreach my $i (0..$#buffer){ |
|
168
|
0
|
0
|
|
|
|
|
next unless ($i == 1); # just parse consensus structure |
|
169
|
0
|
0
|
|
|
|
|
unless ($buffer[$i] =~ m/([\(\)\.]+)\s+\(\s*(-?\d+\.\d+)\s+=\s+(-?\d+\.\d+)\s+\+\s+(-?\d+\.\d+)\)\s+\[sci\s+=\s+(-?\d+\.\d+)\]/){ |
|
170
|
0
|
|
|
|
|
|
carp "ERROR [$this_function] cannot parse RNAalifold output:"; |
|
171
|
0
|
|
|
|
|
|
croak $self->ifile.":\n$buffer[$i]"; |
|
172
|
|
|
|
|
|
|
} |
|
173
|
0
|
|
|
|
|
|
$self->consensus_struc($1); |
|
174
|
0
|
|
|
|
|
|
$self->consensus_mfe($2); |
|
175
|
0
|
|
|
|
|
|
$self->consensus_energy($3); |
|
176
|
0
|
|
|
|
|
|
$self->consensus_covar_terms($4); |
|
177
|
0
|
|
|
|
|
|
$self->sci($5); |
|
178
|
0
|
|
|
|
|
|
last; |
|
179
|
|
|
|
|
|
|
} |
|
180
|
|
|
|
|
|
|
} |
|
181
|
|
|
|
|
|
|
|
|
182
|
|
|
|
|
|
|
1; |