| 1 | #!/usr/bin/env python |
|---|
| 2 | |
|---|
| 3 | """ |
|---|
| 4 | Validate a dataset based on extension a metadata passed in on the |
|---|
| 5 | command line. Outputs a binhex'd representation of the exceptions. |
|---|
| 6 | |
|---|
| 7 | usage: %prog input output |
|---|
| 8 | -m, --metadata=N: base64 pickeled metadata |
|---|
| 9 | -x, --ext=N: extension as understood by galaxy |
|---|
| 10 | """ |
|---|
| 11 | |
|---|
| 12 | import pkg_resources; pkg_resources.require( "bx-python" ) |
|---|
| 13 | from bx.cookbook import doc_optparse |
|---|
| 14 | |
|---|
| 15 | from galaxy import model |
|---|
| 16 | from fileinput import FileInput |
|---|
| 17 | from galaxy import util |
|---|
| 18 | |
|---|
| 19 | def 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 | |
|---|
| 37 | if __name__ == "__main__": |
|---|
| 38 | main() |
|---|