lib/MS/Reader/MzIdentML.pm

filter: Statementstmt 100% 9 / 9 Branchbran n/a Conditioncond n/a MC/DCmcdc n/a Subroutinesub 100% 3 / 3 Podpod n/a totaltotal 100% 12 / 12 CC 1 SCAR 0.0
CC
1
Cov
100%
BEGIN
1.0
BEGIN
1.0
BEGIN
1.0
CRAP 1.0
« lib/MS/Reader/ImzML/Spectrum.pm ↑ Summary lib/MS/Reader/MzIdentML/DBSequence.pm »
1 package MS::Reader::MzIdentML;
2  
3 2 ▶use strict;
Subroutine BEGIN: called CC=1 SCAR=0.0
4 2 ▶use warnings;
Subroutine BEGIN: called CC=1 SCAR=0.0
5  
6 2 ▶use parent qw/MS::Reader::XML/;
Subroutine BEGIN: called CC=1 SCAR=0.0
7  
8 use Carp;
9  
10 use MS::Reader::MzIdentML::SpectrumIdentificationResult;
11 use MS::Reader::MzIdentML::SequenceItem;
12 use MS::Reader::MzIdentML::DBSequence;
13 use MS::Reader::MzIdentML::Peptide;
14 use MS::Reader::MzIdentML::PeptideEvidence;
15 use MS::Reader::MzIdentML::ProteinAmbiguityGroup;
16 use MS::CV qw/:MS/;
17  
18 BEGIN {
19  
20 *fetch_peptide_by_id = \&_fetch_seqitem_by_id;
21 *fetch_peptideevidence_by_id = \&_fetch_seqitem_by_id;
22 *fetch_dbsequence_by_id = \&_fetch_seqitem_by_id;
23  
24 }
25  
26 sub _post_load {
27  
28 my ($self) = @_;
29  
30 $self->{__curr_ident_list} = 0;
31 $self->SUPER::_post_load();
32  
33 }
34  
35 sub _pre_load {
36  
37 my ($self) = @_;
38  
39 # ---------------------------------------------------------------------------#
40 # These tables are the main configuration point between the parser and the
41 # specific document schema. For more information, see the documentation
42 # for the parent class MS::Reader::XML
43 # ---------------------------------------------------------------------------#
44  
45 $self->{_toplevel} = 'MzIdentML';
46  
47 # the situation for DBSequence, Peptide, and PeptideEvidence is a bit
48 # tricky. They are all direct children of the SequenceCollection element,
49 # and the parser infrastructure currently cannot handle this easily.
50 # Instead, they will all be assigned the record type of the first element
51 # seen. Since the XSD requires at least one DBSequence item, and it should
52 # always come before the other element types, this is the type that will
53 # be used. To work around this, we point to a base SequenceItem class, and
54 # within that class figure out what type of item it is and return a
55 # specific sublclass object as appropriate.
56 $self->{__record_classes} = {
57 DBSequence => 'MS::Reader::MzIdentML::SequenceItem',
58 #Peptide => 'MS::Reader::MzIdentML::Peptide',
59 #PeptideEvidence => 'MS::Reader::MzIdentML::PeptideEvidence',
60 SpectrumIdentificationResult => 'MS::Reader::MzIdentML::SpectrumIdentificationResult',
61 ProteinAmbiguityGroup => 'MS::Reader::MzIdentML::ProteinAmbiguityGroup',
62 };
63  
64 $self->{_skip_inside} = { map {$_ => 1} qw/
65 Peptide
66 DBSequence
67 PeptideEvidence
68 SpectrumIdentificationResult
69 ProteinAmbiguityGroup
70 / };
71  
72 $self->{_make_index} = { map {$_ => 'id'} qw/
73 Peptide
74 DBSequence
75 PeptideEvidence
76 SpectrumIdentificationResult
77 ProteinAmbiguityGroup
78 / };
79  
80 # these are indexed elements with no children
81 $self->{_empty_el} = { map {$_ => 1} qw/
82 DBSequence
83 PeptideEvidence
84 / };
85  
86 $self->{_store_child_iters} = {
87 SpectrumIdentificationList => 'SpectrumIdentificationResult',
88 };
89  
90 $self->{_make_named_array} = {
91 cvParam => 'accession',
92 userParam => 'name',
93 };
94  
95 $self->{_make_named_hash} = { map {$_ => 'id'} qw/
96 AnalysisSoftware
97 BibliographicReference
98 cv
99 Enzyme
100 MassTable
101 Measure
102 Organization
103 Person
104 ProteinDetectionHypothesis
105 SampleType
106 SearchDatabase
107 SourceFile
108 SpectraData
109 SpectrumIdentification
110 SpectrumIdentificationItem
111 SpectrumIdentificationProtocol
112 TranslationTable
113 / };
114  
115 # NOTE: SpectrumIdentificationList has unique id, but make array to allow
116 # ordered selection of indexed elements
117  
118 $self->{_make_anon_array} = { map {$_ => 1} qw/
119 Affiliation
120 AmbiguousResidue
121 ContactRole
122 Filter
123 FragmentArray
124 InputSpectra
125 InputSpectrumIdentifications
126 IonType
127 PeptideHypothesis
128 Residue
129 SearchDatabaseRef
130 SearchModification
131 SpecificityRules
132 SpectrumIdentificationItemRef
133 SubSample
134 SpectrumIdentificationList
135 / };
136  
137 }
138  
139 sub fetch_spectrum_result {
140  
141 my ($self, $idx) = @_;
142 my $ref = $self->{DataCollection}->{AnalysisData}
143 ->{SpectrumIdentificationList}->[ $self->{__curr_ident_list} ];
144 return $self->fetch_record($ref => $idx);
145  
146 }
147  
148 sub fetch_protein_group {
149  
150 my ($self, $idx) = @_;
151 my $ref = $self->{DataCollection}->{AnalysisData}
152 ->{ProteinDetectionList};
153 return $self->fetch_record($ref, $idx);
154  
155 }
156  
157 sub _fetch_seqitem_by_id {
158  
159 my ($self, $id) = @_;
160 my $ref = $self->{SequenceCollection};
161 my $idx = $self->get_index_by_id($ref => $id);
162 return $self->fetch_record($ref => $idx);
163  
164 }
165  
166 sub next_spectrum_result {
167  
168 my ($self) = @_;
169 my $ref = $self->{DataCollection}->{AnalysisData}
170 ->{SpectrumIdentificationList}->[ $self->{__curr_ident_list} ];
171 return $self->next_record($ref);
172  
173 }
174  
175 sub next_protein_group {
176  
177 my ($self) = @_;
178 my $ref = $self->{DataCollection}->{AnalysisData}
179 ->{ProteinDetectionList};
180 return $self->next_record($ref);
181  
182 }
183  
184 sub n_ident_lists {
185  
186 my ($self) = @_;
187 return scalar @{ $self->{DataCollection}->{AnalysisData}
188 ->{SpectrumIdentificationList} };
189  
190 }
191  
192 sub goto_ident_list {
193  
194 my ($self, $idx) = @_;
195 $self->{__curr_ident_list} = $idx;
196 my $ref = $self->{DataCollection}->{AnalysisData}
197 ->{SpectrumIdentificationList}->[ $self->{__curr_ident_list} ];
198 $ref->{__pos} = 0;
199 return(1); # otherwise returns zero, causing tests to fail
200  
201 }
202  
203 sub raw_file {
204  
205 my ($self, $id) = @_;
206 return $self->{DataCollection}->{Inputs}
207 ->{SpectraData}->{$id}->{location} ;
208  
209 }
210  
211 1;
212  
213 __END__
« lib/MS/Reader/ImzML/Spectrum.pm ↑ Summary lib/MS/Reader/MzIdentML/DBSequence.pm »