예제 #1
0
def update_pagerank():
    print('Query for uris')
    uri_response = query.query_sparql(uri_query)
    print('Query for uris complete')
    adjacency_list = populate_uris(uri_response)

    print('Query for links')
    link_response = query.query_sparql(link_query)
    print('Query for links complete')
    populate_links(link_response, adjacency_list)

    g = graph(adjacency_list)
    print('Running pagerank')
    pr = pagerank(g, tolerance=float(utils.get_config()['pagerank_tolerance']))
    print('Running pagerank complete')
    pr_vector = np.squeeze(np.asarray(pr))

    return make_uri2rank(pr_vector, g.uri2index)
예제 #2
0
def update_clusters():
    print('Query for sequences')
    sequences_response = query.query_sparql(sequence_query)
    print('Query for sequences complete')
    write_fasta(sequences_response)

    print('Running uclust')
    run_uclust()
    print('Running uclust complete')

    analyze_uclust()
    return uclust2clusters()
예제 #3
0
def update_pagerank():
    utils.log('Query for uris')
    uri_response = query.query_sparql(uri_query)
    utils.log('Query for uris complete')
    adjacency_list = populate_uris(uri_response)

    utils.log('Query for links')
    link_response = query.query_sparql(link_query)
    utils.log('Query for links complete')
    populate_links(link_response, adjacency_list)

    g = graph(adjacency_list)
    utils.log('Running pagerank')
    pr = pagerank(g, tolerance=float(utils.get_config()['pagerank_tolerance']))
    utils.log('Running pagerank complete')
    pr_vector = np.squeeze(np.asarray(pr))

    # after squeeze, make sure it at least has a dimension in the case that there is only one element
    if pr_vector.shape == ():
        pr_vector = np.array([pr_vector])
    
    return make_uri2rank(pr_vector, g.uri2index)
예제 #4
0
def incremental_remove_collection(subject, uri_prefix):
    collection_membership_query = '''
    SELECT
        ?s
    WHERE {
        <''' + subject + '''> sbol2:member ?s .
        FILTER(STRSTARTS(str(?s),''' + "'" + uri_prefix + "'" + '''))
    }
    '''
    members = query.query_sparql(collection_membership_query)

    delete_subject(subject)
    for member in members:
        delete_subject(member['s'])