@@ -23,6 +23,7 @@ use strict;
23
23
24
24
use HTML::Entities qw( encode_entities) ;
25
25
26
+ use EnsEMBL::Web::Utils::Compara qw( orthoset_prod_names) ;
26
27
use EnsEMBL::Web::Utils::FormatText qw( glossary_helptip get_glossary_entry pluralise) ;
27
28
28
29
use base qw( EnsEMBL::Web::Component::Gene) ;
@@ -46,8 +47,9 @@ sub content {
46
47
my $biotype = $object -> Obj-> get_Biotype; # We expect a Biotype object, though it could be a biotype name.
47
48
my $is_ncrna = ( ref $biotype eq ' Bio::EnsEMBL::Biotype' ? $biotype -> biotype_group =~ / noncoding$ / : $biotype =~ / RNA/ );
48
49
my $species_name = $species_defs -> GROUP_DISPLAY_NAME;
49
- my $strain_url = $hub -> is_strain ? " Strain_" : " " ;
50
- my $strain_param = $hub -> is_strain ? " ;strain=1" : " " ; # initialize variable even if is_strain is false, to avoid warnings
50
+ my $is_strain_view = $hub -> action =~ / ^Strain_/ ? 1 : 0;
51
+ my $strain_url = $is_strain_view ? " Strain_" : " " ;
52
+ my $strain_param = $is_strain_view ? " ;strain=1" : " " ; # initialize variable even if is_strain_view is false, to avoid warnings
51
53
52
54
my @orthologues = (
53
55
$object -> get_homology_matches(' ENSEMBL_ORTHOLOGUES' , undef , undef , $cdb ),
@@ -78,11 +80,14 @@ sub content {
78
80
delete $compara_species -> {' ancestral_sequences' };
79
81
}
80
82
83
+ my $orthoset_prod_names = EnsEMBL::Web::Utils::Compara::orthoset_prod_names($hub , $cdb , $is_strain_view );
84
+ my $orthoset_prod_name_set = {map {$_ => 1} @$orthoset_prod_names };
85
+
81
86
# # Work out which species we want to skip over, based on page type and user's configuration
82
87
my $this_group = $species_defs -> STRAIN_GROUP;
83
88
my $species_not_shown = {};
84
- my $strains_not_shown = {};
85
- my $strain_refs = {};
89
+ my $species_not_relevant = {};
90
+ my $unshown_strain_types = {};
86
91
my $hidden = {};
87
92
88
93
foreach my $prod_name (keys %$compara_species ) {
@@ -92,30 +97,23 @@ sub content {
92
97
next if $species eq $hub -> species; # # Ignore current species
93
98
my $label = $is_pan ? $pan_lookup -> {$prod_name }{' display_name' } : $species_defs -> species_label($species );
94
99
95
- # # Should we be showing this orthologue on this pagpe by default?
96
- my $strain_group = $species_defs -> get_config($species , ' STRAIN_GROUP' );
97
- my $related_taxon = $species_defs -> get_config($species , ' RELATED_TAXON' );
98
- if ($hub -> action =~ / ^Strain_/ ) {
99
- unless (($strain_group && $strain_group eq $this_group ) || ($related_taxon && $related_taxon eq $species_defs -> RELATED_TAXON)) {
100
- $species_not_shown -> {$species } = $label ;
101
- next ;
102
- }
103
- }
104
- else {
105
- if ($strain_group ) {
106
- if ($strain_group eq $prod_name ) {
107
- $strain_refs -> {$species } = $label ;
108
- }
109
- else {
110
- # # Do not show any strain species on main species view
111
- $strains_not_shown -> {$species } = $label ;
112
- next ;
113
- }
114
- }
100
+ # Should we be showing this orthologue on this page by default?
101
+ unless ($orthoset_prod_name_set -> {$prod_name }) {
102
+ $species_not_relevant -> {$species } = 1;
103
+ next ;
115
104
}
116
105
117
106
# # Do we even have an orthologue for this species?
118
107
unless ($orthologue_list {$species }) {
108
+
109
+ my $strain_group = $species_defs -> get_config($species , ' STRAIN_GROUP' );
110
+ my $strain_type = $strain_group && $prod_name ne $strain_group
111
+ ? $species_defs -> get_config($species , ' STRAIN_TYPE' )
112
+ : ' species'
113
+ ;
114
+
115
+ $unshown_strain_types -> {$strain_type } += 1;
116
+
119
117
$species_not_shown -> {$species } = $label ;
120
118
next ;
121
119
}
@@ -200,8 +198,8 @@ sub content {
200
198
my $anc_node_ids = $self -> fetch_anc_node_ids($cdb );
201
199
foreach my $species (sort { ($a =~ / ^<.*?>(.+)/ ? $1 : $a ) cmp ($b =~ / ^<.*?>(.+)/ ? $1 : $b ) } keys %orthologue_list ) {
202
200
next unless $species ;
201
+ next if $species_not_relevant -> {$species };
203
202
next if $species_not_shown -> {$species };
204
- next if $strains_not_shown -> {$species };
205
203
next if $hidden -> {$species };
206
204
207
205
my ($species_label , $prodname );
@@ -367,29 +365,26 @@ sub content {
367
365
);
368
366
}
369
367
370
- if (($hub -> action =~ / ^Strain_/ && keys %$strains_not_shown )
371
- || ($hub -> action !~ / ^Strain_/ && keys %$species_not_shown )) {
372
- my ($total , $no_ortho_species , $strain_refs_html );
373
- if ($hub -> action =~ / ^Strain_/ ) {
374
- $total = scalar keys %$strains_not_shown ;
375
- $no_ortho_species = $self -> get_no_ortho_species_html($strains_not_shown , $sets_by_species );
376
- $strain_refs_html = ' ' ;
377
- }
378
- else {
379
- $total = scalar keys %$species_not_shown ;
380
- unless ($is_pan ) {
381
- $no_ortho_species = $self -> get_no_ortho_species_html($species_not_shown , $sets_by_species );
382
- $strain_refs_html = $self -> get_strain_refs_html($strain_refs , $species_not_shown );
383
- }
368
+ if (keys %$species_not_shown ) {
369
+ my $no_ortho_species ;
370
+ my $total = scalar keys %$species_not_shown ;
371
+ unless ($is_pan ) {
372
+ $no_ortho_species = $self -> get_no_ortho_species_html($species_not_shown , $sets_by_species );
384
373
}
385
374
my $not_shown_list = $is_pan ? ' ' : sprintf (' <ul id="no_ortho_species">%s</ul>' , $no_ortho_species );
375
+ my $strain_type_breakdown = $self -> get_strain_type_breakdown($unshown_strain_types , $total );
376
+
377
+ my $not_shown_desc = $total > 1
378
+ ? " are not shown in the table above because they don't have any orthologue with"
379
+ : " is not shown in the table above because it doesn't have any orthologue with"
380
+ ;
381
+
386
382
$html .= ' <br /><a name="list_no_ortho"/>' . $self -> _info(
387
383
' Species without orthologues' ,
388
384
sprintf (
389
- qq( <p><span class="no_ortho_count">%d </span> species are not shown in the table above because they don't have any orthologue with %s .</p>
385
+ qq( <p><span class="no_ortho_count">%d </span> %s %s %s .</p>
390
386
%s
391
- %s
392
- </p> <input type="hidden" class="panel_type" value="ComparaOrtholog" />) , $total , $self -> object-> Obj-> stable_id, $not_shown_list , $strain_refs_html ),
387
+ </p> <input type="hidden" class="panel_type" value="ComparaOrtholog" />) , $total , $strain_type_breakdown , $not_shown_desc , $self -> object-> Obj-> stable_id, $not_shown_list ),
393
388
undef ,
394
389
' no_ortho_message_pad'
395
390
);
@@ -410,7 +405,7 @@ sub create_gene_tree_links {
410
405
my $orthologue = $params -> {orthologue };
411
406
412
407
my $hub = $self -> hub;
413
- my $strain_url = $hub -> is_strain ? " Strain_" : " " ;
408
+ my $strain_url = $hub -> action =~ / ^Strain_ / ? " Strain_" : " " ;
414
409
415
410
my $tree_url = $hub -> url({
416
411
type => ' Gene' ,
@@ -432,32 +427,23 @@ sub species_sets {
432
427
my $hub = $self -> hub;
433
428
my $species_defs = $hub -> species_defs;
434
429
my $is_pan = $cdb =~ / compara_pan_ensembl/ ;
430
+ my $is_strain_view = $self -> hub-> action =~ / ^Strain_/ ;
435
431
436
- return " " if $self -> hub -> action =~ / ^Strain / ; # No summary table needed for strains
432
+ return " " if $is_strain_view ; # No summary table needed for strains
437
433
438
434
my ($set_order , $species_sets , $set_mappings ) = $self -> species_set_config($cdb ); # setting $cdb enables us to fetch Pan species sets
439
435
440
436
return " " unless $set_order ;
441
437
442
- my $compara_spp = {} ;
438
+ my $compara_spp = EnsEMBL::Web::Utils::Compara::orthoset_prod_names( $hub , $cdb , $is_strain_view ) ;
443
439
my $lookup = $species_defs -> prodnames_to_urls_lookup($cdb );
444
- my $pan_info = {};
445
- if ($is_pan ) {
446
- $pan_info = $species_defs -> multi_val(' PAN_COMPARA_LOOKUP' );
447
- $compara_spp = {map { $_ => 1} keys %$pan_info };
448
- }
449
- else {
450
- $compara_spp = { %{$species_defs -> multi_hash-> {' DATABASE_COMPARA' }{' COMPARA_SPECIES' }} };
451
- delete $compara_spp -> {' ancestral_sequences' };
452
- }
440
+ my $pan_info = $is_pan ? $species_defs -> multi_val(' PAN_COMPARA_LOOKUP' ) : {};
453
441
my %orthologue_map = qw( SEED BRH PIP RHS) ;
454
442
my $sets_by_species = {};
455
443
my $ortho_type = {};
456
444
457
- foreach (keys % $compara_spp ) {
445
+ foreach (@ $compara_spp ) {
458
446
my $species = $lookup -> {$_ };
459
- next unless $species ; # skip species absent from URL lookup (e.g. Human in Ensembl Plants)
460
- next if $self -> hub-> is_strain($species ); # skip strain species
461
447
462
448
my $orthologues = $orthologue_list -> {$species } || {};
463
449
my $no_ortho = 0;
@@ -503,7 +489,7 @@ sub species_set_config {} # Stub, as it's clade-specific - implement in plugins
503
489
504
490
sub fetch_anc_node_ids {} # Another stub, only for specific divisions (e.g. Metazoa)
505
491
506
- sub get_strain_refs_html {
492
+ sub get_strain_refs_html { # not in use as of 2025-06
507
493
my ($self , $strain_refs , $species_not_shown ) = @_ ;
508
494
return ' ' unless keys %{$strain_refs ||{}};
509
495
@@ -532,14 +518,33 @@ sub get_no_ortho_species_html {
532
518
my $hub = $self -> hub;
533
519
my $html = ' ' ;
534
520
535
- foreach (sort {lc $a cmp lc $b } keys %$species_not_shown ) {
521
+ # Species will be easier to find if we sort them by display name.
522
+ foreach (sort {lc $species_not_shown -> {$a } cmp lc $species_not_shown -> {$b }} keys %$species_not_shown ) {
536
523
my $class = $sets_by_species -> {$_ } ? sprintf (' class="%s"' , join (' ' , @{$sets_by_species -> {$_ }})) : ' ' ;
537
524
$html .= sprintf ' <li%s>%s</li>' , $class , $species_not_shown -> {$_ };
538
525
}
539
526
540
527
return $html ;
541
528
}
542
529
530
+ sub get_strain_type_breakdown {
531
+ # # Get text listing strain types in order of decreasing frequency.
532
+ my ($self , $strain_types , $num_genomes ) = @_ ;
533
+
534
+ my @ordered_strain_types = sort {$strain_types -> {$b } <=> $strain_types -> {$a } || $a cmp $b } keys %$strain_types ;
535
+
536
+ if ($num_genomes > 1) {
537
+ @ordered_strain_types = map { pluralise($_ ) } @ordered_strain_types ;
538
+ }
539
+
540
+ my $strain_type_text = scalar (@ordered_strain_types ) > 1
541
+ ? join (' , ' , @ordered_strain_types [0 .. ($#ordered_strain_types -1)]) . ' and ' . $ordered_strain_types [-1]
542
+ : $ordered_strain_types [0]
543
+ ;
544
+
545
+ return $strain_type_text ;
546
+ }
547
+
543
548
sub get_export_data {
544
549
# # Get data for export
545
550
my ($self , $flag ) = @_ ;
0 commit comments