use of com.milaboratory.core.alignment.LinearGapAlignmentScoring in project mixcr by milaboratory.
the class JsonOverriderTest method test1.
@Test
public void test1() throws Exception {
KAlignerParameters parameters = KAlignerParameters.getByName("default");
KAlignerParameters override = JsonOverrider.override(parameters, KAlignerParameters.class, "floatingLeftBound=true", "scoring.subsMatrix=simple(match=4,mismatch=-9)");
KAlignerParameters expected = parameters.clone().setFloatingLeftBound(true).setScoring(new LinearGapAlignmentScoring(NucleotideSequence.ALPHABET, 4, -9, parameters.getScoring().getGapPenalty()));
Assert.assertEquals(expected, override);
}
use of com.milaboratory.core.alignment.LinearGapAlignmentScoring in project mixcr by milaboratory.
the class JsonOverriderTest method test2.
@Test
public void test2() throws Exception {
KAlignerParameters parameters = KAlignerParameters.getByName("default");
KAlignerParameters override = JsonOverrider.override(parameters, KAlignerParameters.class, "floatingLeftBound=true", "subsMatrix=simple(match=4,mismatch=-9)");
KAlignerParameters expected = parameters.clone().setFloatingLeftBound(true).setScoring(new LinearGapAlignmentScoring(NucleotideSequence.ALPHABET, 4, -9, parameters.getScoring().getGapPenalty()));
Assert.assertEquals(expected, override);
}
use of com.milaboratory.core.alignment.LinearGapAlignmentScoring in project mixcr by milaboratory.
the class CloneAssemblerRunnerTest method runFullPipeline.
private static CloneSet runFullPipeline(String... fastqFiles) throws IOException, InterruptedException {
// building alignments
VDJCAlignerParameters alignerParameters = VDJCParametersPresets.getByName("default");
VDJCAligner aligner = fastqFiles.length == 1 ? new VDJCAlignerS(alignerParameters) : new VDJCAlignerWithMerge(alignerParameters);
for (VDJCGene gene : VDJCLibraryRegistry.getDefault().getLibrary("mi", "hs").getGenes(Chains.IGH)) if (alignerParameters.containsRequiredFeature(gene))
aligner.addGene(gene);
SequenceReader reader;
if (fastqFiles.length == 1)
reader = new SingleFastqReader(CloneAssemblerRunnerTest.class.getClassLoader().getResourceAsStream(fastqFiles[0]), true);
else
reader = new PairedFastqReader(CloneAssemblerRunnerTest.class.getClassLoader().getResourceAsStream(fastqFiles[0]), CloneAssemblerRunnerTest.class.getClassLoader().getResourceAsStream(fastqFiles[1]), true);
// write alignments to byte array
ByteArrayOutputStream alignmentsSerialized = new ByteArrayOutputStream();
try (VDJCAlignmentsWriter writer = new VDJCAlignmentsWriter(alignmentsSerialized)) {
writer.header(aligner);
for (Object read : CUtils.it(reader)) {
VDJCAlignmentResult result = (VDJCAlignmentResult) aligner.process((SequenceRead) read);
if (result.alignment != null)
writer.write(result.alignment);
}
}
AlignmentsProvider alignmentsProvider = AlignmentsProvider.Util.createProvider(alignmentsSerialized.toByteArray(), VDJCLibraryRegistry.getDefault());
LinearGapAlignmentScoring<NucleotideSequence> scoring = new LinearGapAlignmentScoring<>(NucleotideSequence.ALPHABET, 5, -9, -12);
CloneFactoryParameters factoryParameters = new CloneFactoryParameters(new VJCClonalAlignerParameters(0.8f, scoring, 5), new VJCClonalAlignerParameters(0.8f, scoring, 5), null, new DAlignerParameters(GeneFeature.DRegion, 0.85f, 30.0f, 3, scoring));
CloneAssemblerParameters assemblerParameters = new CloneAssemblerParameters(new GeneFeature[] { GeneFeature.CDR3 }, 12, QualityAggregationType.Average, new CloneClusteringParameters(2, 1, TreeSearchParameters.ONE_MISMATCH, new RelativeConcentrationFilter(1.0E-6)), factoryParameters, true, true, false, 0.4, true, (byte) 20, .8, "2 of 6", (byte) 15);
System.out.println(GlobalObjectMappers.toOneLine(assemblerParameters));
CloneAssemblerRunner assemblerRunner = new CloneAssemblerRunner(alignmentsProvider, new CloneAssembler(assemblerParameters, true, aligner.getUsedGenes(), alignerParameters), 2);
SmartProgressReporter.startProgressReport(assemblerRunner);
assemblerRunner.run();
CloneSet cloneSet = assemblerRunner.getCloneSet(null);
ByteArrayOutputStream bos = new ByteArrayOutputStream();
CloneSetIO.write(cloneSet, bos);
CloneSet cloneSetDeserialized = CloneSetIO.readClns(new ByteArrayInputStream(bos.toByteArray()));
assertCSEquals(cloneSet, cloneSetDeserialized);
OutputPortCloseable<ReadToCloneMapping> rrr = assemblerRunner.assembler.getAssembledReadsPort();
ReadToCloneMapping take;
while ((take = rrr.take()) != null) System.out.println(take);
return cloneSet;
}
use of com.milaboratory.core.alignment.LinearGapAlignmentScoring in project mixcr by milaboratory.
the class MergerTest method mAssert.
public static void mAssert(String originalSeq, String seq1, String seq2, String expectedSequence, String expectedQuality) {
NucleotideSequence originalSequence = new NucleotideSequence(originalSeq);
NSequenceWithQuality target1 = new NSequenceWithQuality(seq1, lets('A', seq1.length()));
NSequenceWithQuality target2 = new NSequenceWithQuality(seq2, lets('B', seq2.length()));
LinearGapAlignmentScoring<NucleotideSequence> scoring = new LinearGapAlignmentScoring<>(NucleotideSequence.ALPHABET, 4, -5, -9);
Alignment<NucleotideSequence> alignment1 = Aligner.alignLocalLinear(scoring, originalSequence, target1.getSequence());
Alignment<NucleotideSequence> alignment2 = Aligner.alignLocalLinear(scoring, originalSequence, target2.getSequence());
NSequenceWithQuality result = Merger.merge(new Range(0, originalSequence.size()), new Alignment[] { alignment1, alignment2 }, new NSequenceWithQuality[] { target1, target2 });
Assert.assertEquals(expectedSequence, result.getSequence().toString());
Assert.assertEquals(expectedQuality, result.getQuality().toString());
}
use of com.milaboratory.core.alignment.LinearGapAlignmentScoring in project mixcr by milaboratory.
the class JsonOverriderTest method test1a.
@Test
public void test1a() throws Exception {
KAlignerParameters parameters = KAlignerParameters.getByName("default");
KAlignerParameters override = JsonOverrider.override(parameters, KAlignerParameters.class, "floatingLeftBound=true", "scoring.subsMatrix='simple(match=4,mismatch=-9)'");
KAlignerParameters expected = parameters.clone().setFloatingLeftBound(true).setScoring(new LinearGapAlignmentScoring(NucleotideSequence.ALPHABET, 4, -9, parameters.getScoring().getGapPenalty()));
Assert.assertEquals(expected, override);
}
Aggregations