Genetic Programming help
I need some guidance on a java project. I'm to develop a human genetic(family) tree.
This is the subject:
Each human cell contains 23 pairs of chromosomes numbered from 1 to 22,and a pair of sex chromosomes: XX in females and XY in man. During fertilization, the 22 chromosomes + (X or Y) of the man merges with the 22 + X chromosome of the woman. This results in 22 pairs of chromosomes + (X or Y) in the cell that will form the future baby. The 23rd chromosome transmitted by the father (an X or Y) will determine the sex of the child (XX for a girl, XY for a boy).
Each chromosome carries many genes (encoding almost everything, a characteristic morphological, physiological, behavioral). Due to pairs of chromosomes, the genetic information is duplicated (except for parts of the sex chromosomes). Each copy of a gene is called an allele. So that means for example, if the a gene is responsible for the color of an eye, then the allele is blue.
The genetic information expressed as a consequence of the combined expression of alleles being present. A dominant allele is always expressed in the genome of its bearer. However, if information from one allele is not expressed when a dominant allele of the same gene is present, it is a recessive allele. The peculiarity of the recessive allele of a gene is that it can be present in the genome and transmitted over several generations without it is expressed in the phenotype its bearers. If there is no dominant allele, two copies of the gene have the same recessive allele (homozygous recessive) then the recessive character is expressed. Through the use of family tree, it is possible to determine the expression of a gene within a family.
The program should be able to do the following:
-generate a simplified version relied on 23 chromosomes and allow the user to place genes on chromosomes then simulate replication, mitosis, meiosis and fusion of the chromosomes and display the locations of genes on the resulting cells.
-allow to draw genealogical trees and deduced probabilities (or certainty) on the expression of genes on a person's family tree.
So far so good i've created a class Gene and a class Chromosome. Next, i thought about creating a class "Parent" for example and creating 23 chromosomes in it. But before doing that i want to make the 23rd chromosome different for a man/woman. Then simulates replication, crossovers, mitosis etc.. I don't know if i'm on the right track. I also don't know how to specify that a particular allele/gene is recessive or dominant. For the moment my classes only act in a random manner. I document
Gene.java
import java.util.Random;
/**
* @author mkab
*
*/
public class Gene implements Cloneable {
private Object allele;
public Gene(){
super();
}
public Gene(Object allele){
super();
this.allele = allele;
}
/**
* Randomly selects a trait from trait1 or trait2 and returns a new Gene with that trait
* @param trait1
* @param trait2
*
* @return a new Gene
*/
public Gene randomAllele(Object trait1, Object trait2){
Object allele = null;
Random rand = new Random();
int i = rand.nextInt(2);// generate between 0 and 2: only 2 possibilities: 0 or 1
switch(i){
case 0:
allele = trait1;
break;
case 1:
allele = trait2;
break;
}
return new Gene(allele);
}
public Gene clone() throws CloneNotSupportedException{
Gene g;
g = (Gene) super.clone();
return g;
}
/**
* @param allele the allele to set
*/
public void setAllele(Object allele) {
this.allele = allele;
}
/**
* @return the allele
*/
public Object getAllele() {
return allele;
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "Gene [allele=" + allele +"]";
}
}
Chromosome.java
/**
*
*/
package project_try;
import java.util.ArrayList;
import java.util.Iterator;
/**
* Class that creates a pair of chromosome by adding random genes
* @author mkab
*
*/
public class Chromosome implements Cloneable {
/**
* the user can put as many genes as possible on the chromosome
*/
private ArrayList<Gene> genes = new ArrayList<Gene>();
public Chromosome(){
super();
}
public Chromosome(ArrayList<Gene> genes){
this.genes = genes;
}
/**
* Add a gene object to this chromosomes list.
*/
public void addGene(Gene gene) {
genes.add(gene);
}
/**
*creates a copy of a chromosome
*/
@SuppressWarnings("unch开发者_JAVA技巧ecked")
@Override
public Chromosome clone()throws CloneNotSupportedException{
Chromosome c;
c = (Chromosome) super.clone();
c.genes = (ArrayList<Gene>)this.genes.clone();
//Iterator<Gene> it = c.genes.iterator();
/*Gene tmp;
while(it.hasNext()){
}*/
return c;
}
/**
* @return the genes
*/
public ArrayList<Gene> getGenes() {
return genes;
}
/**
* @param genes the genes to set
*/
public void setGenes(ArrayList<Gene> genes) {
this.genes = genes;
}
/**
*
* @return
*/
public int getSize(){
return genes.size();
}
/**
* @return a gene at an index i of the ArrayList
* @param index - the index at which to return a gene
*/
public Gene getGenes(int index) {
return genes.get(index);
}
/* (non-Javadoc)
* @see java.lang.Object#toString()
*/
@Override
public String toString() {
return "Chromosome [genes=" + genes + "]";
}
}
My problem is to be able to be able to make a gene recessive or dominant. For example when the chromosomes of the male with blue eyes genes mate the with those of the female with brown, if the male genes are dominant the child would have blue eyes instead of brown but that child would still have the recessive gene "brown eyes" somewhere within it.
I also want to know if the classes i made tackle this problem correctly. I'm also thinking about making a class "Pair_of_chromosome" for example containing two chromosome variables and the making a class "Parent" containing a table of 23 "Pair_of_chromosome". I don't know if this is the right way.
I dont know much about genetics, however the right way to model this is to have a Person-class, implement a constructor that takes 2 Persons (the parents), throw an Exception if they are of same sex, construct the chromosomes (and individual genes) for the new Person inside this constructor based on a random combination of the parents (accounting for recessive genes etc.).
Here is some Octave Code to do similar genetic simulation studies. YMMV.
精彩评论