Beispiel #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;
        }
Beispiel #2
0
 public override string ErrorMessage() 
     { 
     PrettyPrintContext pp = new PrettyPrintContext();
     pp.Append(Format("annealing {1} produces {0} molecular configurations:", configs.Count, annealingFlavor));   // REVIEW: AppendFormat should work, but uses differnt pp context inside, which is wrong
     pp.NewLine();
     pp.Append(Format("input:"));
     pp.Indent(); pp.NewLine();
     pp.Append(Format("{0}", annealed));
     pp.Outdent(); pp.NewLine();
     pp.Append(Format("output:"));
     pp.Indent();
     int i = 0;
     foreach (MoleculeMultiSet config in configs)
         {
         pp.NewLine();
         pp.Append(Format("{0}:", i));
         pp.Indent();
         pp.Append(config);
         pp.Outdent();
         i++;
         }
     pp.Outdent();
     return pp.PrettyPrintedOutputString();
     }
Beispiel #3
0
    int                     test = 0;       // if non-zero, is internal test to run

    void Usage()
        {
        PrettyPrintContext pp = new PrettyPrintContext();
        this.OutputBannerAndCopyright(pp);
        pp.NewLine();
        pp.AppendLine($"usage: nadir [options] input.nadir"); 
        pp.Indent();
        pp.AppendLine($"[-f] inputFile          input file(s) to read from (multiple input files are allowed)");
        pp.AppendLine($"-distill globalItem     process definition globalItem into its parts; defaults to first in first file");
        pp.AppendLine($"-nodistill              force no distillation");
        pp.AppendLine($"-design [designerName]  design nucleotides using indicated designer; default to first designer, or trivial designer if none");
        pp.AppendLine($"-nodesign               do not design nucleotide sequences");
        pp.AppendLine($"-nice                   run a background scheduling priority"); 
        pp.Outdent();
        pp.AppendLine("");
        pp.AppendLine($"nucleotide sequence design options");
        pp.Indent();
        pp.AppendLine($"-keepBest nnnn          report this many of the best nucleic acid assignments we fine (default: {designKeepBestCountDefault:N0})");
        pp.AppendLine($"-seed nnnn              set the seed of the random number generator (default: random seed)");
        pp.AppendLine($"-designRate rate        mean mutation rate per iteration (default: {designMutationsPerIterationDefault})");
        pp.AppendLine($"-designSweep iter       sweep for SNP improvements every # of iterations (default: {designIterMutSweepDefault:N0})");
        pp.AppendLine($"-designMin  iter        run sequence designer at least this # of iterations (default: {designIterMinDefault})");
        pp.AppendLine($"-designMax  iter        run sequence designer at most this # of iterations (default: {designIterMaxDefault:N0})");
        pp.AppendLine($"-designGoal score       run sequence designer until this score level reached (default: {designGoalDefault})");
        pp.AppendLine($"-designTemp t           initial temperature for annealling (default: {designTempDefault})");
        pp.AppendLine($"-[no]designTrace iter   print tracing every # of iterations (default: {designIterTraceDefault})");
        pp.Outdent();
        if (this.showHiddenUsage)
            { 
            pp.AppendLine("felony options");
            pp.Indent();
            pp.AppendLine("-felony");
            pp.AppendLine("-fasta file");
            pp.AppendLine("-forward primer");
            pp.AppendLine("-reverse primer");
            pp.AppendLine("-amplicon index length");
            pp.Outdent();
            pp.AppendLine("output options");
            pp.Indent();
            pp.AppendLine("-out text               show output in human-readable text to stdout (default)");
            pp.Indent();
            pp.AppendLine("-[no]verbose         show verbose details in text output");
            pp.AppendLine("-debug               show debugging-related details in text output");
            pp.AppendLine("-nt                  show nucleotides instead of domains in text output");
            pp.AppendLine("-debugTrace          tracing to debug output");
            pp.AppendLine("-consoleTrace        tracing to console output");
            pp.AppendLine("-dumpParse           trace the parse trees");
            pp.AppendLine("-dumpTrees           trace the parse trees");
            pp.Outdent();
            pp.AppendLine("-out graph              show a graphical representation of the output");
            pp.Outdent();
            pp.AppendLine("rare options");
            pp.Indent();
            pp.AppendLine("-designBad              pessimize rather than optimize interactions while designing");
            pp.AppendLine("-domconn                show domain connections in output");
            pp.Outdent();
            }
        System.Console.Error.Write(pp.PrettyPrintedOutputString());
        Environment.Exit(-1);
        }