@Override public int hashCode() { return getReadName().hashCode(); }
/** * Creates a hard-clipped view on a existing read record. * @param read the underlying unclipped read. * @param start inclusive first position in {@code read} included in the clipped view. * @param end inclusive last position in {@code read} included in the clipped view. */ public ClippedGATKSAMRecord(final GATKSAMRecord read, int start, int end) { super(read.getHeader()); this.setReferenceIndex(read.getReferenceIndex()); this.setAlignmentStart(read.getAlignmentStart() + start); this.setMappingQuality(100); // setting read indexing bin below this.setFlags(read.getFlags()); this.setMateReferenceIndex(read.getMateReferenceIndex()); this.setMateAlignmentStart(read.getMateAlignmentStart()); this.setInferredInsertSize(read.getInferredInsertSize()); this.setReadBases(Arrays.copyOfRange(read.getReadBases(), start, end)); this.setBaseQualities(Arrays.copyOfRange(read.getBaseQualities(),start,end)); this.setReadName(read.getReadName()); insertionQuals = Arrays.copyOfRange(read.getBaseInsertionQualities(),start,end); deletionQuals = Arrays.copyOfRange(read.getBaseDeletionQualities(),start,end); // Set these to null in order to mark them as being candidates for lazy initialization. // If this is not done, they will have non-null defaults. super.setReadName(null); super.setCigarString(null); super.setReadBases(null); super.setBaseQualities(null); // Do this after the above because setCigarString will clear it. GATKBin.setReadIndexingBin(this, -1); }
/** * Returns the reads clipped at their anchors. * * @param reads target reads. * @return never {@code null}. */ protected Map<GATKSAMRecord, GATKSAMRecord> anchorClippedReads(final HaplotypeGraph haplotypeGraph, final List<GATKSAMRecord> reads) { final Map<GATKSAMRecord, GATKSAMRecord> result = new HashMap<>(reads.size()); for (final GATKSAMRecord r : reads) { final ReadAnchoring anchoring = new ReadAnchoring(r,haplotypeGraph); if (anchoring.isAnchoredSomewhere()) continue; final int start = anchoring.leftAnchorIndex; final int end = anchoring.rightAnchorIndex + haplotypeGraph.getKmerSize(); final GATKSAMRecord clipped = new ClippedGATKSAMRecord(r, start, end); result.put(r, clipped); } return result; }
@Override public boolean equals(Object o) { if (o instanceof GATKSAMRecord) { return getReadName().equals(((GATKSAMRecord)o).getReadName()); } else { return false; } }