Search in sources :

Example 21 with VDJCHit

use of com.milaboratory.mixcr.basictypes.VDJCHit in project mixcr by milaboratory.

the class MiXCRTestUtils method assertAlignments.

public static void assertAlignments(VDJCAlignments alignments) {
    for (GeneType gt : GeneType.VDJC_REFERENCE) {
        for (VDJCHit hit : alignments.getHits(gt)) {
            for (int targetIndex = 0; targetIndex < alignments.numberOfTargets(); targetIndex++) {
                Alignment<NucleotideSequence> al = hit.getAlignment(targetIndex);
                if (al == null)
                    continue;
                NucleotideSequence sequence = alignments.getTarget(targetIndex).getSequence();
                AlignerTest.assertAlignment(al, sequence);
            }
        }
    }
}
Also used : NucleotideSequence(com.milaboratory.core.sequence.NucleotideSequence) GeneType(io.repseq.core.GeneType) VDJCHit(com.milaboratory.mixcr.basictypes.VDJCHit)

Example 22 with VDJCHit

use of com.milaboratory.mixcr.basictypes.VDJCHit in project mixcr by milaboratory.

the class VDJCAlignerPVFirstTest method test1.

@Test
public void test1() throws Exception {
    VDJCAlignerParameters parameters = VDJCParametersPresets.getByName("default");
    ByteArrayOutputStream bos = new ByteArrayOutputStream();
    List<VDJCAlignments> alignemntsList = new ArrayList<>();
    int header;
    int total = 0;
    int leftHit = 0;
    try (PairedFastqReader reader = new PairedFastqReader(VDJCAlignerSTest.class.getClassLoader().getResourceAsStream("sequences/sample_IGH_R1.fastq"), VDJCAlignerSTest.class.getClassLoader().getResourceAsStream("sequences/sample_IGH_R2.fastq"), true)) {
        VDJCAlignerPVFirst aligner = new VDJCAlignerPVFirst(parameters);
        for (VDJCGene gene : VDJCLibraryRegistry.getDefault().getLibrary("default", "hs").getGenes(Chains.IGH)) {
            if (parameters.containsRequiredFeature(gene))
                aligner.addGene(gene);
        }
        for (PairedRead read : CUtils.it(reader)) {
            ++total;
            VDJCAlignmentResult<PairedRead> result = aligner.process(read);
            if (result.alignment != null) {
                alignemntsList.add(result.alignment);
                for (VDJCHit hit : result.alignment.getHits(GeneType.Variable)) if (hit.getAlignment(0) != null && hit.getAlignment(1) != null)
                    ++leftHit;
            }
        }
    }
    System.out.println(alignemntsList.size());
    System.out.println(total);
    System.out.println(leftHit);
    Assert.assertTrue(alignemntsList.size() > 10);
    int k = 10;
    for (VDJCAlignments alignments : alignemntsList) {
        for (int target = 0; target < alignments.numberOfTargets(); target++) {
            MultiAlignmentHelper helperBig = VDJCAlignmentsFormatter.getTargetAsMultiAlignment(alignments, target);
            if (helperBig == null)
                continue;
            for (MultiAlignmentHelper helper : helperBig.split(80)) {
                System.out.println(helper);
                System.out.println();
                if (--k < 0)
                    return;
            }
        }
    }
// System.out.println("Bytes per alignment: " + (bos.size() - header) / alignemntsList.size());
// 
// try (VDJCAlignmentsReader reader = new VDJCAlignmentsReader(new ByteArrayInputStream(bos.toByteArray()), ll)) {
// int i = 0;
// for (VDJCAlignments alignments : CUtils.it(reader))
// Assert.assertEquals(alignemntsList.get(i++), alignments);
// }
}
Also used : MultiAlignmentHelper(com.milaboratory.core.alignment.MultiAlignmentHelper) ArrayList(java.util.ArrayList) ByteArrayOutputStream(java.io.ByteArrayOutputStream) PairedRead(com.milaboratory.core.io.sequence.PairedRead) VDJCGene(io.repseq.core.VDJCGene) VDJCAlignments(com.milaboratory.mixcr.basictypes.VDJCAlignments) PairedFastqReader(com.milaboratory.core.io.sequence.fastq.PairedFastqReader) VDJCHit(com.milaboratory.mixcr.basictypes.VDJCHit) Test(org.junit.Test)

Aggregations

VDJCHit (com.milaboratory.mixcr.basictypes.VDJCHit)22 NucleotideSequence (com.milaboratory.core.sequence.NucleotideSequence)8 VDJCAlignments (com.milaboratory.mixcr.basictypes.VDJCAlignments)8 GeneType (io.repseq.core.GeneType)7 VDJCGene (io.repseq.core.VDJCGene)7 Range (com.milaboratory.core.Range)4 ArrayList (java.util.ArrayList)4 Alignment (com.milaboratory.core.alignment.Alignment)3 NSequenceWithQuality (com.milaboratory.core.sequence.NSequenceWithQuality)3 Clone (com.milaboratory.mixcr.basictypes.Clone)3 ReferencePoint (io.repseq.core.ReferencePoint)3 VDJCGeneId (io.repseq.core.VDJCGeneId)3 PairedRead (com.milaboratory.core.io.sequence.PairedRead)2 PairedFastqReader (com.milaboratory.core.io.sequence.fastq.PairedFastqReader)2 VDJCPartitionedSequence (com.milaboratory.mixcr.basictypes.VDJCPartitionedSequence)2 VDJCAlignerParameters (com.milaboratory.mixcr.vdjaligners.VDJCAlignerParameters)2 Chains (io.repseq.core.Chains)2 GeneFeature (io.repseq.core.GeneFeature)2 Test (org.junit.Test)2 CUtils (cc.redberry.pipe.CUtils)1