<commit_before>package Bio::EnsEMBL::Funcgen::RunnableDB::ChIPSeq::FindControlExperiments;

use strict;
use base 'Bio::EnsEMBL::Hive::Process';
use Data::Dumper;
use Bio::EnsEMBL::Funcgen::ChIPSeqAnalysis::ExecutionPlanUtils qw (
    lock_execution_plan
    resolve_nonterminal_symbols
);

use constant {

  # Used for idr
  BRANCH_SIGNALS  => 2,
  
  # Used for aligning and fastqc
  BRANCH_CONTROLS => 3,
};

sub run {

  my $self = shift;
  my $species             = $self->param_required('species');
  my $execution_plan_list = $self->param_required('execution_plan_list');
  
  $self->say_with_header("Got " . scalar @$execution_plan_list . " execution plans.", 1);
  
  my %found_control_alignments;
  my %plan_depending_on_control;
  
  foreach my $current_execution_plan (@$execution_plan_list) {

    my $current_execution_plan_expanded = resolve_nonterminal_symbols($current_execution_plan);
    lock_execution_plan($current_execution_plan_expanded);
    
    my $alignment_plans = $current_execution_plan_expanded->{alignment};
    foreach my $alignment_name (keys %$alignment_plans) {
    
      my $alignment_plan = $alignment_plans->{$alignment_name};
      
      my $want_this
        =    ( $alignment_plan->{is_control}                       )
          && ( $alignment_plan->{analysis} eq 'remove_duplicates'  )
      ;
      if ($want_this) {
        $found_control_alignments{$alignment_name} = $alignment_plan;
        
        if (! exists $plan_depending_on_control{$alignment_name}) {
          $plan_depending_on_control{$alignment_name} = []
        }
        push $plan_depending_on_control{$alignment_name}, $current_execution_plan;
      }
    }
  }
<commit_msg>Updated for experiments that don't have a control<commit_after>package Bio::EnsEMBL::Funcgen::RunnableDB::ChIPSeq::FindControlExperiments;

use strict;
use base 'Bio::EnsEMBL::Hive::Process';
use Data::Dumper;
use Bio::EnsEMBL::Funcgen::ChIPSeqAnalysis::ExecutionPlanUtils qw (
    lock_execution_plan
    resolve_nonterminal_symbols
);

use constant {

  # Used for idr
  BRANCH_SIGNALS  => 2,
  
  # Used for aligning and fastqc
  BRANCH_CONTROLS => 3,
};

sub run {

  my $self = shift;
  my $species             = $self->param_required('species');
  my $execution_plan_list = $self->param_required('execution_plan_list');
  
  $self->say_with_header("Got " . scalar @$execution_plan_list . " execution plans.", 1);
  
  my %found_control_alignments;
  my %plan_depending_on_control;
  
  foreach my $current_execution_plan (@$execution_plan_list) {

    my $current_execution_plan_expanded = resolve_nonterminal_symbols($current_execution_plan);
    lock_execution_plan($current_execution_plan_expanded);
    
    my $alignment_plans = $current_execution_plan_expanded->{alignment};
    
    ALIGNMENT_PLAN:
    foreach my $alignment_name (keys %$alignment_plans) {
    
      my $alignment_plan = $alignment_plans->{$alignment_name};
      
#       if (! exists $alignment_plan->{is_control}) {
#         die(Dumper($alignment_plan));
#       }
      
      my $want_this
        =    
             ( $alignment_plan->{name}     ne 'No control'         )
          && ( $alignment_plan->{is_control}                       )
          && ( $alignment_plan->{analysis} eq 'remove_duplicates'  )
      ;
      if (! $want_this) {
        next ALIGNMENT_PLAN;
      }
      $found_control_alignments{$alignment_name} = $alignment_plan;
      
      if (! exists $plan_depending_on_control{$alignment_name}) {
        $plan_depending_on_control{$alignment_name} = []
      }
      push $plan_depending_on_control{$alignment_name}, $current_execution_plan;
    }
  }

{'fraction_non_alphanumeric': 0.1131765992345544, 'fraction_numerical': 0.0016402405686167304, 'mean_word_length': 3.489570552147239, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 23, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '6347792', 'n_tokens_mistral': 1272, 'n_tokens_neox': 1177, 'n_words': 188}