public bool containsSuperhaplogroup(Haplogroup haplogroup)
 {
     if (haplogroup.isSuperHaplogroup(Cluster[0].Haplogroup))
     {
         return(true);
     }
     return(false);
 }
Exemple #2
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;
 }
 public SearchResult(string haplogroup, Sample polysInTestSample)
 {
     this.haplogroup        = new Haplogroup(haplogroup);
     this.usedPolysInSample = polysInTestSample;
     this.unusedPolys.AddRange(polysInTestSample.Polymorphismn);
     foreach (Polymorphism currentPoly in polysInTestSample.Polymorphismn)
     {
         this.usedWeightPolys += currentPoly.getMutationRate();
     }
 }
 public virtual PhyloTreePath getPhyloTreePath(Haplogroup haplogroup)
 {
     foreach (SearchResult currentResult in this.cluster)
     {
         if (currentResult.Haplogroup.Equals(haplogroup))
         {
             return(currentResult.UsedPath);
         }
     }
     return(null);
 }
Exemple #5
0
        public void changePoly(Haplogroup hg, Polymorphism polyOld, Polymorphism polyNew)
        {
            var e = getPolysOfHg(hg);

            foreach (XmlNode ce in e)
            {
                if (ce.InnerText.Equals(polyOld.ToString()))
                {
                    ce.InnerText = polyNew.ToString();
                    return;
                }
            }
            throw new HaploGrepException("Polymorphism does not exit");
        }
Exemple #6
0
        public override bool Equals(object haplogroup)
        {
            if (!(haplogroup is Haplogroup))
            {
                return(false);
            }
            Haplogroup c = (Haplogroup)haplogroup;

            if (!this.id.Equals(c.id))
            {
                return(false);
            }
            return(true);
        }
Exemple #7
0
        public bool isSuperHaplogroup(Haplogroup hgToCheck)
        {
            if (!(hgToCheck is Haplogroup))
            {
                return(false);
            }
            Haplogroup c = hgToCheck;

            if (!c.id.Contains(this.id))
            {
                return(false);
            }
            return(true);
        }
 public SearchResult(string newHaplogroup, SearchResult resultToCopy)
 {
     this.haplogroup        = new Haplogroup(newHaplogroup);
     this.usedPolysInSample = resultToCopy.usedPolysInSample;
     this.allCheckedPolys.AddRange(resultToCopy.allCheckedPolys);
     this.correctPolys.AddRange(resultToCopy.correctPolys);
     this.unusedPolys.AddRange(resultToCopy.unusedPolys);
     this.correctedBackmutations.AddRange(resultToCopy.correctedBackmutations);
     this.unusedPolysNotInRange.AddRange(resultToCopy.unusedPolysNotInRange);
     this.missingPolysOutOfRange.AddRange(resultToCopy.missingPolysOutOfRange);
     this.usedPath            = new PhyloTreePath(resultToCopy.usedPath);
     this.usedWeightPolys     = resultToCopy.usedWeightPolys;
     this.correctWeightPolys  = resultToCopy.correctWeightPolys;
     this.expectedWeightPolys = resultToCopy.expectedWeightPolys;
     this.missingWeightPolys  = resultToCopy.missingWeightPolys;
 }
Exemple #9
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;
            }
        }
Exemple #10
0
        public XmlNodeList getPolysOfHg(Haplogroup hg)
        {
            var titleNode = xmlDoc.SelectSingleNode("//haplogroup[@name=\"" + hg.ToString() + "\"]/details");

            return(titleNode.SelectNodes("poly"));
        }
        public static List <ClusteredSearchResult> createClusteredSearchResult(List <SearchResult> unclusteredResults, Haplogroup hg)
        {
            List <ClusteredSearchResult> clusteredSearchResult = new List <ClusteredSearchResult>();

            //sort the results by top hit
            unclusteredResults.Sort();
            int    i                 = 0;
            double currentRank       = -1.0D;
            bool   foundPredefinedHG = false;

            foreach (SearchResult currentResult in unclusteredResults)
            {
                if (i == 50)
                {
                    break;
                }
                if (currentRank != currentResult.Rank)
                {
                    clusteredSearchResult.Add(new ClusteredSearchResult(i + 1));
                    i++;
                    currentRank = currentResult.Rank;
                }
                clusteredSearchResult[i - 1].Cluster.Add(currentResult);
                if (currentResult.Haplogroup.Equals(hg))
                {
                    foundPredefinedHG = true;
                }
            }
            if ((!foundPredefinedHG) && (!hg.ToString().Equals("")))
            {
                int pos = 1;
                foreach (SearchResult currentResult in unclusteredResults)
                {
                    if (currentResult.Haplogroup.Equals(hg))
                    {
                        clusteredSearchResult.Add(new ClusteredSearchResult(pos));
                        clusteredSearchResult[i].Cluster.Add(currentResult);
                        break;
                    }
                    pos++;
                }
            }
            return(clusteredSearchResult);
        }
 public PhyloTreeNode(Haplogroup haplogroup)
 {
     this.haplogroup = haplogroup;
 }