BioValidator is a schema validator that validates biological file format like Fasta, GFF, etc. Currently, it supports FASTA, GFF3, and CSV file formats
The most simple way to validate supported file types is to use ValidatorHelper provided by library.
Example:
Arguments in the below validate method
- filename: absolute file path
- validator-type: type of validator
- isStrict: whether to validate in strict mode or permissive
ValidationResult validationResult = ValidatorHelper.validate("filepath", ValidatorType.FASTA, true);
OR
ValidationResult validationResult = ValidatorHelper.validate("filepath", "fasta-dna", true);
OR
ValidationResult validationResult = ValidatorHelper.validateFasta("filepath");
Check whether file is valid or not:
assertTrue(validationResult.isValid());
If file contain errors or warnings:
if (!validationResult.isValid()) {
validationResult.getErrorMessages().forEach(System.out::println);
validationResult.getWarningMessages().forEach(System.out::println);
}
Validator's behaviour and result and can be easily customize, ValidatorBuilder can be used to customize
behaviour and result of the validator.
Example: To validate a file by disabling warnings and continue validation even if error occurred
Validator validator = ValidatorBuilder.withFile("path", "fasta-protein")
.disableWarnings()
.enableErrors()
.disableStopAtFirstError()
.build();
assertTrue(validator.validate().isValid());
OR
validator.validate(result -> {
assertTrue(result.isValid());
})
String dnaSequence = "> seqId | header name\nACTGACTGACTG";
InputStreamReader isr = new InputStreamReader(new ByteArrayInputStream(dnaSequence.getBytes()));
Validator validator = new FastaValidator(isr, SequenceType.DNA);
ValidationResult result = validator.validate();
assertTrue(result.isValid());
Maven dependency
<dependency>
<groupId>org.intermine</groupId>
<artifactId>biovalidator</artifactId>
<version>0.1.2</version>
<type>pom</type>
</dependency>
Gradle dependency
compile 'org.intermine:biovalidator:0.1.2'
Step 1: Get biovalidator Fat-Jar(either build from source or dirctly download from bintray
-
Build from source : $ ./gradlew createFatJar
- this will generate a jar named 'biovalidator-fat-x.x.x.jar' in 'build/libs' directory
-
Or Download fat-jar version of biovalidator from bintray
Setp 2: run as an executable jar file
java -jar biovalidator-fat-0.1.2.jar --help
Documentation about BioValidator uses and validation rules: https://github.com/intermine/biovalidator/wiki
JavaDocs link : http://intermine.org/biovalidator/javadoc