Exemple #1
0
        private void LoadHeader()
        {
            // grab the index and masked intervals offsets
            _indexOffset = _reader.ReadInt64();
            _reader.ReadInt64();

            // skip the creation time
            _reader.ReadOptInt64();

            // grab the reference metadata
            NumRefSeqs = (ushort)_reader.ReadOptInt32();

            for (ushort i = 0; i < NumRefSeqs; i++)
            {
                var metadata = ReferenceMetadata.Read(_reader);
                ReferenceMetadataList.Add(metadata);
                AddReferenceName(metadata.EnsemblName, metadata.UcscName, i);
            }

            // read the cytogenetic bands
            CytogeneticBands = Genome.CytogeneticBands.Read(_reader);

            // read the genome assembly
            Sequence.Assembly = (GenomeAssembly)_reader.ReadByte();

            // grab the data start tag
            ulong dataStartTag = _reader.ReadUInt64();

            if (dataStartTag != CompressedSequenceCommon.DataStartTag)
            {
                throw new InvalidFileFormatException($"The data start tag does not match the expected values: Obs: {dataStartTag} vs Exp: {CompressedSequenceCommon.DataStartTag}");
            }
        }
Exemple #2
0
 public NsaIndexBlock(ExtendedBinaryReader reader)
 {
     Start        = reader.ReadOptInt32();
     End          = reader.ReadOptInt32();
     FilePosition = reader.ReadOptInt64();
     Length       = reader.ReadOptInt32();
 }
Exemple #3
0
 public Chunk(ExtendedBinaryReader reader)
 {
     _start       = reader.ReadOptInt32();
     _end         = reader.ReadOptInt32();
     FilePosition = reader.ReadOptInt64();
     Length       = reader.ReadOptInt32();
 }
Exemple #4
0
 public JasixNode(ExtendedBinaryReader reader)
 {
     _start = reader.ReadOptInt32();
     //on disk we will store the end as an offset to save space
     _end         = _start + reader.ReadOptInt32();
     FileLocation = reader.ReadOptInt64();
 }
Exemple #5
0
        private static Interval <long> ReadInterval(ExtendedBinaryReader reader)
        {
            int  begin    = reader.ReadOptInt32();
            int  end      = reader.ReadOptInt32();
            long position = reader.ReadOptInt64();

            return(new Interval <long>(begin, end, position));
        }
        public static IDataSourceVersion Read(ExtendedBinaryReader reader)
        {
            var name             = reader.ReadAsciiString();
            var version          = reader.ReadAsciiString();
            var releaseDateTicks = reader.ReadOptInt64();
            var description      = reader.ReadAsciiString();

            return(new DataSourceVersion(name, version, releaseDateTicks, description));
        }
        internal DataSourceVersion(ExtendedBinaryReader reader)
        {
            Name             = reader.ReadAsciiString();
            Version          = reader.ReadAsciiString();
            ReleaseDateTicks = reader.ReadOptInt64();
            Description      = reader.ReadAsciiString();

            _hashCode = Name.GetHashCode() ^ Version.GetHashCode() ^ ReleaseDateTicks.GetHashCode();
        }
Exemple #8
0
        public void Read(ExtendedBinaryReader reader)
        {
            var count = reader.ReadOptInt32();

            for (var i = 0; i < count; i++)
            {
                DbSnp.Add(reader.ReadOptInt64());
            }
        }
Exemple #9
0
            public static Phenotype ReadPhenotype(ExtendedBinaryReader reader)
            {
                var mimNumber   = reader.ReadOptInt64();
                var phenotype   = reader.ReadAsciiString();
                var mapping     = (Mapping)reader.ReadByte();
                var comments    = (Comments)reader.ReadByte();
                var inheritance = reader.ReadOptArray(reader.ReadAsciiString);

                var inheritances = inheritance == null ? null : new HashSet <string>(inheritance);

                return(new Phenotype(mimNumber, phenotype, mapping, comments, inheritances));
            }
Exemple #10
0
        private static long GetObservedLong(long expectedLong)
        {
            long observedLong;

            using (var memoryStream = GetMemoryStream(expectedLong))
                using (var reader = new ExtendedBinaryReader(memoryStream))
                {
                    observedLong = reader.ReadOptInt64();
                }

            return(observedLong);
        }
Exemple #11
0
        public JasixIndex(Stream stream) : this()
        {
            _stream = stream;
            using (var reader = new ExtendedBinaryReader(stream))
            {
                int version = reader.ReadOptInt32();
                if (version != JasixCommons.Version)
                {
                    throw new InvalidDataException($"Invalid Jasix version: Observed {version}, expected{JasixCommons.Version}");
                }

                int count = reader.ReadOptInt32();

                for (var i = 0; i < count; i++)
                {
                    var chrIndex = new JasixChrIndex(reader);
                    _chrIndices[chrIndex.ReferenceSequence] = chrIndex;
                }

                int synonymCount = reader.ReadOptInt32();
                for (var i = 0; i < synonymCount; i++)
                {
                    string synonym   = reader.ReadAsciiString();
                    string indexName = reader.ReadAsciiString();
                    _synonymToChrName[synonym] = indexName;
                }

                int sectionCount = reader.ReadOptInt32();
                for (var i = 0; i < sectionCount; i++)
                {
                    string sectionName = reader.ReadAsciiString();
                    long   begin       = reader.ReadOptInt64();
                    long   end         = reader.ReadOptInt64();
                    _sectionRanges[sectionName] = new FileRange(begin, end);
                }
            }
        }
Exemple #12
0
        public static OmimAnnotation Read(ExtendedBinaryReader reader)
        {
            var hgnc           = reader.ReadAsciiString();
            var description    = reader.ReadAsciiString();
            var mimNumber      = reader.ReadOptInt64();
            var phenotypeCount = reader.ReadOptInt32();
            var phenotypes     = new List <Phenotype>();

            for (var i = 0; i < phenotypeCount; i++)
            {
                phenotypes.Add(Phenotype.ReadPhenotype(reader));
            }

            return(new OmimAnnotation(hgnc, description, mimNumber, phenotypes));
        }
Exemple #13
0
        public ClinVarItem(ExtendedBinaryReader reader)
        {
            _alleleOrigins = reader.ReadOptArray(reader.ReadAsciiString)?.ToList();
            SaAltAllele    = reader.ReadAsciiString();
            AltAllele      = SaAltAllele != null?SupplementaryAnnotationUtilities.ReverseSaReducedAllele(SaAltAllele) : "";                 // A

            ReferenceAllele = reader.ReadAsciiString();
            ID               = reader.ReadAsciiString();
            ReviewStatus     = (ReviewStatusEnum)reader.ReadByte();
            IsAlleleSpecific = reader.ReadAsciiString();
            _medgenIds       = reader.ReadOptArray(reader.ReadAsciiString)?.ToList();
            _omimIds         = reader.ReadOptArray(reader.ReadAsciiString)?.ToList();
            _orphanetIds     = reader.ReadOptArray(reader.ReadAsciiString)?.ToList();
            _phenotypes      = reader.ReadOptArray(reader.ReadUtf8String)?.ToList();
            Significance     = reader.ReadAsciiString();
            LastUpdatedDate  = reader.ReadOptInt64();
            _pubmedIds       = reader.ReadOptArray(reader.ReadOptInt64)?.ToList();
        }
        public void Long(long expectedNum)
        {
            long observedNum;

            using (var ms = new MemoryStream())
            {
                using (var writer = new ExtendedBinaryWriter(ms, Encoding.UTF8, true))
                {
                    writer.WriteOpt(expectedNum);
                }

                ms.Seek(0, SeekOrigin.Begin);

                using (var reader = new ExtendedBinaryReader(ms))
                {
                    observedNum = reader.ReadOptInt64();
                }
            }

            Assert.Equal(expectedNum, observedNum);
        }
Exemple #15
0
        public void ReadOptInt64_ThrowException_WithCorruptData()
        {
            Assert.Throws <FormatException>(delegate
            {
                using (var ms = new MemoryStream())
                {
                    using (var writer = new BinaryWriter(ms, Encoding.UTF8, true))
                    {
                        const ulong corruptData = 0xffffffffffffffff;
                        writer.Write(corruptData);
                        writer.Write(corruptData);
                    }

                    ms.Position = 0;

                    using (var reader = new ExtendedBinaryReader(ms))
                    {
                        reader.ReadOptInt64();
                    }
                }
            });
        }