基因编程帮助

发布于 2024-10-20 18:50:29 字数 4475 浏览 2 评论 0原文

我需要一些关于 java 项目的指导。我要开发一棵人类遗传(家族)树。

这就是主题:

每个人体细胞含有23对染色体,编号为1到22,以及一对性染色体:女性为XX,男性为XY。在受精过程中,男性的 22 +(X 或 Y)染色体与女性的 22 + X 染色体融合。这会导致细胞中形成 22 对染色体 +(X 或 Y),从而形成未来的婴儿。 由父亲遗传的第 23 号染色体(X 或 Y)将决定孩子的性别(女孩为 XX,男孩为 XY)。

每条染色体携带许多基因(编码几乎所有的特征,形态、生理、行为)。由于染色体对,遗传信息是重复的(部分性染色体除外)。基因的每个拷贝称为等位基因。 这意味着,如果 a 基因决定眼睛的颜色,那么等位基因就是蓝色

作为存在的等位基因组合表达的结果而表达的遗传信息。显性等位基因总是在其携带者的基因组中表达。然而,如果来自一个等位基因的信息没有被表达 当存在同一基因的显性等位基因时,它是隐性等位基因。基因隐性等位基因的特点是它可以存在于基因组中并传递几代,而不会在表型中表达 它的承载者。如果没有显性等位基因,则该基因的两个拷贝具有相同的隐性等位基因(纯合隐性),则表达隐性特征。 通过使用家谱,可以确定家族内基因的表达。

该程序应该能够执行以下操作:

- 生成依赖于 23 条染色体的简化版本,并允许用户将基因放置在染色体上,然后模拟染色体的复制、有丝分裂、减数分裂和融合,并显示基因在所得细胞上的位置。

-允许绘制家谱树并推断一个人家谱上基因表达的概率(或确定性)。

到目前为止,我已经创建了一个类基因和一个类染色体。接下来,我考虑创建一个“Parent”类,并在其中创建 23 条染色体。但在此之前,我想让第 23 条染色体对于男人/女人来说是不同的。然后模拟复制、交叉、有丝分裂等。 我不知道我是否走在正确的轨道上。我也不知道如何指定特定等位基因/基因是隐性的还是显性的。目前我的课程只是以随机的方式进行。 我记录

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("unchecked")
    @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 + "]";
    }

}

我的问题是能够使基因隐性或显性。例如,当具有蓝眼睛基因的男性染色体与具有棕色眼睛基因的女性染色体交配时,如果男性基因为显性,则孩子将拥有蓝色眼睛而不是棕色眼睛,但该孩子仍将具有隐性基因“棕色眼睛”在其中的某个地方。

我也想知道我制作的课程是否正确解决了这个问题。 我还在考虑创建一个类“Pair_of_chromosome”,例如包含两个染色体变量,并创建一个包含 23 个“Pair_of_chromosome”表的“Parent”类。我不知道这是否是正确的方法。

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("unchecked")
    @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.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

仲春光 2024-10-27 18:50:29

我对遗传学了解不多,但是建模的正确方法是拥有一个 Person 类,实现一个需要 2 个人(父母)的构造函数,如果他们是同性,则抛出异常,构造染色体(和个体)基因)为这个构造函数内的新人基于父母的随机组合(考虑隐性基因等)。

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.).

远山浅 2024-10-27 18:50:29

这里有一些Octave Code,用于进行类似的遗传模拟研究。 YMMV。

Here is some Octave Code to do similar genetic simulation studies. YMMV.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文