Module:Infobox gene: Difference between revisions

Content deleted Content added
from /sandbox: update to use new mw.wikibase API changes & remove unused dependencies
Much more elegant dark mode fix; see talk
 
(21 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)
--local u= table.upack(args)
local exist, val = pcall(f, unpack(args))
if exist and val ~= nil then
return(val)
else
-- Leaking some debugging info won't hurt....
return("'''VALUE_ERROR''' (" .. tostring(val) .. ")")
end
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 21 ⟶ 32:
--frame.args = {QID="Q14865053"} Q18031325
--print(p.getTemplateData(frame))
function p.getTemplateData = function(frame)
 
--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'] or "") --try to get it from the args
local mm_qid = ""
--pull all the entity objects that we will need
local entity = {}
local entity_protein = {}
local entity_mouse = {}
local entity_mouse_protein = {}
local checkOrtholog = "" --flag used to see if mouse data avaliable
 
local mouse_propertyID = "P684" --actually ortholog property additional orthologs can exist
Line 48 ⟶ 59:
end
 
--need to figure out if it is protein or gene here
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
claims = entity.claims["P702"] --encoded by
end
if claims then
--go through each index and reassign entity
Line 66 ⟶ 78:
end --will return nothing if no claims are found
end
entity = mw.wikibase.getEntity(root_qid)
end
 
 
--get the other related entities
if entity then
local claims = ""
--get protein entity object
if entity.claims then
claims = entity.claims[protein_propertyID]
end
if claims then
--go through each index and then make entity_protein indexed
Line 88 ⟶ 99:
end
 
--get mouse entity object
if entity.claims then
claims = entity.claims[mouse_propertyID]
end
Line 101 ⟶ 112:
end
 
local mouse_itemID = "Q" .. v.mainsnak.datavalue.value["numeric-id"]
local quals
if v.qualifiers then
Line 124 ⟶ 135:
end
 
--get mouse protein entity object
if entity_mouse and entity_mouse.claims then
claims = entity_mouse.claims[protein_propertyID]
end
if claims then
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 protein_itemID = "Q" .. claims[#entity_mouse_protein + 1].mainsnak.datavalue.value["numeric-id"]
Line 135 ⟶ 146:
end
end --will return nothing if no claims are found
end
 
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}) --P5572: expressed in
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 uniprotID_mm = check_values(p.getValueProtein, {entity_mouse_protein, "P352", localNotApplicableStr})
local pdbIDs = check_values(p.getPDB, {entity_protein}) --makes a list with links to RCSB
local aliases = check_values(p.getAliases, {entity})
local gene_symbol = check_values(p.getValue, {entity, "P353"})
local hgnc_id = check_values(p.getValue, {entity, "P354"})
local homologene_id = check_values(p.getValue, {entity, "P593"})
local omim_id = check_values(p.getValue, {entity, "P492"})
local mgi_id = check_values(p.getValue, {entity_mouse, "P671"})
local ChEMBL_id = check_values(p.getValue, {entity_protein, "P592"})
local IUPHAR_id = check_values(p.getValue, {entity_protein, "P595"})
local ec_no = check_values(p.getValueProtein, {entity_protein, "P591"})
local mol_funct = check_values(p.getGO, {entity_protein, "P680"})
local cell_comp = check_values(p.getGO, {entity_protein, "P681"})
local bio_process = check_values(p.getGO, {entity_protein, "P682"})
local expression_images = check_values(p.getImage, {entity,"P692","<br><br>","250px"})
local ensembl = check_values(p.getValue, {entity, "P594", localNotApplicableStr})
local ensembl_mm = check_values(p.getValue, {entity_mouse, "P594", localNotApplicableStr})
local refseq_mRNA = check_values(p.getRefseq_mRNA, {entity, "P639", localNotApplicableStr})
local refseq_mRNA_mm = check_values(p.getRefseq_mRNA, {entity_mouse, "P639", localNotApplicableStr})
local refseq_prot = check_values(p.getRefseq_protein, {entity_protein, "P637", localNotApplicableStr})
local refseq_prot_mm = check_values(p.getRefseq_protein, {entity_mouse_protein, "P637", 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 cytoband = check_values(p.getValue, {entity, "P4196", localNotApplicableStr})
local db = check_values(p.getAliasFromGenomeAssembly, {entity,"hg"})
local gstart_mm = check_values(p.getChromosomeLoc, {entity_mouse, "P644", "mm"})
local gend_mm = check_values(p.getChromosomeLoc, {entity_mouse, "P645", "mm"})
local chr_mm = check_values( p.trimChromosome, {entity_mouse})
local db_mm = check_values(p.getAliasFromGenomeAssembly, {entity_mouse,"mm"})
local cytoband_mm = check_values(p.getValue, {entity_mouse, "P4196", localNotApplicableStr})
local disease, dis_ref = ''p.getDisease(entity, "P2293")
local drug, drug_ref, drug_pqid, drug_pname = p.getDrug(entity_protein, "P129")
if p.getDisease(entity, "P2293") then disease, dis_ref = p.getDisease(entity, "P2293") else disease, dis_ref = {"'''VALUE_ERROR'''","'''VALUE_ERROR'''" } end
if p.getDrug(entity_protein, "P129") then drug, drug_ref, drug_pqid, drug_pname = p.getDrug(entity_protein, "P129") else drug, drug_ref, drug_pqid, drug_pname = {"'''VALUE_ERROR'''","'''VALUE_ERROR'''" } end
--local drug = check_values(p.getDrug, {entity_protein, "P129"})
 
--define Global Color Scheme
rowBGcolor = '#eee'
titleBGcolor = '#ddd'
sideTitleBGcolor = '#c3fdb8'
 
p.createTable()
p.renderUpperTitle(name)
--p.renderCaption()
p.renderImage(image)
p.renderAvailableStructures(uniprotID_hs, uniprotID_mm, checkOrtholog, pdbIDs) --PDB info
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 200 ⟶ 206:
--end
 
--uncomment here to add a section of the infobox about drugs that target the protein product of this gene, with references
--if (drug ~= "" ) then --removes section from those items without drug info
-- p.renderDrug(frame,drug, drug_ref, drug_pqid, drug_pname)
--end
 
if (chr ~= "" and gstart ~= "" and gend ~= "") or (chr_mm ~= "" and gstart_mm ~= "" and gend_mm ~= "") then
Line 209 ⟶ 215:
end
if expression_images ~= "" or expressed_in_tissues ~= localNotApplicableStr then
p.renderRNAexpression(expression_images, entrez_gene, ensembl, p.renderBgeeExpression(expressed_in_tissues), ensembl_mm, expressed_in_mouse_tissues)
end
if (mol_funct ~= "" and cell_comp ~= "" and bio_process ~= "") then
Line 218 ⟶ 224:
 
return tostring(root)
--return table.concat(drug_pqid)
 
else
else return "An Error has occurred retrieving Wikidata item for infobox"
return "An Error has occurred retrieving Wikidata item for infobox"
end
end
 
function p.createTable = function(subbox)
 
if subbox == 'sub' then --doesn't work
root
:tag('table')
:css('padding', '0')
:css('border', 'none')
:css('margin', '0')
:css('width', 'auto')
:css('min-width', '100%')
:css('font-size', '100%')
:css('clear', 'none')
:css('float', 'none')
:css('background-color', 'transparent')
 
else
root = mw.html.create('table')
root
-- *lclz*: Some projects, like zhwiki (again), use inline styles on
-- infobox modules in addition to the class. Be sure to check them out.
:addClass('infobox')
--this template needs a stylesheet and a 'infobox-gene' class
:css('width', '26.4em')
:css('width', '26.4em')
end
end
 
end
 
--Title above image
function p.renderUpperTitle = function(name)
local title = name
if not title then return "error: failed to get label"; end
 
root
:tag('tr')
:tag('th')
:attr('colspan', 4)
:css('text-align', 'center')
:css('font-size', '125%')
:css('font-weight', 'bold')
:wikitext(title)
:done() --end th
:done() --end tr
end
 
--This is a place holder for the image caption, which is stored in wikicommons comments unsure how to access
function p.renderCaption = function(entity)
--caption
end
 
--gets default image
function p.renderImage = function(image)
 
root
:tag('tr')
:tag('td')
:attr('colspan', 4)
:css('text-align', 'center')
:wikitext(image)
:done() --end td
:done() --end tr
 
end
 
function p.renderAvailableStructures(uniprotID_hs, uniprotID_mm, checkOrtholog, pdbIDs)
 
local title = 'Available structures' --**lclz**
 
local pdb_link = "[[Protein_Data_Bank|PDB]]" --**lclz**
p.renderAvailableStructures = function(uniprotID_hs, uniprotID_mm, checkOrtholog, pdbIDs)
local searchTitle = ""
 
local listTitle = "List localof title =PDB 'Availableid structures'codes" --**lclz**
local PDBe_base = 'https://www.ebi.ac.uk/pdbe/searchResults.html?display=both&amp;term='
local pdb_link = "[[Protein_Data_Bank|PDB]]" --**lclz**
local RCSB_base = 'https://www.rcsb.org/search?q='
local searchTitle = ""
local listTitle = "List of PDB id codes" --**lclz**
local PDBe_base = 'https://www.ebi.ac.uk/pdbe/searchResults.html?display=both&amp;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:'
local url_uniprot = " "
 
if checkOrtholog == 1 and uniprotID_mm ~= 'n/a' then
 
searchTitle = 'Ortholog search: ' --**lclz**
if checkOrtholog == 1 and uniprotID_mm ~= 'n/a' then
url_uniprot = uniprotID_mm..','..uniprotID_hs
searchTitle = 'Ortholog search: ' --**lclz**
else
url_uniprot = uniprotID_mm..','..uniprotID_hs
searchTitle = 'Human UniProt search: ' --**lclz**
else
url_uniprot = uniprotID_hs
searchTitle = 'Human UniProt search: ' --**lclz**
end
url_uniprot = uniprotID_hs
local PDBe_list = " " --create a list with " or " if there is more than one uniprot
end
--get first uniprot in a list
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 316 ⟶ 318:
end
 
local PDBe = "["..PDBe_base..PDBe_list.." PDBe] "
local RCSB = "["..RCSB_base..url_uniprot.." RCSB] "
 
if string.match(pdbIDs, '%w+') then --if there aren't any PDB_ID don't display this part of the infobox
--p.formatRow(title)---how to not close the tags is a mystery and I could condense code once I figure out
root
:tag('tr')
:tag('td')
:attr('colspan', 4)
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:tag('table')
:csstag('padding', '0table')
:css('borderpadding', 'none0')
:css('marginborder', '0none')
:css('widthmargin', '100%0')
:css('text-alignwidth', 'left100%')
:css('text-align', 'left')
:tag('tr') --create title header
:tag('thtr') --create title header
:attrtag('colspan', '4th')
:cssattr('text-aligncolspan', 'center4')
:css('backgroundtext-coloralign',titleBGcolor 'center')
:css('background-color', titleBGcolor)
:wikitext(title)
:css('color', 'inherit')
:done() --end th
:wikitext(title)
:done() --end tr
:done() --end th
:done() --end tr
 
:tag('tr')
:tag('th')
:attr('rowspan', '2')
:css('background-color', sideTitleBGcolor)
:css('widthcolor', '43pxinherit')
:wikitextcss(pdb_link'width', '43px')
:donewikitext(pdb_link) --end th
:done() --end th
:tag('td')
:attrtag('colspan', '2td')
:cssattr('background-colorcolspan', rowBGcolor'2')
:css('background-color', rowBGcolor)
:wikitext(searchTitle)
:tagcss('spancolor', 'inherit')
:wikitext(searchTitle)
:attr('class', 'plainlinks')
:wikitexttag(PDBe'span')
:attr('class', 'plainlinks')
:wikitext(RCSB)
:donewikitext(PDBe) --end span
:wikitext(RCSB)
:done() --end td
:done() --end trspan
:done() --end td
:done() --end tr
 
:tag('tr') --new row for collapsible list of PDB codes
:tag('td')
:tag('table')
:attr('class', 'collapsible collapsed')
:css('padding', '0')
:css('border', 'none')
:css('margin', '0')
:css('width', '100%')
:css('text-align', 'left')
:tag('tr')
:css('backgroundtext-coloralign',titleBGcolor 'center')
:csstag('text-align', 'centerth')
:css('background-color', titleBGcolor)
:tag('th')
:attrcss('colspancolor', '2inherit')
:wikitextattr(listTitle'colspan', '2')
:donewikitext(listTitle) --end th
:done() --end trth
:tagdone(') --end tr')
:tag('tdtr')
:attrtag('colspan', '2td')
:cssattr('background-colorcolspan', rowBGcolor'2')
:tagcss('pbackground-color', rowBGcolor)
:tagcss('spancolor', 'inherit')
:attrtag('class', 'plainlinksp')
:wikitexttag(pdbIDs'span')
:doneattr('class', 'plainlinks') --end span
:donewikitext(pdbIDs) --end p
:done() --end tdspan
:done() --end trp
:done() --end tabletd
:done() --end tdtr
:done() --end trtable
:done() --end tabletd
:done() --end tdtr
:done() --end trtable
:done() --end td
else
:done() --end tr
return ""
else
return ""
end
 
end
 
function p.renderIdentifiers = function(aliases, hgnc_id, gene_symbol, homologene_id, omim_id, mgi_id, ChEMBL_id, IUPHAR_id, ec_no, entrez_gene, ensembl)
local title = "Identifiers" --**lclz**
local label_aliases = "[[Gene nomenclature|Aliases]]" --**lclz**
local symbol_url
if gene_symbol == "" or gene_symbol == nil then
symbol_url = ""
else
if hgnc_id == "" or hgnc_id == nil then
symbol_url = gene_symbol
 
Line 415 ⟶ 422:
symbol_url = "[https://www.genenames.org/data/gene-symbol-report/#!/hgnc_id/"..hgnc_id.." "..gene_symbol.."]"
end
end
 
-- *lclz*: see getAliases. You can, say, use another punctuation for your language.
aliases = string.gsub(aliases, ', '..gene_symbol..'$', '') --get rid of gene name if last in alias list
aliases = string.gsub(aliases, gene_symbol..', ', '') --get rid of gene name if first in aliases list
aliases = string.gsub(aliases, ', '..gene_symbol..',', ',') --get rid of gene name if in aliases list
aliases = string.gsub(aliases, ", ,", ",") --remove comma from middle
aliases = string.gsub(aliases, ", $", "") --remove comma from end
local label_ext_id = "External IDs" --**lclz**
 
omim_id = string.gsub(omim_id, "%s", "")
local omim_list = mw.text.split(omim_id, localSeparatorStr)
Line 436 ⟶ 442:
end
end
omim = trim(string.gsub(omim, ", $"," ") ) --remove comma from end
 
homologene_id = string.gsub(homologene_id, "%s", "")
local homolo_list = mw.text.split(homologene_id, localSeparatorStr)
Line 449 ⟶ 454:
end
end
homolo = trim(string.gsub(homolo, ", $"," ") ) --remove comma from end
 
 
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 467 ⟶ 469:
end
end
mgi = trim(string.gsub(mgi, ", $"," ")) --remove comma from end
 
local ChEMBL = ""
if string.match(ChEMBL_id, '%w+') then
Line 475 ⟶ 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.."] " --**lclz**
end -- *lclz*
local label_EC = "[[Enzyme_Commission_number|EC number]]" --**lclz**
Line 481 ⟶ 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')
:tag('th')
:attr('colspan', '4')
:css('text-align', 'center')
:css('background-color', titleBGcolor)
:css('color', 'inherit')
:wikitext(title)
:wikitext(title)
:done() --end th
:done() --end trth
:done() --end tr
:tag('tr')
:tag('thtr')
:attrtag('scope', 'rowth')
:attr('scope', 'row')
:css('background-color', sideTitleBGcolor)
:tagcss('spancolor', 'inherit')
:tag('span')
:attr('class', 'plainlinks')
:wikitext(label_aliases)
:done() --end span
:done() --end th
 
:tag('td')
:attr('colspan','3')
:css('background', rowBGcolor)
:tagcss('spancolor', 'inherit')
:tag('span')
:attr('class', 'plainlinks')
:attr('class', 'plainlinks')
:wikitext(symbol_url)
:wikitext(symbol_url)
:done() --end span
:done() --end span
:wikitext(aliases)
:wikitext(mw.text.nowiki(aliases)) -- escape raw text so it cannot be wikitext markup
:done() --end td
:done() --end trtd
:done() --end tr
:done() --end tr
 
:tag('tr')
:tag('th')
:attr('scope', 'row')
:css('background-color', sideTitleBGcolor)
:css('color', 'inherit')
:wikitext(label_ext_id)
:wikitext(label_ext_id)
:done() --end th
:done() --end th
:tag('td')
:attrtag('colspan', '3td')
:attr('colspan', '3')
:css('background-color', rowBGcolor)
:css('background-color', rowBGcolor)
:tag('span')
:attrcss('classcolor', 'plainlinksinherit')
:wikitexttag(omim'span')
:attr('class', 'plainlinks')
:wikitext(mgi)
:wikitext(homoloexternal_ids)
:done() --end span
:wikitext(ChEMBL)
:wikitext(IUPHAR)
:wikitext(genecards)
: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)
:wikitext(label_EC)
:done() --end th
:tag('td')
:attr('colspan', '3')
:css('background-color', rowBGcolor)
:tag('span')
:attr('class', 'plainlinks')
:wikitext(EC)
:done() --end span
:done() --end td
:done() --end tr
 
end
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 = function(frame, disease, dis_ref, name, qid)
local title = "Genetically Related Diseases" --**lclz**
 
Line 572 ⟶ 583:
end
end
if ref_flag_all then
root
:tag('tr')
:tag('td')
:attr('colspan', 4)
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:tag('tr') --create title bar
:tag('th')
:attr('colspan', '3')
:css('text-align', 'center')
:css('background-color', titleBGcolor)
:css('color', 'inherit')
:wikitext(title)
:done() --end th
Line 590 ⟶ 603:
:done() --end tr
 
local ref_url = "https://www.wikidata.org/wiki/"..qid.."#P2293" --direct page to property genetically associated disease
 
 
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 598 ⟶ 609:
root
:tag('tr')
:attr('colspan', 4)
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:tag('td')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:attr('scope', 'row')
:attr('colspan', '3')
:wikitext(ref_link)
:done() --end td
:done() --end tr
end
 
end
 
function p.renderDrug(frame,drug, drug_ref, drug_pqid, drug_pname)
 
p.renderDrug = function(frame,drug, drug_ref, drug_pqid, drug_pname)
local title = "Targeted by Drug" --**lclz**
 
--check first to see if any of the drugs have references
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 624 ⟶ 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
drug_list_per_protein[protein_qid] = drug_list_per_protein[protein_qid]..', '..value --each list of drugs keyed on protein qid
end
ref_flag_all = true
Line 635 ⟶ 646:
end
 
if ref_flag_all then
root
:tag('tr')
:tag('td')
:attr('colspan', 4)
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:tag('tr') --create title bar
:tag('th')
Line 647 ⟶ 659:
:css('text-align', 'center')
:css('background-color', titleBGcolor)
:css('color', 'inherit')
:wikitext(title)
:done() --end th
Line 653 ⟶ 666:
:done() --end tr
 
--loop to create reference links from drug lists
for k,v in pairs(drug_list_per_protein) do
local drug_name = v
local ref_url = "https://www.wikidata.org/wiki/"..k.."#P129" --direct page to property genetically associated disease
local title = "Drugs that physically interact with "..drug_pname[k].." view/edit references on wikidata" --**lclz**
local ref_link = drug_name..frame:extensionTag("ref",frame:expandTemplate{ title = 'cite_web', args = { title = title, url = ref_url} })
 
root
:tag('tr')
:attr('colspan', 4)
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:tag('td')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:attr('scope', 'row')
:attr('colspan', '3')
:wikitext(ref_link)
:done() --end td
:done() --end tr
end
end
 
end
 
function p.renderGeneLocation = function(frame, chr, gstart, gend, db, cytoband, ensembl, chr_mm, gstart_mm, gend_mm, db_mm, cytoband_mm, ensembl_mm, name)
local titleHuman = "Gene ___location ([[Human genome|Human]])" --**lclz**
local titleMouse = "Gene ___location ([[Laboratory mouse|Mouse]])" --**lclz**
local label_chr = "[[Chromosome|Chr.]]" --**lclz**
local label_locus = "[[Locus (genetics)|Band]]" --**lclz**
local label_gstart = "Start" --**lclz**
local label_gend = "End" --**lclz**
local tooltip_arrowSign = "Genomic ___location for "..name --**lclz**
local arrowSign_width = 14
 
if chr ~= "" and gstart ~= "" and gend ~= "" then
Line 755 ⟶ 770:
markerWidth = math.ceil(markerWidth)
end
local markerLocation = (147.0666 * (gstart + gend) / chrLength ) + 1.6 - (markerWidth / 2)
local arrowSignLocation = markerLocation + (markerWidth / 2) - (arrowSign_width / 2)
markerLocation = math.floor( markerLocation * 10 + 0.5 ) / 10
 
local source_link_chr, source_link_gstart, source_link_gend
 
local source_link_chr = ""
local source_link_gstart = ""
local 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.."] -&ndash; [[Ensembl genome database project|Ensembl]], May 2017", {name = "refGRCh38Ensembl"}) --**lclz**
source_link_gstart = frame:extensionTag("ref", "", {name = "refGRCh38Ensembl"})
source_link_gend = frame:extensionTag("ref", "", {name = "refGRCh38Ensembl"})
elseif( db == "hg37") then
source_link_chr = frame:extensionTag("ref", "[http://grch37.ensembl.org/Homo_sapiens/Gene/Summary?db=core;&g="..ensembl.." GRCh37: Ensembl release 89: "..ensembl.."] -&ndash; [[Ensembl genome database project|Ensembl]], May 2017", {name = "refGRCh37Ensembl"}) --**lclz**
source_link_gstart = frame:extensionTag("ref", "", {name = "refGRCh37Ensembl"})
source_link_gend = frame:extensionTag("ref", "", {name = "refGRCh37Ensembl"})
else
source_linksource_link_chr = ""
source_link_gstart = ""
source_link_gend = ""
Line 779 ⟶ 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.."<div align=\"center\">"
--wikitext_for_ideogram_image = wikitext_for_ideogram_image.."<div style=\"position\: relative\; width\: 300px\;\">"
--wikitext_for_ideogram_image = wikitext_for_ideogram_image.."[[File:Map of the human mitochondrial genome.svg|300px|"..chrText.."]]"
--wikitext_for_ideogram_image = wikitext_for_ideogram_image.."</div>"
--wikitext_for_ideogram_image = wikitext_for_ideogram_image.."</div>"
 
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\: relative\; width\: 300px\;\">"
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\: absolute\; left\: "..arrowSignLocation.."px\; top\: 2px\; padding\: 0\;\">"
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\: absolute\; left\: "..markerLocation.."px\; top\: 19px\; padding\: 0\;\">[[File:Red rectangle "..markerWidth.."x18.png|"..markerWidth.."px|"..tooltip_arrowSign.."]]</div>"
wikitext_for_ideogram_image = wikitext_for_ideogram_image.."</div>"
wikitext_for_ideogram_image = wikitext_for_ideogram_image.."</div>"
Line 798 ⟶ 810:
root
:tag('tr')
:tag('td')
:attr('colspan', 4)
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:tagcss('tablecolor', 'inherit')
:tag('table')
:attr('class', 'collapsible collapsed')
:css('padding', '0')
:css('border', 'none')
:css('margin', '0')
:css('width', '100%')
:css('text-align', 'left')
:tag('tr')
:tag('th')
Line 814 ⟶ 827:
:css('text-align', 'center')
:css('background-color', titleBGcolor)
:css('color', 'inherit')
:wikitext(titleHuman)
:done() --end th
Line 822 ⟶ 836:
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:wikitext("[[File:Ideogram human chromosome "..chr..".svg|300px|"..chrText.."]]")
:wikitext("[[File:Ideogram human chromosome "..chr..".svg|300px|"..chrText.."]]")
:done() --end td
:done() --end tr
Line 830 ⟶ 845:
:attr('width', '15%')
:css('background-color', sideTitleBGcolor)
:css('color', 'inherit')
:wikitext(label_chr)
:done() --end th
Line 836 ⟶ 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 td
:done() --end tr
:tag('tr')
Line 847 ⟶ 864:
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:wikitext(wikitext_for_ideogram_image)
:done() --end td
Line 856 ⟶ 874:
:attr('width', '15%')
:css('background-color', sideTitleBGcolor)
:css('color', 'inherit')
:wikitext(label_locus)
:done() --end th
Line 862 ⟶ 881:
:attr('width', '35%')
:css('background-color', rowBGcolor)
:tagcss('spancolor', 'inherit')
:tag('span')
:attr('class', 'plainlinks')
:wikitext(cytoband)
:done() --end span
:done() --end td
: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 td
:done() --end tr
:tag('tr')
Line 884 ⟶ 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 td
:done() --end tr
:done() --end table
:done() --end td
:done() --end tr
end
Line 959 ⟶ 983:
markerWidth_mm = math.ceil(markerWidth_mm)
end
local markerLocation_mm = (147.0666 * (gstart_mm + gend_mm) / chrLength_mm ) + 1.6 - (markerWidth_mm / 2)
local arrowSignLocation_mm = markerLocation_mm + (markerWidth_mm / 2) - (arrowSign_width / 2)
markerLocation_mm = math.floor( markerLocation_mm * 10 + 0.5 ) / 10
local source_link_chr_mm = ""
Line 969 ⟶ 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.."] -&ndash; [[Ensembl genome database project|Ensembl]], May 2017", {name = "refGRCm38Ensembl"}) --**lclz**
source_link_gstart_mm = frame:extensionTag("ref", "", {name = "refGRCm38Ensembl"})
source_link_gend_mm = frame:extensionTag("ref", "", {name = "refGRCm38Ensembl"})
Line 980 ⟶ 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\: relative\; width\: 300px\;\">"
--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 987 ⟶ 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\: relative\; width\: 300px\;\">"
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\: absolute\; left\: "..arrowSignLocation_mm.."px\; top\: 2px\; padding\: 0\;\">"
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\: absolute\; left\: "..markerLocation_mm.."px\; top\: 19px\; padding\: 0\;\">[[File:Red rectangle "..markerWidth_mm.."x18.png|"..markerWidth_mm.."px|"..tooltip_arrowSign.."]]</div>"
wikitext_for_ideogram_image_mm = wikitext_for_ideogram_image_mm.."</div>"
wikitext_for_ideogram_image_mm = wikitext_for_ideogram_image_mm.."</div>"
Line 998 ⟶ 1,022:
root
:tag('tr')
:tag('td')
:attr('colspan', 4)
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:tagcss('tablecolor', 'inherit')
:tag('table')
:attr('class', 'collapsible collapsed')
:css('padding', '0')
:css('border', 'none')
:css('margin', '0')
:css('width', '100%')
:css('text-align', 'left')
:tag('tr')
:tag('th')
Line 1,014 ⟶ 1,039:
:css('text-align', 'center')
:css('background-color', titleBGcolor)
:css('color', 'inherit')
:wikitext(titleMouse)
:done() --end th
Line 1,022 ⟶ 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,030 ⟶ 1,057:
:attr('width', '15%')
:css('background-color', sideTitleBGcolor)
:css('color', 'inherit')
:wikitext(label_chr)
:done() --end th
Line 1,036 ⟶ 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 td
:done() --end tr
:tag('tr')
Line 1,047 ⟶ 1,076:
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:wikitext(wikitext_for_ideogram_image_mm)
:done() --end td
Line 1,056 ⟶ 1,086:
:attr('width', '15%')
:css('background-color', sideTitleBGcolor)
:css('color', 'inherit')
:wikitext(label_locus)
:done() --end th
Line 1,062 ⟶ 1,093:
:attr('width', '35%')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:tag('span')
:attr('class', 'plainlinks')
Line 1,070 ⟶ 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 td
:done() --end tr
:tag('tr')
Line 1,084 ⟶ 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 td
:done() --end tr
:done() --end table
:done() --end td
:done() --end tr
end
end
 
--Get the render elements title, collapse option, collapsed anatomic entities, (defaut text),
--and anatomic entity list for the Bgee gene expression list rendering.
function p.renderBgeeExpression = functionrenderExpressionList(expressed_in_tissues, default_text)
--create list of expressed in anatomic entities
if default_text == nil then default_text = "" end
local bgee_title = "Bgee"
local anatomic_entity_labels = localNotApplicableStr
bgee_title = "[https://bgee.org/ " .. bgee_title .. "]"
local bgee_linkscollapse = localNotApplicableStr"none"
local split_values = mw.text.split(expressed_in_tissues, localSeparatorStr)
local bgee_collapse = "none"
local bgee_defaultanatomic_entity_list = "Top expressed in" {}
local anatomic_entities = {}
local split_bgee = mw.text.split(expressed_in_tissues, localSeparatorStr)
local bgee_link_list = {}
local results
for k,v in ipairs(split_bgeesplit_values) do
if string.match(v, '%w+') and v ~= localNotApplicableStr then
anatomic_entity_list[#anatomic_entity_list+1] = "<li style='line-height: 137%;'>"..v.."</li>"
bgee_link_list[#bgee_link_list+1] = "\n* "..v
anatomic_entities[#anatomic_entities+1] = v
end
end
--if less than 11 don't create collapsible list
if table.getn(bgee_link_listanatomic_entity_list) < 11 then
if bgee_default == nil and table.getn(bgee_link_listanatomic_entity_list) == 0 then bgee_links = localNotApplicableStr end
anatomic_entity_labels = localNotApplicableStr
default_text = ""
end
else
bgee_collapsecollapse = "collapsible collapsed"
bgee_defaultdefault_text = bgee_defaultdefault_text .. '<br>' .. table.remove(bgee_link_listanatomic_entities, 1) .. '<br>' .. table.remove(bgee_link_listanatomic_entities, 1) .. '<br>' ..table.remove(bgee_link_listanatomic_entities, 1) .. '<br>' .. table.remove(bgee_link_listanatomic_entities, 1) .. '<br>' .. table.remove(bgee_link_listanatomic_entities, 1) .. '<br>'--get first 5 elements in table and use for display
end
if bgee_link_listanatomic_entity_list[#bgee_link_listanatomic_entity_list] then
bgee_linksanatomic_entity_labels = table.concat(bgee_link_listanatomic_entity_list, "<br>")
end
results = {bgee_titlecollapse, bgee_collapsedefault_text, bgee_default, bgee_linksanatomic_entity_labels}
return results
end
 
function p.renderRNAexpression = function(expression_images, entrez_gene, ensembl, bgee_expression)
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,137 ⟶ 1,178:
biogps_title = "[http://biogps.org/ " .. biogps_title .. "]"
-- If no expression image exist in BioGPS, the N/A is displayed
if expression_images ~= "" then
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 bgee_title = bgee_expression[1]
local ensembl_id_mouse = string.match(ensembl_mouse,"%a+%d+") or ""
local bgee_collapse = bgee_expression[2]
local bgee_defaultbgee_title = bgee_expression[3]"Bgee"
bgee_title = "[https://www.bgee.org/ " .. bgee_title .. "]"
local bgee_links = bgee_expression[4]
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
local ensembl_id = string.gsub(ensembl, "%s", "")
bgee_more_link = "["..bgee_gene_page..ensembl_id.." More reference expression data]"
if bgee_links ~= localNotApplicableStr then
bgee_more_link = "[https://bgee.org/?page=gene&gene_id="..ensembl_id.." More reference expression data]" --**lclz**
bgee_default = "[https://bgee.org/?page=gene&gene_id="..ensembl_id.." '''"..bgee_default.."'''] " --**lclz**
else
bgee_default = ""
end
 
root
:tag('tr')
:tag('td')
:attr('colspan', 4)
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:tagcss('tablecolor', 'inherit')
:tag('table')
:attr('class', 'collapsible collapsed')
:css('padding', '0')
:css('border', 'none')
:css('margin', '0')
:css('width', '100%')
:css('text-align', 'left')
:tag('tr')
:tag('th')
Line 1,172 ⟶ 1,221:
:css('text-align', 'center')
:css('background-color', titleBGcolor)
:css('color', 'inherit')
:wikitext(title)
:done() --end th
Line 1,177 ⟶ 1,227:
:tag('tr')
:tag('th')
:attr('scope', 'row')
:css('background-color', sideTitleBGcolor)
:wikitextcss(bgee_title'color', 'inherit')
:wikitext(bgee_title)
:done() --end th
:tagdone('td') --end th
:tag('tabletd')
:attrtag('classtable', bgee_collapse)
:cssattr('paddingclass', '0none')
:css('borderpadding', 'none0')
:css('marginborder', '0none')
:css('widthmargin', '100%0')
:css('text-alignwidth', 'left100%')
:tagcss('trtext-align', 'left')
:tag('tdtr')
:attrtag('colspan', '1th')
:wikitext("'''[[Human genome|Human]]'''")
:tag('span')
:attrdone('class',) 'plainlinks')--end th
:wikitexttag(bgee_default'th')
:wikitext("'''[[Laboratory mouse|Mouse]] (ortholog)'''")
:done() --end span
:done() --end tdth
:done() --end tr
:tag('tr')
:tag('td')
:attrtag('colspan', '1table')
:tagattr('divclass', bgee_collapse)
:attrcss('classpadding', 'plainlinks0')
:wikitextcss(bgee_links'border', 'none')
:donecss('margin', '0') --end div
:css('width', '100%')
:done() --end td
:donecss() 'text--endalign', tr'center')
:tag('tr')
: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,218 ⟶ 1,330:
: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)
:wikitextcss(biogps_title'color', 'inherit')
:wikitext(biogps_title)
:done() --end th
:done() --end th
:tag('td')
:tag('table')
:attr('class', bgee_collapse)
:css('padding', '0')
:css('border', 'none')
:css('margin', '0')
:css('width', '100%')
:css('text-align', 'left')
:tag('tr')
:tag('td')
:attr('colspan', '4')
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:wikitext(expression_images)
:done() --end td
Line 1,248 ⟶ 1,362:
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:css('color', 'inherit')
:tag('span')
:attr('class', 'plainlinks')
Line 1,262 ⟶ 1,377:
end
 
 
p.renderGeneOntology = function(mol_funct, cell_comp, bio_process, uniprotID)
function p.renderGeneOntology(mol_funct, cell_comp, bio_process, uniprotID)
local title = "[[Gene ontology]]" --**lclz**
local mol_funct_title = "Molecular function" --**lclz**
Line 1,269 ⟶ 1,385:
local amigo_link = "[http://amigo.geneontology.org/" .. " Amigo]"
local quickGO_link = "[https://www.ebi.ac.uk/QuickGO/" .. " QuickGO]"
 
 
root
:tag('tr')
:tag('td')
:attr('colspan', 4)
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:tagcss('tablecolor', 'inherit')
:tag('table')
:attr('class', 'collapsible collapsed')
:css('padding', '0')
:css('border', 'none')
:css('margin', '0')
:css('width', '100%')
:css('text-align', 'left')
:tag('tr') --create title bar
:tag('th')
:attr('colspan', '4')
:css('text-align', 'center')
:css('background-color', titleBGcolor)
:wikitextcss(title'color', 'inherit')
:donewikitext(title) --end th
:done() --end trth
:tagdone(') --end tr')
:tag('tdtr')
:tag('td')
:css('background-color', sideTitleBGcolor)
:css('font-weightcolor', 'boldinherit')
:css('font-weight', 'bold')
:wikitext(mol_funct_title)
:wikitext(mol_funct_title)
:done() --end td
:tagdone(') --end td')
:tag('td')
:css('background-color', rowBGcolor)
:tagcss('divcolor', 'inherit')
:tag('div')
:attr('class', 'plainlinks')
:wikitext(mol_funct)
:wikitext( '\n' ) -- newline before ending div tag, to ensure next section formats properly
:done() --end div
:done() --end td
:done() --end tr
:tag('tr')
:tag('td')
:css('background-color', sideTitleBGcolor)
:css('font-weightcolor', 'boldinherit')
:css('font-weight', 'bold')
:wikitext(cell_comp_title)
:wikitext(cell_comp_title)
:done() --end td
:tagdone(') --end td')
:tag('td')
:css('background-color', rowBGcolor)
:tagcss('divcolor', 'inherit')
:tag('div')
:attr('class', 'plainlinks')
:wikitext(cell_comp)
:wikitext( '\n' ) -- newline before ending div tag, to ensure next section formats properly
:done() --end div
:done() --end td
:done() --end tr
:tag('tr')
:tag('td')
:css('background-color', sideTitleBGcolor)
:css('font-weightcolor', 'boldinherit')
:css('font-weight', 'bold')
:wikitext(bio_process_title)
:wikitext(bio_process_title)
:done() --end td
:tagdone(') --end td')
:tag('td')
:css('background-color', rowBGcolor)
:tagcss('divcolor', 'inherit')
:tag('div')
:attr('class', 'plainlinks')
:wikitext(bio_process)
:wikitext( '\n' ) -- newline before ending div tag, to ensure next section formats properly
:done() --end div
:done() --end td
:done() --end tr
 
:tag('tr')
:tag('td')
:css('background-color', rowBGcolor)
:css('text-aligncolor', 'centerinherit')
:attrcss('colspantext-align', '4center')
:attr('colspan', '4')
:wikitext("Sources:") -- **lclz**
:wikitext(amigo_link"Sources:") -- **lclz**
:wikitext(" / "amigo_link)
:wikitext(quickGO_link" / ")
:wikitext(quickGO_link)
:done() --end td
:done() --end trtd
:done() --end tr
:done() --end table
:done() --end td
Line 1,354 ⟶ 1,478:
end
 
function p.renderOrthologs = function(frame, entrez_gene, entrez_gene_mm, ensembl, ensembl_mm, uniprot, uniprot_mm, refseq_mRNA, refseq_mRNA_mm, refseq_prot, refseq_prot_mm, db, chr, gstart, gend, db_mm, chr_mm,gstart_mm, gend_mm)
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,380 ⟶ 1,506:
end
--if less than 5 don't create collapsible list
if table.getn(entrez_link_list) < 5 then
entrez_collapse = "none"
if entrez_default == nil and table.getn(entrez_link_list) == 0 then entrez_link = localNotApplicableStr end
Line 1,404 ⟶ 1,530:
end
--if less than 5 don't create collapsible list
if table.getn(entrez_mm_link_list) < 5 then
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,429 ⟶ 1,555:
end
--if less than 5 don't create collapsible list
if table.getn(ensembl_link_list) < 5 then
ensembl_collapse = "none"
if ensembl_default == nil and table.getn(ensembl_link_list) == 0 then ensembl_link = localNotApplicableStr end
Line 1,441 ⟶ 1,567:
 
--create list of mouse ensembl id
local ensemblTitle = "[[Ensembl]]"
ensembl_mm = string.gsub(ensembl_mm, "%s", "")
local ensembl_mm_link = localNotApplicableStr
Line 1,454 ⟶ 1,579:
end
--if less than 5 don't create collapsible list
if table.getn(ensembl_mm_link_list) < 5 then
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,464 ⟶ 1,589:
ensembl_mm_link = table.concat(ensembl_mm_link_list, "<br>")
end
 
 
--create lists of uniprot ID
Line 1,485 ⟶ 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
uniprot_first[#uniprot_first+1] = "[" .. concat_uniprot_link .. " " ..label .. "]"
else
uniprot_alternate[#uniprot_alternate+1] = "[" .. concat_uniprot_link .. " " ..label .. "]"
Line 1,493 ⟶ 1,617:
end
end
if table.getn(uniprot_first)>0 then --if there is something in the preferred values display else display anything else
uniprot_link_list = uniprot_first
else
uniprot_link_list = uniprot_alternate
end
 
--if less than 5 don't create collapsible list
if table.getn(uniprot_link_list) < 5 then
uniprot_collapse = "none"
if uniprot_default == nil and table.getn(uniprot_link_list) == 0 then uniprot_link = localNotApplicableStr end
Line 1,512 ⟶ 1,636:
end
 
--mouse uniprot lists
local uniprot_mm_link = localNotApplicableStr
local uniprot_mm_collapse
Line 1,518 ⟶ 1,642:
--split string and loop through concatenate by <br>
local split_uniprot_mm = mw.text.split(uniprot_mm, localSeparatorStr)
local uniprot_mm_link_list = {}
local uniprot_mm_first = {} --preferred values only display [O,P,Q] prefixed entries if they exist
local uniprot_mm_alternate = {} --[A-N,R-Z] entries
local hash = {} --storage to look for duplicated values
for k,v in ipairs(split_uniprot_mm) do
if not hash[v] then --only add if not found previously..some encodes uniprotID dup in different encodes
local label = mw.text.trim(v)
local concat_uniprot_link = uniprot_url .. label
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
uniprot_mm_first[#uniprot_mm_first+1] = "[" .. concat_uniprot_link .. " " ..label .. "]"
else
uniprot_mm_alternate[#uniprot_mm_alternate+1] = "[" .. concat_uniprot_link .. " " ..label .. "]"
end
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 = uniprot_mm_first
else
uniprot_mm_link_list = uniprot_mm_alternate
end
 
--if less than 5 don't create collapsible list
if table.getn(uniprot_mm_link_list) < 5 then
uniprot__mm_collapseuniprot_mm_collapse = "none"
if uniprot_mm_default == nil and table.getn(uniprot_mm_link_list) == 0 then uniprot_mm_link = localNotApplicableStr end
else
Line 1,554 ⟶ 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,574 ⟶ 1,696:
if string.match(v, '%w+') and v ~= localNotApplicableStr then
if string.match(v, 'NM') or string.match(v, 'NP') then
link_list_first[#link_list_first+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
elseif string.match(v, 'XM') or string.match(v, 'XP') then
link_list_alternate[#link_list_alternate+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
end
end
end
if table.getn(link_list_first)>0 then
link_list = link_list_first
else
Line 1,587 ⟶ 1,709:
 
--if less than 5 don't create collapsible list
if table.getn(link_list) < 6 then
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 = table.remove(link_list, 1) .. '<br>' .. table.remove(link_list, 1) .. '<br>' ..table.remove(link_list, 1) .. '<br>' .. table.remove(link_list, 1) .. '<br>' .. table.remove(link_list, 1) .. '<br>'--get first 5 elements in table and use for display
end
 
Line 1,598 ⟶ 1,720:
refseq_mRNA_link = table.concat(link_list, "<br>")
end
 
 
--create list of links for refSeq mRNA for mouse
Line 1,614 ⟶ 1,735:
if string.match(v, '%w+') and v ~= localNotApplicableStr then
if string.match(v, 'NM') or string.match(v, 'NP') then
link_list_first[#link_list_first+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
elseif string.match(v, 'XM') or string.match(v, 'XP') then
link_list_alternate[#link_list_alternate+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
end
end
end
if table.getn(link_list_first)>0 then
link_list_mm = link_list_first
Line 1,626 ⟶ 1,747:
end
--if less than 5 don't create collapsible list
if table.getn(link_list_mm) < 6 then
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,638 ⟶ 1,759:
end
 
-- *lclz*: sometimes
local refseq_protTitle = "RefSeq (protein)"
--create list of links for human refseq protein
Line 1,646 ⟶ 1,767:
local split_refseq_prot = mw.text.split(refseq_prot, localSeparatorStr)
local link_list_prot = {}
local link_list_first = {} --hold those the have NM or NP values
local link_list_alternate = {} --hold those that are XM or XP values
for k,v in ipairs(split_refseq_prot) do
Line 1,653 ⟶ 1,774:
if string.match(v, '%w+') and v ~= localNotApplicableStr then
if string.match(v, 'NM') or string.match(v, 'NP') then
link_list_first[#link_list_first+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
elseif string.match(v, 'XM') or string.match(v, 'XP') then
link_list_alternate[#link_list_alternate+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
Line 1,660 ⟶ 1,781:
end
if table.getn(link_list_first)>0 then
link_list_prot = link_list_first
else
link_list_prot = link_list_alternate
end
--if less than 5 don't create collapsible list
if table.getn(link_list_prot) < 6 then
refseq_prot_collapse = "none"
if refseq_prot_default == nil and table.getn(link_list_prot) == 0 then refseq_prot_link = localNotApplicableStr end
else
Line 1,672 ⟶ 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,693 ⟶ 1,812:
if string.match(v, '%w+') and v ~= localNotApplicableStr then
if string.match(v, 'NM') or string.match(v, 'NP') then
link_list_first[#link_list_first+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
elseif string.match(v, 'XM') or string.match(v, 'XP') then
link_list_alternate[#link_list_alternate+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
Line 1,700 ⟶ 1,819:
end
if table.getn(link_list_first)>0 then
link_list_prot_mm = link_list_first
else
link_list_prot_mm = link_list_alternate
end
--if less than 5 don't create collapsible list
if table.getn(link_list_prot_mm) < 6 then
refseq_prot_mm_collapse = "none"
if refseq_prot_mm_default == nil and table.getn(link_list_prot_mm) == 0 then refseq_prot_mm_link = localNotApplicableStr end
else
Line 1,715 ⟶ 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,742 ⟶ 1,860:
chr_mm_ucsc = chr_mm
end
chr_loc_mm_link = "[https://genome.ucsc.edu/cgi-bin/hgTracks?org=Mouse&db="..db_mm.."&position=chr"..chr_mm_ucsc..":"..gstart_mm.."-"..gend_mm.." ".."Chr "..chr_mm_ucsc..": "..gstart_mm_mb.." – "..gend_mm_mb.." Mb]"
else
chr_loc_mm_link = localNotApplicableStr
Line 1,759 ⟶ 1,877:
root
:tag('tr')
:tag('th')
:attr('colspan', '4')
:css('text-align', 'center')
:css('background-color', titleBGcolor)
:wikitext(title)
:done() --end th
:done() --end tr
:tag('tr')
:tag('th')
:attr('scope', 'row')
:css('background-color', sideTitleBGcolor)
:wikitext("Species") --**lclz**
:done() --end th
:tag('td')
:wikitext("'''Human'''") --**lclz**
:done() --end td
:tag('td')
:wikitext("'''Mouse'''") --**lclz**
:done() --end td
:done() --end tr
:tag('tr')
:tag('th')
:attr('scope', 'row')
:css('background-color', sideTitleBGcolor)
:wikitext(entrezTitle)
:done() --end th
:tag('td')
:tag('table')
:attr('class', entrez_collapse)
:css('padding', '0')
:css('border', 'none')
:css('margin', '0')
:css('width', '100%')
:css('text-align', 'right')
:tag('tr')
:tag('th')
:attr('colspan', '1')
:tag('span')
:attr('class', 'plainlinks')
:wikitext(entrez_default)
:done() --end span
:done() --end th
:done() --end tr
:tag('tr')
:tag('td')
:attr('colspan', '1')
:tag('p')
:attr('class', 'plainlinks')
:wikitext(entrez_link)
:done() --end p
:done() --end td
:done() --end tr
:done() --end table
:done() --end td
:tag('td')
:tagattr('tablecolspan', 4)
:css('text-align', 'center')
:attr('class', entrez_mm_collapse)
:css('paddingbackground-color', '0'rowBGcolor)
:css('bordercolor', 'noneinherit')
:csstag('margin', '0table')
:cssattr('widthclass', '100%collapsible')
:css('text-alignpadding', 'right0')
:css('border', 'none')
:tag('tr')
:tagcss('thmargin', '0')
:attrcss('colspanwidth', '1100%')
:tagcss('spantext-align', 'left')
:attrtag('class', 'plainlinkstr')
:tag('th')
:wikitext(entrez_mm_default)
:attr('colspan', '4')
:done() --end span
:css('text-align', 'center')
:done() --end th
:css('background-color', titleBGcolor)
:done() --end tr
:tagcss('trcolor', 'inherit')
:wikitext(title)
:tag('td')
:done() --end th
:attr('colspan', '1')
:done() --end tr
:tag('p')
:attrtag('class', 'plainlinkstr')
:tag('th')
:wikitext(entrez_mm_link)
:attr('scope', 'row')
:done() --end p
:css('background-color', sideTitleBGcolor)
:done() --end td
:donecss()'color', --end tr'inherit')
:wikitext("Species") --**lclz**
:done() --end table
:done() --end tdth
:tag('td')
:done() --end tr
:wikitext("'''Human'''") --**lclz**
:tag('tr')
:done() --end td
:tag('th')
:attrtag('scope', 'rowtd')
:wikitext("'''Mouse'''") --**lclz**
:css('background-color', sideTitleBGcolor)
:done() --end td
:wikitext(ensemblTitle)
:done() --end thtr
:tag('tdtr')
:tag('tableth')
:attr('classscope', ensembl_collapse'row')
:css('paddingbackground-color', '0'sideTitleBGcolor)
:css('bordercolor', 'noneinherit')
:wikitext(entrezTitle)
:css('margin', '0')
:done() --end th
:css('width', '100%')
:tag('td')
:css('text-align', 'right')
:tag('trtable')
:attr('class', entrez_collapse)
:tag('th')
:attrcss('colspanpadding', '10')
:tagcss('spanborder', 'none')
:attrcss('classmargin', 'plainlinks0')
:css('width', '100%')
:wikitext(ensembl_default)
:css('text-align', 'right')
:done() --end span
:tag('tr')
:done() --end th
:tag('th')
:done() --end tr
:attr('colspan', '1')
:tag('tr')
:tag('tdspan')
:attr('colspanclass', '1plainlinks')
:wikitext(entrez_default)
:tag('p')
:done() --end span
:attr('class', 'plainlinks')
:done() --end th
:wikitext(ensembl_link)
:done() --end ptr
:tag('tr')
:done() --end td
:tag('td')
:done() --end tr
:attr('colspan', '1')
:done() --end table
:tag('p')
:done() --end td
:tagattr('tdclass', 'plainlinks')
:wikitext(entrez_link)
:tag('table')
:done() --end p
:attr('class', ensembl_mm_collapse)
:done() --end td
:css('padding', '0')
:done() --end tr
:css('border', 'none')
:done() --end table
:css('margin', '0')
:done() --end td
:css('width', '100%')
:tag('td')
:css('text-align', 'right')
:tag('trtable')
:attr('class', entrez_mm_collapse)
:tag('th')
:attrcss('colspanpadding', '10')
:tagcss('spanborder', 'none')
:attrcss('classmargin', 'plainlinks0')
:css('width', '100%')
:wikitext(ensembl_mm_default)
:css('text-align', 'right')
:done() --end span
:tag('tr')
:done() --end th
:tag('th')
:done() --end tr
:attr('colspan', '1')
:tag('tr')
:tag('tdspan')
:attr('colspanclass', '1plainlinks')
:wikitext(entrez_mm_default)
:tag('p')
:done() --end span
:attr('class', 'plainlinks')
:done() --end th
:wikitext(ensembl_mm_link)
:done() --end ptr
:tag('tr')
:done() --end td
:tag('td')
:done() --end tr
:attr('colspan', '1')
:done() --end table
:tag('p')
:done() --end td
:attr('class', 'plainlinks')
:done() --end tr
:wikitext(entrez_mm_link)
:tag('tr')
:done() --end p
:tag('th')
:done() --end td
:attr('scope', 'row')
:done() --end tr
:css('background-color', sideTitleBGcolor)
:done() --end table
:wikitext(uniprotTitle)
:done() --end thtd
:done() --end tr
:tag('td')
:tag('tabletr')
:tag('th')
:attr('class', uniprot_collapse)
:cssattr('paddingscope', '0row')
:css('borderbackground-color', 'none'sideTitleBGcolor)
:css('margincolor', '0inherit')
:wikitext(ensemblTitle)
:css('width', '100%')
:done() --end th
:css('text-align', 'right')
:tag('trtd')
:tag('thtable')
:attr('colspanclass', '1'ensembl_collapse)
:tagcss('spanpadding', '0')
:attrcss('classborder', 'plainlinksnone')
:css('margin', '0')
:wikitext(uniprot_default)
:css('width', '100%')
:done() --end span
:css('text-align', 'right')
:done() --end th
:donetag() --end 'tr')
:tag('trth')
:tagattr('tdcolspan', '1')
:attrtag('colspan', '1span')
:tagattr('pclass', 'plainlinks')
:wikitext(ensembl_default)
:attr('class', 'plainlinks')
:done() --end span
:wikitext(uniprot_link)
:done() --end pth
:done() --end tdtr
:donetag() --end 'tr')
:tag('td')
:done() --end table
:attr('colspan', '1')
:done() --end td
:tag('tdp')
:attr('class', 'plainlinks')
:tag('table')
:wikitext(ensembl_link)
:attr('class', uniprot_mm_collapse)
:done() --end p
:css('padding', '0')
:done() --end td
:css('border', 'none')
:done() --end tr
:css('margin', '0')
:done() --end table
:css('width', '100%')
:done() --end td
:css('text-align', 'right')
:tag('trtd')
:tag('thtable')
:attr('colspanclass', '1'ensembl_mm_collapse)
:tagcss('spanpadding', '0')
:attrcss('classborder', 'plainlinksnone')
:css('margin', '0')
:wikitext(uniprot_mm_default)
:css('width', '100%')
:done() --end span
:css('text-align', 'right')
:done() --end th
:tag('tr')
:done() --end th
:tag('trth')
:tagattr('tdcolspan', '1')
:attrtag('colspan', '1span')
:tagattr('pclass', 'plainlinks')
:wikitext(ensembl_mm_default)
:attr('class', 'plainlinks')
:done() --end span
:wikitext(uniprot_mm_link)
:done() --end pth
:done() --end tdtr
:donetag() --end 'tr')
:tag('td')
:done() --end table
:attr('colspan', '1')
:done() --end td
:tag('p')
:done() --end tr
:attr('class', 'plainlinks')
:tag('tr')
:wikitext(ensembl_mm_link)
:tag('th')
:done() --end p
:attr('scope', 'row')
:done() --end td
:css('background-color', sideTitleBGcolor)
:done() --end tr
:wikitext(refseq_mRNATitle)
:done() --end thtable
:done() --end td
:tag('td') --RNASeq mRNA collapsible table
:done() --end tr
:tag('table')
:tag('tr')
:attr('class', refseq_mRNA_collapse)
:csstag('padding', '0th')
:cssattr('borderscope', 'nonerow')
:css('marginbackground-color', '0'sideTitleBGcolor)
:css('widthcolor', '100%inherit')
:wikitext(uniprotTitle)
:css('text-align', 'right')
:done() --end th
:tag('tr')
:tag('thtd')
:attrtag('colspan', '1table')
:attr('class', 'plainlinks'uniprot_collapse)
:css('padding', '0')
:wikitext(refseq_mRNA_default)
:css('border', 'none')
:done() --end th
:css('margin', '0')
:done() --end tr
:css('width', '100%')
:tag('tr')
:css('text-align', 'right')
:tag('td')
:attrtag('colspan', '1tr')
:tag('pth')
:tagattr('spancolspan', '1')
:attrtag('class', 'plainlinksspan')
:attr('class', 'plainlinks')
:wikitext(refseq_mRNA_link)
:wikitext(uniprot_default)
:done() --end span
:done() --end pspan
:done() --end tdth
:done() --end tr
:tag('tr')
:done() --end table
:tag('td')
:done() --end td
:attr('colspan', '1')
:tag('td') --RNASeq mRNA collapsible table for mouse
:tag('tablep')
:attr('class', refseq_mRNA_mm_collapse'plainlinks')
:wikitext(uniprot_link)
:css('padding', '0')
:done() --end p
:css('border', 'none')
:done() --end td
:css('margin', '0')
:done() --end tr
:css('width', '100%')
:done() --end table
:css('text-align', 'right')
:done() --end td
:tag('tr')
:tag('thtd')
:attrtag('colspan', '1table')
:attr('class', 'plainlinks'uniprot_mm_collapse)
:css('padding', '0')
:wikitext(refseq_mRNA_mm_default)
:css('border', 'none')
:done() --end th
:css('margin', '0')
:done() --end tr
:css('width', '100%')
:tag('tr')
:css('text-align', 'right')
:tag('td')
:attrtag('colspan', '1tr')
:tag('pth')
:tagattr('spancolspan', '1')
:attrtag('class', 'plainlinksspan')
:attr('class', 'plainlinks')
:wikitext(refseq_mRNA_mm_link)
:wikitext(uniprot_mm_default)
:done() --end span
:done() --end pspan
:done() --end tdth
:done() --end trth
:tag('tr')
:done() --end table
:donetag() --end 'td')
:attr('colspan', '1')
:done() --end tr
:tag('trp')
:attr('class', 'plainlinks')
:tag('th')
:wikitext(uniprot_mm_link)
:attr('scope', 'row')
:done() --end p
:css('background-color', sideTitleBGcolor)
:done() --end td
:wikitext(refseq_protTitle)
:done() --end thtr
:tagdone('td') --RNASeq protein collapsibleend table
:done() --end td
:tag('table')
:done() --end tr
:attr('class', refseq_prot_collapse)
:csstag('padding', '0tr')
:tag('th')
:css('border', 'none')
:cssattr('marginscope', '0row')
:css('widthbackground-color', '100%'sideTitleBGcolor)
:css('text-aligncolor', 'rightinherit')
:wikitext(refseq_mRNATitle)
:tag('tr')
:tagdone(') --end th')
:tag('td') --RNASeq mRNA collapsible table
:attr('colspan', '1')
:attrtag('class', 'plainlinkstable')
:attr('class', refseq_mRNA_collapse)
:wikitext(refseq_prot_default)
:css('padding', '0')
:done() --end th
:css('border', 'none')
:done() --end tr
:tagcss('trmargin', '0')
:tagcss('tdwidth', '100%')
:attrcss('colspantext-align', '1right')
:tag('ptr')
:tag('spanth')
:attr('classcolspan', 'plainlinks1')
:attr('class', 'plainlinks')
:wikitext(refseq_prot_link)
:wikitext(refseq_mRNA_default)
:done() --end span
:done() --end pth
:done() --end tdtr
:donetag() --end 'tr')
:tag('td')
:done() --end table
:attr('colspan', '1')
:done() --end td
:tag('p')
:tag('td') --RNASeq protein collapsible table for mouse
:tag('tablespan')
:attr('class', refseq_prot_mm_collapse'plainlinks')
:wikitext(refseq_mRNA_link)
:css('padding', '0')
:done() --end span
:css('border', 'none')
:done() --end p
:css('margin', '0')
:done() --end td
:css('width', '100%')
:done() --end tr
:css('text-align', 'right')
:done() --end table
:tag('tr')
:done() --end td
:tag('th')
:tag('td') --RNASeq mRNA collapsible table for mouse
:attr('colspan', '1')
:attrtag('class', 'plainlinkstable')
:attr('class', refseq_mRNA_mm_collapse)
:wikitext(refseq_prot_mm_default)
:css('padding', '0')
:done() --end th
:css('border', 'none')
:done() --end tr
:tagcss('trmargin', '0')
:tagcss('tdwidth', '100%')
:attrcss('colspantext-align', '1right')
:tag('ptr')
:tag('spanth')
:attr('classcolspan', 'plainlinks1')
:attr('class', 'plainlinks')
:wikitext(refseq_prot_mm_link)
:wikitext(refseq_mRNA_mm_default)
:done() --end span
:done() --end pth
:done() --end tdtr
:donetag() --end 'tr')
:tag('td')
:done() --end table
:attr('colspan', '1')
:done() --end td
:tag('p')
:done() --end tr
:tag('trspan')
:attr('class', 'plainlinks')
:tag('th')
:wikitext(refseq_mRNA_mm_link)
:attr('scope', 'row')
:done() --end span
:css('background-color', sideTitleBGcolor)
:done() --end p
:wikitext(locTitle)
:done() --end thtd
:done() --end tr
:tag('td')
:done() --end table
:tag('span')
:done() --end td
:attr('class', 'plainlinks')
:done() --end tr
:wikitext(chr_loc_link)
:tag('tr')
:done() --end span
:tag('th')
:done() --end td
:attr('scope', 'row')
:tag('td')
:css('background-color', sideTitleBGcolor)
:tag('span')
:attrcss('classcolor', 'plainlinksinherit')
:wikitext(chr_loc_mm_linkrefseq_protTitle)
:done() --end spanth
:tag('td') --RNASeq protein collapsible table
:done() --end td
:tag('table')
:done() --end tr
:attr('class', refseq_prot_collapse)
:tag('tr')
:tagcss('thpadding', '0')
:attrcss('scopeborder', 'rownone')
:css('background-colormargin', sideTitleBGcolor'0')
:css('width', '100%')
:wikitext(pubmedTitle)
:css('text-align', 'right')
:done() --end th
:tag('tdtr')
:tag('spanth')
:attr('classcolspan', 'plainlinks1')
:attr('class', 'plainlinks')
:wikitext(pubmed_link)
:wikitext(refseq_prot_default)
:done() --end span
:done() --end tdth
:done() --end tr
:tag('td')
:tag('spantr')
:tag('td')
:attr('class', 'plainlinks')
:attr('colspan', '1')
:wikitext(pubmed_mm_link)
:tag('p')
:done() --end span
:tag('span')
:wikitext(category_chromosome)
:attr('class', 'plainlinks')
:done() --end td
:wikitext(refseq_prot_link)
:done() --end tr
: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 = function(title)
root
:tag('tr')
:tag('td')
:attr('colspan', '4')
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:tagcss('tablecolor', 'inherit')
:csstag('padding', '0table')
:css('borderpadding', 'none0')
:css('marginborder', '0none')
:css('widthmargin', '100%0')
:css('text-alignwidth', 'left100%')
:css('text-align', 'left')
:tag('tr') --create title header
:tag('tr') --create title header
:css('background-color',titleBGcolor)
:css('textbackground-aligncolor', 'center'titleBGcolor)
:tagcss('thcolor', 'inherit')
:attrcss('colspantext-align',"2" 'center')
:wikitexttag(title'th')
:attr('colspan',"2")
:done() --end th
:wikitext(title)
:done() --end tr
:done() --end tableth
:done() --end tdtr
:done() --end trtable
:done() --end td
:done() --end tr
end
 
function p.renderFooter = function(Qid, Qid_mm)
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
link_no_mm = 0
link_no_hs = 4
else
link_no_mm = 2
link_no_hs = 2
mm_link = "[[d:"..Qid_mm.."|View/Edit Mouse]]" --**lclz**
end
 
root
:tag('tr')
:tag('td')
:attr('colspan', '4')
:css('text-align', 'center')
:css('fontbackground-sizecolor','x-small' rowBGcolor)
:css('background-color', rowBGcolor'inherit')
:wikitext(text)
:done() --end td
:tag('tr')
:tag('td')
:attr('colspan', '4')
:css('text-align', 'center')
:css('fontbackground-sizecolor','x-small' rowBGcolor)
:css('background-color', rowBGcolor'inherit')
:tag('table')
:css('padding', '0')
:css('border', 'none')
:css('margin', '0')
:css('width', '100%')
:css('text-align', 'center')
:tag('tr')
:tag('td')
:attr('colspan', link_no_hs)
:css('background-color', rowBGcolor)
:css('text-aligncolor', 'centerinherit')
:css('fonttext-sizealign', 'x-smallcenter')
:wikitext(hs_link)
:done() --end td
:tag('td')
:attr('colspan', link_no_mm)
:css('background-color', rowBGcolor)
:css('text-aligncolor', 'centerinherit')
:css('fonttext-sizealign', 'x-smallcenter')
: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=function(label)
root
:tag('tr')
:tag('th')
:attr('rowspan', '2')
:css('background-color', sideTitleBGcolor)
:css('widthcolor', '43pxinherit')
:css('width', '43px')
:wikitext(label)
:wikitext(label)
--:done()
--:done()
end
 
-- look into entity object
function p.getLabel = function(entity)
local data = entity
 
Line 2,258 ⟶ 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.
--general function to get value given an entity and property
-- 'rertun_val' parameter, if no result is returned, the value assigned to this parameter is returned, the default value is an empty string.
p.getValue = function(entity, propertyID, return_val, sep)
-- '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 sep == nil then sep = " " end
if entity and entity.claims then
claims = entity.claims[propertyID]
Line 2,274 ⟶ 2,422:
local out = {}
for k, v in pairs(claims) do
local datav = mw.wikibase.getLabellabel("Q" .. v.mainsnak.datavalue.value["numeric-id"])
if datav == nil then datav = " " end
--Filter statements with the specified stated_in reference value, if none (stated_in = nil) all statements are considered.
out[#out + 1] = datav
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,288 ⟶ 2,456:
end
 
function p.getValueProtein = function(protein_entities, propertyID, return_val)
if return_val == nil then return_val = "" end
local sep = ","
local overall_results = {} --should return empty if nothing assigned
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,323 ⟶ 2,491:
end
end
 
 
--general function to get value given an entity and property
function p.getQid = function(entity)
local Qid
if entity and entity.id then
Line 2,339 ⟶ 2,506:
-- *lclz*: Sometimes Wikibase returns punctuations other than "," depending on
-- your site's language. Consider adding a gsub here.
function p.getRefseq_mRNA = function(entity, propertyID, return_val)
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,376 ⟶ 2,543:
for i, id in ipairs(results_split) do
local trim_id = mw.text.trim(id)
if string.match( trim_id, '^NM_%d+') then
preferred_result = trim_id --overwrite each time found only need one to display
end
end
if preferred_result then
Line 2,394 ⟶ 2,561:
 
-- *lclz*: same as getRefseq_mRNA
function p.getRefseq_protein = function(protein_entities, propertyID, return_val)
local sep = localSeparatorStr
local overall_results = {} --should return empty if nothing assigned
Line 2,403 ⟶ 2,570:
local entity = val --each protein in encodes
if entity.claims then
claims = entity.claims["P637"propertyID]
end
if claims then
Line 2,417 ⟶ 2,584:
results = table.concat(out, sep)
else
results = entity:formatPropertyValues("P637"propertyID, mw.wikibase.entity.claimRanks).value
end
overall_results[#overall_results+1] = results --a list is in each index
Line 2,431 ⟶ 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,452 ⟶ 2,618:
 
--gets an image
function p.getImage = function(entity, propertyID, sep, imgsize)
 
local claims
 
if entity and entity.claims then
claims = entity.claims[propertyID]
end
 
if claims then
if (claims[1] and claims[1].mainsnak.datatype == "commonsMedia") then
local out = {}
for k, v in pairs(claims) do
local filename = v.mainsnak.datavalue.value
out[#out + 1] = "[[File:" .. filename .. "|" .. imgsize .. "]]"
end
return table.concat(out, sep)
else
return ""
end
else
return ""
end
end
 
function p.getPDB = function(protein_entities)
local pdb_propertyID = "P638"
local overall_results = {}
Line 2,489 ⟶ 2,655:
local results
if (claims[1] and claims[1].mainsnak.snaktype == "value") then
 
 
local out = {}
Line 2,504 ⟶ 2,669:
results = table.concat(out, ", ") -- *lclz*: punctuation (CJK comma, etc.)
else
results = entity:formatPropertyValues(propertyIDpdb_propertyID, mw.wikibase.entity.claimRanks).value
end
overall_results[#overall_results+1] = results --individual propertyID values stored in this index
Line 2,513 ⟶ 2,678:
 
function p.getAliases(entity)
a = ''
if entity['aliases'] ~= nil then
-- *lclz*: You will need a different language here.
Line 2,521 ⟶ 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 test = entity['aliases']['en']
if test then
local a = ''
for key, value in ipairs(test) do
a = a .. ', ' .. value['value']
end
return a
Line 2,535 ⟶ 2,700:
 
end
 
 
--get a geneome start P644 or end P645
function p.getChromosomeLoc = function(entity, propertyID, prefix)
-- will contain the numeric value for the requested coordinate
local output = ""
Line 2,604 ⟶ 2,768:
end
--in case there are no qualifiers, but there is a ___location, might as well return it
else
output = ___location
end
end
return output
else
return ""
Line 2,618 ⟶ 2,783:
end
 
function p.getAliasFromGenomeAssembly = function(entity, prefix)
-- will contain the numeric value for the requested coordinate
local output = ""
Line 2,628 ⟶ 2,793:
local claims
if entity.claims then
claims = entity.claims[propertyID]
end
--will return nothing if no claims are found
Line 2,638 ⟶ 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,671 ⟶ 2,837:
end
--in case there are no qualifiers, but there is a ___location, might as well return it
else
output = ___location
end
end
return prefix .. newest_build
else
return ""
Line 2,685 ⟶ 2,852:
-- *lclz*: Your language's wikidata may have different nouns for chromosome and
-- mitochodria.
function p.trimChromosome = function(entity)
local string_to_trim = p.getValue(entity, "P1057")
local out = ''
Line 2,702 ⟶ 2,869:
end
 
function p.locToMb = function(num, idp)
num = tonumber(num)
if num == nil then
return ""
else
local mb = num/1000000
local mult = 10^(idp or 0)
return math.floor(mb * mult + 0.5) / mult
end
end
 
function p.isempty = function(s)
return s == nil or s == ''
end
 
function p.getGO(protein_entities, propertyID)
 
p.getGO = function(protein_entities, propertyID)
--propertyID ie molecular, cellular, function
 
Line 2,744 ⟶ 2,910:
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
Line 2,751 ⟶ 2,917:
local label = mw.wikibase.getLabel("Q" .. v.mainsnak.datavalue.value["numeric-id"])
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,772 ⟶ 2,938:
 
for _,v in ipairs(overall_results) do
if (not hash[v]) then
res[#res+1] = v
hash[v] = true
end
end
return table.concat(res, "")
Line 2,790 ⟶ 2,956:
return nil
end
 
 
local i = 1
Line 2,811 ⟶ 2,976:
end
 
function p.getDisease= function(entity, propertyID)
local claims
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,838 ⟶ 3,003:
ref = getReference("", entity, "P2293", k)
if (ref ~= nil and ref ~= '') then
--refLink = refLink..","..ref
refLink = ref
end
 
--if refLink = "" then --skip if there isn't a reference found
 
if linkTarget then
Line 2,861 ⟶ 3,026:
return return_val
end
return return_val
end
 
function p.getDrug= function(protein_entities, propertyID)
local out = {}
local datasource = {}
local pname = {}
local pqid = {}
 
 
for key, val in pairs(protein_entities) do
Line 2,891 ⟶ 3,055:
local ref = getReference(protein_id, entity, "P129",k) --just check if anything returned
if (ref ~= nil and ref ~= '') then
refLink = ref
end
if linkTarget then
out[#out + 1] = "[["..linkTarget.."|"..datav.."]]"
else
out[#out + 1] = "[[:d:" .. id .. "|" .. datav .. "]]"
end
pname[protein_id] = name
pqid[#out] = protein_id
datasource[#out] = refLink
end --end k,v claims loop
end --end claims[1]
end --if claims
end -- end protein_entities loop
return out, datasource, pqid, pname
end
 
function p.separateWithComma= function(bp)
--Separate number with comma. For example when this function gets "12345678", returns "12,345,678"
local commaSeparated = bp
while true do
local k
commaSeparated, k = string.gsub(commaSeparated, "^(-?%d+)(%d%d%d)", '%1,%2')
commaSeparated, k = string.gsub(commaSeparated, "^(-?%d+)(%d%d%d)", '%1,%2')
if (k==0) then
if k == 0 breakthen
break
end
end
end
return commaSeparated
return commaSeparated
end