| 1 | package Bio::FastParsers::CdHit; | ||||||||||||||||||
| 2 | # ABSTRACT: Front-end class for CD-HIT parser | ||||||||||||||||||
| 3 | # CONTRIBUTOR: Amandine BERTRAND <amandine.bertrand@doct.uliege.be> | ||||||||||||||||||
| 4 | 7 | $Bio::FastParsers::CdHit::VERSION = '0.221230'; | |||||||||||||||||
| 5 | 7 | ▶ | use Moose; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 6 | 7 | ▶ | use namespace::autoclean; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 7 | |||||||||||||||||||
| 8 | 7 | ▶ | use autodie; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 9 | |||||||||||||||||||
| 10 | 7 | ▶ | use Tie::IxHash; | ||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||
| 11 | |||||||||||||||||||
| 12 | 7 | extends 'Bio::FastParsers::Base'; | |||||||||||||||||
| 13 | |||||||||||||||||||
| 14 | |||||||||||||||||||
| 15 | # public attributes (inherited) | ||||||||||||||||||
| 16 | |||||||||||||||||||
| 17 | |||||||||||||||||||
| 18 | 7 | with 'Bio::FastParsers::Roles::Clusterable'; | |||||||||||||||||
| 19 | |||||||||||||||||||
| 20 | |||||||||||||||||||
| 21 | 1 | ▶ | sub BUILD { | ||||||||||||||||
|
Subroutine
BUILD: called CC=7 SCAR=19.5
Pod
undocumented
| |||||||||||||||||||
| 22 | 1 | my $self = shift; | |||||||||||||||||
| 23 | |||||||||||||||||||
| 24 | 1 | my $cluster_like = qr{\>Cluster \s (\d+)}xms; | |||||||||||||||||
| 25 | 1 | my $repr_id_like = qr{\d+ \t \d+\w{2}\, \s \>([\w\|\.]+) .{4} \* }xms; | |||||||||||||||||
| 26 | 1 | my $memb_id_like = qr{\d+ \t \d+\w{2}\, \s \>([\w\|\.]+) .{4} at .* \%}xms; | |||||||||||||||||
| 27 | |||||||||||||||||||
| 28 | 1 | my $infile = $self->filename; | |||||||||||||||||
| 29 | 1 | open my $in, '<', $infile; | |||||||||||||||||
| 30 | |||||||||||||||||||
| 31 | 1 | tie my %members_for, 'Tie::IxHash'; | |||||||||||||||||
| 32 | |||||||||||||||||||
| 33 | 1 | my $repr_id; | |||||||||||||||||
| 34 | my @members; | ||||||||||||||||||
| 35 | |||||||||||||||||||
| 36 | 1 | ▶ | while (my $line = <$in>) { | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 37 | 1157 | chomp $line; | |||||||||||||||||
| 38 | |||||||||||||||||||
| 39 | 1157 | ▶ | if ($line =~ $cluster_like){ | ||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||
| 40 | #### cluster: $line | ||||||||||||||||||
| 41 | 112 | ▶ | push @{ $members_for{$repr_id} }, @members | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 42 | if $repr_id; | ||||||||||||||||||
| 43 | 112 | $repr_id = q{}; | |||||||||||||||||
| 44 | 112 | @members = (); | |||||||||||||||||
| 45 | #### $repr_id | ||||||||||||||||||
| 46 | #### @members | ||||||||||||||||||
| 47 | #### %members_for | ||||||||||||||||||
| 48 | } | ||||||||||||||||||
| 49 | |||||||||||||||||||
| 50 | elsif ($line =~ $repr_id_like) { | ||||||||||||||||||
| 51 | #### reference sequence: $line | ||||||||||||||||||
| 52 | 112 | $repr_id = $1; | |||||||||||||||||
| 53 | #### $repr_id | ||||||||||||||||||
| 54 | } | ||||||||||||||||||
| 55 | |||||||||||||||||||
| 56 | # find other seq (array) | ||||||||||||||||||
| 57 | elsif ($line =~ $memb_id_like){ | ||||||||||||||||||
| 58 | #### member sequence: $line | ||||||||||||||||||
| 59 | 933 | my $memb_id = $1; | |||||||||||||||||
| 60 | 933 | push @members, $memb_id; | |||||||||||||||||
| 61 | #### @members | ||||||||||||||||||
| 62 | } | ||||||||||||||||||
| 63 | } | ||||||||||||||||||
| 64 | |||||||||||||||||||
| 65 | 1 | ▶ | push @{ $members_for{$repr_id} }, @members | ||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||
| 66 | if $repr_id; | ||||||||||||||||||
| 67 | #### %members_for | ||||||||||||||||||
| 68 | |||||||||||||||||||
| 69 | # store representative and member sequence ids | ||||||||||||||||||
| 70 | 1 | $self->_set_members_for( \%members_for ); | |||||||||||||||||
| 71 | |||||||||||||||||||
| 72 | 1 | return; | |||||||||||||||||
| 73 | } | ||||||||||||||||||
| 74 | |||||||||||||||||||
| 75 | 7 | __PACKAGE__->meta->make_immutable; | |||||||||||||||||
| 76 | 7 | 1; | |||||||||||||||||
| 77 | |||||||||||||||||||
| 78 | __END__ | ||||||||||||||||||