#!/usr/bin/python import os import shutil import sys import time sys.path.insert( 0, os.path.dirname( __file__ ) ) sys.path.insert( 0, "/data/dat0/galaxy-dist/scripts/api" ) from common import submit, display import pkg_resources pkg_resources.require( "simplejson" ) import simplejson def main() : print "Hello" library_name = "METALIB" library_id = "f2db41e1fa331b3e" api_key = "71edcbdb2b91c9b2c1125775804d2093" api_url = "http://cogangs.biobase.de:82/api/" #<----->libs = display(api_key, api_url + 'libraries', return_formatted=False) #<----->print libs #<----->for library in libs: #<-----> if library['name'] == library_name: #<-----> library_id = library['id'] #<----->if not library_id: #<-----> lib_create_data = {'name':library_name} #<-----> library = submit(api_key, api_url + 'libraries', lib_create_data, return_formatted=False) #<-----> library_id = library[0]['id'] # folders = display(api_key, api_url + "libraries/%s/contents" % library_id, return_formatted = False) # for f in folders: # if f['name'] == "/": # library_folder_id = f['id'] # print "folder_id:"+library_folder_id+"\n" fullpath = "/home/nikolay/galaxy/fasta.fa" # fullpath = "https://s3.amazonaws.com/BIOBASE/sequences/fasta.txt" if os.path.isfile(fullpath): data = {} # data['folder_id'] = library_folder_id # data['file_type'] = 'auto' # data['dbkey'] = 'hg19' # data['upload_option'] = 'upload_paths' data['filename'] = fullpath # data['create_type'] = 'file' libset = submit(api_key, api_url + "user/adm/upload", data, return_formatted = False) # time.sleep(5) print libset if __name__ == '__main__': main()