Search in sources :

Example 56 with NucleotideSequence

use of com.milaboratory.core.sequence.NucleotideSequence in project repseqio by repseqio.

the class BaseSequence method resolve.

/**
 * Returns SequenceProvider to access underlying sequence
 *
 * @param context  resolution context
 * @param resolver sequence resolver
 * @return SequenceProvider to access underlying sequence
 */
public SequenceProvider<NucleotideSequence> resolve(Path context, SequenceResolver resolver) {
    CachedSequenceProvider<NucleotideSequence> originalProvider = resolver.resolve(new SequenceAddress(context, origin));
    if (isPureOriginalSequence()) {
        return originalProvider;
    } else {
        // TODO implement more lazy algorithm
        int length = 0;
        for (Range region : regions) length += region.length();
        SequenceBuilder<NucleotideSequence> builder = NucleotideSequence.ALPHABET.createBuilder().ensureCapacity(length);
        for (Range region : regions) builder.append(originalProvider.getRegion(region));
        NucleotideSequence seq = builder.createAndDestroy();
        seq = mutations == null ? seq : mutations.mutate(seq);
        return SequenceProviderUtils.fromSequence(seq);
    }
}
Also used : SequenceAddress(io.repseq.seqbase.SequenceAddress) NucleotideSequence(com.milaboratory.core.sequence.NucleotideSequence) Range(com.milaboratory.core.Range)

Example 57 with NucleotideSequence

use of com.milaboratory.core.sequence.NucleotideSequence in project repseqio by repseqio.

the class AbstractRAFastaResolver method resolve.

@Override
public CachedSequenceProvider<NucleotideSequence> resolve(final SequenceAddress address) {
    final URI uri = address.getUri();
    CachedSequenceProvider<NucleotideSequence> provider = records.get(uri);
    if (provider == null) {
        final String recordId = resolveRecordId(uri);
        records.put(uri, provider = new CachedSequenceProvider<>(NucleotideSequence.ALPHABET, SequenceProviderUtils.lazyProvider(new SequenceProviderFactory<NucleotideSequence>() {

            @Override
            public SequenceProvider<NucleotideSequence> create() {
                RandomAccessFastaReader<NucleotideSequence> fasta = resolveReader(address);
                return fasta.getSequenceProvider(recordId);
            }
        })));
    }
    return provider;
}
Also used : NucleotideSequence(com.milaboratory.core.sequence.NucleotideSequence) CachedSequenceProvider(com.milaboratory.core.sequence.provider.CachedSequenceProvider) URI(java.net.URI) SequenceProviderFactory(com.milaboratory.core.sequence.provider.SequenceProviderFactory)

Example 58 with NucleotideSequence

use of com.milaboratory.core.sequence.NucleotideSequence in project repseqio by repseqio.

the class KnownSequenceFragmentDataTest method test1.

@Test
public void test1() throws Exception {
    KnownSequenceFragmentData data = new KnownSequenceFragmentData(URI.create("file://some_fasta.fasta#24.6jsd21.Tut"), new Range(10, 30), new NucleotideSequence("ATCCTGGCTTAGAACTAACG"));
    TestUtil.assertJson(data);
}
Also used : NucleotideSequence(com.milaboratory.core.sequence.NucleotideSequence) Range(com.milaboratory.core.Range) Test(org.junit.Test)

Example 59 with NucleotideSequence

use of com.milaboratory.core.sequence.NucleotideSequence in project repseqio by repseqio.

the class GGeneTest method assertSequences.

void assertSequences(NucleotideSequence expected, NucleotideSequence... toConcat) {
    SequenceBuilder<NucleotideSequence> b = NucleotideSequence.ALPHABET.createBuilder();
    for (NucleotideSequence ns : toConcat) b.append(ns);
    assertEquals(expected, b.createAndDestroy());
}
Also used : NucleotideSequence(com.milaboratory.core.sequence.NucleotideSequence)

Example 60 with NucleotideSequence

use of com.milaboratory.core.sequence.NucleotideSequence in project repseqio by repseqio.

the class BasicGCloneModelTest method test1.

@Test
public void test1() throws Exception {
    GGeneModel geneModel = new BasicGGeneModel(new IndependentVDJCGenesModel(b("TRBV12-2*00", 1.0).put("TRBV12-3*00", 0.0).get(), b("TRBD1*00", 1.0).put("TRBD2*00", 0.0).get(), b("TRBJ1-2*00", 1.0).put("TRBJ1-3*00", 0.0).get(), b("TRBC1*00", 1.0).put("TRBC2*00", 0.0).get()), new IndependentVDJTrimmingModel(new CommonCategoricalGeneTrimmingModel(b(-1, 1.0).get()), new CommonCategoricalDGeneTrimmingModel(b("-2|-3", 1.0).get()), new CommonCategoricalGeneTrimmingModel(b(-4, 1.0).get())), new FixedInsertModel(new NucleotideSequence("ATTA")), new FixedInsertModel(new NucleotideSequence("GACA")));
    BasicGCloneModel model = new BasicGCloneModel(new VDJCLibraryId("default", 9606), new FixedRealModel(1.0), b("TRB", geneModel).get());
    TestUtil.assertJson(model);
    GCloneGenerator gen = model.create(new Well19937c(123), VDJCLibraryRegistry.getDefault());
    GClone clone = gen.sample();
    TestUtil.assertJson(clone);
    GGene trb = clone.genes.get("TRB");
    assertEquals(trb.vdjcGenes.v.getName(), "TRBV12-2*00");
    assertEquals(trb.vdjcGenes.d.getName(), "TRBD1*00");
    assertEquals(trb.vdjcGenes.j.getName(), "TRBJ1-2*00");
    assertEquals(trb.vdjcGenes.c.getName(), "TRBC1*00");
    assertEquals(new VDJTrimming(-1, -4, -2, -3), trb.vdjTrimming);
    assertEquals(new NucleotideSequence("ATTA"), trb.vInsert);
    assertEquals(new NucleotideSequence("GACA"), trb.djInsert);
}
Also used : VDJCLibraryId(io.repseq.core.VDJCLibraryId) Well19937c(org.apache.commons.math3.random.Well19937c) VDJTrimming(io.repseq.gen.VDJTrimming) GGene(io.repseq.gen.GGene) NucleotideSequence(com.milaboratory.core.sequence.NucleotideSequence) GClone(io.repseq.gen.GClone) Test(org.junit.Test)

Aggregations

NucleotideSequence (com.milaboratory.core.sequence.NucleotideSequence)81 Test (org.junit.Test)32 Range (com.milaboratory.core.Range)19 VDJCGene (io.repseq.core.VDJCGene)15 GeneType (io.repseq.core.GeneType)14 NSequenceWithQuality (com.milaboratory.core.sequence.NSequenceWithQuality)13 GeneFeature (io.repseq.core.GeneFeature)9 VDJCAlignments (com.milaboratory.mixcr.basictypes.VDJCAlignments)8 VDJCHit (com.milaboratory.mixcr.basictypes.VDJCHit)8 ReferencePoint (io.repseq.core.ReferencePoint)7 VDJCLibrary (io.repseq.core.VDJCLibrary)7 ArrayList (java.util.ArrayList)7 VDJCAlignerParameters (com.milaboratory.mixcr.vdjaligners.VDJCAlignerParameters)6 AlignmentHit (com.milaboratory.core.alignment.batch.AlignmentHit)5 PairedRead (com.milaboratory.core.io.sequence.PairedRead)5 AminoAcidSequence (com.milaboratory.core.sequence.AminoAcidSequence)5 Path (java.nio.file.Path)5 Alignment (com.milaboratory.core.alignment.Alignment)4 Pattern (java.util.regex.Pattern)4 AlignmentHelper (com.milaboratory.core.alignment.AlignmentHelper)3