def fetch_feature(feature, anchor, path_ddbb): (c, db) = link_db(path_ddbb) pfam_hits = [] query = c.execute(""" SELECT * FROM %s WHERE id='%s' """ % (feature, anchor)) # query = c.execute("""SELECT * FROM uniprot_ptms WHERE uniprot_id = "Q8IZP0" """) # Row_id Uniprot_id postion Value ['*'] in pfam ['*',enzymatic bool] for row in query: uniprot_id = row[0] start = int(row[1]) end = int(row[2]) pfam_id = row[3] pfam_hits.append([uniprot_id, start, end, pfam_id]) c.close() return pfam_hits
def fetch_feature(feature, anchors_map, path_ddbb): (c, db) = link_db(path_ddbb) dict_feature = {} for anchor in anchors_map: # print anchor query = c.execute(""" SELECT * FROM %s WHERE id='%s' """ % (feature, anchor.strip())) # query = c.execute("""SELECT * FROM uniprot_ptms WHERE uniprot_id = "Q8IZP0" """) # Row_id Uniprot_id postion Value ['*'] in pfam ['*',enzymatic bool] for row in query: uniprot_id = row[0] index = int(row[1]) value = row[2] if dict_feature.has_key(uniprot_id): dict_feature[uniprot_id][index] = value else: dict_feature[uniprot_id] = {index: value} c.close() return dict_feature