Beispiel #1
0
 public TestSample(string sampleID, Haplogroup predefiniedHaplogroup, Sample sample, SampleRange sampleRange, string state)
 {
     this.testSampleID          = sampleID;
     this.sample                = sample;
     this.predefiniedHaplogroup = predefiniedHaplogroup;
     this.sampleRange           = sampleRange;
     this.state = state;
 }
Beispiel #2
0
        private void exportResults(string outFilename)
        {
            StringBuilder result           = new StringBuilder();
            var           sampleCollection = session.CurrentSampleFile.TestSamples;

            sampleCollection.Sort();
            result.Append("SampleID\tRange\tHaplogroup\tQuality\tPolymorphisms\n");
            if (sampleCollection != null)
            {
                foreach (TestSample sample in sampleCollection)
                {
                    result.Append(sample.SampleID + "\t");
                    SampleRange range       = sample.SampleRanges;
                    var         startRange  = range.Starts;
                    var         endRange    = range.Ends;
                    string      resultRange = "";
                    for (int i = 0; i < startRange.Count; i++)
                    {
                        if (startRange[i] == endRange[i])
                        {
                            resultRange = resultRange + startRange[i] + ";";
                        }
                        else
                        {
                            resultRange = resultRange + startRange[i] + "-" + endRange[i] + ";";
                        }
                    }
                    result.Append(resultRange + "\t");
                    result.Append(sample.RecognizedHaplogroup + "\t");
                    result.Append(sample.ResultQuality + "\t");
                    getPolysUsed(result, session.getClassificationResults(sample.SampleID));
                    getPolysNotUsed(result, session.getClassificationResults(sample.SampleID));
                    getPolysUnused(result, session.getClassificationResults(sample.SampleID));
                    result.Append("\n");
                }
            }
            StreamWriter fileWriter = new StreamWriter(outFilename);

            fileWriter.Write(result.ToString());
            fileWriter.Close();
        }
Beispiel #3
0
        public TestSample(string currentLine)
        {
            string[] tokens = currentLine.Split(new char[] { '\t' }, StringSplitOptions.RemoveEmptyEntries);
            if (tokens.Length < 4)
            {
                throw new HaploGrepException("Not enough columns in .hsd file");
            }
            this.testSampleID = tokens[0].Trim();
            if (tokens[1].Length == 0)
            {
                throw new ArgumentException("No range specified, range given was: " + tokens[1]);
            }
            tokens[1]        = tokens[1].Replace("\"", "");
            this.sampleRange = new SampleRange(tokens[1]);
            if ((tokens[2].Equals("?")) || (tokens[2].Equals("SEQ")))
            {
                this.predefiniedHaplogroup = new Haplogroup("");
            }
            else
            {
                this.predefiniedHaplogroup = new Haplogroup(tokens[2]);
            }
            StringBuilder sampleString = new StringBuilder();

            for (int i = 3; i < tokens.Length; i++)
            {
                sampleString.Append(tokens[i] + " ");
            }
            try
            {
                this.sample = new Sample(sampleString.ToString(), 0);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
 public SampleRange(SampleRange rangeToCopy)
 {
     this.starts.AddRange(rangeToCopy.starts);
     this.ends.AddRange(rangeToCopy.ends);
 }