Git Product home page Git Product logo

biovalidator's Introduction

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

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.