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
Added a new Walker
abstract class to be used for all built-in walkers.
#4964
Conversation
Codecov Report
@@ Coverage Diff @@
## master #4964 +/- ##
===============================================
- Coverage 86.832% 80.097% -6.734%
+ Complexity 32291 30641 -1650
===============================================
Files 1990 1991 +1
Lines 149107 149120 +13
Branches 16477 16477
===============================================
- Hits 129472 119441 -10031
- Misses 13622 23872 +10250
+ Partials 6013 5807 -206
|
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.
I known that @droazen asked for this in the Funcotator PR, but I would like to give my opition about this before: I think that it should not be recommended to overwrite, but it will be nice that a Walker
class can retrieve the reads/reference/features. For example, aLocusWalker
could access in the initialization the reference
to compute some statistic that will be use in each locus afterwards.
Otherwise, just one comment.
|
||
@Override | ||
final protected ReferenceDataSource getReferenceDataSource() { | ||
throw new GATKException("Should never access ReferenceDataSource in child classes of AssemblyRegionWalker."); |
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.
AssemblyRegionWalker
should be Walker
- here and below!
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.
Good catch!
Fixed!
Sorry for the multiple edits, something was wrong with my keyboard and it was submitting without my action. |
@magicDGS The problem with exposing the datasources to walkers is that they would be able to invalidate the entire traversal. For example, a This is why I feel strongly that the datasource objects should not be directly accessible to walker-based tools. Note that it's still possible for walkers to create their own, separate datasources without reaching into the ones used by the engine, or a tool author can extend |
I am aware that those methods should be definetively implemented in the abstract class - but it could be recommended NOT TO OVERRIDE unless you know what you are doing. I know the problems of having them exposed, but also I can see some potential to be accessible from an implemented walker when the user knows what is doing... |
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.
Back to @jonn-smith with my comments.
@@ -79,7 +78,7 @@ private void initializeDrivingFeatures() { | |||
* Subclasses can override to provide their own behavior but default implementation should be suitable for most uses. | |||
*/ | |||
@Override | |||
public void traverse() { | |||
public final void traverse() { |
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 final
conflicts with the "Subclasses can override to provide their own behavior" comment above. We typically don't make traverse()
final to allow for specializations of walker traversals (like TwoPassVariantWalker
overriding traverse()
from VariantWalker
). I think the comment should be modified to read:
"You should only override traverse() if you are writing a new walker base class in the engine package that extends this class. It is not meant to be overridden by tools outside of the engine package."
While you're at it, can you make the same change to the comments for traverse()
in the other walker base classes (and remove the finals).
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.
Fixed.
@@ -56,7 +54,7 @@ protected final void onStartup() { | |||
} | |||
|
|||
@Override | |||
public void traverse() { | |||
public final void traverse() { |
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.
As discussed above, don't make this final, but do add the comment "You should only override traverse() if you are writing a new walker base class in the engine package that extends this class. It is not meant to be overridden by tools outside of the engine package."
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.
Fixed.
@@ -146,7 +146,7 @@ protected final void onStartup() { | |||
* and including deletions only if {@link #includeDeletions()} returns {@code true}. | |||
*/ | |||
@Override | |||
public void traverse() { | |||
public final void traverse() { |
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.
As discussed above, don't make this final, but do modify the comment to read: "You should only override traverse() if you are writing a new walker base class in the engine package that extends this class. It is not meant to be overridden by tools outside of the engine package."
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.
Fixed
@@ -29,7 +24,7 @@ | |||
* ReadWalker authors must implement the apply() method to process each read, and may optionally implement | |||
* onTraversalStart() and/or onTraversalSuccess(). See the PrintReadsWithReference walker for an example. | |||
*/ | |||
public abstract class ReadWalker extends GATKTool { | |||
public abstract class ReadWalker extends Walker { |
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.
Update docs for ReadWalker.traverse()
to read "You should only override traverse() if you are writing a new walker base class in the engine package that extends this class. It is not meant to be overridden by tools outside of the engine package." instead of the current "Subclasses can override to provide own behavior"
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.
Fixed.
@@ -43,7 +39,7 @@ | |||
* Internally, the reads are loaded in chunks called read shards, which are then subdivided into active/inactive regions | |||
* for processing by the tool implementation. One read shard is created per contig. | |||
*/ | |||
public abstract class AssemblyRegionWalker extends GATKTool { | |||
public abstract class AssemblyRegionWalker extends Walker { |
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.
Update docs for AssemblyRegionWalker.traverse()
to read "You should only override traverse() if you are writing a new walker base class in the engine package that extends this class. It is not meant to be overridden by tools outside of the engine package." instead of the current "Subclasses can override to provide own behavior"
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.
Fixed.
|
||
@Override | ||
final protected ReadsDataSource getReadsDataSource() { | ||
throw new GATKException("Should never access ReadsDataSource in child classes of Walker."); |
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.
Change to: "Walker tools outside of the engine package should not directly access the engine reads datasource. They should get their reads data via apply() instead. Tools that need direct datasource access (eg., to implement custom traversal patterns) should extend GATKTool directly rather than a walker class, or introduce a new walker base class for the new traversal."
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.
Fixed.
|
||
@Override | ||
final protected FeatureManager getFeatureManager() { | ||
throw new GATKException("Should never access FeatureManager in child classes of Walker."); |
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.
Change to: "Walker tools outside of the engine package should not directly access the engine feature manager. They should get their feature data via apply() instead. Tools that need direct datasource access (eg., to implement custom traversal patterns) should extend GATKTool directly rather than a walker class, or introduce a new walker base class for the new traversal."
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.
Fixed.
*/ | ||
public abstract class Walker extends GATKTool { | ||
|
||
@Override |
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.
Add method-level javadoc comment stating that we are overriding this method to prevent walker tool implementations outside of the engine package from directly accessing the engine datasources, since walker tools should get their data via apply() instead.
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.
Fixed.
throw new GATKException("Should never access ReferenceDataSource in child classes of Walker."); | ||
} | ||
|
||
@Override |
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.
Add method-level javadoc comment stating that we are overriding this method to prevent walker tool implementations outside of the engine package from directly accessing the engine datasources, since walker tools should get their data via apply() instead.
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.
Fixed.
throw new GATKException("Should never access ReadsDataSource in child classes of Walker."); | ||
} | ||
|
||
@Override |
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.
Add method-level javadoc comment stating that we are overriding this method to prevent walker tool implementations outside of the engine package from directly accessing the engine datasources, since walker tools should get their data via apply() instead.
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.
Fixed.
* An abstract class to represent built-in walkers that inherit directly from {@link GATKTool}. | ||
* Created by jonn on 6/28/18. | ||
*/ | ||
public abstract class Walker extends GATKTool { |
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.
It might be good to rename this to WalkerBase
or AbstractWalker
. Walker sounds like a concrete class.
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.
WalkerBase
it is!
a870581
to
053d861
Compare
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.
I've pushed some final tweaks to the method-level docs into this branch, and will merge once tests pass.
f318ca6
to
0ea3c8c
Compare
Added the following methods to
GATKTool
:getReferenceDataSource()
getReadsDataSource()
getFeatureManager()
Walker
inherits directly fromGATKTool
and overrides these methods to throw an exception if they are called.No walker should need to directly access the data.