Search in sources :

Example 11 with TIntIntIterator

use of gnu.trove.iterator.TIntIntIterator in project mixcr by milaboratory.

the class FullSeqAssembler method calculateRawData.

public RawVariantsData calculateRawData(Supplier<OutputPort<VDJCAlignments>> alignments) {
    if (!sequenceToVariantId.isEmpty())
        throw new IllegalStateException();
    for (byte letter = 0; letter < NucleotideSequence.ALPHABET.basicSize(); letter++) {
        NucleotideSequence seq = new NucleotideSequence(new byte[] { letter });
        sequenceToVariantId.put(seq, letter);
        variantIdToSequence.put(letter, seq);
    }
    sequenceToVariantId.put(NucleotideSequence.EMPTY, NucleotideSequence.ALPHABET.basicSize());
    variantIdToSequence.put(NucleotideSequence.ALPHABET.basicSize(), NucleotideSequence.EMPTY);
    TIntIntHashMap coverage = new TIntIntHashMap();
    TIntObjectHashMap<TIntObjectHashMap<VariantAggregator>> variants = new TIntObjectHashMap<>();
    int nAlignments = 0;
    for (VDJCAlignments al : CUtils.it(alignments.get())) {
        ++nAlignments;
        for (PointSequence point : toPointSequences(al)) {
            int seqIndex = getVariantIndex(point.sequence.getSequence());
            coverage.adjustOrPutValue(point.point, 1, 1);
            TIntObjectHashMap<VariantAggregator> map = variants.get(point.point);
            if (map == null)
                variants.put(point.point, map = new TIntObjectHashMap<>());
            VariantAggregator var = map.get(seqIndex);
            if (var == null)
                map.put(point.point, var = new VariantAggregator());
            var.count += 1;
            var.sumQuality += 0x7F & point.quality;
        }
    }
    assert nAlignments > 0;
    long[] forSort = new long[coverage.size()];
    TIntIntIterator iterator = coverage.iterator();
    int i = 0;
    while (iterator.hasNext()) {
        iterator.advance();
        forSort[i++] = -((((long) iterator.value()) << 32) | iterator.key());
    }
    Arrays.sort(forSort);
    int[] pointsArray = Arrays.stream(forSort).mapToInt(l -> (int) (-l)).toArray();
    TIntIntHashMap revIndex = new TIntIntHashMap();
    for (int j = 0; j < pointsArray.length; j++) revIndex.put(pointsArray[j], j);
    int[] coverageArray = Arrays.stream(forSort).mapToInt(l -> (int) ((-l) >> 32)).toArray();
    int[][] packedData = new int[pointsArray.length][nAlignments];
    for (int[] aPackedData : packedData) Arrays.fill(aPackedData, -1);
    i = 0;
    for (VDJCAlignments al : CUtils.it(alignments.get())) {
        for (PointSequence point : toPointSequences(al)) {
            int pointIndex = revIndex.get(point.point);
            packedData[pointIndex][i] = (sequenceToVariantId.get(point.sequence.getSequence()) << 8) | (0xFF & point.quality);
        }
        i++;
    }
    return new RawVariantsData(nAlignments, pointsArray, coverageArray) {

        @Override
        OutputPort<int[]> createPort() {
            return CUtils.asOutputPort(Arrays.asList(packedData));
        }
    };
}
Also used : IntStream(java.util.stream.IntStream) VDJCPartitionedSequence(com.milaboratory.mixcr.basictypes.VDJCPartitionedSequence) TIntObjectHashMap(gnu.trove.map.hash.TIntObjectHashMap) java.util(java.util) TObjectFloatHashMap(gnu.trove.map.hash.TObjectFloatHashMap) Clone(com.milaboratory.mixcr.basictypes.Clone) Supplier(java.util.function.Supplier) TIntIntIterator(gnu.trove.iterator.TIntIntIterator) com.milaboratory.core.alignment(com.milaboratory.core.alignment) VDJCAlignerParameters(com.milaboratory.mixcr.vdjaligners.VDJCAlignerParameters) CloneFactory(com.milaboratory.mixcr.assembler.CloneFactory) MutationsBuilder(com.milaboratory.core.mutations.MutationsBuilder) Constants(gnu.trove.impl.Constants) io.repseq.core(io.repseq.core) Range(com.milaboratory.core.Range) TObjectIntHashMap(gnu.trove.map.hash.TObjectIntHashMap) CUtils(cc.redberry.pipe.CUtils) TIntIntHashMap(gnu.trove.map.hash.TIntIntHashMap) OutputPort(cc.redberry.pipe.OutputPort) Collectors(java.util.stream.Collectors) com.milaboratory.core.sequence(com.milaboratory.core.sequence) TIntHashSet(gnu.trove.set.hash.TIntHashSet) Joining(io.repseq.core.GeneType.Joining) Stream(java.util.stream.Stream) VDJCHit(com.milaboratory.mixcr.basictypes.VDJCHit) VDJCGenes(io.repseq.gen.VDJCGenes) VDJCAlignments(com.milaboratory.mixcr.basictypes.VDJCAlignments) Variable(io.repseq.core.GeneType.Variable) TIntIntIterator(gnu.trove.iterator.TIntIntIterator) TIntObjectHashMap(gnu.trove.map.hash.TIntObjectHashMap) TIntIntHashMap(gnu.trove.map.hash.TIntIntHashMap) VDJCAlignments(com.milaboratory.mixcr.basictypes.VDJCAlignments)

Example 12 with TIntIntIterator

use of gnu.trove.iterator.TIntIntIterator in project Terasology by MovingBlocks.

the class GLSLMaterial method setFloat.

@Override
public void setFloat(String desc, float f, boolean currentOnly) {
    if (isDisposed()) {
        return;
    }
    if (currentOnly) {
        enable();
        int id = getUniformLocation(getActiveShaderProgramId(), desc);
        GL20.glUniform1f(id, f);
    } else {
        TIntIntIterator it = disposalAction.shaderPrograms.iterator();
        while (it.hasNext()) {
            it.advance();
            GL20.glUseProgram(it.value());
            int id = getUniformLocation(it.value(), desc);
            GL20.glUniform1f(id, f);
        }
        restoreStateAfterUniformsSet();
    }
}
Also used : TIntIntIterator(gnu.trove.iterator.TIntIntIterator)

Example 13 with TIntIntIterator

use of gnu.trove.iterator.TIntIntIterator in project Terasology by MovingBlocks.

the class GLSLMaterial method setFloat3.

@Override
public void setFloat3(String desc, FloatBuffer buffer, boolean currentOnly) {
    if (isDisposed()) {
        return;
    }
    if (currentOnly) {
        enable();
        int id = getUniformLocation(getActiveShaderProgramId(), desc);
        GL20.glUniform3(id, buffer);
    } else {
        TIntIntIterator it = disposalAction.shaderPrograms.iterator();
        while (it.hasNext()) {
            it.advance();
            GL20.glUseProgram(it.value());
            int id = getUniformLocation(it.value(), desc);
            GL20.glUniform3(id, buffer);
        }
        restoreStateAfterUniformsSet();
    }
}
Also used : TIntIntIterator(gnu.trove.iterator.TIntIntIterator)

Example 14 with TIntIntIterator

use of gnu.trove.iterator.TIntIntIterator in project Terasology by MovingBlocks.

the class GLSLMaterial method setFloat4.

@Override
public void setFloat4(String desc, FloatBuffer buffer, boolean currentOnly) {
    if (isDisposed()) {
        return;
    }
    if (currentOnly) {
        enable();
        int id = getUniformLocation(getActiveShaderProgramId(), desc);
        GL20.glUniform4(id, buffer);
    } else {
        TIntIntIterator it = disposalAction.shaderPrograms.iterator();
        while (it.hasNext()) {
            it.advance();
            GL20.glUseProgram(it.value());
            int id = getUniformLocation(it.value(), desc);
            GL20.glUniform4(id, buffer);
        }
        restoreStateAfterUniformsSet();
    }
}
Also used : TIntIntIterator(gnu.trove.iterator.TIntIntIterator)

Example 15 with TIntIntIterator

use of gnu.trove.iterator.TIntIntIterator in project Terasology by MovingBlocks.

the class GLSLMaterial method setMatrix4.

@Override
public void setMatrix4(String desc, Matrix4f value, boolean currentOnly) {
    if (isDisposed()) {
        return;
    }
    if (currentOnly) {
        enable();
        int id = getUniformLocation(getActiveShaderProgramId(), desc);
        GL20.glUniformMatrix4(id, false, MatrixUtils.matrixToFloatBuffer(value));
    } else {
        TIntIntIterator it = disposalAction.shaderPrograms.iterator();
        while (it.hasNext()) {
            it.advance();
            GL20.glUseProgram(it.value());
            int id = getUniformLocation(it.value(), desc);
            GL20.glUniformMatrix4(id, false, MatrixUtils.matrixToFloatBuffer(value));
        }
        restoreStateAfterUniformsSet();
    }
}
Also used : TIntIntIterator(gnu.trove.iterator.TIntIntIterator)

Aggregations

TIntIntIterator (gnu.trove.iterator.TIntIntIterator)22 TIntIntMap (gnu.trove.map.TIntIntMap)3 TIntIntHashMap (gnu.trove.map.hash.TIntIntHashMap)2 LocalDate (org.joda.time.LocalDate)2 Test (org.junit.Test)2 TaskStatistics (org.opentripplanner.analyst.cluster.TaskStatistics)2 QualifiedModeSet (org.opentripplanner.api.parameter.QualifiedModeSet)2 FakeGraph (org.opentripplanner.graph_builder.module.FakeGraph)2 ProfileRequest (org.opentripplanner.profile.ProfileRequest)2 RaptorWorkerData (org.opentripplanner.profile.RaptorWorkerData)2 RepeatedRaptorProfileRouter (org.opentripplanner.profile.RepeatedRaptorProfileRouter)2 TraverseModeSet (org.opentripplanner.routing.core.TraverseModeSet)2 Graph (org.opentripplanner.routing.graph.Graph)2 DefaultStreetVertexIndexFactory (org.opentripplanner.routing.impl.DefaultStreetVertexIndexFactory)2 CUtils (cc.redberry.pipe.CUtils)1 OutputPort (cc.redberry.pipe.OutputPort)1 Range (com.milaboratory.core.Range)1 com.milaboratory.core.alignment (com.milaboratory.core.alignment)1 MutationsBuilder (com.milaboratory.core.mutations.MutationsBuilder)1 com.milaboratory.core.sequence (com.milaboratory.core.sequence)1