| 1 | # BioPerl module for Bio::SeqIO::seqxml | ||||||||||||||||||||||||||||||||||||||||||
| 2 | # | ||||||||||||||||||||||||||||||||||||||||||
| 3 | # Please direct questions and support issues to <bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||||||||||||
| 4 | # | ||||||||||||||||||||||||||||||||||||||||||
| 5 | # Cared for by Dave Messina <dmessina@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||
| 6 | # | ||||||||||||||||||||||||||||||||||||||||||
| 7 | # Copyright Dave Messina | ||||||||||||||||||||||||||||||||||||||||||
| 8 | # | ||||||||||||||||||||||||||||||||||||||||||
| 9 | # You may distribute this module under the same terms as perl itself | ||||||||||||||||||||||||||||||||||||||||||
| 10 | # _history | ||||||||||||||||||||||||||||||||||||||||||
| 11 | # December 2009 - initial version | ||||||||||||||||||||||||||||||||||||||||||
| 12 | # July 2 2010 - updated for SeqXML v0.2 | ||||||||||||||||||||||||||||||||||||||||||
| 13 | # November 11 2010 - added schemaLocation | ||||||||||||||||||||||||||||||||||||||||||
| 14 | # December 9 2010 - SeqXML v0.3 | ||||||||||||||||||||||||||||||||||||||||||
| 15 | # | ||||||||||||||||||||||||||||||||||||||||||
| 16 | |||||||||||||||||||||||||||||||||||||||||||
| 17 | # POD documentation - main docs before the code | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | Bio::SeqIO::seqxml - SeqXML sequence input/output stream | ||||||||||||||||||||||||||||||||||||||||||
| 22 | |||||||||||||||||||||||||||||||||||||||||||
| 23 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 24 | |||||||||||||||||||||||||||||||||||||||||||
| 25 | # Do not use this module directly. Use it via the Bio::SeqIO class. | ||||||||||||||||||||||||||||||||||||||||||
| 26 | |||||||||||||||||||||||||||||||||||||||||||
| 27 | use Bio::SeqIO; | ||||||||||||||||||||||||||||||||||||||||||
| 28 | |||||||||||||||||||||||||||||||||||||||||||
| 29 | # read a SeqXML file | ||||||||||||||||||||||||||||||||||||||||||
| 30 | my $seqio = Bio::SeqIO->new(-format => 'seqxml', | ||||||||||||||||||||||||||||||||||||||||||
| 31 | -file => 'my_seqs.xml'); | ||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||
| 33 | while (my $seq_object = $seqio->next_seq) { | ||||||||||||||||||||||||||||||||||||||||||
| 34 | print join("\t", | ||||||||||||||||||||||||||||||||||||||||||
| 35 | $seq_object->display_id, | ||||||||||||||||||||||||||||||||||||||||||
| 36 | $seq_object->description, | ||||||||||||||||||||||||||||||||||||||||||
| 37 | $seq_object->seq, | ||||||||||||||||||||||||||||||||||||||||||
| 38 | ), "\n"; | ||||||||||||||||||||||||||||||||||||||||||
| 39 | } | ||||||||||||||||||||||||||||||||||||||||||
| 40 | |||||||||||||||||||||||||||||||||||||||||||
| 41 | # write a SeqXML file | ||||||||||||||||||||||||||||||||||||||||||
| 42 | # | ||||||||||||||||||||||||||||||||||||||||||
| 43 | # Note that you can (optionally) specify the source | ||||||||||||||||||||||||||||||||||||||||||
| 44 | # (usually a database) and source version. | ||||||||||||||||||||||||||||||||||||||||||
| 45 | my $seqwriter = Bio::SeqIO->new(-format => 'seqxml', | ||||||||||||||||||||||||||||||||||||||||||
| 46 | -file => ">outfile.xml", | ||||||||||||||||||||||||||||||||||||||||||
| 47 | -source => 'Ensembl', | ||||||||||||||||||||||||||||||||||||||||||
| 48 | -sourceVersion => '56'); | ||||||||||||||||||||||||||||||||||||||||||
| 49 | $seqwriter->write_seq($seq_object); | ||||||||||||||||||||||||||||||||||||||||||
| 50 | |||||||||||||||||||||||||||||||||||||||||||
| 51 | # once you've written all of your seqs, you may want to do | ||||||||||||||||||||||||||||||||||||||||||
| 52 | # an explicit close to get the closing </seqXML> tag | ||||||||||||||||||||||||||||||||||||||||||
| 53 | $seqwriter->close; | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | This object can transform Bio::Seq objects to and from SeqXML format. | ||||||||||||||||||||||||||||||||||||||||||
| 58 | For more information on the SeqXML standard, visit L<http://www.seqxml.org>. | ||||||||||||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||||||||||||
| 60 | In short, SeqXML is a lightweight sequence format that takes advantage | ||||||||||||||||||||||||||||||||||||||||||
| 61 | of the validation capabilities of XML while not overburdening you | ||||||||||||||||||||||||||||||||||||||||||
| 62 | with a strict and complicated schema. | ||||||||||||||||||||||||||||||||||||||||||
| 63 | |||||||||||||||||||||||||||||||||||||||||||
| 64 | This module is based in part (particularly the XML-parsing part) on | ||||||||||||||||||||||||||||||||||||||||||
| 65 | Bio::TreeIO::phyloxml by Mira Han. | ||||||||||||||||||||||||||||||||||||||||||
| 66 | |||||||||||||||||||||||||||||||||||||||||||
| 67 | =head1 FEEDBACK | ||||||||||||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||||||||||||
| 69 | =head2 Mailing Lists | ||||||||||||||||||||||||||||||||||||||||||
| 70 | |||||||||||||||||||||||||||||||||||||||||||
| 71 | User feedback is an integral part of the evolution of this and other | ||||||||||||||||||||||||||||||||||||||||||
| 72 | Bioperl modules. Send your comments and suggestions preferably to one | ||||||||||||||||||||||||||||||||||||||||||
| 73 | of the Bioperl mailing lists. Your participation is much appreciated. | ||||||||||||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||||||||||||
| 75 | bioperl-l@bioperl.org - General discussion | ||||||||||||||||||||||||||||||||||||||||||
| 76 | http://bioperl.org/wiki/Mailing_lists - About the mailing lists | ||||||||||||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||||||||||||
| 78 | =head2 Support | ||||||||||||||||||||||||||||||||||||||||||
| 79 | |||||||||||||||||||||||||||||||||||||||||||
| 80 | Please direct usage questions or support issues to the mailing list: | ||||||||||||||||||||||||||||||||||||||||||
| 81 | |||||||||||||||||||||||||||||||||||||||||||
| 82 | I<bioperl-l@bioperl.org> | ||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||
| 84 | rather than to the module maintainer directly. Many experienced and | ||||||||||||||||||||||||||||||||||||||||||
| 85 | reponsive experts will be able look at the problem and quickly | ||||||||||||||||||||||||||||||||||||||||||
| 86 | address it. Please include a thorough description of the problem | ||||||||||||||||||||||||||||||||||||||||||
| 87 | with code and data examples if at all possible. | ||||||||||||||||||||||||||||||||||||||||||
| 88 | |||||||||||||||||||||||||||||||||||||||||||
| 89 | =head2 Reporting Bugs | ||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||
| 91 | Report bugs to the Bioperl bug tracking system to help us keep track | ||||||||||||||||||||||||||||||||||||||||||
| 92 | the bugs and their resolution. Bug reports can be submitted via the | ||||||||||||||||||||||||||||||||||||||||||
| 93 | web: | ||||||||||||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||||||||||||
| 95 | https://github.com/bioperl/bioperl-live/issues | ||||||||||||||||||||||||||||||||||||||||||
| 96 | |||||||||||||||||||||||||||||||||||||||||||
| 97 | =head1 AUTHORS - Dave Messina | ||||||||||||||||||||||||||||||||||||||||||
| 98 | |||||||||||||||||||||||||||||||||||||||||||
| 99 | Email: I<dmessina@cpan.org> | ||||||||||||||||||||||||||||||||||||||||||
| 100 | |||||||||||||||||||||||||||||||||||||||||||
| 101 | =head1 CONTRIBUTORS | ||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||
| 104 | =head1 APPENDIX | ||||||||||||||||||||||||||||||||||||||||||
| 105 | |||||||||||||||||||||||||||||||||||||||||||
| 106 | The rest of the documentation details each of the object | ||||||||||||||||||||||||||||||||||||||||||
| 107 | methods. Internal methods are usually preceded with a _ | ||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||
| 109 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||
| 111 | # Let the code begin... | ||||||||||||||||||||||||||||||||||||||||||
| 112 | |||||||||||||||||||||||||||||||||||||||||||
| 113 | package Bio::SeqIO::seqxml; | ||||||||||||||||||||||||||||||||||||||||||
| 114 | 2 | $Bio::SeqIO::seqxml::VERSION = '1.7.8'; | |||||||||||||||||||||||||||||||||||||||||
| 115 | 2 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 116 | |||||||||||||||||||||||||||||||||||||||||||
| 117 | 2 | ▶ | use Bio::Seq; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 118 | 2 | ▶ | use Bio::Seq::SeqFactory; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 119 | 2 | ▶ | use Bio::Species; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 120 | 2 | ▶ | use Bio::Annotation::DBLink; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 121 | 2 | ▶ | use Bio::Annotation::SimpleValue; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 122 | 2 | ▶ | use XML::LibXML; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 123 | 2 | ▶ | use XML::LibXML::Reader; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 124 | 2 | ▶ | use XML::Writer; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 125 | |||||||||||||||||||||||||||||||||||||||||||
| 126 | 2 | ▶ | use base qw(Bio::SeqIO); | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 127 | |||||||||||||||||||||||||||||||||||||||||||
| 128 | # define seqXML header stuff | ||||||||||||||||||||||||||||||||||||||||||
| 129 | # there's no API for XMLNS XMLNS_XSI; you must set them here. | ||||||||||||||||||||||||||||||||||||||||||
| 130 | 2 | ▶ | use constant SEQXML_VERSION => 0.3; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 131 | 2 | ▶ | use constant SCHEMA_LOCATION => 'http://www.seqxml.org/0.3/seqxml.xsd'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 132 | 2 | ▶ | use constant XMLNS_XSI => 'http://www.w3.org/2001/XMLSchema-instance'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 133 | |||||||||||||||||||||||||||||||||||||||||||
| 134 | =head2 _initialize | ||||||||||||||||||||||||||||||||||||||||||
| 135 | |||||||||||||||||||||||||||||||||||||||||||
| 136 | Title : _initialize | ||||||||||||||||||||||||||||||||||||||||||
| 137 | Usage : $self->_initialize(@args) | ||||||||||||||||||||||||||||||||||||||||||
| 138 | Function: constructor (for internal use only). | ||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||
| 140 | Besides the usual SeqIO arguments (-file, -fh, etc.), | ||||||||||||||||||||||||||||||||||||||||||
| 141 | Bio::SeqIO::seqxml accepts three arguments which are used | ||||||||||||||||||||||||||||||||||||||||||
| 142 | when writing out a seqxml file. They are all optional. | ||||||||||||||||||||||||||||||||||||||||||
| 143 | Returns : none | ||||||||||||||||||||||||||||||||||||||||||
| 144 | Args : -source => source string (usually a database name) | ||||||||||||||||||||||||||||||||||||||||||
| 145 | -sourceVersion => source version. The version number of the source | ||||||||||||||||||||||||||||||||||||||||||
| 146 | -seqXMLversion => the version of seqXML that will be used | ||||||||||||||||||||||||||||||||||||||||||
| 147 | Throws : Exception if XML::LibXML::Reader or XML::Writer | ||||||||||||||||||||||||||||||||||||||||||
| 148 | is not initialized | ||||||||||||||||||||||||||||||||||||||||||
| 149 | |||||||||||||||||||||||||||||||||||||||||||
| 150 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||||||||||||
| 152 | 5 | ▶ | sub _initialize { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_initialize: called CC=13 SCAR=26.3
| |||||||||||||||||||||||||||||||||||||||||||
| 153 | 5 | my ( $self, @args ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | 5 | $self->SUPER::_initialize(@args); | |||||||||||||||||||||||||||||||||||||||||
| 156 | 5 | ▶ | if ( !defined $self->sequence_factory ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 157 | 5 | $self->sequence_factory( | |||||||||||||||||||||||||||||||||||||||||
| 158 | Bio::Seq::SeqFactory->new( | ||||||||||||||||||||||||||||||||||||||||||
| 159 | -verbose => $self->verbose(), | ||||||||||||||||||||||||||||||||||||||||||
| 160 | -type => 'Bio::Seq', | ||||||||||||||||||||||||||||||||||||||||||
| 161 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 162 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 163 | } | ||||||||||||||||||||||||||||||||||||||||||
| 164 | |||||||||||||||||||||||||||||||||||||||||||
| 165 | # holds version and source data | ||||||||||||||||||||||||||||||||||||||||||
| 166 | 5 | $self->{'_seqxml_metadata'} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||||||||||||
| 168 | # load any passed parameters | ||||||||||||||||||||||||||||||||||||||||||
| 169 | 5 | my %params = @args; | |||||||||||||||||||||||||||||||||||||||||
| 170 | 5 | ▶ | if ($params{'-sourceVersion'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 171 | 1 | $self->sourceVersion($params{'-sourceVersion'}); | |||||||||||||||||||||||||||||||||||||||||
| 172 | } | ||||||||||||||||||||||||||||||||||||||||||
| 173 | 5 | ▶ | if ($params{'-source'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 174 | 1 | $self->source($params{'-source'}); | |||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||
| 176 | 5 | ▶ | if ($params{'-seqXMLversion'}) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 1 | $self->seqXMLversion($params{'-seqXMLversion'}); | |||||||||||||||||||||||||||||||||||||||||
| 178 | } | ||||||||||||||||||||||||||||||||||||||||||
| 179 | # reading in SeqXML | ||||||||||||||||||||||||||||||||||||||||||
| 180 | 5 | ▶ | if ( $self->mode eq 'r' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 181 | 3 | ▶ | if ( $self->_fh ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 182 | 3 | $self->{'_reader'} = XML::LibXML::Reader->new( | |||||||||||||||||||||||||||||||||||||||||
| 183 | IO => $self->_fh, | ||||||||||||||||||||||||||||||||||||||||||
| 184 | no_blanks => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 185 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 186 | } | ||||||||||||||||||||||||||||||||||||||||||
| 187 | 3 | ▶ | if ( !$self->{'_reader'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | $self->throw("XML::LibXML::Reader not initialized"); | |||||||||||||||||||||||||||||||||||||||||
| 189 | } | ||||||||||||||||||||||||||||||||||||||||||
| 190 | |||||||||||||||||||||||||||||||||||||||||||
| 191 | # holds data temporarily during parsing | ||||||||||||||||||||||||||||||||||||||||||
| 192 | 3 | $self->{'_current_entry_data'} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | 3 | $self->_initialize_seqxml_node_methods(); | |||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | # read SeqXML header | ||||||||||||||||||||||||||||||||||||||||||
| 197 | 3 | $self->parseHeader(); | |||||||||||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||||||||||||
| 200 | # writing out SeqXML | ||||||||||||||||||||||||||||||||||||||||||
| 201 | elsif ( $self->mode eq 'w' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 202 | 2 | ▶ | if ( $self->_fh ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 203 | 2 | $self->{'_writer'} = XML::Writer->new( | |||||||||||||||||||||||||||||||||||||||||
| 204 | OUTPUT => $self->_fh, | ||||||||||||||||||||||||||||||||||||||||||
| 205 | DATA_MODE => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 206 | DATA_INDENT => 1, | ||||||||||||||||||||||||||||||||||||||||||
| 207 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 208 | 2 | ▶ | if ( !$self->{'_writer'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $self->throw("XML::Writer not initialized"); | |||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | # write SeqXML header | ||||||||||||||||||||||||||||||||||||||||||
| 213 | 2 | $self->{'_writer'}->xmlDecl("UTF-8"); | |||||||||||||||||||||||||||||||||||||||||
| 214 | 2 | ▶ | if ($self->source || $self->sourceVersion) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->source or $self->sourceVersion
MC/DC50%1/2
$self->source or $self->sourceVersion
$self->source
$self->sourceVersion
Truth table66%2/3
A or B
A= $self->sourceB= $self->sourceVersion
| |||||||||||||||||||||||||||||||||||||||||||
| 215 | 1 | $self->{'_writer'}->startTag( | |||||||||||||||||||||||||||||||||||||||||
| 216 | 'seqXML', | ||||||||||||||||||||||||||||||||||||||||||
| 217 | 'seqXMLversion' => $self->seqXMLversion(SEQXML_VERSION), | ||||||||||||||||||||||||||||||||||||||||||
| 218 | 'xmlns:xsi' => XMLNS_XSI, | ||||||||||||||||||||||||||||||||||||||||||
| 219 | 'xsi:noNamespaceSchemaLocation' => $self->schemaLocation(SCHEMA_LOCATION), | ||||||||||||||||||||||||||||||||||||||||||
| 220 | 'source' => $self->source, | ||||||||||||||||||||||||||||||||||||||||||
| 221 | 'sourceVersion' => $self->sourceVersion, | ||||||||||||||||||||||||||||||||||||||||||
| 222 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 223 | } | ||||||||||||||||||||||||||||||||||||||||||
| 224 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 225 | 1 | $self->{'_writer'}->startTag( | |||||||||||||||||||||||||||||||||||||||||
| 226 | 'seqXML', | ||||||||||||||||||||||||||||||||||||||||||
| 227 | 'seqXMLversion' => $self->seqXMLversion(SEQXML_VERSION), | ||||||||||||||||||||||||||||||||||||||||||
| 228 | 'xmlns:xsi' => XMLNS_XSI, | ||||||||||||||||||||||||||||||||||||||||||
| 229 | 'xsi:noNamespaceSchemaLocation' => $self->schemaLocation(SCHEMA_LOCATION), | ||||||||||||||||||||||||||||||||||||||||||
| 230 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 231 | } | ||||||||||||||||||||||||||||||||||||||||||
| 232 | } | ||||||||||||||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||||||||||||
| 234 | |||||||||||||||||||||||||||||||||||||||||||
| 235 | } | ||||||||||||||||||||||||||||||||||||||||||
| 236 | |||||||||||||||||||||||||||||||||||||||||||
| 237 | =head2 next_seq | ||||||||||||||||||||||||||||||||||||||||||
| 238 | |||||||||||||||||||||||||||||||||||||||||||
| 239 | Title : next_seq | ||||||||||||||||||||||||||||||||||||||||||
| 240 | Usage : $seq = $stream->next_seq() | ||||||||||||||||||||||||||||||||||||||||||
| 241 | Function: returns the next sequence in the stream | ||||||||||||||||||||||||||||||||||||||||||
| 242 | Returns : L<Bio::Seq> object, or nothing if no more available | ||||||||||||||||||||||||||||||||||||||||||
| 243 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||
| 245 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 246 | |||||||||||||||||||||||||||||||||||||||||||
| 247 | 4 | ▶ | sub next_seq { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
next_seq: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 248 | 4 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 249 | 4 | my $reader = $self->{'_reader'}; | |||||||||||||||||||||||||||||||||||||||||
| 250 | 4 | my $entry; | |||||||||||||||||||||||||||||||||||||||||
| 251 | |||||||||||||||||||||||||||||||||||||||||||
| 252 | 4 | ▶ | while ( $reader->read ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 253 | |||||||||||||||||||||||||||||||||||||||||||
| 254 | # we're done if we hit </entry> | ||||||||||||||||||||||||||||||||||||||||||
| 255 | 40 | ▶ | if ( $reader->nodeType == XML_READER_TYPE_END_ELEMENT ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 256 | 12 | ▶ | if ( $reader->name eq 'entry' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 257 | 4 | $entry = $self->end_element_entry(); | |||||||||||||||||||||||||||||||||||||||||
| 258 | 4 | last; | |||||||||||||||||||||||||||||||||||||||||
| 259 | } | ||||||||||||||||||||||||||||||||||||||||||
| 260 | } | ||||||||||||||||||||||||||||||||||||||||||
| 261 | 36 | $self->processXMLnode; | |||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | 4 | return $entry; | |||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||
| 266 | |||||||||||||||||||||||||||||||||||||||||||
| 267 | =head2 write_seq | ||||||||||||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||||||||||||
| 269 | Title : write_seq | ||||||||||||||||||||||||||||||||||||||||||
| 270 | Usage : $stream->write_seq(@seq) | ||||||||||||||||||||||||||||||||||||||||||
| 271 | Function: Writes the $seq object into the stream | ||||||||||||||||||||||||||||||||||||||||||
| 272 | Returns : 1 for success and 0 for error | ||||||||||||||||||||||||||||||||||||||||||
| 273 | Args : Array of 1 or more L<Bio::PrimarySeqI> objects | ||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 3 | ▶ | sub write_seq { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
write_seq: called CC=27 SCAR=38.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 3 | my ( $self, @seqs ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 279 | 3 | my $writer = $self->{'_writer'}; | |||||||||||||||||||||||||||||||||||||||||
| 280 | |||||||||||||||||||||||||||||||||||||||||||
| 281 | 3 | foreach my $seqobj (@seqs) { | |||||||||||||||||||||||||||||||||||||||||
| 282 | 3 | ▶ | $self->throw("Trying to write with no seq!") unless defined $seqobj; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | 3 | ▶ | if ( !ref $seqobj || !$seqobj->isa('Bio::SeqI') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
ref $seqobj and $seqobj->isa("Bio::SeqI")
MC/DC0%0/2
ref $seqobj and $seqobj->isa("Bio::SeqI")
ref $seqobj
$seqobj->isa("Bio::SeqI")
Truth table33%1/3
A and B
A= ref $seqobjB= $seqobj->isa("Bio::SeqI")
| |||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | $self->warn( | |||||||||||||||||||||||||||||||||||||||||
| 286 | " $seqobj is not a SeqI compliant module. Attempting to dump, but may fail!" | ||||||||||||||||||||||||||||||||||||||||||
| 287 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||
| 290 | # opening tag, ID, and source (if present -- it's optional) | ||||||||||||||||||||||||||||||||||||||||||
| 291 | 3 | my $id = $seqobj->display_id; | |||||||||||||||||||||||||||||||||||||||||
| 292 | 3 | my ($source_obj) = $seqobj->get_Annotations('source'); | |||||||||||||||||||||||||||||||||||||||||
| 293 | 3 | ▶ | if (defined $source_obj && defined $id) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition66%2/3
defined $source_obj and defined $id
MC/DC50%1/2
defined $source_obj and defined $id
defined $source_obj
defined $id
Truth table66%2/3
A and B
A= defined $source_objB= defined $id
| |||||||||||||||||||||||||||||||||||||||||||
| 294 | 1 | $writer->startTag( 'entry', 'id' => $id, 'source' => $source_obj->value ); | |||||||||||||||||||||||||||||||||||||||||
| 295 | } | ||||||||||||||||||||||||||||||||||||||||||
| 296 | elsif (defined $id) { | ||||||||||||||||||||||||||||||||||||||||||
| 297 | 2 | $writer->startTag( 'entry', 'id' => $id ); | |||||||||||||||||||||||||||||||||||||||||
| 298 | } | ||||||||||||||||||||||||||||||||||||||||||
| 299 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | $self->throw(" $seqobj has no ID!"); | |||||||||||||||||||||||||||||||||||||||||
| 301 | } | ||||||||||||||||||||||||||||||||||||||||||
| 302 | |||||||||||||||||||||||||||||||||||||||||||
| 303 | # species and NCBI taxID | ||||||||||||||||||||||||||||||||||||||||||
| 304 | 3 | ▶ | if ( $seqobj->species ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 305 | 1 | my $name = $seqobj->species->node_name; | |||||||||||||||||||||||||||||||||||||||||
| 306 | 1 | my $taxid = $seqobj->species->ncbi_taxid; | |||||||||||||||||||||||||||||||||||||||||
| 307 | 1 | ▶ | if ( $name && ( $taxid =~ /[0-9]+/ ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$name and $taxid =~ /[0-9]+/
MC/DC0%0/2
$name and $taxid =~ /[0-9]+/
$name
$taxid =~ /[0-9]+/
Truth table33%1/3
A and B
A= $nameB= $taxid =~ /[0-9]+/
| |||||||||||||||||||||||||||||||||||||||||||
| 308 | 1 | $writer->emptyTag( | |||||||||||||||||||||||||||||||||||||||||
| 309 | 'species', | ||||||||||||||||||||||||||||||||||||||||||
| 310 | 'name' => $name, | ||||||||||||||||||||||||||||||||||||||||||
| 311 | 'ncbiTaxID' => $taxid | ||||||||||||||||||||||||||||||||||||||||||
| 312 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 313 | } | ||||||||||||||||||||||||||||||||||||||||||
| 314 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 315 | 0 | $self->throw("$seqobj has malformed species data"); | |||||||||||||||||||||||||||||||||||||||||
| 316 | } | ||||||||||||||||||||||||||||||||||||||||||
| 317 | } | ||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||
| 319 | # description | ||||||||||||||||||||||||||||||||||||||||||
| 320 | 3 | ▶ | if ( $seqobj->desc ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 321 | 3 | $writer->dataElement( 'description', $seqobj->desc ); | |||||||||||||||||||||||||||||||||||||||||
| 322 | } | ||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | # sequence | ||||||||||||||||||||||||||||||||||||||||||
| 325 | # - throws if seq is empty or missing because having a sequence | ||||||||||||||||||||||||||||||||||||||||||
| 326 | # is a SeqXML requirement | ||||||||||||||||||||||||||||||||||||||||||
| 327 | 3 | ▶ | if ( $seqobj->seq ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 328 | # check that there's actually sequence in there | ||||||||||||||||||||||||||||||||||||||||||
| 329 | 3 | ▶ | unless ( length($seqobj->seq) > 0 ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | $self->throw("sequence entry $id lacks a sequence!"); | |||||||||||||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||||||||||||
| 332 | 3 | my $alphabet = $seqobj->alphabet; | |||||||||||||||||||||||||||||||||||||||||
| 333 | 3 | my %seqtype = ( | |||||||||||||||||||||||||||||||||||||||||
| 334 | 'rna' => 'RNAseq', | ||||||||||||||||||||||||||||||||||||||||||
| 335 | 'dna' => 'DNAseq', | ||||||||||||||||||||||||||||||||||||||||||
| 336 | 'protein' => 'AAseq' | ||||||||||||||||||||||||||||||||||||||||||
| 337 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 338 | 3 | ▶ | unless ( exists( $seqtype{$alphabet} ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 339 | 0 | $self->throw("invalid sequence alphabet $alphabet!"); | |||||||||||||||||||||||||||||||||||||||||
| 340 | } | ||||||||||||||||||||||||||||||||||||||||||
| 341 | 3 | $writer->dataElement( $seqtype{$alphabet}, $seqobj->seq ); | |||||||||||||||||||||||||||||||||||||||||
| 342 | } | ||||||||||||||||||||||||||||||||||||||||||
| 343 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | $self->throw("sequence entry $id lacks a sequence!"); | |||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | # Database crossreferences | ||||||||||||||||||||||||||||||||||||||||||
| 348 | 3 | my @dblinks = $seqobj->get_Annotations('dblink'); | |||||||||||||||||||||||||||||||||||||||||
| 349 | 3 | foreach my $dblink (@dblinks) { | |||||||||||||||||||||||||||||||||||||||||
| 350 | 1 | ▶ | unless ( $dblink->database && $dblink->primary_id ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$dblink->database and $dblink->primary_id
MC/DC0%0/2
$dblink->database and $dblink->primary_id
$dblink->database
$dblink->primary_id
Truth table33%1/3
A and B
A= $dblink->databaseB= $dblink->primary_id
| |||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | $self->throw("dblink $dblink is malformed"); | |||||||||||||||||||||||||||||||||||||||||
| 352 | } | ||||||||||||||||||||||||||||||||||||||||||
| 353 | 1 | ▶ | if (defined($dblink->type)) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 354 | 1 | $writer->emptyTag( | |||||||||||||||||||||||||||||||||||||||||
| 355 | 'DBRef', | ||||||||||||||||||||||||||||||||||||||||||
| 356 | 'type' => $dblink->type, | ||||||||||||||||||||||||||||||||||||||||||
| 357 | 'source' => $dblink->database, | ||||||||||||||||||||||||||||||||||||||||||
| 358 | 'id' => $dblink->primary_id, | ||||||||||||||||||||||||||||||||||||||||||
| 359 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 360 | } | ||||||||||||||||||||||||||||||||||||||||||
| 361 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 362 | 0 | $writer->emptyTag( | |||||||||||||||||||||||||||||||||||||||||
| 363 | 'DBRef', | ||||||||||||||||||||||||||||||||||||||||||
| 364 | 'source' => $dblink->database, | ||||||||||||||||||||||||||||||||||||||||||
| 365 | 'id' => $dblink->primary_id, | ||||||||||||||||||||||||||||||||||||||||||
| 366 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 367 | } | ||||||||||||||||||||||||||||||||||||||||||
| 368 | } | ||||||||||||||||||||||||||||||||||||||||||
| 369 | |||||||||||||||||||||||||||||||||||||||||||
| 370 | # properties | ||||||||||||||||||||||||||||||||||||||||||
| 371 | 3 | my @annotations = $seqobj->get_Annotations(); | |||||||||||||||||||||||||||||||||||||||||
| 372 | 3 | foreach my $annot_obj (@annotations) { | |||||||||||||||||||||||||||||||||||||||||
| 373 | 4 | ▶ | next if ( $annot_obj->tagname eq 'dblink' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | 3 | ▶ | next if ( $annot_obj->tagname eq 'source' ); # handled above | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 375 | |||||||||||||||||||||||||||||||||||||||||||
| 376 | # SeqXML doesn't support references | ||||||||||||||||||||||||||||||||||||||||||
| 377 | 2 | ▶ | next if ( $annot_obj->tagname eq 'reference' ); | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 378 | |||||||||||||||||||||||||||||||||||||||||||
| 379 | 2 | ▶ | unless ( $annot_obj->tagname ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 380 | 0 | $self->throw("property $annot_obj is missing a tagname"); | |||||||||||||||||||||||||||||||||||||||||
| 381 | } | ||||||||||||||||||||||||||||||||||||||||||
| 382 | 2 | ▶ | if ( $annot_obj->value ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 383 | 1 | $writer->emptyTag( | |||||||||||||||||||||||||||||||||||||||||
| 384 | 'property', | ||||||||||||||||||||||||||||||||||||||||||
| 385 | 'name' => $annot_obj->tagname, | ||||||||||||||||||||||||||||||||||||||||||
| 386 | 'value' => $annot_obj->value, | ||||||||||||||||||||||||||||||||||||||||||
| 387 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 388 | } | ||||||||||||||||||||||||||||||||||||||||||
| 389 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 390 | 1 | $writer->emptyTag( | |||||||||||||||||||||||||||||||||||||||||
| 391 | 'property', | ||||||||||||||||||||||||||||||||||||||||||
| 392 | 'name' => $annot_obj->tagname, | ||||||||||||||||||||||||||||||||||||||||||
| 393 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 394 | } | ||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | } | ||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | # closing tag | ||||||||||||||||||||||||||||||||||||||||||
| 399 | 3 | $writer->endTag('entry'); | |||||||||||||||||||||||||||||||||||||||||
| 400 | |||||||||||||||||||||||||||||||||||||||||||
| 401 | # make sure it gets written to the file | ||||||||||||||||||||||||||||||||||||||||||
| 402 | 3 | ▶ | $self->flush if $self->_flush_on_write && defined $self->_fh; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$self->_flush_on_write and defined $self->_fh
MC/DC0%0/2
$self->_flush_on_write and defined $self->_fh
$self->_flush_on_write
defined $self->_fh
Truth table33%1/3
A and B
A= $self->_flush_on_writeB= defined $self->_fh
| |||||||||||||||||||||||||||||||||||||||||||
| 403 | 3 | return 1; | |||||||||||||||||||||||||||||||||||||||||
| 404 | } | ||||||||||||||||||||||||||||||||||||||||||
| 405 | } | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | =head2 _initialize_seqxml_node_methods | ||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | Title : _initialize_seqxml_node_methods | ||||||||||||||||||||||||||||||||||||||||||
| 410 | Usage : $self->_initialize_xml_node_methods | ||||||||||||||||||||||||||||||||||||||||||
| 411 | Function: sets up code ref mapping of each seqXML node type | ||||||||||||||||||||||||||||||||||||||||||
| 412 | to a method for processing that node type | ||||||||||||||||||||||||||||||||||||||||||
| 413 | Returns : none | ||||||||||||||||||||||||||||||||||||||||||
| 414 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 415 | |||||||||||||||||||||||||||||||||||||||||||
| 416 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 417 | |||||||||||||||||||||||||||||||||||||||||||
| 418 | 3 | ▶ | sub _initialize_seqxml_node_methods { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_initialize_seqxml_node_methods: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 419 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 420 | |||||||||||||||||||||||||||||||||||||||||||
| 421 | 3 | my %start_elements = ( | |||||||||||||||||||||||||||||||||||||||||
| 422 | 'seqXML' => \&element_seqXML, | ||||||||||||||||||||||||||||||||||||||||||
| 423 | 'entry' => \&element_entry, | ||||||||||||||||||||||||||||||||||||||||||
| 424 | 'species' => \&element_species, | ||||||||||||||||||||||||||||||||||||||||||
| 425 | 'description' => \&element_description, | ||||||||||||||||||||||||||||||||||||||||||
| 426 | 'RNAseq' => \&element_RNAseq, | ||||||||||||||||||||||||||||||||||||||||||
| 427 | 'DNAseq' => \&element_DNAseq, | ||||||||||||||||||||||||||||||||||||||||||
| 428 | 'AAseq' => \&element_AAseq, | ||||||||||||||||||||||||||||||||||||||||||
| 429 | 'DBRef' => \&element_DBRef, | ||||||||||||||||||||||||||||||||||||||||||
| 430 | 'property' => \&element_property, | ||||||||||||||||||||||||||||||||||||||||||
| 431 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 432 | 3 | $self->{'_start_elements'} = \%start_elements; | |||||||||||||||||||||||||||||||||||||||||
| 433 | |||||||||||||||||||||||||||||||||||||||||||
| 434 | 3 | my %end_elements = ( | |||||||||||||||||||||||||||||||||||||||||
| 435 | 'seqXML' => \&end_element_default, | ||||||||||||||||||||||||||||||||||||||||||
| 436 | 'entry' => \&end_element_entry, | ||||||||||||||||||||||||||||||||||||||||||
| 437 | 'species' => \&end_element_default, | ||||||||||||||||||||||||||||||||||||||||||
| 438 | 'description' => \&end_element_default, | ||||||||||||||||||||||||||||||||||||||||||
| 439 | 'RNAseq' => \&end_element_RNAseq, | ||||||||||||||||||||||||||||||||||||||||||
| 440 | 'DNAseq' => \&end_element_DNAseq, | ||||||||||||||||||||||||||||||||||||||||||
| 441 | 'AAseq' => \&end_element_AAseq, | ||||||||||||||||||||||||||||||||||||||||||
| 442 | 'DBRef' => \&end_element_default, | ||||||||||||||||||||||||||||||||||||||||||
| 443 | 'property' => \&end_element_default, | ||||||||||||||||||||||||||||||||||||||||||
| 444 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 445 | 3 | $self->{'_end_elements'} = \%end_elements; | |||||||||||||||||||||||||||||||||||||||||
| 446 | |||||||||||||||||||||||||||||||||||||||||||
| 447 | } | ||||||||||||||||||||||||||||||||||||||||||
| 448 | |||||||||||||||||||||||||||||||||||||||||||
| 449 | =head2 schemaLocation | ||||||||||||||||||||||||||||||||||||||||||
| 450 | |||||||||||||||||||||||||||||||||||||||||||
| 451 | Title : schemaLocation | ||||||||||||||||||||||||||||||||||||||||||
| 452 | Usage : $self->schemaLocation | ||||||||||||||||||||||||||||||||||||||||||
| 453 | Function: gets/sets the schema location in the <seqXML> header | ||||||||||||||||||||||||||||||||||||||||||
| 454 | Returns : the schema location string | ||||||||||||||||||||||||||||||||||||||||||
| 455 | Args : To set the schemaLocation, call with a schemaLocation as the argument. | ||||||||||||||||||||||||||||||||||||||||||
| 456 | |||||||||||||||||||||||||||||||||||||||||||
| 457 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 458 | |||||||||||||||||||||||||||||||||||||||||||
| 459 | 3 | ▶ | sub schemaLocation { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
schemaLocation: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 460 | 3 | my ( $self, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 461 | 3 | my $metadata = $self->{'_seqxml_metadata'}; | |||||||||||||||||||||||||||||||||||||||||
| 462 | |||||||||||||||||||||||||||||||||||||||||||
| 463 | # set if a value is supplied | ||||||||||||||||||||||||||||||||||||||||||
| 464 | 3 | ▶ | if ($value) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 465 | 2 | $metadata->{'schemaLocation'} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 466 | } | ||||||||||||||||||||||||||||||||||||||||||
| 467 | |||||||||||||||||||||||||||||||||||||||||||
| 468 | 3 | return $metadata->{'schemaLocation'}; | |||||||||||||||||||||||||||||||||||||||||
| 469 | } | ||||||||||||||||||||||||||||||||||||||||||
| 470 | |||||||||||||||||||||||||||||||||||||||||||
| 471 | =head2 source | ||||||||||||||||||||||||||||||||||||||||||
| 472 | |||||||||||||||||||||||||||||||||||||||||||
| 473 | Title : source | ||||||||||||||||||||||||||||||||||||||||||
| 474 | Usage : $self->source | ||||||||||||||||||||||||||||||||||||||||||
| 475 | Function: gets/sets the data source in the <seqXML> header | ||||||||||||||||||||||||||||||||||||||||||
| 476 | Returns : the data source string | ||||||||||||||||||||||||||||||||||||||||||
| 477 | Args : To set the source, call with a source string as the argument. | ||||||||||||||||||||||||||||||||||||||||||
| 478 | |||||||||||||||||||||||||||||||||||||||||||
| 479 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 480 | |||||||||||||||||||||||||||||||||||||||||||
| 481 | 7 | ▶ | sub source { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
source: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 482 | 7 | my ( $self, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 483 | 7 | my $metadata = $self->{'_seqxml_metadata'}; | |||||||||||||||||||||||||||||||||||||||||
| 484 | |||||||||||||||||||||||||||||||||||||||||||
| 485 | # set if a value is supplied | ||||||||||||||||||||||||||||||||||||||||||
| 486 | 7 | ▶ | if ($value) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 487 | 1 | $metadata->{'source'} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 488 | } | ||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||
| 490 | 7 | return $metadata->{'source'}; | |||||||||||||||||||||||||||||||||||||||||
| 491 | } | ||||||||||||||||||||||||||||||||||||||||||
| 492 | |||||||||||||||||||||||||||||||||||||||||||
| 493 | =head2 sourceVersion | ||||||||||||||||||||||||||||||||||||||||||
| 494 | |||||||||||||||||||||||||||||||||||||||||||
| 495 | Title : sourceVersion | ||||||||||||||||||||||||||||||||||||||||||
| 496 | Usage : $self->sourceVersion | ||||||||||||||||||||||||||||||||||||||||||
| 497 | Function: gets/sets the data source version in the <seqXML> header | ||||||||||||||||||||||||||||||||||||||||||
| 498 | Returns : the data source version string | ||||||||||||||||||||||||||||||||||||||||||
| 499 | Args : To set the source version, call with a source version string | ||||||||||||||||||||||||||||||||||||||||||
| 500 | as the argument. | ||||||||||||||||||||||||||||||||||||||||||
| 501 | |||||||||||||||||||||||||||||||||||||||||||
| 502 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 503 | |||||||||||||||||||||||||||||||||||||||||||
| 504 | 6 | ▶ | sub sourceVersion { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
sourceVersion: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 505 | 6 | my ( $self, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 506 | 6 | my $metadata = $self->{'_seqxml_metadata'}; | |||||||||||||||||||||||||||||||||||||||||
| 507 | |||||||||||||||||||||||||||||||||||||||||||
| 508 | # set if a value is supplied | ||||||||||||||||||||||||||||||||||||||||||
| 509 | 6 | ▶ | if ($value) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 510 | 1 | $metadata->{'sourceVersion'} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 511 | } | ||||||||||||||||||||||||||||||||||||||||||
| 512 | |||||||||||||||||||||||||||||||||||||||||||
| 513 | 6 | return $metadata->{'sourceVersion'}; | |||||||||||||||||||||||||||||||||||||||||
| 514 | } | ||||||||||||||||||||||||||||||||||||||||||
| 515 | |||||||||||||||||||||||||||||||||||||||||||
| 516 | =head2 seqXMLversion | ||||||||||||||||||||||||||||||||||||||||||
| 517 | |||||||||||||||||||||||||||||||||||||||||||
| 518 | Title : seqXMLversion | ||||||||||||||||||||||||||||||||||||||||||
| 519 | Usage : $self->seqXMLversion | ||||||||||||||||||||||||||||||||||||||||||
| 520 | Function: gets/sets the seqXML version in the <seqXML> header | ||||||||||||||||||||||||||||||||||||||||||
| 521 | Returns : the seqXML version string. | ||||||||||||||||||||||||||||||||||||||||||
| 522 | Args : To set the seqXML version, call with a seqXML version string | ||||||||||||||||||||||||||||||||||||||||||
| 523 | as the argument. | ||||||||||||||||||||||||||||||||||||||||||
| 524 | |||||||||||||||||||||||||||||||||||||||||||
| 525 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 526 | |||||||||||||||||||||||||||||||||||||||||||
| 527 | 6 | ▶ | sub seqXMLversion { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
seqXMLversion: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 528 | 6 | my ( $self, $value ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 529 | 6 | my $metadata = $self->{'_seqxml_metadata'}; | |||||||||||||||||||||||||||||||||||||||||
| 530 | |||||||||||||||||||||||||||||||||||||||||||
| 531 | # set if a value is supplied | ||||||||||||||||||||||||||||||||||||||||||
| 532 | 6 | ▶ | if ($value) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 533 | 3 | $metadata->{'seqXMLversion'} = $value; | |||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||
| 536 | 6 | return $metadata->{'seqXMLversion'}; | |||||||||||||||||||||||||||||||||||||||||
| 537 | } | ||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||
| 539 | =head1 Methods for parsing the XML document | ||||||||||||||||||||||||||||||||||||||||||
| 540 | |||||||||||||||||||||||||||||||||||||||||||
| 541 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 542 | |||||||||||||||||||||||||||||||||||||||||||
| 543 | =head2 processXMLNode | ||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||
| 545 | Title : processXMLNode | ||||||||||||||||||||||||||||||||||||||||||
| 546 | Usage : $seqio->processXMLNode | ||||||||||||||||||||||||||||||||||||||||||
| 547 | Function: reads the XML node and processes according to the node type | ||||||||||||||||||||||||||||||||||||||||||
| 548 | Returns : none | ||||||||||||||||||||||||||||||||||||||||||
| 549 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 550 | Throws : Exception on unexpected XML node type, warnings on unexpected | ||||||||||||||||||||||||||||||||||||||||||
| 551 | XML element names. | ||||||||||||||||||||||||||||||||||||||||||
| 552 | |||||||||||||||||||||||||||||||||||||||||||
| 553 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 554 | |||||||||||||||||||||||||||||||||||||||||||
| 555 | 36 | ▶ | sub processXMLnode { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
processXMLnode: called CC=7 SCAR=21.2
Pod
undocumented
| |||||||||||||||||||||||||||||||||||||||||||
| 556 | 36 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 557 | 36 | my $reader = $self->{'_reader'}; | |||||||||||||||||||||||||||||||||||||||||
| 558 | 36 | my $nodetype = $reader->nodeType; | |||||||||||||||||||||||||||||||||||||||||
| 559 | |||||||||||||||||||||||||||||||||||||||||||
| 560 | 36 | ▶ | if ( $nodetype == XML_READER_TYPE_ELEMENT ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 561 | 20 | $self->{'_current_element_name'} = $reader->name; | |||||||||||||||||||||||||||||||||||||||||
| 562 | |||||||||||||||||||||||||||||||||||||||||||
| 563 | 20 | ▶ | if ( exists $self->{'_start_elements'}->{ $reader->name } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 564 | 20 | my $method = $self->{'_start_elements'}->{ $reader->name }; | |||||||||||||||||||||||||||||||||||||||||
| 565 | 20 | $self->$method(); | |||||||||||||||||||||||||||||||||||||||||
| 566 | } | ||||||||||||||||||||||||||||||||||||||||||
| 567 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | my $name = $reader->name; | |||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | $self->warn("unexpected start element encountered: $name"); | |||||||||||||||||||||||||||||||||||||||||
| 570 | } | ||||||||||||||||||||||||||||||||||||||||||
| 571 | } | ||||||||||||||||||||||||||||||||||||||||||
| 572 | elsif ( $nodetype == XML_READER_TYPE_TEXT ) { | ||||||||||||||||||||||||||||||||||||||||||
| 573 | |||||||||||||||||||||||||||||||||||||||||||
| 574 | # store key-value pair of element name and the corresponding text | ||||||||||||||||||||||||||||||||||||||||||
| 575 | 8 | my $name = $self->{'_current_element_name'}; | |||||||||||||||||||||||||||||||||||||||||
| 576 | 8 | $self->{'_current_entry_data'}->{$name} = $reader->value; | |||||||||||||||||||||||||||||||||||||||||
| 577 | |||||||||||||||||||||||||||||||||||||||||||
| 578 | } | ||||||||||||||||||||||||||||||||||||||||||
| 579 | elsif ( $nodetype == XML_READER_TYPE_END_ELEMENT ) { | ||||||||||||||||||||||||||||||||||||||||||
| 580 | 8 | ▶ | if ( exists $self->{'_end_elements'}->{ $reader->name } ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 581 | 8 | my $method = $self->{'_end_elements'}->{ $reader->name }; | |||||||||||||||||||||||||||||||||||||||||
| 582 | 8 | $self->$method(); | |||||||||||||||||||||||||||||||||||||||||
| 583 | } | ||||||||||||||||||||||||||||||||||||||||||
| 584 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 585 | 0 | my $name = $reader->name; | |||||||||||||||||||||||||||||||||||||||||
| 586 | 0 | $self->warn("unexpected end element encountered: $name"); | |||||||||||||||||||||||||||||||||||||||||
| 587 | } | ||||||||||||||||||||||||||||||||||||||||||
| 588 | 8 | $self->{'_current_element_name'} = {}; # empty current element name | |||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||
| 590 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 591 | 0 | $self->throw( | |||||||||||||||||||||||||||||||||||||||||
| 592 | "unexpected node type " . $nodetype, | ||||||||||||||||||||||||||||||||||||||||||
| 593 | " encountered (name: ", | ||||||||||||||||||||||||||||||||||||||||||
| 594 | $reader->name, ")\n" | ||||||||||||||||||||||||||||||||||||||||||
| 595 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 596 | } | ||||||||||||||||||||||||||||||||||||||||||
| 597 | |||||||||||||||||||||||||||||||||||||||||||
| 598 | 36 | ▶ | if ( $self->debug ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 599 | 0 | printf "%d %d %s %d\n", | |||||||||||||||||||||||||||||||||||||||||
| 600 | ( | ||||||||||||||||||||||||||||||||||||||||||
| 601 | $reader->depth, $reader->nodeType, | ||||||||||||||||||||||||||||||||||||||||||
| 602 | $reader->name, $reader->isEmptyElement | ||||||||||||||||||||||||||||||||||||||||||
| 603 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 604 | } | ||||||||||||||||||||||||||||||||||||||||||
| 605 | } | ||||||||||||||||||||||||||||||||||||||||||
| 606 | |||||||||||||||||||||||||||||||||||||||||||
| 607 | =head2 processAttribute | ||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||
| 609 | Title : processAttribute | ||||||||||||||||||||||||||||||||||||||||||
| 610 | Usage : $seqio->processAttribute(\%hash_for_attribute); | ||||||||||||||||||||||||||||||||||||||||||
| 611 | Function: reads the attributes of the current element into a hash | ||||||||||||||||||||||||||||||||||||||||||
| 612 | Returns : none | ||||||||||||||||||||||||||||||||||||||||||
| 613 | Args : hash reference where the attributes will be stored. | ||||||||||||||||||||||||||||||||||||||||||
| 614 | |||||||||||||||||||||||||||||||||||||||||||
| 615 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 616 | |||||||||||||||||||||||||||||||||||||||||||
| 617 | 15 | ▶ | sub processAttribute { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
processAttribute: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 618 | 15 | my ( $self, $data ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 619 | 15 | my $reader = $self->{'_reader'}; | |||||||||||||||||||||||||||||||||||||||||
| 620 | |||||||||||||||||||||||||||||||||||||||||||
| 621 | # several ways of reading attributes: | ||||||||||||||||||||||||||||||||||||||||||
| 622 | # read all attributes: | ||||||||||||||||||||||||||||||||||||||||||
| 623 | 15 | ▶ | if ( $reader->moveToFirstAttribute ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 624 | 15 | ▶ | do { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 625 | 35 | $data->{ $reader->name() } = $reader->value; | |||||||||||||||||||||||||||||||||||||||||
| 626 | } while ( $reader->moveToNextAttribute ); | ||||||||||||||||||||||||||||||||||||||||||
| 627 | 15 | $reader->moveToElement; | |||||||||||||||||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||||||||||||||||
| 629 | } | ||||||||||||||||||||||||||||||||||||||||||
| 630 | |||||||||||||||||||||||||||||||||||||||||||
| 631 | =head2 parseHeader | ||||||||||||||||||||||||||||||||||||||||||
| 632 | |||||||||||||||||||||||||||||||||||||||||||
| 633 | Title : parseHeader | ||||||||||||||||||||||||||||||||||||||||||
| 634 | Usage : $self->parseHeader(); | ||||||||||||||||||||||||||||||||||||||||||
| 635 | Function: reads the opening <seqXML> block and grabs the metadata from it, | ||||||||||||||||||||||||||||||||||||||||||
| 636 | namely the source, sourceVersion, and seqXMLversion. | ||||||||||||||||||||||||||||||||||||||||||
| 637 | Returns : none | ||||||||||||||||||||||||||||||||||||||||||
| 638 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 639 | Throws : Exception if it hits an <entry> tag, because that means it's | ||||||||||||||||||||||||||||||||||||||||||
| 640 | missed the <seqXML> tag and read too far into the file. | ||||||||||||||||||||||||||||||||||||||||||
| 641 | |||||||||||||||||||||||||||||||||||||||||||
| 642 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 643 | |||||||||||||||||||||||||||||||||||||||||||
| 644 | 3 | ▶ | sub parseHeader { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parseHeader: called CC=5 SCAR=19.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 645 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 646 | 3 | my $reader = $self->{'_reader'}; | |||||||||||||||||||||||||||||||||||||||||
| 647 | |||||||||||||||||||||||||||||||||||||||||||
| 648 | 3 | ▶ | while($reader->read) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 649 | |||||||||||||||||||||||||||||||||||||||||||
| 650 | # just read the header | ||||||||||||||||||||||||||||||||||||||||||
| 651 | 3 | ▶ | if ( $reader->nodeType == XML_READER_TYPE_ELEMENT ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 652 | 3 | ▶ | if ( $reader->name eq 'seqXML' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 653 | 3 | $self->element_seqXML(); | |||||||||||||||||||||||||||||||||||||||||
| 654 | 3 | last; | |||||||||||||||||||||||||||||||||||||||||
| 655 | } | ||||||||||||||||||||||||||||||||||||||||||
| 656 | elsif ( $reader->name eq 'entry' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 657 | 0 | my $name = $reader->name; | |||||||||||||||||||||||||||||||||||||||||
| 658 | 0 | $self->throw("Missed the opening <seqXML> tag. Got $name instead."); | |||||||||||||||||||||||||||||||||||||||||
| 659 | } | ||||||||||||||||||||||||||||||||||||||||||
| 660 | } | ||||||||||||||||||||||||||||||||||||||||||
| 661 | } | ||||||||||||||||||||||||||||||||||||||||||
| 662 | } | ||||||||||||||||||||||||||||||||||||||||||
| 663 | |||||||||||||||||||||||||||||||||||||||||||
| 664 | =head2 element_seqXML | ||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||
| 666 | Title : element_seqXML | ||||||||||||||||||||||||||||||||||||||||||
| 667 | Usage : $self->element_seqXML | ||||||||||||||||||||||||||||||||||||||||||
| 668 | Function: processes the opening <seqXML> node | ||||||||||||||||||||||||||||||||||||||||||
| 669 | Returns : none | ||||||||||||||||||||||||||||||||||||||||||
| 670 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 671 | |||||||||||||||||||||||||||||||||||||||||||
| 672 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||
| 674 | 3 | ▶ | sub element_seqXML { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
element_seqXML: called CC=2 SCAR=7.2
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 675 | 3 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 676 | 3 | my $reader = $self->{'_reader'}; | |||||||||||||||||||||||||||||||||||||||||
| 677 | |||||||||||||||||||||||||||||||||||||||||||
| 678 | # reset for every new <seqXML> block | ||||||||||||||||||||||||||||||||||||||||||
| 679 | 3 | $self->{'_seqxml_metadata'} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 680 | |||||||||||||||||||||||||||||||||||||||||||
| 681 | 3 | ▶ | if ( $reader->hasAttributes() ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 682 | 3 | $self->processAttribute( $self->{'_seqxml_metadata'} ); | |||||||||||||||||||||||||||||||||||||||||
| 683 | } | ||||||||||||||||||||||||||||||||||||||||||
| 684 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | $self->throw("no SeqXML metadata!"); | |||||||||||||||||||||||||||||||||||||||||
| 686 | } | ||||||||||||||||||||||||||||||||||||||||||
| 687 | } | ||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||
| 689 | =head2 element_entry | ||||||||||||||||||||||||||||||||||||||||||
| 690 | |||||||||||||||||||||||||||||||||||||||||||
| 691 | Title : element_entry | ||||||||||||||||||||||||||||||||||||||||||
| 692 | Usage : $self->element_entry | ||||||||||||||||||||||||||||||||||||||||||
| 693 | Function: processes a sequence <entry> node | ||||||||||||||||||||||||||||||||||||||||||
| 694 | Returns : none | ||||||||||||||||||||||||||||||||||||||||||
| 695 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 696 | Throws : Exception if sequence ID is not present in <entry> element | ||||||||||||||||||||||||||||||||||||||||||
| 697 | |||||||||||||||||||||||||||||||||||||||||||
| 698 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 699 | |||||||||||||||||||||||||||||||||||||||||||
| 700 | 4 | ▶ | sub element_entry { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
element_entry: called CC=2 SCAR=7.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 701 | 4 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 702 | 4 | my $reader = $self->{'_reader'}; | |||||||||||||||||||||||||||||||||||||||||
| 703 | |||||||||||||||||||||||||||||||||||||||||||
| 704 | 4 | ▶ | if ( $reader->hasAttributes() ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 705 | 4 | $self->processAttribute( $self->{'_current_entry_data'} ); | |||||||||||||||||||||||||||||||||||||||||
| 706 | } | ||||||||||||||||||||||||||||||||||||||||||
| 707 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 708 | 0 | $self->throw("no sequence ID!"); | |||||||||||||||||||||||||||||||||||||||||
| 709 | } | ||||||||||||||||||||||||||||||||||||||||||
| 710 | } | ||||||||||||||||||||||||||||||||||||||||||
| 711 | |||||||||||||||||||||||||||||||||||||||||||
| 712 | =head2 element_species | ||||||||||||||||||||||||||||||||||||||||||
| 713 | |||||||||||||||||||||||||||||||||||||||||||
| 714 | Title : element_entry | ||||||||||||||||||||||||||||||||||||||||||
| 715 | Usage : $self->element_entry | ||||||||||||||||||||||||||||||||||||||||||
| 716 | Function: processes a <species> node, creating a Bio::Species object | ||||||||||||||||||||||||||||||||||||||||||
| 717 | Returns : none | ||||||||||||||||||||||||||||||||||||||||||
| 718 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 719 | Throws : Exception if <species> tag exists but is empty, | ||||||||||||||||||||||||||||||||||||||||||
| 720 | or if the attributes 'name' or 'ncbiTaxID' are undefined | ||||||||||||||||||||||||||||||||||||||||||
| 721 | |||||||||||||||||||||||||||||||||||||||||||
| 722 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 723 | |||||||||||||||||||||||||||||||||||||||||||
| 724 | 2 | ▶ | sub element_species { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
element_species: called CC=4 SCAR=14.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 725 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 726 | 2 | my $reader = $self->{'_reader'}; | |||||||||||||||||||||||||||||||||||||||||
| 727 | 2 | my $data = $self->{'_current_entry_data'}; | |||||||||||||||||||||||||||||||||||||||||
| 728 | |||||||||||||||||||||||||||||||||||||||||||
| 729 | 2 | my $species_data = {}; | |||||||||||||||||||||||||||||||||||||||||
| 730 | 2 | my $species_obj; | |||||||||||||||||||||||||||||||||||||||||
| 731 | |||||||||||||||||||||||||||||||||||||||||||
| 732 | 2 | ▶ | if ( $reader->hasAttributes() ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 733 | 2 | $self->processAttribute($species_data); | |||||||||||||||||||||||||||||||||||||||||
| 734 | } | ||||||||||||||||||||||||||||||||||||||||||
| 735 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | $self->throw("no species information!"); | |||||||||||||||||||||||||||||||||||||||||
| 737 | } | ||||||||||||||||||||||||||||||||||||||||||
| 738 | |||||||||||||||||||||||||||||||||||||||||||
| 739 | 2 | ▶ | if ( defined $species_data->{'name'} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
defined $species_data->{"name"} and defined $species_data->{"ncbiTaxID"}
MC/DC0%0/2
defined $species_data->{"name"} and defined $species_data->{"ncbiTaxID"}
defined $species_data->{"name"}
defined $species_data->{"ncbiTaxID"}
Truth table33%1/3
A and B
A= defined $species_data->{"name"}B= defined $species_data->{"ncbiTaxID"}
| |||||||||||||||||||||||||||||||||||||||||||
| 740 | && defined $species_data->{'ncbiTaxID'} ) | ||||||||||||||||||||||||||||||||||||||||||
| 741 | { | ||||||||||||||||||||||||||||||||||||||||||
| 742 | $species_obj = | ||||||||||||||||||||||||||||||||||||||||||
| 743 | 2 | Bio::Species->new( -ncbi_taxid => $species_data->{'ncbiTaxID'}, ); | |||||||||||||||||||||||||||||||||||||||||
| 744 | 2 | $species_obj->node_name( $species_data->{'name'} ); | |||||||||||||||||||||||||||||||||||||||||
| 745 | 2 | $data->{'species'} = $species_obj; | |||||||||||||||||||||||||||||||||||||||||
| 746 | } | ||||||||||||||||||||||||||||||||||||||||||
| 747 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | $self->throw("<species> attributes name and ncbiTaxID are undefined"); | |||||||||||||||||||||||||||||||||||||||||
| 749 | } | ||||||||||||||||||||||||||||||||||||||||||
| 750 | |||||||||||||||||||||||||||||||||||||||||||
| 751 | } | ||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||
| 753 | =head2 element_description | ||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||
| 755 | Title : element_description | ||||||||||||||||||||||||||||||||||||||||||
| 756 | Usage : $self->element_description | ||||||||||||||||||||||||||||||||||||||||||
| 757 | Function: processes a sequence <description> node; | ||||||||||||||||||||||||||||||||||||||||||
| 758 | a no-op -- description text is read by | ||||||||||||||||||||||||||||||||||||||||||
| 759 | processXMLnode | ||||||||||||||||||||||||||||||||||||||||||
| 760 | Returns : none | ||||||||||||||||||||||||||||||||||||||||||
| 761 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||
| 763 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 764 | |||||||||||||||||||||||||||||||||||||||||||
| 765 | 4 | ▶ | sub element_description { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
element_description: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 766 | 4 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 767 | } | ||||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||
| 769 | =head2 element_RNAseq | ||||||||||||||||||||||||||||||||||||||||||
| 770 | |||||||||||||||||||||||||||||||||||||||||||
| 771 | Title : element_RNAseq | ||||||||||||||||||||||||||||||||||||||||||
| 772 | Usage : $self->element_RNAseq | ||||||||||||||||||||||||||||||||||||||||||
| 773 | Function: processes a sequence <RNAseq> node | ||||||||||||||||||||||||||||||||||||||||||
| 774 | Returns : none | ||||||||||||||||||||||||||||||||||||||||||
| 775 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||
| 777 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 778 | |||||||||||||||||||||||||||||||||||||||||||
| 779 | 2 | ▶ | sub element_RNAseq { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
element_RNAseq: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 780 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 781 | 2 | my $reader = $self->{'_reader'}; | |||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||
| 783 | 2 | my $data = $self->{'_current_entry_data'}; | |||||||||||||||||||||||||||||||||||||||||
| 784 | 2 | $data->{'alphabet'} = 'rna'; | |||||||||||||||||||||||||||||||||||||||||
| 785 | 2 | $data->{'sequence'} = $data->{'RNAseq'}; | |||||||||||||||||||||||||||||||||||||||||
| 786 | |||||||||||||||||||||||||||||||||||||||||||
| 787 | } | ||||||||||||||||||||||||||||||||||||||||||
| 788 | |||||||||||||||||||||||||||||||||||||||||||
| 789 | =head2 element_DNAseq | ||||||||||||||||||||||||||||||||||||||||||
| 790 | |||||||||||||||||||||||||||||||||||||||||||
| 791 | Title : element_DNAseq | ||||||||||||||||||||||||||||||||||||||||||
| 792 | Usage : $self->element_DNAseq | ||||||||||||||||||||||||||||||||||||||||||
| 793 | Function: processes a sequence <DNAseq> node | ||||||||||||||||||||||||||||||||||||||||||
| 794 | Returns : none | ||||||||||||||||||||||||||||||||||||||||||
| 795 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 796 | |||||||||||||||||||||||||||||||||||||||||||
| 797 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 798 | |||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | ▶ | sub element_DNAseq { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
element_DNAseq: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 801 | 0 | my $reader = $self->{'_reader'}; | |||||||||||||||||||||||||||||||||||||||||
| 802 | |||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | my $data = $self->{'_current_entry_data'}; | |||||||||||||||||||||||||||||||||||||||||
| 804 | 0 | $data->{'alphabet'} = 'dna'; | |||||||||||||||||||||||||||||||||||||||||
| 805 | 0 | $data->{'sequence'} = $data->{'DNAseq'}; | |||||||||||||||||||||||||||||||||||||||||
| 806 | |||||||||||||||||||||||||||||||||||||||||||
| 807 | } | ||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||
| 809 | =head2 element_AAseq | ||||||||||||||||||||||||||||||||||||||||||
| 810 | |||||||||||||||||||||||||||||||||||||||||||
| 811 | Title : element_AAseq | ||||||||||||||||||||||||||||||||||||||||||
| 812 | Usage : $self->element_AAseq | ||||||||||||||||||||||||||||||||||||||||||
| 813 | Function: processes a sequence <AAseq> node | ||||||||||||||||||||||||||||||||||||||||||
| 814 | Returns : none | ||||||||||||||||||||||||||||||||||||||||||
| 815 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 816 | |||||||||||||||||||||||||||||||||||||||||||
| 817 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 818 | |||||||||||||||||||||||||||||||||||||||||||
| 819 | 2 | ▶ | sub element_AAseq { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
element_AAseq: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 820 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 821 | 2 | my $reader = $self->{'_reader'}; | |||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||
| 823 | 2 | my $data = $self->{'_current_entry_data'}; | |||||||||||||||||||||||||||||||||||||||||
| 824 | 2 | $data->{'alphabet'} = 'protein'; | |||||||||||||||||||||||||||||||||||||||||
| 825 | 2 | $data->{'sequence'} = $data->{'AAseq'}; | |||||||||||||||||||||||||||||||||||||||||
| 826 | |||||||||||||||||||||||||||||||||||||||||||
| 827 | } | ||||||||||||||||||||||||||||||||||||||||||
| 828 | |||||||||||||||||||||||||||||||||||||||||||
| 829 | =head2 element_DBRef | ||||||||||||||||||||||||||||||||||||||||||
| 830 | |||||||||||||||||||||||||||||||||||||||||||
| 831 | Title : element_DBRef | ||||||||||||||||||||||||||||||||||||||||||
| 832 | Usage : $self->element_DBRef | ||||||||||||||||||||||||||||||||||||||||||
| 833 | Function: processes a sequence <DBRef> node, | ||||||||||||||||||||||||||||||||||||||||||
| 834 | creating a Bio::Annotation::DBLink object | ||||||||||||||||||||||||||||||||||||||||||
| 835 | Returns : none | ||||||||||||||||||||||||||||||||||||||||||
| 836 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 837 | |||||||||||||||||||||||||||||||||||||||||||
| 838 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 839 | |||||||||||||||||||||||||||||||||||||||||||
| 840 | 2 | ▶ | sub element_DBRef { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
element_DBRef: called CC=5 SCAR=18.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 841 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 842 | 2 | my $reader = $self->{'_reader'}; | |||||||||||||||||||||||||||||||||||||||||
| 843 | 2 | my $data = $self->{'_current_entry_data'}; | |||||||||||||||||||||||||||||||||||||||||
| 844 | |||||||||||||||||||||||||||||||||||||||||||
| 845 | 2 | my $DBRef = {}; | |||||||||||||||||||||||||||||||||||||||||
| 846 | 2 | my $annotation_obj; | |||||||||||||||||||||||||||||||||||||||||
| 847 | |||||||||||||||||||||||||||||||||||||||||||
| 848 | 2 | ▶ | if ( $reader->hasAttributes() ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 849 | 2 | $self->processAttribute($DBRef); | |||||||||||||||||||||||||||||||||||||||||
| 850 | } | ||||||||||||||||||||||||||||||||||||||||||
| 851 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 852 | 0 | $self->throw("no DBRef data!"); | |||||||||||||||||||||||||||||||||||||||||
| 853 | } | ||||||||||||||||||||||||||||||||||||||||||
| 854 | |||||||||||||||||||||||||||||||||||||||||||
| 855 | 2 | ▶ | if ( defined $DBRef->{'source'} | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%2/6
defined $DBRef->{"source"} and defined $DBRef->{"id"} and defined $DBRef->{"type"}
defined $DBRef->{"source"} and defined $DBRef->{"id"}
MC/DC0%0/3
defined $DBRef->{"source"} and defined $DBRef->{"id"} and defined $DBRef->{"type"}
defined $DBRef->{"source"}
defined $DBRef->{"id"}
defined $DBRef->{"type"}
Truth table25%1/4
A and B and C
A= defined $DBRef->{"source"}B= defined $DBRef->{"id"}C= defined $DBRef->{"type"}
| |||||||||||||||||||||||||||||||||||||||||||
| 856 | && defined $DBRef->{'id'} | ||||||||||||||||||||||||||||||||||||||||||
| 857 | && defined $DBRef->{'type'}) | ||||||||||||||||||||||||||||||||||||||||||
| 858 | { | ||||||||||||||||||||||||||||||||||||||||||
| 859 | $annotation_obj = Bio::Annotation::DBLink->new( | ||||||||||||||||||||||||||||||||||||||||||
| 860 | -primary_id => $DBRef->{'id'}, | ||||||||||||||||||||||||||||||||||||||||||
| 861 | -database => $DBRef->{'source'}, | ||||||||||||||||||||||||||||||||||||||||||
| 862 | 2 | -type => $DBRef->{'type'}, | |||||||||||||||||||||||||||||||||||||||||
| 863 | -tagname => 'dblink', | ||||||||||||||||||||||||||||||||||||||||||
| 864 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 865 | 2 | push @{ $data->{'DBRefs'} }, $annotation_obj; | |||||||||||||||||||||||||||||||||||||||||
| 866 | } | ||||||||||||||||||||||||||||||||||||||||||
| 867 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 868 | 0 | $self->throw("malformed DBRef data!"); | |||||||||||||||||||||||||||||||||||||||||
| 869 | } | ||||||||||||||||||||||||||||||||||||||||||
| 870 | } | ||||||||||||||||||||||||||||||||||||||||||
| 871 | |||||||||||||||||||||||||||||||||||||||||||
| 872 | =head2 element_property | ||||||||||||||||||||||||||||||||||||||||||
| 873 | |||||||||||||||||||||||||||||||||||||||||||
| 874 | Title : element_property | ||||||||||||||||||||||||||||||||||||||||||
| 875 | Usage : $self->element_property | ||||||||||||||||||||||||||||||||||||||||||
| 876 | Function: processes a sequence <property> node, creating a | ||||||||||||||||||||||||||||||||||||||||||
| 877 | Bio::Annotation::SimpleValue object | ||||||||||||||||||||||||||||||||||||||||||
| 878 | Returns : none | ||||||||||||||||||||||||||||||||||||||||||
| 879 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 880 | |||||||||||||||||||||||||||||||||||||||||||
| 881 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||||||||||||||||
| 883 | 4 | ▶ | sub element_property { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
element_property: called CC=4 SCAR=14.1
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 884 | 4 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 885 | 4 | my $reader = $self->{'_reader'}; | |||||||||||||||||||||||||||||||||||||||||
| 886 | 4 | my $data = $self->{'_current_entry_data'}; | |||||||||||||||||||||||||||||||||||||||||
| 887 | |||||||||||||||||||||||||||||||||||||||||||
| 888 | 4 | my $property = {}; | |||||||||||||||||||||||||||||||||||||||||
| 889 | 4 | my $annotation_obj; | |||||||||||||||||||||||||||||||||||||||||
| 890 | |||||||||||||||||||||||||||||||||||||||||||
| 891 | 4 | ▶ | if ( $reader->hasAttributes() ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 892 | 4 | $self->processAttribute($property); | |||||||||||||||||||||||||||||||||||||||||
| 893 | } | ||||||||||||||||||||||||||||||||||||||||||
| 894 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 895 | 0 | $self->throw("no property data!"); | |||||||||||||||||||||||||||||||||||||||||
| 896 | } | ||||||||||||||||||||||||||||||||||||||||||
| 897 | |||||||||||||||||||||||||||||||||||||||||||
| 898 | 4 | ▶ | if ( defined $property->{'name'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 899 | $annotation_obj = | ||||||||||||||||||||||||||||||||||||||||||
| 900 | 4 | Bio::Annotation::SimpleValue->new( -tagname => $property->{'name'} ); | |||||||||||||||||||||||||||||||||||||||||
| 901 | |||||||||||||||||||||||||||||||||||||||||||
| 902 | 4 | ▶ | if ( defined $property->{'value'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 903 | 2 | $annotation_obj->value( $property->{'value'} ); | |||||||||||||||||||||||||||||||||||||||||
| 904 | } | ||||||||||||||||||||||||||||||||||||||||||
| 905 | |||||||||||||||||||||||||||||||||||||||||||
| 906 | 4 | push @{ $data->{'properties'} }, $annotation_obj; | |||||||||||||||||||||||||||||||||||||||||
| 907 | } | ||||||||||||||||||||||||||||||||||||||||||
| 908 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 909 | 0 | $self->throw("malformatted property!"); | |||||||||||||||||||||||||||||||||||||||||
| 910 | } | ||||||||||||||||||||||||||||||||||||||||||
| 911 | } | ||||||||||||||||||||||||||||||||||||||||||
| 912 | |||||||||||||||||||||||||||||||||||||||||||
| 913 | =head2 end_element_RNAseq | ||||||||||||||||||||||||||||||||||||||||||
| 914 | |||||||||||||||||||||||||||||||||||||||||||
| 915 | Title : end_element_RNAseq | ||||||||||||||||||||||||||||||||||||||||||
| 916 | Usage : $self->end_element_RNAseq | ||||||||||||||||||||||||||||||||||||||||||
| 917 | Function: processes a sequence <RNAseq> node | ||||||||||||||||||||||||||||||||||||||||||
| 918 | Returns : none | ||||||||||||||||||||||||||||||||||||||||||
| 919 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 920 | |||||||||||||||||||||||||||||||||||||||||||
| 921 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 922 | |||||||||||||||||||||||||||||||||||||||||||
| 923 | 2 | ▶ | sub end_element_RNAseq { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
end_element_RNAseq: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 924 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 925 | 2 | my $reader = $self->{'_reader'}; | |||||||||||||||||||||||||||||||||||||||||
| 926 | |||||||||||||||||||||||||||||||||||||||||||
| 927 | 2 | my $data = $self->{'_current_entry_data'}; | |||||||||||||||||||||||||||||||||||||||||
| 928 | 2 | $data->{'alphabet'} = 'rna'; | |||||||||||||||||||||||||||||||||||||||||
| 929 | 2 | $data->{'sequence'} = $data->{'RNAseq'}; | |||||||||||||||||||||||||||||||||||||||||
| 930 | } | ||||||||||||||||||||||||||||||||||||||||||
| 931 | |||||||||||||||||||||||||||||||||||||||||||
| 932 | =head2 end_element_DNAseq | ||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||
| 934 | Title : end_element_DNAseq | ||||||||||||||||||||||||||||||||||||||||||
| 935 | Usage : $self->end_element_DNAseq | ||||||||||||||||||||||||||||||||||||||||||
| 936 | Function: processes a sequence <DNAseq> node | ||||||||||||||||||||||||||||||||||||||||||
| 937 | Returns : none | ||||||||||||||||||||||||||||||||||||||||||
| 938 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 939 | |||||||||||||||||||||||||||||||||||||||||||
| 940 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 941 | |||||||||||||||||||||||||||||||||||||||||||
| 942 | 0 | ▶ | sub end_element_DNAseq { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
end_element_DNAseq: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 943 | 0 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 944 | 0 | my $reader = $self->{'_reader'}; | |||||||||||||||||||||||||||||||||||||||||
| 945 | |||||||||||||||||||||||||||||||||||||||||||
| 946 | 0 | my $data = $self->{'_current_entry_data'}; | |||||||||||||||||||||||||||||||||||||||||
| 947 | 0 | $data->{'alphabet'} = 'dna'; | |||||||||||||||||||||||||||||||||||||||||
| 948 | 0 | $data->{'sequence'} = $data->{'DNAseq'}; | |||||||||||||||||||||||||||||||||||||||||
| 949 | |||||||||||||||||||||||||||||||||||||||||||
| 950 | } | ||||||||||||||||||||||||||||||||||||||||||
| 951 | |||||||||||||||||||||||||||||||||||||||||||
| 952 | =head2 end_element_AAseq | ||||||||||||||||||||||||||||||||||||||||||
| 953 | |||||||||||||||||||||||||||||||||||||||||||
| 954 | Title : end_element_AAseq | ||||||||||||||||||||||||||||||||||||||||||
| 955 | Usage : $self->end_element_AAseq | ||||||||||||||||||||||||||||||||||||||||||
| 956 | Function: processes a sequence <AAseq> node | ||||||||||||||||||||||||||||||||||||||||||
| 957 | Returns : none | ||||||||||||||||||||||||||||||||||||||||||
| 958 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 959 | |||||||||||||||||||||||||||||||||||||||||||
| 960 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 961 | |||||||||||||||||||||||||||||||||||||||||||
| 962 | 2 | ▶ | sub end_element_AAseq { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
end_element_AAseq: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 963 | 2 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 964 | 2 | my $reader = $self->{'_reader'}; | |||||||||||||||||||||||||||||||||||||||||
| 965 | |||||||||||||||||||||||||||||||||||||||||||
| 966 | 2 | my $data = $self->{'_current_entry_data'}; | |||||||||||||||||||||||||||||||||||||||||
| 967 | 2 | $data->{'alphabet'} = 'protein'; | |||||||||||||||||||||||||||||||||||||||||
| 968 | 2 | $data->{'sequence'} = $data->{'AAseq'}; | |||||||||||||||||||||||||||||||||||||||||
| 969 | |||||||||||||||||||||||||||||||||||||||||||
| 970 | } | ||||||||||||||||||||||||||||||||||||||||||
| 971 | |||||||||||||||||||||||||||||||||||||||||||
| 972 | =head2 end_element_entry | ||||||||||||||||||||||||||||||||||||||||||
| 973 | |||||||||||||||||||||||||||||||||||||||||||
| 974 | Title : end_element_entry | ||||||||||||||||||||||||||||||||||||||||||
| 975 | Usage : $self->end_element_entry | ||||||||||||||||||||||||||||||||||||||||||
| 976 | Function: processes the closing </entry> node, creating the Seq object | ||||||||||||||||||||||||||||||||||||||||||
| 977 | Returns : a Bio::Seq object | ||||||||||||||||||||||||||||||||||||||||||
| 978 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 979 | Throws : Exception if sequence, sequence ID, or alphabet are missing | ||||||||||||||||||||||||||||||||||||||||||
| 980 | |||||||||||||||||||||||||||||||||||||||||||
| 981 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 982 | |||||||||||||||||||||||||||||||||||||||||||
| 983 | 4 | ▶ | sub end_element_entry { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
end_element_entry: called CC=12 SCAR=25.7
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 984 | 4 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 985 | 4 | my $reader = $self->{'_reader'}; | |||||||||||||||||||||||||||||||||||||||||
| 986 | |||||||||||||||||||||||||||||||||||||||||||
| 987 | 4 | my $data = $self->{'_current_entry_data'}; | |||||||||||||||||||||||||||||||||||||||||
| 988 | |||||||||||||||||||||||||||||||||||||||||||
| 989 | # make sure we've got at least a seq, an ID, and an alphabet | ||||||||||||||||||||||||||||||||||||||||||
| 990 | 4 | ▶ | unless ( $data->{'sequence'} && length($data->{'sequence'}) > 0) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition33%1/3
$data->{"sequence"} and length $data->{"sequence"} > 0
MC/DC0%0/2
$data->{"sequence"} and length $data->{"sequence"} > 0
$data->{"sequence"}
length $data->{"sequence"} > 0
Truth table33%1/3
A and B
A= $data->{"sequence"}B= length $data->{"sequence"} > 0
| |||||||||||||||||||||||||||||||||||||||||||
| 991 | 0 | $self->throw("this entry lacks a sequence"); | |||||||||||||||||||||||||||||||||||||||||
| 992 | } | ||||||||||||||||||||||||||||||||||||||||||
| 993 | 4 | ▶ | unless ( $data->{'id'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 994 | 0 | $self->throw("this entry lacks an id"); | |||||||||||||||||||||||||||||||||||||||||
| 995 | } | ||||||||||||||||||||||||||||||||||||||||||
| 996 | 4 | ▶ | unless ( $data->{'alphabet'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 997 | 0 | $self->throw("this entry lacks an alphabet"); | |||||||||||||||||||||||||||||||||||||||||
| 998 | } | ||||||||||||||||||||||||||||||||||||||||||
| 999 | |||||||||||||||||||||||||||||||||||||||||||
| 1000 | # create new sequence object with minimum necessary parameters | ||||||||||||||||||||||||||||||||||||||||||
| 1001 | my $seq_obj = $self->sequence_factory->create( | ||||||||||||||||||||||||||||||||||||||||||
| 1002 | -seq => $data->{'sequence'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1003 | -alphabet => $data->{'alphabet'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1004 | -id => $data->{'id'}, | ||||||||||||||||||||||||||||||||||||||||||
| 1005 | 4 | -primary_id => $data->{'id'}, | |||||||||||||||||||||||||||||||||||||||||
| 1006 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1007 | |||||||||||||||||||||||||||||||||||||||||||
| 1008 | # add additional parameters if available | ||||||||||||||||||||||||||||||||||||||||||
| 1009 | 4 | ▶ | if ( $data->{'description'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1010 | 4 | $seq_obj->desc( $data->{'description'} ); | |||||||||||||||||||||||||||||||||||||||||
| 1011 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1012 | 4 | ▶ | if ( $data->{'species'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1013 | 2 | $seq_obj->species( $data->{'species'} ); | |||||||||||||||||||||||||||||||||||||||||
| 1014 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1015 | 4 | ▶ | if ( $data->{'DBRefs'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1016 | 2 | foreach my $annotation_obj ( @{ $data->{'DBRefs'} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 1017 | 2 | $seq_obj->add_Annotation($annotation_obj); | |||||||||||||||||||||||||||||||||||||||||
| 1018 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1019 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1020 | 4 | ▶ | if ( $data->{'properties'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1021 | 2 | foreach my $annotation_obj ( @{ $data->{'properties'} } ) { | |||||||||||||||||||||||||||||||||||||||||
| 1022 | 4 | $seq_obj->add_Annotation($annotation_obj); | |||||||||||||||||||||||||||||||||||||||||
| 1023 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1024 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1025 | 4 | ▶ | if ( $data->{'source'} ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 1026 | my $annotation_obj = Bio::Annotation::SimpleValue->new( | ||||||||||||||||||||||||||||||||||||||||||
| 1027 | '-tagname' => 'source', | ||||||||||||||||||||||||||||||||||||||||||
| 1028 | 2 | '-value' => $data->{'source'}, | |||||||||||||||||||||||||||||||||||||||||
| 1029 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 1030 | 2 | $seq_obj->add_Annotation($annotation_obj); | |||||||||||||||||||||||||||||||||||||||||
| 1031 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1032 | |||||||||||||||||||||||||||||||||||||||||||
| 1033 | # empty the temporary data store | ||||||||||||||||||||||||||||||||||||||||||
| 1034 | 4 | $self->{'_current_entry_data'} = {}; | |||||||||||||||||||||||||||||||||||||||||
| 1035 | |||||||||||||||||||||||||||||||||||||||||||
| 1036 | 4 | return $seq_obj; | |||||||||||||||||||||||||||||||||||||||||
| 1037 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1038 | |||||||||||||||||||||||||||||||||||||||||||
| 1039 | =head2 end_element_default | ||||||||||||||||||||||||||||||||||||||||||
| 1040 | |||||||||||||||||||||||||||||||||||||||||||
| 1041 | Title : end_element_default | ||||||||||||||||||||||||||||||||||||||||||
| 1042 | Usage : $self->end_element_default | ||||||||||||||||||||||||||||||||||||||||||
| 1043 | Function: processes all other closing tags; | ||||||||||||||||||||||||||||||||||||||||||
| 1044 | a no-op. | ||||||||||||||||||||||||||||||||||||||||||
| 1045 | Returns : none | ||||||||||||||||||||||||||||||||||||||||||
| 1046 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 1047 | |||||||||||||||||||||||||||||||||||||||||||
| 1048 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1049 | |||||||||||||||||||||||||||||||||||||||||||
| 1050 | 4 | ▶ | sub end_element_default { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
end_element_default: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1051 | 4 | my ($self) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 1052 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1053 | |||||||||||||||||||||||||||||||||||||||||||
| 1054 | =head2 DESTROY | ||||||||||||||||||||||||||||||||||||||||||
| 1055 | |||||||||||||||||||||||||||||||||||||||||||
| 1056 | Title : DESTROY | ||||||||||||||||||||||||||||||||||||||||||
| 1057 | Usage : called automatically by Perl just before object | ||||||||||||||||||||||||||||||||||||||||||
| 1058 | goes out of scope | ||||||||||||||||||||||||||||||||||||||||||
| 1059 | Function: performs a write flush | ||||||||||||||||||||||||||||||||||||||||||
| 1060 | Returns : none | ||||||||||||||||||||||||||||||||||||||||||
| 1061 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 1062 | |||||||||||||||||||||||||||||||||||||||||||
| 1063 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1064 | |||||||||||||||||||||||||||||||||||||||||||
| 1065 | 5 | ▶ | sub DESTROY { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
DESTROY: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||||||||||||
| 1066 | 5 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1067 | 5 | ▶ | $self->flush if $self->_flush_on_write && defined $self->_fh; | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->_flush_on_write and defined $self->_fh
MC/DC50%1/2
$self->_flush_on_write and defined $self->_fh
$self->_flush_on_write
defined $self->_fh
Truth table66%2/3
A and B
A= $self->_flush_on_writeB= defined $self->_fh
| |||||||||||||||||||||||||||||||||||||||||||
| 1068 | 5 | $self->SUPER::DESTROY; | |||||||||||||||||||||||||||||||||||||||||
| 1069 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1070 | |||||||||||||||||||||||||||||||||||||||||||
| 1071 | =head2 close | ||||||||||||||||||||||||||||||||||||||||||
| 1072 | |||||||||||||||||||||||||||||||||||||||||||
| 1073 | Title : close | ||||||||||||||||||||||||||||||||||||||||||
| 1074 | Usage : $seqio_obj->close(). | ||||||||||||||||||||||||||||||||||||||||||
| 1075 | Function: writes closing </seqXML> tag. | ||||||||||||||||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||||||||||||||||
| 1077 | close() will be called automatically by Perl when your | ||||||||||||||||||||||||||||||||||||||||||
| 1078 | program exits, but if you want to use the seqXML file | ||||||||||||||||||||||||||||||||||||||||||
| 1079 | you've written before then, you'll need to do an explicit | ||||||||||||||||||||||||||||||||||||||||||
| 1080 | close first to get the final </seqXML> tag. | ||||||||||||||||||||||||||||||||||||||||||
| 1081 | Returns : none | ||||||||||||||||||||||||||||||||||||||||||
| 1082 | Args : none | ||||||||||||||||||||||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||||||||||||||||||||||
| 1084 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 1085 | |||||||||||||||||||||||||||||||||||||||||||
| 1086 | 7 | ▶ | sub close { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
close: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 1087 | 7 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 1088 | 7 | ▶ | if ( $self->mode eq 'w' && $self->{'_writer'}->within_element('seqXML') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->mode eq "w" and $self->{"_writer"}->within_element("seqXML")
MC/DC100%2/2
$self->mode eq "w" and $self->{"_writer"}->within_element("seqXML")
$self->mode eq "w"
$self->{"_writer"}->within_element("seqXML")
Truth table100%3/3
A and B
A= $self->mode eq "w"B= $self->{"_writer"}->within_element("seqXML")
| |||||||||||||||||||||||||||||||||||||||||||
| 1089 | 2 | $self->{'_writer'}->endTag("seqXML"); | |||||||||||||||||||||||||||||||||||||||||
| 1090 | 2 | $self->{'_writer'}->end(); | |||||||||||||||||||||||||||||||||||||||||
| 1091 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1092 | 7 | $self->SUPER::close(); | |||||||||||||||||||||||||||||||||||||||||
| 1093 | } | ||||||||||||||||||||||||||||||||||||||||||
| 1094 | |||||||||||||||||||||||||||||||||||||||||||
| 1095 | 2 | 1; | |||||||||||||||||||||||||||||||||||||||||