use of com.milaboratory.core.io.sequence.PairedRead in project mixcr by milaboratory.
the class PartialAlignmentsAssemblerTest method test2.
@Test
public void test2() throws Exception {
RandomUtil.reseedThreadLocal(47);
final InputTestData input = createTestData(47);
final NucleotideSequence reference = input.reference;
final EnumMap<GeneType, int[]> refPositions = input.refPositions;
PairedRead[] data = { createPair(0, reference.getRange(refPositions.get(Diversity)[0] - 85, refPositions.get(Diversity)[0] + 10), reference.getRange(refPositions.get(Diversity)[1], refPositions.get(Diversity)[1] + 85).getReverseComplement()), createPair(1, reference.getRange(refPositions.get(Diversity)[0] - 135, refPositions.get(Diversity)[0] - 70), reference.getRange(refPositions.get(Diversity)[0] - 8, refPositions.get(Diversity)[0] + 85).getReverseComplement()) };
final TestResult testResult = processData(data, input);
for (VDJCAlignments al : testResult.assembled) {
MiXCRTestUtils.printAlignment(al);
// System.out.println(input.VJJunction);
// System.out.println(al.getFeature(GeneFeature.VJJunction).getSequence());
Assert.assertTrue(input.VJJunction.toString().contains(al.getFeature(GeneFeature.VJJunction).getSequence().toString()));
}
}
use of com.milaboratory.core.io.sequence.PairedRead in project mixcr by milaboratory.
the class PartialAlignmentsAssemblerTest method test3.
@Test
public void test3() throws Exception {
for (int i = 0; i < 100; i++) {
RandomUtil.reseedThreadLocal(i);
// System.out.println(i);
final InputTestData input = createTestData(i);
final NucleotideSequence reference = input.reference;
final EnumMap<GeneType, int[]> refPositions = input.refPositions;
PairedRead[] data = { createPair(0, reference.getRange(refPositions.get(Diversity)[0] - 85, refPositions.get(Diversity)[0] + 10), reference.getRange(refPositions.get(Diversity)[1], refPositions.get(Diversity)[1] + 85).getReverseComplement()), createPair(1, reference.getRange(refPositions.get(Diversity)[0] - 135, refPositions.get(Diversity)[0] - 70), reference.getRange(refPositions.get(Diversity)[0] - 8, refPositions.get(Diversity)[0] + 85).getReverseComplement()) };
final TestResult testResult = processData(data, input);
for (VDJCAlignments al : testResult.assembled) {
// printAlignment(al);
if (al.numberOfTargets() == 1) {
// System.out.println(input.VJJunction);
// System.out.println(al.getFeature(GeneFeature.VJJunction).getSequence());
Assert.assertTrue(input.VJJunction.toString().contains(al.getFeature(GeneFeature.VJJunction).getSequence().toString()));
}
}
}
}
use of com.milaboratory.core.io.sequence.PairedRead in project mixcr by milaboratory.
the class RunMiXCRTest method test2.
// @Test
// public void testt() throws Exception {
// try {
// Path cachePath = Paths.get(System.getProperty("user.home"), ".repseqio", "cache");
// SequenceResolvers.initDefaultResolver(cachePath);
// VDJCLibraryRegistry.getDefault().registerLibraries("/Volumes/Data/Projects/repseqio/reference/human/TRB.json", "mi");
// System.out.println(VDJCLibraryRegistry.getDefault().getLibrary("mi", "hs").get("TRBV12-3*00").getFeature(GeneFeature.parse("VRegion(-100,+10000000)")));
// } catch (SequenceProviderIndexOutOfBoundsException e) {
// System.out.println(e.getAvailableRange());
// }
// }
@Test
public void test2() throws Exception {
// Path cachePath = Paths.get(System.getProperty("user.home"), ".repseqio", "cache");
// SequenceResolvers.initDefaultResolver(cachePath);
// VDJCLibraryRegistry.getDefault().addPathResolver("/Volumes/Data/Projects/repseqio/reference/human/");
RunMiXCR.RunMiXCRAnalysis params = new RunMiXCR.RunMiXCRAnalysis(RunMiXCR.class.getResource("/sequences/test_R1.fastq").getFile(), RunMiXCR.class.getResource("/sequences/test_R2.fastq").getFile());
params.alignerParameters.setSaveOriginalReads(true);
// params.library = "human_TR";
// params.species = "hs";
RunMiXCR.AlignResult align = RunMiXCR.align(params);
List<PairedRead> reads = new ArrayList<>();
try (PairedFastqReader fReader = new PairedFastqReader(RunMiXCR.class.getResource("/sequences/test_R1.fastq").getFile(), RunMiXCR.class.getResource("/sequences/test_R2.fastq").getFile())) {
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 test2.
@Test
@Ignore
public void test2() throws Exception {
PairedRead read1 = new PairedRead(new SingleReadImpl(0, new NSequenceWithQuality(new NucleotideSequence("GCTGTGTATTACTGTGCAAGAGGGCCCCAAGAAAATAGTGGTTATTACTACGGGTTTGACTACTGGGGCCAGGGA"), SequenceQuality.GOOD_QUALITY_VALUE), "206"), new SingleReadImpl(0, new NSequenceWithQuality(new NucleotideSequence("GGCGCCAGGGGGAAGACCGATGGGCCCTTGGTGGAGGCTGAGGAGACGGTGACCAGGGTTCCCTGGCCCCAGTAG"), SequenceQuality.GOOD_QUALITY_VALUE), "206"));
PairedRead read2 = new PairedRead(new SingleReadImpl(1, new NSequenceWithQuality(new NucleotideSequence("GCTGTGTATTACTGTGCAAGAGGGCCCCAAGAAAATAGTGGTTATTACTACGGGTTTGACTACTGGGGCCAGGGA"), SequenceQuality.GOOD_QUALITY_VALUE), "11621"), new SingleReadImpl(1, new NSequenceWithQuality(new NucleotideSequence("GGCGCCAGGGGGAAGACCGATGGGCCCTTGGTGGAGGCTGAGGAGACGGTGACCAGGGTTCCCTGGCCCCAGTAG"), SequenceQuality.GOOD_QUALITY_VALUE), "11621"));
RunMiXCR.RunMiXCRAnalysis params = new RunMiXCR.RunMiXCRAnalysis(read1);
RunMiXCR.AlignResult align = RunMiXCR.align(params);
for (VDJCAlignments al : align.alignments) {
for (int i = 0; i < al.numberOfTargets(); i++) {
System.out.println(VDJCAlignmentsFormatter.getTargetAsMultiAlignment(al, i));
System.out.println();
}
System.out.println();
System.out.println(" ================================================ ");
System.out.println();
}
}
use of com.milaboratory.core.io.sequence.PairedRead in project mixcr by milaboratory.
the class VDJCAlignerWithMergeTest 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)) {
VDJCAlignerWithMerge aligner = new VDJCAlignerWithMerge(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;
}
}
}
// for (VDJCAlignments alignments : alignemntsList) {
// for (int i = 0; i < alignments.numberOfTargets(); i++) {
// System.out.println(VDJCAlignmentsFormatter.getTargetAsMultiAlignment(alignments, i));
// }
// }
System.out.println(alignemntsList.size());
System.out.println(total);
System.out.println(leftHit);
Assert.assertTrue(alignemntsList.size() > 10);
// 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