Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
__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']
template_string = '''
{{{{GNF_Protein_box
| Name =
| image = {{{{#property:P469|from={human}}}}}
| image_source =
| PDB =
| HGNCid =
| MGIid =
| Symbol = {{{{#property:P479|from={human}}}}}
| AltSymbols = {{{{#property:P477|from={human}}}}}
| IUPHAR =
| ChEMBL =
| OMIM = <!--{{{{#property:P496|from={human}}}}}-->
| ECnumber =
| Homologene =
| GeneAtlas_image1 =
| GeneAtlas_image2 =
| GeneAtlas_image3 =
| Protein_domain_image =
| Function =
| Process =
| Hs_EntrezGene = {{{{#property:P475|from={human}}}}}
| Hs_Ensembl = {{{{#property:P480|from={human}}}}}
| Hs_RefseqmRNA = {{{{#property:P481|from={human}}}}}
| Hs_RefseqProtein =
| Hs_GenLoc_db =
| Hs_GenLoc_chr = {{{{#property:P474|from={human}}}}}
| Hs_GenLoc_start = {{{{#property:P470|from={human}}}}}
| Hs_GenLoc_end = {{{{#property:P472|from={human}}}}}
| Hs_Uniprot = {{{{#property:P463|from={human}}}}}
| Mm_EntrezGene = {{{{#property:P475|from={mouse}}}}}
| Mm_Ensembl = {{{{#property:P480|from={mouse}}}}}
| Mm_RefseqmRNA = {{{{#property:P481|from={mouse}}}}}
| Mm_RefseqProtein =
| Mm_GenLoc_db =
| Mm_GenLoc_chr = {{{{#property:P474|from={mouse}}}}}
| Mm_GenLoc_start = {{{{#property:P470|from={mouse}}}}}
| Mm_GenLoc_end = {{{{#property:P472|from={mouse}}}}}
| Mm_Uniprot = {{{{#property:P463|from={mouse}}}}}
| path = PBB/{{{{#property:P475|from={human}}}}}
}}}}
'''
site = pywikibot.Site("test", "wikipedia")
for count, i in enumerate(gene_list):
new_template_string = template_string.format(human=hgid[count], mouse=mgid[count])
print(new_template_string)
page = pywikibot.Page(site, pages[count])
# page_text = page.get()
# new_text = page.text
page.put(newtext=new_template_string)
# print(site.family.nicepath(site.lang))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment