コード例 #1
0
 public Func <DateTime, string>[] GetFormatters(IntervalBase interval)
 {
     return(new Func <DateTime, string>[]
     {
         date => $"{date:mm} min"
     });
 }
コード例 #2
0
 public Func <DateTime, string>[] GetFormatters(IntervalBase interval)
 {
     return(new Func <DateTime, string>[]
     {
         date => string.Format("Minute : {0}", date.ToString("mm"))
     });
 }
コード例 #3
0
ファイル: RegionGen.cs プロジェクト: olgatei/Di4
        private void CreateMapFile(int chr, string chrTitle, string filePath)
        {
            var mapIntervals = new SortedDictionary <IntervalBase, Interval>();

            Console.WriteLine("");

            int generatedMapIntervals = 0;

            while (generatedMapIntervals < windowCount[chr])
            {
                var iBase = new IntervalBase();
                iBase.left  = rnd.Next(chrBorders.left, chrBorders.right - maxLenght - 2);
                iBase.right = rnd.Next(iBase.left + 1, iBase.left + 1 + maxLenght);

                if (!mapIntervals.ContainsKey(iBase))
                {
                    generatedMapIntervals++;
                    mapIntervals.Add(iBase, new Interval(chrTitle, iBase, GetRandomName(generatedMapIntervals), Math.Round(rnd.NextDouble(), 5)));

                    Console.Write("\r{0:N0} map intervals created.", generatedMapIntervals);
                }
            }

            using (FileStream fs = new FileStream(filePath + "sorted" + dirSep + "mapRef." + filesExtension, FileMode.Append, FileAccess.Write))
                using (StreamWriter sw = new StreamWriter(fs))
                    foreach (var interval in mapIntervals)
                    {
                        sw.WriteLine(interval.Value.ToString());
                    }
        }
コード例 #4
0
 public Func <DateTime, string>[] GetIntervalSpanFormatters(IntervalBase interval)
 {
     return(new Func <DateTime, string>[]
     {
         date => date.ToString("mm")
     });
 }
コード例 #5
0
 public Func <DateTime, string>[] GetIntervalSpanFormatters(IntervalBase interval)
 {
     return(new Func <DateTime, string>[]
     {
         date => String.Format("{0} ... {1}", date.Hour, interval.IncrementByCurrentInterval(date).Hour)
     });
 }
コード例 #6
0
 public Func <DateTime, string>[] GetFormatters(IntervalBase interval)
 {
     return(new Func <DateTime, string>[]
     {
         date => date.Hour.ToString(CultureInfo.InvariantCulture)
     });
 }
コード例 #7
0
		public Func<DateTime, string>[] GetFormatters(IntervalBase interval)
		{
			return new Func<DateTime, string>[]
			{
				date => date.ToString("mm:ss")
			};
		}
コード例 #8
0
        public Func <DateTime, string>[] GetIntervalSpanFormatters(IntervalBase interval)
        {
            if (this.intervalSpanFormatters == null)
            {
                this.intervalSpanFormatters = new Func <DateTime, string>[]
                {
                    date => String.Format("{0} - {1}", date.ToString("dddd H:mm"), interval.IncrementByCurrentInterval(date).ToString("H:mm"))
                };
            }

            return(this.intervalSpanFormatters);
        }
コード例 #9
0
ファイル: RegionGen.cs プロジェクト: olgatei/Di4
            public Interval GetInterval(int count)
            {
                var ibase = new IntervalBase();

                ibase.left = _ErlangDistribution.NextErlang(_left, _right - 2);

                /*do
                 * {
                 *  ibase.left = (int)Math.Floor(((_length * GetErlangNo(rnd.NextDouble())) / _maxErlang) + _left);
                 * } while (ibase.left + 2 >= _right);*/



                ibase.right = _ErlangDistribution.NextErlang(ibase.left + 1, Math.Min(ibase.left + 1 + maxLenght, _right));
                //ibase.right = rnd.Next(ibase.left + 1, Math.Min(ibase.left + 1 + maxLenght, _right));


                return(new Interval(_chr, ibase, GetRandomName(count), Math.Round(rnd.NextDouble(), 5)));
            }
コード例 #10
0
ファイル: RegionGen.cs プロジェクト: olgatei/Di4
        private void CreateSortedRegions(int varIndex, int chr, string chrTitle, string filePath)
        {
            mOG = (int)Math.Round((_pwAsi[varIndex] * windowCount[chr]) / 100.0);
            gOG = 0;

            int  retries;
            bool overlaps;

            // Total number of intervals
            // to be created.
            int iToCreate;

            // Total number of created intervals.
            int iCreated;

            // Min and Max of overlapping
            // intervals to be created.
            int[] oToCreate;

            // Number of overlapping intervals created.
            // i.e., the overlap that satisfies 'oToCreate' criteria.
            int oCreated;

            Console.WriteLine("Total Created Regions : ");


            // Window number starts from 1 (not 0) because of the calculation of cOG.
            for (int windowNumber = 1; windowNumber <= windowCount[chr]; windowNumber++)
            {
                retries  = 0;
                iCreated = 0;
                oCreated = 0;

                gIntervals.Clear();

                window.left  = window.right + rnd.Next(minGap, maxGap);
                window.right = window.left + windowLength;


                if (CreateMaxOverlap(windowCount[chr] - windowNumber))
                {
                    // try to re-write this with Erlang function too.

                    iToCreate = sampleCount;
                    oToCreate = new int[] { sampleCount, sampleCount };
                    gOG++;

                    var iRegion = new IntervalBase(window);

                    while (iCreated < iToCreate)
                    {
                        var ibase = new IntervalBase();
                        ibase.left  = rnd.Next(window.left, window.right - maxLenght - 1);
                        ibase.right = rnd.Next(ibase.left + 1, ibase.left + 1 + maxLenght);

                        overlaps = ibase.CompareTo(iRegion) == 0 ? true : false;

                        if (overlaps && oCreated <= oToCreate[1])
                        {
                            var i = new Interval(chrTitle, ibase, GetRandomName(iCreated++), Math.Round(rnd.NextDouble(), 5));
                            gIntervals.Add(i.name, i);
                            iRegion.Intersect(i);
                            oCreated++;
                            retries = 0;
                            continue;
                        }
                        else
                        {
                            if (++retries > _maxRetries)
                            {
                                gIntervals.Clear();
                                iCreated = 0;
                                oCreated = 0;

                                iRegion.left  = window.left;
                                iRegion.right = window.right;
                            }
                            continue;
                        }
                    }
                }
                else
                {
                    iToCreate = sampleCount - (int)Math.Round((sampleCount * regionCountVarience) / 100.0);

                    while (iCreated < iToCreate)
                    {
                        var ibase = new IntervalBase();
                        ibase.left  = (int)Math.Floor(((windowLength * GetErlangNo(rnd.NextDouble())) / _maxErlang) + window.left);
                        ibase.right = rnd.Next(ibase.left + 1, Math.Min(ibase.left + 1 + maxLenght, window.right));
                        var i = new Interval(chrTitle, ibase, GetRandomName(iCreated++), Math.Round(rnd.NextDouble(), 5));
                        gIntervals.Add(i.name, i);
                    }
                }



                _tSampleNo = 0;
                var tSet = new HashSet <int>(_jdh);
                foreach (var region in gIntervals)
                {
                    _tSampleNo = tSet.ElementAt(rnd.Next(0, tSet.Count));
                    tSet.Remove(_tSampleNo);

                    if (!Directory.Exists(filePath + "sorted" + dirSep))
                    {
                        Directory.CreateDirectory(filePath + "sorted" + dirSep);
                    }
                    using (FileStream fs =
                               new FileStream(filePath + "sorted" + dirSep + "sample_" + _tSampleNo.ToString() + "." + filesExtension, FileMode.Append, FileAccess.Write))
                        using (StreamWriter sw = new StreamWriter(fs))
                            sw.WriteLine(region.Value);
                }



                Console.Write("\r{0:N0} \\ {1:N0}", (windowNumber + 1).ToString(), windowCount[chr].ToString());
            }

            Console.WriteLine("");
            Console.WriteLine("Done !");
        }
コード例 #11
0
ファイル: RegionGen.cs プロジェクト: olgatei/Di4
 public RegionGenerator()
 {
     window     = new IntervalBase();
     chrBorders = new IntervalBase();
     _accDis    = new SortedDictionary <int, AccDis>();
 }
コード例 #12
0
ファイル: RegionGen.cs プロジェクト: olgatei/Di4
 public Interval(string chr, IntervalBase interval, string name, double value) : base(interval)
 {
     this.chr   = chr;
     this.name  = name;
     this.value = value;
 }
コード例 #13
0
 public Func <DateTime, string>[] GetFormatters(IntervalBase interval)
 {
     return(formatters);
 }
コード例 #14
0
ファイル: AlignedSecurity.cs プロジェクト: tslab-hub/handlers
        private TimeSpan GetInterval()
        {
            switch (IntervalBase)
            {
            case DataIntervals.DAYS:
                return(TimeSpan.FromDays(Interval));

            case DataIntervals.MINUTE:
                return(TimeSpan.FromMinutes(Interval));

            case DataIntervals.SECONDS:
                return(TimeSpan.FromSeconds(Interval));

            default:
                throw new InvalidEnumArgumentException(nameof(IntervalBase), (int)IntervalBase, IntervalBase.GetType());
            }
        }