Skip to content

Commit

Permalink
adding doc strings
Browse files Browse the repository at this point in the history
  • Loading branch information
lbergelson committed Aug 16, 2024
1 parent 231be5a commit e96d439
Showing 1 changed file with 23 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import htsjdk.variant.variantcontext.VariantContext;
import htsjdk.variant.variantcontext.writer.VariantContextWriter;
import htsjdk.variant.vcf.VCFHeader;
import org.broadinstitute.barclay.argparser.CommandLineParser;
import org.broadinstitute.hellbender.utils.SimpleInterval;
import org.broadinstitute.hellbender.utils.Utils;

Expand All @@ -19,12 +20,13 @@ public class IntervalFilteringVcfWriter implements VariantContextWriter {
/**
* Comparison modes which allow matching intervals in different ways.
*/
public enum Mode {
public enum Mode implements CommandLineParser.ClpEnum {

/**
* Matches if the query starts within any of the given intervals.
*/
STARTS_IN{
STARTS_IN("starts within any of the given intervals"){

@Override
boolean test(OverlapDetector<? extends Locatable> detector, final VariantContext query) {
final SimpleInterval startPosition = new SimpleInterval(query.getContig(), query.getStart(), query.getStart());
Expand All @@ -35,7 +37,7 @@ boolean test(OverlapDetector<? extends Locatable> detector, final VariantContext
/**
* Matches if the query ends within any of the given intervals
*/
ENDS_IN{
ENDS_IN("ends within any of the given intervals"){
@Override
boolean test(final OverlapDetector<? extends Locatable> detector, final VariantContext query) {
final SimpleInterval endPosition = new SimpleInterval(query.getContig(), query.getEnd(), query.getEnd());
Expand All @@ -46,17 +48,19 @@ boolean test(final OverlapDetector<? extends Locatable> detector, final VariantC
/**
* Matches if any part of the query overlaps any one of the given intervals
*/
OVERLAPS{
OVERLAPS("overlaps any of the given intervals"){
@Override
boolean test(final OverlapDetector<? extends Locatable> detector, final VariantContext query) {
return detector.overlapsAny(query);
}
},

// TODO finish this exception here...
/**
* Matches if the entirety of the query is contained within one of the intervals
* Matches if the entirety of the query is contained within one of the intervals. Note that adjacent intervals
* may be merged into a single interval depending on the values in
*/
CONTAINED {
CONTAINED("contained completely within a contiguous block of intervals without overlap") {
@Override
boolean test(final OverlapDetector<? extends Locatable> detector, final VariantContext query) {
final Set<? extends Locatable> overlaps = detector.getOverlaps(query);
Expand All @@ -70,21 +74,32 @@ boolean test(final OverlapDetector<? extends Locatable> detector, final VariantC
},

/**
* Always matches, may be used to not perform any filtering, alternatively a
* Always matches, may be used to not perform any filtering
*/
ANYWHERE {
ANYWHERE("no filtering") {
@Override
boolean test(final OverlapDetector<? extends Locatable> detector, final VariantContext query) {
return true;
}
};

private final String doc;

/**
* @param detector The OverlapDetector to compare against
* @param query The variant being tested
* @return true iff the variant matches the given intervals
*/
abstract boolean test(OverlapDetector<? extends Locatable> detector, VariantContext query);

private Mode(String doc){
this.doc = doc;

}
@Override
public String getHelpDoc() {
return doc;
}
}

private final VariantContextWriter writer;
Expand Down

0 comments on commit e96d439

Please sign in to comment.