//public static MarkerEvidence Date ( ITrendComparison comparison ) {
 //   if ( comparison == null )
 //      throw new ArgumentNullException("comparison");
 //   else if ( comparison.Count <= 0 )
 //      throw new InvalidOperationException("There should be at least one survey year considered.");
 //   else if ( comparison.CountOfNullZeroes <= 0 ) //All the scores are null for both subjects.
 //      return MarkerEvidence.Missing;
 //   else if ( comparison.CountOfNullZeroes >= 2 && comparison.PointsAgreePerfectly )
 //      return MarkerEvidence.StronglySupports;
 //   else if ( comparison.CountOfNullZeroes >= 3 && Math.Abs(comparison.AgreementProportionExcludingNulls - 1.0) < 1e-5 )
 //   //else if ( comparison.CountOfNullZeroes >= 2 && Math.Abs(comparison.AgreementProportionExcludingNulls - 1.0) < 1e-5 )
 //      return MarkerEvidence.StronglySupports;
 //   else if ( comparison.LastMutualNonNullPointsAgree.HasValue && comparison.LastMutualNonNullPointsAgree.Value )
 //      return MarkerEvidence.Supports;
 //   else if ( comparison.CountOfNullZeroes >= 2 && comparison.AgreementProportionExcludingNulls <= .5 )
 //      return MarkerEvidence.Disconfirms;
 //   else if ( comparison.CountOfNullZeroes >= 2 && comparison.AgreementProportionExcludingNulls > .5 )
 //      return MarkerEvidence.Supports;
 //   else if ( comparison.LastMutualNonNullPointsAgree.HasValue && !comparison.LastMutualNonNullPointsAgree.Value )
 //      return MarkerEvidence.Unlikely;
 //   //else if ( DisagreementCountIncludingNulls > 0 )
 //   //   return MarkerEvidence.Unlikely;
 //   else
 //      return MarkerEvidence.Ambiguous;
 //}
 public static MarkerEvidence InHH( TrendComparisonInteger comparison )
 {
     if ( comparison == null )
         throw new ArgumentNullException("comparison");
     else if ( comparison.Count <= 0 )
         throw new InvalidOperationException("There should be at least one survey year considered.");
     else if ( comparison.CountOfNullZeroes <= 0 ) //All the scores are null for both subjects.
         return MarkerEvidence.Missing;
     //else if ( comparison.CountOfNullZeroes >= 2 && Math.Abs(comparison.AgreementProportionOfOnes - 0.0) < 1e-7 ) //If agree on no twice, disconfirm full sibs (ie, go half siblings);
     else if ( comparison.CountOfAtLeastOneResponseIsOne >= 2 && Math.Abs(comparison.AgreementProportionOfOnes - 0.0) < 1e-7 ) //If agree on no twice, disconfirm full sibs (ie, go half siblings);
         return MarkerEvidence.Disconfirms;
     else if ( comparison.AgreementCountOfOnes >= 2 && Math.Abs(comparison.AgreementProportionOfOnes - 1.0) < 1e-7 ) //If always agree on yes twice, support full siblings
         return MarkerEvidence.StronglySupports;
     else if ( comparison.CountOfNullZeroes >= 3 && comparison.AgreementProportionOfOnes > .6 ) //If 2 of 3 responses (or more) say agree on yes, support full siblings
         return MarkerEvidence.Supports;
     else if ( comparison.CountOfNullZeroes >= 2 && Math.Abs(comparison.AgreementProportionOfOnes - 0.0) < 1e-7 ) //If agree on no twice, disconfirm full sibs (ie, go half siblings);
         return MarkerEvidence.Unlikely;//Moved down and switched from disconfirms to unlikely
     else if ( comparison.CountOfNullZeroes == 1 && Math.Abs(comparison.AgreementProportionOfOnes - 0.0) < 1e-7 ) //If agree on no once, say unlikely full sibs (ie, go half siblings);
         return MarkerEvidence.Unlikely;
     else if ( comparison.AgreementCountOfOnes < 2 && Math.Abs(comparison.AgreementProportionOfOnes - 1.0) < 1e-7 ) //If always agree on yes, support full siblings
         return MarkerEvidence.Supports;//Moved down from BabyDaddy
     //else if ( comparison.CountOfNullZeroes >= 3 && comparison.AgreementProportionOfOnes < .3 ) //If 1 of 3 responses (or less) say disagree on yes, disconfirm full sibs (ie, go half siblings);
     else if ( comparison.CountOfAtLeastOneResponseIsOne >= 3 && comparison.AgreementProportionOfOnes < .34 ) //If 1 of 3 responses (or less) say disagree on yes, disconfirm full sibs (ie, go half siblings);
         return MarkerEvidence.Disconfirms;
     else
         return MarkerEvidence.Ambiguous;
 }
 public static MarkerEvidence AliveOrAsthma( TrendComparisonInteger comparison )
 {
     if ( comparison == null )
         throw new ArgumentNullException("comparison");
     else if ( comparison.Count <= 0 )
         throw new InvalidOperationException("There should be at least one survey year considered.");
     else if ( comparison.CountOfNullZeroes <= 0 ) //All the scores are null for both subjects.
         return MarkerEvidence.Missing;
     else if ( comparison.CountOfNullZeroes >= 2 && Math.Abs(comparison.AgreementProportionExcludingNulls - 0.0) < 1e-7 ) //If different values twice, disconfirm full sibs (ie, go half siblings);
         return MarkerEvidence.Disconfirms;
     else if ( comparison.CountOfNullZeroes >= 4 && comparison.AgreementProportionExcludingNulls <= .5 ) //If the majority of 4+ responses disagree, disconfirm full sibs (ie, go half siblings);
         return MarkerEvidence.Disconfirms;
     else if ( comparison.CountOfNullZeroes >= 1 && !comparison.LastMutualNonNullPointsAgree.Value ) //If different values once, unlikely full sibs (ie, go half siblings);
         return MarkerEvidence.Unlikely;
     else if ( comparison.CountOfNullZeroes >= 1 && Math.Abs(comparison.AgreementProportionExcludingNulls - 1.0) < 1e-7 ) //If always agree on yes, evidence is consistent with full siblings.
         return MarkerEvidence.Consistent;
     else if ( comparison.CountOfNullZeroes >= 4 && comparison.AgreementProportionExcludingNulls >= .75 ) //If 75% of 4+ responses agree, disconfirm full sibs (ie, go half siblings);
         return MarkerEvidence.Consistent;
     else
         return MarkerEvidence.Ambiguous;
 }
 public static MarkerEvidence DistanceFromHH( TrendComparisonInteger comparison )
 {
     if ( comparison == null )
         throw new ArgumentNullException("comparison");
     else if ( comparison.Count <= 0 )
         throw new InvalidOperationException("There should be at least one survey year considered.");
     else if ( comparison.CountOfNullZeroes <= 0 ) //All the scores are null for both subjects.
         return MarkerEvidence.Missing;
     else if ( comparison.CountOfNullZeroes >= 2 && Math.Abs(comparison.AgreementProportionExcludingNulls - 0.0) < 1e-7 ) //If different distances twice, disconfirm full sibs (ie, go half siblings);
         return MarkerEvidence.Disconfirms;
     else if ( comparison.CountOfNullZeroes >= 4 && comparison.AgreementProportionExcludingNulls <= .5 ) //If the majority of 4+ responses disagree, disconfirm full sibs (ie, go half siblings);
         return MarkerEvidence.Disconfirms;
     else if ( comparison.CountOfNullZeroes >= 1 && Math.Abs(comparison.AgreementProportionExcludingNulls - 0.0) < 1e-7 ) //If different distances once, unlikely full sibs (ie, go half siblings);
         return MarkerEvidence.Unlikely;
     else if ( comparison.CountOfNullZeroes >= 1 && Math.Abs(comparison.AgreementProportionExcludingNulls - 1.0) < 1e-7 ) //If always agree on yes, evidence is consistent with full siblings.
         return MarkerEvidence.Consistent;
     else if ( comparison.CountOfNullZeroes >= 4 && comparison.AgreementProportionExcludingNulls >= .75 ) //If 75% of 4+ responses agree, disconfirm full sibs (ie, go half siblings);
         return MarkerEvidence.Consistent;
     //TODO: add a clause that weakly supports with the following case. Multiple distances over the years, and the values agree.
     //	It's not great, because two biodads could live close to each other, and when the mom moves around, it could look like the two dads are the same person.
     else
         return MarkerEvidence.Ambiguous;
 }
        private Int32 FromFatherIsAlive( LinksDataSet.tblRelatedStructureRow drRelated, LinksDataSet.tblFatherOfGen2DataTable dtFatherSubject1, LinksDataSet.tblFatherOfGen2DataTable dtFatherSubject2, Int16 extendedID )
        {
            const MarkerType markerType = MarkerType.Gen2CFatherAlive;
            const bool fromMother = false;
            Int16[] surveyYears = ItemYears.Gen2CFatherAlive;
            Int16?[] points1 = FatherOfGen2.RetrieveIsAlive(drRelated.SubjectTag_S1, surveyYears, dtFatherSubject1);
            Int16?[] points2 = FatherOfGen2.RetrieveIsAlive(drRelated.SubjectTag_S2, surveyYears, dtFatherSubject2);

            TrendLineInteger trend1 = new TrendLineInteger(surveyYears, points1);
            TrendLineInteger trend2 = new TrendLineInteger(surveyYears, points2);
            TrendComparisonInteger comparison = new TrendComparisonInteger(trend1, trend2);
            MarkerEvidence mzEvidence = DetermineShareGen2Father.AliveOrAsthma(comparison);
            MarkerEvidence biodadEvidence = mzEvidence;
            return AddMarkerRow(extendedID, drRelated.ID, markerType, comparison.LastNonMutualNullPointsYear, mzEvidence, biodadEvidence, fromMother);
        }
        private Int32 FromBabyDaddyInHH( LinksDataSet.tblRelatedStructureRow drRelated, LinksDataSet.tblBabyDaddyDataTable dtBabyDaddySubject1, LinksDataSet.tblBabyDaddyDataTable dtBabyDaddySubject2, Int16 extendedID )
        {
            const MarkerType markerType = MarkerType.BabyDaddyInHH;
            const bool fromMother = true;
            Int16[] surveyYears = ItemYears.BabyDaddyInHH;
            Int16?[] values1 = BabyDaddy.RetrieveInHH(drRelated.SubjectTag_S1, surveyYears, dtBabyDaddySubject1);
            Int16?[] values2 = BabyDaddy.RetrieveInHH(drRelated.SubjectTag_S2, surveyYears, dtBabyDaddySubject2);

            TrendLineInteger trend1 = new TrendLineInteger(surveyYears, values1);
            TrendLineInteger trend2 = new TrendLineInteger(surveyYears, values2);
            TrendComparisonInteger comparison = new TrendComparisonInteger(trend1, trend2);
            MarkerEvidence mzEvidence = DetermineShareBabyDaddy.InHH(comparison);
            MarkerEvidence biodadEvidence = mzEvidence;
            return AddMarkerRow(extendedID, drRelated.ID, markerType, comparison.LastNonMutualNullPointsYear, mzEvidence, biodadEvidence, fromMother);
        }
 private void BiodadInHH( MarkerEvidence expected, TrendComparisonInteger comparison )
 {
     MarkerEvidence actual = DetermineShareBabyDaddy.InHH(comparison);
     Assert.AreEqual(expected, actual, "The determination should be correct.");
 }
 public void TestInitialize( )
 {
     _trend0 = new TrendLineInteger(_surveyYears2, _values0);
     _trend1 = new TrendLineInteger(_surveyYears1, _values1);
     _trend2 = new TrendLineInteger(_surveyYears2, _values2);
     _trend3 = new TrendLineInteger(_surveyYears2, _values3);
     _trend4 = new TrendLineInteger(_surveyYears2, _values4);
     _trend5 = new TrendLineInteger(_surveyYears2, _values5);
     _comparison0vs0 = new TrendComparisonInteger(_trend0, _trend0);
     _comparison0vs1 = new TrendComparisonInteger(_trend0, _trend1);
     _comparison0vs3 = new TrendComparisonInteger(_trend0, _trend3);
     _comparison1vs2 = new TrendComparisonInteger(_trend1, _trend2);
     _comparison1vs3 = new TrendComparisonInteger(_trend1, _trend3);
     _comparison1vs4 = new TrendComparisonInteger(_trend1, _trend4);
     _comparison1vs5 = new TrendComparisonInteger(_trend1, _trend5);
     _comparison2vs3 = new TrendComparisonInteger(_trend2, _trend3);
     _comparison3vs3 = new TrendComparisonInteger(_trend3, _trend3);
     _comparison3vs4 = new TrendComparisonInteger(_trend3, _trend4);
 }
 public void TestCleanup( )
 {
     _trend0 = null;
     _trend1 = null;
     _trend2 = null;
     _trend3 = null;
     _trend4 = null;
     _trend5 = null;
     _comparison0vs0 = null;
     _comparison0vs1 = null;
     _comparison0vs3 = null;
     _comparison1vs2 = null;
     _comparison1vs3 = null;
     _comparison1vs4 = null;
     _comparison1vs5 = null;
     _comparison2vs3 = null;
     _comparison3vs3 = null;
     _comparison3vs4 = null;
 }