Mercurial > repos > eric-rasche > apollo
diff fetch_organism_jbrowse.py @ 0:6002cc0df04e draft
planemo upload for repository https://github.com/TAMU-CPT/galaxy-webapollo commit 4e5a5af7689f1713c34a6ad9a9594c205e762fdd
author | eric-rasche |
---|---|
date | Tue, 03 May 2016 13:38:55 -0400 |
parents | |
children | d4ae83dedb14 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/fetch_organism_jbrowse.py Tue May 03 13:38:55 2016 -0400 @@ -0,0 +1,42 @@ +#!/usr/bin/env python +import os +import json +import argparse +import time +from webapollo import WebApolloInstance +import logging +import subprocess +logging.basicConfig(level=logging.INFO) +log = logging.getLogger(__name__) + + +if __name__ == '__main__': + parser = argparse.ArgumentParser(description='Sample script to add an attribute to a feature via web services') + parser.add_argument('apollo', help='Complete Apollo URL') + parser.add_argument('username', help='WA Admin Username') + parser.add_argument('password', help='WA Admin Password') + parser.add_argument('cn', help='Organism Common Name') + parser.add_argument('email', help='User Email') + parser.add_argument('target_dir', help='Target directory') + + args = parser.parse_args() + + + wa = WebApolloInstance(args.apollo, args.username, args.password) + # User must have an account + gx_user = wa.users.loadUsers(email=args.email) + if len(gx_user) == 0: + raise Exception("Unknown user. Please register first") + org = wa.organisms.findOrganismByCn(args.cn) + + + if not os.path.exists(args.target_dir): + os.makedirs(args.target_dir) + + cmd = [ + 'cp', '-R', + org['directory'], + os.path.join(args.target_dir, 'data') + ] + print ' '.join(cmd) + subprocess.check_call(cmd)