/** * Matches each {@link JexlVCMatchExp} exp against the data contained in {@code vc}, {@code g}, * and returns a map from these expressions to {@code true} (if they matched) or {@code false} (if they didn't). * This the best way to apply JEXL expressions to {@link VariantContext} records. * Use the various {@code initializeMatchExps()}'s to create the list of {@link JexlVCMatchExp} expressions. * * Expressions that contain literals not available in the VariantContext or Genotype will be treated as not matching * @param vc variant context * @param g genotype * @param exps expressions * @return true if there is a match */ public static Map<JexlVCMatchExp, Boolean> match(VariantContext vc, Genotype g, Collection<JexlVCMatchExp> exps) { return match(vc, g, exps, JEXLMap.DEFAULT_MISSING_VALUE_TREATMENT); }
/** * Matches each {@link JexlVCMatchExp} exp against the data contained in {@code vc}, {@code g}, * and returns a map from these expressions to {@code true} (if they matched) or {@code false} (if they didn't). * This the best way to apply JEXL expressions to {@link VariantContext} records. * Use the various {@code initializeMatchExps()}'s to create the list of {@link JexlVCMatchExp} expressions. * * Expressions that contain literals not available in the VariantContext or Genotype will be treated as not matching * @param vc variant context * @param g genotype * @param exps expressions * @return true if there is a match */ public static Map<JexlVCMatchExp, Boolean> match(VariantContext vc, Genotype g, Collection<JexlVCMatchExp> exps) { return match(vc, g, exps, JEXLMap.DEFAULT_MISSING_VALUE_TREATMENT); }
/** * Returns true if {@code exp} match {@code vc}, {@code g}. * See {@link #match(VariantContext, Genotype, Collection)} for full docs. * @param vc variant context * @param g genotype * @param exp expression * @param howToTreatMissingValues what to do if the jexl expression contains literals that aren't in the context * @return true if there is a match */ public static boolean match(VariantContext vc, Genotype g, JexlVCMatchExp exp, JexlMissingValueTreatment howToTreatMissingValues) { return match(vc, g, Collections.singletonList(exp), howToTreatMissingValues).get(exp); }
/** * Returns true if {@code exp} match {@code vc}, {@code g}. * See {@link #match(VariantContext, Genotype, Collection)} for full docs. * @param vc variant context * @param g genotype * @param exp expression * @return true if there is a match */ public static boolean match(VariantContext vc, Genotype g, JexlVCMatchExp exp) { return match(vc, g, Collections.singletonList(exp), JEXLMap.DEFAULT_MISSING_VALUE_TREATMENT).get(exp); }
/** * Returns true if {@code exp} match {@code vc}. * See {@link #match(VariantContext, Collection)} for full docs. * @param vc variant context * @param exp expression * @return true if there is a match */ public static boolean match(VariantContext vc, JexlVCMatchExp exp) { return match(vc, Collections.singletonList(exp)).get(exp); }
/** * Returns true if {@code exp} match {@code vc}, {@code g}. * See {@link #match(VariantContext, Genotype, Collection)} for full docs. * @param vc variant context * @param g genotype * @param exp expression * @param howToTreatMissingValues what to do if the jexl expression contains literals that aren't in the context * @return true if there is a match */ public static boolean match(VariantContext vc, Genotype g, JexlVCMatchExp exp, JexlMissingValueTreatment howToTreatMissingValues) { return match(vc, g, Collections.singletonList(exp), howToTreatMissingValues).get(exp); }
/** * Returns true if {@code exp} match {@code vc}. * See {@link #match(VariantContext, Collection)} for full docs. * @param vc variant context * @param exp expression * @return true if there is a match */ public static boolean match(VariantContext vc, JexlVCMatchExp exp) { return match(vc, Collections.singletonList(exp)).get(exp); }
/** * Returns true if {@code exp} match {@code vc}, {@code g}. * See {@link #match(VariantContext, Genotype, Collection)} for full docs. * @param vc variant context * @param g genotype * @param exp expression * @return true if there is a match */ public static boolean match(VariantContext vc, Genotype g, JexlVCMatchExp exp) { return match(vc, g, Collections.singletonList(exp), JEXLMap.DEFAULT_MISSING_VALUE_TREATMENT).get(exp); }
/** * Returns true if exp match VC. See collection<> version for full docs. * @param vc variant context * @param exp expression * @return true if there is a match */ public static boolean match(VariantContext vc, JexlVCMatchExp exp) { return match(vc,Arrays.asList(exp)).get(exp); }
/** * Returns true if exp match VC/g. See collection<> version for full docs. * @param vc variant context * @param g genotype * @param exp expression * @return true if there is a match */ public static boolean match(VariantContext vc, Genotype g, JexlVCMatchExp exp) { return match(vc,g,Arrays.asList(exp)).get(exp); }
public List<Object> getRelevantStates(ReferenceContext ref, RefMetaDataTracker tracker, VariantContext comp, String compName, VariantContext eval, String evalName, String sampleName, String FamilyName) { ArrayList<Object> relevantStates = new ArrayList<Object>(); relevantStates.add("none"); for ( SortableJexlVCMatchExp jexlExpression : jexlExpressions ) { if (eval != null && VariantContextUtils.match(eval, jexlExpression)) { relevantStates.add(jexlExpression.name); } } return relevantStates; } }
private static boolean matchesFilter(final VariantContext vc, final Genotype g, final VariantContextUtils.JexlVCMatchExp exp, final boolean invertVCfilterExpression, final boolean failIfMissingValues) { final JexlMissingValueTreatment howToTreatMissingValues = failIfMissingValues ? JexlMissingValueTreatment.TREAT_AS_MATCH : JexlMissingValueTreatment.TREAT_AS_MISMATCH; return Utils.invertLogic(VariantContextUtils.match(vc, g, exp, howToTreatMissingValues), invertVCfilterExpression); }
@Test(dataProvider = "getMissingValueTestData") public void testMissingBehaviorThroughMatch(VariantContext vc, JexlMissingValueTreatment missingValueTreatment, boolean expected, Class<? extends Exception> expectedException){ if(expectedException == null) { Assert.assertEquals(VariantContextUtils.match(vc, null, missingValueExpression, missingValueTreatment), expected); } else { Assert.assertThrows(expectedException, () -> VariantContextUtils.match(vc, null, missingValueExpression, missingValueTreatment)); } }
List<Genotype> filteredGenotypes = new ArrayList<Genotype>(context.getNSamples()); for ( Genotype g : context.getGenotypes() ) { Map<VariantContextUtils.JexlVCMatchExp, Boolean> matchMap = VariantContextUtils.match(context, g, exps); boolean filtered = false; for ( Boolean b : matchMap.values() ) {
if ( Utils.invertLogic(!VariantContextUtils.match(filteredGenotypeToNocall, jexl), invertSelect) ){ failedJexlMatch = true; break;