Search in sources :

Example 1 with VDJCPartitionedSequence

use of com.milaboratory.mixcr.basictypes.VDJCPartitionedSequence in project mixcr by milaboratory.

the class FullSeqAssembler method toPointSequences.

List<PointSequence> toPointSequences(VDJCAlignments alignments, int iTarget) {
    // 
    // N_LEFT_DUMMIES     assemblingFeatureLength
    // ------|--------------|--------------|------------------------>
    // ↓              ↓              ↓
    // 0000000vvvvvvvvvvvvvvCDR3CDR3CDR3CDR3jjjjjjjjjjjjjjjjCCCCCCCCC
    VDJCPartitionedSequence target = alignments.getPartitionedTarget(iTarget);
    NSequenceWithQuality targetSeq = alignments.getTarget(iTarget);
    VDJCHit vHit = alignments.getBestHit(Variable);
    Alignment<NucleotideSequence> vAlignment = (vHit == null || vHit.getAlignment(iTarget) == null || !Objects.equals(genes.v, vHit.getGene()) || vHit.getAlignment(iTarget).getSequence1Range().getFrom() > lengthV) ? null : vHit.getAlignment(iTarget);
    VDJCHit jHit = alignments.getBestHit(Joining);
    Alignment<NucleotideSequence> jAlignment = (jHit == null || jHit.getAlignment(iTarget) == null || !Objects.equals(genes.j, jHit.getGene()) || jHit.getAlignment(iTarget).getSequence1Range().getTo() < jOffset) ? null : jHit.getAlignment(iTarget);
    List<PointSequence> points = new ArrayList<>();
    if (target.getPartitioning().isAvailable(assemblingFeature.getFirstPoint())) {
        // This target contains left edge of the assembling feature
        int leftStop = target.getPartitioning().getPosition(assemblingFeature.getFirstPoint());
        if (hasV) {
            if (vAlignment != null)
                toPointSequencesByAlignments(points, vAlignment, targetSeq, new Range(parameters.alignedRegionsOnly ? vAlignment.getSequence2Range().getFrom() : 0, leftStop), N_LEFT_DUMMIES);
        } else if (!parameters.alignedRegionsOnly)
            toPointSequencesNoAlignments(points, targetSeq, new Range(0, leftStop), N_LEFT_DUMMIES - leftStop);
    } else if (hasV && vAlignment != null)
        // This target ends before beginning (left edge) of the assembling feature
        toPointSequencesByAlignments(points, vAlignment, targetSeq, new Range(parameters.alignedRegionsOnly ? vAlignment.getSequence2Range().getFrom() : 0, vAlignment.getSequence2Range().getTo()), N_LEFT_DUMMIES);
    if (target.getPartitioning().isAvailable(assemblingFeature.getLastPoint())) {
        // This target contains right edge of the assembling feature
        int rightStart = target.getPartitioning().getPosition(assemblingFeature.getLastPoint());
        if (hasJ) {
            if (jAlignment != null)
                toPointSequencesByAlignments(points, jAlignment, targetSeq, new Range(rightStart, parameters.alignedRegionsOnly ? jAlignment.getSequence2Range().getTo() : targetSeq.size()), N_LEFT_DUMMIES + lengthV + assemblingFeatureLength - jOffset);
        } else
            toPointSequencesNoAlignments(points, targetSeq, new Range(rightStart, targetSeq.size()), N_LEFT_DUMMIES + lengthV + assemblingFeatureLength - rightStart);
    } else if (hasJ && jAlignment != null)
        // This target starts after the end (right edge) of the assembling feature
        toPointSequencesByAlignments(points, jAlignment, targetSeq, new Range(jAlignment.getSequence2Range().getFrom(), parameters.alignedRegionsOnly ? jAlignment.getSequence2Range().getTo() : targetSeq.size()), N_LEFT_DUMMIES + lengthV + assemblingFeatureLength - jOffset);
    return points;
}
Also used : VDJCPartitionedSequence(com.milaboratory.mixcr.basictypes.VDJCPartitionedSequence) Range(com.milaboratory.core.Range) VDJCHit(com.milaboratory.mixcr.basictypes.VDJCHit)

Aggregations

Range (com.milaboratory.core.Range)1 VDJCHit (com.milaboratory.mixcr.basictypes.VDJCHit)1 VDJCPartitionedSequence (com.milaboratory.mixcr.basictypes.VDJCPartitionedSequence)1