java.lang.Object
com.hexagram2021.chromosomelib.common.gene_locus.GeneLocus
Direct Known Subclasses:
GeneLocus.HomologousGeneLocus, GeneLocus.LeftGeneLocus, GeneLocus.RightGeneLocus

public abstract class GeneLocus extends Object
  • Field Details

    • chromosome

      @Internal @Nullable public net.minecraft.core.Holder<Chromosome> chromosome
      The chromosome that this locus belongs to.
    • genes

      @Internal @Nullable public net.minecraft.core.HolderSet<Gene> genes
      The allele located at this locus.
    • possibilityOfMutation

      public final double possibilityOfMutation
      The possibility of this locus to mutate.
    • possibilityOfCrossingOver

      public final double possibilityOfCrossingOver
      The possibility of this locus to cross over.
  • Constructor Details

    • GeneLocus

      protected GeneLocus(double possibilityOfMutation, double possibilityOfCrossingOver)
  • Method Details

    • index

      public abstract int index(ChromosomeType chromosomeType)
      Parameters:
      chromosomeType - left or right.
    • left

      public static GeneLocus.LeftGeneLocus left(int index, double possibilityOfMutation, double possibilityOfCrossingOver)
      Create a gene locus only in the left chromosome (e.g. X sex chromosome, Z sex chromosome).
      Parameters:
      index - the index of this locus in the chromosome.
      possibilityOfMutation - the possibility of this locus to mutate.
      possibilityOfCrossingOver - the possibility of this locus to cross over.
      Returns:
      the gene locus.
    • right

      public static GeneLocus.RightGeneLocus right(int index, double possibilityOfMutation, double possibilityOfCrossingOver)
      Create a gene locus only in the right chromosome (e.g. Y sex chromosome, W sex chromosome).
      Parameters:
      index - the index of this locus in the chromosome.
      possibilityOfMutation - the possibility of this locus to mutate.
      possibilityOfCrossingOver - the possibility of this locus to cross over.
      Returns:
      the gene locus.
    • homologous

      public static GeneLocus.HomologousGeneLocus homologous(int index, double possibilityOfMutation, double possibilityOfCrossingOver)
      Create a gene locus that is homologous to both chromosomes (e.g. most autosomes).
      Parameters:
      index - the index of this locus in the chromosome.
      possibilityOfMutation - the possibility of this locus to mutate.
      possibilityOfCrossingOver - the possibility of this locus to cross over.
      Returns:
      the gene locus.
    • homologous

      public static GeneLocus.HomologousGeneLocus homologous(int leftIndex, int rightIndex, double possibilityOfMutation, double possibilityOfCrossingOver)
      Create a gene locus that is homologous to both chromosomes, but is at different position of them (e.g. homologous segments of sex chromosomes).
      Parameters:
      leftIndex - the left index of this locus in the chromosome.
      rightIndex - the right index of this locus in the chromosome.
      possibilityOfMutation - the possibility of this locus to mutate.
      possibilityOfCrossingOver - the possibility of this locus to cross over.
      Returns:
      the gene locus.
    • setGeneFrequency

      @Internal public static void setGeneFrequency(Map<net.minecraft.core.Holder<GeneLocus>,IWeightedGeneList> geneFrequency)
    • getRandomGene

      public static net.minecraft.core.Holder<Gene> getRandomGene(net.minecraft.core.Holder<GeneLocus> geneLocus, IWeightedGeneList.Context context)
      Get a random gene from the gene locus.
      Parameters:
      geneLocus - the gene locus.
      Returns:
      a random gene from the gene locus.