File Coverage

blib/lib/Bio/MUST/Apps/TwoScalp/Profile2Profile.pm
Criterion Covered Total %
statement 57 76 75.0
branch 0 4 0.0
condition n/a
subroutine 19 20 95.0
pod 0 1 0.0
total 76 101 75.2


line stmt bran cond sub pod time code
1             package Bio::MUST::Apps::TwoScalp::Profile2Profile;
2             # ABSTRACT: internal class for two-scalp tool
3             # CONTRIBUTOR: Amandine BERTRAND <amandine.bertrand@doct.uliege.be>
4             # CONTRIBUTOR: Valerian LUPO <valerian.lupo@doct.uliege.be>
5             $Bio::MUST::Apps::TwoScalp::Profile2Profile::VERSION = '0.231010';
6 1     1   8 use Moose;
  1         3  
  1         7  
7 1     1   7363 use namespace::autoclean;
  1         3  
  1         10  
8              
9 1     1   111 use autodie;
  1         2  
  1         13  
10 1     1   5782 use feature qw(say);
  1         2  
  1         121  
11              
12 1     1   7 use Smart::Comments '###';
  1         3  
  1         10  
13              
14 1     1   2478 use Carp;
  1         2  
  1         89  
15 1     1   10 use List::AllUtils qw(part);
  1         3  
  1         54  
16              
17 1     1   6 use Bio::MUST::Core;
  1         2  
  1         36  
18 1     1   7 use Bio::MUST::Core::Constants qw(:gaps);
  1         4  
  1         175  
19 1     1   9 use Bio::MUST::Core::Utils qw(secure_outfile);
  1         3  
  1         61  
20              
21 1     1   7 use aliased 'Bio::MUST::Core::Ali';
  1         3  
  1         11  
22 1     1   235 use aliased 'Bio::MUST::Core::Seq';
  1         3  
  1         4  
23 1     1   193 use aliased 'Bio::MUST::Core::SeqId';
  1         6  
  1         5  
24 1     1   203 use aliased 'Bio::MUST::Core::SeqMask';
  1         3  
  1         5  
25 1     1   203 use aliased 'Bio::MUST::Drivers::Blast::Database::Temporary';
  1         2  
  1         4  
26 1     1   185 use aliased 'Bio::MUST::Drivers::Mafft';
  1         6  
  1         4  
27 1     1   178 use aliased 'Bio::MUST::Drivers::ClustalO';
  1         3  
  1         8  
28 1     1   164 use aliased 'Bio::MUST::Apps::SlaveAligner::Local';
  1         3  
  1         3  
29 1     1   186 use aliased 'Bio::MUST::Core::IdList';
  1         2  
  1         15  
30              
31              
32             has 'file1' => (
33             is => 'ro',
34             isa => 'Bio::MUST::Core::Ali',
35             required => 1,
36             coerce => 1,
37             );
38              
39             has 'file2' => (
40             is => 'ro',
41             isa => 'Bio::MUST::Core::Ali',
42             required => 1,
43             coerce => 1,
44             );
45              
46             has 'ali' => (
47             is => 'ro',
48             isa => 'Bio::MUST::Core::Ali',
49             init_arg => undef,
50             writer => '_set_ali',
51             handles => qr{.*}xms,
52             );
53              
54             has 'options' => (
55             traits => ['Hash'],
56             is => 'ro',
57             isa => 'HashRef',
58             default => sub { {} },
59             );
60              
61              
62             sub BUILD {
63 0     0 0   my $self = shift;
64              
65             # idealize to avoid shared gapped for ClustalO
66 0           my $ali1 = $self->file1->idealize;
67 0           my $ali2 = $self->file2->idealize;
68 0           my $opt = $self->options;
69              
70 0           my ($filename1, $id_mapper1) = $ali1->temp_fasta( {id_prefix => 'file1-'} );
71 0           my ($filename2, $id_mapper2) = $ali2->temp_fasta( {id_prefix => 'file2-'} );
72              
73 0           my %mapper = ( ali1 => $id_mapper1, ali2 => $id_mapper2 );
74              
75 0           my $mafft = Mafft->new( file => $filename1 );
76 0           my $ali_out = $mafft->profile2profile($filename2, $opt);
77              
78 0 0         unless (defined $ali_out){
79 0           carp 'Note: cannot align with mafft; using clustalo instead!';
80 0           my %clustal_opt;
81             $clustal_opt{ '--threads' } = $opt->{ '--thread' }
82 0 0         if $opt->{ '--thread' }; # Adapt arg to clustalo syntax
83 0           my $clustalo = ClustalO->new( file => $filename1 );
84 0           $ali_out = $clustalo->profile2profile($filename2, \%clustal_opt);
85             }
86              
87 0           $ali_out->restore_ids($mapper{ali1});
88 0           $ali_out->restore_ids($mapper{ali2});
89              
90 0           $self->_set_ali($ali_out);
91              
92 0           return;
93             }
94              
95             __PACKAGE__->meta->make_immutable;
96             1;
97              
98             __END__
99              
100             =pod
101              
102             =head1 NAME
103              
104             Bio::MUST::Apps::TwoScalp::Profile2Profile - internal class for two-scalp tool
105              
106             =head1 VERSION
107              
108             version 0.231010
109              
110             =head1 SYNOPSIS
111              
112             # TODO
113              
114             =head1 DESCRIPTION
115              
116             # TODO
117              
118             =head1 AUTHOR
119              
120             Denis BAURAIN <denis.baurain@uliege.be>
121              
122             =head1 CONTRIBUTORS
123              
124             =for stopwords Amandine BERTRAND Valerian LUPO
125              
126             =over 4
127              
128             =item *
129              
130             Amandine BERTRAND <amandine.bertrand@doct.uliege.be>
131              
132             =item *
133              
134             Valerian LUPO <valerian.lupo@doct.uliege.be>
135              
136             =back
137              
138             =head1 COPYRIGHT AND LICENSE
139              
140             This software is copyright (c) 2013 by University of Liege / Unit of Eukaryotic Phylogenomics / Denis BAURAIN.
141              
142             This is free software; you can redistribute it and/or modify it under
143             the same terms as the Perl 5 programming language system itself.
144              
145             =cut