-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathdeCODEmeReader.cs
46 lines (39 loc) · 1.19 KB
/
deCODEmeReader.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
44
45
46
using System;
using System.Text;
using System.IO;
namespace Personal_Genome_Explorer
{
/** Imports genome data exported from 23andme's website. */
class deCODEmeReader
{
public static string fileFilterString = "deCODEme data files|*.csv|All files (*.*)|*.*";
DelimitedTableFileReader tableReader;
public deCODEmeReader(StreamReader inParentReader)
{
tableReader = new DelimitedTableFileReader(inParentReader, '#', ',');
// Skip the first line of the file, which contains headings.
inParentReader.ReadLine();
}
public IndividualGenomeDatabase Read()
{
// Initialize the database.
var database = new IndividualGenomeDatabase();
// Read the table of SNP genotypes.
tableReader.Read(
delegate(string[] columns)
{
if(columns.Length == 6)
{
// Parse a column of this format: rs4477212,A/G,1,72017,+,AA
var snpId = columns[0];
var snpValue = new SNPGenotype();
snpValue.genotype = DNA.StringToDiploidGenotype(columns[5]);
snpValue.orientation = DNA.StringToOrientation(columns[4]);
// Add the SNP genotype to the database.
database.AddSNPValue(snpId, snpValue);
}
});
return database;
}
}
}