public async Task WriteAllAsync(IFormatReader reader)
 {
     while (!reader.EndOfFile)
     {
         SNP genotype = await reader.ReadNext();
         await WriteNext(genotype);
     }
 }
        public async Task WriteNext(SNP genotype)
        {
            if (genotype == null)
            {
                return;
            }

            string line = SerializeGenotype(genotype);
            await _streamWriter.WriteLineAsync(line);
        }
        private SNP Parse(string line)
        {
            if (string.IsNullOrEmpty(line))
            {
                throw new InvalidFormatException();
            }

            string[] parts = line.Split("\t");
            if (parts.Length != 4)
            {
                throw new InvalidFormatException();
            }
            SNP genotype = new SNP
            {
                Rsid       = parts[0],
                Chromosome = parts[1],
                Position   = parts[2],
                Result     = parts[3]
            };

            return(genotype);
        }
        private SNP Parse(string line)
        {
            if (string.IsNullOrEmpty(line))
            {
                throw new InvalidFormatException();
            }

            string[] parts = line.Split(",");
            if (parts.Length != 4)
            {
                throw new InvalidFormatException();
            }
            string toReplace = "\"";
            SNP    genotype  = new SNP
            {
                Rsid       = parts[0].Replace(toReplace, String.Empty),
                Chromosome = parts[1].Replace(toReplace, String.Empty),
                Position   = parts[2].Replace(toReplace, String.Empty),
                Result     = parts[3].Replace(toReplace, String.Empty)
            };

            return(genotype);
        }
 private string SerializeGenotype(SNP genotype)
 {
     return($"\"{genotype.Rsid}\",\"{genotype.Chromosome}\",\"{genotype.Position}\",\"{genotype.Result}\"");
 }