Content deleted Content added
per edit request on talk page - include gene expression calls via "expressed in" statements from Wikidata / Bgee database Tag: Reverted |
Much more elegant dark mode fix; see talk |
||
(24 intermediate revisions by 8 users not shown) | |||
Line 1:
local p = {
local localSeparatorStr = "," -- **lclz** Correct it if your wiki has different setting, like zhwiki uses "、" for now
local localNotApplicableStr = "n/a" -- **lclz**
local root
--define Global Color Scheme
local rowBGcolor = 'light-dark(#eee, #27292d) !important' --'var(--background-color-neutral)'
local titleBGcolor = 'light-dark(#ddd, #404244) !important'
local sideTitleBGcolor = 'light-dark(#c3fdb8, #003500) !important'
-- wrapped "protected call", return "value error" with error info on error
local function check_values(f,args)
end
local function trim(s)
return (s:gsub("^%s*(.-)%s*$", "%1"))
end
--texts relevant to localization are tagged with --**lclz** and/or *lclz*
--on a page {{#invoke:Sandbox/genewiki/alllua|getTemplateData|QID=Q14865053}}
Line 24 ⟶ 32:
--frame.args = {QID="Q14865053"} Q18031325
--print(p.getTemplateData(frame))
function p.getTemplateData
--make some guesses about whether the provided QID is a good one
--could expand here if we had some kind of error handling framework
--did we get it from the page
local root_qid = mw.text.trim(frame.args['QID']
local mm_qid = ""
--pull all the entity objects that we will need
local
local
local
local
local
local mouse_propertyID = "P684" --actually ortholog property additional orthologs can exist
Line 43 ⟶ 51:
--get root gene entity
if root_qid == "" then
entity = mw.wikibase.
if entity then root_qid = entity.id else root_qid = "" end
Line 51 ⟶ 59:
end
local subclass = p.getValue(entity, "P31") or ""
if string.find(subclass, 'protein') then --if protein switch entity to gene **lclz**
local claims
if entity.claims then
if claims then
--go through each index and reassign entity
Line 69 ⟶ 78:
end --will return nothing if no claims are found
end
--get the other related entities
if entity then
local claims
if claims then
--go through each index and then make entity_protein indexed
Line 91 ⟶ 99:
end
claims = entity.claims[mouse_propertyID]
end
Line 104 ⟶ 112:
end
local quals
if v.qualifiers then
Line 127 ⟶ 135:
end
claims = entity_mouse.claims[protein_propertyID]
end
for k, v in pairs(claims) do
local protein_itemID = "Q" .. claims[#entity_mouse_protein + 1].mainsnak.datavalue.value["numeric-id"]
Line 138 ⟶ 146:
end
end --will return nothing if no claims are found
end
if entity then --only require the main gene entity
--a list variables of all the data in the info box
local name = check_values(p.getLabel,{entity})
local bgee_wikidata_id = 'Q54985720'
local expressed_in_tissues = check_values(p.getValue, {entity, "P5572", localNotApplicableStr, localSeparatorStr, bgee_wikidata_id}) --P5572: expressed in
local expressed_in_mouse_tissues = check_values(p.getValue, {entity_mouse, "P5572", localNotApplicableStr, localSeparatorStr, bgee_wikidata_id}) --P5572: expressed in
local entrez_gene = check_values(p.getValue, {entity, "P351", localNotApplicableStr} )
local entrez_gene_mm = check_values(p.getValue, {entity_mouse, "P351", localNotApplicableStr})
local image = check_values( p.getImage, {entity, "P18", " ", "250px"}) --need to set size
local uniprotID_hs = check_values(p.getValueProtein, {entity_protein, "P352", localNotApplicableStr})
local gstart = check_values(p.getChromosomeLoc, {entity, "P644", "hg"})
local gend = check_values(p.getChromosomeLoc, {entity, "P645", "hg"})
local chr = check_values(p.trimChromosome, {entity})
local db = check_values(p.getAliasFromGenomeAssembly, {entity,"hg"})
local gstart_mm = check_values(p.getChromosomeLoc, {entity_mouse, "P644", "mm"})
local gend_mm =
local chr_mm = check_values( p.trimChromosome, {entity_mouse})
local db_mm = check_values(p.getAliasFromGenomeAssembly, {entity_mouse,"mm"})
local disease, dis_ref =
local drug, drug_ref, drug_pqid, drug_pname = p.getDrug(entity_protein, "P129")
--local drug = check_values(p.getDrug, {entity_protein, "P129"})
p.createTable()
p.renderIdentifiers(aliases, hgnc_id, gene_symbol, homologene_id, omim_id, mgi_id, ChEMBL_id, IUPHAR_id, ec_no, entrez_gene, ensembl)
--uncomment here to add a section of the infobox about genetically related diseases, with references
--if (disease ~= "" and dis_ref ~= "") then --removes section from those items without disease info
Line 203 ⟶ 206:
--end
--if (drug ~= "" ) then --removes section from those items without drug info
-- p.renderDrug(frame,drug, drug_ref, drug_pqid, drug_pname)
if (chr ~= "" and gstart ~= "" and gend ~= "") or (chr_mm ~= "" and gstart_mm ~= "" and gend_mm ~= "") then
Line 212 ⟶ 215:
end
if expression_images ~= "" or expressed_in_tissues ~= localNotApplicableStr then
p.renderRNAexpression(expression_images, entrez_gene, ensembl,
end
if (mol_funct ~= "" and cell_comp ~= "" and bio_process ~= "") then
Line 221 ⟶ 224:
return tostring(root)
else
return "An Error has occurred retrieving Wikidata item for infobox"
end
end
function p.createTable
--this template needs a stylesheet and a 'infobox-gene' class
:css('width', '26.4em')
end
end
--Title above image
function p.renderUpperTitle
local title = name
end
--This is a place holder for the image caption, which is stored in wikicommons comments unsure how to access
function p.renderCaption
--caption
end
--gets default image
function p.renderImage
root
end
function p.renderAvailableStructures(uniprotID_hs, uniprotID_mm, checkOrtholog, pdbIDs)
local title = 'Available structures' --**lclz**
local pdb_link = "[[Protein_Data_Bank|PDB]]" --**lclz**
local searchTitle = ""
local listTitle = "List
local PDBe_base = 'https://www.ebi.ac.uk/pdbe/searchResults.html?display=both&term='
local RCSB_base = 'https://www.rcsb.org/search?q='
..'rcsb_polymer_entity_container_identifiers.reference_sequence_identifiers.database_name:UniProt%20AND%20'
..'rcsb_polymer_entity_container_identifiers.reference_sequence_identifiers.database_accession:'
if checkOrtholog == 1 and uniprotID_mm ~= 'n/a' then
searchTitle = 'Ortholog search: ' --**lclz**
url_uniprot = uniprotID_mm..','..uniprotID_hs
else
searchTitle = 'Human UniProt search: ' --**lclz**
url_uniprot = uniprotID_hs
end
local PDBe_list = " " --create a list with " or " if there is more than one uniprot
--get first uniprot in a list
if url_uniprot:match("([^,]+),") then--first check if there is a list if not just assume one value
PDBe_list = string.gsub(url_uniprot, ",", "%%20or%%20") --add or's inststead of commas
Line 319 ⟶ 318:
end
:css('color', 'inherit')
:css('text-align', 'left')
:css('background-color', titleBGcolor)
:css('color', 'inherit')
:wikitext(title)
:done() --end th
:done() --end tr
:done() --end th
:css('background-color', rowBGcolor)
:wikitext(searchTitle)
:attr('class', 'plainlinks')
:wikitext(RCSB)
:done() --end td
:done() --end tr
:css('background-color', titleBGcolor)
:done() --end td
:done() --end tr
else
return ""
end
end
function p.renderIdentifiers
local title = "Identifiers" --**lclz**
local label_aliases = "[[Gene nomenclature|Aliases]]" --**lclz**
local symbol_url
if gene_symbol == "" or gene_symbol == nil
symbol_url = ""
else
if hgnc_id == "" or hgnc_id == nil
symbol_url = gene_symbol
Line 418 ⟶ 422:
symbol_url = "[https://www.genenames.org/data/gene-symbol-report/#!/hgnc_id/"..hgnc_id.." "..gene_symbol.."]"
end
-- *lclz*: see getAliases. You can, say, use another punctuation for your language.
local label_ext_id = "External IDs" --**lclz**
omim_id = string.gsub(omim_id, "%s", "")
local omim_list = mw.text.split(omim_id, localSeparatorStr)
Line 439 ⟶ 442:
end
end
omim = trim(string.gsub(omim, ", $","
homologene_id = string.gsub(homologene_id, "%s", "")
local homolo_list = mw.text.split(homologene_id, localSeparatorStr)
Line 452 ⟶ 454:
end
end
homolo = trim(string.gsub(homolo, ", $","
local genecards = "[[GeneCards]]"..": "
genecards = genecards.."[https://www.genecards.org/cgi-bin/carddisp.pl?gene="..gene_symbol.." "..gene_symbol.."]
mgi_id = string.gsub(mgi_id, "%s", "")
local mgi_list = mw.text.split(mgi_id, localSeparatorStr)
Line 470 ⟶ 469:
end
end
mgi = trim(string.gsub(mgi, ", $","
local ChEMBL = ""
if string.match(ChEMBL_id, '%w+') then
Line 478 ⟶ 476:
local IUPHAR = ""
if string.match(IUPHAR_id, '%w+') then
IUPHAR = "[[International_Union_of_Basic_and_Clinical_Pharmacology|IUPHAR]]"..": ".."[http://www.guidetopharmacology.org/GRAC/ObjectDisplayForward?objectId="..IUPHAR_id.." "..IUPHAR_id.."]
end -- *lclz*
local label_EC = "[[Enzyme_Commission_number|EC number]]" --**lclz**
Line 484 ⟶ 482:
ec_no = string.gsub(ec_no, "%d%.%d+%.%d+%.%-", "")--remove those with"-" not in list
local link_ec_no = string.gsub(ec_no, "," ,"+") --create format for link
local EC = "[https://www.genome.jp/dbget-bin/www_bget?enzyme+" .. link_ec_no .. " " .. ec_no .. "]"
local oma = "[[Orthologous_MAtrix|OMA]]:"
oma = oma.."[https://omabrowser.org/oma/vps/"..mw.text.split(ensembl,",")[1].." "..gene_symbol.." - orthologs]"
external_id_table = {omim, mgi, homolo, ChEMBL, IUPHAR, genecards, oma}
external_id_processed_table = {}
for i, v in ipairs(external_id_table) do
if (v ~= "") then
external_id_processed_table[#external_id_processed_table + 1] = v
end
end
external_ids = tostring(table.concat(external_id_processed_table, "; "))
root
:tag('tr')
:css('color', 'inherit')
:wikitext(title)
:done() --end tr
:attr('scope',
:css('background-color', sideTitleBGcolor) :attr('class', 'plainlinks') :tag('span')
:attr('class', 'plainlinks')
:wikitext(symbol_url)
:done() --end span
:wikitext(mw.text.nowiki(aliases)) -- escape raw text so it cannot be wikitext markup
:done() --end tr
:css('color', 'inherit')
:wikitext(label_ext_id)
:done() --end th
:attr('colspan', '3')
:css('background-color', rowBGcolor)
:attr('class', 'plainlinks')
:done() --end span
:done() --end td
:done() --end tr
if ec_no ~= "" then
root
:tag('tr')
:tag('th')
:attr('scope', 'row')
:css('background-color', sideTitleBGcolor)
:css('color', 'inherit')
:wikitext(label_EC)
:done() --end th
:tag('td')
:attr('colspan', '3')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:tag('span')
:attr('class', 'plainlinks')
:wikitext(EC)
:done() --end span
:done() --end td
:done() --end tr
end
end
function p.renderDiseases
local title = "Genetically Related Diseases" --**lclz**
Line 575 ⟶ 583:
end
end
:tag('tr')
:tag('td')
:css('color', 'inherit')
:tag('tr') --create title bar
:tag('th')
:attr('colspan', '3')
:css('background-color', titleBGcolor)
:css('color', 'inherit')
:wikitext(title)
:done() --end th
Line 593 ⟶ 603:
:done() --end tr
local ref_url = "https://www.wikidata.org/wiki/"..qid.."#P2293" --direct page to property genetically associated disease
local title = "Diseases that are genetically associated with "..name.." view/edit references on wikidata" --**lclz**
local ref_link = disease_name..frame:extensionTag("ref",frame:expandTemplate{ title = 'cite_web', args = { title = title, url = ref_url} })
Line 601 ⟶ 609:
root
:tag('tr')
:css('color', 'inherit')
:tag('td')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:attr('scope', 'row')
:attr('colspan', '3')
:wikitext(ref_link)
:done() --end td
end
function p.renderDrug(frame,drug, drug_ref, drug_pqid, drug_pname)
local title = "Targeted by Drug" --**lclz**
local ref_flag_all = false --check if any drugs have references if not then don't render the headers
local drug_list_per_protein = {} -- a list of lists of drugs to put in reference string each protein will have a list
--for i,v in ipairs(drug_pqid) do -- set all lists keys to empty so can append without key errors
Line 627 ⟶ 635:
for index,value in ipairs(drug) do
if (drug_ref[index] ~= nil and drug_ref[index] ~= '') then
local protein_qid = drug_pqid[index]
if drug_list_per_protein[protein_qid] == '' or drug_list_per_protein[protein_qid] == nil then
drug_list_per_protein[protein_qid] = value
else
-- *lclz*: comma
end
ref_flag_all = true
Line 638 ⟶ 646:
end
:tag('tr')
:tag('td')
:css('color', 'inherit')
:tag('tr') --create title bar
:tag('th')
Line 650 ⟶ 659:
:css('text-align', 'center')
:css('background-color', titleBGcolor)
:css('color', 'inherit')
:wikitext(title)
:done() --end th
Line 656 ⟶ 666:
:done() --end tr
:css('color', 'inherit')
:tag('td')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:attr('scope', 'row')
:attr('colspan', '3')
:wikitext(ref_link)
:done() --end td
end
function p.renderGeneLocation
local titleHuman = "Gene ___location ([[Human genome|Human]])" --**lclz**
local titleMouse = "Gene ___location ([[Laboratory mouse|Mouse]])" --**lclz**
local tooltip_arrowSign = "Genomic ___location for "..name --**lclz**
if chr ~= "" and gstart ~= "" and gend ~= "" then
Line 758 ⟶ 770:
markerWidth = math.ceil(markerWidth)
end
local markerLocation =
local arrowSignLocation =
markerLocation = math.floor( markerLocation * 10 + 0.5 ) / 10
local source_link_chr, source_link_gstart, source_link_gend
if( db == "hg38" ) then
source_link_chr = frame:extensionTag("ref", "[http://May2017.archive.ensembl.org/Homo_sapiens/Gene/Summary?db=core;g="..ensembl.." GRCh38: Ensembl release 89: "..ensembl.."]
source_link_gstart = frame:extensionTag("ref", "", {name = "refGRCh38Ensembl"})
source_link_gend = frame:extensionTag("ref", "", {name = "refGRCh38Ensembl"})
source_link_chr = frame:extensionTag("ref", "[http://grch37.ensembl.org/Homo_sapiens/Gene/Summary?db=core;&g="..ensembl.." GRCh37: Ensembl release 89: "..ensembl.."]
source_link_gstart = frame:extensionTag("ref", "", {name = "refGRCh37Ensembl"})
source_link_gend = frame:extensionTag("ref", "", {name = "refGRCh37Ensembl"})
source_link_gstart = ""
source_link_gend = ""
Line 782 ⟶ 791:
local wikitext_for_ideogram_image = "" --wikitext used for showing gene ___location
if chr == "MT" then -- wikitext for mitochondrial DNA
--wikitext_for_ideogram_image
--wikitext_for_ideogram_image
--wikitext_for_ideogram_image
--wikitext_for_ideogram_image
--wikitext_for_ideogram_image
else -- wikitext for autosome and sex chromosome
wikitext_for_ideogram_image = wikitext_for_ideogram_image.."<div align=\"center\">"
wikitext_for_ideogram_image = wikitext_for_ideogram_image.."<div style=\"position
wikitext_for_ideogram_image = wikitext_for_ideogram_image.."[[File:Human chromosome "..chr.." ideogram.svg|300px|"..chrText.."]]"
wikitext_for_ideogram_image = wikitext_for_ideogram_image.."<div style=\"position
wikitext_for_ideogram_image = wikitext_for_ideogram_image.."[[File:HSR 1996 II 3.5e.svg|"..arrowSign_width.."px|"..tooltip_arrowSign.."]]</div>"
wikitext_for_ideogram_image = wikitext_for_ideogram_image.."<div style=\"position
wikitext_for_ideogram_image = wikitext_for_ideogram_image.."</div>"
wikitext_for_ideogram_image = wikitext_for_ideogram_image.."</div>"
Line 801 ⟶ 810:
root
:tag('tr')
:attr('class', 'collapsible collapsed') :tag('tr')
:tag('th')
Line 817 ⟶ 827:
:css('text-align', 'center')
:css('background-color', titleBGcolor)
:css('color', 'inherit')
:wikitext(titleHuman)
:done() --end th
Line 825 ⟶ 836:
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:wikitext("[[File:Ideogram human chromosome "..chr..".svg|300px|"..chrText.."]]")
:done() --end td
:done() --end tr
Line 833 ⟶ 845:
:attr('width', '15%')
:css('background-color', sideTitleBGcolor)
:css('color', 'inherit')
:wikitext(label_chr)
:done() --end th
Line 839 ⟶ 852:
:attr('width', '85%')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:tag('span')
:attr('class', 'plainlinks')
:wikitext("[["..chrText.."]]"..source_link_chr)
:done() --end span
:done() --end tr
:tag('tr')
Line 850 ⟶ 864:
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:wikitext(wikitext_for_ideogram_image)
:done() --end td
Line 859 ⟶ 874:
:attr('width', '15%')
:css('background-color', sideTitleBGcolor)
:css('color', 'inherit')
:wikitext(label_locus)
:done() --end th
Line 865 ⟶ 881:
:attr('width', '35%')
:css('background-color', rowBGcolor)
:tag('span')
:attr('class', 'plainlinks')
:wikitext(cytoband)
:done() --end span
:tag('th')
:attr('scope', 'row')
:css('background-color', sideTitleBGcolor)
:css('color', 'inherit')
:wikitext(label_gstart)
:done() --end th
:tag('td')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:tag('span')
:attr('class', 'plainlinks')
:wikitext(p.separateWithComma(gstart).." [[Base pair|bp]]"..source_link_gstart) -- **lclz** Change it if it is inappropriate
:done() --end span
:done() --end tr
:tag('tr')
Line 887 ⟶ 906:
:attr('scope', 'row')
:css('background-color', sideTitleBGcolor)
:css('color', 'inherit')
:wikitext(label_gend)
:done() --end th
:tag('td')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:tag('span')
:attr('class', 'plainlinks')
:wikitext(p.separateWithComma(gend).." [[Base pair|bp]]"..source_link_gend) -- **lclz** Change it if it is inappropriate
:done() --end span
:done() --end tr
:done() --end table
:done() --end tr
end
Line 962 ⟶ 983:
markerWidth_mm = math.ceil(markerWidth_mm)
end
local markerLocation_mm =
local arrowSignLocation_mm =
markerLocation_mm = math.floor( markerLocation_mm * 10 + 0.5 ) / 10
local source_link_chr_mm = ""
Line 972 ⟶ 993:
--But as of now, Aug. 2017, it seems that all data which is stored in Wikidata are based on GRCm38/mm10.
--So treating mouse genomic data as GRCm38/mm10 if not specified.
source_link_chr_mm = frame:extensionTag("ref", "[http://May2017.archive.ensembl.org/Mus_musculus/Gene/Summary?db=core;g="..ensembl_mm.." GRCm38: Ensembl release 89: "..ensembl_mm.."]
source_link_gstart_mm = frame:extensionTag("ref", "", {name = "refGRCm38Ensembl"})
source_link_gend_mm = frame:extensionTag("ref", "", {name = "refGRCm38Ensembl"})
Line 983 ⟶ 1,004:
if chr_mm == "MT" then -- wikitext for mitochondrial DNA
--wikitext_for_ideogram_image_mm = wikitext_for_ideogram_image_mm.."<div align=\"center\">"
--wikitext_for_ideogram_image_mm = wikitext_for_ideogram_image_mm.."<div style=\"position
--wikitext_for_ideogram_image_mm = wikitext_for_ideogram_image_mm.."[[File:Map of the human mitochondrial genome.svg|300px|"..chrText_mm.."]]"
--wikitext_for_ideogram_image_mm = wikitext_for_ideogram_image_mm.."</div>"
Line 990 ⟶ 1,011:
else -- wikitext for autosome and sex chromosome
wikitext_for_ideogram_image_mm = wikitext_for_ideogram_image_mm.."<div align=\"center\">"
wikitext_for_ideogram_image_mm = wikitext_for_ideogram_image_mm.."<div style=\"position
wikitext_for_ideogram_image_mm = wikitext_for_ideogram_image_mm.."[[File:Ideogram of house mouse chromosome "..chr_mm..".svg|300px|"..chrText_mm.."]]"
wikitext_for_ideogram_image_mm = wikitext_for_ideogram_image_mm.."<div style=\"position
wikitext_for_ideogram_image_mm = wikitext_for_ideogram_image_mm.."[[File:HSR 1996 II 3.5e.svg|"..arrowSign_width.."px|"..tooltip_arrowSign.."]]</div>"
wikitext_for_ideogram_image_mm = wikitext_for_ideogram_image_mm.."<div style=\"position
wikitext_for_ideogram_image_mm = wikitext_for_ideogram_image_mm.."</div>"
wikitext_for_ideogram_image_mm = wikitext_for_ideogram_image_mm.."</div>"
Line 1,001 ⟶ 1,022:
root
:tag('tr')
:attr('class', 'collapsible collapsed') :tag('tr')
:tag('th')
Line 1,017 ⟶ 1,039:
:css('text-align', 'center')
:css('background-color', titleBGcolor)
:css('color', 'inherit')
:wikitext(titleMouse)
:done() --end th
Line 1,025 ⟶ 1,048:
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:wikitext("[[File:Ideogram house mouse chromosome "..chr_mm..".svg|260px|"..chrText_mm.."]]")
:done() --end td
Line 1,033 ⟶ 1,057:
:attr('width', '15%')
:css('background-color', sideTitleBGcolor)
:css('color', 'inherit')
:wikitext(label_chr)
:done() --end th
Line 1,039 ⟶ 1,064:
:attr('width', '85%')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:tag('span')
:attr('class', 'plainlinks')
:wikitext(chrText_mm..source_link_chr_mm)
:done() --end span
:done() --end tr
:tag('tr')
Line 1,050 ⟶ 1,076:
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:wikitext(wikitext_for_ideogram_image_mm)
:done() --end td
Line 1,059 ⟶ 1,086:
:attr('width', '15%')
:css('background-color', sideTitleBGcolor)
:css('color', 'inherit')
:wikitext(label_locus)
:done() --end th
Line 1,065 ⟶ 1,093:
:attr('width', '35%')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:tag('span')
:attr('class', 'plainlinks')
Line 1,073 ⟶ 1,102:
:attr('scope', 'row')
:css('background-color', sideTitleBGcolor)
:css('color', 'inherit')
:wikitext(label_gstart)
:done() --end th
:tag('td')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:tag('span')
:attr('class', 'plainlinks')
:wikitext(p.separateWithComma(gstart_mm).." [[Base pair|bp]]"..source_link_gstart_mm) -- **lclz** Change it if it is inappropriate
:done() --end span
:done() --end tr
:tag('tr')
Line 1,087 ⟶ 1,118:
:attr('scope', 'row')
:css('background-color', sideTitleBGcolor)
:css('color', 'inherit')
:wikitext(label_gend)
:done() --end th
:tag('td')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:tag('span')
:attr('class', 'plainlinks')
:wikitext(p.separateWithComma(gend_mm).." [[Base pair|bp]]"..source_link_gend_mm) -- **lclz** Change it if it is inappropriate
:done() --end span
:done() --end tr
:done() --end table
:done() --end tr
end
end
--Get the render elements
--and anatomic entity list for the
function p.
--create list of expressed in anatomic entities
if default_text == nil then default_text = "" end
local anatomic_entity_labels = localNotApplicableStr
local
local split_values = mw.text.split(expressed_in_tissues, localSeparatorStr)
local
local anatomic_entities = {}
local results
for k,v in ipairs(
if string.match(v, '%w+') and v ~= localNotApplicableStr then
anatomic_entities[#anatomic_entities+1] = v
end
end
--if less than 11 don't create collapsible list
if
if
anatomic_entity_labels = localNotApplicableStr
default_text = ""
end
else
end
if
end
results = {
return results
end
function p.renderRNAexpression
ensembl, bgee_expression, ensembl_mouse, bgee_expression_mouse)
local bgee_gene_page = "https://www.bgee.org/gene/"
local title = "[[Gene expression|RNA expression]] pattern" --**lclz**
local biogps_link = ""
Line 1,140 ⟶ 1,178:
biogps_title = "[http://biogps.org/ " .. biogps_title .. "]"
-- If no expression image exist in BioGPS, the N/A is displayed
if expression_images ~= ""
biogps_link = "[http://biogps.org/gene/"..entrez_gene.."/ More reference expression data]" --**lclz**
else
expression_images = localNotApplicableStr
end
local ensembl_id = string.match(ensembl,"%a+%d+") or ""
local ensembl_id_mouse = string.match(ensembl_mouse,"%a+%d+") or ""
local
bgee_title = "[https://www.bgee.org/ " .. bgee_title .. "]"
local bgee_default = "["..bgee_gene_page..ensembl_id.." Top expressed in]"
bgee_expression = p.renderExpressionList(bgee_expression, bgee_default)
local bgee_collapse = bgee_expression[1]
bgee_default = bgee_expression[2]
local bgee_tissues = bgee_expression[3]
local bgee_default_mm = "["..bgee_gene_page..ensembl_id_mouse.." Top expressed in]"
bgee_expression_mouse = p.renderExpressionList(bgee_expression_mouse, bgee_default_mm)
local bgee_collapse_mm = bgee_expression_mouse[1]
bgee_default_mm = bgee_expression_mouse[2]
local bgee_tissues_mm = bgee_expression_mouse[3]
local bgee_more_link = ""
if bgee_tissues ~= localNotApplicableStr then
bgee_more_link = "["..bgee_gene_page..ensembl_id.." More reference expression data]"
end
root
:tag('tr')
:attr('class', 'collapsible collapsed') :tag('tr')
:tag('th')
Line 1,175 ⟶ 1,221:
:css('text-align', 'center')
:css('background-color', titleBGcolor)
:css('color', 'inherit')
:wikitext(title)
:done() --end th
Line 1,180 ⟶ 1,227:
:tag('tr')
:tag('th')
:wikitext(bgee_title)
:wikitext("'''[[Human genome|Human]]'''")
:wikitext("'''[[Laboratory mouse|Mouse]] (ortholog)'''")
:css('width', '100%')
:tag('td')
:attr('colspan', '1')
:tag('span')
:attr('class', 'plainlinks')
:css('margin', '-3px')
:wikitext(bgee_default)
:done() --end span
:done() --end td
:done() --end tr
:tag('tr')
:tag('td')
:attr('colspan', '1')
:tag('div')
:css('margin', '-12px 0px -10px 0px')
:attr('class', 'plainlinks')
:tag('ul')
:css('line-height', '15%')
:css('margin', '9px')
:wikitext(bgee_tissues)
:done() --end ul
:done() --end div
:done() --end td
:done() --end tr
:done() --end table
:done() --end td
:tag('td')
:tag('table')
:attr('class', bgee_collapse_mm)
:css('padding', '0')
:css('border', 'none')
:css('margin', '0')
:css('width', '100%')
:css('text-align', 'center')
:tag('tr')
:tag('td')
:attr('colspan', '1')
:tag('span')
:attr('class', 'plainlinks')
:css('margin', '-3px')
:wikitext(bgee_default_mm)
:done() --end span
:done() --end td
:done() --end tr
:tag('tr')
:tag('td')
:attr('colspan', '1')
:tag('div')
:css('margin', '-12px 0px -10px 0px')
:attr('class', 'plainlinks')
:tag('ul')
:css('line-height', '15%')
:css('margin', '9px')
:wikitext(bgee_tissues_mm)
:done() --end ul
:done() --end div
:done() --end td
:done() --end tr
:done() --end table
:done() --end td
:done() --end tr
:tag('tr')
:tag('td')
:attr('colspan', '4')
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:tag('span')
:attr('class', 'plainlinks')
Line 1,221 ⟶ 1,330:
:done() --end td
:done() --end tr
:done() --end tr
:tag('tr')
:tag('th')
:wikitext(biogps_title)
:done() --end th
:tag('td')
:tag('table')
:attr('colspan', '4')
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:wikitext(expression_images)
:done() --end td
Line 1,251 ⟶ 1,362:
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:tag('span')
:attr('class', 'plainlinks')
Line 1,265 ⟶ 1,377:
end
function p.renderGeneOntology(mol_funct, cell_comp, bio_process, uniprotID)
local title = "[[Gene ontology]]" --**lclz**
local mol_funct_title = "Molecular function" --**lclz**
Line 1,272 ⟶ 1,385:
local amigo_link = "[http://amigo.geneontology.org/" .. " Amigo]"
local quickGO_link = "[https://www.ebi.ac.uk/QuickGO/" .. " QuickGO]"
root
:tag('tr')
:attr('class', 'collapsible collapsed') :css('background-color', sideTitleBGcolor) :css('font-weight', 'bold')
:wikitext(mol_funct_title)
:css('background-color', rowBGcolor) :attr('class', 'plainlinks') :css('font-weight', 'bold')
:wikitext(cell_comp_title)
:css('background-color', rowBGcolor) :attr('class', 'plainlinks') :css('font-weight', 'bold')
:wikitext(bio_process_title)
:css('background-color', rowBGcolor) :attr('class', 'plainlinks') :attr('colspan', '4')
:wikitext(quickGO_link)
:done() --end tr
:done() --end table
:done() --end td
Line 1,357 ⟶ 1,478:
end
function p.renderOrthologs
local title = "[[Orthologs]]" --**lclz**
--to do make the list creation a function
--create list for entrez ids
local category_chromosome = '[[Category:Genes on human chromosome '..chr..']]'-- *lclz*: Category name
if chr == "MT" then
category_chromosome = '[[Category:Human mitochondrial genes]]'-- *lclz*: Category name for mtDNA genes
end
if chr == "" then
category_chromosome = '[[Category:Human genes]]' -- Per [[Wikipedia:Categories for discussion/Log/2023 August 15]]
end
if mw.title.getCurrentTitle().namespace ~= 0 then
Line 1,383 ⟶ 1,506:
end
--if less than 5 don't create collapsible list
if
entrez_collapse = "none"
if entrez_default == nil and table.getn(entrez_link_list) == 0 then entrez_link = localNotApplicableStr end
Line 1,407 ⟶ 1,530:
end
--if less than 5 don't create collapsible list
if
entrez_mm_collapse = "none"
if entrez_mm_default == nil and table.getn(entrez_mm_link_list) == 0 then entrez_mm_link = localNotApplicableStr end
Line 1,432 ⟶ 1,555:
end
--if less than 5 don't create collapsible list
if
ensembl_collapse = "none"
if ensembl_default == nil and table.getn(ensembl_link_list) == 0 then ensembl_link = localNotApplicableStr end
Line 1,444 ⟶ 1,567:
--create list of mouse ensembl id
ensembl_mm = string.gsub(ensembl_mm, "%s", "")
local ensembl_mm_link = localNotApplicableStr
Line 1,457 ⟶ 1,579:
end
--if less than 5 don't create collapsible list
if
ensembl_mm_collapse = "none"
if ensembl_mm_default == nil and table.getn(ensembl_mm_link_list) == 0 then ensembl_mm_link = localNotApplicableStr end
Line 1,467 ⟶ 1,589:
ensembl_mm_link = table.concat(ensembl_mm_link_list, "<br>")
end
--create lists of uniprot ID
Line 1,488 ⟶ 1,609:
if string.match(v, '%w+') and v ~= localNotApplicableStr then
if string.match(v, '^O') or string.match(v,'^P') or string.match(v, '^Q') then
else
uniprot_alternate[#uniprot_alternate+1] = "[" .. concat_uniprot_link .. " " ..label .. "]"
Line 1,496 ⟶ 1,617:
end
end
uniprot_link_list
else
uniprot_link_list
end
--if less than 5 don't create collapsible list
if
uniprot_collapse = "none"
if uniprot_default == nil and table.getn(uniprot_link_list) == 0 then uniprot_link = localNotApplicableStr end
Line 1,515 ⟶ 1,636:
end
local uniprot_mm_link = localNotApplicableStr
local uniprot_mm_collapse
Line 1,521 ⟶ 1,642:
--split string and loop through concatenate by <br>
local split_uniprot_mm = mw.text.split(uniprot_mm, localSeparatorStr)
for k,v in ipairs(split_uniprot_mm) do
uniprot_mm_first[#uniprot_mm_first+1] = "[" .. concat_uniprot_link .. " " ..label .. "]"
else
uniprot_mm_alternate[#uniprot_mm_alternate+1] = "[" .. concat_uniprot_link .. " " ..label .. "]"
end
hash[v] = true
end
end
if table.getn(uniprot_mm_first)>0 then --if there is something in the preferred values display else display anything else
uniprot_mm_link_list
else
uniprot_mm_link_list
end
--if less than 5 don't create collapsible list
if
if uniprot_mm_default == nil and table.getn(uniprot_mm_link_list) == 0 then uniprot_mm_link = localNotApplicableStr end
else
Line 1,557 ⟶ 1,678:
uniprot_mm_link = table.concat(uniprot_mm_link_list, "<br>")
end
local ncbi_link = "https://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?val="
Line 1,577 ⟶ 1,696:
if string.match(v, '%w+') and v ~= localNotApplicableStr then
if string.match(v, 'NM') or string.match(v, 'NP') then
elseif string.match(v, 'XM') or string.match(v, 'XP') then
link_list_alternate[#link_list_alternate+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
end
end
link_list = link_list_first
else
Line 1,590 ⟶ 1,709:
--if less than 5 don't create collapsible list
if
refseq_mRNA_collapse = "none"
if refseq_mRNA_default == nil and table.getn(link_list) == 0 then refseq_mRNA_link = localNotApplicableStr end
else
refseq_mRNA_collapse = "collapsible collapsed"
refseq_mRNA_default
end
Line 1,601 ⟶ 1,720:
refseq_mRNA_link = table.concat(link_list, "<br>")
end
--create list of links for refSeq mRNA for mouse
Line 1,617 ⟶ 1,735:
if string.match(v, '%w+') and v ~= localNotApplicableStr then
if string.match(v, 'NM') or string.match(v, 'NP') then
elseif string.match(v, 'XM') or string.match(v, 'XP') then
link_list_alternate[#link_list_alternate+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
end
end
if table.getn(link_list_first)>0 then
link_list_mm = link_list_first
Line 1,629 ⟶ 1,747:
end
--if less than 5 don't create collapsible list
if
refseq_mRNA_mm_collapse = "none"
if refseq_mRNA_mm_default == nil and table.getn(link_list_mm) == 0 then refseq_mRNA_mm_link = localNotApplicableStr end
Line 1,641 ⟶ 1,759:
end
local refseq_protTitle = "RefSeq (protein)"
--create list of links for human refseq protein
Line 1,649 ⟶ 1,767:
local split_refseq_prot = mw.text.split(refseq_prot, localSeparatorStr)
local link_list_prot = {}
local link_list_alternate = {} --hold those that are XM or XP values
for k,v in ipairs(split_refseq_prot) do
Line 1,656 ⟶ 1,774:
if string.match(v, '%w+') and v ~= localNotApplicableStr then
if string.match(v, 'NM') or string.match(v, 'NP') then
elseif string.match(v, 'XM') or string.match(v, 'XP') then
link_list_alternate[#link_list_alternate+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
Line 1,663 ⟶ 1,781:
end
if table.getn(link_list_first)>0 then
link_list_prot
else
link_list_prot
end
--if less than 5 don't create collapsible list
if
refseq_prot_collapse
if refseq_prot_default == nil and table.getn(link_list_prot) == 0 then refseq_prot_link = localNotApplicableStr end
else
Line 1,675 ⟶ 1,793:
refseq_prot_default = table.remove(link_list_prot, 1) .. '<br>' .. table.remove(link_list_prot, 1) .. '<br>' ..table.remove(link_list_prot, 1) .. '<br>' .. table.remove(link_list_prot, 1) .. '<br>' .. table.remove(link_list_prot, 1) .. '<br>'--get first 5 elements in table and use for display
end
if link_list_prot[#link_list_prot] then
refseq_prot_link = table.concat(link_list_prot, "<br>")
end
--create list of links for mouse refseq protein
Line 1,696 ⟶ 1,812:
if string.match(v, '%w+') and v ~= localNotApplicableStr then
if string.match(v, 'NM') or string.match(v, 'NP') then
elseif string.match(v, 'XM') or string.match(v, 'XP') then
link_list_alternate[#link_list_alternate+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
Line 1,703 ⟶ 1,819:
end
if table.getn(link_list_first)>0 then
link_list_prot_mm
else
link_list_prot_mm
end
--if less than 5 don't create collapsible list
if
refseq_prot_mm_collapse
if refseq_prot_mm_default == nil and table.getn(link_list_prot_mm) == 0 then refseq_prot_mm_link = localNotApplicableStr end
else
Line 1,718 ⟶ 1,834:
refseq_prot_mm_link = table.concat(link_list_prot_mm, "<br>")
end
local locTitle = "Location (UCSC)" -- *lclz*
local gstart_mb = p.locToMb(gstart, 2)
local gend_mb = p.locToMb(gend, 2)
local chr_loc_link =
if (string.match(db, '%w+') and string.match(chr, '%w+') and string.match(gstart, '%w+') and string.match(gend, '%w+') )then
local chr_ucsc
Line 1,745 ⟶ 1,860:
chr_mm_ucsc = chr_mm
end
chr_loc_mm_link =
else
chr_loc_mm_link = localNotApplicableStr
Line 1,762 ⟶ 1,877:
root
:tag('tr')
:tag('td')
:css('text-align', 'center')
:css('border', 'none')
:tag('th')
:attr('colspan', '4')
:css('text-align', 'center')
:css('background-color', titleBGcolor)
:wikitext(title)
:done() --end th
:done() --end tr
:tag('th')
:attr('scope', 'row')
:css('background-color', sideTitleBGcolor)
:wikitext("Species") --**lclz**
:tag('td')
:wikitext("'''Human'''") --**lclz**
:done() --end td
:wikitext("'''Mouse'''") --**lclz**
:done() --end td
:wikitext(entrezTitle)
:done() --end th
:tag('td')
:attr('class', entrez_collapse)
:css('width', '100%')
:css('text-align', 'right')
:tag('tr')
:tag('th')
:attr('colspan', '1')
:wikitext(entrez_default)
:done() --end span
:done() --end th
:tag('tr')
:tag('td')
:attr('colspan', '1')
:tag('p')
:
:wikitext(entrez_link)
:done() --end p
:done() --end td
:done() --end tr
:done() --end table
:done() --end td
:tag('td')
:attr('class', entrez_mm_collapse)
:css('width', '100%')
:css('text-align', 'right')
:tag('tr')
:tag('th')
:attr('colspan', '1')
:wikitext(entrez_mm_default)
:done() --end span
:done() --end th
:tag('tr')
:tag('td')
:attr('colspan', '1')
:tag('p')
:attr('class', 'plainlinks')
:wikitext(entrez_mm_link)
:done() --end p
:done() --end td
:done() --end tr
:done() --end table
:done() --end tr
:tag('th')
:wikitext(ensemblTitle)
:done() --end th
:css('margin', '0')
:css('width', '100%')
:css('text-align', 'right')
:wikitext(ensembl_default)
:done() --end span
:tag('td')
:attr('colspan', '1')
:attr('class', 'plainlinks')
:wikitext(ensembl_link)
:done() --end p
:done() --end td
:done() --end tr
:done() --end table
:done() --end td
:css('margin', '0')
:css('width', '100%')
:css('text-align', 'right')
:tag('tr')
:wikitext(ensembl_mm_default)
:done() --end span
:tag('td')
:attr('colspan', '1')
:tag('p')
:attr('class', 'plainlinks')
:wikitext(ensembl_mm_link)
:done() --end p
:done() --end td
:done() --end tr
:done() --end td
:done() --end tr
:tag('tr')
:wikitext(uniprotTitle)
:done() --end th
:css('padding', '0')
:css('border', 'none')
:css('margin', '0')
:css('width', '100%')
:css('text-align', 'right')
:attr('class', 'plainlinks')
:wikitext(uniprot_default)
:tag('tr')
:tag('td')
:attr('colspan', '1')
:wikitext(uniprot_link)
:done() --end p
:done() --end td
:done() --end tr
:done() --end table
:done() --end td
:css('padding', '0')
:css('border', 'none')
:css('margin', '0')
:css('width', '100%')
:css('text-align', 'right')
:attr('class', 'plainlinks')
:wikitext(uniprot_mm_default)
:tag('tr')
:attr('colspan', '1')
:attr('class', 'plainlinks')
:wikitext(uniprot_mm_link)
:done() --end p
:done() --end td
:done() --end td
:done() --end tr
:tag('th')
:wikitext(refseq_mRNATitle)
:tag('td') --RNASeq mRNA collapsible table
:attr('class', refseq_mRNA_collapse)
:css('padding', '0')
:css('border', 'none')
:attr('class', 'plainlinks')
:wikitext(refseq_mRNA_default)
:tag('td')
:attr('colspan', '1')
:tag('p')
:wikitext(refseq_mRNA_link)
:done() --end span
:done() --end p
:done() --end td
:done() --end tr
:done() --end table
:done() --end td
:tag('td') --RNASeq mRNA collapsible table for mouse
:attr('class', refseq_mRNA_mm_collapse)
:css('padding', '0')
:css('border', 'none')
:attr('class', 'plainlinks')
:wikitext(refseq_mRNA_mm_default)
:tag('td')
:attr('colspan', '1')
:tag('p')
:attr('class', 'plainlinks')
:wikitext(refseq_mRNA_mm_link)
:done() --end span
:done() --end p
:done() --end tr
:done() --end table
:done() --end td
:done() --end tr
:tag('tr')
:tag('th')
:attr('scope', 'row')
:css('background-color', sideTitleBGcolor)
:tag('td') --RNASeq protein collapsible table
:tag('table')
:attr('class', refseq_prot_collapse)
:css('width', '100%')
:css('text-align', 'right')
:attr('class', 'plainlinks')
:wikitext(refseq_prot_default)
:done() --end tr
:tag('td')
:attr('colspan', '1')
:tag('p')
:tag('span')
:attr('class', 'plainlinks')
:wikitext(refseq_prot_link)
:done() --end span
:done() --end p
:done() --end td
:done() --end tr
:done() --end table
:done() --end td
:tag('td') --RNASeq protein collapsible table for mouse
:tag('table')
:attr('class', refseq_prot_mm_collapse)
:css('padding', '0')
:css('border', 'none')
:css('margin', '0')
:css('width', '100%')
:css('text-align', 'right')
:tag('tr')
:tag('th')
:attr('colspan', '1')
:attr('class', 'plainlinks')
:wikitext(refseq_prot_mm_default)
:done() --end th
:done() --end tr
:tag('tr')
:tag('td')
:attr('colspan', '1')
:tag('p')
:tag('span')
:attr('class', 'plainlinks')
:wikitext(refseq_prot_mm_link)
:done() --end span
:done() --end p
:done() --end td
:done() --end tr
:done() --end table
:done() --end td
:done() --end tr
:tag('tr')
:tag('th')
:attr('scope', 'row')
:css('background-color', sideTitleBGcolor)
:css('color', 'inherit')
:wikitext(locTitle)
:done() --end th
:tag('td')
:tag('span')
:attr('class', 'plainlinks')
:wikitext(chr_loc_link)
:done() --end span
:done() --end td
:tag('td')
:tag('span')
:attr('class', 'plainlinks')
:wikitext(chr_loc_mm_link)
:done() --end span
:done() --end td
:done() --end tr
:tag('tr')
:tag('th')
:attr('scope', 'row')
:css('background-color', sideTitleBGcolor)
:css('color', 'inherit')
:wikitext(pubmedTitle)
:done() --end th
:tag('td')
:tag('span')
:attr('class', 'plainlinks')
:wikitext(pubmed_link)
:done() --end span
:done() --end td
:tag('td')
:tag('span')
:attr('class', 'plainlinks')
:wikitext(pubmed_mm_link)
:done() --end span
:wikitext(category_chromosome)
:done() --end td
:done() --end tr
:done() --end table
:done() --end td
:done() --end tr
end
function p.formatRow
:css('text-align', 'left')
:tag('tr') --create title header
:attr('colspan',"2")
:wikitext(title)
:done() --end td
:done() --end tr
end
function p.renderFooter
local text = "[[Wikidata]]" --**lclz**
local hs_link = "[[d:"..Qid.."|View/Edit Human]]" --**lclz**
local mm_link = ""
local link_no_hs
local link_no_mm
if Qid_mm == "" then
else
end
root
:css('
:wikitext(hs_link)
:done() --end td
:tag('td')
:css('
:wikitext(mm_link)
:done() --end td
:done() --end tr
:done() --end table
:done() --end tr
root:done() --end root table
end
--this code isn't used was hoping could do some generalization of rows
function p.rowLabel
root
:css('width', '43px')
:wikitext(label)
--:done()
end
-- look into entity object
function p.getLabel
local data = entity
Line 2,261 ⟶ 2,403:
end
-- Get property values formatted as a string of a given instance/entity.
-- 'entity' parameter denfines the instance from which we want to get some property values.
-- 'propertyID' parameter defines from which property the values are gotten.
-- 'rertun_val' parameter, if no result is returned, the value assigned to this parameter is returned, the default value is an empty string.
-- 'sep' parameter is the separation caracter used to separate returned values (e.g. ','), default is a space caracter, e.g. ' '.
-- Assign to 'stated_in' a wikidata entry id, if getValue() should only return values containing a reference statement 'stated in' (e.g. database, project, catalog). Note that the 'stated_in' parameter is only considered, if the assigned value to 'propertyID' is a wikidata entry.
function p.getValue(entity, propertyID, return_val, sep, stated_in)
local claims
if return_val == nil then return_val = "" end
if entity and entity.claims then
claims = entity.claims[propertyID]
Line 2,277 ⟶ 2,422:
local out = {}
for k, v in pairs(claims) do
local datav = mw.wikibase.label(
if datav == nil then datav = " " end
--Filter statements with the specified stated_in reference value, if none (stated_in = nil) all statements are considered.
local is_from_given_source = true
if stated_in ~= nil then
is_from_given_source = false
if v.references then
for rk, rv in pairs(v.references) do
local ref_val = rv.snaks.P248
if ref_val then
for stated_k, stated_v in pairs(ref_val) do
if (stated_v and stated_v.snaktype == "value" and stated_v.datavalue.type == "wikibase-entityid") then
local ref_stated_in_val = stated_v.datavalue.value["id"]
if ref_stated_in_val == stated_in then is_from_given_source = true end
end
end
end
end
end
end
if is_from_given_source then
out[#out + 1] = datav
end
end
return table.concat(out, sep)
Line 2,291 ⟶ 2,456:
end
function p.getValueProtein
if return_val == nil then return_val = "" end
local sep = ","
for key, val in pairs(protein_entities) do --in cases where there are multiple encodes we loop through each and return concatenated data as a whole
local claims
Line 2,307 ⟶ 2,472:
local out = {}
for k, v in pairs(claims) do
local datav = mw.wikibase.
if datav == nil then datav = " " end
out[#out + 1] = datav
Line 2,326 ⟶ 2,491:
end
end
--general function to get value given an entity and property
function p.getQid
local Qid
if entity and entity.id then
Line 2,342 ⟶ 2,506:
-- *lclz*: Sometimes Wikibase returns punctuations other than "," depending on
-- your site's language. Consider adding a gsub here.
function p.getRefseq_mRNA
if return_val == nil then return_val = "" end
local input_rank = "RANK_PREFERRED" ---this is mostly like won't do anything because ranking isn't maintained in wikidata
Line 2,355 ⟶ 2,519:
local out = {}
for k, v in pairs(claims) do
local sitelink = mw.wikibase.
local label = mw.wikibase.
if label == nil then label = "Q" .. v.mainsnak.datavalue.value["numeric-id"] end
Line 2,379 ⟶ 2,543:
for i, id in ipairs(results_split) do
local trim_id = mw.text.trim(id)
end
if preferred_result then
Line 2,397 ⟶ 2,561:
-- *lclz*: same as getRefseq_mRNA
function p.getRefseq_protein
local sep = localSeparatorStr
local overall_results = {} --should return empty if nothing assigned
Line 2,406 ⟶ 2,570:
local entity = val --each protein in encodes
if entity.claims then
claims = entity.claims[
end
if claims then
Line 2,414 ⟶ 2,578:
local out = {}
for k, v in pairs(claims) do
local datav = mw.wikibase.
if datav == nil then datav = " " end
out[#out + 1] = datav
Line 2,420 ⟶ 2,584:
results = table.concat(out, sep)
else
results = entity:formatPropertyValues(
end
overall_results[#overall_results+1] = results --a list is in each index
Line 2,434 ⟶ 2,598:
local results_split = mw.text.split(str_overall_results, sep) --split complete list so can loop through..probably a more direct way to do this
--loop through results until get a NP or NM or just return whatever is in first element
local preffered_result = results_split[1] or ""
Line 2,455 ⟶ 2,618:
--gets an image
function p.getImage
else
end
function p.getPDB
local pdb_propertyID = "P638"
local overall_results = {}
Line 2,492 ⟶ 2,655:
local results
if (claims[1] and claims[1].mainsnak.snaktype == "value") then
local out = {}
for k, v in pairs(claims) do
local label = mw.wikibase.
if label == nil then label = v.mainsnak.datavalue.value end
Line 2,507 ⟶ 2,669:
results = table.concat(out, ", ") -- *lclz*: punctuation (CJK comma, etc.)
else
results = entity:formatPropertyValues(
end
overall_results[#overall_results+1] = results --individual propertyID values stored in this index
Line 2,516 ⟶ 2,678:
function p.getAliases(entity)
if entity['aliases'] ~= nil then
-- *lclz*: You will need a different language here.
Line 2,524 ⟶ 2,685:
-- so that this function can perform the deduplication here instead of
-- in renderIdentifiers. That way they skip messing with commas and spaces.
local a = ''
for key, value in ipairs(test) do
a = a .. ', ' ..
end
return a
Line 2,538 ⟶ 2,700:
end
--get a geneome start P644 or end P645
function p.getChromosomeLoc
-- will contain the numeric value for the requested coordinate
local output = ""
Line 2,559 ⟶ 2,720:
local newest_build = "0"
-- starts the process
--local entity = mw.wikibase.
local claims
--gets a table of claims on the (genomic start or end) property Q19847637
Line 2,586 ⟶ 2,747:
local qual_obj_id = "Q"..qv.datavalue.value["numeric-id"]
--get to the entity targeted by the qualifier property. Genome builds are Items in wikidata
local qual_obj = mw.wikibase.
local alias = ""
--this uses the aliases to pull out version numbers
Line 2,607 ⟶ 2,768:
end
--in case there are no qualifiers, but there is a ___location, might as well return it
else
output = ___location end
end
else
return ""
Line 2,621 ⟶ 2,783:
end
function p.getAliasFromGenomeAssembly
-- will contain the numeric value for the requested coordinate
local output = ""
Line 2,631 ⟶ 2,793:
local claims
if entity.claims then
end
--will return nothing if no claims are found
Line 2,641 ⟶ 2,803:
--pulls the genome ___location from the claim
for k, v in pairs(claims) do
local ___location = '' -- TODO what should this be? defining ___location is required for 'output = ___location' below
local quals
if v.qualifiers then
Line 2,652 ⟶ 2,815:
local qual_obj_id = "Q"..qv.datavalue.value["numeric-id"]
--get to the entity targeted by the qualifier property. Genome builds are Items in wikidata
local qual_obj = mw.wikibase.
local alias = ""
--this uses the aliases to pull out version numbers
Line 2,674 ⟶ 2,837:
end
--in case there are no qualifiers, but there is a ___location, might as well return it
else
output = ___location end
end
else
return ""
Line 2,688 ⟶ 2,852:
-- *lclz*: Your language's wikidata may have different nouns for chromosome and
-- mitochodria.
function p.trimChromosome
local string_to_trim = p.getValue(entity, "P1057")
local out = ''
Line 2,705 ⟶ 2,869:
end
function p.locToMb
end
function p.isempty
end
function p.getGO(protein_entities, propertyID)
--propertyID ie molecular, cellular, function
Line 2,742 ⟶ 2,905:
for k, v in pairs(claims) do
local itemID_child = "Q" .. v.mainsnak.datavalue.value["numeric-id"] --get Qid of property item so can get the GOid
local entity = mw.wikibase.
local claims
local result_GOID = ''
if entity and entity.claims then claims = entity.claims[propertyID_child] end
if claims then
result_GOID = entity:formatPropertyValues(propertyID_child, {mw.wikibase.entity.claimRanks.RANK_NORMAL}).value
else
result_GOID = nil --no GO ID
end
local sitelink = "http://amigo.geneontology.org/amigo/term/"
local label = mw.wikibase.
if label == nil then label = "Q" .. v.mainsnak.datavalue.value["numeric-id"] end
local wiki_link
if sitelink and result_GOID ~= nil then
wiki_link = "\n* [" .. sitelink .. result_GOID .. " " .. label .."]"
Line 2,775 ⟶ 2,938:
for _,v in ipairs(overall_results) do
end
return table.concat(res, "")
Line 2,793 ⟶ 2,956:
return nil
end
local i = 1
Line 2,814 ⟶ 2,976:
end
function p.getDisease
local return_val = "" -- define variable; this line was 'if return_val == nil then return_val = "" end' which looks like a copy/paste
if entity and entity.claims then
claims = entity.claims[propertyID]
Line 2,831 ⟶ 2,993:
for k, v in pairs(claims) do
local datav = mw.wikibase.
if datav == nil then datav = " " end
local id = "Q" .. v.mainsnak.datavalue.value["numeric-id"]
local linkTarget = mw.wikibase.
local refLink = ""
local ref = ""
ref = getReference("", entity, "P2293", k)
if (ref ~= nil and ref ~= '') then
end
if linkTarget then
Line 2,864 ⟶ 3,026:
return return_val
end
end
function p.getDrug
local datasource = {}
local pname = {}
local pqid = {}
for key, val in pairs(protein_entities) do
Line 2,886 ⟶ 3,047:
if (claims[1] and claims[1].mainsnak.snaktype == "value" and claims[1].mainsnak.datavalue.type == "wikibase-entityid") then
for k, v in pairs(claims) do
local datav = mw.wikibase.
if datav == nil then datav = "" end
local id = "Q" .. v.mainsnak.datavalue.value["numeric-id"]
local linkTarget = mw.wikibase.
local refLink = ""
local ref = getReference(protein_id, entity, "P129",k) --just check if anything returned
if (ref ~= nil and ref ~= '') then
if linkTarget then
pname[protein_id] = name
datasource[#out] = refLink
end --end k,v claims loop
end --end claims[1]
end --if claims
return out, datasource, pqid, pname
end
function p.separateWithComma
--Separate number with comma. For example when this function gets "12345678", returns "12,345,678"
local k
commaSeparated, k = string.gsub(commaSeparated, "^(-?%d+)(%d%d%d)", '%1,%2')
if k == 0
break
end
return commaSeparated
end
|