Ejemplo n.º 1
0
        /// <summary>
        /// Parses a list of biological sequence data from a file.
        /// </summary>
        /// <param name="filename">The name of a biological sequence file.</param>
        /// <param name="isReadOnly">
        /// Flag to indicate whether the resulting QualitativeSequences should be in readonly mode or not.
        /// If this flag is set to true then the resulting QualitativeSequences's isReadOnly property
        /// will be set to true, otherwise it will be set to false.
        /// </param>
        /// <returns>The list of parsed IQualitativeSequence objects.</returns>
        new public IList <IQualitativeSequence> Parse(string filename, bool isReadOnly)
        {
            _fileName = filename;

            //check DV is requried
            if (filename != null)
            {
                _fileLoadHelper    = new FileLoadHelper(filename);
                _blockSize         = _fileLoadHelper.BlockSize;
                _maxNumberOfBlocks = _fileLoadHelper.MaxNumberOfBlocks;

                if (_isDataVirtualizationForced)
                {
                    _blockSize = FileLoadHelper.DefaultBlockSize;
                }
            }
            else
            {
                _blockSize         = FileLoadHelper.DefaultFullLoadBlockSize;
                _maxNumberOfBlocks = 0;
            }

            SidecarFileProvider indexedProvider = null;

            // Check for sidecar
            if (IsDataVirtualizationEnabled)
            {
                try
                {
                    indexedProvider = SidecarFileProvider.GetProvider(filename);
                }
                catch (OperationCanceledException)
                {
                    indexedProvider = null;
                }
            }

            if (indexedProvider != null)
            {
                // Create virtual list and return
                return(new VirtualQualitativeSequenceList(indexedProvider, this, indexedProvider.Count)
                {
                    CreateSequenceAsReadOnly = isReadOnly
                });
            }
            else
            {
                using (BioTextReader bioReader = new BioTextReader(filename))
                {
                    return(Parse(bioReader, isReadOnly));
                }
            }
        }