Search in sources :

Example 1 with VDJCMultiRead

use of com.milaboratory.mixcr.partialassembler.VDJCMultiRead in project mixcr by milaboratory.

the class VDJCObjectExtenderTest method testTripleRead.

@Test
public void testTripleRead() throws Exception {
    final boolean print = true;
    Well44497b rg = new Well44497b(12312);
    final VDJCAlignerParameters rnaSeqParams = VDJCParametersPresets.getByName("rna-seq");
    final PartialAlignmentsAssemblerAligner aligner = new PartialAlignmentsAssemblerAligner(rnaSeqParams);
    final VDJCLibrary lib = VDJCLibraryRegistry.getDefault().getLibrary("default", "hs");
    for (VDJCGene gene : VDJCLibraryRegistry.getDefault().getLibrary("default", "hs").getGenes()) if (gene.isFunctional())
        aligner.addGene(gene);
    TargetBuilder.VDJCGenes genes = new TargetBuilder.VDJCGenes(lib, "TRBV12-3*00", "TRBD1*00", "TRBJ1-3*00", "TRBC2*00");
    // | 310  | 338   | 438
    // 250V + 60CDR3 (20V 7N 10D 3N 20J) + 28J + 100C + 100N
    final NucleotideSequence baseSeq = TargetBuilder.generateSequence(genes, "{CDR3Begin(-250)}V*270 NNNNNNN {DBegin(0)}D*10 NNN {CDR3End(-20):FR4End} {CBegin}C*100 N*100", rg);
    F4 goAssert = new F4() {

        @Override
        public VDJCAlignments go(int len, int offset1, int offset2, int offset3) {
            NucleotideSequence seq1 = baseSeq.getRange(offset1, offset1 + len);
            NucleotideSequence seq2 = baseSeq.getRange(offset2, offset2 + len);
            NucleotideSequence seq3 = offset3 == -1 ? null : baseSeq.getRange(offset3, offset3 + len);
            VDJCAlignmentResult<VDJCMultiRead> alignment = offset3 == -1 ? aligner.process(MiXCRTestUtils.createMultiRead(seq1, seq2)) : aligner.process(MiXCRTestUtils.createMultiRead(seq1, seq2, seq3));
            VDJCAlignments al = alignment.alignment;
            Assert.assertNotNull(al);
            VDJCObjectExtender<VDJCAlignments> extender = new VDJCObjectExtender<>(Chains.TCR, (byte) 35, rnaSeqParams.getVAlignerParameters().getParameters().getScoring(), rnaSeqParams.getJAlignerParameters().getParameters().getScoring(), 100, 70, ReferencePoint.CDR3Begin, ReferencePoint.CDR3End);
            MiXCRTestUtils.assertAlignments(al);
            if (print) {
                MiXCRTestUtils.printAlignment(al);
                System.out.println();
                System.out.println("-------------------------------------------");
                System.out.println();
            }
            VDJCAlignments processed = extender.process(al);
            if (print) {
                MiXCRTestUtils.printAlignment(processed);
                System.out.println();
                System.out.println("===========================================");
                System.out.println();
                System.out.println();
            }
            MiXCRTestUtils.assertAlignments(processed);
            Assert.assertEquals(al.getFeature(GeneFeature.VDJunction), processed.getFeature(GeneFeature.VDJunction));
            Assert.assertEquals(al.getFeature(GeneFeature.DJJunction), processed.getFeature(GeneFeature.DJJunction));
            Assert.assertEquals(al.getFeature(GeneFeature.VJJunction), processed.getFeature(GeneFeature.VJJunction));
            return processed;
        }
    };
    VDJCAlignments a1 = goAssert.go(60, 245, 307, 450);
    Assert.assertEquals(2, a1.numberOfTargets());
    VDJCAlignments a2 = goAssert.go(60, 245, 315, 450);
    Assert.assertEquals(3, a2.numberOfTargets());
    VDJCAlignments a3 = goAssert.go(60, 245, 315, -1);
    Assert.assertEquals(2, a3.numberOfTargets());
    VDJCAlignments a4 = goAssert.go(60, 245, 307, -1);
    Assert.assertEquals(1, a4.numberOfTargets());
    VDJCAlignments a5 = goAssert.go(53, 252, 307, -1);
    Assert.assertEquals(1, a5.numberOfTargets());
    VDJCAlignments a6 = goAssert.go(53, 252, 307, 450);
    Assert.assertEquals(2, a6.numberOfTargets());
}
Also used : VDJCMultiRead(com.milaboratory.mixcr.partialassembler.VDJCMultiRead) VDJCAlignerParameters(com.milaboratory.mixcr.vdjaligners.VDJCAlignerParameters) PartialAlignmentsAssemblerAligner(com.milaboratory.mixcr.partialassembler.PartialAlignmentsAssemblerAligner) NucleotideSequence(com.milaboratory.core.sequence.NucleotideSequence) Well44497b(org.apache.commons.math3.random.Well44497b) TargetBuilder(com.milaboratory.mixcr.tests.TargetBuilder) VDJCAlignments(com.milaboratory.mixcr.basictypes.VDJCAlignments) Test(org.junit.Test)

Example 2 with VDJCMultiRead

use of com.milaboratory.mixcr.partialassembler.VDJCMultiRead in project mixcr by milaboratory.

the class FieldExtractorsTest method testAnchorPoints1.

@Test
public void testAnchorPoints1() throws Exception {
    final boolean print = false;
    final Well44497b rg = new Well44497b(12312);
    final VDJCAlignerParameters rnaSeqParams = VDJCParametersPresets.getByName("rna-seq");
    final PartialAlignmentsAssemblerAligner aligner = new PartialAlignmentsAssemblerAligner(rnaSeqParams);
    final VDJCLibrary lib = VDJCLibraryRegistry.getDefault().getLibrary("default", "hs");
    for (VDJCGene gene : VDJCLibraryRegistry.getDefault().getLibrary("default", "hs").getGenes()) if (gene.isFunctional())
        aligner.addGene(gene);
    final TargetBuilder.VDJCGenes genes = new TargetBuilder.VDJCGenes(lib, "TRBV12-3*00", "TRBD1*00", "TRBJ1-3*00", "TRBC2*00");
    // | 310  | 338   | 438
    // 250V + 60CDR3 (20V 7N 10D 3N 20J) + 28J + 100C + 100N
    // "{CDR3Begin(-250)}V*270 NNNNNNN {DBegin(0)}D*10 NNN {CDR3End(-20):FR4End} {CBegin}C*100 N*100"
    final FieldExtractors.ExtractDefaultReferencePointsPositions extractor = new FieldExtractors.ExtractDefaultReferencePointsPositions();
    F6 goAssert = new F6() {

        @Override
        public Integer[][] go(String seq, int len, int offset1, int offset2, int offset3, String expected) {
            final NucleotideSequence baseSeq = TargetBuilder.generateSequence(genes, seq, rg);
            NucleotideSequence seq1 = baseSeq.getRange(offset1, Math.min(baseSeq.size(), offset1 + len));
            NucleotideSequence seq2 = offset2 == -1 ? null : baseSeq.getRange(offset2, Math.min(baseSeq.size(), offset2 + len));
            NucleotideSequence seq3 = offset3 == -1 ? null : baseSeq.getRange(offset3, Math.min(baseSeq.size(), offset3 + len));
            VDJCAlignmentResult<VDJCMultiRead> alignment = offset3 == -1 ? offset2 == -1 ? aligner.process(MiXCRTestUtils.createMultiRead(seq1)) : aligner.process(MiXCRTestUtils.createMultiRead(seq1, seq2)) : aligner.process(MiXCRTestUtils.createMultiRead(seq1, seq2, seq3));
            VDJCAlignments al = alignment.alignment;
            Assert.assertNotNull(al);
            if (print) {
                MiXCRTestUtils.printAlignment(al);
                System.out.println();
                System.out.println("-------------------------------------------");
                System.out.println();
            }
            String val = extractor.extract(al);
            if (print)
                System.out.println(val);
            String[] spl = val.split(",");
            Integer[][] result = new Integer[spl.length][ReferencePoint.DefaultReferencePoints.length];
            for (int i = 0; i < spl.length; i++) {
                String[] spl1 = spl[i].split(":");
                for (int j = 0; j < spl1.length; j++) {
                    try {
                        result[i][j] = Integer.decode(spl1[j]);
                    } catch (NumberFormatException e) {
                    }
                }
            }
            return result;
        }
    };
    // No PSegments, just deletions
    Integer[][] r = goAssert.go("{CDR3Begin(-250):VEnd(-3)} 'CCAAA' {DBegin(0):DEnd(0)} 'AAA' {JBegin(2):FR4End} " + "{CBegin}C*100 N*100", 100, 240, 307, 450, "");
    assertExportPoint(r[0], ReferencePoint.VEnd, -3);
    assertExportPoint(r[0], ReferencePoint.DBegin, 0);
    assertExportPoint(r[0], ReferencePoint.DEnd, 0);
    assertExportPoint(r[0], ReferencePoint.JBegin, -2);
    r = goAssert.go("{CDR3Begin(-250):VEnd(0)} 'CCAAA' {DBegin(0):DEnd(-2)} 'AAA' {JBegin:FR4End} {CBegin}C*100 N*100", 100, 240, 307, 450, "");
    assertExportPoint(r[0], ReferencePoint.VEnd, 0);
    assertExportPoint(r[0], ReferencePoint.DBegin, 0);
    assertExportPoint(r[0], ReferencePoint.DEnd, -2);
    assertExportPoint(r[0], ReferencePoint.JBegin, 0);
    // With PSegments
    r = goAssert.go("{CDR3Begin(-250):VEnd(0)} {VEnd:VEnd(-3)} 'CCAAA' {DBegin(3):DBegin} {DBegin:DEnd(-2)} 'AAA' " + "{JBegin(2):JBegin} {JBegin:FR4End} {CBegin}C*100 N*100", 100, 240, 307, 450, "");
    assertExportPoint(r[0], ReferencePoint.VEnd, 3);
    assertExportPoint(r[0], ReferencePoint.DBegin, 3);
    assertExportPoint(r[0], ReferencePoint.DEnd, -2);
    assertExportPoint(r[0], ReferencePoint.JBegin, 2);
}
Also used : VDJCMultiRead(com.milaboratory.mixcr.partialassembler.VDJCMultiRead) VDJCAlignerParameters(com.milaboratory.mixcr.vdjaligners.VDJCAlignerParameters) PartialAlignmentsAssemblerAligner(com.milaboratory.mixcr.partialassembler.PartialAlignmentsAssemblerAligner) NucleotideSequence(com.milaboratory.core.sequence.NucleotideSequence) Well44497b(org.apache.commons.math3.random.Well44497b) TargetBuilder(com.milaboratory.mixcr.tests.TargetBuilder) VDJCAlignments(com.milaboratory.mixcr.basictypes.VDJCAlignments) Test(org.junit.Test)

Aggregations

NucleotideSequence (com.milaboratory.core.sequence.NucleotideSequence)2 VDJCAlignments (com.milaboratory.mixcr.basictypes.VDJCAlignments)2 PartialAlignmentsAssemblerAligner (com.milaboratory.mixcr.partialassembler.PartialAlignmentsAssemblerAligner)2 VDJCMultiRead (com.milaboratory.mixcr.partialassembler.VDJCMultiRead)2 TargetBuilder (com.milaboratory.mixcr.tests.TargetBuilder)2 VDJCAlignerParameters (com.milaboratory.mixcr.vdjaligners.VDJCAlignerParameters)2 Well44497b (org.apache.commons.math3.random.Well44497b)2 Test (org.junit.Test)2