Module:Infobox gene: Difference between revisions

Content deleted Content added
Replacing dash with ndash from sandbox
add semicolons between identifiers, add Orthologous_MAtrix identifiers, code by User:Tarsmf
Line 20:
return("'''VALUE_ERROR''' (" .. tostring(val) .. ")")
end
end
 
local function trim(s)
return (s:gsub("^%s*(.-)%s*$", "%1"))
end
 
Line 49 ⟶ 53:
entity = mw.wikibase.getEntity()
if entity then root_qid = entity.id else root_qid = "" end
 
else
--assuming we think its good make one call to retrieve and store its wikidata representation
Line 135 ⟶ 138:
claims = entity_mouse.claims[protein_propertyID]
end
if claims then
ifand (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"]
entity_mouse_protein[#entity_mouse_protein + 1] = mw.wikibase.getEntity(protein_itemID)
end
end --will return nothing if no claims are found
end
 
end
 
Line 196 ⟶ 200:
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 308 ⟶ 312:
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
else
Line 399 ⟶ 403:
end
 
function p.renderIdentifiers(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**
Line 405 ⟶ 409:
if gene_symbol == "" or gene_symbol == nil then
symbol_url = ""
if elseif hgnc_id == "" or hgnc_id == nil then
symbol_url = gene_symbol
else
symbol_url = "[https://www.genenames.org/data/gene-symbol-report/#!/hgnc_id/"..hgnc_id.." "..gene_symbol.."]"
if hgnc_id == "" or hgnc_id == nil then
symbol_url = gene_symbol
 
else
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.aliases: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 433:
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 446 ⟶ 445:
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 463 ⟶ 460:
end
end
mgi = trim(string.gsub(mgi, ", $"," ")) --remove comma from end
 
local ChEMBL = ""
if string.match(ChEMBL_id, '%w+') then
Line 471 ⟶ 467:
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 477 ⟶ 473:
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 chr(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')
Line 522 ⟶ 526:
:tag('span')
:attr('class', 'plainlinks')
:wikitext(omimexternal_ids)
:wikitext(mgi)
:wikitext(homolo)
:wikitext(ChEMBL)
:wikitext(IUPHAR)
:wikitext(genecards)
:done() --end span
:done() --end td
Line 1,125 ⟶ 1,124:
function p.renderRNAexpression(expression_images, entrez_gene,
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,139 ⟶ 1,138:
local ensembl_id_mouse = string.match(ensembl_mouse,"%a+%d+") or ""
local bgee_title = "Bgee"
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)
Line 1,423 ⟶ 1,422:
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