Search in sources :

Example 1 with VDJCGenes

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

the class IndependentVDJTrimmingModel method create.

@Override
public VDJTrimmingGenerator create(RandomGenerator random, List<VDJCGene> vGenes, List<VDJCGene> dGenes, List<VDJCGene> jGenes, List<VDJCGene> cGenes) {
    final Map<VDJCGene, GeneTrimmingGenerator> vGenerators = new HashMap<>();
    final Map<VDJCGene, DTrimmingGenerator> dGenerators = new HashMap<>();
    final Map<VDJCGene, GeneTrimmingGenerator> jGenerators = new HashMap<>();
    for (VDJCGene gene : vGenes) vGenerators.put(gene, v.create(random, gene));
    for (VDJCGene gene : dGenes) dGenerators.put(gene, d.create(random, gene));
    for (VDJCGene gene : jGenes) jGenerators.put(gene, j.create(random, gene));
    return new VDJTrimmingGenerator() {

        @Override
        public VDJTrimming sample(VDJCGenes genes) {
            if (genes.d == null)
                return new VDJTrimming(vGenerators.get(genes.v).sample(), jGenerators.get(genes.j).sample());
            else
                return new VDJTrimming(vGenerators.get(genes.v).sample(), jGenerators.get(genes.j).sample(), dGenerators.get(genes.d).sample());
        }
    };
}
Also used : VDJCGenes(io.repseq.gen.VDJCGenes) VDJTrimming(io.repseq.gen.VDJTrimming) HashMap(java.util.HashMap) VDJCGene(io.repseq.core.VDJCGene)

Example 2 with VDJCGenes

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

the class BasicGGeneModel method create.

@Override
public GGeneGenerator create(RandomGenerator random, VDJCLibrary library) {
    final VDJCGenesGenerator vdjcGenesGenerator = vdjcGenesModel.create(random, library);
    List<VDJCGene> vGenes = vdjcGenesGenerator.genes(GeneType.Variable);
    List<VDJCGene> dGenes = vdjcGenesGenerator.genes(GeneType.Diversity);
    List<VDJCGene> jGenes = vdjcGenesGenerator.genes(GeneType.Joining);
    List<VDJCGene> cGenes = vdjcGenesGenerator.genes(GeneType.Constant);
    final VDJTrimmingGenerator trimmingGenerator = trimmingModel.create(random, vGenes, dGenes, jGenes, cGenes);
    final InsertGenerator vInsertGenerator = vInsertModel.create(random, true, vGenes, dGenes, jGenes, cGenes);
    final InsertGenerator djInsertGenerator = dGenes.isEmpty() ? null : djInsertModel.create(random, false, vGenes, dGenes, jGenes, cGenes);
    return new GGeneGenerator() {

        @Override
        public GGene generate() {
            VDJCGenes vdjcGenes = vdjcGenesGenerator.sample();
            VDJTrimming trimming = trimmingGenerator.sample(vdjcGenes);
            assert !vdjcGenes.isDDefined() || (vdjcGenes.isDDefined() && djInsertGenerator != null);
            NucleotideSequence vInsert;
            NucleotideSequence djInsert;
            if (vdjcGenes.isDDefined()) {
                assert djInsertGenerator != null;
                GGene tempGene = new GGene(null, vdjcGenes, trimming, NucleotideSequence.EMPTY, NucleotideSequence.EMPTY);
                vInsert = vInsertGenerator.generate(tempGene);
                djInsert = djInsertGenerator.generate(tempGene);
            } else {
                GGene tempGene = new GGene(null, vdjcGenes, trimming, NucleotideSequence.EMPTY, null);
                vInsert = vInsertGenerator.generate(tempGene);
                djInsert = null;
            }
            return new GGene(null, vdjcGenes, trimming, vInsert, djInsert);
        }
    };
}
Also used : VDJCGenes(io.repseq.gen.VDJCGenes) VDJTrimming(io.repseq.gen.VDJTrimming) GGene(io.repseq.gen.GGene) NucleotideSequence(com.milaboratory.core.sequence.NucleotideSequence) VDJCGene(io.repseq.core.VDJCGene)

Aggregations

VDJCGene (io.repseq.core.VDJCGene)2 VDJCGenes (io.repseq.gen.VDJCGenes)2 VDJTrimming (io.repseq.gen.VDJTrimming)2 NucleotideSequence (com.milaboratory.core.sequence.NucleotideSequence)1 GGene (io.repseq.gen.GGene)1 HashMap (java.util.HashMap)1