Exemple #1
0
 public void AddSampleVars(SampleVariant vr)
 {
     if (varTypes == null)
     {
         varTypes = new Dictionary <string, List <SampleVariant> > ();
     }
     if (!varTypes.ContainsKey(vr.BioS.ID))
     {
         varTypes.Add(vr.BioS.ID, new List <SampleVariant> ());
     }
     varTypes[vr.BioS.ID].Add(vr);
 }
Exemple #2
0
        protected static void LoadVarFile(string fName, BioSample [] samps, bool genotyped)
        {
            char[] seps  = { '/', '|' };
            int    count = 0;

            using (StreamReader sr = new StreamReader(fName)) {
                while ((int)'#' == sr.Peek())
                {
                    sr.ReadLine();
                }

                string[] spstrs;
                string   line;

                while ((line = sr.ReadLine()) != null)
                {
                    spstrs = line.Split('\t');

                    if (spstrs [6] == "PASS")
                    {
                        Variant v;

                        string[] sps = spstrs [4].Split(',');
                        if (sps.Length == 1)
                        {
                            v = new Variant(int.Parse(spstrs [1]), spstrs [3], spstrs [4]);
                        }
                        else if (sps.Length == 2)
                        {
                            v = new Variant(int.Parse(spstrs [1]), spstrs [3], sps [0], sps [1]);
                        }
                        else
                        {
                            v = new Variant(int.Parse(spstrs [1]), spstrs [3], sps [0], sps [1], sps [2]);
                        }

                        if (genotyped)
                        {
                            int genLen = spstrs.Length;
                            int stInd  = 9;

                            for (int i = stInd; i < genLen; i++)
                            {
                                bool parsed = true;

                                string[] sps2 = spstrs [i].Split(':');
                                string[] sps3 = sps2 [0].Split(seps);
                                int      ma   = 0;
                                int      al   = 0;
                                if (!int.TryParse(sps3 [0], out ma))
                                {
                                    parsed = false;
                                }
                                if (sps3.Length > 1)
                                {
                                    if (!int.TryParse(sps3 [1], out al))
                                    {
                                        parsed = false;
                                    }
                                }
                                if (parsed)
                                {
                                    SampleVariant s = new SampleVariant(ma, al, samps [i - stInd]);
                                    v.AddSampleVars(s);
                                }
                            }
                        }

                        AllVarPairs.Add(new VarScaffPair(spstrs [0], v));

                        count++;
                        if (count % 100000 == 0)
                        {
                            int tot = count / 100000;
                            MainData.UpdateLog("Read " + tot + "00K variants from " + MainData.MainWindow.MaxLenString(fName, 20), true);
                        }
                    }
                }
            }
        }