Module:Infobox gene: Difference between revisions

Content deleted Content added
srv edits of 25 Oct 2021 - notify User:Tarsmf - please see talk page
reintroduce Bgee edits with fixes
Line 143:
--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})
Line 207 ⟶ 210:
p.renderGeneLocation(frame, chr, gstart, gend, db, cytoband, ensembl, chr_mm, gstart_mm, gend_mm, db_mm, cytoband_mm, ensembl_mm, name)
end
if expression_images ~= "" or expressed_in_tissues ~= localNotApplicableStr then
p.renderRNAexpression(expression_images, entrez_gene, ensembl, expressed_in_tissues)
end
if (mol_funct ~= "" and cell_comp ~= "" and bio_process ~= "") then
Line 1,099 ⟶ 1,102:
end
 
--Get the render elements collapse option, collapsed anatomic entities (defaut text),
p.renderRNAexpression = function(expression_images, entrez_gene)
--and anatomic entity list for the gene expression list rendering.
p.renderExpressionList = function(expressed_in_tissues, default_text)
--create list of expressed in anatomic entities
if default_text == nil then default_text = "" end
local anatomic_entity_labels = localNotApplicableStr
local collapse = "none"
local split_values = mw.text.split(expressed_in_tissues, localSeparatorStr)
local anatomic_entity_list = {}
local anatomic_entities = {}
local results
for k,v in ipairs(split_values) do
if string.match(v, '%w+') and v ~= localNotApplicableStr then
anatomic_entity_list[#anatomic_entity_list+1] = "\n* "..v
anatomic_entities[#anatomic_entities+1] = v
end
end
--if less than 11 don't create collapsible list
if table.getn(anatomic_entity_list) < 11 then
if table.getn(anatomic_entity_list) == 0 then
anatomic_entity_labels = localNotApplicableStr
default_text = ""
end
else
collapse = "collapsible collapsed"
default_text = default_text .. '<br>' .. table.remove(anatomic_entities, 1) .. '<br>' .. table.remove(anatomic_entities, 1) .. '<br>' ..table.remove(anatomic_entities, 1) .. '<br>' .. table.remove(anatomic_entities, 1) .. '<br>' .. table.remove(anatomic_entities, 1) .. '<br>'--get first 5 elements in table and use for display
end
if anatomic_entity_list[#anatomic_entity_list] then
anatomic_entity_labels = table.concat(anatomic_entity_list, "<br>")
end
results = {collapse, default_text, anatomic_entity_labels}
return results
end
 
p.renderRNAexpression = function(expression_images, entrez_gene,
ensembl, bgee_expression)
local title = "[[Gene expression|RNA expression]] pattern" --**lclz**
local biogps_link = "[http://biogps.org/gene/"..entrez_gene.."/ More reference expression data]" --**lclz**
local biogps_title = "BioGPS"
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+")
local bgee_title = "Bgee"
bgee_title = "[https://bgee.org/ " .. bgee_title .. "]"
local bgee_default = "[https://bgee.org/?page=gene&gene_id="..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_more_link = ""
if bgee_tissues ~= localNotApplicableStr then
bgee_more_link = "[https://bgee.org/?page=gene&gene_id="..ensembl_id.." More reference expression data]"
end
root
:tag('tr')
Line 1,124 ⟶ 1,183:
:done() --end tr
:tag('tr')
:tag('tdth')
:attr('colspanscope', '4row')
:css('textbackground-aligncolor', 'center'sideTitleBGcolor)
:wikitext(bgee_title)
:css('background-color', rowBGcolor)
:done() --end th
:wikitext(expression_images)
:donetag() --end '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', '1')
:tag('span')
:attr('class', 'plainlinks')
:wikitext(bgee_default)
:done() --end span
:done() --end td
:done() --end tr
:tag('tr')
:tag('td')
:attr('colspan', '1')
:tag('div')
:attr('class', 'plainlinks')
:wikitext(bgee_tissues)
:done() --end div
:done() --end td
:done() --end tr
:tag('tr')
:tag('td')
:attr('colspan', '4')
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:tag('span')
:attr('class', 'plainlinks')
:wikitext(bgee_more_link)
:done() --end span
: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)
:wikitext(biogps_title)
:done() --end th
:tag('td')
:attrtag('colspan', '4table')
:cssattr('text-alignclass', 'center'bgee_collapse)
:css('background-colorpadding', rowBGcolor'0')
:tagcss('spanborder', 'none')
:attrcss('classmargin', 'plainlinks0')
:css('width', '100%')
:wikitext(biogps_link)
:donecss() 'text--endalign', span'left')
:tag('tr')
:tag('td')
:attr('colspan', '4')
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:wikitext(expression_images)
:done() --end td
:done() --end tr
:tag('tr')
:tag('td')
:attr('colspan', '4')
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:tag('span')
:attr('class', 'plainlinks')
:wikitext(biogps_link)
:done() --end span
:done() --end td
:done() --end tr
:done() --end table
:done() --end td
:done() --end tr
Line 1,178 ⟶ 1,300:
:done() --end tr
:tag('tr')
:tag('thtd')
:css('background-color', sideTitleBGcolor)
:css('font-weight', 'bold')
:wikitext(mol_funct_title)
:done() --end thtd
:tag('td')
:css('background-color', rowBGcolor)
:tag('spandiv')
:attr('class', 'plainlinks')
:wikitext(mol_funct)
:donewikitext( '\n' ) --end spannewline before ending div tag, to ensure next section formats properly
:done() --end div
:done() --end td
:done() --end tr
:tag('tr')
:tag('thtd')
:css('background-color', sideTitleBGcolor)
:css('font-weight', 'bold')
:wikitext(cell_comp_title)
:done() --end thtd
:tag('td')
:css('background-color', rowBGcolor)
:tag('spandiv')
:attr('class', 'plainlinks')
:wikitext(cell_comp)
:donewikitext( '\n' ) --end spannewline before ending div tag, to ensure next section formats properly
:done() --end div
:done() --end td
:done() --end tr
:tag('tr')
:tag('thtd')
:css('background-color', sideTitleBGcolor)
:css('font-weight', 'bold')
:wikitext(bio_process_title)
:done() --end thtd
:tag('td')
:css('background-color', rowBGcolor)
:tag('spandiv')
:attr('class', 'plainlinks')
:wikitext(bio_process)
:donewikitext( '\n' ) --end spannewline before ending div tag, to ensure next section formats properly
:done() --end div
:done() --end td
:done() --end tr
Line 2,139 ⟶ 2,267:
 
 
-- Get property values formatted as a string of a given instance/entity.
--general function to get value given an entity and property
-- 'entity' parameter denfines the instance from which we want to get some property values.
p.getValue = function(entity, propertyID, return_val)
-- '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.
p.getValue = function(entity, propertyID, return_val, sep, stated_in)
 
local claims
if return_val == nil then return_val = "" end
localif sep == "nil "then --couldsep ad= as" input parameter if need" beend
if entity and entity.claims then
claims = entity.claims[propertyID]
Line 2,153 ⟶ 2,286:
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,632 ⟶ 2,785:
local wiki_link = ""
if sitelink and result_GOID ~= nil then
wiki_link = "<big>•</big>\n* [" .. sitelink .. result_GOID .. " " .. label .."]<br>"
else
wiki_link = "<big>•</big>\n* [[:d:Q" .. v.mainsnak.datavalue.value["numeric-id"] .. "|" .. label .. "]]<br>"
end
overall_results[#overall_results+1] = wiki_link