示例#1
0
    string OutputText(SequenceDesignContext context, object result, SortedList<DesignScoreResult, SequencesSaveState> best)
        {
        string fileName = null;

        PrettyPrintContext pp = new PrettyPrintContext();
        //
        DateTime now = DateTime.Now;
        //
        if (this.nadirFiles.Count > 0)
            {
            StreamWriter writer = CreateWritableFile("");
            fileName = (writer.BaseStream as FileStream)?.Name;
            pp.LogToFile(writer);
            }
        //
        pp.NewLine();
        this.OutputBannerAndCopyright(pp);
        //
        pp.Append("Parameters: "); 
        pp.Append(this.args.Interleave(" "));
        pp.NewLine(); 
        //
        pp.AppendLine("Start:        {0}, {1}", this.StartTime.ToLongDateString(), this.StartTime.ToLongTimeString());
        pp.AppendLine("Now:          {0}, {1}", now.ToLongDateString(), now.ToLongTimeString());
        pp.AppendLine("Elapsed time: {0}", FormatElapsed(now - this.StartTime));
        pp.AppendLine("Iterations:   {0:N0}", context.DesignIter);
        pp.AppendLine("Random Seed:  {0}", MiscUtil.RandSeed);
        //
        List<Strand> strands = new List<Strand>();
        if (result is Model)
            {
            strands = new List<Strand>((result as Model).ChemicallyUniqueStrands());
            strands.Sort();

            pp.AppendLine("Nucleotides:  {0,6:N0} unique nucleotide bases", context.IndependentNucleotideCount);
            pp.AppendLine("              {0,6:N0} of those are mutable", context.MutableNucleotideCount);
            pp.AppendLine("Strands:      {0,6:N0} unique strands", strands.Count);
            pp.AppendLine("              {0,6:N0} bases total length", context.TotalNucleotideCount);
            if (context.Designer != null)
                { 
                pp.AppendLine("Tm Calculation Parameters:");
                pp.AppendLine("              {0,6:F2} mM monovalent salt concentration",  context.Designer.MonovalentConcentration * 1000);
                pp.AppendLine("              {0,6:F2} mM divalent salt concentration",    context.Designer.DivalentConcentration * 1000);
                pp.AppendLine("              {0,6:F2} uM oligo concentration",            context.Designer.OligoConcentration * 1000000);
                pp.AppendLine("Scoring Complexity: {0,6:F3}", context.Designer.ScoringComplexity());
                }
            }
        pp.NewLine();
        //
        string title = "Result of Distillation Computation";
        pp.AppendLine(title);
        pp.AppendLine(new string('-', title.Length)); 
        pp.NewLine();
        pp.Indent();
        //
        // Note: this Append here will cause all the domain ids to disambiguate.
        // We want to keep the same disambiguation through the rest of the output here.
        //
        pp.What = PrettyPrintContext.WHAT.DOMAINS;
        pp.AppendLine(result);
        //
        if (this.fOutputNucleotides)
            {
            pp.NewLine();
            pp.What = PrettyPrintContext.WHAT.NUCLEOTIDES;
            pp.AppendLine(result);
            }
        pp.Outdent();
        pp.What = PrettyPrintContext.WhatDefault;
        //
        if (result is Model)
            {
            Model m = result as Model;
            OutputDomains(context, pp, m);
            if (best==null || best.Count == 0)
                {
                OutputStrands(1, context, pp, strands, context.DesignIter);
                }
            else
                {
                int i=1;
                foreach (KeyValuePair<DesignScoreResult,SequencesSaveState> pair in best)
                    {
                    pair.Value.RestoreAndRescore();
                    // scores should be as they originally were, but scoring uses parallelization, which introduces some small numerical uncertainty
                    Trace.Assert(DesignScoreResult.ApproximatelyEquals(pair.Key, pair.Value.SavedDesignScore));
                    OutputStrands(i++, context, pp, strands, pair.Value.Iteration);
                    }
                }
            }
        //
        if (this.nadirFileContents.Length > 0)
            {
            pp.InhibitConsole();
            pp.Append(this.nadirFileContents.ToString());
            pp.DisinhibitConsole();
            }
        //
        MiscUtil.TraceLine(pp.PrettyPrintedOutputString());
        pp.CloseLogFile();
        
        return fileName;
        }