| 1 | package MS::Reader::PepXML::Result; | ||
| 2 | |||
| 3 | 1 | ▶ | use strict; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 4 | 1 | ▶ | use warnings; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 5 | |||
| 6 | 1 | ▶ | use Data::Dumper; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 7 | 1 | ▶ | use MS::Mass qw/aa_mass elem_mass/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 8 | |||
| 9 | 1 | ▶ | use parent qw/MS::Reader::XML::Record/; |
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||
| 10 | |||
| 11 | # Lookup tables to quickly check elements | ||
| 12 | |||
| 13 | sub _pre_load { | ||
| 14 | |||
| 15 | my ($self) = @_; | ||
| 16 | |||
| 17 | $self->{_toplevel} = 'spectrum_query'; | ||
| 18 | |||
| 19 | $self->{_make_named_hash} = { map {$_ => 'name'} qw/ | ||
| 20 | parameter | ||
| 21 | search_score | ||
| 22 | / }; | ||
| 23 | |||
| 24 | $self->{_make_anon_array} = { map {$_ => 1} qw/ | ||
| 25 | search_result | ||
| 26 | search_hit | ||
| 27 | search_id | ||
| 28 | alternative_protein | ||
| 29 | mod_aminoacid_mass | ||
| 30 | analysis_result | ||
| 31 | / }; | ||
| 32 | |||
| 33 | } | ||
| 34 | |||
| 35 | sub get_hit { | ||
| 36 | |||
| 37 | my ($self, $idx) = @_; | ||
| 38 | $idx //= 0; | ||
| 39 | return $self->{search_result}->[0]->{search_hit}->[$idx]; | ||
| 40 | |||
| 41 | } | ||
| 42 | |||
| 43 | sub mod_delta_array { | ||
| 44 | |||
| 45 | my ($self, $hit) = @_; | ||
| 46 | $hit = $hit // 0; | ||
| 47 | $hit = $self->{search_result}->[0]->{search_hit}->[$hit]; | ||
| 48 | my $pep = $hit->{peptide}; | ||
| 49 | my @deltas = (0) x (length($pep)+2); | ||
| 50 | $deltas[0] += $hit->{modification_info}->{mod_nterm_mass} - elem_mass('H') | ||
| 51 | if (defined $hit->{modification_info}->{mod_nterm_mass}); | ||
| 52 | $deltas[-1] += $hit->{modification_info}->{mod_cterm_mass} - elem_mass('OH') | ||
| 53 | if (defined $hit->{modification_info}->{mod_cterm_mass}); | ||
| 54 | for my $mod (@{ $hit->{modification_info}->{mod_aminoacid_mass} }) { | ||
| 55 | my $pos = $mod->{position}; | ||
| 56 | my $mass = $mod->{mass} - aa_mass( substr $pep, $pos-1, 1 ); | ||
| 57 | $deltas[$pos] += $mass; | ||
| 58 | } | ||
| 59 | return \@deltas; | ||
| 60 | |||
| 61 | } | ||
| 62 | |||
| 63 | sub dump { | ||
| 64 | |||
| 65 | my ($self) = @_; | ||
| 66 | |||
| 67 | my $copy = {}; | ||
| 68 | %$copy = %$self; | ||
| 69 | |||
| 70 | delete $copy->{$_} | ||
| 71 | for qw/use_cache/; | ||
| 72 | |||
| 73 | my $dump = ''; | ||
| 74 | |||
| 75 | { | ||
| 76 | local $Data::Dumper::Indent = 1; | ||
| 77 | local $Data::Dumper::Terse = 1; | ||
| 78 | local $Data::Dumper::Sortkeys = 1; | ||
| 79 | $dump = Dumper $copy; | ||
| 80 | } | ||
| 81 | |||
| 82 | return $dump; | ||
| 83 | |||
| 84 | } | ||
| 85 | |||
| 86 | 1; | ||
| 87 | |||
| 88 | __END__ | ||