Search in sources :

Example 1 with AlignerReport

use of com.milaboratory.mixcr.cli.AlignerReport in project mixcr by milaboratory.

the class RunMiXCR method align.

public static AlignResult align(RunMiXCRAnalysis parameters) throws Exception {
    VDJCAlignerParameters alignerParameters = parameters.alignerParameters;
    VDJCAligner aligner = VDJCAligner.createAligner(alignerParameters, parameters.isInputPaired(), alignerParameters.getMergerParameters() != null);
    List<VDJCGene> genes = new ArrayList<>();
    for (VDJCGene gene : VDJCLibraryRegistry.getDefault().getLibrary(parameters.library, parameters.species).getGenes(parameters.chains)) if (alignerParameters.containsRequiredFeature(gene) && (gene.isFunctional() || !parameters.isFunctionalOnly)) {
        genes.add(gene);
        aligner.addGene(gene);
    }
    AlignerReport report = new AlignerReport();
    aligner.setEventsListener(report);
    try (SequenceReaderCloseable<? extends SequenceRead> reader = parameters.getReader()) {
        // start progress reporting
        if (reader instanceof CanReportProgress)
            SmartProgressReporter.startProgressReport("align", (CanReportProgress) reader);
        OutputPort<Chunk<SequenceRead>> mainInputReads = CUtils.buffered((OutputPort) chunked(reader, 64), 16);
        OutputPort<VDJCAlignmentResult> alignments = unchunked(new ParallelProcessor(mainInputReads, chunked(aligner), parameters.threads));
        List<VDJCAlignments> als = new ArrayList<>();
        int ind = 0;
        for (VDJCAlignmentResult t : CUtils.it(new OrderedOutputPort<>(alignments, new Indexer<VDJCAlignmentResult>() {

            @Override
            public long getIndex(VDJCAlignmentResult r) {
                return r.read.getId();
            }
        }))) {
            if (t.alignment != null) {
                t.alignment.setAlignmentsIndex(ind++);
                als.add(t.alignment);
            }
        }
        return new AlignResult(parameters, reader.getNumberOfReads(), report, als, genes, aligner);
    }
}
Also used : AlignerReport(com.milaboratory.mixcr.cli.AlignerReport) VDJCAlignerParameters(com.milaboratory.mixcr.vdjaligners.VDJCAlignerParameters) ArrayList(java.util.ArrayList) VDJCAlignmentResult(com.milaboratory.mixcr.vdjaligners.VDJCAlignmentResult) Chunk(cc.redberry.pipe.util.Chunk) VDJCAligner(com.milaboratory.mixcr.vdjaligners.VDJCAligner) ParallelProcessor(cc.redberry.pipe.blocks.ParallelProcessor) Indexer(cc.redberry.pipe.util.Indexer) CanReportProgress(com.milaboratory.util.CanReportProgress) VDJCGene(io.repseq.core.VDJCGene) VDJCAlignments(com.milaboratory.mixcr.basictypes.VDJCAlignments)

Aggregations

ParallelProcessor (cc.redberry.pipe.blocks.ParallelProcessor)1 Chunk (cc.redberry.pipe.util.Chunk)1 Indexer (cc.redberry.pipe.util.Indexer)1 VDJCAlignments (com.milaboratory.mixcr.basictypes.VDJCAlignments)1 AlignerReport (com.milaboratory.mixcr.cli.AlignerReport)1 VDJCAligner (com.milaboratory.mixcr.vdjaligners.VDJCAligner)1 VDJCAlignerParameters (com.milaboratory.mixcr.vdjaligners.VDJCAlignerParameters)1 VDJCAlignmentResult (com.milaboratory.mixcr.vdjaligners.VDJCAlignmentResult)1 CanReportProgress (com.milaboratory.util.CanReportProgress)1 VDJCGene (io.repseq.core.VDJCGene)1 ArrayList (java.util.ArrayList)1