示例#1
0
        public void RefMinorSearch()
        {
            var saIndex   = new SaIndex(3);
            var nodeCount = 3 * SaIndexNode.SaNodeWidth;

            for (uint i = 0; i < nodeCount; i++)
            {
                saIndex.Add(100 + i * 3, 1000 + i * 30, i % 3 == 0);//every third item is ref minor
            }
            var randomPath = GetRandomPath();

            saIndex.Write(randomPath, "chr1");

            using (var reader = new ExtendedBinaryReader(FileUtilities.GetReadStream(randomPath)))
            {
                var readSaIndex = new SaIndex(reader);

                Assert.True(readSaIndex.IsRefMinor(100));
                //this result should be cached for the next query
                Assert.Equal((uint)1000, readSaIndex.GetFileLocation(100));

                Assert.False(readSaIndex.IsRefMinor(101));//not present position

                Assert.Equal((uint)1030, readSaIndex.GetFileLocation(103));
                //this result should be cached for the next query
                Assert.True(readSaIndex.IsRefMinor(109));

                Assert.Equal(uint.MinValue, readSaIndex.GetFileLocation(131));//location past the index
            }

            File.Delete(randomPath);
        }
示例#2
0
        public void IndexCreation()
        {
            var saIndex   = new SaIndex(3);
            var nodeCount = 3 * SaIndexNode.SaNodeWidth;

            for (uint i = 0; i < nodeCount; i++)
            {
                saIndex.Add(100 + i, 1000 + i * 19, false);
            }

            Assert.Equal(Math.Ceiling(nodeCount * 1.0 / (SaIndexNode.SaNodeWidth + 1)), saIndex.Count());
        }
示例#3
0
 public RefMinorProvider(List <string> supplementaryAnnotationDirectories)
 {
     foreach (var directory in supplementaryAnnotationDirectories)
     {
         foreach (var file in Directory.GetFiles(directory, "*.idx"))
         {
             var chromeName       = Path.GetFileNameWithoutExtension(file).Split('.')[0];
             var refMinorPostions = SaIndex.Read(FileUtilities.GetReadStream(file)).GlobalMajorAlleleForRefMinor;
             if (refMinorPostions.Length > 0)
             {
                 _positionDict[chromeName] = refMinorPostions.ToDictionary(x => x.Position, x => x.GlobalMajorAllele);
             }
         }
     }
 }
示例#4
0
        public void IndexWriteRead()
        {
            var saIndex   = new SaIndex(3);
            var nodeCount = 3 * SaIndexNode.SaNodeWidth;

            for (uint i = 0; i < nodeCount; i++)
            {
                saIndex.Add(100 + i, 1000 + i * 19, i % 3 == 0);//every third node is ref minor
            }
            var randomPath = GetRandomPath();

            saIndex.Write(randomPath, "chr1");

            using (var reader = new ExtendedBinaryReader(FileUtilities.GetReadStream(randomPath)))
            {
                var readSaIndex = new SaIndex(reader);
                Assert.Equal(Math.Ceiling(nodeCount * 1.0 / (SaIndexNode.SaNodeWidth + 1)), readSaIndex.Count());
                Assert.Equal("chr1", readSaIndex.RefSeqName);
            }

            File.Delete(randomPath);
        }