using System; namespace Science.Biology.PopulationGenetics { /// /// Gene /// public class Gene { public Gene() { } private double[,] mutation; public double[,] Mutation { get { return mutation; } } private int numberOfAllele; public int NumberOfAllele { get{return numberOfAllele;} set { numberOfAllele = value; mutation = new Double[numberOfAllele, numberOfAllele]; } } private int from, to; private double modifiedvalue; public int From { set { from = value; } } public int To { set { to = value; } } public double ModifiedValue { set { modifiedvalue = value; } } public void SetMutation() // after set { mutation[from, to] = modifiedvalue; double sum = 0.0; for (int j = 0; j < NumberOfAllele; j++) if (j != from) sum += mutation[from, j]; mutation[from, from] = 1.0 - sum; } private int locus, start, end; public int ChromosomeNumber { get{return locus;} set{locus = value;} } public int StartBase { get { return start; } set{start = value;} } public int EndBase { get { return end; } set{end = value;} } private double factor1 = 0.0000001, factor2 = 0.0001; public double TransitionFactor { set { factor1 = value; } } public double RecoveringFactor { set { factor2 = value; } } public void FindMutation() // after set { double sum; for (int i = 0; i < NumberOfAllele; i++) for (int j = i + 1; j < NumberOfAllele; j++) { mutation[i, j] = factor1 * Convert.ToDouble(end - start); mutation[j, i] = factor2; } for (int i = 0; i < NumberOfAllele; i++) { sum = 0.0; for (int j = 0; j < NumberOfAllele; j++) if (j != i) sum += mutation[i, j]; mutation[i, i] = 1.0 - sum; } } } }