示例#1
0
 /// <summary>
 /// Overlap copying constructor.
 /// </summary>
 /// <param name="overlap">Overlap.</param>
 public Overlap(Overlap overlap)
     : this(overlap.Name, overlap.Seq_5, overlap.Seq_3, overlap.Settings, overlap.PairIndex)
 { }
示例#2
0
        /// <summary>
        /// Converts the chromosome to its corresponding overlap list.
        /// </summary>
        /// <param name="templates">List of overlap templates.</param>
        /// <returns>List of overlaps represented by this chromosome.</returns>
        public List<Overlap> ToOverlaps(List<Overlap> templates)
        {
            Overlaps.Clear();

            for (int i = 0; i < templates.Count; i++)
            {
                Overlap temp;
                Sequence seq_3 = (Sequence)templates[i].Seq_3.GetSubSequence(0, this.Lengths_3[i]);

                if (templates[i].Seq_5.Count > 0)
                {
                    Sequence seq_5 = (Sequence)templates[i].Seq_5.GetSubSequence(templates[i].Seq_5.Count - this.Lengths_5[i], this.Lengths_5[i]);
                    temp = new Overlap(templates[i].Name, seq_5, seq_3, templates[i].Settings, templates[i].PairIndex);
                }
                else
                {
                    temp = new Overlap(templates[i].Name, seq_3, templates[i].Settings, templates[i].PairIndex);
                }

                Overlaps.Add(temp);
            }

            return Overlaps;
        }
示例#3
0
        /// <summary>
        /// Compute overlap's duplex melting temperature.
        /// </summary>
        /// <returns>Duplex melting temperature.</returns>
        public double GetDuplexTemperature(Overlap twin)
        {
            double T = 0.0;
            String upper = this.Sequence.ToString().ToUpper();
            String upperTwin = twin.Sequence.ToString().ToUpper();

            Thermodynamics.thal_results results = new Thermodynamics.thal_results();
            Thermodynamics.p3_thal_args args = this.Settings.ThalSettings;

            Thermodynamics.p3_thal(upper, upperTwin, ref args, ref results);

            T = results.temp;

            return T;
        }
示例#4
0
        /// <summary>
        /// Overlap naive-greedy temperature optimization.
        /// </summary>
        /// <param name="o"></param>
        /// <param name="args"></param>
        public void SemiNaiveOptimizeOverlaps(object o, DoWorkEventArgs args)
        {
            stop = false;

            this.b = o as BackgroundWorker;

            const byte end_3 = 255;
            const byte end_5 = 255;
            int progress = 0;

            for (int i = 0; i < this.Construct.Overlaps.Count; i++)
            {
                byte item_3 = 0;
                byte item_5 = 0;
                bool done_3 = false;
                bool done_5 = false;
                bool tmTooHigh = true;

                double diff = this.Construct.Overlaps[i].MeltingTemperature - this.Construct.Settings.TargetTm;
                double _bestDiff = diff;
                Overlap _best = new Overlap(this.Construct.Overlaps[i]);

                do
                {
                    if ((item_5 != end_5))
                    {
                        item_5 = this.Construct.Overlaps[i].Dequeue(this.Construct.Settings.MinLen_5);

                        diff = this.Construct.Overlaps[i].MeltingTemperature - this.Construct.Settings.TargetTm;
                        tmTooHigh = (this.Construct.Overlaps[i].MeltingTemperature > this.Construct.Settings.TargetTm);

                        if (Math.Abs(_bestDiff) > Math.Abs(diff))
                        {
                            //check if hairpin is acceptable

                            if (this.Construct.Overlaps[i].IsAcceptable(this.Construct.Settings.MaxTh, this.Construct.Settings.MaxTd, false))
                            {
                                //if found a better solution, copy it, and do not stop
                                _bestDiff = diff;
                                _best = new Overlap(this.Construct.Overlaps[i]);
                                done_5 = false;
                            }
                        }
                        else
                        {
                            //if passed the threshold, done
                            if (!tmTooHigh)
                            {
                                done_5 = true;
                            }
                        }

                    }
                    else
                    {
                        done_5 = true;
                    }

                    if ((item_3 != end_3))
                    {
                        item_3 = this.Construct.Overlaps[i].Pop(this.Construct.Settings.MinLen_3);
                        diff = this.Construct.Overlaps[i].MeltingTemperature - this.Construct.Settings.TargetTm;

                        tmTooHigh = (this.Construct.Overlaps[i].MeltingTemperature > this.Construct.Settings.TargetTm);

                        if (Math.Abs(_bestDiff) > Math.Abs(diff))
                        {
                            //check if hairpin is acceptable

                            if (this.Construct.Overlaps[i].IsAcceptable(this.Construct.Settings.MaxTh, this.Construct.Settings.MaxTd, false))
                            {
                                //if found a better solution, copy it, and do not stop
                                _bestDiff = diff;
                                _best = new Overlap(this.Construct.Overlaps[i]);
                                done_3 = false;
                            }
                        }
                        else
                        {
                            //if passed the threshold, done
                            if (!tmTooHigh)
                            {
                                done_3 = true;
                            }
                        }
                    }
                    else
                    {
                        done_3 = true;
                    }

                    if (!this.IgnorePreoptimizationExceptions && item_3 == end_3 && item_5 == end_5 && !this.Construct.Overlaps[i].IsAcceptable(this.Construct.Settings.MaxTh, this.Construct.Settings.MaxTd, true))
                    {

                        /*
                         * If you are running under the Visual Studio debugger, the debugger will break
                         * at the point in the DoWork event handler where the unhandled exception was raised.
                         * - Mark Cranness, Mar 9 '11 @ StackOverflow
                         * 
                         * Solution: run without debugging. I want that exception here, for now.
                         */
                        throw new AssemblyException(this.Construct.Overlaps[i].ToString());
                    }

                } while (!stop && (!done_5 || !done_3));

                this.Construct.Overlaps[i] = _best;

                progress = (int)(100.0 * (double)i / (double)(this.Construct.Overlaps.Count - 1));
                b.ReportProgress(progress);
            }

            stop = false;
            this.Construct.Evaluate();

            if (!this.IgnorePreoptimizationExceptions && Double.IsPositiveInfinity(this.Construct.Score.NormalizedScore))
            {
                //if failed to achieve an acceptable construct
                throw new AssemblyException("Heteroduplex melting temperature too high. ");
            }

        }