Esempio n. 1
0
        /// <summary>
        /// Gets a block from the cache at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index of the block.</param>
        /// <returns>The cached sequence block.</returns>
        private CacheBox <byte[]> GetCacheBlock(int index)
        {
            CacheBox <byte[]> block = _virtualData.FirstOrDefault(C => index >= C.StartRange && index <= C.EndRange);

            if (block != null)
            {
                return(block);
            }
            else
            {
                int    startIndex = index - (index % BlockSize);
                byte[] seq        = _parser.ParseRange(startIndex, BlockSize, SequencePointerInstance);

                if (seq == null)
                {
                    return(null);
                }
                else
                {
                    block = new CacheBox <byte[]>(seq.Length)
                    {
                        StartRange = startIndex
                    };
                    block.EndRange = block.StartRange + seq.Length - 1;
                    block.Data     = seq;

                    _virtualData.Add(block);
                    return(block);
                }
            }
        }
        public Folder GetParent(Guid libraryId, FolderGetOptions options)
        {
            var cacheId   = ParentFolderCacheKey(libraryId, options.Path);
            var folderBox = (CacheBox <Folder>)cacheService.Get(cacheId, CacheScope.Context | CacheScope.Process);

            if (folderBox == null)
            {
                var url    = !string.IsNullOrEmpty(options.SPWebUrl) ? options.SPWebUrl : GetUrl(libraryId);
                var folder = folders.GetParent(url, libraryId, options.Path);
                folderBox = new CacheBox <Folder>(folder);
                cacheService.Put(cacheId, folderBox, CacheScope.Context | CacheScope.Process, new[] { Tag(libraryId) }, CacheTimeOut);
            }
            return(folderBox.Data);
        }
Esempio n. 3
0
        /// <summary>
        /// Gets a block from the cache at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index of the block.</param>
        /// <returns>The cached sequence block.</returns>
        private CacheBox <byte[]> GetCacheBlock(int index)
        {
            CacheBox <byte[]> block = _virtualData.FirstOrDefault(C => index >= C.StartRange && index <= C.EndRange);

            if (block != null)
            {
                return(block);
            }
            else
            {
                int startIndex         = index;
                int blockStartingIndex = index - (index % BlockSize);
                int sequenceLength     = (int)(SequencePointerInstance.IndexOffsets[1] - SequencePointerInstance.IndexOffsets[0]);
                int count = sequenceLength > BlockSize ? BlockSize : sequenceLength;

                if (sequenceLength > BlockSize && _sidecarProvider != null)
                {
                    blockStartingIndex = _sidecarProvider.GetBlockToLoad(_sequenceIndex, index, ref startIndex, ref count);
                }
                else
                {
                    blockStartingIndex = 0;
                    startIndex         = 0;
                }

                byte[] seq = _parser.ParseRange(blockStartingIndex, count, SequencePointerInstance);

                if (seq == null)
                {
                    return(null);
                }
                else
                {
                    block = new CacheBox <byte[]>(seq.Length)
                    {
                        StartRange = startIndex
                    };
                    block.EndRange = block.StartRange + seq.Length - 1;
                    block.Data     = seq;

                    _virtualData.Add(block);
                    return(block);
                }
            }
        }
Esempio n. 4
0
        /// <summary>
        /// Creates an edited sequence block at the specified position.
        /// </summary>
        /// <param name="position">The position to create the block at.</param>
        /// <returns>The edited sequence block.</returns>
        private CacheBox <IDerivedSequence> CreateEditedSequenceBlock(int position)
        {
            CacheBox <Sequence> block = GetCacheBlock(position);
            Sequence            seq   = block.Data;

            IDerivedSequence derivedSeq = new DerivedSequence(seq);
            int listindex = position / BlockSize;

            CacheBox <IDerivedSequence> cache = new CacheBox <IDerivedSequence>(block.BlockSize)
            {
                StartRange = block.StartRange,
                EndRange   = block.EndRange,
                Data       = derivedSeq
            };

            _editedSequences.Add(listindex, cache);
            return(cache);
        }
Esempio n. 5
0
        /// <summary>
        /// Gets or sets the symbol at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index of the symbol to get or set.</param>
        /// <returns> The symbol at the specified index.</returns>
        public ISequenceItem this[int index]
        {
            get
            {
                int position = index;
                if (_editedSequences != null && _editedSequences.Values.Count > 0)
                {
                    CacheBox <IDerivedSequence> editedBlock = GetEditedBlock(position);
                    if (editedBlock != null)
                    {
                        IDerivedSequence derivedSeq = editedBlock.Data;
                        return(derivedSeq[position - (int)editedBlock.StartRange]);
                    }
                    else
                    {
                        position = position + (int)GetPositionDiff(position);
                    }
                }

                CacheBox <Sequence> block = GetCacheBlock(position);
                if (block != null)
                {
                    return(block.Data[position - (int)block.StartRange]);
                }
                else
                {
                    return(null);
                }
            }

            set
            {
                if (value == null)
                {
                    throw new ArgumentNullException("value");
                }
                if (IsReadOnly)
                {
                    throw new InvalidOperationException(Properties.Resource.CanNotModifyReadonlySequence);
                }
                // Sequence edit is not taken care when DV is enabled.
            }
        }
Esempio n. 6
0
        /// <summary>
        /// Creates an edited sequence block at the specified position.
        /// </summary>
        /// <param name="position">The position to create the block at.</param>
        /// <returns>The edited sequence block.</returns>
        private CacheBox <IDerivedSequence> CreateEditedSequenceBlock(int position)
        {
            CacheBox <byte[]> block = GetCacheBlock(position);

            char[] chars = new char[block.Data.Length];
            block.Data.CopyTo(chars, 0);
            Sequence         seq        = new Sequence(_alphabet, new string(chars));
            IDerivedSequence derivedSeq = new DerivedSequence(seq);
            int listindex = position / BlockSize;

            CacheBox <IDerivedSequence> cache = new CacheBox <IDerivedSequence>(block.BlockSize)
            {
                StartRange = block.StartRange,
                EndRange   = block.EndRange,
                Data       = derivedSeq
            };

            _editedSequences.Add(listindex, cache);
            return(cache);
        }
Esempio n. 7
0
        /// <summary>
        /// Removes a range of symbols from the sequence.
        /// </summary>
        /// <param name="position">The zero-based starting index of the range of symbols to remove.</param>
        /// <param name="length">The number of symbols to remove.</param>
        public void RemoveRange(int position, int length)
        {
            int currentPosition = position;
            int localPosition;
            IDerivedSequence            derivedSequence;
            CacheBox <IDerivedSequence> editedBlock = GetEditedBlock(currentPosition);

            if (editedBlock != null)
            {
                derivedSequence = editedBlock.Data;
                localPosition   = currentPosition - (int)editedBlock.StartRange;
            }
            else
            {
                int positionDiff = (int)GetPositionDiff(currentPosition);
                currentPosition         = currentPosition + positionDiff;
                editedBlock             = CreateEditedSequenceBlock(currentPosition);
                derivedSequence         = editedBlock.Data;
                editedBlock.StartRange -= positionDiff;
                editedBlock.EndRange   -= positionDiff;
                localPosition           = position - (int)editedBlock.StartRange;
            }

            int removableLength = length;

            if ((derivedSequence.Count - localPosition) < length)
            {
                removableLength = derivedSequence.Count - localPosition;
            }

            derivedSequence.RemoveRange(localPosition, removableLength);
            editedBlock.EndRange = editedBlock.EndRange - removableLength;
            UpdateStartAndEndRanges(editedBlock.StartRange, -removableLength);
            _count -= removableLength;

            if (removableLength != length)
            {
                RemoveRange(position, length - removableLength);
            }
        }
Esempio n. 8
0
        /// <summary>
        /// Gets or sets the symbol at the specified index.
        /// </summary>
        /// <param name="index">The zero-based index of the symbol to get or set.</param>
        /// <returns> The symbol at the specified index.</returns>
        public byte this[int index]
        {
            get
            {
                int position = index;
                if (_editedSequences != null && _editedSequences.Values.Count > 0)
                {
                    CacheBox <IDerivedSequence> editedBlock = GetEditedBlock(position);
                    if (editedBlock != null)
                    {
                        IDerivedSequence derivedSeq = editedBlock.Data;
                        return((byte)derivedSeq[position - (int)editedBlock.StartRange].Symbol);
                    }
                    else
                    {
                        position = position + (int)GetPositionDiff(position);
                    }
                }

                CacheBox <byte[]> block = GetCacheBlock(position);
                if (block != null)
                {
                    return(block.Data[position - (int)block.StartRange]);
                }
                else
                {
                    return(default(byte));
                }
            }

            set
            {
                if (IsReadOnly)
                {
                    throw new InvalidOperationException(Properties.Resource.CanNotModifyReadonlySequence);
                }
                Replace(index, value);
            }
        }
Esempio n. 9
0
        public void ValidateCacheBoxAllProperties()
        {
            CacheBox <Sequence> ch     = new CacheBox <Sequence>(10);
            Sequence            seqObj = new Sequence(Alphabets.DNA, "AGCT");

            ch.Data     = seqObj;
            ch.EndRange = 6;
            DateTime nowObj = DateTime.Now;

            ch.LastAccessTime = nowObj;
            ch.StartRange     = 0;

            Assert.AreEqual(10, ch.BlockSize);
            Assert.AreEqual(seqObj, ch.Data);
            Assert.AreEqual(6, ch.EndRange);
            Assert.AreEqual(nowObj, ch.LastAccessTime);
            Assert.AreEqual(0, ch.StartRange);

            // Logs to the NUnit GUI (Console.Out) window
            Console.WriteLine(
                "Cache Box BVT : Successfully validated all the properties.");
            ApplicationLog.WriteLine(
                "Cache Box BVT : Successfully validated all the properties.");
        }
Esempio n. 10
0
        private Dictionary <int, InputRangeInfo> RebuildCacheBoxRanges(IEnumerable <RlmIOWithValue> inputs, double linearTolerance)
        {
            CacheBoxCount++;
            CacheBox.Clear();

            var cacheBoxRangeInfos = new Dictionary <int, InputRangeInfo>();
            int cacheRangeCnt      = 0;

            foreach (var item in inputs)
            {
                if (item.Type == Enums.RlmInputType.Linear)
                {
                    double val     = Convert.ToDouble(item.Value);
                    double dataOff = (item.Max - item.Min) * ((linearTolerance == 0) ? 0 : (linearTolerance / 100D));
                    //double cacheMargin = (CacheBoxMargin == 0) ? 0 : ((item.Max - item.Min) * (CacheBoxMargin / 100));
                    double momentum = item.InputMomentum.MomentumDirection;
                    double toOff    = 0;
                    double fromOff  = 0;
                    double cacheOff = 0;

                    if (UseMomentumAvgValue)
                    {
                        cacheOff = item.InputMomentum.MomentumValue * MomentumAdjustment;
                    }
                    else
                    {
                        cacheOff = (item.Max - item.Min) * ((linearTolerance == 0) ? 0 : (MomentumAdjustment / 100D));
                    }


                    if (momentum > 0)
                    {
                        var offset = momentum * cacheOff;
                        toOff   = val + dataOff + (cacheOff + offset);
                        fromOff = val - dataOff - (cacheOff - offset);
                    }
                    else if (momentum < 0)
                    {
                        var offset = Math.Abs(momentum) * cacheOff;
                        toOff   = val + dataOff + (cacheOff - offset);
                        fromOff = val - dataOff - (cacheOff + offset);
                    }
                    else
                    {
                        toOff   = val + dataOff + cacheOff;
                        fromOff = val - dataOff - cacheOff;
                    }

                    double cacheMargin = (CacheBoxMargin == 0) ? 0 : (cacheOff) * (CacheBoxMargin / 100D);

                    toOff   += cacheMargin;
                    fromOff -= cacheMargin;

                    cacheBoxRangeInfos.Add(cacheRangeCnt, new InputRangeInfo()
                    {
                        InputId = item.ID, FromValue = Math.Ceiling(fromOff), ToValue = Math.Ceiling(toOff)
                    });
                }
                else
                {
                    cacheBoxRangeInfos.Add(cacheRangeCnt, new InputRangeInfo()
                    {
                        InputId = item.ID, Value = item.Value
                    });
                }
                cacheRangeCnt++;
            }

            CacheBox.SetRanges(cacheBoxRangeInfos.Values);
            return(cacheBoxRangeInfos);
        }
Esempio n. 11
0
        /// <summary>
        /// Gets best Solution
        /// </summary>
        /// <param name="inputs"></param>
        /// <param name="linearTolerance"></param>
        /// <param name="predict"></param>
        /// <returns></returns>
        public Solution GetBestSolution(IEnumerable <RlmIOWithValue> inputs, double trainingLinearTolerance = 0, bool predict = false, double predictLinearTolerance = 0, IEnumerable <long> excludeSolutions = null)
        {
            this.predict          = predict;
            this.excludeSolutions = excludeSolutions;

            bool   useLinearTolerance = ((predict && predictLinearTolerance > 0) || !predict) ? true : false;
            double linearTolerance    = (predict) ? predictLinearTolerance : trainingLinearTolerance;

            Solution retVal = null;

            int cnt = 0;

            foreach (var item in inputs)
            {
                InputRangeInfo rangeInfo = null;
                double         val;

                if (item.DotNetType == typeof(bool).ToString())
                {
                    bool boolVal = Convert.ToBoolean(item.Value);
                    val = (boolVal) ? 1 : 0;
                }
                else
                {
                    val = Convert.ToDouble(item.Value);
                }

                if (item.Type == Enums.RlmInputType.Linear)
                {
                    double off = (item.Max - item.Min) * ((linearTolerance == 0) ? 0 : (linearTolerance / 100D));
                    rangeInfo = new InputRangeInfo()
                    {
                        InputId = item.ID, InputType = item.Type, FromValue = val - off, ToValue = val + off
                    };
                }
                else
                {
                    rangeInfo = new InputRangeInfo()
                    {
                        InputId = item.ID, InputType = item.Type, Value = item.Value, FromValue = val, ToValue = val
                    };
                }

                rangeInfos[cnt] = rangeInfo;

                doubleInputsArray[cnt] = doubleInputs[cnt].DataArray;
                resultsArray[cnt]      = results[cnt].DataArray;
                fromArray[cnt]         = rangeInfo.FromValue;
                toArray[cnt]           = rangeInfo.ToValue;
                cnt++;
            }

            currBS = null;

            if (useLinearTolerance && predict == false)
            {
                if (CacheBox.IsWithinRange(rangeInfos, linearTolerance))
                {
                    rneuronProcessor.Execute(CacheBox.CachedRneurons, CacheBox.CachedInputs, fromArray, toArray, false);
                }
                else
                {
                    double[][] cacheBoxRangeInfos = RebuildCacheBoxRangesGPU(inputs, linearTolerance);

                    rneuronsCacheArray = new bool[rneuronIds.DataArray.Length];
                    var cachedDataArray = rneuronProcessor.Execute(rneuronIds.DataArray, doubleInputsArray, fromArray, toArray, rneuronsCacheArray, cacheBoxRangeInfos[0], cacheBoxRangeInfos[1]);

                    CacheBox.CachedRneurons = cachedDataArray.Rneurons.ToArray();
                    CacheBox.CachedInputs   = cachedDataArray.Inputs.Select(a => a.ToArray()).ToArray();
                }
            }
            else
            {
                rneuronProcessor.Execute(rneuronIds.DataArray, doubleInputsArray, fromArray, toArray, true);
            }

            if (currBS != null)
            {
                retVal = Solutions[currBS.SolutionId];
            }

            return(retVal);
        }
        /// <summary>
        /// Gets best Solution
        /// </summary>
        /// <param name="inputs"></param>
        /// <param name="linearTolerance"></param>
        /// <param name="predict"></param>
        /// <returns></returns>
        public Solution GetBestSolution(IEnumerable <RlmIOWithValue> inputs, double linearTolerance = 0, bool predict = false)
        {
            Solution retVal = null;

            var         comparer      = new DynamicInputComparer();//Util.DynamicInputComparer;
            List <long> rneuronsFound = new List <long>();

            var rangeInfos = new Dictionary <int, InputRangeInfo>();
            int cnt        = 0;

            foreach (var item in inputs)
            {
                if (item.Type == Enums.RlmInputType.Linear)
                {
                    double val = Convert.ToDouble(item.Value);
                    double off = (item.Max - item.Min) * ((linearTolerance == 0) ? 0 : (linearTolerance / 100D));

                    rangeInfos.Add(cnt, new InputRangeInfo()
                    {
                        InputId = item.ID, InputType = item.Type, FromValue = val - off, ToValue = val + off
                    });
                }
                else
                {
                    rangeInfos.Add(cnt, new InputRangeInfo()
                    {
                        InputId = item.ID, InputType = item.Type, Value = item.Value
                    });
                }
                cnt++;
            }

            //swGetRneuron.Start();

            //RnnInputValue.RecurseInputForMatchingRneurons(DynamicInputs, rangeInfos, rneuronsFound);

            //swGetRneuron.Stop();
            //GetRneuronTimes.Add(swGetRneuron.Elapsed);
            //swGetRneuron.Reset();

            //TODO Cache Box, current implementation is slow don't know why
            if (!predict)
            {
                if (CacheBox.IsWithinRange(rangeInfos, linearTolerance))
                {
                    swGetRneuron.Start();

                    RlmInputValue.RecurseInputForMatchingRneurons(CacheBox.CachedInputs, rangeInfos, rneuronsFound);

                    swGetRneuron.Stop();
                    GetRneuronTimes.Add(swGetRneuron.Elapsed);
                    swGetRneuron.Reset();
                }
                else
                {
                    swRebuildCache.Start();

                    CacheBoxCount++;
                    CacheBox.Clear();

                    var cacheBoxRangeInfos = new Dictionary <int, InputRangeInfo>();
                    int cacheRangeCnt      = 0;
                    foreach (var item in inputs)
                    {
                        if (item.Type == Enums.RlmInputType.Linear)
                        {
                            double val     = Convert.ToDouble(item.Value);
                            double dataOff = (item.Max - item.Min) * ((linearTolerance == 0) ? 0 : (linearTolerance / 100D));
                            //double cacheMargin = (CacheBoxMargin == 0) ? 0 : ((item.Max - item.Min) * (CacheBoxMargin / 100));
                            double momentum = item.InputMomentum.MomentumDirection;
                            double toOff    = 0;
                            double fromOff  = 0;
                            double cacheOff = 0;

                            if (UseMomentumAvgValue)
                            {
                                cacheOff = item.InputMomentum.MomentumValue * MomentumAdjustment;
                            }
                            else
                            {
                                cacheOff = (item.Max - item.Min) * ((linearTolerance == 0) ? 0 : (MomentumAdjustment / 100D));
                            }


                            if (momentum > 0)
                            {
                                var offset = momentum * cacheOff;
                                toOff   = val + dataOff + (cacheOff + offset);
                                fromOff = val - dataOff - (cacheOff - offset);
                            }
                            else if (momentum < 0)
                            {
                                var offset = Math.Abs(momentum) * cacheOff;
                                toOff   = val + dataOff + (cacheOff - offset);
                                fromOff = val - dataOff - (cacheOff + offset);
                            }
                            else
                            {
                                toOff   = val + dataOff + cacheOff;
                                fromOff = val - dataOff - cacheOff;
                            }

                            double cacheMargin = (CacheBoxMargin == 0) ? 0 : (cacheOff) * (CacheBoxMargin / 100D);

                            toOff   += cacheMargin;
                            fromOff -= cacheMargin;

                            cacheBoxRangeInfos.Add(cacheRangeCnt, new InputRangeInfo()
                            {
                                InputId = item.ID, FromValue = Math.Ceiling(fromOff), ToValue = Math.Ceiling(toOff)
                            });
                        }
                        else
                        {
                            cacheBoxRangeInfos.Add(cacheRangeCnt, new InputRangeInfo()
                            {
                                InputId = item.ID, Value = item.Value
                            });
                        }
                        cacheRangeCnt++;
                    }

                    CacheBox.SetRanges(cacheBoxRangeInfos.Values);

                    CacheBox.CachedInputs = RlmInputValue.RecurseInputForMatchingRneuronsForCaching(DynamicInputs, cacheBoxRangeInfos, rangeInfos, rneuronsFound);
                    //RnnInputValue.RecurseInputForMatchingRneurons(CacheBox.CachedInputs, rangeInfos, rneuronsFound);

                    swRebuildCache.Stop();
                    RebuildCacheboxTimes.Add(swRebuildCache.Elapsed);
                    swRebuildCache.Reset();
                }
            }
            else
            {
                RlmInputValue.RecurseInputForMatchingRneurons(DynamicInputs, rangeInfos, rneuronsFound);
            }

            BestSolution currBS = null;

            foreach (var rneuronId in rneuronsFound)
            {
                Dictionary <long, BestSolution> bsDict;
                if (BestSolutions.TryGetValue(rneuronId, out bsDict))
                {
                    foreach (var bs in bsDict.Values)
                    {
                        if (!predict)
                        {
                            if (currBS != null)
                            {
                                if (bs.CycleScore > currBS.CycleScore)
                                {
                                    currBS = bs;
                                }
                                else if (bs.CycleScore == currBS.CycleScore && bs.SessionScore >= currBS.SessionScore && bs.CycleOrder >= currBS.CycleOrder)
                                {
                                    currBS = bs;
                                }
                            }
                            else
                            {
                                currBS = bs;
                            }
                        }
                        else
                        {
                            if (currBS != null)
                            {
                                if (bs.SessionScore > currBS.SessionScore)
                                {
                                    currBS = bs;
                                }
                                else if (bs.SessionScore == currBS.SessionScore && bs.CycleScore >= currBS.CycleScore && bs.CycleOrder >= currBS.CycleOrder)
                                {
                                    currBS = bs;
                                }
                            }
                            else
                            {
                                currBS = bs;
                            }
                        }
                    }
                }
            }

            if (currBS != null)
            {
                retVal = Solutions[currBS.SolutionId];
            }

            return(retVal);
        }
Esempio n. 13
0
        /// <summary>
        /// General method to validate virtual data class.
        /// <param name="addParam">Additional parameter.</param>
        /// </summary>
        static void ValidateGeneralVirtualDataTestCases(AdditionalParameters addParam)
        {
            VirtualData <Sequence> vdObj = new VirtualData <Sequence>();

            // Sets the Initial Properties and required Cache box
            vdObj.MaxNumberOfBlocks = 5;
            vdObj.BlockSize         = 5;
            CacheBox <Sequence> cb1 = new CacheBox <Sequence>(11);

            cb1.StartRange = 0;
            cb1.EndRange   = 10;
            cb1.Data       = new Sequence(Alphabets.DNA, "GGGGGGGGGGGGG");

            CacheBox <Sequence> cb2 = new CacheBox <Sequence>(11);

            cb2.StartRange = 0;
            cb2.EndRange   = 10;
            cb2.Data       = new Sequence(Alphabets.DNA, "TTTTTTTTTTTTT");

            CacheBox <Sequence> cb3 = new CacheBox <Sequence>(11);

            cb3.StartRange = 0;
            cb3.EndRange   = 10;
            cb3.Data       = new Sequence(Alphabets.DNA, "CCCCCCCCCCCCC");

            CacheBox <Sequence> cb4 = new CacheBox <Sequence>(11);

            cb4.StartRange = 0;
            cb4.EndRange   = 10;
            cb4.Data       = new Sequence(Alphabets.DNA, "AAAAAAAAAAAAAA");

            List <CacheBox <Sequence> > cbList = new List <CacheBox <Sequence> >();

            cbList.Add(cb1);
            cbList.Add(cb2);
            cbList.Add(cb3);
            cbList.Add(cb4);

            switch (addParam)
            {
            case AdditionalParameters.Add:
                vdObj.Add(cb1);
                vdObj.Add(cb2);
                vdObj.Add(cb3);
                vdObj.Add(cb4);

                for (int i = 0; i < vdObj.Count; i++)
                {
                    Assert.AreEqual(cbList[i].Data, vdObj[i].Data);
                }

                // Logs to the NUnit GUI (Console.Out) window
                Console.WriteLine(
                    "Virtual Data BVT : Successfully validated the Add() method.");
                ApplicationLog.WriteLine(
                    "Virtual Data BVT : Successfully validated the Add() method.");
                break;

            case AdditionalParameters.AddData:
                vdObj.AddData(new Sequence(Alphabets.DNA, "GGGGGGGGGGGGG"), 0, 10);
                vdObj.AddData(new Sequence(Alphabets.DNA, "TTTTTTTTTTTTT"), 0, 10);
                vdObj.AddData(new Sequence(Alphabets.DNA, "CCCCCCCCCCCCC"), 0, 10);
                vdObj.AddData(new Sequence(Alphabets.DNA, "AAAAAAAAAAAAAA"), 0, 10);

                for (int i = 0; i < vdObj.Count; i++)
                {
                    Assert.AreEqual(cbList[i].Data.ToString(), vdObj[i].Data.ToString());
                }

                // Logs to the NUnit GUI (Console.Out) window
                Console.WriteLine(
                    "Virtual Data BVT : Successfully validated the AddData() method.");
                ApplicationLog.WriteLine(
                    "Virtual Data BVT : Successfully validated the AddData() method.");
                break;

            case AdditionalParameters.AddDelay:
                vdObj.MaxNumberOfBlocks = 2;
                vdObj.Add(cb1);
                vdObj.Add(cb2);
                // Sleep for 20 seconds so that the cache box would be cleared
                // and the count of items in the VirtualData would be reduced
                Thread.Sleep(20000);
                vdObj.Add(cb3);
                vdObj.Add(cb4);

                for (int i = 0; i < vdObj.Count; i++)
                {
                    Assert.AreEqual(cbList[i + 2].Data, vdObj[i].Data);
                }

                // Logs to the NUnit GUI (Console.Out) window
                Console.WriteLine(
                    "Virtual Data BVT : Successfully validated the Add() method.");
                ApplicationLog.WriteLine(
                    "Virtual Data BVT : Successfully validated the Add() method.");
                break;

            case AdditionalParameters.AddDataDelay:
                vdObj.MaxNumberOfBlocks = 2;
                vdObj.AddData(new Sequence(Alphabets.DNA, "GGGGGGGGGGGGG"), 0, 10);
                vdObj.AddData(new Sequence(Alphabets.DNA, "TTTTTTTTTTTTT"), 0, 10);
                // Sleep for 20 seconds so that the cache box would be cleared
                // and the count of items in the VirtualData would be reduced
                Thread.Sleep(20000);
                vdObj.AddData(new Sequence(Alphabets.DNA, "CCCCCCCCCCCCC"), 0, 10);
                vdObj.AddData(new Sequence(Alphabets.DNA, "AAAAAAAAAAAAAA"), 0, 10);

                for (int i = 0; i < vdObj.Count; i++)
                {
                    Assert.AreEqual(cbList[i + 2].Data.ToString(), vdObj[i].Data.ToString());
                }

                // Logs to the NUnit GUI (Console.Out) window
                Console.WriteLine(
                    "Virtual Data BVT : Successfully validated the AddData() method.");
                ApplicationLog.WriteLine(
                    "Virtual Data BVT : Successfully validated the AddData() method.");
                break;

            case AdditionalParameters.Clear:
                vdObj.Add(cb1);
                vdObj.Add(cb2);
                vdObj.Add(cb3);
                vdObj.Add(cb4);
                vdObj.Clear();
                Assert.AreEqual(0, vdObj.Count);
                // Logs to the NUnit GUI (Console.Out) window
                Console.WriteLine(
                    "Virtual Data BVT : Successfully validated the Clear() method.");
                ApplicationLog.WriteLine(
                    "Virtual Data BVT : Successfully validated the Clear() method.");
                break;

            case AdditionalParameters.ClearStaleData:
                vdObj.MaxNumberOfBlocks = 2;
                vdObj.Add(cb1);
                vdObj.Add(cb2);
                // Sleep for 20 seconds so that the cache box would be cleared
                // and the count of items in the VirtualData would be reduced
                Thread.Sleep(20000);
                vdObj.Add(cb3);
                vdObj.Add(cb4);
                Assert.IsTrue(3 > vdObj.Count);
                // Logs to the NUnit GUI (Console.Out) window
                Console.WriteLine(
                    "Virtual Data BVT : Successfully validated the ClearStaleData() method.");
                ApplicationLog.WriteLine(
                    "Virtual Data BVT : Successfully validated the ClearStaleData() method.");
                break;

            case AdditionalParameters.GetAllData:
                vdObj.Add(cb1);
                vdObj.Add(cb2);
                vdObj.Add(cb3);
                vdObj.Add(cb4);
                // Gets all the data in Virtual data object
                IList <Sequence> allSeqData = vdObj.GetAllData();
                for (int i = 0; i < allSeqData.Count; i++)
                {
                    Assert.AreEqual(cbList[i].Data.ToString(), allSeqData[i].ToString());
                }

                // Logs to the NUnit GUI (Console.Out) window
                Console.WriteLine(
                    "Virtual Data BVT : Successfully validated the GetAllData() method.");
                ApplicationLog.WriteLine(
                    "Virtual Data BVT : Successfully validated the GetAllData() method.");
                break;

            case AdditionalParameters.GetData:
                vdObj.Add(cb1);
                vdObj.Add(cb2);
                vdObj.Add(cb3);
                vdObj.Add(cb4);
                // Gets the data in Virtual data object
                for (int i = 0; i < vdObj.Count; i++)
                {
                    Assert.AreEqual(cbList[i].Data.ToString(), vdObj.GetData(i).ToString());
                }

                // Logs to the NUnit GUI (Console.Out) window
                Console.WriteLine(
                    "Virtual Data BVT : Successfully validated the GetData() method.");
                ApplicationLog.WriteLine(
                    "Virtual Data BVT : Successfully validated the GetData() method.");
                break;

            case AdditionalParameters.GetEnumerator:
                vdObj.Add(cb1);
                vdObj.Add(cb2);
                IEnumerator <CacheBox <Sequence> > enumObj = vdObj.GetEnumerator();
                Assert.IsTrue(null != enumObj);
                Assert.AreEqual(cb1, vdObj.FirstOrDefault(C => 0 >= C.StartRange && 0 <= C.EndRange));
                // Logs to the NUnit GUI (Console.Out) window
                Console.WriteLine(
                    "Virtual Data BVT : Successfully validated the GetEnumerator() method.");
                ApplicationLog.WriteLine(
                    "Virtual Data BVT : Successfully validated the GetEnumerator() method.");
                break;

            case AdditionalParameters.Insert:
                vdObj.Add(cb1);
                vdObj.Add(cb2);
                vdObj.Add(cb3);
                // Inserts the cache box in Virtual data object
                vdObj.Insert(3, cb4);
                for (int i = 0; i < vdObj.Count; i++)
                {
                    Assert.AreEqual(cbList[i].Data, vdObj[i].Data);
                }

                // Logs to the NUnit GUI (Console.Out) window
                Console.WriteLine(
                    "Virtual Data BVT : Successfully validated the Insert() method.");
                ApplicationLog.WriteLine(
                    "Virtual Data BVT : Successfully validated the Insert() method.");
                break;

            case AdditionalParameters.Remove:
                vdObj.Add(cb1);
                vdObj.Add(cb2);
                vdObj.Add(cb3);
                vdObj.Add(cb4);

                // Add a Cache Box and remove the same
                CacheBox <Sequence> cb5 = new CacheBox <Sequence>(11);
                cb5.StartRange = 0;
                cb5.EndRange   = 10;
                cb5.Data       = new Sequence(Alphabets.DNA, "AAAAAATTTTTTT");
                vdObj.Add(cb5);
                vdObj.Remove(cb5);
                // Removes the cache box from the virtual data list
                for (int i = 0; i < cbList.Count; i++)
                {
                    Assert.AreEqual(cbList[i].Data, vdObj[i].Data);
                }

                // Logs to the NUnit GUI (Console.Out) window
                Console.WriteLine(
                    "Virtual Data BVT : Successfully validated the Remove() method.");
                ApplicationLog.WriteLine(
                    "Virtual Data BVT : Successfully validated the Remove() method.");
                break;

            case AdditionalParameters.RemoveAt:
                vdObj.Add(cb1);
                vdObj.Add(cb2);
                vdObj.Add(cb3);
                vdObj.Add(cb4);

                // Add a Cache Box and remove the same
                CacheBox <Sequence> cbRemove = new CacheBox <Sequence>(11);
                cbRemove.StartRange = 0;
                cbRemove.EndRange   = 10;
                cbRemove.Data       = new Sequence(Alphabets.DNA, "AAAAAATTTTTTT");
                vdObj.Add(cbRemove);
                vdObj.RemoveAt(4);

                for (int i = 0; i < cbList.Count; i++)
                {
                    Assert.AreEqual(cbList[i].Data, vdObj[i].Data);
                }

                // Logs to the NUnit GUI (Console.Out) window
                Console.WriteLine(
                    "Virtual Data BVT : Successfully validated the RemoveAt() method.");
                ApplicationLog.WriteLine(
                    "Virtual Data BVT : Successfully validated the RemoveAt() method.");
                break;

            case AdditionalParameters.Contains:
                vdObj.Add(cb1);
                vdObj.Add(cb2);
                vdObj.Add(cb3);
                vdObj.Add(cb4);
                // Validates the contains block
                Assert.IsTrue(vdObj.Contains(cb4));

                // Logs to the NUnit GUI (Console.Out) window
                Console.WriteLine(
                    "Virtual Data BVT : Successfully validated the Contains() method.");
                ApplicationLog.WriteLine(
                    "Virtual Data BVT : Successfully validated the Contains() method.");
                break;

            case AdditionalParameters.CopyTo:
                vdObj.Add(cb1);
                vdObj.Add(cb2);
                vdObj.Add(cb3);
                vdObj.Add(cb4);
                CacheBox <Sequence>[] cbArray = new CacheBox <Sequence> [vdObj.Count];
                vdObj.CopyTo(cbArray, 0);

                for (int i = 0; i < vdObj.Count; i++)
                {
                    Assert.AreEqual(cbArray[i].Data, vdObj[i].Data);
                }

                // Logs to the NUnit GUI (Console.Out) window
                Console.WriteLine(
                    "Virtual Data BVT : Successfully validated the CopyTo() method.");
                ApplicationLog.WriteLine(
                    "Virtual Data BVT : Successfully validated the CopyTo() method.");
                break;

            default:
                break;
            }
        }