| line | stmt | bran | cond | sub | pod | time | code | 
| 1 |  |  |  |  |  |  | # ABSTRACT: Internal class for standard HMMER parser | 
| 2 |  |  |  |  |  |  | # CONTRIBUTOR: Arnaud DI FRANCO <arnaud.difranco@gmail.com> | 
| 3 |  |  |  |  |  |  | $Bio::FastParsers::Hmmer::Standard::Domain::VERSION = '0.221230'; | 
| 4 |  |  |  |  |  |  | use Moose; | 
| 5 | 7 |  |  | 7 |  | 3678 | use namespace::autoclean; | 
|  | 7 |  |  |  |  | 16 |  | 
|  | 7 |  |  |  |  | 44 |  | 
| 6 | 7 |  |  | 7 |  | 39002 |  | 
|  | 7 |  |  |  |  | 24 |  | 
|  | 7 |  |  |  |  | 45 |  | 
| 7 |  |  |  |  |  |  | use List::AllUtils qw(mesh); | 
| 8 | 7 |  |  | 7 |  | 536 |  | 
|  | 7 |  |  |  |  | 17 |  | 
|  | 7 |  |  |  |  | 5039 |  | 
| 9 |  |  |  |  |  |  |  | 
| 10 |  |  |  |  |  |  | # public attributes | 
| 11 |  |  |  |  |  |  |  | 
| 12 |  |  |  |  |  |  | has $_ => ( | 
| 13 |  |  |  |  |  |  | is       => 'ro', | 
| 14 |  |  |  |  |  |  | isa      => 'Str', | 
| 15 |  |  |  |  |  |  | required => 1, | 
| 16 |  |  |  |  |  |  | ) for qw(seq scoreseq profile probabilities); | 
| 17 |  |  |  |  |  |  |  | 
| 18 |  |  |  |  |  |  | with 'Bio::FastParsers::Roles::Domainable'; | 
| 19 |  |  |  |  |  |  |  | 
| 20 |  |  |  |  |  |  | around BUILDARGS => sub { | 
| 21 |  |  |  |  |  |  | my ($orig, $class, $inargs) = @_; | 
| 22 |  |  |  |  |  |  |  | 
| 23 |  |  |  |  |  |  | my @raw = @{ $inargs->{raw} }; | 
| 24 |  |  |  |  |  |  | my $summary = $inargs->{summary}; | 
| 25 |  |  |  |  |  |  |  | 
| 26 |  |  |  |  |  |  | my %outargs; | 
| 27 |  |  |  |  |  |  |  | 
| 28 |  |  |  |  |  |  | # parse header | 
| 29 |  |  |  |  |  |  | my @header_vals = $raw[0] =~ m/([\d\.]+)/xmsg; | 
| 30 |  |  |  |  |  |  | $outargs{'rank'}      = $header_vals[0]; | 
| 31 |  |  |  |  |  |  | $outargs{'dom_score'} = $header_vals[1]; | 
| 32 |  |  |  |  |  |  | $outargs{'c_evalue'} | 
| 33 |  |  |  |  |  |  | = @header_vals == 3 ? $header_vals[2] : join 'e-', @header_vals[2,3] | 
| 34 |  |  |  |  |  |  | ; | 
| 35 |  |  |  |  |  |  |  | 
| 36 |  |  |  |  |  |  | # coerce numeric fields to numbers | 
| 37 |  |  |  |  |  |  | %outargs = map { $_ => 0 + $outargs{$_} } keys %outargs; | 
| 38 |  |  |  |  |  |  |  | 
| 39 |  |  |  |  |  |  | # parse domain alignment | 
| 40 |  |  |  |  |  |  |  | 
| 41 |  |  |  |  |  |  | # Alignment is made of 4 lines: best match to profile, scoring | 
| 42 |  |  |  |  |  |  | # correspondance, sequence alignment and posterior predictive. Each line | 
| 43 |  |  |  |  |  |  | # is shifted to the right by the same amount of characters, which is | 
| 44 |  |  |  |  |  |  | # different for each target. To get the size of the shift, I insert | 
| 45 |  |  |  |  |  |  | # special characters on the seqline and split on hit. Each part gives the | 
| 46 |  |  |  |  |  |  | # right length to extract correctly the information. | 
| 47 |  |  |  |  |  |  |  | 
| 48 |  |  |  |  |  |  | my $profileline = $raw[1]; | 
| 49 |  |  |  |  |  |  | my $scoreline = $raw[2]; | 
| 50 |  |  |  |  |  |  | my $probline = $raw[4]; | 
| 51 |  |  |  |  |  |  | ( my $seqline = $raw[3] ) | 
| 52 |  |  |  |  |  |  | =~ s{(^\s+.*\s+\d+\s+)(\S+)\s\d+\s*$}{$1\|\|\|$2}xms; | 
| 53 |  |  |  |  |  |  | chomp $seqline; | 
| 54 |  |  |  |  |  |  | my ($skip, $tmpseq) = split /\|{3}/xms, $seqline; | 
| 55 |  |  |  |  |  |  | my $scoreseq = substr $scoreline, length $skip, length $tmpseq; | 
| 56 |  |  |  |  |  |  | my $profileseq = substr $profileline, length $skip, length $tmpseq; | 
| 57 |  |  |  |  |  |  | my $probabilities = substr $probline, length $skip, length $tmpseq; | 
| 58 |  |  |  |  |  |  | $outargs{'seq'} = $tmpseq; | 
| 59 |  |  |  |  |  |  | $outargs{'scoreseq'} = $scoreseq; | 
| 60 |  |  |  |  |  |  | $outargs{'profile'} = $profileseq; | 
| 61 |  |  |  |  |  |  | $outargs{'probabilities'} = $probabilities; | 
| 62 |  |  |  |  |  |  |  | 
| 63 |  |  |  |  |  |  | # attributes from summary domtbl | 
| 64 |  |  |  |  |  |  | my @summary_attrs = qw( | 
| 65 |  |  |  |  |  |  | dom_bias i_evalue | 
| 66 |  |  |  |  |  |  | hmm_from hmm_to | 
| 67 |  |  |  |  |  |  | ali_from ali_to | 
| 68 |  |  |  |  |  |  | env_from env_to | 
| 69 |  |  |  |  |  |  | acc | 
| 70 |  |  |  |  |  |  | ); | 
| 71 |  |  |  |  |  |  | my @summary_slots = qw(4 6 7 8 10 11 13 14 16); | 
| 72 |  |  |  |  |  |  |  | 
| 73 |  |  |  |  |  |  | # parse summary | 
| 74 |  |  |  |  |  |  | # and coerce numeric fields to numbers | 
| 75 |  |  |  |  |  |  | my @fields = split /\s+/xms, $summary; | 
| 76 |  |  |  |  |  |  | my @summary_vals = map { 0 + $fields[$_] } @summary_slots; | 
| 77 |  |  |  |  |  |  | my %summary_hash = mesh @summary_attrs, @summary_vals; | 
| 78 |  |  |  |  |  |  |  | 
| 79 |  |  |  |  |  |  | # return expected constructor hash | 
| 80 |  |  |  |  |  |  | return $class->$orig( %outargs, %summary_hash ); | 
| 81 |  |  |  |  |  |  | }; | 
| 82 |  |  |  |  |  |  |  | 
| 83 |  |  |  |  |  |  | # TODO: check if this could not be avoided | 
| 84 |  |  |  |  |  |  | #       as this looks like code duplication with Bio::MUST::Core | 
| 85 |  |  |  |  |  |  | #       This one too ? | 
| 86 |  |  |  |  |  |  |  | 
| 87 |  |  |  |  |  |  | my $self   = shift; | 
| 88 |  |  |  |  |  |  | my $tmpseq = $self->seq; | 
| 89 | 3 |  |  | 3 | 0 | 13 | my $score  = $self->scoreseq; | 
| 90 | 3 |  |  |  |  | 78 |  | 
| 91 | 3 |  |  |  |  | 81 | # Need brackets or else pos == 1 | 
| 92 |  |  |  |  |  |  | while ( (my $pos = index($tmpseq, '-') ) != -1 ) { | 
| 93 |  |  |  |  |  |  | substr $tmpseq, $pos, 1, q{}; | 
| 94 | 3 |  |  |  |  | 11 | substr $score,  $pos, 1, q{}; | 
| 95 | 87 |  |  |  |  | 127 | } | 
| 96 | 87 |  |  |  |  | 157 |  | 
| 97 |  |  |  |  |  |  | return $score; | 
| 98 |  |  |  |  |  |  | } | 
| 99 | 3 |  |  |  |  | 14 |  | 
| 100 |  |  |  |  |  |  |  | 
| 101 |  |  |  |  |  |  | # aliases | 
| 102 |  |  |  |  |  |  |  | 
| 103 |  |  |  |  |  |  | return shift->c_evalue; | 
| 104 |  |  |  |  |  |  | } | 
| 105 |  |  |  |  |  |  |  | 
| 106 | 12 |  |  | 12 | 0 | 381 | return shift->dom_score; | 
| 107 |  |  |  |  |  |  | } | 
| 108 |  |  |  |  |  |  |  | 
| 109 |  |  |  |  |  |  | return shift->number; | 
| 110 | 12 |  |  | 12 | 0 | 6890 | } | 
| 111 |  |  |  |  |  |  |  | 
| 112 |  |  |  |  |  |  | return shift->number-1; | 
| 113 |  |  |  |  |  |  | } | 
| 114 | 0 |  |  | 0 | 0 |  |  | 
| 115 |  |  |  |  |  |  | __PACKAGE__->meta->make_immutable; | 
| 116 |  |  |  |  |  |  | 1; | 
| 117 |  |  |  |  |  |  |  | 
| 118 | 0 |  |  | 0 | 0 |  |  | 
| 119 |  |  |  |  |  |  | =pod | 
| 120 |  |  |  |  |  |  |  | 
| 121 |  |  |  |  |  |  | =head1 NAME | 
| 122 |  |  |  |  |  |  |  | 
| 123 |  |  |  |  |  |  | Bio::FastParsers::Hmmer::Standard::Domain - Internal class for standard HMMER parser | 
| 124 |  |  |  |  |  |  |  | 
| 125 |  |  |  |  |  |  | =head1 VERSION | 
| 126 |  |  |  |  |  |  |  | 
| 127 |  |  |  |  |  |  | version 0.221230 | 
| 128 |  |  |  |  |  |  |  | 
| 129 |  |  |  |  |  |  | =head1 SYNOPSIS | 
| 130 |  |  |  |  |  |  |  | 
| 131 |  |  |  |  |  |  | # TODO | 
| 132 |  |  |  |  |  |  |  | 
| 133 |  |  |  |  |  |  | =head1 DESCRIPTION | 
| 134 |  |  |  |  |  |  |  | 
| 135 |  |  |  |  |  |  | # TODO | 
| 136 |  |  |  |  |  |  |  | 
| 137 |  |  |  |  |  |  | =head1 AUTHOR | 
| 138 |  |  |  |  |  |  |  | 
| 139 |  |  |  |  |  |  | Denis BAURAIN <denis.baurain@uliege.be> | 
| 140 |  |  |  |  |  |  |  | 
| 141 |  |  |  |  |  |  | =head1 CONTRIBUTOR | 
| 142 |  |  |  |  |  |  |  | 
| 143 |  |  |  |  |  |  | =for stopwords Arnaud DI FRANCO | 
| 144 |  |  |  |  |  |  |  | 
| 145 |  |  |  |  |  |  | Arnaud DI FRANCO <arnaud.difranco@gmail.com> | 
| 146 |  |  |  |  |  |  |  | 
| 147 |  |  |  |  |  |  | =head1 COPYRIGHT AND LICENSE | 
| 148 |  |  |  |  |  |  |  | 
| 149 |  |  |  |  |  |  | This software is copyright (c) 2013 by University of Liege / Unit of Eukaryotic Phylogenomics / Denis BAURAIN. | 
| 150 |  |  |  |  |  |  |  | 
| 151 |  |  |  |  |  |  | This is free software; you can redistribute it and/or modify it under | 
| 152 |  |  |  |  |  |  | the same terms as the Perl 5 programming language system itself. | 
| 153 |  |  |  |  |  |  |  | 
| 154 |  |  |  |  |  |  | =cut |