-
Notifications
You must be signed in to change notification settings - Fork 1
/
TwentyThreeAndMeReader.cs
43 lines (37 loc) · 1.11 KB
/
TwentyThreeAndMeReader.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
using System;
using System.Text;
using System.IO;
namespace Personal_Genome_Explorer
{
/** Imports genome data exported from 23andme's website. */
class TwentyThreeAndMeReader
{
public static string fileFilterString = "23andme data files|*.txt|All files (*.*)|*.*";
DelimitedTableFileReader tableReader;
public TwentyThreeAndMeReader(StreamReader inParentReader)
{
tableReader = new DelimitedTableFileReader(inParentReader,'#','\t');
}
public IndividualGenomeDatabase Read()
{
// Initialize the database.
var database = new IndividualGenomeDatabase();
// Read the table of SNP genotypes.
tableReader.Read(
delegate(string[] columns)
{
if(columns.Length == 4)
{
// Parse a column of this format: rs# chromosome position genotype
var snpId = columns[0];
var snpValue = new SNPGenotype();
snpValue.genotype = DNA.StringToDiploidGenotype(columns[3]);
snpValue.orientation = Orientation.Plus;
// Add the SNP genotype to the database.
database.AddSNPValue(snpId, snpValue);
}
});
return database;
}
}
}