use of io.repseq.core.GeneType in project mixcr by milaboratory.
the class ActionExportAlignmentsPretty method outputVerbose.
public void outputVerbose(PrintStream output, final VDJCAlignments alignments) {
output.println(">>> Read ids: " + Arrays.toString(alignments.getReadIds()).replace("[", "").replace("]", ""));
output.println();
output.println(">>> Target sequences (input sequences):");
output.println();
for (int i = 0; i < alignments.numberOfTargets(); i++) {
output.println("Sequence" + i + ":");
final VDJCPartitionedSequence partitionedTarget = alignments.getPartitionedTarget(i);
printGeneFeatures(new Filter<GeneFeature>() {
@Override
public boolean accept(GeneFeature object) {
return partitionedTarget.getPartitioning().isAvailable(object);
}
}, output, "Contains features: ");
output.println();
output.print(new NSequenceWithQualityPrintHelper(alignments.getTarget(i), LINE_OFFSET, LINE_LENGTH));
}
if (alignments.numberOfTargets() > 1) {
// Printing a set of available gene features for a full read
output.println(">>> Gene features that can be extracted from this paired-read: ");
printGeneFeatures(new Filter<GeneFeature>() {
@Override
public boolean accept(GeneFeature object) {
return alignments.getFeature(object) != null;
}
}, output, "");
}
output.println();
for (GeneType geneType : GeneType.values()) {
output.println(">>> Alignments with " + geneType.getLetter() + " gene:");
output.println();
boolean exists = false;
VDJCHit[] hits = alignments.getHits(geneType);
if (hits.length > 0) {
hits = actionParameters.isOnlyTop() ? new VDJCHit[] { hits[0] } : hits;
for (VDJCHit hit : hits) {
exists = true;
output.println(hit.getGene().getName() + " (total score = " + hit.getScore() + ")");
for (int i = 0; i < alignments.numberOfTargets(); i++) {
Alignment<NucleotideSequence> alignment = hit.getAlignment(i);
if (alignment == null)
continue;
output.println("Alignment of Sequence" + i + " (score = " + (alignment == null ? "NaN" : alignment.getScore()) + "):");
if (alignment != null) {
for (AlignmentHelper subHelper : alignment.getAlignmentHelper().split(LINE_LENGTH, LINE_OFFSET)) {
output.println(subHelper.toStringWithSeq2Quality(alignments.getTarget(i).getQuality()));
output.println();
}
if (actionParameters.printGeneSequence()) {
output.println("Gene sequence:");
output.println(alignment.getSequence1());
output.println();
}
}
}
}
}
if (!exists) {
output.println("No hits.");
output.println();
}
}
char[] ll = new char[94];
Arrays.fill(ll, '=');
output.println(ll);
output.println();
}
use of io.repseq.core.GeneType in project mixcr by milaboratory.
the class VDJCAlignmentsReader method initGeneFeatureReferencesFrom.
/**
* Produce reader that uses the same reference for geneFeatures.
*
* @param reader target reader
* @param parameters parameters to take reference from
*/
public static void initGeneFeatureReferencesFrom(VDJCAlignmentsReader reader, VDJCAlignerParameters parameters) {
Map<GeneFeature, GeneFeature> featureRefs = new HashMap<>();
for (GeneType gt : GeneType.VDJC_REFERENCE) {
GeneFeature f = parameters.getFeatureToAlign(gt);
featureRefs.put(f, f);
}
reader.init(featureRefs);
}
use of io.repseq.core.GeneType in project mixcr by milaboratory.
the class CloneAccumulator method calculateScores.
public void calculateScores(CloneFactoryParameters parameters) {
for (GeneType geneType : GeneType.VJC_REFERENCE) {
VJCClonalAlignerParameters vjcParameters = parameters.getVJCParameters(geneType);
if (vjcParameters == null)
continue;
TObjectFloatHashMap<VDJCGeneId> accumulatorGeneIds = geneScores.get(geneType);
if (accumulatorGeneIds == null)
continue;
TObjectFloatIterator<VDJCGeneId> iterator = accumulatorGeneIds.iterator();
float maxScore = 0;
while (iterator.hasNext()) {
iterator.advance();
float value = iterator.value();
if (value > maxScore)
maxScore = value;
}
maxScore = maxScore * vjcParameters.getRelativeMinScore();
iterator = accumulatorGeneIds.iterator();
while (iterator.hasNext()) {
iterator.advance();
if (maxScore > iterator.value())
iterator.remove();
else
iterator.setValue(Math.round(iterator.value() * 10f / coreCount) / 10f);
}
}
}
use of io.repseq.core.GeneType in project mixcr by milaboratory.
the class PartialAlignmentsAssemblerTest method test2.
@Test
public void test2() throws Exception {
RandomUtil.reseedThreadLocal(47);
final InputTestData input = createTestData(47);
final NucleotideSequence reference = input.reference;
final EnumMap<GeneType, int[]> refPositions = input.refPositions;
PairedRead[] data = { createPair(0, reference.getRange(refPositions.get(Diversity)[0] - 85, refPositions.get(Diversity)[0] + 10), reference.getRange(refPositions.get(Diversity)[1], refPositions.get(Diversity)[1] + 85).getReverseComplement()), createPair(1, reference.getRange(refPositions.get(Diversity)[0] - 135, refPositions.get(Diversity)[0] - 70), reference.getRange(refPositions.get(Diversity)[0] - 8, refPositions.get(Diversity)[0] + 85).getReverseComplement()) };
final TestResult testResult = processData(data, input);
for (VDJCAlignments al : testResult.assembled) {
MiXCRTestUtils.printAlignment(al);
// System.out.println(input.VJJunction);
// System.out.println(al.getFeature(GeneFeature.VJJunction).getSequence());
Assert.assertTrue(input.VJJunction.toString().contains(al.getFeature(GeneFeature.VJJunction).getSequence().toString()));
}
}
use of io.repseq.core.GeneType in project mixcr by milaboratory.
the class PartialAlignmentsAssemblerTest method test3.
@Test
public void test3() throws Exception {
for (int i = 0; i < 100; i++) {
RandomUtil.reseedThreadLocal(i);
// System.out.println(i);
final InputTestData input = createTestData(i);
final NucleotideSequence reference = input.reference;
final EnumMap<GeneType, int[]> refPositions = input.refPositions;
PairedRead[] data = { createPair(0, reference.getRange(refPositions.get(Diversity)[0] - 85, refPositions.get(Diversity)[0] + 10), reference.getRange(refPositions.get(Diversity)[1], refPositions.get(Diversity)[1] + 85).getReverseComplement()), createPair(1, reference.getRange(refPositions.get(Diversity)[0] - 135, refPositions.get(Diversity)[0] - 70), reference.getRange(refPositions.get(Diversity)[0] - 8, refPositions.get(Diversity)[0] + 85).getReverseComplement()) };
final TestResult testResult = processData(data, input);
for (VDJCAlignments al : testResult.assembled) {
// printAlignment(al);
if (al.numberOfTargets() == 1) {
// System.out.println(input.VJJunction);
// System.out.println(al.getFeature(GeneFeature.VJJunction).getSequence());
Assert.assertTrue(input.VJJunction.toString().contains(al.getFeature(GeneFeature.VJJunction).getSequence().toString()));
}
}
}
}
Aggregations