示例#1
0
        public List <decimal> getPaternityIndices()
        {
            List <decimal> ret = new List <decimal>();

            for (int i = 0; i < config.fatherLoci.Count; i++)
            {
                Locus   fatherLocus = config.fatherLoci[i];
                Locus   childLocus  = config.childLoci[i];
                decimal X           = 0.5M;
                if (fatherLocus.isSame())
                {
                    X = 1;
                }
                decimal Y             = 0M;
                decimal similarAllele = Locus.getSimilarAllele(fatherLocus, childLocus);
                if (similarAllele > 0)
                {
                    var alleleFrequency = alleleFrequencies.Where((alleleFreq) => alleleFreq.locusName.Equals(fatherLocus.name) && alleleFreq.alleleNo.Equals(similarAllele)).FirstOrDefault();
                    if (alleleFrequency != null)
                    {
                        Y = alleleFrequency.frequency;
                    }
                }
                Console.WriteLine("X: " + X + "\t" + "Y: " + Y);
                if (Y == 0)
                {
                    ret.Add(0);         //paternity indexfor this locus will be zero
                }
                else
                {
                    ret.Add(X / Y * 100);
                }
            }
            return(ret);
        }
示例#2
0
 public static decimal getSimilarAllele(Locus a, Locus b)
 {
     //a could be father and b could be child ... even vice-versa
     if (a.allele1 == b.allele1 || a.allele1 == b.allele2)
     {
         return(a.allele1);
     }
     if (a.allele2 == b.allele1 || a.allele2 == b.allele2)
     {
         return(a.allele2);
     }
     if (a.allele1 == b.allele1 || a.allele2 == b.allele1)
     {
         return(b.allele1);
     }
     if (a.allele1 == b.allele2 || a.allele2 == b.allele2)
     {
         return(b.allele2);
     }
     return(0);
 }