line |
stmt |
bran |
cond |
sub |
pod |
time |
code |
1
|
|
|
|
|
|
|
# ABSTRACT: Attributes and methods common to CD-HIT and UCLUST drivers |
2
|
|
|
|
|
|
|
# CONTRIBUTOR: Amandine BERTRAND <amandine.bertrand@doct.uliege.be> |
3
|
|
|
|
|
|
|
$Bio::FastParsers::Roles::Clusterable::VERSION = '0.221230'; |
4
|
|
|
|
|
|
|
use Moose::Role; |
5
|
7
|
|
|
7
|
|
4014
|
|
|
7
|
|
|
|
|
31
|
|
|
7
|
|
|
|
|
63
|
|
6
|
|
|
|
|
|
|
use autodie; |
7
|
7
|
|
|
7
|
|
33866
|
use feature qw(say); |
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
53
|
|
8
|
7
|
|
|
7
|
|
32371
|
|
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
634
|
|
9
|
|
|
|
|
|
|
use Carp; |
10
|
7
|
|
|
7
|
|
43
|
use Sort::Naturally; |
|
7
|
|
|
|
|
16
|
|
|
7
|
|
|
|
|
555
|
|
11
|
7
|
|
|
7
|
|
3997
|
use Try::Tiny; |
|
7
|
|
|
|
|
24143
|
|
|
7
|
|
|
|
|
454
|
|
12
|
7
|
|
|
7
|
|
59
|
|
|
7
|
|
|
|
|
18
|
|
|
7
|
|
|
|
|
2388
|
|
13
|
|
|
|
|
|
|
|
14
|
|
|
|
|
|
|
# private attributes |
15
|
|
|
|
|
|
|
|
16
|
|
|
|
|
|
|
has '_members_for' => ( |
17
|
|
|
|
|
|
|
traits => ['Hash'], |
18
|
|
|
|
|
|
|
is => 'ro', |
19
|
|
|
|
|
|
|
isa => 'HashRef[ArrayRef[Str]]', |
20
|
|
|
|
|
|
|
init_arg => undef, |
21
|
|
|
|
|
|
|
writer => '_set_members_for', |
22
|
|
|
|
|
|
|
handles => { |
23
|
|
|
|
|
|
|
all_representatives => 'keys', |
24
|
|
|
|
|
|
|
members_for => 'get', |
25
|
|
|
|
|
|
|
}, |
26
|
|
|
|
|
|
|
); |
27
|
|
|
|
|
|
|
|
28
|
|
|
|
|
|
|
my $self = shift; |
29
|
|
|
|
|
|
|
|
30
|
2
|
|
|
2
|
0
|
3179
|
# sort first on descending cluster size then on representative id |
31
|
|
|
|
|
|
|
# using natural sort and the Schwartzian transform |
32
|
|
|
|
|
|
|
my @list = map { $_->[1] } |
33
|
|
|
|
|
|
|
sort { $b->[0] <=> $a->[0] || ncmp($a->[1], $b->[1]) } |
34
|
134
|
|
|
|
|
296
|
map { [ scalar @{ $self->members_for($_) }, $_ ] } |
35
|
664
|
50
|
|
|
|
30337
|
$self->all_representatives |
36
|
2
|
|
|
|
|
84
|
; |
|
134
|
|
|
|
|
1169
|
|
|
134
|
|
|
|
|
4000
|
|
37
|
|
|
|
|
|
|
|
38
|
|
|
|
|
|
|
return @list; |
39
|
|
|
|
|
|
|
} |
40
|
2
|
|
|
|
|
51
|
|
41
|
|
|
|
|
|
|
|
42
|
|
|
|
|
|
|
my $self = shift; |
43
|
|
|
|
|
|
|
my $sep = shift // q{/}; |
44
|
|
|
|
|
|
|
|
45
|
0
|
|
|
0
|
0
|
|
# do not force Bio::FastParsers to depend on Bio::MUST::Core |
46
|
0
|
|
0
|
|
|
|
my $bmc = try { require Bio::MUST::Core } |
47
|
|
|
|
|
|
|
catch { return } |
48
|
|
|
|
|
|
|
; |
49
|
0
|
|
|
0
|
|
|
unless ($bmc) { |
50
|
0
|
|
|
0
|
|
|
carp 'Warning: Bio::MUST::Core not installed; returning nothing!'; |
51
|
0
|
|
|
|
|
|
return; |
52
|
0
|
0
|
|
|
|
|
} |
53
|
0
|
|
|
|
|
|
|
54
|
0
|
|
|
|
|
|
my @abbr_ids; |
55
|
|
|
|
|
|
|
my @long_ids; |
56
|
|
|
|
|
|
|
|
57
|
0
|
|
|
|
|
|
for my $repr ( $self->all_representatives_by_cluster_size ) { |
58
|
|
|
|
|
|
|
push @abbr_ids, $repr; |
59
|
|
|
|
|
|
|
push @long_ids, join $sep, |
60
|
0
|
|
|
|
|
|
nsort ( @{ $self->members_for($repr) }, $repr ) |
61
|
0
|
|
|
|
|
|
; |
62
|
|
|
|
|
|
|
} |
63
|
0
|
|
|
|
|
|
|
|
0
|
|
|
|
|
|
|
64
|
|
|
|
|
|
|
return Bio::MUST::Core::IdMapper->new( |
65
|
|
|
|
|
|
|
abbr_ids => \@abbr_ids, |
66
|
|
|
|
|
|
|
long_ids => \@long_ids, |
67
|
0
|
|
|
|
|
|
); |
68
|
|
|
|
|
|
|
} |
69
|
|
|
|
|
|
|
|
70
|
|
|
|
|
|
|
no Moose::Role; |
71
|
|
|
|
|
|
|
1; |
72
|
|
|
|
|
|
|
|
73
|
7
|
|
|
7
|
|
59
|
|
|
7
|
|
|
|
|
17
|
|
|
7
|
|
|
|
|
67
|
|
74
|
|
|
|
|
|
|
=pod |
75
|
|
|
|
|
|
|
|
76
|
|
|
|
|
|
|
=head1 NAME |
77
|
|
|
|
|
|
|
|
78
|
|
|
|
|
|
|
Bio::FastParsers::Roles::Clusterable - Attributes and methods common to CD-HIT and UCLUST drivers |
79
|
|
|
|
|
|
|
|
80
|
|
|
|
|
|
|
=head1 VERSION |
81
|
|
|
|
|
|
|
|
82
|
|
|
|
|
|
|
version 0.221230 |
83
|
|
|
|
|
|
|
|
84
|
|
|
|
|
|
|
=head1 DESCRIPTION |
85
|
|
|
|
|
|
|
|
86
|
|
|
|
|
|
|
This role implements the attributes and methods that are common to CD-HIT and |
87
|
|
|
|
|
|
|
UCLUST parsers. Those are documented in their respective modules: |
88
|
|
|
|
|
|
|
L<Bio::FastParsers::CdHit> and L<Bio::FastParsers::Uclust>. |
89
|
|
|
|
|
|
|
|
90
|
|
|
|
|
|
|
Available methods are: C<all_representatives>, |
91
|
|
|
|
|
|
|
C<all_representatives_by_cluster_size>, C<members_for> and C<clust_mapper>. |
92
|
|
|
|
|
|
|
|
93
|
|
|
|
|
|
|
=head1 AUTHOR |
94
|
|
|
|
|
|
|
|
95
|
|
|
|
|
|
|
Denis BAURAIN <denis.baurain@uliege.be> |
96
|
|
|
|
|
|
|
|
97
|
|
|
|
|
|
|
=head1 CONTRIBUTOR |
98
|
|
|
|
|
|
|
|
99
|
|
|
|
|
|
|
=for stopwords Amandine BERTRAND |
100
|
|
|
|
|
|
|
|
101
|
|
|
|
|
|
|
Amandine BERTRAND <amandine.bertrand@doct.uliege.be> |
102
|
|
|
|
|
|
|
|
103
|
|
|
|
|
|
|
=head1 COPYRIGHT AND LICENSE |
104
|
|
|
|
|
|
|
|
105
|
|
|
|
|
|
|
This software is copyright (c) 2013 by University of Liege / Unit of Eukaryotic Phylogenomics / Denis BAURAIN. |
106
|
|
|
|
|
|
|
|
107
|
|
|
|
|
|
|
This is free software; you can redistribute it and/or modify it under |
108
|
|
|
|
|
|
|
the same terms as the Perl 5 programming language system itself. |
109
|
|
|
|
|
|
|
|
110
|
|
|
|
|
|
|
=cut |