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

Add registry for deprecated tools and annotations. #4505

Merged
merged 1 commit into from
Mar 20, 2018
Merged

Conversation

cmnbroad
Copy link
Collaborator

@cmnbroad cmnbroad commented Mar 7, 2018

We should be able to use this single implementation to satisfy both #4347 and #4351.

Questions: @vdauwera What other tools that were dropped from GATK3 should be added to the list now? GATK3 also has a deprecated annotations list, which is included here, but is empty. Are there any annotations that should be listed ? I can't really implement/test that part unless I populate it with something.

Also, trying to run a missing tool is currently handled as an error, and surfaces in the context of a usage message. Perhaps that hides it too much:

screen shot 2018-03-07 at 11 25 40 am

@codecov-io
Copy link

codecov-io commented Mar 7, 2018

Codecov Report

Merging #4505 into master will decrease coverage by 0.229%.
The diff coverage is 87.5%.

@@               Coverage Diff               @@
##              master     #4505       +/-   ##
===============================================
- Coverage     79.119%   78.891%   -0.229%     
- Complexity     16677     16775       +98     
===============================================
  Files           1051      1051               
  Lines          60285     60916      +631     
  Branches        9875     10060      +185     
===============================================
+ Hits           47697     48057      +360     
- Misses          8760      9014      +254     
- Partials        3828      3845       +17
Impacted Files Coverage Δ Complexity Δ
...stitute/hellbender/cmdline/CommandLineProgram.java 82.432% <ø> (ø) 43 <0> (ø) ⬇️
.../main/java/org/broadinstitute/hellbender/Main.java 72.637% <100%> (+0.698%) 48 <3> (+3) ⬆️
...ellbender/cmdline/DeprecatedArtifactsRegistry.java 81.818% <81.818%> (ø) 3 <3> (?)
...ignment/AssemblyContigWithFineTunedAlignments.java 53.595% <0%> (-1.961%) 34% <0%> (+11%)
...der/engine/spark/datasources/ReadsSparkSource.java 80.198% <0%> (-1.853%) 38% <0%> (-6%)
...der/tools/spark/sv/discovery/SvDiscoveryUtils.java 7.143% <0%> (-1.19%) 3% <0%> (+1%)
...r/tools/walkers/mutect/Mutect2FilteringEngine.java 81.6% <0%> (-1.159%) 36% <0%> (-4%)
.../walkers/mutect/GermlineProbabilityCalculator.java 89.286% <0%> (-1.037%) 9% <0%> (-3%)
...lbender/utils/variant/GATKVariantContextUtils.java 83.52% <0%> (-0.8%) 215% <0%> (-1%)
...ark/sv/discovery/inference/CpxVariantDetector.java 1.835% <0%> (-0.769%) 2% <0%> (ø)
... and 29 more

@@ -480,6 +481,10 @@ public static String getUnknownCommandMessage(final Set<Class<?>> classes, final
int bestDistance = Integer.MAX_VALUE;
int bestN = 0;

final String deprecationMessage = DeprecatedArtifactsRegistry.getToolDeprecationInfo(command);
Copy link
Contributor

Choose a reason for hiding this comment

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

Please, make this configurable outside the getUnknownCommandMessage to override by downstream toolkits (if someone is trying to run IndelRealignment on my toolkit, I would like to throw an error saying that it does not exists but not that it is not included in GATK4 but I would like still to have the code for searching for similar commands...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks!

static {
// Indicate version in which the tool disappeared, and recommended replacement in parentheses if applicable
deprecatedTools.put("IndelRealigner", new Tuple2<>("4.0.0.0", "Please use GATK3 to run this tool"));
deprecatedTools.put("RealignerTargetCreator", new Tuple2<>("4.0.0.0", "Please use GATK3 to run this tool"));
Copy link
Contributor

Choose a reason for hiding this comment

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

If these tools are going to be included after I implement them, saying that they are deprecated might be a strong statement: maybe a distinction between "not supported yet (but probably future support)" and "deprecated" is a better idea. Otherwise, if they are included again after version x.x.x.x, this message in previous version will be weird.

An idea might be to include a placeholder command line programs that just throw an "unsupported in the current version" for that kind of tools and annotated with @ExperimentalFeature, for example. Anyway, I hope to have IndelRealignment sooner than later...

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

I think these messages should reflect the current state, rather than speculate about the future. Hopefully we can get these tools ported; at that point we can remove them from this list.

Copy link
Contributor

Choose a reason for hiding this comment

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

Fair enough.

*
* @param toolName the tool class name (not the full package) to check
*/
public static String getToolDeprecationInfo(final String toolName) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe instead of handle this here, a method to throw a new UserException in main if it is in the deprecation registry may be more informative and will handle common message....

* be added to this list to issue a message when the user tries to run that tool.
*
* NOTE: Picard tools should be listed here as well, since by definition such tools will not be found in
* the Picard jar.
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe a registry in Picard that can add on runtime values will be helpful. The same for dowsntream tools...

Copy link
Collaborator Author

@cmnbroad cmnbroad Mar 8, 2018

Choose a reason for hiding this comment

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

Unfortunately we'll probably have to duplicate this in picard as well. If and when picard has such a thing we can consider integrating it here. for downstream toolkits, getUnknownCommand is overridable now, which I think will allow you the flexibility to do whatever integration you want.

@droazen droazen requested a review from vdauwera March 7, 2018 18:44

// Mapping from tool name to string describing the major version number where the tool first disappeared and
// optional recommended alternatives
private static Map<String, Tuple2<String, String>> deprecatedTools = new HashMap<>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Use org.apache.commons.lang3.tuple.Pair instead of Scala Tuple2

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

deprecatedTools.put("RealignerTargetCreator", new Tuple2<>("4.0.0.0", "Please use GATK3 to run this tool"));
}

// Mapping from walker name to major version number where the walker first disappeared and optional replacement options
Copy link
Collaborator

Choose a reason for hiding this comment

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

walker -> annotation

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Removed completely.

}

// Mapping from walker name to major version number where the walker first disappeared and optional replacement options
private static Map<String, String> deprecatedAnnotations = new HashMap<>();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Remove deprecatedAnnotations for now until there's a formal request for this feature.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

*/
public static String getToolDeprecationInfo(final String toolName) {
return deprecatedTools.containsKey(toolName) ?
String.format("%s is no longer included in GATK as of version %s. (%s)",
Copy link
Collaborator

Choose a reason for hiding this comment

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

(%s) -> %s

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

() -> new Main().instanceMain( new String[] {missingTool} )
);
Assert.assertTrue(e.getMessage().contains(DeprecatedArtifactsRegistry.getToolDeprecationInfo(missingTool)));
}
Copy link
Collaborator

Choose a reason for hiding this comment

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

Add a second test for a tool that doesn't exist and is not in the registry.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

* NOTE: Picard tools should be listed here as well, since by definition such tools will not be found in
* the Picard jar.
*/
public class DeprecatedArtifactsRegistry {
Copy link
Collaborator

Choose a reason for hiding this comment

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

MissingToolsRegistry ?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Copy link
Collaborator

@droazen droazen left a comment

Choose a reason for hiding this comment

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

Review complete, back to @cmnbroad. Merge after addressing comments.

static {
// Indicate version in which the tool disappeared, and recommended replacement in parentheses if applicable
deprecatedTools.put("IndelRealigner", Pair.of("4.0.0.0", "Please use GATK3 to run this tool"));
deprecatedTools.put("RealignerTargetCreator", Pair.of("4.0.0.0", "Please use GATK3 to run this tool"));
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

@vdauwera Anything else that you want on this list before I merge this PR ?

@cmnbroad cmnbroad merged commit 5127367 into master Mar 20, 2018
@cmnbroad cmnbroad deleted the cn_tool_registry branch March 20, 2018 18:55
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.

4 participants