my ($self) = @_;
my $main_pipeline = $self->pipeline;
$self->{'_foreign_analyses'} = {};
foreach my $source_analysis ( @{ $main_pipeline->get_source_analyses } ) {
# run the recursion in each component that has a non-cyclic start:
$self->_propagate_allocation( $source_analysis );
}
foreach my $cyclic_analysis ( $main_pipeline->collection_of( 'Analysis' )->list ) {
next if(defined $cyclic_analysis->{'_funnel_dfr'});
$self->_propagate_allocation( $cyclic_analysis );
}
foreach my $source_analysis ( @{ $main_pipeline->get_source_analyses } ) {
# run the recursion in each component that has a non-cyclic start:
$self->_add_analysis_node( $source_analysis );
}
foreach my $cyclic_analysis ( $main_pipeline->collection_of( 'Analysis' )->list ) {
next if($self->{'_created_analysis'}{ $cyclic_analysis });
$self->_add_analysis_node( $cyclic_analysis );
}
if($self->config_get('DisplayStretched') ) { # put each analysis before its' funnel midpoint
foreach my $analysis ( $main_pipeline->collection_of('Analysis')->list ) {
if(ref($analysis->{'_funnel_dfr'})) { # this should only affect analyses that have a funnel
my $from = $self->_analysis_node_name( $analysis );
my $to = _midpoint_name( $analysis->{'_funnel_dfr'} );
$self->graph->add_edge( $from => $to,
style => 'invis', # toggle visibility by changing 'invis' to 'dashed'
color => 'black',
);
}
}
}
my %cluster_2_nodes = ();
$self->graph->cluster_2_nodes( \%cluster_2_nodes );
if( $self->config_get('DisplayDetails') ) {
foreach my $pipeline ( Bio::EnsEMBL::Hive::TheApiary->pipelines_collection->list ) {
my $pipeline_cluster_name = _cluster_name( $pipeline->hive_pipeline_name );
$self->graph->cluster_2_attributes->{ $pipeline_cluster_name }{ 'cluster_label' } = $pipeline_cluster_name;
$self->graph->cluster_2_attributes->{ $pipeline_cluster_name }{ 'style' } = 'bold,filled';
$self->graph->cluster_2_attributes->{ $pipeline_cluster_name }{ 'fill_colour_pair' } = ($pipeline == $main_pipeline)
? [$self->config_get('Box', 'MainPipeline', 'ColourScheme'), $self->config_get('Box', 'MainPipeline', 'ColourOffset')]
: [$self->config_get('Box', 'OtherPipeline', 'ColourScheme'), $self->config_get('Box', 'OtherPipeline', 'ColourOffset')];
}
}
if($self->config_get('DisplaySemaphoreBoxes') ) {
foreach my $analysis ( $main_pipeline->collection_of('Analysis')->list, values %{ $self->{'_foreign_analyses'} } ) {
push @{$cluster_2_nodes{ _cluster_name( $analysis->{'_funnel_dfr'} ) } }, $self->_analysis_node_name( $analysis );
foreach my $group ( @{ $self->_grouped_dataflow_rules($analysis) } ) {
my ($df_rule, $fan_dfrs, $df_targets) = @$group;
my $choice = (scalar(@$df_targets)!=1) || defined($df_targets->[0]->on_condition);
if(@$fan_dfrs or $choice) {
# top-level funnels define clusters (top-level "boxes"):
push @{$cluster_2_nodes{ _cluster_name( $df_rule->{'_funnel_dfr'} ) }}, _midpoint_name( $df_rule );
my $box_needed = 0;
foreach my $fan_dfr (@$fan_dfrs) {
my $fan_targets = $fan_dfr->get_my_targets; # FIXME: ->get_my_targets() may be too computationally-expensive to run so may times?
foreach my $fan_target (@$fan_targets) {
my $target_object = $fan_target->to_analysis;
if( $target_object->{'_funnel_dfr'} eq $df_rule
# or $target_object->hive_pipeline ne $fan_dfr->hive_pipeline # crossing the pipeline boundary
) {
$box_needed = 1;
}
}
}
if( $box_needed ) {
push @{$cluster_2_nodes{ _cluster_name( $df_rule->{'_funnel_dfr'} ) }}, _cluster_name( $df_rule );
}
foreach my $fan_dfr (@$fan_dfrs) {
push @{$cluster_2_nodes{ _cluster_name( $fan_dfr->{'_funnel_dfr'} ) } }, _midpoint_name( $fan_dfr ); # midpoints of rules that have a funnel live inside "boxes"
}
}
foreach my $df_target (@$df_targets) {
my $target_object = $df_target->to_analysis;
push @{$cluster_2_nodes{ _cluster_name( $target_object->{'_funnel_dfr'} ) } }, $self->_table_node_name( $target_object );
push @{$cluster_2_nodes{ _cluster_name( $analysis->{'_funnel_dfr'} ) } }, _accu_sink_node_name( $analysis->{'_funnel_dfr'} );
}
}
} # /foreach group
}
$self->graph->nested_bgcolour( [$self->config_get('Box', 'Semaphore', 'ColourScheme'), $self->config_get('Box', 'Semaphore', 'ColourOffset')] );
}
return $self->graph();
}