| 1 | package Bio::Phylo::NeXML::Meta; | ||||||||||||||||||||||||||||||||||||||||||
| 2 | 10 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 3 | 10 | ▶ | use warnings; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 4 | 10 | ▶ | use base 'Bio::Phylo::Listable'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 5 | 10 | ▶ | use Bio::Phylo::Util::CONSTANT qw'_DOMCREATOR_ _META_ /looks_like/'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 6 | 10 | ▶ | use Bio::Phylo::Util::Exceptions 'throw'; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 7 | 10 | ▶ | use Bio::Phylo::Factory; | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 8 | { | ||||||||||||||||||||||||||||||||||||||||||
| 9 | 10 | my $fac = Bio::Phylo::Factory->new; | |||||||||||||||||||||||||||||||||||||||||
| 10 | 10 | my @fields = \( my ( %property, %content ) ); | |||||||||||||||||||||||||||||||||||||||||
| 11 | 10 | my $TYPE_CONSTANT = _META_; | |||||||||||||||||||||||||||||||||||||||||
| 12 | 10 | my $CONTAINER_CONSTANT = $TYPE_CONSTANT; | |||||||||||||||||||||||||||||||||||||||||
| 13 | |||||||||||||||||||||||||||||||||||||||||||
| 14 | =head1 NAME | ||||||||||||||||||||||||||||||||||||||||||
| 15 | |||||||||||||||||||||||||||||||||||||||||||
| 16 | Bio::Phylo::NeXML::Meta - Single predicate/object annotation, attached to an | ||||||||||||||||||||||||||||||||||||||||||
| 17 | xml-writable subject | ||||||||||||||||||||||||||||||||||||||||||
| 18 | |||||||||||||||||||||||||||||||||||||||||||
| 19 | =head1 SYNOPSIS | ||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||
| 21 | use Bio::Phylo::Factory; | ||||||||||||||||||||||||||||||||||||||||||
| 22 | use Bio::Phylo::Util::CONSTANT ':namespaces'; | ||||||||||||||||||||||||||||||||||||||||||
| 23 | my $fac = Bio::Phylo::Factory->new; | ||||||||||||||||||||||||||||||||||||||||||
| 24 | my $url = 'http://purl.org/phylo/treebase/phylows/study/TB2:S1787'; | ||||||||||||||||||||||||||||||||||||||||||
| 25 | my $proj = $fac->create_project->add_meta( | ||||||||||||||||||||||||||||||||||||||||||
| 26 | $fac->create_meta( | ||||||||||||||||||||||||||||||||||||||||||
| 27 | '-namespaces' => { 'cdao' => _NS_CDAO_ }, | ||||||||||||||||||||||||||||||||||||||||||
| 28 | '-triple' => { | ||||||||||||||||||||||||||||||||||||||||||
| 29 | 'cdao:hasMeta' => $fac->create_meta( | ||||||||||||||||||||||||||||||||||||||||||
| 30 | '-namespaces' => { 'cdao' => _NS_CDAO_ }, | ||||||||||||||||||||||||||||||||||||||||||
| 31 | '-triple' => { 'cdao:has_External_Reference' => $url } | ||||||||||||||||||||||||||||||||||||||||||
| 32 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 33 | } | ||||||||||||||||||||||||||||||||||||||||||
| 34 | ) | ||||||||||||||||||||||||||||||||||||||||||
| 35 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 36 | |||||||||||||||||||||||||||||||||||||||||||
| 37 | =head1 DESCRIPTION | ||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||
| 39 | To comply with the NeXML standard (L<http://www.nexml.org>), Bio::Phylo | ||||||||||||||||||||||||||||||||||||||||||
| 40 | implements metadata annotations which consist conceptually of RDF triples where | ||||||||||||||||||||||||||||||||||||||||||
| 41 | the subject is a container object that subclasses | ||||||||||||||||||||||||||||||||||||||||||
| 42 | L<Bio::Phylo::NeXML::Writable>, and the predicate and object are defined in | ||||||||||||||||||||||||||||||||||||||||||
| 43 | this class. | ||||||||||||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||||||||||||
| 45 | The objects of the triples provided by this class can be of any simple type | ||||||||||||||||||||||||||||||||||||||||||
| 46 | (string, number) or one of L<XML::DOM>, L<XML::GDOME>, L<XML::LibXML>, | ||||||||||||||||||||||||||||||||||||||||||
| 47 | L<XML::Twig>, L<XML::DOM2>, L<XML::DOMBacked>, L<XML::Handler>, L<XML::Element>, | ||||||||||||||||||||||||||||||||||||||||||
| 48 | L<XML::API>, L<XML::Code> or L<XML::XMLWriter> or L<RDF::Core::Model>. | ||||||||||||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||||||||||||
| 50 | When serialized, the Bio::Phylo::NeXML::Meta object in NeXML is typically written out | ||||||||||||||||||||||||||||||||||||||||||
| 51 | as an element called 'meta', with RDFa compliant attributes. | ||||||||||||||||||||||||||||||||||||||||||
| 52 | |||||||||||||||||||||||||||||||||||||||||||
| 53 | =head1 METHODS | ||||||||||||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||||||||||||
| 55 | =head2 CONSTRUCTOR | ||||||||||||||||||||||||||||||||||||||||||
| 56 | |||||||||||||||||||||||||||||||||||||||||||
| 57 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||||||||||||
| 59 | =item new() | ||||||||||||||||||||||||||||||||||||||||||
| 60 | |||||||||||||||||||||||||||||||||||||||||||
| 61 | Type : Constructor | ||||||||||||||||||||||||||||||||||||||||||
| 62 | Title : new | ||||||||||||||||||||||||||||||||||||||||||
| 63 | Usage : my $anno = Bio::Phylo::NeXML::Meta->new; | ||||||||||||||||||||||||||||||||||||||||||
| 64 | Function: Initializes a Bio::Phylo::NeXML::Meta object. | ||||||||||||||||||||||||||||||||||||||||||
| 65 | Returns : A Bio::Phylo::NeXML::Meta object. | ||||||||||||||||||||||||||||||||||||||||||
| 66 | Args : optional constructor arguments are key/value | ||||||||||||||||||||||||||||||||||||||||||
| 67 | pairs where the key corresponds with any of | ||||||||||||||||||||||||||||||||||||||||||
| 68 | the methods that starts with set_ (i.e. mutators) | ||||||||||||||||||||||||||||||||||||||||||
| 69 | and the value is the permitted argument for such | ||||||||||||||||||||||||||||||||||||||||||
| 70 | a method. The method name is changed such that, | ||||||||||||||||||||||||||||||||||||||||||
| 71 | in order to access the set_value($val) method | ||||||||||||||||||||||||||||||||||||||||||
| 72 | in the constructor, you would pass -value => $val | ||||||||||||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||||||||||||
| 74 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 75 | |||||||||||||||||||||||||||||||||||||||||||
| 76 | # sub new { return shift->SUPER::new( '-tag' => 'meta', @_ ) } | ||||||||||||||||||||||||||||||||||||||||||
| 77 | 1494 | ▶ | my $set_content = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=16 SCAR=40.8
| |||||||||||||||||||||||||||||||||||||||||||
| 78 | 1494 | my ( $self, $content ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 79 | 1494 | my $predicateName = 'property'; | |||||||||||||||||||||||||||||||||||||||||
| 80 | 1494 | $content{ $self->get_id } = $content; | |||||||||||||||||||||||||||||||||||||||||
| 81 | 1494 | my %resource = ( 'xsi:type' => 'nex:ResourceMeta' ); | |||||||||||||||||||||||||||||||||||||||||
| 82 | 1494 | my %literal = ( 'xsi:type' => 'nex:LiteralMeta' ); | |||||||||||||||||||||||||||||||||||||||||
| 83 | 1494 | ▶ | if ( not ref $content ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 84 | 1494 | ▶ | if ( $content && ( $content =~ m|^http://| or $content =~ m|^urn:| ) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition50%3/6
$content and $content =~ m[^http://] || $content =~ /^urn:/
$content =~ m[^http://] or $content =~ /^urn:/
MC/DC0%0/3
$content and $content =~ m[^http://] || $content =~ /^urn:/
$content
$content =~ m[^http://]
$content =~ /^urn:/
Truth table50%2/4
A and B or C
A= $contentB= $content =~ m[^http://]C= $content =~ /^urn:/
| |||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | $content =~ s/&([^a])/&$1/g; | |||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | $self->set_attributes( 'href' => $content, %resource ); | |||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | ▶ | if ( my $prop = $self->get_attributes('property') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 88 | 0 | $self->set_attributes( 'rel' => $prop ); | |||||||||||||||||||||||||||||||||||||||||
| 89 | 0 | $self->unset_attribute('property'); | |||||||||||||||||||||||||||||||||||||||||
| 90 | 0 | $predicateName = 'rel'; | |||||||||||||||||||||||||||||||||||||||||
| 91 | } | ||||||||||||||||||||||||||||||||||||||||||
| 92 | } | ||||||||||||||||||||||||||||||||||||||||||
| 93 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 94 | 1494 | $self->set_attributes( 'content' => $content, %literal ); | |||||||||||||||||||||||||||||||||||||||||
| 95 | 1494 | ▶ | if ( looks_like_number $content ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||
| 96 | 1057 | ▶ | my $dt = $content == int($content) | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$content == int $content and not $content =~ /\./
MC/DC100%2/2
$content == int $content and not $content =~ /\./
$content == int $content
not $content =~ /\./
Truth table100%3/3
A and not(B)
A= $content == int $contentB= not $content =~ /\./
| |||||||||||||||||||||||||||||||||||||||||||
| 97 | && $content !~ /\./ ? 'integer' : 'float'; | ||||||||||||||||||||||||||||||||||||||||||
| 98 | 1057 | $self->set_attributes( 'datatype' => 'xsd:' . $dt ); | |||||||||||||||||||||||||||||||||||||||||
| 99 | } | ||||||||||||||||||||||||||||||||||||||||||
| 100 | ▶ | elsif ( $content && ( $content eq 'true' or $content eq 'false' ) ) { | |||||||||||||||||||||||||||||||||||||||||
|
Condition50%3/6
$content and $content eq "true" || $content eq "false"
$content eq "true" or $content eq "false"
MC/DC0%0/3
$content and $content eq "true" || $content eq "false"
$content
$content eq "true"
$content eq "false"
Truth table50%2/4
A and B or C
A= $contentB= $content eq "true"C= $content eq "false"
| |||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | $self->set_attributes( 'datatype' => 'xsd:boolean' ); | |||||||||||||||||||||||||||||||||||||||||
| 102 | } | ||||||||||||||||||||||||||||||||||||||||||
| 103 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 104 | 437 | $self->set_attributes( 'datatype' => 'xsd:string' ); | |||||||||||||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||||||||||||
| 107 | } | ||||||||||||||||||||||||||||||||||||||||||
| 108 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | if ( looks_like_instance $content, | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition0%0/3
&looks_like_instance($content, "Bio::Phylo") and $content->_type == $TYPE_CONSTANT
MC/DC0%0/2
&looks_like_instance($content, "Bio::Phylo") and $content->_type == $TYPE_CONSTANT
&looks_like_instance($content, "Bio::Phylo")
$content->_type == $TYPE_CONSTANT
Truth table0%0/3
A and B
A= &looks_like_instance($content, "Bio::Phylo")B= $content->_type == $TYPE_CONSTANT
| |||||||||||||||||||||||||||||||||||||||||||
| 110 | 'Bio::Phylo' and $content->_type == $TYPE_CONSTANT ) | ||||||||||||||||||||||||||||||||||||||||||
| 111 | { | ||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | $self->insert($content)->set_attributes(%resource); | |||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | ▶ | if ( my $prop = $self->get_attributes('property') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | $self->set_attributes( 'rel' => $prop ); | |||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | $self->unset_attribute('property'); | |||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $predicateName = 'rel'; | |||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||
| 119 | elsif ( looks_like_instance $content, 'DateTime' ) { | ||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | $self->set_attributes( | |||||||||||||||||||||||||||||||||||||||||
| 121 | 'content' => $content->iso8601(), | ||||||||||||||||||||||||||||||||||||||||||
| 122 | 'datatype' => 'xsd:date', | ||||||||||||||||||||||||||||||||||||||||||
| 123 | %literal | ||||||||||||||||||||||||||||||||||||||||||
| 124 | ); | ||||||||||||||||||||||||||||||||||||||||||
| 125 | } | ||||||||||||||||||||||||||||||||||||||||||
| 126 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 127 | 0 | $self->set_attributes( 'datatype' => 'rdf:XMLLiteral', %resource ); | |||||||||||||||||||||||||||||||||||||||||
| 128 | 0 | $self->insert( $fac->create_xmlliteral($content) ); | |||||||||||||||||||||||||||||||||||||||||
| 129 | 0 | $self->unset_attribute('content'); | |||||||||||||||||||||||||||||||||||||||||
| 130 | } | ||||||||||||||||||||||||||||||||||||||||||
| 131 | } | ||||||||||||||||||||||||||||||||||||||||||
| 132 | 1494 | $property{ shift->get_id } = $predicateName; | |||||||||||||||||||||||||||||||||||||||||
| 133 | 1494 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 134 | 10 | }; | |||||||||||||||||||||||||||||||||||||||||
| 135 | 1494 | ▶ | my $set_property = sub { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: called CC=3 SCAR=12.3
| |||||||||||||||||||||||||||||||||||||||||||
| 136 | 1494 | my ( $self, $property ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 137 | 1494 | ▶ | if ( $property =~ m/^([a-zA-Z_]+):([a-zA-Z0-9_\-\.]+)$/ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 138 | 1494 | my ( $prefix, $prop ) = ( $1, $2 ); | |||||||||||||||||||||||||||||||||||||||||
| 139 | 1494 | ▶ | if ( $self->get_namespaces($prefix) ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 140 | 1494 | $self->set_attributes( 'property' => $property ); | |||||||||||||||||||||||||||||||||||||||||
| 141 | } | ||||||||||||||||||||||||||||||||||||||||||
| 142 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 143 | 0 | throw 'BadArgs' => "Prefix $prefix not bound to a namespace"; | |||||||||||||||||||||||||||||||||||||||||
| 144 | } | ||||||||||||||||||||||||||||||||||||||||||
| 145 | } | ||||||||||||||||||||||||||||||||||||||||||
| 146 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | throw 'BadString' => "$property is not a valid CURIE"; | |||||||||||||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||||||||||||
| 149 | 10 | }; | |||||||||||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||||||||||||
| 151 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 152 | |||||||||||||||||||||||||||||||||||||||||||
| 153 | =head2 MUTATORS | ||||||||||||||||||||||||||||||||||||||||||
| 154 | |||||||||||||||||||||||||||||||||||||||||||
| 155 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 156 | |||||||||||||||||||||||||||||||||||||||||||
| 157 | =item set_triple() | ||||||||||||||||||||||||||||||||||||||||||
| 158 | |||||||||||||||||||||||||||||||||||||||||||
| 159 | Populates the triple, assuming that the invocant is attached to a subject. | ||||||||||||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||||||||||||
| 161 | Type : Mutator | ||||||||||||||||||||||||||||||||||||||||||
| 162 | Title : set_triple | ||||||||||||||||||||||||||||||||||||||||||
| 163 | Usage : $meta->set_triple( $predicate, $object ); | ||||||||||||||||||||||||||||||||||||||||||
| 164 | Function: Populates the triple. | ||||||||||||||||||||||||||||||||||||||||||
| 165 | Returns : Modified object. | ||||||||||||||||||||||||||||||||||||||||||
| 166 | Args : $predicate - a CURIE whose namespace prefix must | ||||||||||||||||||||||||||||||||||||||||||
| 167 | have been bound previously using | ||||||||||||||||||||||||||||||||||||||||||
| 168 | $meta->set_namespaces( $prefix, $uri ); | ||||||||||||||||||||||||||||||||||||||||||
| 169 | $object - any of the valid object types: a number, | ||||||||||||||||||||||||||||||||||||||||||
| 170 | a string, a url, a nested annotation | ||||||||||||||||||||||||||||||||||||||||||
| 171 | or anything that can be adapted by | ||||||||||||||||||||||||||||||||||||||||||
| 172 | Bio::Phylo::NeXML::Meta::XMLLiteral | ||||||||||||||||||||||||||||||||||||||||||
| 173 | |||||||||||||||||||||||||||||||||||||||||||
| 174 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 175 | |||||||||||||||||||||||||||||||||||||||||||
| 176 | 1494 | ▶ | sub set_triple : Clonable { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_triple: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 177 | 1494 | my ( $self, $property, $content ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 178 | 1494 | ▶ | if ( ref($property) && ref($property) eq 'HASH' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
ref $property and ref $property eq "HASH"
MC/DC50%1/2
ref $property and ref $property eq "HASH"
ref $property
ref $property eq "HASH"
Truth table66%2/3
A and B
A= ref $propertyB= ref $property eq "HASH"
| |||||||||||||||||||||||||||||||||||||||||||
| 179 | 1423 | ( $property, $content ) = each %{$property}; | |||||||||||||||||||||||||||||||||||||||||
| 180 | } | ||||||||||||||||||||||||||||||||||||||||||
| 181 | 1494 | $set_property->( $self, $property ); | |||||||||||||||||||||||||||||||||||||||||
| 182 | 1494 | $set_content->( $self, $content ); | |||||||||||||||||||||||||||||||||||||||||
| 183 | 1494 | return $self; | |||||||||||||||||||||||||||||||||||||||||
| 184 | 10 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 185 | |||||||||||||||||||||||||||||||||||||||||||
| 186 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 187 | |||||||||||||||||||||||||||||||||||||||||||
| 188 | =head2 ACCESSORS | ||||||||||||||||||||||||||||||||||||||||||
| 189 | |||||||||||||||||||||||||||||||||||||||||||
| 190 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 191 | |||||||||||||||||||||||||||||||||||||||||||
| 192 | =item get_triple () | ||||||||||||||||||||||||||||||||||||||||||
| 193 | |||||||||||||||||||||||||||||||||||||||||||
| 194 | Returns predicate and object for the triple | ||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||
| 196 | Type : Accessor | ||||||||||||||||||||||||||||||||||||||||||
| 197 | Title : get_triple | ||||||||||||||||||||||||||||||||||||||||||
| 198 | Usage : my ( $predicate, $object ) = $anno->get_triple; | ||||||||||||||||||||||||||||||||||||||||||
| 199 | Function: Returns triple | ||||||||||||||||||||||||||||||||||||||||||
| 200 | Returns : Predicate and object of a triple | ||||||||||||||||||||||||||||||||||||||||||
| 201 | Args : NONE | ||||||||||||||||||||||||||||||||||||||||||
| 202 | |||||||||||||||||||||||||||||||||||||||||||
| 203 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 204 | |||||||||||||||||||||||||||||||||||||||||||
| 205 | 0 | ▶ | sub get_triple { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_triple: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 206 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | return $self->get_predicate, $self->get_object; | |||||||||||||||||||||||||||||||||||||||||
| 208 | } | ||||||||||||||||||||||||||||||||||||||||||
| 209 | |||||||||||||||||||||||||||||||||||||||||||
| 210 | =item get_object() | ||||||||||||||||||||||||||||||||||||||||||
| 211 | |||||||||||||||||||||||||||||||||||||||||||
| 212 | Returns triple object | ||||||||||||||||||||||||||||||||||||||||||
| 213 | |||||||||||||||||||||||||||||||||||||||||||
| 214 | Type : Accessor | ||||||||||||||||||||||||||||||||||||||||||
| 215 | Title : get_object | ||||||||||||||||||||||||||||||||||||||||||
| 216 | Usage : my $val = $anno->get_object; | ||||||||||||||||||||||||||||||||||||||||||
| 217 | Function: Returns triple object | ||||||||||||||||||||||||||||||||||||||||||
| 218 | Returns : A triple object | ||||||||||||||||||||||||||||||||||||||||||
| 219 | Args : NONE | ||||||||||||||||||||||||||||||||||||||||||
| 220 | |||||||||||||||||||||||||||||||||||||||||||
| 221 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 222 | |||||||||||||||||||||||||||||||||||||||||||
| 223 | 1714 | ▶ | sub get_object { $content{ shift->get_id } } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_object: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 224 | |||||||||||||||||||||||||||||||||||||||||||
| 225 | =item get_predicate() | ||||||||||||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||||||||||||
| 227 | Returns triple predicate | ||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||
| 229 | Type : Accessor | ||||||||||||||||||||||||||||||||||||||||||
| 230 | Title : get_predicate | ||||||||||||||||||||||||||||||||||||||||||
| 231 | Usage : my $val = $anno->get_predicate; | ||||||||||||||||||||||||||||||||||||||||||
| 232 | Function: Returns triple predicate | ||||||||||||||||||||||||||||||||||||||||||
| 233 | Returns : A triple predicate | ||||||||||||||||||||||||||||||||||||||||||
| 234 | Args : NONE | ||||||||||||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||||||||||||
| 236 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||
| 238 | 15014 | ▶ | sub get_predicate { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_predicate: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 239 | 15014 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 240 | 15014 | my $predicateName = $property{ $self->get_id }; | |||||||||||||||||||||||||||||||||||||||||
| 241 | 15014 | return $self->get_attributes->{$predicateName}; | |||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||
| 244 | =item get_predicate_namespace() | ||||||||||||||||||||||||||||||||||||||||||
| 245 | |||||||||||||||||||||||||||||||||||||||||||
| 246 | Returns predicate namespace | ||||||||||||||||||||||||||||||||||||||||||
| 247 | |||||||||||||||||||||||||||||||||||||||||||
| 248 | Type : Accessor | ||||||||||||||||||||||||||||||||||||||||||
| 249 | Title : get_predicate_namespace | ||||||||||||||||||||||||||||||||||||||||||
| 250 | Usage : my $val = $anno->get_predicate_namespace; | ||||||||||||||||||||||||||||||||||||||||||
| 251 | Function: Returns predicate namespace | ||||||||||||||||||||||||||||||||||||||||||
| 252 | Returns : A namespace | ||||||||||||||||||||||||||||||||||||||||||
| 253 | Args : NONE | ||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||
| 255 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 256 | |||||||||||||||||||||||||||||||||||||||||||
| 257 | 1282 | ▶ | sub get_predicate_namespace { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_predicate_namespace: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 258 | 1282 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 259 | 1282 | my $predicate = $self->get_predicate; | |||||||||||||||||||||||||||||||||||||||||
| 260 | 1282 | my ( $pre, $pred ) = split /:/, $predicate; | |||||||||||||||||||||||||||||||||||||||||
| 261 | 1282 | return $self->get_namespaces($pre); | |||||||||||||||||||||||||||||||||||||||||
| 262 | } | ||||||||||||||||||||||||||||||||||||||||||
| 263 | |||||||||||||||||||||||||||||||||||||||||||
| 264 | =item get_predicate_local() | ||||||||||||||||||||||||||||||||||||||||||
| 265 | |||||||||||||||||||||||||||||||||||||||||||
| 266 | Returns predicate without prefix | ||||||||||||||||||||||||||||||||||||||||||
| 267 | |||||||||||||||||||||||||||||||||||||||||||
| 268 | Type : Accessor | ||||||||||||||||||||||||||||||||||||||||||
| 269 | Title : get_predicate_local | ||||||||||||||||||||||||||||||||||||||||||
| 270 | Usage : my $val = $anno->get_predicate_local; | ||||||||||||||||||||||||||||||||||||||||||
| 271 | Function: Returns predicate without prefix | ||||||||||||||||||||||||||||||||||||||||||
| 272 | Returns : A predicate | ||||||||||||||||||||||||||||||||||||||||||
| 273 | Args : NONE | ||||||||||||||||||||||||||||||||||||||||||
| 274 | |||||||||||||||||||||||||||||||||||||||||||
| 275 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 276 | |||||||||||||||||||||||||||||||||||||||||||
| 277 | 637 | ▶ | sub get_predicate_local { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_predicate_local: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 278 | 637 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 279 | 637 | my $predicate = $self->get_predicate; | |||||||||||||||||||||||||||||||||||||||||
| 280 | 637 | my ( $pre, $pred ) = split /:/, $predicate; | |||||||||||||||||||||||||||||||||||||||||
| 281 | 637 | return $pred; | |||||||||||||||||||||||||||||||||||||||||
| 282 | } | ||||||||||||||||||||||||||||||||||||||||||
| 283 | |||||||||||||||||||||||||||||||||||||||||||
| 284 | =item get_object_type() | ||||||||||||||||||||||||||||||||||||||||||
| 285 | |||||||||||||||||||||||||||||||||||||||||||
| 286 | Returns data type of object | ||||||||||||||||||||||||||||||||||||||||||
| 287 | |||||||||||||||||||||||||||||||||||||||||||
| 288 | Type : Accessor | ||||||||||||||||||||||||||||||||||||||||||
| 289 | Title : get_object_type | ||||||||||||||||||||||||||||||||||||||||||
| 290 | Usage : my $val = $anno->get_object_type; | ||||||||||||||||||||||||||||||||||||||||||
| 291 | Function: Returns data type of object | ||||||||||||||||||||||||||||||||||||||||||
| 292 | Returns : A local predicate, e.g. 'boolean' | ||||||||||||||||||||||||||||||||||||||||||
| 293 | Args : NONE | ||||||||||||||||||||||||||||||||||||||||||
| 294 | |||||||||||||||||||||||||||||||||||||||||||
| 295 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 296 | |||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | sub get_object_type { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_object_type: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | ▶ | if ( my $type = $self->get_attributes('datatype') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | my ( $pre, $datatype ) = split /:/, $type; | |||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | return $datatype; | |||||||||||||||||||||||||||||||||||||||||
| 302 | } | ||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||
| 304 | |||||||||||||||||||||||||||||||||||||||||||
| 305 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 306 | |||||||||||||||||||||||||||||||||||||||||||
| 307 | =head2 TESTS | ||||||||||||||||||||||||||||||||||||||||||
| 308 | |||||||||||||||||||||||||||||||||||||||||||
| 309 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 310 | |||||||||||||||||||||||||||||||||||||||||||
| 311 | =item is_resource() | ||||||||||||||||||||||||||||||||||||||||||
| 312 | |||||||||||||||||||||||||||||||||||||||||||
| 313 | Returns whether the object is a resource (e.g. an href or a nested XMLLiteral) | ||||||||||||||||||||||||||||||||||||||||||
| 314 | |||||||||||||||||||||||||||||||||||||||||||
| 315 | Type : Accessor | ||||||||||||||||||||||||||||||||||||||||||
| 316 | Title : is_resource | ||||||||||||||||||||||||||||||||||||||||||
| 317 | Usage : my $val = $anno->is_resource; | ||||||||||||||||||||||||||||||||||||||||||
| 318 | Function: Returns whether object is a resource | ||||||||||||||||||||||||||||||||||||||||||
| 319 | Returns : Boolean | ||||||||||||||||||||||||||||||||||||||||||
| 320 | Args : NONE | ||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||
| 322 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 323 | |||||||||||||||||||||||||||||||||||||||||||
| 324 | 0 | ▶ | sub is_resource { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_resource: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 325 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | return $self->get_attributes('xsi:type') =~ /ResourceMeta/; | |||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||
| 328 | |||||||||||||||||||||||||||||||||||||||||||
| 329 | =item is_xml_literal() | ||||||||||||||||||||||||||||||||||||||||||
| 330 | |||||||||||||||||||||||||||||||||||||||||||
| 331 | Returns whether the object is a nested XMLLiteral | ||||||||||||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||||||||||||
| 333 | Type : Accessor | ||||||||||||||||||||||||||||||||||||||||||
| 334 | Title : is_xml_literal | ||||||||||||||||||||||||||||||||||||||||||
| 335 | Usage : my $val = $anno->is_xml_literal; | ||||||||||||||||||||||||||||||||||||||||||
| 336 | Function: Returns whether object is a nested XMLLiteral | ||||||||||||||||||||||||||||||||||||||||||
| 337 | Returns : Boolean | ||||||||||||||||||||||||||||||||||||||||||
| 338 | Args : NONE | ||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||
| 340 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||
| 342 | 0 | ▶ | sub is_xml_literal { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
is_xml_literal: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 343 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||
| 344 | 0 | return $self->get_object_type eq 'XMLLiteral'; | |||||||||||||||||||||||||||||||||||||||||
| 345 | } | ||||||||||||||||||||||||||||||||||||||||||
| 346 | |||||||||||||||||||||||||||||||||||||||||||
| 347 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 348 | |||||||||||||||||||||||||||||||||||||||||||
| 349 | =head2 SERIALIZERS | ||||||||||||||||||||||||||||||||||||||||||
| 350 | |||||||||||||||||||||||||||||||||||||||||||
| 351 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 352 | |||||||||||||||||||||||||||||||||||||||||||
| 353 | =item to_dom() | ||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||
| 355 | Type : Serializer | ||||||||||||||||||||||||||||||||||||||||||
| 356 | Title : to_dom | ||||||||||||||||||||||||||||||||||||||||||
| 357 | Usage : $obj->to_dom | ||||||||||||||||||||||||||||||||||||||||||
| 358 | Function: Generates a DOM subtree from the invocant and | ||||||||||||||||||||||||||||||||||||||||||
| 359 | its contained objects | ||||||||||||||||||||||||||||||||||||||||||
| 360 | Returns : a DOM element object (default: XML::Twig flavor) | ||||||||||||||||||||||||||||||||||||||||||
| 361 | Args : DOM factory object | ||||||||||||||||||||||||||||||||||||||||||
| 362 | Note : This is the generic function. It is redefined in the | ||||||||||||||||||||||||||||||||||||||||||
| 363 | classes below. | ||||||||||||||||||||||||||||||||||||||||||
| 364 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 365 | |||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | ▶ | sub to_dom { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
to_dom: not called CC=6 SCAR=37.4
Pod
documented
| |||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my ( $self, $dom ) = @_; | |||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | ▶ | $dom ||= Bio::Phylo::NeXML::DOM->get_dom; | ||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/3
$dom ||= "Bio::Phylo::NeXML::DOM"->get_dom
MC/DC0%0/2
$dom ||= "Bio::Phylo::NeXML::DOM"->get_dom
$dom
"Bio::Phylo::NeXML::DOM"->get_dom
Truth table0%0/3
A ||= B
A= $domB= "Bio::Phylo::NeXML::DOM"->get_dom
| |||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | ▶ | if ( looks_like_object $dom, _DOMCREATOR_ ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | my $elt = $self->get_dom_elt($dom); | |||||||||||||||||||||||||||||||||||||||||
| 371 | 0 | ▶ | if ( $self->can('get_entities') ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 372 | 0 | for my $ent ( @{ $self->get_entities } ) { | |||||||||||||||||||||||||||||||||||||||||
| 373 | 0 | ▶ | if ( looks_like_implementor $ent, 'to_dom' ) { | ||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||
| 374 | 0 | $elt->set_child( $ent->to_dom($dom) ); | |||||||||||||||||||||||||||||||||||||||||
| 375 | } | ||||||||||||||||||||||||||||||||||||||||||
| 376 | } | ||||||||||||||||||||||||||||||||||||||||||
| 377 | } | ||||||||||||||||||||||||||||||||||||||||||
| 378 | 0 | return $elt; | |||||||||||||||||||||||||||||||||||||||||
| 379 | } | ||||||||||||||||||||||||||||||||||||||||||
| 380 | else { | ||||||||||||||||||||||||||||||||||||||||||
| 381 | 0 | throw 'BadArgs' => 'DOM factory object not provided'; | |||||||||||||||||||||||||||||||||||||||||
| 382 | } | ||||||||||||||||||||||||||||||||||||||||||
| 383 | } | ||||||||||||||||||||||||||||||||||||||||||
| 384 | |||||||||||||||||||||||||||||||||||||||||||
| 385 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 386 | |||||||||||||||||||||||||||||||||||||||||||
| 387 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 388 | |||||||||||||||||||||||||||||||||||||||||||
| 389 | # podinherit_insert_token | ||||||||||||||||||||||||||||||||||||||||||
| 390 | |||||||||||||||||||||||||||||||||||||||||||
| 391 | =head1 SEE ALSO | ||||||||||||||||||||||||||||||||||||||||||
| 392 | |||||||||||||||||||||||||||||||||||||||||||
| 393 | There is a mailing list at L<https://groups.google.com/forum/#!forum/bio-phylo> | ||||||||||||||||||||||||||||||||||||||||||
| 394 | for any user or developer questions and discussions. | ||||||||||||||||||||||||||||||||||||||||||
| 395 | |||||||||||||||||||||||||||||||||||||||||||
| 396 | =over | ||||||||||||||||||||||||||||||||||||||||||
| 397 | |||||||||||||||||||||||||||||||||||||||||||
| 398 | =item L<Bio::Phylo::Dictionary> | ||||||||||||||||||||||||||||||||||||||||||
| 399 | |||||||||||||||||||||||||||||||||||||||||||
| 400 | Annotation objects are combined into a dictionary. | ||||||||||||||||||||||||||||||||||||||||||
| 401 | |||||||||||||||||||||||||||||||||||||||||||
| 402 | =item L<Bio::Phylo::NeXML::Writable> | ||||||||||||||||||||||||||||||||||||||||||
| 403 | |||||||||||||||||||||||||||||||||||||||||||
| 404 | This object inherits from L<Bio::Phylo::NeXML::Writable>, so methods | ||||||||||||||||||||||||||||||||||||||||||
| 405 | defined there are also applicable here. | ||||||||||||||||||||||||||||||||||||||||||
| 406 | |||||||||||||||||||||||||||||||||||||||||||
| 407 | =item L<Bio::Phylo::Manual> | ||||||||||||||||||||||||||||||||||||||||||
| 408 | |||||||||||||||||||||||||||||||||||||||||||
| 409 | Also see the manual: L<Bio::Phylo::Manual> and L<http://rutgervos.blogspot.com>. | ||||||||||||||||||||||||||||||||||||||||||
| 410 | |||||||||||||||||||||||||||||||||||||||||||
| 411 | =back | ||||||||||||||||||||||||||||||||||||||||||
| 412 | |||||||||||||||||||||||||||||||||||||||||||
| 413 | =head1 CITATION | ||||||||||||||||||||||||||||||||||||||||||
| 414 | |||||||||||||||||||||||||||||||||||||||||||
| 415 | If you use Bio::Phylo in published research, please cite it: | ||||||||||||||||||||||||||||||||||||||||||
| 416 | |||||||||||||||||||||||||||||||||||||||||||
| 417 | B<Rutger A Vos>, B<Jason Caravas>, B<Klaas Hartmann>, B<Mark A Jensen> | ||||||||||||||||||||||||||||||||||||||||||
| 418 | and B<Chase Miller>, 2011. Bio::Phylo - phyloinformatic analysis using Perl. | ||||||||||||||||||||||||||||||||||||||||||
| 419 | I<BMC Bioinformatics> B<12>:63. | ||||||||||||||||||||||||||||||||||||||||||
| 420 | L<http://dx.doi.org/10.1186/1471-2105-12-63> | ||||||||||||||||||||||||||||||||||||||||||
| 421 | |||||||||||||||||||||||||||||||||||||||||||
| 422 | =cut | ||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||
| 424 | 1423 | ▶ | sub _tag { 'meta' } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_tag: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 425 | 2866 | ▶ | sub _type { $TYPE_CONSTANT } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_type: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | ▶ | sub _container { $CONTAINER_CONSTANT } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_container: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 427 | |||||||||||||||||||||||||||||||||||||||||||
| 428 | 1423 | ▶ | sub _cleanup : Destructor { | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
_cleanup: called CC=2 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||
| 429 | 1423 | my $id = shift->get_id; | |||||||||||||||||||||||||||||||||||||||||
| 430 | 1423 | delete $_->{$id} for @fields; | |||||||||||||||||||||||||||||||||||||||||
| 431 | 10 | ▶ | } | ||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||
| 432 | } | ||||||||||||||||||||||||||||||||||||||||||
| 433 | 10 | 1; | |||||||||||||||||||||||||||||||||||||||||