Free cookie consent management tool by TermsFeed Policy Generator

Changeset 13944


Ignore:
Timestamp:
06/28/16 23:26:41 (8 years ago)
Author:
bburlacu
Message:

#1772: Fix bug in fragment length calculator leading to exception when we try to compute the average out of an empty sequence of fragment lengths.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • branches/HeuristicLab.EvolutionTracking/HeuristicLab.Problems.DataAnalysis.Symbolic/3.4/Tracking/Analyzers/SymbolicDataAnalysisFragmentLengthAnalyzer.cs

    r13747 r13944  
    111111        }
    112112      }
    113       var averageFragmentLength = (crossoverFragmentLengthDistribution.Average() + mutationFragmentLengthDistribution.Average()) / 2d;
     113      var avgCXFragmentLength = crossoverFragmentLengthDistribution.Any() ? crossoverFragmentLengthDistribution.Average() : 0;
     114      var avgReplacedCXFragmentLength = replacedCrossoverFragmentLengthDistribution.Any() ? replacedCrossoverFragmentLengthDistribution.Average() : 0;
     115      var avgMutFragmentLength = mutationFragmentLengthDistribution.Any() ? mutationFragmentLengthDistribution.Average() : 0;
     116      var avgReplacedMutFragmentLength = replacedMutationFragmentLengthDistribution.Any() ? replacedMutationFragmentLengthDistribution.Average() : 0;
     117      var avgFragmentLength = (avgCXFragmentLength + avgMutFragmentLength) / 2d;
    114118      DataTable table;
    115119      if (!Results.ContainsKey("AverageFragmentLength")) {
    116120        table = new DataTable("Average fragment length");
    117121        var row = new DataRow("Average fragment length") { VisualProperties = { StartIndexZero = true } };
    118         row.Values.Add(averageFragmentLength);
     122        row.Values.Add(avgFragmentLength);
    119123        table.Rows.Add(row);
    120124        row = new DataRow("Average crossover fragment length") { VisualProperties = { StartIndexZero = true } };
    121         row.Values.Add(crossoverFragmentLengthDistribution.Average());
     125        row.Values.Add(avgCXFragmentLength);
    122126        table.Rows.Add(row);
    123127        row = new DataRow("Average replaced crossover fragment length") { VisualProperties = { StartIndexZero = true } };
    124         row.Values.Add(replacedCrossoverFragmentLengthDistribution.Average());
     128        row.Values.Add(avgReplacedCXFragmentLength);
    125129        table.Rows.Add(row);
    126130        row = new DataRow("Average mutation fragment length") { VisualProperties = { StartIndexZero = true } };
    127         row.Values.Add(mutationFragmentLengthDistribution.Average());
     131        row.Values.Add(avgMutFragmentLength);
    128132        table.Rows.Add(row);
    129133        row = new DataRow("Average replaced mutation fragment length") { VisualProperties = { StartIndexZero = true } };
    130         row.Values.Add(replacedMutationFragmentLengthDistribution.Average());
     134        row.Values.Add(avgReplacedMutFragmentLength);
    131135        table.Rows.Add(row);
    132136        Results.Add(new Result("AverageFragmentLength", table));
    133137      } else {
    134138        table = (DataTable)Results["AverageFragmentLength"].Value;
    135         table.Rows["Average fragment length"].Values.Add(averageFragmentLength);
    136         table.Rows["Average crossover fragment length"].Values.Add(crossoverFragmentLengthDistribution.Average());
    137         table.Rows["Average replaced crossover fragment length"].Values.Add(replacedCrossoverFragmentLengthDistribution.Average());
    138         table.Rows["Average mutation fragment length"].Values.Add(mutationFragmentLengthDistribution.Average());
    139         table.Rows["Average replaced mutation fragment length"].Values.Add(replacedMutationFragmentLengthDistribution.Average());
     139        table.Rows["Average fragment length"].Values.Add(avgFragmentLength);
     140        table.Rows["Average crossover fragment length"].Values.Add(avgCXFragmentLength);
     141        table.Rows["Average replaced crossover fragment length"].Values.Add(avgReplacedCXFragmentLength);
     142        table.Rows["Average mutation fragment length"].Values.Add(avgMutFragmentLength);
     143        table.Rows["Average replaced mutation fragment length"].Values.Add(avgReplacedMutFragmentLength);
    140144      }
    141145      if (!Results.ContainsKey("FragmentLengthDistribution")) {
Note: See TracChangeset for help on using the changeset viewer.