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);
}
}
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;
}
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);
}
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());
}
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);
}
Aggregations