Skip to content
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

Protection against using the wrong sample alias which produces zero L… #1242

Merged
merged 6 commits into from Oct 23, 2018

Conversation

yfarjoun
Copy link
Contributor

…OD. Now the tool will fail (i.e. return 1)

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

  • Added or modified tests to cover changes and any new functionality
  • Edited the README / documentation (if applicable)
  • All tests passing on Travis

Review

  • Final thumbs-up from reviewer
  • Rebase, squash and reword as applicable

For more detailed guidelines, see https://github.com/broadinstitute/picard/wiki/Guidelines-for-pull-requests

@coveralls
Copy link

Coverage Status

Coverage increased (+0.005%) to 81.381% when pulling 3eeec7d on yf_error_when_no_data_FP into 1329b5c on master.

@coveralls
Copy link

coveralls commented Oct 17, 2018

Coverage Status

Coverage increased (+0.02%) to 81.394% when pulling b024781 on yf_error_when_no_data_FP into 1329b5c on master.

@@ -365,11 +366,22 @@ protected int doWork() {

summaryFile.addMetric(metrics);
log.info("Read Group: " + metrics.READ_GROUP + " / " + observedSampleAlias + " vs. " + metrics.SAMPLE + ": LOD = " + metrics.LOD_EXPECTED_SAMPLE);
if (metrics.LOD_EXPECTED_SAMPLE!=0) {
anyNonzeroLod |= true;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The bitwise |= here isn't necessary. The RHS of the statement is always true, so a simple = would suffice. Also, if we don't care about writing the metrics files in the case of this error, we can just output the error log from below and return 1

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

"...and return 1" in what case? I am erroring out when I fail to find a non-zero LOD for all the FPs in the loop....so I need to wait until I'm out of the loop

src/main/java/picard/fingerprint/CheckFingerprint.java Outdated Show resolved Hide resolved
src/main/java/picard/fingerprint/CheckFingerprint.java Outdated Show resolved Hide resolved
@@ -366,16 +368,15 @@ protected int doWork() {

summaryFile.addMetric(metrics);
log.info("Read Group: " + metrics.READ_GROUP + " / " + observedSampleAlias + " vs. " + metrics.SAMPLE + ": LOD = " + metrics.LOD_EXPECTED_SAMPLE);
if (metrics.LOD_EXPECTED_SAMPLE!=0) {
anyNonzeroLod |= true;
if (metrics.LOD_EXPECTED_SAMPLE != 0) {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you could write

anyNonzeroLod |= metrics.LOD_EXPECTED_SAMPLE != 0;

(also, I think the proper spelling is anyNonZeroLod as non-zero is a hyphenated word)

Conversely avoiding negatives would make this a bit nicer, IMO, e.g.

allZeroLod &= metrics.LOD_EXPECTED_SAMPLE == 0;
...
if (allZeroLod) {

I find reading code with double negatives like !anyNonZeroLod to be unnecessarily confusing. The same is true of the text No Non-zero results found.

@@ -224,7 +224,9 @@ protected int doWork() {
outputDetailMetricsFile = DETAIL_OUTPUT;
outputSummaryMetricsFile = SUMMARY_OUTPUT;
} else {
if (!OUTPUT.endsWith(".")) OUTPUT = OUTPUT + ".";
if (!OUTPUT.endsWith(".")) {
OUTPUT = OUTPUT + ".";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
OUTPUT = OUTPUT + ".";
OUTPUT += ".";

@@ -268,38 +268,38 @@ protected int doWork() {
// Key: previous PG ID on a SAM Record (or null). Value: New PG ID to replace it.
final Map<String, String> chainedPgIds = getChainedPgIds(outputHeader);

final SAMFileWriter out = new SAMFileWriterFactory().makeSAMOrBAMWriter(outputHeader,
try(SAMFileWriter out = new SAMFileWriterFactory().makeSAMOrBAMWriter(outputHeader,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
try(SAMFileWriter out = new SAMFileWriterFactory().makeSAMOrBAMWriter(outputHeader,
try (SAMFileWriter out = new SAMFileWriterFactory().makeSAMOrBAMWriter(outputHeader,

@yfarjoun yfarjoun merged commit dd22493 into master Oct 23, 2018
@kbergin kbergin deleted the yf_error_when_no_data_FP branch March 13, 2019 19:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants