void ResetSummaries(bool clearAll)
 {
     //Saves the current summaries as the last summaries and then deletes the current summaries - or deletes all summaries if clearAll is true
     if (clearAll)
     {
         //Clear the 'last' summary data
         m_lastLocalSummary = new Summary(m_loci);
     }
     else
     {
         //copy current summaries to last summaries
         m_lastLocalSummary = m_localSummary;
     }
     m_localSummary = new Summary(m_loci);
 }
 public void PostInitialise()
 {
     if (m_enabled)
     {
         //Assemble the paths and file names we will be using
         m_localDemographicsLog = System.IO.Path.Combine(m_logPath, "local-" + m_instanceTag + "-demographics.log");
         m_localHweLog = System.IO.Path.Combine(m_logPath, "local-" + m_instanceTag + "-hwe.log");
         //Register for events
         m_scene.EventManager.OnChatFromClient += OnChat;
         m_scene.EventManager.OnChatFromWorld += OnChat;
         m_log.WarnFormat("[vpgSummary] PostInitialized region {0}", m_scene.RegionInfo.RegionName);
         //Set up timer events (but don't start them yet)
         m_cycleTimer.Elapsed += new ElapsedEventHandler(OnCycleTimer);
         m_cycleTimer.Interval = m_cycleTime * 1000;
         //Create Summary instances to hold data
         m_localSummary = new Summary(m_loci);
         m_lastLocalSummary = new Summary(m_loci);
         m_onDemandSummary = new Summary(m_loci);
     }
 }
 void FormatHudData(bool isScheduled)
 {
     if (!isScheduled)
     {
         //Don't ResetSummaries for 'on demand' summaries
         string[] hudString = m_onDemandSummary.GetHudString(m_lastLocalSummary);
         m_onDemandSummary = new Summary(m_loci);
         UpdateHUDs(hudString);
     }
     else
     {
         string[] hudString = m_localSummary.GetHudString(m_lastLocalSummary);
         ResetSummaries(false);
         UpdateHUDs(hudString);
     }
 }
 public string[] GetHudString(Summary lastSummary)
 {
     //Returns summary data as a list with a string for each prim of the inworld HUD
     string[] hudString = new string[12];
     hudString[2] = "Haplotype\n";
     hudString[3] = "Total\n";
     hudString[4] = "Spores\n";
     hudString[5] = "Gamet\n";
     hudString[6] = "Sporo\n";
     hudString[7] = "";
     hudString[8] = "p(1)\n";
     hudString[9] = "Change\n";
     hudString[10] = "H-obs\n";
     hudString[11] = "H-exp\n";
     int sporesChange = m_spores - lastSummary.Spores;
     int gametophytesChange = m_gametophytes - lastSummary.Gametophytes;
     int sporophytesChange = m_sporophytes - lastSummary.Sporophytes;
     hudString[0] = "Qty\n" + m_spores + "\n" + m_gametophytes + "\n" + m_sporophytes;
     hudString[1] = "Change\n" +sporesChange + "\n" + gametophytesChange + "\n" + sporophytesChange;
     for(int h=0; h<m_sporeHaplotypes.Length; h++)
     {
         int totalHaplotypes = m_sporeHaplotypes[h] + m_gametHaplotypes[h] + m_sporoHaplotypes[h];
         if (totalHaplotypes > 0) //If a haplotype isn't present, don't report it.
         {
             //Only report information for haplotypes that exist.
             hudString[2] = hudString[2] + Decimal2Binary(h) + "\n";
             hudString[3] = hudString[3] + totalHaplotypes + "\n";
             hudString[4] = hudString[4] + m_sporeHaplotypes[h] + "\n";
             hudString[5] = hudString[5] + m_gametHaplotypes[h] + "\n";
             hudString[6] = hudString[6] + m_sporoHaplotypes[h] + "\n";
         }
     }
     if (m_sporophytes > 0) //can't calculate hwe stats if there are no sporophytes
     {
         for(int i=(m_loci - 1); i>=0; i--)
         {
             float alleleFrequency = GetAlleleFrequency(i);
             hudString[7] = hudString[7] + "Locus" + (i+1) + "\n";
             hudString[8] = hudString[8] + alleleFrequency + "\n";
             hudString[9] = hudString[9] + Math.Round(alleleFrequency - lastSummary.GetAlleleFrequency(i), 3) + "\n";
             float hetObserved = GetHetObserved(i);
             float hetExpected = (float)Math.Round(2 * alleleFrequency * (1 - alleleFrequency), 3);
             hudString[10] = hudString[10] + hetObserved + "\n";
             hudString[11] = hudString[11] + hetExpected + "\n";
         }
     }
     return hudString;
 }