use of com.milaboratory.core.io.sequence.PairedRead in project mixcr by milaboratory.
the class PartialAlignmentsAssemblerTest method test1.
// @Test
// public void testMaxAllele() throws Exception {
// final LociLibrary ll = LociLibraryManager.getDefault().getLibrary("mi");
// final Locus locus = Locus.TRB;
//
// for (GeneFeature feature : new GeneFeature[]{VRegionWithP, DRegion, JRegionWithP, CRegion}) {
// Allele maxAllele = null;
// for (Allele allele : ll.getAllAlleles()) {
// if (allele.getLocusContainer().getSpeciesAndLocus().taxonId != Species.HomoSapiens)
// continue;
// if (!allele.isFunctional())
// continue;
// if (allele.getLocus() != locus)
// continue;
// if (maxAllele == null && allele.getFeature(feature) != null)
// maxAllele = allele;
// if (allele.getFeature(feature) != null && allele.getFeature(feature).size() > maxAllele.getFeature(feature).size())
// maxAllele = allele;
// }
//
// System.out.println(maxAllele.getName() + " Size: " + maxAllele.getFeature(feature).size());
// }
// }
@Test
public void test1() throws Exception {
final InputTestData input = createTestData();
final NucleotideSequence reference = input.reference;
final EnumMap<GeneType, int[]> refPositions = input.refPositions;
PairedRead[] data = { createPair(0, reference.getRange(refPositions.get(Variable)[1] - 85, refPositions.get(Variable)[1] + 15), reference.getRange(refPositions.get(Joining)[1] - 20, refPositions.get(Joining)[1] + 80).getReverseComplement()), createPair(1, reference.getRange(refPositions.get(Variable)[1] - 186, refPositions.get(Variable)[1] - 86), reference.getRange(refPositions.get(Variable)[1] - 10, refPositions.get(Variable)[1] + 102).getReverseComplement()) };
final TestResult testResult = processData(data, input);
for (VDJCAlignments al : testResult.assembled) {
MiXCRTestUtils.printAlignment(al);
}
}
use of com.milaboratory.core.io.sequence.PairedRead in project mixcr by milaboratory.
the class RunMiXCRTest method test3.
@Ignore
@Test
public void test3() throws Exception {
RunMiXCR.RunMiXCRAnalysis params = new RunMiXCR.RunMiXCRAnalysis("/Users/poslavsky/Projects/milab/temp/R1_part.fastq.gz", "/Users/poslavsky/Projects/milab/temp/R2_part.fastq.gz");
RunMiXCR.AlignResult align = RunMiXCR.align(params);
List<PairedRead> reads = new ArrayList<>();
try (PairedFastqReader fReader = new PairedFastqReader("/Users/poslavsky/Projects/milab/temp/R1_part.fastq.gz", "/Users/poslavsky/Projects/milab/temp/R2_part.fastq.gz", true)) {
for (PairedRead s : CUtils.it(fReader)) reads.add(s);
}
File tempFile = TempFileManager.getTempFile();
try (VDJCAlignmentsWriter writer = new VDJCAlignmentsWriter(tempFile)) {
writer.header(align.aligner);
for (VDJCAlignments alignment : align.alignments) writer.write(alignment);
}
try (VDJCAlignmentsReader reader = new VDJCAlignmentsReader(tempFile)) {
int tr = 0;
for (VDJCAlignments alignment : CUtils.it(reader)) {
PairedRead actual = reads.get((int) alignment.getMinReadId());
++tr;
Assert.assertEquals(actual, alignment.getOriginalReads().get(0));
}
System.out.println(tr);
}
}
use of com.milaboratory.core.io.sequence.PairedRead 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);
// }
}
Aggregations