Moved the evaluation of the JEXL expressions to a point *after* the samples are subset and the INFO-field annotations are updated. I think this makes more sense than having the evaluations happen beforehand, since it seems jarring to have the JEXL expressions operate on the annotations before they're updated, and have the file contain the annotations after they're updated. Now, selecting on something like allele frequency will actually apply to the annotations that actually end up in the file, while selection on other annotations (which are carried over without modification) will act exactly the same regardless.
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3970 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
594b7912f1
commit
eb1bb94d1c
|
|
@ -29,16 +29,16 @@ import java.util.regex.Pattern;
|
|||
*/
|
||||
@Requires(value={},referenceMetaData=@RMD(name="variant", type=ReferenceOrderedDatum.class))
|
||||
public class SelectVariants extends RodWalker<Integer, Integer> {
|
||||
@Argument(fullName="sample", shortName="SN", doc="Sample(s) to include. Can be a single sample, specified multiple times for many samples, or a regular expression to select many samples", required=false)
|
||||
@Argument(fullName="sample", shortName="SN", doc="Sample(s) to include. Can be a single sample, specified multiple times for many samples, or a regular expression to select many samples.", required=false)
|
||||
public Set<String> SAMPLE_EXPRESSIONS;
|
||||
|
||||
@Argument(shortName="select", doc="One or more criteria to use when selecting the data", required=false)
|
||||
@Argument(shortName="select", doc="One or more criteria to use when selecting the data. Evaluated *after* the specified samples are extracted and the INFO-field annotations are updated.", required=false)
|
||||
public ArrayList<String> SELECT_EXPRESSIONS = new ArrayList<String>();
|
||||
|
||||
@Argument(fullName="excludeNonVariants", shortName="ENV", doc="Don't include loci found to be non-variant after the subsetting procedure", required=false)
|
||||
@Argument(fullName="excludeNonVariants", shortName="ENV", doc="Don't include loci found to be non-variant after the subsetting procedure.", required=false)
|
||||
private boolean EXCLUDE_NON_VARIANTS = false;
|
||||
|
||||
@Argument(fullName="excludeFiltered", shortName="EF", doc="Don't include filtered loci", required=false)
|
||||
@Argument(fullName="excludeFiltered", shortName="EF", doc="Don't include filtered loci.", required=false)
|
||||
private boolean EXCLUDE_FILTERED = false;
|
||||
|
||||
private ArrayList<String> selectNames = new ArrayList<String>();
|
||||
|
|
@ -121,25 +121,25 @@ public class SelectVariants extends RodWalker<Integer, Integer> {
|
|||
jexls = VariantContextUtils.initializeMatchExps(selectNames, SELECT_EXPRESSIONS);
|
||||
}
|
||||
|
||||
/**
|
||||
* If JEXL expressions are supplied, include only records that satisfy the expression
|
||||
*
|
||||
* @param tracker the ROD tracker
|
||||
* @param ref reference information
|
||||
* @param context alignment info
|
||||
* @return true if no JEXL expressions are supplied or if a record satisfies all JEXL criteria, false if otherwise
|
||||
*/
|
||||
public boolean filter(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
||||
VariantContext vc = tracker.getVariantContext(ref, "variant", null, context.getLocation(), true);
|
||||
|
||||
for ( VariantContextUtils.JexlVCMatchExp jexl : jexls ) {
|
||||
if ( !VariantContextUtils.match(vc, jexl) ) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
// /**
|
||||
// * If JEXL expressions are supplied, include only records that satisfy the expression
|
||||
// *
|
||||
// * @param tracker the ROD tracker
|
||||
// * @param ref reference information
|
||||
// * @param context alignment info
|
||||
// * @return true if no JEXL expressions are supplied or if a record satisfies all JEXL criteria, false if otherwise
|
||||
// */
|
||||
// public boolean filter(RefMetaDataTracker tracker, ReferenceContext ref, AlignmentContext context) {
|
||||
// VariantContext vc = tracker.getVariantContext(ref, "variant", null, context.getLocation(), true);
|
||||
//
|
||||
// for ( VariantContextUtils.JexlVCMatchExp jexl : jexls ) {
|
||||
// if ( !VariantContextUtils.match(vc, jexl) ) {
|
||||
// return false;
|
||||
// }
|
||||
// }
|
||||
//
|
||||
// return true;
|
||||
// }
|
||||
|
||||
/**
|
||||
* Subset VC record if necessary and emit the modified record (provided it satisfies criteria for printing)
|
||||
|
|
@ -158,6 +158,12 @@ public class SelectVariants extends RodWalker<Integer, Integer> {
|
|||
VariantContext sub = subsetRecord(vc, samples);
|
||||
|
||||
if ( (sub.isPolymorphic() || !EXCLUDE_NON_VARIANTS) && (!sub.isFiltered() || !EXCLUDE_FILTERED) ) {
|
||||
for ( VariantContextUtils.JexlVCMatchExp jexl : jexls ) {
|
||||
if ( !VariantContextUtils.match(sub, jexl) ) {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
vcfWriter.add(sub, ref.getBase());
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue