Ejemplo n.º 1
0
def setup():
    shared.setup()
    global t_new, t_new_e, t_old, t_old_e, t_client_new, t_client_old
    t_new = TaxonAPI(shared.services, shared.token, taxon_new)
    t_new_e = _Taxon(shared.services, shared.token, taxon_new)
    t_old = TaxonAPI(shared.services, shared.token, taxon_old)
    t_old_e = _KBaseGenomes_Genome(shared.services, shared.token, taxon_old)
    _log.info("Connecting to Taxon Thrift Service at {}".format(shared.services["taxon_service_url"]))
    t_client_new = TaxonClientAPI(shared.services["taxon_service_url"], shared.token, taxon_new)
    t_client_old = TaxonClientAPI(shared.services["taxon_service_url"], shared.token, taxon_old)
Ejemplo n.º 2
0
def test_api_service(service_name='assembly',apiurl='http://localhost',token=None):
    try:
        if service_name == "taxon":
            #from doekbase.data_api.taxonomy.taxon.service import thrift_client
            from doekbase.data_api.taxonomy.taxon.api import TaxonClientAPI
            api = TaxonClientAPI(apiurl, token, 'ReferenceTaxons/242159_taxon')
        elif service_name == "assembly":
            #from doekbase.data_api.sequence.assembly.service import thrift_client
            from doekbase.data_api.sequence.assembly.api import AssemblyClientAPI
            api = AssemblyClientAPI(apiurl, token, 'ReferenceGenomeAnnotations/kb|g.166819_assembly')
        elif service_name == "genome_annotation":
            #from doekbase.data_api.annotation.genome_annotation.service import thrift_client
            from doekbase.data_api.annotation.genome_annotation.api import GenomeAnnotationClientAPI
            api = GenomeAnnotationClientAPI(apiurl, token, 'ReferenceGenomeAnnotations/kb|g.166819')
        else:
            raise Exception("Service not activated: {}".format(service_name))
    except Exception as e:
        print '3 ' + service_name + '_api - UNKNOWN - could not load client library for ' + service_name + ' ' + str(sys.path) + ' ' + str(sys.exc_info()[0])
        raise

    if service_name == 'genome_annotation':
        try:
            feature_types = api.get_feature_types()
            if 'CDS' in feature_types:
                print '0 ' + service_name + '_api - OK - feature_type returned ' + str(feature_types)
            else:
                print '2 ' + service_name + '_api - CRITICAL - unexpected feature_types returned ' + str(feature_types)
        except:
            print '2 ' + service_name + '_api - CRITICAL - unexpected error encountered ' + str(sys.exc_info()[0])

    if service_name == 'taxon':
        try:
            lineage = api.get_scientific_lineage()
            if 'Ostreococcus' in lineage:
                print '0 ' + service_name + '_api - OK - expected lineage OK ' + str(lineage)
            else:
                print '2 ' + service_name + '_api - CRITICAL - unexpected lineage ' + str(lineage)
        except:
            print '2 ' + service_name + '_api - CRITICAL - unexpected error encountered ' + str(sys.exc_info()[0])

    if service_name == 'assembly':
        try:
            stats = api.get_stats()
            ref_num_contigs=21
            if stats['num_contigs']==ref_num_contigs:
                print '0 ' + service_name + '_api - OK - ' + str(ref_num_contigs) + ' contigs found'
            else:
                print '2 ' + service_name + '_api - CRITICAL - ' + str(stats['num_contigs']) + ' contigs found, not ' + str(ref_num_contigs)
        except:
            print '2 ' + service_name + '_api - CRITICAL - unexpected error encountered ' + str(sys.exc_info()[0])
Ejemplo n.º 3
0
def test_client():
    ap = argparse.ArgumentParser()
    ap.add_argument('--ref',
                    default='ReferenceTaxons/242159_taxon',
                    help='Object reference ID, e.g. 1019/4/1')
    ap.add_argument('--url',
                    dest='url',
                    default='http://localhost:9101',
                    metavar='URL',
                    help='Remote server url '
                    '(default=%(default)s)')
    args = ap.parse_args()

    token = ''
    if os.environ.has_key('KB_AUTH_TOKEN'):
        token = os.environ['KB_AUTH_TOKEN']

    api = TaxonClientAPI(args.url, token, args.ref)

    print("Getting data..")

    t0 = time.time()
    object_info = api.get_info()
    dt = time.time() - t0
    print object_info
    print("Got and parsed data from get_info in {:g} seconds".format(dt))

    t0 = time.time()
    history = api.get_history()
    dt = time.time() - t0
    print history
    print("Got and parsed data from get_history in {:g} seconds".format(dt))

    t0 = time.time()
    provenance = api.get_provenance()
    dt = time.time() - t0
    print provenance
    print("Got and parsed data from get_provenance in {:g} seconds".format(dt))

    t0 = time.time()
    id = api.get_id()
    dt = time.time() - t0
    print id
    print("Got and parsed data from get_id in {:g} seconds".format(dt))

    t0 = time.time()
    name = api.get_name()
    dt = time.time() - t0
    print name
    print("Got and parsed data from get_name in {:g} seconds".format(dt))

    t0 = time.time()
    version = api.get_version()
    dt = time.time() - t0
    print version
    print("Got and parsed data from get_version in {:g} seconds".format(dt))

    t0 = time.time()
    genetic_code = api.get_genetic_code()
    dt = time.time() - t0
    print genetic_code
    print(
        "Got and parsed data from get_genetic_code in {:g} seconds".format(dt))

    t0 = time.time()
    aliases = api.get_aliases()
    dt = time.time() - t0
    print aliases
    print("Got and parsed data from get_aliases in {:g} seconds".format(dt))

    t0 = time.time()
    domain = api.get_domain()
    dt = time.time() - t0
    print domain
    print("Got and parsed data from get_domain in {:g} seconds".format(dt))

    try:
        t0 = time.time()
        kingdom = api.get_kingdom()
        dt = time.time() - t0
        print kingdom
        print(
            "Got and parsed data from get_kingdom in {:g} seconds".format(dt))
    except:
        pass

    t0 = time.time()
    taxonomic_id = api.get_taxonomic_id()
    dt = time.time() - t0
    print taxonomic_id
    print(
        "Got and parsed data from get_taxonomic_id in {:g} seconds".format(dt))

    t0 = time.time()
    scientific_lineage = api.get_scientific_lineage()
    dt = time.time() - t0
    print scientific_lineage
    print("Got and parsed data from get_scientific_lineage in {:g} seconds".
          format(dt))

    t0 = time.time()
    genome_annotations = api.get_genome_annotations()
    dt = time.time() - t0
    print genome_annotations
    print("Got and parsed data from get_genome_annotations in {:g} seconds".
          format(dt))

    t0 = time.time()
    parent = api.get_parent()
    dt = time.time() - t0
    print parent
    print("Got and parsed data from get_parent in {:g} seconds".format(dt))

    t0 = time.time()
    children = api.get_children()
    dt = time.time() - t0
    print children
    print("Got and parsed data from get_children in {:g} seconds".format(dt))
Ejemplo n.º 4
0
def test_client():
    ap = argparse.ArgumentParser()
    ap.add_argument('--ref', default='ReferenceTaxons/242159_taxon', help='Object reference ID, e.g. 1019/4/1')
    ap.add_argument('--url', dest='url', default='http://localhost:9101',
                    metavar='URL', help='Remote server url '
                                         '(default=%(default)s)')
    args = ap.parse_args()

    token='';
    if os.environ.has_key('KB_AUTH_TOKEN'):
        token = os.environ['KB_AUTH_TOKEN']

    api = TaxonClientAPI(args.url, token, args.ref)

    print("Getting data..")

    t0 = time.time()
    object_info = api.get_info()
    dt = time.time() - t0
    print object_info
    print("Got and parsed data from get_info in {:g} seconds".format(dt))

    t0 = time.time()
    history = api.get_history()
    dt = time.time() - t0
    print history
    print("Got and parsed data from get_history in {:g} seconds".format(dt))

    t0 = time.time()
    provenance = api.get_provenance()
    dt = time.time() - t0
    print provenance
    print("Got and parsed data from get_provenance in {:g} seconds".format(dt))

    t0 = time.time()
    id = api.get_id()
    dt = time.time() - t0
    print id
    print("Got and parsed data from get_id in {:g} seconds".format(dt))

    t0 = time.time()
    name = api.get_name()
    dt = time.time() - t0
    print name
    print("Got and parsed data from get_name in {:g} seconds".format(dt))

    t0 = time.time()
    version = api.get_version()
    dt = time.time() - t0
    print version
    print("Got and parsed data from get_version in {:g} seconds".format(dt))

    t0 = time.time()
    genetic_code = api.get_genetic_code()
    dt = time.time() - t0
    print genetic_code
    print("Got and parsed data from get_genetic_code in {:g} seconds".format(dt))

    t0 = time.time()
    aliases = api.get_aliases()
    dt = time.time() - t0
    print aliases
    print("Got and parsed data from get_aliases in {:g} seconds".format(dt))

    t0 = time.time()
    domain = api.get_domain()
    dt = time.time() - t0
    print domain
    print("Got and parsed data from get_domain in {:g} seconds".format(dt))

    try:
        t0 = time.time()
        kingdom = api.get_kingdom()
        dt = time.time() - t0
        print kingdom
        print("Got and parsed data from get_kingdom in {:g} seconds".format(dt))
    except:
        pass

    t0 = time.time()
    taxonomic_id = api.get_taxonomic_id()
    dt = time.time() - t0
    print taxonomic_id
    print("Got and parsed data from get_taxonomic_id in {:g} seconds".format(dt))

    t0 = time.time()
    scientific_lineage = api.get_scientific_lineage()
    dt = time.time() - t0
    print scientific_lineage
    print("Got and parsed data from get_scientific_lineage in {:g} seconds".format(dt))

    t0 = time.time()
    genome_annotations = api.get_genome_annotations()
    dt = time.time() - t0
    print genome_annotations
    print("Got and parsed data from get_genome_annotations in {:g} seconds".format(dt))

    t0 = time.time()
    parent = api.get_parent()
    dt = time.time() - t0
    print parent
    print("Got and parsed data from get_parent in {:g} seconds".format(dt))

    t0 = time.time()
    children = api.get_children()
    dt = time.time() - t0
    print children
    print("Got and parsed data from get_children in {:g} seconds".format(dt))
Ejemplo n.º 5
0
def test_client():
    ap = argparse.ArgumentParser()
    ap.add_argument('--ref', default='ReferenceTaxons/83333_taxon', help='Object reference ID, e.g. 1019/4/1')
    ap.add_argument('--host', dest='host', default='localhost',
                    metavar='ADDR', help='Remote server host '
                                         '(default=%(default)s)')
    ap.add_argument('--port', dest='port', default=9090,
                    metavar='PORT', help='Remote server port '
                                         '(default=%(default)d)')
    args = ap.parse_args()

    api = TaxonClientAPI(args.host, args.port, os.environ["KB_AUTH_TOKEN"], args.ref)

    print("Getting data..")

    t0 = time.time()
    genetic_code = api.get_genetic_code()
    dt = time.time() - t0
    print genetic_code
    print("Got and parsed data in {:g} seconds".format(dt))

    t0 = time.time()
    aliases = api.get_aliases()
    dt = time.time() - t0
    print aliases
    print("Got and parsed data in {:g} seconds".format(dt))

    t0 = time.time()
    domain = api.get_domain()
    dt = time.time() - t0
    print domain
    print("Got and parsed data in {:g} seconds".format(dt))

    try:
        t0 = time.time()
        kingdom = api.get_kingdom()
        dt = time.time() - t0
        print kingdom
        print("Got and parsed data in {:g} seconds".format(dt))
    except:
        pass

    t0 = time.time()
    taxonomic_id = api.get_taxonomic_id()
    dt = time.time() - t0
    print taxonomic_id
    print("Got and parsed data in {:g} seconds".format(dt))

    t0 = time.time()
    scientific_lineage = api.get_scientific_lineage()
    dt = time.time() - t0
    print scientific_lineage
    print("Got and parsed data in {:g} seconds".format(dt))

    t0 = time.time()
    genome_annotations = api.get_genome_annotations()
    dt = time.time() - t0
    print genome_annotations
    print("Got and parsed data in {:g} seconds".format(dt))

    t0 = time.time()
    parent = api.get_parent()
    dt = time.time() - t0
    print parent
    print("Got and parsed data in {:g} seconds".format(dt))

    t0 = time.time()
    children = api.get_children()
    dt = time.time() - t0
    print children
    print("Got and parsed data in {:g} seconds".format(dt))
Ejemplo n.º 6
0
def test_api_service(service_name='assembly',
                     apiurl='http://localhost',
                     token=None):
    try:
        if service_name == "taxon":
            #from doekbase.data_api.taxonomy.taxon.service import thrift_client
            from doekbase.data_api.taxonomy.taxon.api import TaxonClientAPI
            api = TaxonClientAPI(apiurl, token, 'ReferenceTaxons/242159_taxon')
        elif service_name == "assembly":
            #from doekbase.data_api.sequence.assembly.service import thrift_client
            from doekbase.data_api.sequence.assembly.api import AssemblyClientAPI
            api = AssemblyClientAPI(
                apiurl, token,
                'ReferenceGenomeAnnotations/kb|g.166819_assembly')
        elif service_name == "genome_annotation":
            #from doekbase.data_api.annotation.genome_annotation.service import thrift_client
            from doekbase.data_api.annotation.genome_annotation.api import GenomeAnnotationClientAPI
            api = GenomeAnnotationClientAPI(
                apiurl, token, 'ReferenceGenomeAnnotations/kb|g.166819')
        else:
            raise Exception("Service not activated: {}".format(service_name))
    except Exception as e:
        print '3 ' + service_name + '_api - UNKNOWN - could not load client library for ' + service_name + ' ' + str(
            sys.path) + ' ' + str(sys.exc_info()[0])
        raise

    if service_name == 'genome_annotation':
        try:
            feature_types = api.get_feature_types()
            if 'CDS' in feature_types:
                print '0 ' + service_name + '_api - OK - feature_type returned ' + str(
                    feature_types)
            else:
                print '2 ' + service_name + '_api - CRITICAL - unexpected feature_types returned ' + str(
                    feature_types)
        except:
            print '2 ' + service_name + '_api - CRITICAL - unexpected error encountered ' + str(
                sys.exc_info()[0])

    if service_name == 'taxon':
        try:
            lineage = api.get_scientific_lineage()
            if 'Ostreococcus' in lineage:
                print '0 ' + service_name + '_api - OK - expected lineage OK ' + str(
                    lineage)
            else:
                print '2 ' + service_name + '_api - CRITICAL - unexpected lineage ' + str(
                    lineage)
        except:
            print '2 ' + service_name + '_api - CRITICAL - unexpected error encountered ' + str(
                sys.exc_info()[0])

    if service_name == 'assembly':
        try:
            stats = api.get_stats()
            ref_num_contigs = 21
            if stats['num_contigs'] == ref_num_contigs:
                print '0 ' + service_name + '_api - OK - ' + str(
                    ref_num_contigs) + ' contigs found'
            else:
                print '2 ' + service_name + '_api - CRITICAL - ' + str(
                    stats['num_contigs']) + ' contigs found, not ' + str(
                        ref_num_contigs)
        except:
            print '2 ' + service_name + '_api - CRITICAL - unexpected error encountered ' + str(
                sys.exc_info()[0])