@Test public void testMyVariantInfoAnnotation() { String[] genomicLocation = { "7,140453136,140453136,A,ATGC-T", "A,37880220,37880220,T,C", "7,-1,37879794,G,C", "12,25398284,-2,CC,GA", "12,25380271,25380271,12,T", "10,89692940,89692940,C,Q", "X,89692940,89692940,C,", "X_89692940_89692940_C_T", "MT,10360,10360,G,A", }; GenomicLocationValidator validator = new GenomicLocationValidator(); assertEquals(true, validator.isValid(genomicLocation[0], null)); assertEquals(false, validator.isValid(genomicLocation[1], null)); assertEquals(false, validator.isValid(genomicLocation[2], null)); assertEquals(false, validator.isValid(genomicLocation[3], null)); assertEquals(false, validator.isValid(genomicLocation[4], null)); assertEquals(false, validator.isValid(genomicLocation[5], null)); assertEquals(false, validator.isValid(genomicLocation[6], null)); assertEquals(false, validator.isValid(genomicLocation[7], null)); assertEquals(true, validator.isValid(genomicLocation[8], null)); }
public boolean isValid(String genomicLocation, ConstraintValidatorContext context) { String[] genomicLocationSplit = genomicLocation.split(","); if (genomicLocationSplit.length < 5) { return false; } else { boolean result = true; result &= genomicLocationSplit[0].matches("X") || genomicLocationSplit[0].matches("Y") || genomicLocationSplit[0].matches("MT") || genomicLocationSplit[0].matches("[0-9]+") && Integer.valueOf(genomicLocationSplit[0]) >= 1 && Integer.valueOf(genomicLocationSplit[0]) <= 24; result &= Integer.valueOf(genomicLocationSplit[1]) >= 0 && Integer.valueOf(genomicLocationSplit[2]) >= 0; result &= genomicLocationSplit[3].matches("[TCGA-]*") && genomicLocationSplit[4].matches("[TCGA-]*"); return result; } }
GenomicLocationValidator implements ConstraintValidator<ValidGenomicLocation, String> { public boolean isValid(String genomicLocation, ConstraintValidatorContext context) { String[] genomicLocationSplit = genomicLocation.split(","); if (genomicLocationSplit.length < 5) { return false; } else { boolean result = true; result &= genomicLocationSplit[0].matches("X") || genomicLocationSplit[0].matches("Y") || genomicLocationSplit[0].matches("MT") || genomicLocationSplit[0].matches("[0-9]+") && Integer.valueOf(genomicLocationSplit[0]) >= 1 && Integer.valueOf(genomicLocationSplit[0]) <= 24; result &= Integer.valueOf(genomicLocationSplit[1]) >= 0 && Integer.valueOf(genomicLocationSplit[2]) >= 0; result &= genomicLocationSplit[3].matches("[TCGA-]*") && genomicLocationSplit[4].matches("[TCGA-]*"); return result; } } }
GenomicLocationValidator implements ConstraintValidator<ValidGenomicLocation, String> { public boolean isValid(String genomicLocation, ConstraintValidatorContext context) { String[] genomicLocationSplit = genomicLocation.split(","); if (genomicLocationSplit.length < 5) { return false; } else { boolean result = true; result &= genomicLocationSplit[0].matches("X") || genomicLocationSplit[0].matches("Y") || genomicLocationSplit[0].matches("MT") || genomicLocationSplit[0].matches("[0-9]+") && Integer.valueOf(genomicLocationSplit[0]) >= 1 && Integer.valueOf(genomicLocationSplit[0]) <= 24; result &= Integer.valueOf(genomicLocationSplit[1]) >= 0 && Integer.valueOf(genomicLocationSplit[2]) >= 0; result &= genomicLocationSplit[3].matches("[TCGA-]*") && genomicLocationSplit[4].matches("[TCGA-]*"); return result; } }  }
GenomicLocationValidator implements ConstraintValidator<ValidGenomicLocation, String> { public boolean isValid(String genomicLocation, ConstraintValidatorContext context) { String[] genomicLocationSplit = genomicLocation.split(","); if (genomicLocationSplit.length < 5) { return false; } else { boolean result = true; result &= genomicLocationSplit[0].matches("X") || genomicLocationSplit[0].matches("Y") || genomicLocationSplit[0].matches("MT") || genomicLocationSplit[0].matches("[0-9]+") && Integer.valueOf(genomicLocationSplit[0]) >= 1 && Integer.valueOf(genomicLocationSplit[0]) <= 24; result &= Integer.valueOf(genomicLocationSplit[1]) >= 0 && Integer.valueOf(genomicLocationSplit[2]) >= 0; result &= genomicLocationSplit[3].matches("[TCGA-]*") && genomicLocationSplit[4].matches("[TCGA-]*"); return result; } }  void initialize(ValidGenomicLocation constraintAnnotation); boolean isValid(String genomicLocation, ConstraintValidatorContext context); }
GenomicLocationValidator implements ConstraintValidator<ValidGenomicLocation, String> { public boolean isValid(String genomicLocation, ConstraintValidatorContext context) { String[] genomicLocationSplit = genomicLocation.split(","); if (genomicLocationSplit.length < 5) { return false; } else { boolean result = true; result &= genomicLocationSplit[0].matches("X") || genomicLocationSplit[0].matches("Y") || genomicLocationSplit[0].matches("MT") || genomicLocationSplit[0].matches("[0-9]+") && Integer.valueOf(genomicLocationSplit[0]) >= 1 && Integer.valueOf(genomicLocationSplit[0]) <= 24; result &= Integer.valueOf(genomicLocationSplit[1]) >= 0 && Integer.valueOf(genomicLocationSplit[2]) >= 0; result &= genomicLocationSplit[3].matches("[TCGA-]*") && genomicLocationSplit[4].matches("[TCGA-]*"); return result; } }  void initialize(ValidGenomicLocation constraintAnnotation); boolean isValid(String genomicLocation, ConstraintValidatorContext context);  }