Ejemplo n.º 1
0
        private void CloseCurrentSaWriter()
        {
            if (_currentRefName == null)
            {
                return;
            }

            //write last SA item
            if (!_prevSaCreator.IsEmpty())
            {
                _saWriter.Write(_prevSaCreator, _prevSaCreator.ReferencePosition);
                _numSaWritten++;
            }
            // reset _prevSa
            _prevSaCreator = null;

            // write the intervals
            _saWriter.SetIntervalList(_supplementaryIntervalList);

            Console.WriteLine("No of intervals: {0}", _supplementaryIntervalList.Count);

            _saWriter.Dispose();
            double lookupsPerSecond;

            Console.WriteLine("No of annotations : {0}", _numSaWritten);
            Console.WriteLine("{0} supplementary annotations written - {1}", _numSaWritten,
                              _creationBench.GetElapsedIterationTime(_numSaWritten, "variants", out lookupsPerSecond));

            Console.WriteLine("No of ref minor positions: {0}", _saWriter.RefMinorCount);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// writes the annotations to the current database file
        /// </summary>
        public void Write(SupplementaryPositionCreator spCreator, int referencePos, bool finalizePositinalAnnotation = true)
        {
            if (finalizePositinalAnnotation)
            {
                spCreator.FinalizePositionalAnnotations();
            }

            if (spCreator.IsEmpty())
            {
                return;
            }

            // add this entry to the index
            var currentOffset = _stream.Position;

            _index.Add((uint)referencePos, (uint)currentOffset, spCreator.IsRefMinor());
            if (spCreator.IsRefMinor())
            {
                RefMinorCount++;
            }

            spCreator.WriteAnnotation(_writer);
        }
Ejemplo n.º 3
0
        public void CreateDatabase()
        {
            var unsorted = 0;

            _creationBench = new Benchmark();

            _prevSaCreator = null;

            // loading ref sequence
            var saCreator = GetNextSupplementaryAnnotation();

            while (saCreator != null)
            {
                if (!_currentRefName.Equals(saCreator.RefSeqName)) //sanity check
                {
                    throw new Exception("Error: currentRef != sa ref");
                }

                if (_saWriter == null) //check for empty writer
                {
                    Console.WriteLine("Supplementary annotationa writer was not initialized");
                    return;
                }


                // this SA is not the first one in current contig
                if (_prevSaCreator != null)
                {
                    if (saCreator.ReferencePosition == _prevSaCreator.ReferencePosition)
                    {
                        _prevSaCreator.MergeSaCreator(saCreator);
                    }
                    else
                    {
                        if (_prevSaCreator.RefSeqName == saCreator.RefSeqName && _prevSaCreator.ReferencePosition > saCreator.ReferencePosition)
                        {
                            Console.WriteLine("Unsorted records:{0}, {1}, {2}, {3}", _prevSaCreator.RefSeqName,
                                              _prevSaCreator.ReferencePosition, saCreator.RefSeqName, saCreator.ReferencePosition);
                            unsorted++;
                        }

                        if (!_prevSaCreator.IsEmpty())
                        {
                            _saWriter.Write(_prevSaCreator, _prevSaCreator.ReferencePosition);
                            _numSaWritten++;
                        }
                        _prevSaCreator = saCreator;
                    }
                }
                else
                {
                    _prevSaCreator = saCreator;
                }


                saCreator = GetNextSupplementaryAnnotation();
            }


            // do not forgot to write the last item
            CloseCurrentSaWriter();

            Console.WriteLine("");
            Console.WriteLine("unsorted records: {0}", unsorted);
        }