Skip to content

Instantly share code, notes, and snippets.

View sebotic's full-sized avatar

sebotic

  • The Scripps Research Institute
  • La Jolla, CA
View GitHub Profile
import requests
query = '''
select distinct ?p1 where {
VALUES ?pd {
<http://www.wikidata.org/entity/Q423026>
<http://www.wikidata.org/entity/Q616005>
<http://www.wikidata.org/entity/Q7644128>
<http://www.wikidata.org/entity/Q898273>
<http://www.wikidata.org/entity/Q898362>
@sebotic
sebotic / wikidata_mygene_wrapper.py
Created March 18, 2016 23:11
a script to retrieve a mapping from entrez id to Wikidata QID and English Wikipedia pages
import requests
import urllib
import json
__author__ = 'Sebastian Burgstaller'
__license__ = 'AGPLv3'
prefix = '''
PREFIX schema: <http://schema.org/>
PREFIX wd: <http://www.wikidata.org/entity/>
@sebotic
sebotic / gene_ontology_evidence_codes.py
Created March 18, 2016 04:26
Gene Ontology evidence codes to determine how a certain annotation came into existance
# instance of Gene Ontology Evidence code (Q23173209)
go_evidence_codes = {
'EXP': 'Q23173789',
'IDA': 'Q23174122',
'IPI': 'Q23174389',
'IMP': 'Q23174671',
'IGI': 'Q23174952',
'IEP': 'Q23175251',
'ISS': 'Q23175558',
'ISO': 'Q23190637',
@sebotic
sebotic / latest_rev.py
Created February 18, 2016 06:22
Retrieves the latest revision for all Wikidata items which are retrieved by a SPARQL query
import requests
import PBB_login
import sys
import pprint
__author__ = 'Sebastian Burgstaller-Muehlbacher'
__license__ = 'AGPLv3'
def exec_wd_query(y):
rev_id_block = [x[1] for x in y]
@sebotic
sebotic / WD_WP_disease_mapping.py
Created July 25, 2015 00:49
maps the labels of Wikidata QIDs to the appropriate Wikipedia pages
#!/usr/bin/env python
# -*- coding: utf-8 -*-
__author__ = 'Sebastian Burgstaller'
__licence__ = 'GPLv3'
import PBB_Core
import pandas as pd
import requests
import os
eferences = { 'P279': [ { 'ref_properties': ['P248', 'P143', 'TIMESTAMP'],
'ref_values': ['Q17939676', 'Q20641742', 'TIMESTAMP']}],
'P351': [ { 'ref_properties': ['P248', 'P143', 'TIMESTAMP'],
'ref_values': ['Q17939676', 'Q20641742', 'TIMESTAMP']}],
'P353': [ { 'ref_properties': ['P248', 'P143', 'TIMESTAMP'],
'ref_values': ['Q17939676', 'Q20641742', 'TIMESTAMP']}],
'P703': [ { 'ref_properties': ['P248', 'P143
9;, 'TIMESTAMP'],
'ref_values': ['Q17939676', 'Q20641742', 'TIMESTAMP']}]}
__author__ = 'Sebastian Burgstaller'
__licence__ = 'GPLv3'
"""
Test retrieval and construction of a WD json representation
"""
import PBB_Core
import pprint
import time
from PBB_login import WDLogin
__author__ = 'Sebastian Burgstaller'
from PBB_login import WDLogin
import requests
import json
import pprint
user = ''
pwd = ''
__author__ = 'sebastian'
__license__ = 'GPLv3'
import pywikibot
import pywikibot.login
gene_list = ['BRCA1', 'REELIN', 'MYL2', 'TP53', 'INS']
hgid = ['Q1232', 'Q1235', 'Q1236', 'Q1234', 'Q1233']
mgid = ['Q1238', 'Q1239', 'Q1240', 'Q1237', 'Q1241']
pages = ['Template:PBB/672', 'Template:PBB/5649', 'Template:PBB/4633', 'Template:PBB/7157', 'Template:PBB/3630']