Пример #1
0
def run(service_host, kbase_host):
    pid = os.getpid()
    ws = Workspace(url=get_workspace_url(kbase_host), token=token)
    for name in workspace_names:

        while 1:
            print('[{:d}] List objects'.format(pid))
            try:
                annotations = ws.list_objects({"workspaces": [name], "type": "KBaseGenomeAnnotations.GenomeAnnotation"})
                break
            except Exception as err:
                print('Retry on timeout: {}'.format(str(err)))

        print('[{:d}] Got {:d} objects'.format(pid, len(annotations)))
        for obj_num, obj in enumerate(annotations):
            ref = obj[7] + "/" + obj[1]
            print('[{:d}] Fetch {:d}/{:d}: {}'.format(pid, obj_num +1, len(annotations), ref))
            ga = GenomeAnnotationClientAPI(get_genome_annotation_url(service_host),token,ref)
            #taxon = TaxonClientAPI(services["taxon_service_url"],token,ga.get_taxon())
            assembly = AssemblyClientAPI(get_assembly_url(service_host), token, ga.get_assembly())
            while 1:
                try:
                    fids = ga.get_feature_ids()
                    fdata = ga.get_features()
                    cids = assembly.get_contig_ids()
                    contigs = assembly.get_contigs()
                except doekbase.data_api.exceptions.ServiceError as err:
                    print('[{:d}] Error: {}'.format(pid, err))
                    time.sleep(0.5)
                    print('[{:d}] Retrying'.format(pid))
Пример #2
0
def run(service_host, kbase_host):
    pid = os.getpid()
    ws = Workspace(url=get_workspace_url(kbase_host), token=token)
    for name in workspace_names:

        while 1:
            print('[{:d}] List objects'.format(pid))
            try:
                annotations = ws.list_objects({
                    "workspaces": [name],
                    "type":
                    "KBaseGenomeAnnotations.GenomeAnnotation"
                })
                break
            except Exception as err:
                print('Retry on timeout: {}'.format(str(err)))

        print('[{:d}] Got {:d} objects'.format(pid, len(annotations)))
        for obj_num, obj in enumerate(annotations):
            ref = obj[7] + "/" + obj[1]
            print('[{:d}] Fetch {:d}/{:d}: {}'.format(pid, obj_num + 1,
                                                      len(annotations), ref))
            ga = GenomeAnnotationClientAPI(
                get_genome_annotation_url(service_host), token, ref)
            #taxon = TaxonClientAPI(services["taxon_service_url"],token,ga.get_taxon())
            assembly = AssemblyClientAPI(get_assembly_url(service_host), token,
                                         ga.get_assembly())
            while 1:
                try:
                    fids = ga.get_feature_ids()
                    fdata = ga.get_features()
                    cids = assembly.get_contig_ids()
                    contigs = assembly.get_contigs()
                except doekbase.data_api.exceptions.ServiceError as err:
                    print('[{:d}] Error: {}'.format(pid, err))
                    time.sleep(0.5)
                    print('[{:d}] Retrying'.format(pid))
    "handle_service_url": "https://kbase.us/services/handle_service/"
}

token = os.environ["KB_AUTH_TOKEN"]
ws = Workspace(url=services["workspace_service_url"], token=token)
hc = handleClient(url=services["handle_service_url"], token=token)

fix_workspace = "ReferenceEnsemblPlantGenomeAnnotations"

count = 0
limit = 10000
skip = 0
done = False
while not done:
    results = ws.list_objects({"workspaces": [fix_workspace],
                               "type": "KBaseGenomeAnnotations.Assembly",
                               "skip": skip,
                               "limit": limit})

    if len(results) == 0:
        done = True

    for x in results:
        count += 1
        ac = AssemblyAPI(services, token, ref="{}/{}".format(fix_workspace, x[1]))
        handle_ref = ac.get_data()["fasta_handle_ref"]
        shock_node_id = None
        
        try:
            handle = hc.hids_to_handles([handle_ref])[0]
            shock_node_id = handle["id"]
        except Exception, e:
Пример #4
0
}

token = os.environ["KB_AUTH_TOKEN"]
ws = Workspace(url=services["workspace_service_url"], token=token)
hc = handleClient(url=services["handle_service_url"], token=token)

fix_workspace = "ReferenceEnsemblPlantGenomeAnnotations"

count = 0
limit = 10000
skip = 0
done = False
while not done:
    results = ws.list_objects({
        "workspaces": [fix_workspace],
        "type": "KBaseGenomeAnnotations.Assembly",
        "skip": skip,
        "limit": limit
    })

    if len(results) == 0:
        done = True

    for x in results:
        count += 1
        ac = AssemblyAPI(services,
                         token,
                         ref="{}/{}".format(fix_workspace, x[1]))
        handle_ref = ac.get_data()["fasta_handle_ref"]
        shock_node_id = None

        try: