New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Removed plain assert
s and replaced them with ValidationUtil function
#1465
Conversation
…ions. - some asserts remain, but they have been fixed in a different PR.
8ba675b
to
daead95
Compare
Yes... asserts are evil. |
feel free to review this @lbergelson .... |
@@ -45,7 +47,7 @@ | |||
public static TruthState getHom(final int alleleIdx) { | |||
if (alleleIdx == 0) return HOM_REF; | |||
if (alleleIdx == 1) return HOM_VAR1; | |||
assert false; | |||
ValidationUtils.validateArg(false,"Shouldn't be here."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In this case, why not throw new PicardException("Invalid allele index: " + alleleIdx);
? This doesn't seem like a proper use of validateArg()
.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yfarjoun Wait, I lied, you didn't respond to Phil here.
@@ -186,7 +187,7 @@ protected WgsMetrics generateWgsMetrics(final IntervalList intervals, | |||
|
|||
@Override | |||
protected WgsMetricsCollector getCollector(final int coverageCap, final IntervalList intervals) { | |||
assert(coverageCap == this.collector.coverageCap); | |||
ValidationUtils.validateArg(coverageCap == this.collector.coverageCap,()->"coverageCap has to be the same as the internal coverageCap, found " + coverageCap + " and " + this.collector.coverageCap); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please reformat the changed lines in the IDE. In this case I would expect to see spaces around the ->
operator, and the line length seems long to me.
* one or two of them, depending on whether it's a paired-end read. This relies on the unmapped | ||
* BAM file having all paired reads together in order. | ||
*/ | ||
public class BamToBfqWriter { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Did you mean to delete this class? This seems unrelated to your other changes, and maybe deserves its own PR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this seemed to have been due to the rebase...I didn't do it...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yfarjoun I agree with @pshapiro4broad 👍 after resolving the minor issues.
@@ -948,7 +949,7 @@ private void doTest(final String[] args, final File metrics, final int expectedR | |||
|
|||
} catch (NoSuchFieldException e) { | |||
e.printStackTrace(); | |||
assert false; | |||
ValidationUtils.validateArg(false,"Shouldn't be here."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
just throw here
@@ -56,7 +58,7 @@ public static TruthState getVar(final int allele0idx, final int allele1idx) { | |||
if (allele0idx == 1 && allele1idx == 2) return HET_VAR1_VAR2; | |||
if (allele0idx == 2 && allele1idx == 1) return HET_VAR1_VAR2; | |||
|
|||
assert false; | |||
ValidationUtils.validateArg(false,"Shouldn't be here."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just throw if we shouldn't be here.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same
// adjust to a shorter length iff clipping tag exists | ||
Integer trimPoint = rec.getIntegerAttribute(ReservedTagConstants.XT); | ||
if (trimPoint != null) { | ||
ValidationUtils.validateArg(rec.getReadLength() == seqs.length, () -> "length of read and seqs differ. Found " + rec.getReadLength() + " and '" + seqs.length + "."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is the actual change in the file...everything else is due to newline differences.....
since I added a commit...I cannot merge without another review.... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yfarjoun Looks good, although something funky is going on with the BamToBfqWriter. I it supposed to be deleted in master?
@@ -109,8 +111,7 @@ public static CallState getHom(final int alleleIdx) { | |||
if (alleleIdx == 2) return HOM_VAR2; | |||
if (alleleIdx == 3) return HOM_VAR3; | |||
|
|||
assert false; | |||
return null; | |||
throw new IllegalStateException("Shouldn't be here."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here
@@ -124,22 +125,22 @@ public static CallState getHet(int allele0idx, int allele1idx) { | |||
if (allele1idx == 1) return HET_REF_VAR1; | |||
if (allele1idx == 2) return HET_REF_VAR2; | |||
if (allele1idx == 3) return HET_REF_VAR3; | |||
assert false; | |||
ValidationUtils.validateArg(false,"Shouldn't be here."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
to
return null; | ||
} | ||
|
||
//HET CASES | ||
if(allele0idx == 1) { | ||
if (allele1idx == 2) return HET_VAR1_VAR2; | ||
if (allele1idx == 3) return HET_VAR1_VAR3; | ||
assert false; | ||
ValidationUtils.validateArg(false,"Shouldn't be here."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
and
return null; | ||
} | ||
|
||
if(allele0idx == 2 && allele1idx == 3) return HET_VAR3_VAR4; //special case not a mistake. | ||
if(allele0idx == 3 && allele1idx == 4) return HET_VAR3_VAR4; | ||
|
||
assert false; | ||
ValidationUtils.validateArg(false,"Shouldn't be here."); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@yfarjoun Missed a set of comments
thanks @lbergelson fixed. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks good. Some (maybe) unused imports to clean up.
@@ -1,5 +1,7 @@ | |||
package picard.vcf; | |||
|
|||
import htsjdk.utils.ValidationUtils; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import is now unused?
@@ -3,6 +3,7 @@ | |||
import htsjdk.samtools.SamReader; | |||
import htsjdk.samtools.metrics.MetricsFile; | |||
import htsjdk.samtools.util.IOUtil; | |||
import htsjdk.utils.ValidationUtils; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also unused import
Description
Give your PR a concise yet descriptive title
Please explain the changes you made here.
Explain the motivation for making this change. What existing problem does the pull request solve?
Mention any issues fixed, addressed or otherwise related to this pull request, including issue numbers or hard links for issues in other repos.
You can delete these instructions once you have written your PR description.
Checklist (never delete this)
Never delete this, it is our record that procedure was followed. If you find that for whatever reason one of the checklist points doesn't apply to your PR, you can leave it unchecked but please add an explanation below.
Content
Review
For more detailed guidelines, see https://github.com/broadinstitute/picard/wiki/Guidelines-for-pull-requests