From 0b181be61fb06ead1fbee278a218f421232d0524 Mon Sep 17 00:00:00 2001 From: Ryan Poplin Date: Mon, 7 Nov 2011 15:25:16 -0500 Subject: [PATCH 01/11] Bug fix in SelectVariants when using a discordance track but no sample specifications. Added integration test to test this. --- .../gatk/walkers/variantutils/SelectVariants.java | 6 +++--- .../variantutils/SelectVariantsIntegrationTest.java | 13 +++++++++++++ 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java index 2e17d68d8..609593acc 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariants.java @@ -556,9 +556,9 @@ public class SelectVariants extends RodWalker { if (vc == null) return false; - // if we're not looking at specific samples then the absense of a compVC means discordance - if (NO_SAMPLES_SPECIFIED && (compVCs == null || compVCs.isEmpty())) - return true; + // if we're not looking at specific samples then the absence of a compVC means discordance + if (NO_SAMPLES_SPECIFIED) + return (compVCs == null || compVCs.isEmpty()); // check if we find it in the variant rod Map genotypes = vc.getGenotypes(samples); diff --git a/public/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariantsIntegrationTest.java b/public/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariantsIntegrationTest.java index e4ded491b..6e994be3a 100755 --- a/public/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariantsIntegrationTest.java +++ b/public/java/test/org/broadinstitute/sting/gatk/walkers/variantutils/SelectVariantsIntegrationTest.java @@ -64,6 +64,19 @@ public class SelectVariantsIntegrationTest extends WalkerTest { executeTest("testDiscordance--" + testFile, spec); } + @Test + public void testDiscordanceNoSampleSpecified() { + String testFile = validationDataLocation + "NA12878.hg19.example1.vcf"; + + WalkerTestSpec spec = new WalkerTestSpec( + "-T SelectVariants -R " + hg19Reference + " -L 20:1012700-1020000 --variant " + b37hapmapGenotypes + " -disc " + testFile + " -o %s -NO_HEADER", + 1, + Arrays.asList("5d7d899c0c4954ec59104aebfe4addd5") + ); + + executeTest("testDiscordanceNoSampleSpecified--" + testFile, spec); + } + @Test public void testConcordance() { String testFile = validationDataLocation + "NA12878.hg19.example1.vcf"; From b0e6afec48ca8d9451ed581f06d837a74e2a2592 Mon Sep 17 00:00:00 2001 From: Ryan Poplin Date: Tue, 8 Nov 2011 14:51:25 -0500 Subject: [PATCH 02/11] Bug fix for HMM optimization. Need to also check the gap continuation penalty array for the index with the first discrepancy. --- .../walkers/indels/PairHMMIndelErrorModel.java | 16 +++++++++------- 1 file changed, 9 insertions(+), 7 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/indels/PairHMMIndelErrorModel.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/indels/PairHMMIndelErrorModel.java index 11ff99ce3..ef1c14576 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/indels/PairHMMIndelErrorModel.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/indels/PairHMMIndelErrorModel.java @@ -528,10 +528,10 @@ public class PairHMMIndelErrorModel { } else { - byte[] readBases = Arrays.copyOfRange(unclippedReadBases,numStartClippedBases, + final byte[] readBases = Arrays.copyOfRange(unclippedReadBases,numStartClippedBases, unclippedReadBases.length-numEndClippedBases); - byte[] readQuals = Arrays.copyOfRange(unclippedReadQuals,numStartClippedBases, + final byte[] readQuals = Arrays.copyOfRange(unclippedReadQuals,numStartClippedBases, unclippedReadBases.length-numEndClippedBases); int j=0; @@ -540,6 +540,7 @@ public class PairHMMIndelErrorModel { double[][] matchMetricArray = null, XMetricArray = null, YMetricArray = null; byte[] previousHaplotypeSeen = null; double[] previousGOP = null; + double[] previousGCP = null; int startIdx; for (Allele a: haplotypeMap.keySet()) { @@ -555,7 +556,7 @@ public class PairHMMIndelErrorModel { long indStart = start - haplotype.getStartPosition(); long indStop = stop - haplotype.getStartPosition(); - byte[] haplotypeBases = Arrays.copyOfRange(haplotype.getBasesAsBytes(), + final byte[] haplotypeBases = Arrays.copyOfRange(haplotype.getBasesAsBytes(), (int)indStart, (int)indStop); double readLikelihood; @@ -572,13 +573,14 @@ public class PairHMMIndelErrorModel { if (previousHaplotypeSeen == null) startIdx = 0; else { - int s1 = computeFirstDifferingPosition(haplotypeBases, previousHaplotypeSeen); - int s2 = computeFirstDifferingPosition(currentContextGOP, previousGOP); - startIdx = Math.min(s1,s2); + final int s1 = computeFirstDifferingPosition(haplotypeBases, previousHaplotypeSeen); + final int s2 = computeFirstDifferingPosition(currentContextGOP, previousGOP); + final int s3 = computeFirstDifferingPosition(currentContextGCP, previousGCP); + startIdx = Math.min(Math.min(s1, s2), s3); } previousHaplotypeSeen = haplotypeBases.clone(); previousGOP = currentContextGOP.clone(); - + previousGCP = currentContextGCP.clone(); readLikelihood = computeReadLikelihoodGivenHaplotypeAffineGaps(haplotypeBases, readBases, readQuals, From e1b4c3968f7df4b4f50495b0ee15ab20f7c33ffd Mon Sep 17 00:00:00 2001 From: Mauricio Carneiro Date: Tue, 8 Nov 2011 16:50:03 -0500 Subject: [PATCH 04/11] Fixing GATKSAMRecord bug when constructing a GATKSAMRecord from scratch, we should set "mRestOfBinaryData" to null so the BAMRecord doesn't try to retrieve missing information from the non-existent bam file. --- .../org/broadinstitute/sting/utils/sam/GATKSAMRecord.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/utils/sam/GATKSAMRecord.java b/public/java/src/org/broadinstitute/sting/utils/sam/GATKSAMRecord.java index ede75817a..4c1cbf547 100755 --- a/public/java/src/org/broadinstitute/sting/utils/sam/GATKSAMRecord.java +++ b/public/java/src/org/broadinstitute/sting/utils/sam/GATKSAMRecord.java @@ -24,7 +24,10 @@ package org.broadinstitute.sting.utils.sam; -import net.sf.samtools.*; +import net.sf.samtools.BAMRecord; +import net.sf.samtools.SAMFileHeader; +import net.sf.samtools.SAMReadGroupRecord; +import net.sf.samtools.SAMRecord; import org.broadinstitute.sting.utils.NGSPlatform; import java.util.HashMap; @@ -83,7 +86,7 @@ public class GATKSAMRecord extends BAMRecord { read.getMateReferenceIndex(), read.getMateAlignmentStart(), read.getInferredInsertSize(), - new byte[]{}); + null); super.clearAttributes(); } From 091229e4dbf99666668ce8214f360e6138994fdb Mon Sep 17 00:00:00 2001 From: Christopher Hartl Date: Wed, 9 Nov 2011 11:03:29 -0500 Subject: [PATCH 05/11] MVLikelihoodRatio now checks if the family string is provided before attempting to instantiate. Also check that variant contexts have both genotypes and genotype likelihoods. Table codec now yells at users for not providing a HEADER with the table - parsing tables without a header line was causing the first line of the file to be eaten. Table feature now has a toString method. These are minor bug fixes. --- .../sting/gatk/walkers/annotator/MVLikelihoodRatio.java | 8 ++++---- .../sting/utils/codecs/table/TableCodec.java | 6 ++++++ .../sting/utils/codecs/table/TableFeature.java | 6 ++++++ 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MVLikelihoodRatio.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MVLikelihoodRatio.java index e0a2329f8..8da64608f 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MVLikelihoodRatio.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MVLikelihoodRatio.java @@ -33,7 +33,7 @@ public class MVLikelihoodRatio extends InfoFieldAnnotation implements Experiment public Map annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( mendelianViolation == null ) { - if ( walker instanceof VariantAnnotator ) { + if ( walker instanceof VariantAnnotator && ((VariantAnnotator) walker).familyStr != null) { mendelianViolation = new MendelianViolation(((VariantAnnotator)walker).familyStr, ((VariantAnnotator)walker).minGenotypeQualityP ); } else { @@ -42,9 +42,9 @@ public class MVLikelihoodRatio extends InfoFieldAnnotation implements Experiment } Map toRet = new HashMap(1); - boolean hasAppropriateGenotypes = vc.hasGenotype(mendelianViolation.getSampleChild()) && - vc.hasGenotype(mendelianViolation.getSampleDad()) && - vc.hasGenotype(mendelianViolation.getSampleMom()); + boolean hasAppropriateGenotypes = vc.hasGenotype(mendelianViolation.getSampleChild()) && vc.getGenotype(mendelianViolation.getSampleChild()).hasLikelihoods() && + vc.hasGenotype(mendelianViolation.getSampleDad()) && vc.getGenotype(mendelianViolation.getSampleDad()).hasLikelihoods() && + vc.hasGenotype(mendelianViolation.getSampleMom()) && vc.getGenotype(mendelianViolation.getSampleMom()).hasLikelihoods(); if ( hasAppropriateGenotypes ) toRet.put("MVLR",mendelianViolation.violationLikelihoodRatio(vc)); diff --git a/public/java/src/org/broadinstitute/sting/utils/codecs/table/TableCodec.java b/public/java/src/org/broadinstitute/sting/utils/codecs/table/TableCodec.java index 1919ccbf0..fac926587 100755 --- a/public/java/src/org/broadinstitute/sting/utils/codecs/table/TableCodec.java +++ b/public/java/src/org/broadinstitute/sting/utils/codecs/table/TableCodec.java @@ -86,7 +86,13 @@ public class TableCodec implements ReferenceDependentFeatureCodec { public Object readHeader(LineReader reader) { String line = ""; try { + boolean isFirst = true; while ((line = reader.readLine()) != null) { + System.out.println(line); + if ( isFirst && ! line.startsWith(headerDelimiter) ) { + throw new UserException.MalformedFile("TableCodec file does not have a header"); + } + isFirst &= false; if (line.startsWith(headerDelimiter)) { if (header.size() > 0) throw new IllegalStateException("Input table file seems to have two header lines. The second is = " + line); String spl[] = line.split(delimiterRegex); diff --git a/public/java/src/org/broadinstitute/sting/utils/codecs/table/TableFeature.java b/public/java/src/org/broadinstitute/sting/utils/codecs/table/TableFeature.java index a85849f0b..4b5c51bd4 100755 --- a/public/java/src/org/broadinstitute/sting/utils/codecs/table/TableFeature.java +++ b/public/java/src/org/broadinstitute/sting/utils/codecs/table/TableFeature.java @@ -1,7 +1,9 @@ package org.broadinstitute.sting.utils.codecs.table; + import org.broad.tribble.Feature; import org.broadinstitute.sting.utils.GenomeLoc; +import org.broadinstitute.sting.utils.Utils; import java.util.List; @@ -44,6 +46,10 @@ public class TableFeature implements Feature { return values.get(columnPosition); } + public String toString() { + return String.format("%s\t%s",position.toString(), Utils.join("\t",values)); + } + public String get(String columnName) { int position = keys.indexOf(columnName); if (position < 0) throw new IllegalArgumentException("We don't have a column named " + columnName); From 5eaf8002810237e3dfa67cf72a619a39c3cb45fd Mon Sep 17 00:00:00 2001 From: Christopher Hartl Date: Wed, 9 Nov 2011 11:22:20 -0500 Subject: [PATCH 06/11] a --- .../sting/gatk/walkers/annotator/MVLikelihoodRatio.java | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MVLikelihoodRatio.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MVLikelihoodRatio.java index 8da64608f..795c430bf 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MVLikelihoodRatio.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MVLikelihoodRatio.java @@ -33,8 +33,11 @@ public class MVLikelihoodRatio extends InfoFieldAnnotation implements Experiment public Map annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( mendelianViolation == null ) { - if ( walker instanceof VariantAnnotator && ((VariantAnnotator) walker).familyStr != null) { - mendelianViolation = new MendelianViolation(((VariantAnnotator)walker).familyStr, ((VariantAnnotator)walker).minGenotypeQualityP ); + if ( walker instanceof VariantAnnotator) { + if ( ((VariantAnnotator) walker).familyStr != null ) + mendelianViolation = new MendelianViolation(((VariantAnnotator)walker).familyStr, ((VariantAnnotator)walker).minGenotypeQualityP ); + else + return new HashMap(); } else { throw new UserException("Mendelian violation annotation can only be used from the Variant Annotator"); From d3a533b82e29d39d32af2c3a6992ef0a466ff09a Mon Sep 17 00:00:00 2001 From: Christopher Hartl Date: Wed, 9 Nov 2011 11:22:26 -0500 Subject: [PATCH 07/11] Revert "a" This reverts commit 1175f50ddbf389f5da74d27dc725596582ae15af. --- .../sting/gatk/walkers/annotator/MVLikelihoodRatio.java | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MVLikelihoodRatio.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MVLikelihoodRatio.java index 795c430bf..8da64608f 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MVLikelihoodRatio.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MVLikelihoodRatio.java @@ -33,11 +33,8 @@ public class MVLikelihoodRatio extends InfoFieldAnnotation implements Experiment public Map annotate(RefMetaDataTracker tracker, AnnotatorCompatibleWalker walker, ReferenceContext ref, Map stratifiedContexts, VariantContext vc) { if ( mendelianViolation == null ) { - if ( walker instanceof VariantAnnotator) { - if ( ((VariantAnnotator) walker).familyStr != null ) - mendelianViolation = new MendelianViolation(((VariantAnnotator)walker).familyStr, ((VariantAnnotator)walker).minGenotypeQualityP ); - else - return new HashMap(); + if ( walker instanceof VariantAnnotator && ((VariantAnnotator) walker).familyStr != null) { + mendelianViolation = new MendelianViolation(((VariantAnnotator)walker).familyStr, ((VariantAnnotator)walker).minGenotypeQualityP ); } else { throw new UserException("Mendelian violation annotation can only be used from the Variant Annotator"); From 11abb4f9d1173992d0576ee04db4c7c7cdaf5341 Mon Sep 17 00:00:00 2001 From: Christopher Hartl Date: Wed, 9 Nov 2011 11:25:28 -0500 Subject: [PATCH 08/11] Better error message. --- .../sting/gatk/walkers/annotator/MVLikelihoodRatio.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MVLikelihoodRatio.java b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MVLikelihoodRatio.java index 8da64608f..bd0d4e3fb 100755 --- a/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MVLikelihoodRatio.java +++ b/public/java/src/org/broadinstitute/sting/gatk/walkers/annotator/MVLikelihoodRatio.java @@ -37,7 +37,7 @@ public class MVLikelihoodRatio extends InfoFieldAnnotation implements Experiment mendelianViolation = new MendelianViolation(((VariantAnnotator)walker).familyStr, ((VariantAnnotator)walker).minGenotypeQualityP ); } else { - throw new UserException("Mendelian violation annotation can only be used from the Variant Annotator"); + throw new UserException("Mendelian violation annotation can only be used from the Variant Annotator, and must be provided a valid Family String file (-family) on the command line."); } } From 9427ada49839bde78037dc63dd938c62f7afb07a Mon Sep 17 00:00:00 2001 From: Mauricio Carneiro Date: Wed, 9 Nov 2011 12:15:54 -0500 Subject: [PATCH 09/11] Fixing no cigar bug empty GATKSAMRecords will have a null cigar. Treat them accordingly. --- .../sting/utils/clipreads/ReadClipper.java | 20 +++++++++---------- .../sting/utils/sam/GATKSAMRecord.java | 4 ++++ 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/utils/clipreads/ReadClipper.java b/public/java/src/org/broadinstitute/sting/utils/clipreads/ReadClipper.java index a6df986ba..6e4ddddc4 100644 --- a/public/java/src/org/broadinstitute/sting/utils/clipreads/ReadClipper.java +++ b/public/java/src/org/broadinstitute/sting/utils/clipreads/ReadClipper.java @@ -58,15 +58,6 @@ public class ReadClipper { return hardClipByReferenceCoordinates(refStart, -1); } - private int numDeletions(GATKSAMRecord read) { - int result = 0; - for (CigarElement e: read.getCigar().getCigarElements()) { - if ( e.getOperator() == CigarOperator.DELETION || e.getOperator() == CigarOperator.D ) - result =+ e.getLength(); - } - return result; - } - protected GATKSAMRecord hardClipByReferenceCoordinates(int refStart, int refStop) { int start = (refStart < 0) ? 0 : ReadUtils.getReadCoordinateForReferenceCoordinate(read, refStart, ReadUtils.ClippingTail.RIGHT_TAIL); int stop = (refStop < 0) ? read.getReadLength() - 1 : ReadUtils.getReadCoordinateForReferenceCoordinate(read, refStop, ReadUtils.ClippingTail.LEFT_TAIL); @@ -90,7 +81,7 @@ public class ReadClipper { @Requires("left <= right") public GATKSAMRecord hardClipBothEndsByReferenceCoordinates(int left, int right) { - if (left == right) + if (read.isEmpty() || left == right) return new GATKSAMRecord(read.getHeader()); GATKSAMRecord leftTailRead = hardClipByReferenceCoordinates(right, -1); @@ -104,6 +95,9 @@ public class ReadClipper { } public GATKSAMRecord hardClipLowQualEnds(byte lowQual) { + if (read.isEmpty()) + return read; + byte [] quals = read.getBaseQualities(); int leftClipIndex = 0; int rightClipIndex = read.getReadLength() - 1; @@ -126,6 +120,9 @@ public class ReadClipper { } public GATKSAMRecord hardClipSoftClippedBases () { + if (read.isEmpty()) + return read; + int readIndex = 0; int cutLeft = -1; // first position to hard clip (inclusive) int cutRight = -1; // first position to hard clip (inclusive) @@ -182,6 +179,9 @@ public class ReadClipper { } public GATKSAMRecord hardClipLeadingInsertions() { + if (read.isEmpty()) + return read; + for(CigarElement cigarElement : read.getCigar().getCigarElements()) { if (cigarElement.getOperator() != CigarOperator.HARD_CLIP && cigarElement.getOperator() != CigarOperator.SOFT_CLIP && cigarElement.getOperator() != CigarOperator.INSERTION && cigarElement.getOperator() != CigarOperator.DELETION) diff --git a/public/java/src/org/broadinstitute/sting/utils/sam/GATKSAMRecord.java b/public/java/src/org/broadinstitute/sting/utils/sam/GATKSAMRecord.java index 4c1cbf547..63a618aed 100755 --- a/public/java/src/org/broadinstitute/sting/utils/sam/GATKSAMRecord.java +++ b/public/java/src/org/broadinstitute/sting/utils/sam/GATKSAMRecord.java @@ -237,4 +237,8 @@ public class GATKSAMRecord extends BAMRecord { // note that we do not consider the GATKSAMRecord internal state at all return super.equals(o); } + + public boolean isEmpty() { + return this.getReadLength() == 0; + } } From f9530e07683250cc2da6e2b178dc3d07230dce00 Mon Sep 17 00:00:00 2001 From: Mauricio Carneiro Date: Wed, 9 Nov 2011 12:37:14 -0500 Subject: [PATCH 10/11] Clean unnecessary attributes from the read this gives on average 40% file size reduction. --- .../org/broadinstitute/sting/utils/sam/GATKSAMRecord.java | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/public/java/src/org/broadinstitute/sting/utils/sam/GATKSAMRecord.java b/public/java/src/org/broadinstitute/sting/utils/sam/GATKSAMRecord.java index 63a618aed..d36ec3411 100755 --- a/public/java/src/org/broadinstitute/sting/utils/sam/GATKSAMRecord.java +++ b/public/java/src/org/broadinstitute/sting/utils/sam/GATKSAMRecord.java @@ -241,4 +241,10 @@ public class GATKSAMRecord extends BAMRecord { public boolean isEmpty() { return this.getReadLength() == 0; } + + public void simplify () { + GATKSAMReadGroupRecord rg = getReadGroup(); + this.clearAttributes(); + setReadGroup(rg); + } } From f080f64f99423bdb75d047843ed75499862fb1fe Mon Sep 17 00:00:00 2001 From: Mauricio Carneiro Date: Wed, 9 Nov 2011 12:46:27 -0500 Subject: [PATCH 11/11] Preserve RG information on new GATKSAMRecord from SAMRecord --- .../sting/utils/sam/GATKSAMRecord.java | 64 +++++++++++++------ 1 file changed, 43 insertions(+), 21 deletions(-) diff --git a/public/java/src/org/broadinstitute/sting/utils/sam/GATKSAMRecord.java b/public/java/src/org/broadinstitute/sting/utils/sam/GATKSAMRecord.java index d36ec3411..9e07b1112 100755 --- a/public/java/src/org/broadinstitute/sting/utils/sam/GATKSAMRecord.java +++ b/public/java/src/org/broadinstitute/sting/utils/sam/GATKSAMRecord.java @@ -87,7 +87,12 @@ public class GATKSAMRecord extends BAMRecord { read.getMateAlignmentStart(), read.getInferredInsertSize(), null); - super.clearAttributes(); + SAMReadGroupRecord samRG = read.getReadGroup(); + clearAttributes(); + if (samRG != null) { + GATKSAMReadGroupRecord rg = new GATKSAMReadGroupRecord(samRG); + setReadGroup(rg); + } } public GATKSAMRecord(final SAMFileHeader header, @@ -134,6 +139,21 @@ public class GATKSAMRecord extends BAMRecord { return mReadGroup; } + @Override + public int hashCode() { + return super.hashCode(); + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + + if (!(o instanceof GATKSAMRecord)) return false; + + // note that we do not consider the GATKSAMRecord internal state at all + return super.equals(o); + } + /** * Efficient caching accessor that returns the GATK NGSPlatform of this read * @return @@ -147,11 +167,9 @@ public class GATKSAMRecord extends BAMRecord { retrievedReadGroup = true; } - // - // - // Reduced read functions - // - // + /////////////////////////////////////////////////////////////////////////////// + // *** ReduceReads functions ***// + /////////////////////////////////////////////////////////////////////////////// public byte[] getReducedReadCounts() { if ( ! retrievedReduceReadCounts ) { @@ -170,6 +188,12 @@ public class GATKSAMRecord extends BAMRecord { return getReducedReadCounts()[i]; } + + /////////////////////////////////////////////////////////////////////////////// + // *** GATKSAMRecord specific methods ***// + /////////////////////////////////////////////////////////////////////////////// + + /** * Checks whether an attribute has been set for the given key. * @@ -223,28 +247,26 @@ public class GATKSAMRecord extends BAMRecord { return null; } - @Override - public int hashCode() { - return super.hashCode(); - } - - @Override - public boolean equals(Object o) { - if (this == o) return true; - - if (!(o instanceof GATKSAMRecord)) return false; - - // note that we do not consider the GATKSAMRecord internal state at all - return super.equals(o); - } - + /** + * Checks whether if the read has any bases. + * + * Empty reads can be dangerous as it may have no cigar strings, no read names and + * other missing attributes. + * + * @return true if the read has no bases + */ public boolean isEmpty() { return this.getReadLength() == 0; } + /** + * Clears all attributes except ReadGroup of the read. + */ public void simplify () { GATKSAMReadGroupRecord rg = getReadGroup(); this.clearAttributes(); setReadGroup(rg); } + + }