Ejemplo n.º 1
0
        public static MitoHeteroplasmyProvider GetProvider()
        {
            var assembly = Assembly.GetExecutingAssembly();

            using var stream = assembly.GetManifestResourceStream(ResourceName);
            if (stream == null)
            {
                throw new NullReferenceException("Unable to read from the Mitochondrial Heteroplasmy file");
            }

            using var gzStream = new GZipStream(stream, CompressionMode.Decompress);
            using var reader   = new StreamReader(gzStream);
            reader.ReadLine();

            var heteroplasmyProvider = new MitoHeteroplasmyProvider();

            while (true)
            {
                string line = reader.ReadLine();
                if (line == null)
                {
                    break;
                }

                var fields       = line.OptimizedSplit('\t');
                var position     = int.Parse(fields[PositionIndex]);
                var vrfs         = fields[VrfIndex].Split(',').Select(double.Parse);
                var alleleDepths = fields[AlleleDepthIndex].Split(',').Select(int.Parse).ToArray();
                heteroplasmyProvider.Add(position, fields[AltIndex], vrfs, alleleDepths);
            }

            return(heteroplasmyProvider);
        }
Ejemplo n.º 2
0
        public static MitoHeteroplasmyProvider GetProvider()
        {
            var assembly = Assembly.GetExecutingAssembly();

            using var stream = assembly.GetManifestResourceStream(ResourceName);
            if (stream == null)
            {
                throw new NullReferenceException("Unable to read from the Mitochondrial Heteroplasmy file");
            }

            using var gzStream = new GZipStream(stream, CompressionMode.Decompress);
            using var reader   = new StreamReader(gzStream);

            string line;

            var heteroplasmyProvider = new MitoHeteroplasmyProvider();

            while ((line = reader.ReadLine()) != null)
            {
                if (line.StartsWith("#"))
                {
                    continue;
                }

                var fields    = line.OptimizedSplit('\t');
                var position  = int.Parse(fields[PositionIndex]);
                var refAllele = fields[RefIndex];
                var altAllele = fields[AltIndex];
                if (altAllele == "." || !(refAllele.Length == 1 && altAllele.Length == 1))
                {
                    continue;
                }

                var vrfs         = fields[VrfBinsIndex].Split(',').Select(double.Parse);
                var alleleDepths = fields[VrfCountsIndex].Split(',').Select(int.Parse).ToArray();
                heteroplasmyProvider.Add(position, altAllele, vrfs.ToArray(), alleleDepths);
            }

            return(heteroplasmyProvider);
        }