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);
}
}
Aggregations