예제 #1
0
 def protein_query(protname):
     protein_to_search = tfc_label = ''
     query = createquery('SELECT ?subject WHERE {?subject sybig:name "' +
                         str(protname) + '"}')
     # print("Checking where " + protname + "belongs to")
     uri_unparsed = rq.get(FUSEKI_URL,
                           params={
                               'format': 'json',
                               'query': query
                           })
     uri = uri_unparsed.json()
     for x in uri['results']['bindings']:
         protein_to_search = x['subject']['value']
         # print("Found " + protein_to_search)
         query = createquery('SELECT ?subject WHERE {<' +
                             str(protein_to_search) +
                             '> sybig:belongs_to ?subject}')
         tfc_unparsed = rq.get(FUSEKI_URL,
                               params={
                                   'format': 'json',
                                   'query': query
                               })
         tfc = tfc_unparsed.json()
         for y in tfc['results']['bindings']:
             tfc_label = tfc_uri_to_label(y['subject']['value'])
     return protein_to_search, tfc_label
예제 #2
0
def collect_tfc_ids(mode, level):
    tf_list = []
    if level == "All":
        query = createquery(
            'SELECT ?subject WHERE {?subject sybig:tfclass_id ?o}')
    else:
        query = createquery(
            'SELECT ?subject WHERE {?subject sybig:tfclass_id ?o ; sybig:level "'
            + str(level) + '" .}')
    tf_list_unparsed = rq.get(FUSEKI_URL,
                              params={
                                  'format': 'json',
                                  'query': query
                              })
    tf_list_json = tf_list_unparsed.json()
    for x in tf_list_json['results']['bindings']:
        if mode == 0:
            element = x['subject']['value']  # .replace("localhost", "coyote")
            tf_list.append(element)
        else:
            temp_ids = x['subject']['value']
            id_splitter = temp_ids.split('/')
            id_splitter = id_splitter[len(id_splitter) - 1]
            tf_list.append(id_splitter)
    tf_list.sort()
    return tf_list
예제 #3
0
def get_node(tfc_id):
    query = createquery('SELECT ?subject ?pred ?object WHERE {\n' +
                        '?subject sybig:tfclass_id "' + tfc_id + '" .\n' +
                        '?subject ?pred ?object}\n')
    res = rq.get(FUSEKI_URL, params={'format': 'json', 'query': query})
    data = res.json()
    # Return the URI to given TFClass ID aswell
    tmp = data['results']['bindings'][0]
    subject = tmp['subject']['value']

    return data, subject
예제 #4
0
def collect_tf_proteins():
    prot_list = []
    query = createquery(
        'SELECT ?subject WHERE { ?subject sybig:level ?o FILTER ('
        ' !EXISTS {	?subject sybig:tfclass_id ?o2})}')
    prot_list_unparsed = rq.get(FUSEKI_URL,
                                params={
                                    'format': 'json',
                                    'query': query
                                })
    prot_list_json = prot_list_unparsed.json()
    for x in prot_list_json['results']['bindings']:
        prot_list.append(x['subject']['value'])
    prot_list.sort()
    return prot_list
예제 #5
0
 def add_single_dbd(dbd):
     dbd = dbd.rstrip()
     query = createquery(
         'SELECT ?subject WHERE { ?subject <http://sybig.de/tfclass#name> "'
         + protein.strip() + '"}')
     query_out = rq.get(FUSEKI_URL,
                        params={
                            'format': 'json',
                            'query': query
                        })
     query_out_json = query_out.json()
     for element in query_out_json['results']['bindings']:
         protein_uri = element['subject']['value']
         # protein_uri = protein_uri.replace("localhost", "coyote")
         turtlefile = rq.get(protein_uri).text
         print(protein_uri + " ----- " + dbd)
         with open("temp_turtle", "w") as update:
             update.write(turtlefile)
             update.write('\n<' + protein_uri + '> sybig:dbd "' + dbd +
                          '" .')
         os.system(
             'curl -X PUT -H "Content-type: text/turtle" --data-binary "@temp_turtle" "'
             + protein_uri + '"')
예제 #6
0
import requests as rq
from queryCreator import createquery
from database import FUSEKI_URL

with open('TF_ids.tsv', "w") as tsvfile:
    tf_list = []
    query = createquery('SELECT ?subject WHERE {?subject sybig:tfclass_id ?o}')
    tf_list_unparsed = rq.get(FUSEKI_URL,
                              params={
                                  'format': 'json',
                                  'query': query
                              })
    tf_list_json = tf_list_unparsed.json()
    # print(tf_list_json)
    for x in tf_list_json['results']['bindings']:
        tf_list.append(x['subject']['value'])

    tf_list.sort()
    tsvfile.write("TFClass_ID\tTF_Label\tConsensus Sequence\n")
    res_list = []
    last_triple = []
    for tfc in tf_list:
        # print("Found " + tfc)
        query = createquery('SELECT ?n ?o ?i WHERE\n {<' + tfc +
                            '> sybig:consensus_sequence ?i . \n' + '<' + tfc +
                            '> rdfs:label ?o . \n' + '<' + tfc +
                            '> sybig:tfclass_id ?n}')
        # print("Created query: " + query)
        res = rq.get(FUSEKI_URL, params={'format': 'json', 'query': query})
        data = res.json()
        if data['results']['bindings']:  # Non-empty result