Search in sources :

Example 1 with NSequenceWithQuality

use of com.milaboratory.core.sequence.NSequenceWithQuality in project mixcr by milaboratory.

the class CloneAccumulator method rebuildClonalSequence.

public void rebuildClonalSequence() {
    SequenceQuality newQuality = aggregator.getQuality();
    final NSequenceWithQuality[] updated = new NSequenceWithQuality[sequence.size()];
    int pointer = 0;
    for (int i = 0; i < updated.length; i++) {
        final NucleotideSequence s = this.sequence.get(i).getSequence();
        updated[i] = new NSequenceWithQuality(s, newQuality.getRange(pointer, pointer + s.size()));
        pointer += s.size();
    }
    sequence = new ClonalSequence(updated);
    return;
}
Also used : SequenceQuality(com.milaboratory.core.sequence.SequenceQuality) NSequenceWithQuality(com.milaboratory.core.sequence.NSequenceWithQuality) NucleotideSequence(com.milaboratory.core.sequence.NucleotideSequence) ClonalSequence(com.milaboratory.mixcr.basictypes.ClonalSequence)

Example 2 with NSequenceWithQuality

use of com.milaboratory.core.sequence.NSequenceWithQuality in project mixcr by milaboratory.

the class BackwardCompatibilityTests method assertGoodVDJCA.

public static void assertGoodVDJCA(String resource, int size) throws IOException {
    try (VDJCAlignmentsReader reader = new VDJCAlignmentsReader(BackwardCompatibilityTests.class.getResource(resource).getFile())) {
        int countGood = 0;
        for (VDJCAlignments vdjcAlignments : CUtils.it(reader)) {
            NSequenceWithQuality cdr3NQ = vdjcAlignments.getFeature(GeneFeature.CDR3);
            if (cdr3NQ == null)
                continue;
            AminoAcidSequence aaCDR3 = AminoAcidSequence.translateFromCenter(cdr3NQ.getSequence());
            if (aaCDR3.codeAt(0) == AminoAcidAlphabet.C && aaCDR3.codeAt(aaCDR3.size() - 1) == AminoAcidAlphabet.F)
                ++countGood;
        }
        Assert.assertEquals(size, countGood);
    }
}
Also used : AminoAcidSequence(com.milaboratory.core.sequence.AminoAcidSequence) NSequenceWithQuality(com.milaboratory.core.sequence.NSequenceWithQuality)

Example 3 with NSequenceWithQuality

use of com.milaboratory.core.sequence.NSequenceWithQuality 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();
    }
}
Also used : SingleReadImpl(com.milaboratory.core.io.sequence.SingleReadImpl) NSequenceWithQuality(com.milaboratory.core.sequence.NSequenceWithQuality) NucleotideSequence(com.milaboratory.core.sequence.NucleotideSequence) PairedRead(com.milaboratory.core.io.sequence.PairedRead) RunMiXCR(com.milaboratory.mixcr.util.RunMiXCR) VDJCAlignments(com.milaboratory.mixcr.basictypes.VDJCAlignments) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 4 with NSequenceWithQuality

use of com.milaboratory.core.sequence.NSequenceWithQuality in project mixcr by milaboratory.

the class VDJCAlignerSTest method test2.

@Test
@Ignore
public void test2() throws Exception {
    // @
    // GCTGTGTATTACTGTGCAAGAGGGCCCCAAGAAAATAGTGGTTATTACTACGGGTTTGACTACTGGGGCCAGGGAACCCTGGTCACCGTCTCCTCAGCCTCCACCAAGGGCCCATCGGTCTTCCCCCTGGCGCC
    // +
    // CCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCCC
    VDJCAlignerParameters parameters = VDJCParametersPresets.getByName("default");
    VDJCAlignerS aligner = new VDJCAlignerS(parameters);
    for (VDJCGene gene : VDJCLibraryRegistry.getDefault().getLibrary("default", "hs").getGenes(Chains.IGH)) if (parameters.containsRequiredFeature(gene))
        aligner.addGene(gene);
    SingleReadImpl read = new SingleReadImpl(0, new NSequenceWithQuality(new NucleotideSequence("GCTGTGTATTACTGTGCAAGAGGGCCCCAAGAAAATAGTGGTTATTACTACGGGTTTGACTACTGGGGCCAGGGAACCCTGGTCACCGTCTCCTCAGCCTCCACCAAGGGCCCATCGGTCTTCCCCCTGGCGCC"), SequenceQuality.GOOD_QUALITY_VALUE), "");
    RandomUtil.getThreadLocalRandom().setSeed(29);
    VDJCAlignmentResult<SingleRead> result = aligner.process0(read);
}
Also used : SingleReadImpl(com.milaboratory.core.io.sequence.SingleReadImpl) NSequenceWithQuality(com.milaboratory.core.sequence.NSequenceWithQuality) NucleotideSequence(com.milaboratory.core.sequence.NucleotideSequence) VDJCGene(io.repseq.core.VDJCGene) SingleRead(com.milaboratory.core.io.sequence.SingleRead) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 5 with NSequenceWithQuality

use of com.milaboratory.core.sequence.NSequenceWithQuality in project mixcr by milaboratory.

the class PartialAlignmentsAssembler method addLeftToIndex.

private boolean addLeftToIndex(VDJCAlignments alignment) {
    int leftTargetId = getLeftPartitionedSequence(alignment);
    if (leftTargetId == -1)
        return false;
    VDJCPartitionedSequence left = alignment.getPartitionedTarget(leftTargetId);
    NSequenceWithQuality seq = left.getSequence();
    int kFromFirst = left.getPartitioning().getPosition(ReferencePoint.VEndTrimmed) + kOffset;
    if (kFromFirst < 0 || kFromFirst + kValue >= seq.size()) {
        noKMer.incrementAndGet();
        return false;
    }
    for (int kFrom = kFromFirst; kFrom < seq.size() - kValue; ++kFrom) {
        long kmer = kMer(seq.getSequence(), kFrom, kValue);
        if (kmer == -1) {
            wildcardsInKMer.incrementAndGet();
            continue;
        }
        List<KMerInfo> ids = kToIndexLeft.get(kmer);
        if (ids == null) {
            kToIndexLeft.put(kmer, ids = new ArrayList<>(1));
            kMerDiversity.incrementAndGet();
        }
        ids.add(new KMerInfo(alignment, kFrom, leftTargetId));
    }
    leftParts.incrementAndGet();
    return true;
}
Also used : NSequenceWithQuality(com.milaboratory.core.sequence.NSequenceWithQuality) ArrayList(java.util.ArrayList)

Aggregations

NSequenceWithQuality (com.milaboratory.core.sequence.NSequenceWithQuality)21 NucleotideSequence (com.milaboratory.core.sequence.NucleotideSequence)16 VDJCAlignments (com.milaboratory.mixcr.basictypes.VDJCAlignments)8 GeneType (io.repseq.core.GeneType)7 SequenceRead (com.milaboratory.core.io.sequence.SequenceRead)6 SingleReadImpl (com.milaboratory.core.io.sequence.SingleReadImpl)6 SequenceQuality (com.milaboratory.core.sequence.SequenceQuality)6 PairedRead (com.milaboratory.core.io.sequence.PairedRead)5 GeneFeature (io.repseq.core.GeneFeature)5 Test (org.junit.Test)5 Clone (com.milaboratory.mixcr.basictypes.Clone)4 RunMiXCR (com.milaboratory.mixcr.util.RunMiXCR)4 ArrayList (java.util.ArrayList)4 CUtils (cc.redberry.pipe.CUtils)3 Alignment (com.milaboratory.core.alignment.Alignment)3 SequenceReaderCloseable (com.milaboratory.core.io.sequence.SequenceReaderCloseable)3 CloneFactory (com.milaboratory.mixcr.assembler.CloneFactory)3 CloneSet (com.milaboratory.mixcr.basictypes.CloneSet)3 VDJCAlignmentsFormatter (com.milaboratory.mixcr.basictypes.VDJCAlignmentsFormatter)3 VDJCHit (com.milaboratory.mixcr.basictypes.VDJCHit)3