File Coverage

blib/lib/Bio/MUST/Drivers/ClustalO.pm
Criterion Covered Total %
statement 33 60 55.0
branch 0 12 0.0
condition 0 2 0.0
subroutine 11 15 73.3
pod 0 3 0.0
total 44 92 47.8


line stmt bran cond sub pod time code
1             package Bio::MUST::Drivers::ClustalO;
2             # ABSTRACT: Bio::MUST driver for running the Clustal Omega program
3             # CONTRIBUTOR: Amandine BERTRAND <amandine.bertrand@doct.uliege.be>
4             $Bio::MUST::Drivers::ClustalO::VERSION = '0.193030';
5 6     6   3982138 use Moose;
  6         21  
  6         46  
6 6     6   53091 use namespace::autoclean;
  6         16  
  6         62  
7              
8 6     6   520 use autodie;
  6         15  
  6         53  
9 6     6   29420 use feature qw(say);
  6         14  
  6         556  
10              
11             # use Smart::Comments;
12              
13 6     6   38 use Carp;
  6         14  
  6         594  
14 6     6   38 use IPC::System::Simple qw(system);
  6         14  
  6         284  
15 6     6   43 use Module::Runtime qw(use_module);
  6         13  
  6         50  
16 6     6   498 use Path::Class qw(file);
  6         13  
  6         343  
17              
18 6     6   37 use Bio::MUST::Core;
  6         12  
  6         286  
19             extends 'Bio::FastParsers::Base';
20              
21 6     6   627 use Bio::MUST::Drivers::Utils qw(stringify_args);
  6         16  
  6         322  
22 6     6   41 use aliased 'Bio::MUST::Core::Ali';
  6         14  
  6         71  
23              
24              
25             sub align_all { ## no critic (RequireArgUnpacking)
26             #### in align_all
27 0     0 0   return shift->_clustalo('align_all', @_);
28             }
29              
30             sub seqs2profile { ## no critic (RequireArgUnpacking)
31             #### in seqs2profile
32 0     0 0   my $self = shift;
33              
34 0 0         carp '[BMD] Warning: align seqs before aligning on profile!'
35             unless Ali->load( $self->file )->is_aligned;
36 0           return $self->_clustalo('seqs2profile', @_);
37             }
38              
39             sub profile2profile { ## no critic (RequireArgUnpacking)
40             #### in profile2profile
41 0     0 0   return shift->_clustalo('profile2profile', @_);
42             }
43              
44             sub _clustalo {
45             #### in _clustalo
46              
47 0     0     my $self = shift;
48 0           my $mode = shift;
49 0           my $profile; # conditional declaring is bad...
50 0 0         $profile = shift unless $mode eq 'align_all';
51 0   0       my $args = shift // {};
52              
53             # provision executable
54 0           my $app = use_module('Bio::MUST::Provision::ClustalO')->new;
55 0           $app->meet();
56              
57             # setup input/output files
58 0           my $infile = $self->filename;
59 0           my $outfile = $infile . '.clustalo';
60              
61 0           $args->{-o} = $outfile;
62 0 0         $args->{ $mode eq 'profile2profile' ? '--p1' : '-i' } = $infile;
63 0 0         $args->{ $mode eq 'profile2profile' ? '--p2' : '--p1' } = $profile
    0          
64             if $profile;
65              
66 0           my $args_str = stringify_args($args);
67              
68             # create clustalo command
69 0           my $pgm = 'clustalo';
70 0           my $cmd = join q{ }, $pgm, $args_str, '2> /dev/null';
71             #### $cmd
72              
73             # try to robustly execute clustalo
74 0           my $ret_code = system( [ 0, 127 ], $cmd);
75 0 0         if ($ret_code == 127) {
76 0           carp "[BMD] Warning: cannot execute $pgm command; returning nothing!";
77 0           return;
78             }
79              
80 0           my $out = Ali->load($outfile);
81             # TODO: try to bypass shell (need for absolute path to executable then)
82              
83             # unlink temp file
84 0           file($outfile)->remove;
85              
86             # return Ali
87 0           return $out;
88             }
89              
90             __PACKAGE__->meta->make_immutable;
91             1;
92              
93             __END__
94              
95             =pod
96              
97             =head1 NAME
98              
99             Bio::MUST::Drivers::ClustalO - Bio::MUST driver for running the Clustal Omega program
100              
101             =head1 VERSION
102              
103             version 0.193030
104              
105             =head1 SYNOPSIS
106              
107             # TODO
108              
109             =head1 DESCRIPTION
110              
111             # TODO
112              
113             =head1 AUTHOR
114              
115             Denis BAURAIN <denis.baurain@uliege.be>
116              
117             =head1 CONTRIBUTOR
118              
119             =for stopwords Amandine BERTRAND
120              
121             Amandine BERTRAND <amandine.bertrand@doct.uliege.be>
122              
123             =head1 COPYRIGHT AND LICENSE
124              
125             This software is copyright (c) 2013 by University of Liege / Unit of Eukaryotic Phylogenomics / Denis BAURAIN.
126              
127             This is free software; you can redistribute it and/or modify it under
128             the same terms as the Perl 5 programming language system itself.
129              
130             =cut