Skip to content
a library to validate biological data formats
Java
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
config/checkstyle
docs
gradle/wrapper
src
.gitignore
.travis.yml
LICENSE
README.md
RELEASE_NOTES
build.gradle
gradlew
gradlew.bat
settings.gradle

README.md

BioValidator master build status

BioValidator is a schema validator that validates biological file format like Fasta, GFF, etc. Currently, it supports FASTA, GFF3, and CSV file formats

Usage

The most simple way to validate supported file types is to use ValidatorHelper provided by library.
Example: Arguments in the below validate method

  1. filename: absolute file path
  2. validator-type: type of validator
  3. 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);
}

Validation Result Customization

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());
})

Construct a raw validator:

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());

Using biovalidator in your application

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'

Using biovalidator as a command line utility

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

BioValidator Documentation

Documentation about BioValidator uses and validation rules: https://github.com/intermine/biovalidator/wiki

BioValidator JavaDoc

JavaDocs link : http://intermine.org/biovalidator/javadoc

You can’t perform that action at this time.