Search in sources :

Example 26 with GeneFeature

use of io.repseq.core.GeneFeature in project mixcr by milaboratory.

the class JsonOverriderTest method testArray1.

@Test
public void testArray1() throws Exception {
    CloneFactoryParameters factoryParameters = new CloneFactoryParameters(new VJCClonalAlignerParameters(0.3f, LinearGapAlignmentScoring.getNucleotideBLASTScoring(), 3), new VJCClonalAlignerParameters(0.4f, LinearGapAlignmentScoring.getNucleotideBLASTScoring(), 5), null, new DClonalAlignerParameters(0.85f, 30.0f, 3, AffineGapAlignmentScoring.getNucleotideBLASTScoring()));
    CloneAssemblerParameters params = new CloneAssemblerParameters(new GeneFeature[] { GeneFeature.FR1, GeneFeature.CDR3 }, 12, QualityAggregationType.Average, new CloneClusteringParameters(2, 1, TreeSearchParameters.ONE_MISMATCH, new RelativeConcentrationFilter(1.0E-6)), factoryParameters, true, true, false, 0.4, true, (byte) 20, .8, "2of6", (byte) 15);
    CloneAssemblerParameters override = JsonOverrider.override(params, CloneAssemblerParameters.class, "assemblingFeatures=[CDR1(-5,+6),CDR2]");
    CloneAssemblerParameters expected = new CloneAssemblerParameters(new GeneFeature[] { new GeneFeature(GeneFeature.CDR1, -5, +6), GeneFeature.CDR2 }, 12, QualityAggregationType.Average, new CloneClusteringParameters(2, 1, TreeSearchParameters.ONE_MISMATCH, new RelativeConcentrationFilter(1.0E-6)), factoryParameters, true, true, false, 0.4, true, (byte) 20, .8, "2of6", (byte) 15);
    Assert.assertEquals(expected, override);
}
Also used : GeneFeature(io.repseq.core.GeneFeature) Test(org.junit.Test)

Example 27 with GeneFeature

use of io.repseq.core.GeneFeature in project mixcr by milaboratory.

the class JsonOverriderTest method test3.

@Test
public void test3() throws Exception {
    GeneFeature jRegion = GeneFeature.parse("JRegion");
    System.out.println(jRegion);
    System.out.println(GeneFeature.encode(jRegion));
    VDJCAlignerParameters params = VDJCParametersPresets.getByName("default");
    Map<String, String> overrides = new HashMap<String, String>() {

        {
            put("vParameters.geneFeatureToAlign", "VTranscript");
        }
    };
    Assert.assertNotNull(JsonOverrider.override(params, VDJCAlignerParameters.class, overrides));
}
Also used : GeneFeature(io.repseq.core.GeneFeature) VDJCAlignerParameters(com.milaboratory.mixcr.vdjaligners.VDJCAlignerParameters) HashMap(java.util.HashMap) Test(org.junit.Test)

Example 28 with GeneFeature

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

the class ExportCloneSequencesAction method go.

@Override
public void go(ActionHelper helper) throws Exception {
    Chains chains = params.getChains();
    GeneFeature geneFeature = params.getGeneFeature();
    RandomGenerator random = new Well19937c(1232434);
    try (GRepertoireReader input = new GRepertoireReader(createBufferedReader(params.getInput()));
        FastaWriter<NucleotideSequence> output = createSingleFastaWriter(params.getOutput())) {
        List<DescriptionExtractor> extractors = params.getExtractors(input.getLibrary());
        long i = 0;
        for (GClone clone : CUtils.it(input)) {
            int f = params.factor == null ? 1 : randomizedRound(clone.abundance * params.factor, random);
            for (int j = 0; j < f; j++) for (Map.Entry<String, GGene> e : clone.genes.entrySet()) if (chains.contains(e.getKey())) {
                StringBuilder descriptionLine = new StringBuilder("GClone");
                for (DescriptionExtractor extractor : extractors) descriptionLine.append("|").append(extractor.extract(clone, e.getValue(), e.getKey()));
                output.write(new FastaRecord<>(i++, descriptionLine.toString(), e.getValue().getFeature(geneFeature)));
            }
        }
    }
}
Also used : GeneFeature(io.repseq.core.GeneFeature) Chains(io.repseq.core.Chains) Well19937c(org.apache.commons.math3.random.Well19937c) RandomGenerator(org.apache.commons.math3.random.RandomGenerator) NucleotideSequence(com.milaboratory.core.sequence.NucleotideSequence)

Example 29 with GeneFeature

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

the class GeneFeatureTest method testIntersection7.

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

Example 30 with GeneFeature

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

the class GeneFeatureTest method test3_2.

@Test
public void test3_2() throws Exception {
    GeneFeature f1 = new GeneFeature(createWithOffsets(1, 3, -2, 0), createWithOffsets(4, 5, -2, 4));
    GeneFeature f2 = new GeneFeature(createWithOffsets(1, 3, -6, 0), createWithOffsets(4, 5, -2, 2));
    assertEquals(f2, new GeneFeature(f1, -4, -2));
}
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