| 1 | package Bio::Tools::EUtilities::Link::LinkSet; | ||||||||||||||||||||||||||||||||
| 2 | BEGIN { | ||||||||||||||||||||||||||||||||
| 3 | 9 | ▶ | $Bio::Tools::EUtilities::Link::LinkSet::AUTHORITY = 'cpan:BIOPERLML'; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 4 | } | ||||||||||||||||||||||||||||||||
| 5 | { | ||||||||||||||||||||||||||||||||
| 6 | 9 | $Bio::Tools::EUtilities::Link::LinkSet::VERSION = '1.73'; | |||||||||||||||||||||||||||||||
| 7 | } | ||||||||||||||||||||||||||||||||
| 8 | 9 | ▶ | use utf8; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 9 | 9 | ▶ | use strict; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 10 | 9 | ▶ | use warnings; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 11 | 9 | ▶ | use base qw(Bio::Root::Root Bio::Tools::EUtilities::HistoryI); | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 12 | 9 | ▶ | use Bio::Tools::EUtilities::Link::UrlLink; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 13 | 9 | ▶ | use Bio::Tools::EUtilities::Info::LinkInfo; | ||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||
| 15 | # ABSTRACT: Class for EUtils LinkSets. | ||||||||||||||||||||||||||||||||
| 16 | # AUTHOR: Chris Fields <cjfields@bioperl.org> | ||||||||||||||||||||||||||||||||
| 17 | # OWNER: 2006-2013 Chris Fields | ||||||||||||||||||||||||||||||||
| 18 | # LICENSE: Perl_5 | ||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||
| 21 | sub new { | ||||||||||||||||||||||||||||||||
| 22 | 50 | ▶ | my ($class,@args) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
new: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 23 | 50 | my $self = $class->SUPER::new(@args); | |||||||||||||||||||||||||||||||
| 24 | 50 | my ($type) = $self->_rearrange([qw(DATATYPE)],@args); | |||||||||||||||||||||||||||||||
| 25 | 50 | ▶ | $type ||= 'linkset'; | ||||||||||||||||||||||||||||||
|
Condition50%1/2
$type ||= "linkset"
MC/DC0%0/1
$type ||= "linkset"
$type
Truth table50%1/2
A
A= $type
| |||||||||||||||||||||||||||||||||
| 26 | 50 | $self->eutil('elink'); | |||||||||||||||||||||||||||||||
| 27 | 50 | $self->datatype($type); | |||||||||||||||||||||||||||||||
| 28 | 50 | return $self; | |||||||||||||||||||||||||||||||
| 29 | } | ||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||
| 31 | |||||||||||||||||||||||||||||||||
| 32 | sub get_ids { | ||||||||||||||||||||||||||||||||
| 33 | 102 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
get_ids: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 34 | 102 | ▶ | unless ($self->{'_sorted_id'}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 35 | 50 | @{$self->{'_sorted_id'}} = | |||||||||||||||||||||||||||||||
| 36 | sort { | ||||||||||||||||||||||||||||||||
| 37 | $self->{'_id'}->{$a}->[0] <=> | ||||||||||||||||||||||||||||||||
| 38 | 32 | $self->{'_id'}->{$b}->[0] | |||||||||||||||||||||||||||||||
| 39 | 50 | } keys %{$self->{'_id'}}; | |||||||||||||||||||||||||||||||
| 40 | } | ||||||||||||||||||||||||||||||||
| 41 | 102 | return @{$self->{'_sorted_id'}}; | |||||||||||||||||||||||||||||||
| 42 | } | ||||||||||||||||||||||||||||||||
| 43 | |||||||||||||||||||||||||||||||||
| 44 | |||||||||||||||||||||||||||||||||
| 45 | sub get_database { | ||||||||||||||||||||||||||||||||
| 46 | 0 | ▶ | return ($_[0]->get_databases)[0]; | ||||||||||||||||||||||||||||||
|
Subroutine
get_database: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 47 | } | ||||||||||||||||||||||||||||||||
| 48 | |||||||||||||||||||||||||||||||||
| 49 | |||||||||||||||||||||||||||||||||
| 50 | sub get_db { | ||||||||||||||||||||||||||||||||
| 51 | 0 | ▶ | return shift->get_database; | ||||||||||||||||||||||||||||||
|
Subroutine
get_db: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 52 | } | ||||||||||||||||||||||||||||||||
| 53 | |||||||||||||||||||||||||||||||||
| 54 | |||||||||||||||||||||||||||||||||
| 55 | sub get_dbto { | ||||||||||||||||||||||||||||||||
| 56 | 0 | ▶ | return shift->get_database; | ||||||||||||||||||||||||||||||
|
Subroutine
get_dbto: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 57 | } | ||||||||||||||||||||||||||||||||
| 58 | |||||||||||||||||||||||||||||||||
| 59 | |||||||||||||||||||||||||||||||||
| 60 | sub get_databases { | ||||||||||||||||||||||||||||||||
| 61 | 167 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
get_databases: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 62 | 167 | my %tmp; | |||||||||||||||||||||||||||||||
| 63 | 328 | my @dbs = sort map {$_->get_database} | |||||||||||||||||||||||||||||||
| 64 | 167 | grep {!$tmp{$_->get_database}++} ($self->get_LinkInfo); | |||||||||||||||||||||||||||||||
| 65 | 167 | ▶ | unshift @dbs, $self->{'_dbto'} if $self->{'_dbto'} && !$tmp{$self->{'_dbto'}}++; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition66%2/3
$self->{"_dbto"} and not $tmp{$self->{"_dbto"}}++
MC/DC50%1/2
$self->{"_dbto"} and not $tmp{$self->{"_dbto"}}++
$self->{"_dbto"}
not $tmp{$self->{"_dbto"}}++
Truth table66%2/3
A and not(B)
A= $self->{"_dbto"}B= not $tmp{$self->{"_dbto"}}++
| |||||||||||||||||||||||||||||||||
| 66 | 167 | return @dbs; | |||||||||||||||||||||||||||||||
| 67 | } | ||||||||||||||||||||||||||||||||
| 68 | |||||||||||||||||||||||||||||||||
| 69 | |||||||||||||||||||||||||||||||||
| 70 | sub get_dbs { | ||||||||||||||||||||||||||||||||
| 71 | 0 | ▶ | return shift->get_databases; | ||||||||||||||||||||||||||||||
|
Subroutine
get_dbs: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 72 | } | ||||||||||||||||||||||||||||||||
| 73 | |||||||||||||||||||||||||||||||||
| 74 | |||||||||||||||||||||||||||||||||
| 75 | 26 | ▶ | sub get_dbfrom { return shift->{'_dbfrom'} } | ||||||||||||||||||||||||||||||
|
Subroutine
get_dbfrom: called CC=1 SCAR=0.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 76 | |||||||||||||||||||||||||||||||||
| 77 | |||||||||||||||||||||||||||||||||
| 78 | sub get_link_names { | ||||||||||||||||||||||||||||||||
| 79 | 26 | ▶ | my ($self) = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
get_link_names: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 80 | 26 | my %tmps; | |||||||||||||||||||||||||||||||
| 81 | my @lns; | ||||||||||||||||||||||||||||||||
| 82 | 26 | ▶ | if ($self->{'_linkname'}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 83 | 10 | push @lns, $self->{'_linkname'}; | |||||||||||||||||||||||||||||||
| 84 | 10 | $tmps{$self->{'_linkname'}}++; | |||||||||||||||||||||||||||||||
| 85 | } | ||||||||||||||||||||||||||||||||
| 86 | 26 | push @lns, map {$_->get_link_name} $self->get_LinkInfo; | |||||||||||||||||||||||||||||||
| 87 | 26 | return @lns; | |||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||
| 89 | |||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||
| 91 | sub get_link_name { | ||||||||||||||||||||||||||||||||
| 92 | 0 | ▶ | return ($_[0]->get_link_names)[0]; | ||||||||||||||||||||||||||||||
|
Subroutine
get_link_name: not called CC=1 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 93 | } | ||||||||||||||||||||||||||||||||
| 94 | |||||||||||||||||||||||||||||||||
| 95 | |||||||||||||||||||||||||||||||||
| 96 | sub get_submitted_ids { | ||||||||||||||||||||||||||||||||
| 97 | 26 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
get_submitted_ids: called CC=4 SCAR=14.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 98 | 26 | my $datatype = $self->datatype; | |||||||||||||||||||||||||||||||
| 99 | 26 | ▶ | if ($datatype eq 'idcheck' || $datatype eq 'urllink') { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
Condition100%3/3
$datatype eq "idcheck" or $datatype eq "urllink"
MC/DC100%2/2
$datatype eq "idcheck" or $datatype eq "urllink"
$datatype eq "idcheck"
$datatype eq "urllink"
Truth table100%3/3
A or B
A= $datatype eq "idcheck"B= $datatype eq "urllink"
| |||||||||||||||||||||||||||||||||
| 100 | 16 | return $self->get_ids; | |||||||||||||||||||||||||||||||
| 101 | } elsif ($self->{'_submitted_ids'}) { | ||||||||||||||||||||||||||||||||
| 102 | 10 | return @{$self->{'_submitted_ids'}}; | |||||||||||||||||||||||||||||||
| 103 | } else { | ||||||||||||||||||||||||||||||||
| 104 | 0 | return (); | |||||||||||||||||||||||||||||||
| 105 | } | ||||||||||||||||||||||||||||||||
| 106 | } | ||||||||||||||||||||||||||||||||
| 107 | |||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||
| 109 | sub has_scores { | ||||||||||||||||||||||||||||||||
| 110 | 28 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
has_scores: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 111 | 28 | ▶ | return exists $self->{'_has_scores'} ? 1 : 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 112 | } | ||||||||||||||||||||||||||||||||
| 113 | |||||||||||||||||||||||||||||||||
| 114 | |||||||||||||||||||||||||||||||||
| 115 | sub get_scores { | ||||||||||||||||||||||||||||||||
| 116 | 2 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
get_scores: called CC=2 SCAR=7.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 117 | # do we want to cache this or generate only when needed? Likely won't be | ||||||||||||||||||||||||||||||||
| 118 | # called more than once... | ||||||||||||||||||||||||||||||||
| 119 | 2 | ▶ | return unless $self->has_scores; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 120 | 2 | my %scores = map {$_ => $self->{'_id'}->{$_}->[1]} keys %{$self->{'_id'}}; | |||||||||||||||||||||||||||||||
| 121 | 2 | return %scores; | |||||||||||||||||||||||||||||||
| 122 | } | ||||||||||||||||||||||||||||||||
| 123 | |||||||||||||||||||||||||||||||||
| 124 | |||||||||||||||||||||||||||||||||
| 125 | sub get_score_by_id { | ||||||||||||||||||||||||||||||||
| 126 | 0 | ▶ | my ($self, $id) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
get_score_by_id: not called CC=3 SCAR=24.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 127 | 0 | ▶ | ($id && exists $self->{'_id'}->{$id}) ? return $self->{'_id'}->{$id}->[1] : | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$id and exists $self->{"_id"}{$id}
MC/DC0%0/2
$id and exists $self->{"_id"}{$id}
$id
exists $self->{"_id"}{$id}
Truth table0%0/3
A and B
A= $idB= exists $self->{"_id"}{$id}
| |||||||||||||||||||||||||||||||||
| 128 | return; | ||||||||||||||||||||||||||||||||
| 129 | } | ||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||
| 131 | |||||||||||||||||||||||||||||||||
| 132 | sub has_linkout { | ||||||||||||||||||||||||||||||||
| 133 | 26 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
has_linkout: called CC=4 SCAR=13.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 134 | 26 | ▶ | if (exists $self->{'_haslinkout'}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 135 | 4 | ▶ | return $self->{'_haslinkout'} eq 'Y' ? 1 : 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 136 | } else { | ||||||||||||||||||||||||||||||||
| 137 | 22 | ▶ | return (grep {$_ eq 'LinkOut'} $self->get_databases) ? 1 : 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||
| 139 | } | ||||||||||||||||||||||||||||||||
| 140 | |||||||||||||||||||||||||||||||||
| 141 | |||||||||||||||||||||||||||||||||
| 142 | sub has_neighbor { | ||||||||||||||||||||||||||||||||
| 143 | 26 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
has_neighbor: called CC=3 SCAR=11.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 144 | 26 | ▶ | if (exists $self->{'_hasneighbor'}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 145 | 4 | ▶ | return $self->{'_hasneighbor'} eq 'Y' ? 1 : 0; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 146 | } else { | ||||||||||||||||||||||||||||||||
| 147 | 22 | return 0; | |||||||||||||||||||||||||||||||
| 148 | } | ||||||||||||||||||||||||||||||||
| 149 | } | ||||||||||||||||||||||||||||||||
| 150 | |||||||||||||||||||||||||||||||||
| 151 | |||||||||||||||||||||||||||||||||
| 152 | sub next_UrlLink { | ||||||||||||||||||||||||||||||||
| 153 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
next_UrlLink: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 154 | 0 | ▶ | unless ($self->{"_urllinks_it"}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 155 | 0 | my @ul = $self->get_UrlLinks; | |||||||||||||||||||||||||||||||
| 156 | 0 | ▶ | $self->{"_urllinks_it"} = sub {return shift @ul} | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 157 | 0 | } | |||||||||||||||||||||||||||||||
| 158 | 0 | $self->{'_urllinks_it'}->(); | |||||||||||||||||||||||||||||||
| 159 | } | ||||||||||||||||||||||||||||||||
| 160 | |||||||||||||||||||||||||||||||||
| 161 | |||||||||||||||||||||||||||||||||
| 162 | sub get_UrlLinks { | ||||||||||||||||||||||||||||||||
| 163 | 26 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
get_UrlLinks: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 164 | 26 | ▶ | return ref $self->{'_urllinks'} ? @{ $self->{'_urllinks'} } : return; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 165 | } | ||||||||||||||||||||||||||||||||
| 166 | |||||||||||||||||||||||||||||||||
| 167 | |||||||||||||||||||||||||||||||||
| 168 | sub next_LinkInfo { | ||||||||||||||||||||||||||||||||
| 169 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
next_LinkInfo: not called CC=2 SCAR=17.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 170 | 0 | ▶ | unless ($self->{"_linkinfo_it"}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 171 | 0 | my @li = $self->get_LinkInfo; | |||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | $self->{"_linkinfo_it"} = sub {return shift @li} | ||||||||||||||||||||||||||||||
|
Subroutine
__ANON__: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||
| 173 | 0 | } | |||||||||||||||||||||||||||||||
| 174 | 0 | $self->{'_linkinfo_it'}->(); | |||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||
| 176 | |||||||||||||||||||||||||||||||||
| 177 | |||||||||||||||||||||||||||||||||
| 178 | sub get_LinkInfo { | ||||||||||||||||||||||||||||||||
| 179 | 219 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
get_LinkInfo: called CC=2 SCAR=6.9
Pod
documented
| |||||||||||||||||||||||||||||||||
| 180 | 219 | ▶ | return ref $self->{'_linkinfo'} ? @{ $self->{'_linkinfo'} } : return (); | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 181 | } | ||||||||||||||||||||||||||||||||
| 182 | |||||||||||||||||||||||||||||||||
| 183 | |||||||||||||||||||||||||||||||||
| 184 | { | ||||||||||||||||||||||||||||||||
| 185 | 9 | my %VALID_DATA = ('linkinfo' => 'linkinfo', | |||||||||||||||||||||||||||||||
| 186 | 'linkinfos' => 'linkinfo', | ||||||||||||||||||||||||||||||||
| 187 | 'urllinks' => 'urllinks'); | ||||||||||||||||||||||||||||||||
| 188 | |||||||||||||||||||||||||||||||||
| 189 | sub rewind { | ||||||||||||||||||||||||||||||||
| 190 | 0 | ▶ | my ($self, $arg) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
rewind: not called CC=5 SCAR=34.0
Pod
documented
| |||||||||||||||||||||||||||||||||
| 191 | 0 | ▶ | $arg ||= 'all'; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
$arg ||= "all"
MC/DC0%0/1
$arg ||= "all"
$arg
Truth table0%0/2
A
A= $arg
| |||||||||||||||||||||||||||||||||
| 192 | 0 | ▶ | if (exists $VALID_DATA{$arg}) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 193 | 0 | delete $self->{'_'.$arg.'_it'}; | |||||||||||||||||||||||||||||||
| 194 | } elsif ($arg eq 'all') { | ||||||||||||||||||||||||||||||||
| 195 | 0 | delete $self->{'_'.$_.'_it'} for values %VALID_DATA; | |||||||||||||||||||||||||||||||
| 196 | } | ||||||||||||||||||||||||||||||||
| 197 | } | ||||||||||||||||||||||||||||||||
| 198 | } | ||||||||||||||||||||||||||||||||
| 199 | |||||||||||||||||||||||||||||||||
| 200 | # private methods and handlers | ||||||||||||||||||||||||||||||||
| 201 | |||||||||||||||||||||||||||||||||
| 202 | { | ||||||||||||||||||||||||||||||||
| 203 | 9 | my %DATA_HANDLER = ( | |||||||||||||||||||||||||||||||
| 204 | 'IdList' => \&_add_submitted_ids, | ||||||||||||||||||||||||||||||||
| 205 | 'Id' => \&_add_retrieved_ids, | ||||||||||||||||||||||||||||||||
| 206 | 'LinkInfo' => \&_add_linkinfo, | ||||||||||||||||||||||||||||||||
| 207 | 'Link' => \&_add_retrieved_ids, | ||||||||||||||||||||||||||||||||
| 208 | 'ObjUrl' => \&_add_objurls, | ||||||||||||||||||||||||||||||||
| 209 | ); | ||||||||||||||||||||||||||||||||
| 210 | |||||||||||||||||||||||||||||||||
| 211 | sub _add_data { | ||||||||||||||||||||||||||||||||
| 212 | 50 | ▶ | my ($self, $data) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
_add_data: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||
| 213 | 50 | for my $key (qw(IdList Link Id ObjUrl LinkInfo)) { | |||||||||||||||||||||||||||||||
| 214 | 250 | ▶ | next if !exists $data->{$key}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 215 | 58 | my $handler = $DATA_HANDLER{$key}; | |||||||||||||||||||||||||||||||
| 216 | 58 | $self->$handler($data); | |||||||||||||||||||||||||||||||
| 217 | 58 | delete $data->{$key}; | |||||||||||||||||||||||||||||||
| 218 | } | ||||||||||||||||||||||||||||||||
| 219 | # map the rest | ||||||||||||||||||||||||||||||||
| 220 | 50 | ▶ | if ($self->datatype eq 'idcheck' && exists $data->{content}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition100%3/3
$self->datatype eq "idcheck" and exists $data->{"content"}
MC/DC100%2/2
$self->datatype eq "idcheck" and exists $data->{"content"}
$self->datatype eq "idcheck"
exists $data->{"content"}
Truth table100%3/3
A and B
A= $self->datatype eq "idcheck"B= exists $data->{"content"}
| |||||||||||||||||||||||||||||||||
| 221 | 16 | %{$self->{'_id'} } = ($data->{content} => [1]); | |||||||||||||||||||||||||||||||
| 222 | delete $data->{content} | ||||||||||||||||||||||||||||||||
| 223 | 16 | } | |||||||||||||||||||||||||||||||
| 224 | 50 | map {$self->{'_'.lc $_} = $data->{$_}} keys %$data; | |||||||||||||||||||||||||||||||
| 225 | } | ||||||||||||||||||||||||||||||||
| 226 | |||||||||||||||||||||||||||||||||
| 227 | } | ||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||
| 229 | 9 | sub _add_submitted_ids { | |||||||||||||||||||||||||||||||
| 230 | 18 | ▶ | my ($self, $data) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
_add_submitted_ids: called CC=2 SCAR=7.0
| |||||||||||||||||||||||||||||||||
| 231 | 18 | ▶ | if (exists $data->{IdList}->{Id}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 232 | 18 | @{$self->{'_submitted_ids'}} = @{$data->{IdList}->{Id}} ; | |||||||||||||||||||||||||||||||
| 233 | } | ||||||||||||||||||||||||||||||||
| 234 | } | ||||||||||||||||||||||||||||||||
| 235 | |||||||||||||||||||||||||||||||||
| 236 | sub _add_retrieved_ids { | ||||||||||||||||||||||||||||||||
| 237 | 26 | ▶ | my ($self, $data) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
_add_retrieved_ids: called CC=5 SCAR=16.1
| |||||||||||||||||||||||||||||||||
| 238 | # map all IDs to deal with possible scores | ||||||||||||||||||||||||||||||||
| 239 | # ID => {'count' = POSITION, 'score' => SCORE} | ||||||||||||||||||||||||||||||||
| 240 | 26 | ▶ | if (exists $data->{Link}) { | ||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||
| 241 | 10 | my $ct = 0; | |||||||||||||||||||||||||||||||
| 242 | 10 | for my $link (@{$data->{Link}}) { | |||||||||||||||||||||||||||||||
| 243 | 26 | ▶ | if (exists $link->{Score}) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 244 | 12 | $self->{'_has_scores'}++; | |||||||||||||||||||||||||||||||
| 245 | 12 | $self->{'_id'}->{$link->{Id}->[0]} = [ $ct++,$link->{Score}]; | |||||||||||||||||||||||||||||||
| 246 | } else { | ||||||||||||||||||||||||||||||||
| 247 | 14 | $self->{'_id'}->{$link->{Id}->[0]} = [ $ct++ ]; | |||||||||||||||||||||||||||||||
| 248 | } | ||||||||||||||||||||||||||||||||
| 249 | } | ||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||
| 251 | elsif (exists $data->{Id}) { # urls | ||||||||||||||||||||||||||||||||
| 252 | 16 | %{$self->{'_id'} } = ($data->{Id}->[0] => [1]); | |||||||||||||||||||||||||||||||
| 253 | } | ||||||||||||||||||||||||||||||||
| 254 | } | ||||||||||||||||||||||||||||||||
| 255 | |||||||||||||||||||||||||||||||||
| 256 | sub _add_objurls { | ||||||||||||||||||||||||||||||||
| 257 | 6 | ▶ | my ($self, $data) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
_add_objurls: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||
| 258 | 6 | for my $urldata (@{$data->{ObjUrl}}) { | |||||||||||||||||||||||||||||||
| 259 | 6 | ▶ | $urldata->{dbfrom} = $data->{DbFrom} if exists $data->{DbFrom}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 260 | 6 | my $obj = Bio::Tools::EUtilities::Link::UrlLink->new(-eutil => 'elink', | |||||||||||||||||||||||||||||||
| 261 | -datatype => 'urldata', | ||||||||||||||||||||||||||||||||
| 262 | -verbose => $self->verbose | ||||||||||||||||||||||||||||||||
| 263 | ); | ||||||||||||||||||||||||||||||||
| 264 | 6 | $obj->_add_data($urldata); | |||||||||||||||||||||||||||||||
| 265 | 6 | push @{$self->{'_urllinks'}}, $obj; | |||||||||||||||||||||||||||||||
| 266 | } | ||||||||||||||||||||||||||||||||
| 267 | } | ||||||||||||||||||||||||||||||||
| 268 | |||||||||||||||||||||||||||||||||
| 269 | sub _add_linkinfo { | ||||||||||||||||||||||||||||||||
| 270 | 8 | ▶ | my ($self, $data) = @_; | ||||||||||||||||||||||||||||||
|
Subroutine
_add_linkinfo: called CC=3 SCAR=11.0
| |||||||||||||||||||||||||||||||||
| 271 | 8 | for my $linkinfo (@{$data->{LinkInfo}}) { | |||||||||||||||||||||||||||||||
| 272 | 116 | ▶ | $linkinfo->{dbfrom} = $data->{DbFrom} if exists $data->{DbFrom}; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 273 | 116 | my $obj = Bio::Tools::EUtilities::Info::LinkInfo->new(-eutil => 'elink', | |||||||||||||||||||||||||||||||
| 274 | -datatype => 'linkinfo', | ||||||||||||||||||||||||||||||||
| 275 | -verbose => $self->verbose | ||||||||||||||||||||||||||||||||
| 276 | ); | ||||||||||||||||||||||||||||||||
| 277 | 116 | $obj->_add_data($linkinfo); | |||||||||||||||||||||||||||||||
| 278 | 116 | push @{$self->{'_linkinfo'}}, $obj; | |||||||||||||||||||||||||||||||
| 279 | } | ||||||||||||||||||||||||||||||||
| 280 | } | ||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||
| 282 | |||||||||||||||||||||||||||||||||
| 283 | sub to_string { | ||||||||||||||||||||||||||||||||
| 284 | 0 | ▶ | my $self = shift; | ||||||||||||||||||||||||||||||
|
Subroutine
to_string: not called CC=8 SCAR=42.8
Pod
documented
| |||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | my $level = shift || 0; | ||||||||||||||||||||||||||||||
|
Condition0%0/2
shift() || 0
MC/DC0%0/1
shift() || 0
shift()
Truth table0%0/2
A
A= shift()
| |||||||||||||||||||||||||||||||||
| 286 | 0 | my $pad = 20 - $level; | |||||||||||||||||||||||||||||||
| 287 | # order method name | ||||||||||||||||||||||||||||||||
| 288 | 0 | my %tags = (1 => ['get_databases' => 'DB'], | |||||||||||||||||||||||||||||||
| 289 | 2 => ['get_ids' => 'ID'], | ||||||||||||||||||||||||||||||||
| 290 | 3 => ['get_link_names' => 'Link Names'], | ||||||||||||||||||||||||||||||||
| 291 | 5 => ['get_submitted_ids' => 'Submitted IDs'], | ||||||||||||||||||||||||||||||||
| 292 | 6 => ['has_scores' => 'Scores?'], | ||||||||||||||||||||||||||||||||
| 293 | 7 => ['has_linkout' => 'LinkOut?'], | ||||||||||||||||||||||||||||||||
| 294 | 8 => ['has_neighbor' => 'DB Neighbors?'], | ||||||||||||||||||||||||||||||||
| 295 | 9 => ['get_webenv' => 'WebEnv'], | ||||||||||||||||||||||||||||||||
| 296 | 10 => ['get_query_key' => 'Key'], | ||||||||||||||||||||||||||||||||
| 297 | ); | ||||||||||||||||||||||||||||||||
| 298 | 0 | my $string; | |||||||||||||||||||||||||||||||
| 299 | 0 | for my $tag (sort {$a <=> $b} keys %tags) { | |||||||||||||||||||||||||||||||
| 300 | 0 | my ($m, $nm) = (@{$tags{$tag}}[0..1]); | |||||||||||||||||||||||||||||||
| 301 | # using this awkward little construct to deal with both lists and scalars | ||||||||||||||||||||||||||||||||
| 302 | 0 | my @content = grep {defined $_} $self->$m(); | |||||||||||||||||||||||||||||||
| 303 | 0 | ▶ | next unless @content; | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 304 | 0 | $string .= $self->_text_wrap( | |||||||||||||||||||||||||||||||
| 305 | sprintf("%-*s%-*s:",$level, '',$pad, $nm,), | ||||||||||||||||||||||||||||||||
| 306 | ' ' x ($pad).':', | ||||||||||||||||||||||||||||||||
| 307 | join(', ',@content))."\n"; | ||||||||||||||||||||||||||||||||
| 308 | } | ||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | while (my $li = $self->next_LinkInfo) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 310 | 0 | $string .= $li->to_string(4); | |||||||||||||||||||||||||||||||
| 311 | } | ||||||||||||||||||||||||||||||||
| 312 | 0 | ▶ | while (my $ui = $self->next_UrlLink) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 313 | 0 | $string .= $ui->to_string(4); | |||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||
| 315 | 0 | ▶ | if ($self->has_scores) { | ||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||
| 316 | 0 | $string .= "Scores:\n"; | |||||||||||||||||||||||||||||||
| 317 | 0 | my %scores = $self->get_scores; | |||||||||||||||||||||||||||||||
| 318 | 0 | $string .= sprintf("%-*s%-*s%s\n", | |||||||||||||||||||||||||||||||
| 319 | $level + 4, '', | ||||||||||||||||||||||||||||||||
| 320 | $pad - 4, 'ID', 'Score' | ||||||||||||||||||||||||||||||||
| 321 | ); | ||||||||||||||||||||||||||||||||
| 322 | 0 | for my $id ($self->get_ids) { | |||||||||||||||||||||||||||||||
| 323 | $string .= sprintf("%-*s%-*s%s\n", | ||||||||||||||||||||||||||||||||
| 324 | $level + 4, '', | ||||||||||||||||||||||||||||||||
| 325 | 0 | $pad - 4, $id, $scores{$id} | |||||||||||||||||||||||||||||||
| 326 | ); | ||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||
| 328 | } | ||||||||||||||||||||||||||||||||
| 329 | 0 | $string .= "\n"; | |||||||||||||||||||||||||||||||
| 330 | 0 | return $string; | |||||||||||||||||||||||||||||||
| 331 | } | ||||||||||||||||||||||||||||||||
| 332 | |||||||||||||||||||||||||||||||||
| 333 | 9 | 1; | |||||||||||||||||||||||||||||||
| 334 | |||||||||||||||||||||||||||||||||
| 335 | __END__ | ||||||||||||||||||||||||||||||||