PageRenderTime 17ms CodeModel.GetById 11ms app.highlight 4ms RepoModel.GetById 1ms app.codeStats 0ms

/tools/validation/validate.py

https://bitbucket.org/cistrome/cistrome-harvard/
Python | 38 lines | 31 code | 2 blank | 5 comment | 0 complexity | 0d6a608536da5a87e417be13727a8125 MD5 | raw file
 1#!/usr/bin/env python
 2
 3"""
 4Validate a dataset based on extension a metadata passed in on the
 5command line.  Outputs a binhex'd representation of the exceptions.
 6
 7usage: %prog input output
 8    -m, --metadata=N: base64 pickeled metadata
 9    -x, --ext=N: extension as understood by galaxy
10"""
11
12import pkg_resources; pkg_resources.require( "bx-python" )
13from bx.cookbook import doc_optparse
14
15from galaxy import model
16from fileinput import FileInput
17from galaxy import util
18
19def main():
20    options, args = doc_optparse.parse( __doc__ )
21
22    try:
23        extension = options.ext
24    except:
25        doc_optparse.exception()
26
27    # create datatype
28    data = model.Dataset( extension=extension, id=int( args[0] ) )
29    data.file_path = "/home/ian/trunk/database/files/"
30    
31    if options.metadata:
32        data.metadata = util.string_to_object( options.metadata )
33
34    errors = data.datatype.validate( data )
35    print util.object_to_string(errors)
36
37if __name__ == "__main__":
38    main()