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