Search in sources :

Example 11 with GeneFeature

use of io.repseq.core.GeneFeature in project repseqio by repseqio.

the class GeneFeatureTest method testRandom1.

@Test
public void testRandom1() {
    Well44497a rand = new Well44497a();
    int tn = BasicReferencePoint.TOTAL_NUMBER_OF_BASIC_REFERENCE_POINTS;
    for (int baseBlock = 2; baseBlock < 5; ++baseBlock) for (int t = 0; t < 1000; ++t) {
        int[] all = new int[tn];
        ArrayList<GeneFeature> features = new ArrayList<>();
        int begin, end = 0;
        do {
            begin = end + rand.nextInt(baseBlock);
            end = begin + 1 + rand.nextInt(baseBlock);
            if (end >= tn)
                break;
            Arrays.fill(all, begin, end, 1);
            features.add(create(begin, end));
        } while (end < tn);
        IntArrayList expectedPoints = new IntArrayList();
        if (all[0] == 1)
            expectedPoints.add(0);
        for (int i = 1; i < tn; ++i) if (all[i] != all[i - 1])
            expectedPoints.add(i);
        if (all[tn - 1] == 1)
            expectedPoints.add(tn);
        GeneFeature actual = new GeneFeature(features.toArray(new GeneFeature[features.size()]));
        assertEquals(create(expectedPoints.toArray()), actual);
        assertEquals(expectedPoints.size() / 2, actual.regions.length);
    }
}
Also used : GeneFeature(io.repseq.core.GeneFeature) IntArrayList(com.milaboratory.util.IntArrayList) Well44497a(org.apache.commons.math3.random.Well44497a) IntArrayList(com.milaboratory.util.IntArrayList) Test(org.junit.Test)

Example 12 with GeneFeature

use of io.repseq.core.GeneFeature in project repseqio by repseqio.

the class GeneFeatureTest method testIntersection9.

@Test
public void testIntersection9() throws Exception {
    GeneFeature f1, f2;
    f1 = create(new int[] { 7, 9 }, new int[] { 2, -4 });
    f2 = create(new int[] { 1, 5, 7, 9, 10, 12 }, new int[] { -3, 0, 1, -4, -2, 4 });
    Assert.assertEquals(create(new int[] { 7, 9 }, new int[] { 2, -4 }), GeneFeature.intersection(f2, f1));
}
Also used : GeneFeature(io.repseq.core.GeneFeature) Test(org.junit.Test)

Example 13 with GeneFeature

use of io.repseq.core.GeneFeature in project repseqio by repseqio.

the class GeneFeatureTest method testIntersection14.

@Test
public void testIntersection14() throws Exception {
    GeneFeature aa1 = GeneFeature.VRegion.append(new GeneFeature(ReferencePoint.VEnd, ReferencePoint.VEnd.move(-20)));
    GeneFeature aa2 = GeneFeature.VRegion.append(new GeneFeature(ReferencePoint.VEnd, ReferencePoint.VEnd.move(-15)));
    Assert.assertEquals(aa2, GeneFeature.intersection(aa1, aa2));
    GeneFeature dd1 = new GeneFeature(ReferencePoint.DEnd.move(-3), ReferencePoint.DBegin).append(GeneFeature.DRegion).append(GeneFeature.GermlineDPSegment);
    GeneFeature dd2 = GeneFeature.GermlineDPSegment.append(GeneFeature.DRegion).append(new GeneFeature(ReferencePoint.DEnd, ReferencePoint.DBegin.move(3)));
    GeneFeature dd3 = new GeneFeature(ReferencePoint.DEnd.move(-3), ReferencePoint.DBegin).append(GeneFeature.DRegion).append(new GeneFeature(ReferencePoint.DEnd, ReferencePoint.DBegin.move(3)));
    Assert.assertEquals(dd3, GeneFeature.intersection(dd1, dd2));
}
Also used : GeneFeature(io.repseq.core.GeneFeature) Test(org.junit.Test)

Example 14 with GeneFeature

use of io.repseq.core.GeneFeature in project repseqio by repseqio.

the class GeneFeatureTest method testIntersection3.

@Test(expected = IllegalArgumentException.class)
public void testIntersection3() throws Exception {
    GeneFeature f1, f2;
    f1 = create(1, 5, 7, 9);
    f2 = create(2, 5, 6, 9);
    GeneFeature.intersection(f1, f2);
}
Also used : GeneFeature(io.repseq.core.GeneFeature) Test(org.junit.Test)

Example 15 with GeneFeature

use of io.repseq.core.GeneFeature in project repseqio by repseqio.

the class GeneFeatureTest method testReversed.

@Test
public void testReversed() throws Exception {
    GeneFeature gf = GeneFeature.parse("{FR1Begin:VEnd}+{VEnd:VEnd(-20)}");
    assertEquals(2, gf.size());
    gf = GeneFeature.parse("{FR1Begin:VEnd}").append(GeneFeature.parse("{VEnd:VEnd(-20)}"));
    assertEquals(2, gf.size());
    gf = GeneFeature.VGeneWithP;
    assertEquals(2, gf.size());
}
Also used : GeneFeature(io.repseq.core.GeneFeature) Test(org.junit.Test)

Aggregations

GeneFeature (io.repseq.core.GeneFeature)41 Test (org.junit.Test)23 NucleotideSequence (com.milaboratory.core.sequence.NucleotideSequence)10 GeneType (io.repseq.core.GeneType)9 VDJCGene (io.repseq.core.VDJCGene)6 NSequenceWithQuality (com.milaboratory.core.sequence.NSequenceWithQuality)3 VDJCAlignments (com.milaboratory.mixcr.basictypes.VDJCAlignments)3 ReferencePoint (io.repseq.core.ReferencePoint)3 VDJCLibrary (io.repseq.core.VDJCLibrary)3 VDJCLibraryRegistry (io.repseq.core.VDJCLibraryRegistry)3 Pattern (java.util.regex.Pattern)3 SequenceRead (com.milaboratory.core.io.sequence.SequenceRead)2 AminoAcidSequence (com.milaboratory.core.sequence.AminoAcidSequence)2 Clone (com.milaboratory.mixcr.basictypes.Clone)2 VDJCHit (com.milaboratory.mixcr.basictypes.VDJCHit)2 VDJCAlignerParameters (com.milaboratory.mixcr.vdjaligners.VDJCAlignerParameters)2 IntArrayList (com.milaboratory.util.IntArrayList)2 ArrayList (java.util.ArrayList)2 HashMap (java.util.HashMap)2 Well19937c (org.apache.commons.math3.random.Well19937c)2