Search in sources :

Example 1 with DTrimming

use of io.repseq.gen.DTrimming in project repseqio by repseqio.

the class CommonNormalDTrimmingModel method create.

@Override
public DTrimmingGenerator create(RandomGenerator random, VDJCGene gene) {
    final int dLength = gene.getPartitioning().getLength(GeneFeature.DRegion);
    final EnumeratedIntegerDistribution dist3 = parameters3.truncatedDistribution(random, -dLength, Math.min(dLength, maxPLength3));
    final EnumeratedIntegerDistribution dist5 = parameters5.truncatedDistribution(random, -dLength, Math.min(dLength, maxPLength5));
    return new DTrimmingGenerator() {

        @Override
        public DTrimming sample() {
            int trimming3 = dist3.sample();
            int trimming5 = dist5.sample();
            if (trimming3 + trimming5 < -dLength) {
                int excess = dLength - trimming3 - trimming5;
                trimming3 += excess / 2;
                trimming5 += excess - (excess / 2);
            }
            return new DTrimming(trimming3, trimming5);
        }
    };
}
Also used : EnumeratedIntegerDistribution(org.apache.commons.math3.distribution.EnumeratedIntegerDistribution) DTrimming(io.repseq.gen.DTrimming)

Aggregations

DTrimming (io.repseq.gen.DTrimming)1 EnumeratedIntegerDistribution (org.apache.commons.math3.distribution.EnumeratedIntegerDistribution)1