Module:Infobox gene and Module:Infobox gene/sandbox: Difference between pages
(Difference between pages)
imported>Pppery Undo unintended changes per talk request |
imported>Jmarchn No edit summary |
||
Line 1: | Line 1: | ||
local p = {} | local p = { } | ||
--To translate visual items of this module, you do not modify this module !!. | |||
--You must to copy and save the file "en:Module:Infobox gene/sandbox/en" in your wiki, | |||
--changing the name of the Module (as needed) and the "en" with your language international code | |||
local root | local root | ||
-- CHANGED, BEGIN-- | |||
--local SD = require "Module:SimpleDebug" | |||
local local_lang = mw.getContentLanguage().code | |||
local LOC = require (mw.getCurrentFrame():getTitle().."/"..local_lang) --the translated module | |||
local CFG = LOC.CFG | |||
local RS = LOC.RS | |||
local MkExtLnk = LOC.MkExtLnk | |||
-- CHANGED, END | |||
--define Global Color Scheme | --define Global Color Scheme | ||
Line 9: | Line 19: | ||
local titleBGcolor = '#ddd' | local titleBGcolor = '#ddd' | ||
local sideTitleBGcolor = '#c3fdb8' | local sideTitleBGcolor = '#c3fdb8' | ||
local function title_without_disambig () -- CHANGED, NEW, from Global infobox tools | |||
-- returns the current page name without text between "()" | |||
local s = mw.title.getCurrentTitle().baseText | |||
s = mw.ustring.gsub(s,'%s%(.*%)','') | |||
return s | |||
end | |||
local function GetParam (args, NameValues) -- CHANGED, NEW | |||
local value = nil | |||
for k, v in pairs(NameValues) do | |||
if args[v] ~= nil then | |||
value = args[v] | |||
break | |||
end | |||
end | |||
return value | |||
end | |||
local function MkIntLnk (S) -- CHANGED, NEW | |||
return "[["..S.."]]" | |||
end | |||
local function getInYourLang (ident) -- CHANGED, NEW | |||
function lnk () | |||
return "https://www.wikidata.org/wiki/" .. ident .. "?uselang="..local_lang | |||
end | |||
local label = mw.wikibase.getLabelByLang(ident, local_lang) | |||
local addEnd = '' | |||
local Article = nil | |||
if label == nil then | |||
label = mw.wikibase.getLabelByLang(ident,'en') | |||
if CFG.WDLnk_Transl then | |||
addEnd = ' [[File:OOjs UI icon Wikidata Echo lightcolors en.svg|17px|text-bottom|'..RS.youCanTranslateIt | |||
.. "|link="..lnk().."]]" | |||
end | |||
else | |||
if CFG.ArticleLnk then | |||
Article = mw.wikibase.getSitelink (ident) | |||
end | |||
if (Article == nil) and CFG.WDLnk_CorrectTransl then | |||
addEnd = ' [[File:OOjs UI icon Wikidata Echo lightcolors.svg|10px|baseline|'..RS.youCanModifyIt | |||
.. "|link="..lnk().."]]" | |||
end | |||
end | |||
return label, addEnd, Article | |||
end | |||
local function getInYourLang1 (ident) -- CHANGED, NEW. Used for p.getDisease and p.getDrug | |||
label, addEnd, Article = getInYourLang (ident) | |||
if Article then | |||
label = MkIntLnk (Article..'|'..label) | |||
end | |||
return label..addEnd | |||
end | |||
local function MkChrTextTable (last, specie, isHuman) -- CHANGED, NEW | |||
local chrTextTable = {} | |||
for v = 1, last do | |||
chrTextTable[tostring(v)] = string.format (RS.ChromosomeAutoSex_abbr, v, specie) | |||
if isHuman then | |||
chrTextTable[tostring(v)] = string.format (RS.ChromosomeAuto_lnk, v, specie)..'|'..chrTextTable[tostring(v)] | |||
end | |||
end | |||
local SexGen = {'X','Y'} | |||
for v = 1, 2 do | |||
chrTextTable[tostring(v)] = string.format (RS.ChromosomeAutoSex_abbr, SexGen[v], specie) | |||
if isHuman then | |||
chrTextTable[SexGen[v]] = string.format (RS.ChromosomeSex_lnk, SexGen[v], specie)..'|'..chrTextTable[tostring(v)] | |||
end | |||
end | |||
chrTextTable["MT"] = string.format (RS.ChromosomeMit, specie) | |||
return chrTextTable | |||
end | |||
-- wrapped "protected call", return "value error" with error info on error | -- wrapped "protected call", return "value error" with error info on error | ||
Line 26: | Line 110: | ||
end | end | ||
--texts relevant to localization are tagged with -- | function p.GetArgs (frame) -- CHANGED, NEW | ||
local origArgs | |||
if frame == mw.getCurrentFrame() then | |||
-- We're being called via #invoke. If the invoking template passed any parameters, | |||
-- use them. Otherwise, use the parameters that were passed into the template. | |||
origArgs = frame:getParent().args | |||
for _, v in pairs( frame.args ) do | |||
origArgs = frame.args | |||
break | |||
end | |||
else | |||
-- We're being called from another module or from the debug console, so assume | |||
-- the parameters are passed in directly. | |||
origArgs = frame | |||
end | |||
return origArgs | |||
end | |||
--texts relevant to localization are tagged with --*lclz* and/or *lclz* | |||
--on a page {{#invoke:Sandbox/genewiki/alllua|getTemplateData|QID=Q14865053}} | --on a page {{#invoke:Sandbox/genewiki/alllua|getTemplateData|QID=Q14865053}} | ||
--in debug window | --in debug window | ||
Line 33: | Line 135: | ||
--print(p.getTemplateData(frame)) | --print(p.getTemplateData(frame)) | ||
function p.getTemplateData(frame) | function p.getTemplateData(frame) | ||
if (local_lang == 'en') or (local_lang == 'simple') then -- CHANGED, NEW | |||
CFG.WDLnk_Transl = false | |||
CFG.WDLnk_CorrectTransl = false | |||
end | |||
--make some guesses about whether the provided QID is a good one | --make some guesses about whether the provided QID is a good one | ||
--could expand here if we had some kind of error handling framework | --could expand here if we had some kind of error handling framework | ||
--did we get it from the page | --did we get it from the page | ||
local root_qid = mw.text.trim( | local args = p.GetArgs (frame) | ||
local root_qid = mw.text.trim(args['QID'] or "") --try to get it from the args | |||
local mm_qid = "" | local mm_qid = "" | ||
--pull all the entity objects that we will need | --pull all the entity objects that we will need | ||
local entity = {} | local entity = {} | ||
local entity_protein = {} | local entity_protein = {} | ||
local entity_mouse = {} | local entity_mouse = {} | ||
local entity_mouse_protein = {} | local entity_mouse_protein = {} | ||
local checkOrtholog = "" --flag used to see if mouse data avaliable | local checkOrtholog = "" --flag used to see if mouse data avaliable | ||
local mouse_propertyID = "P684" --actually ortholog property additional orthologs can exist | local mouse_propertyID = "P684" --actually ortholog property additional orthologs can exist | ||
local protein_propertyID = "P688" | local protein_propertyID = "P688" | ||
--get root gene entity | --get root gene entity | ||
Line 53: | Line 159: | ||
entity = mw.wikibase.getEntity() | entity = mw.wikibase.getEntity() | ||
if entity then root_qid = entity.id else root_qid = "" end | if entity then root_qid = entity.id else root_qid = "" end | ||
else | else | ||
--assuming we think its good make one call to retrieve and store its wikidata representation | --assuming we think its good make one call to retrieve and store its wikidata representation | ||
entity = mw.wikibase.getEntity(root_qid) | entity = mw.wikibase.getEntity(root_qid) | ||
end | end | ||
--need to figure out if it is protein or gene here | |||
local subclass = p.getValue(entity, "P31") or "" | local subclass = p.getValue(entity, "P31") or "" | ||
if string.find(subclass, | if string.find(subclass, RS.proteinL) then --if protein switch entity to gene | ||
local claims | local claims | ||
if entity.claims then | if entity.claims then | ||
claims = entity.claims["P702"] --encoded bychrLength_mm | |||
end | |||
if claims then | if claims then | ||
--go through each index and reassign entity | --go through each index and reassign entity | ||
Line 75: | Line 180: | ||
root_qid = itemID | root_qid = itemID | ||
end | end | ||
end --will return nothing if no claims are found | end --will return nothing if no claims are found | ||
end | end | ||
entity = mw.wikibase.getEntity(root_qid) | entity = mw.wikibase.getEntity(root_qid) | ||
end | |||
--get the other related entities | --get the other related entities | ||
if entity then | if entity then | ||
local claims | local claims | ||
--get protein entity object | |||
if entity.claims then | |||
claims = entity.claims[protein_propertyID] | |||
end | |||
if claims then | if claims then | ||
--go through each index and then make entity_protein indexed | --go through each index and then make entity_protein indexed | ||
Line 95: | Line 200: | ||
entity_protein[#entity_protein + 1] = mw.wikibase.getEntity(protein_itemID) | entity_protein[#entity_protein + 1] = mw.wikibase.getEntity(protein_itemID) | ||
end | end | ||
end --will return nothing if no claims are found | end --will return nothing if no claims are found | ||
end | end | ||
--get mouse entity object | |||
if entity.claims then | |||
claims = entity.claims[mouse_propertyID] | claims = entity.claims[mouse_propertyID] | ||
end | end | ||
Line 149: | Line 254: | ||
end | end | ||
if entity then --only require the main gene entity | if entity then --only require the main gene entity | ||
--a list variables of all the data in the info box | --a list variables of all the data in the info box | ||
local name = check_values(p.getLabel,{entity}) | local name = check_values(p.getLabel,{entity}) | ||
local bgee_wikidata_id = 'Q54985720' | local bgee_wikidata_id = 'Q54985720' | ||
local expressed_in_tissues = check_values(p.getValue, {entity, "P5572", | local expressed_in_tissues = check_values(p.getValue, {entity, "P5572", CFG.NotApplicableStr, CFG.SeparatorStr, bgee_wikidata_id, CFG.ArticleLnk}) --P5572: expressed in -- CHANGED: add CFG.ArticleLnk | ||
local expressed_in_mouse_tissues = check_values(p.getValue, {entity_mouse, "P5572", | local expressed_in_mouse_tissues = check_values(p.getValue, {entity_mouse, "P5572", CFG.NotApplicableStr, CFG.SeparatorStr, bgee_wikidata_id, false}) --P5572: expressed in -- CHANGED: add false | ||
local entrez_gene = check_values(p.getValue, {entity, "P351", | local entrez_gene = check_values(p.getValue, {entity, "P351", CFG.NotApplicableStr} ) | ||
local entrez_gene_mm = check_values(p.getValue, {entity_mouse, "P351", | local entrez_gene_mm = check_values(p.getValue, {entity_mouse, "P351", CFG.NotApplicableStr}) | ||
local image = check_values( p.getImage, {entity, "P18", " ", "250px"}) --need to set size | local image = GetParam (args, RS.imageNames) -- CHANGED, image from args | ||
local uniprotID_hs = check_values(p.getValueProtein, {entity_protein, "P352", | local caption = nil -- CHANGED, NEW | ||
local uniprotID_mm = check_values(p.getValueProtein, {entity_mouse_protein, "P352", | if image == nil then | ||
--image = check_values( p.getImage, {entity, "P18", " ", "250px"}) --need to set size | |||
image, caption = p.getImage (entity, "P18", " ", "250px", true) -- CHANGED, need to set size | |||
else | |||
image = "[[File:" .. image .. "|250px]]" | |||
caption = GetParam (args, RS.captionNames) -- CHANGED, NEW | |||
end | |||
local uniprotID_hs = check_values(p.getValueProtein, {entity_protein, "P352", CFG.NotApplicableStr}) | |||
local uniprotID_mm = check_values(p.getValueProtein, {entity_mouse_protein, "P352", CFG.NotApplicableStr}) | |||
local pdbIDs = check_values(p.getPDB, {entity_protein}) --makes a list with links to RCSB | local pdbIDs = check_values(p.getPDB, {entity_protein}) --makes a list with links to RCSB | ||
local aliases = check_values(p.getAliases, {entity}) | local aliases = check_values(p.getAliases, {entity}) | ||
Line 175: | Line 288: | ||
local bio_process = check_values(p.getGO, {entity_protein, "P682"}) | local bio_process = check_values(p.getGO, {entity_protein, "P682"}) | ||
local expression_images = check_values(p.getImage, {entity,"P692","<br><br>","250px"}) | local expression_images = check_values(p.getImage, {entity,"P692","<br><br>","250px"}) | ||
local ensembl = check_values(p.getValue, {entity, "P594", | local ensembl = check_values(p.getValue, {entity, "P594", CFG.NotApplicableStr}) | ||
local ensembl_mm = check_values(p.getValue, {entity_mouse, "P594", | local ensembl_mm = check_values(p.getValue, {entity_mouse, "P594", CFG.NotApplicableStr}) | ||
local refseq_mRNA = check_values(p.getRefseq_mRNA, {entity, "P639", | local refseq_mRNA = check_values(p.getRefseq_mRNA, {entity, "P639", CFG.NotApplicableStr}) | ||
local refseq_mRNA_mm = check_values(p.getRefseq_mRNA, {entity_mouse, "P639", | local refseq_mRNA_mm = check_values(p.getRefseq_mRNA, {entity_mouse, "P639", CFG.NotApplicableStr}) | ||
local refseq_prot = check_values(p.getRefseq_protein, {entity_protein, "P637", | local refseq_prot = check_values(p.getRefseq_protein, {entity_protein, "P637", CFG.NotApplicableStr}) | ||
local refseq_prot_mm = check_values(p.getRefseq_protein, {entity_mouse_protein, "P637", | local refseq_prot_mm = check_values(p.getRefseq_protein, {entity_mouse_protein, "P637", CFG.NotApplicableStr}) | ||
local gstart = check_values(p.getChromosomeLoc, {entity, "P644", "hg"}) | local gstart = check_values(p.getChromosomeLoc, {entity, "P644", "hg"}) | ||
local gend = check_values(p.getChromosomeLoc, {entity, "P645", "hg"}) | local gend = check_values(p.getChromosomeLoc, {entity, "P645", "hg"}) | ||
local chr = | local chr = p.trimChromosome (entity) | ||
local cytoband = check_values(p.getValue, {entity, "P4196", | local cytoband = check_values(p.getValue, {entity, "P4196", CFG.NotApplicableStr}) | ||
local db = check_values(p.getAliasFromGenomeAssembly, {entity,"hg"}) | local db = check_values(p.getAliasFromGenomeAssembly, {entity,"hg"}) | ||
local gstart_mm = check_values(p.getChromosomeLoc, {entity_mouse, "P644", "mm"}) | local gstart_mm = check_values(p.getChromosomeLoc, {entity_mouse, "P644", "mm"}) | ||
local gend_mm = check_values(p.getChromosomeLoc, {entity_mouse, "P645", "mm"}) | local gend_mm = check_values(p.getChromosomeLoc, {entity_mouse, "P645", "mm"}) | ||
local chr_mm = | local chr_mm = p.trimChromosome (entity_mouse) | ||
local db_mm = check_values(p.getAliasFromGenomeAssembly, {entity_mouse,"mm"}) | local db_mm = check_values(p.getAliasFromGenomeAssembly, {entity_mouse,"mm"}) | ||
local cytoband_mm = check_values(p.getValue, {entity_mouse, "P4196", | local cytoband_mm = check_values(p.getValue, {entity_mouse, "P4196", CFG.NotApplicableStr}) | ||
local disease, dis_ref = p.getDisease(entity, "P2293") | local disease, dis_ref = p.getDisease(entity, "P2293") | ||
local drug, drug_ref, drug_pqid, drug_pname = p.getDrug(entity_protein, "P129") | local drug, drug_ref, drug_pqid, drug_pname = p.getDrug(entity_protein, "P129") | ||
Line 196: | Line 309: | ||
p.createTable() | p.createTable() | ||
p.renderUpperTitle(name) | |||
--p.renderCaption() | |||
p.renderImage(image, caption) -- CHANGED, Added caption | |||
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) | 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 | --uncomment here to add a section of the infobox about genetically related diseases, with references | ||
if (CFG.ShowDiseases and disease ~= "" and dis_ref ~= "") then --removes section from those items without disease info | |||
p.renderDiseases(frame, disease, dis_ref, name, root_qid) | |||
end | |||
--uncomment here to add a section of the infobox about drugs that target the protein product of this gene, with references | --uncomment here to add a section of the infobox about drugs that target the protein product of this gene, with references | ||
if (CFG.ShowDrugs and 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 | if (chr ~= "" and gstart ~= "" and gend ~= "") or (chr_mm ~= "" and gstart_mm ~= "" and gend_mm ~= "") then | ||
p.renderGeneLocation(frame, chr, gstart, gend, db, cytoband, ensembl, chr_mm, gstart_mm, gend_mm, db_mm, cytoband_mm, ensembl_mm, name) | p.renderGeneLocation(frame, chr, gstart, gend, db, cytoband, ensembl, chr_mm, gstart_mm, gend_mm, db_mm, cytoband_mm, ensembl_mm, name) | ||
end | end | ||
if expression_images ~= "" or expressed_in_tissues ~= | if expression_images ~= "" or expressed_in_tissues ~= CFG.NotApplicableStr then | ||
p.renderRNAexpression(expression_images, entrez_gene, ensembl, expressed_in_tissues, ensembl_mm, expressed_in_mouse_tissues) | p.renderRNAexpression(expression_images, entrez_gene, ensembl, expressed_in_tissues, ensembl_mm, expressed_in_mouse_tissues) | ||
end | end | ||
Line 221: | Line 335: | ||
end | end | ||
p.renderOrthologs(frame, entrez_gene, entrez_gene_mm, ensembl, ensembl_mm, uniprotID_hs, uniprotID_mm, refseq_mRNA, refseq_mRNA_mm, refseq_prot, refseq_prot_mm, db, chr, gstart, gend, db_mm, chr_mm, gstart_mm, gend_mm) | p.renderOrthologs(frame, entrez_gene, entrez_gene_mm, ensembl, ensembl_mm, uniprotID_hs, uniprotID_mm, refseq_mRNA, refseq_mRNA_mm, refseq_prot, refseq_prot_mm, db, chr, gstart, gend, db_mm, chr_mm, gstart_mm, gend_mm) | ||
p.renderFooter(root_qid, mm_qid) | p.renderFooter(root_qid, mm_qid) | ||
return tostring(root) | 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 | ||
end | end | ||
function p.createTable(subbox) | function p.createTable(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 | root | ||
-- *lclz*: Some projects, like zhwiki (again), use inline styles on | -- *lclz*: Some projects, like zhwiki (again), use inline styles on | ||
-- infobox modules in addition to the class. Be sure to check them out. | -- infobox modules in addition to the class. Be sure to check them out. | ||
:addClass('infobox') | :addClass('infobox') | ||
:css('font-size', '90%') --NEW | |||
:css('width', '23em') -- CHANGED, before: --:css('width', '26.4em') | |||
end | |||
end | end | ||
Line 260: | Line 375: | ||
function p.renderUpperTitle(name) | function p.renderUpperTitle(name) | ||
local title = name | local title = name | ||
if not title then return "error: failed to get label"; end | |||
if CFG.TitleIcon ~= '' and CFG.TitleIcon ~= nil then | |||
title = '<span style="float:left; margin-left: 3px;">[[File:'..CFG.TitleIcon..'|8px|Infotaula de gen|link=]]</span>' | |||
..' '..title -- CHANGED, NEW | |||
end | |||
root | root | ||
:tag('tr') | :tag('tr') | ||
Line 269: | Line 387: | ||
:css('font-size', '125%') | :css('font-size', '125%') | ||
:css('font-weight', 'bold') | :css('font-weight', 'bold') | ||
:css('background-color', CFG.topTitleBGcolor) -- CHANGED, NEW | |||
:wikitext(title) | :wikitext(title) | ||
:done() --end th | :done() --end th | ||
Line 274: | Line 393: | ||
end | end | ||
--This is a place holder for the image caption, which is stored in wikicommons comments unsure how to access | --This is a place holder for the image caption, which is stored in wikicommons comments unsure how to access | ||
function p.renderCaption(entity) | function p.renderCaption(entity) | ||
--caption | --caption | ||
Line 280: | Line 399: | ||
--gets default image | --gets default image | ||
function p.renderImage(image) | --function p.renderImage(image) | ||
function p.renderImage(image, caption) -- CHANGED, New | |||
if caption ~= nil then | |||
image = image.."<br />"..caption | |||
end | |||
root | root | ||
:tag('tr') | :tag('tr') | ||
Line 293: | Line 416: | ||
function p.renderAvailableStructures(uniprotID_hs, uniprotID_mm, checkOrtholog, pdbIDs) | function p.renderAvailableStructures(uniprotID_hs, uniprotID_mm, checkOrtholog, pdbIDs) | ||
local title = RS.AvailableStructures | |||
local pdb_link = MkIntLnk (RS.PDB_lnk) | |||
local searchTitle = "" | |||
local listTitle = RS.PDBListTitle | |||
local PDBe_base = 'https://www.ebi.ac.uk/pdbe/searchResults.html?display=both&term=' | local PDBe_base = 'https://www.ebi.ac.uk/pdbe/searchResults.html?display=both&term=' | ||
local RCSB_base = 'https://www.rcsb.org/search?q=' | 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_name:UniProt%20AND%20' | ||
..'rcsb_polymer_entity_container_identifiers.reference_sequence_identifiers.database_accession:' | ..'rcsb_polymer_entity_container_identifiers.reference_sequence_identifiers.database_accession:' | ||
local url_uniprot = " " | |||
if checkOrtholog == 1 and uniprotID_mm ~= 'n/a' then | |||
searchTitle = RS.checkOrtholog | |||
url_uniprot = uniprotID_mm..','..uniprotID_hs | |||
else | |||
searchTitle = RS.checkOrthologH | |||
url_uniprot = uniprotID_hs | |||
end | |||
local PDBe_list = " " --create a list with " or " if there is more than one uniprot | |||
--get first uniprot in a list | |||
if url_uniprot:match("([^,]+),") then--first check if there is a list if not just assume one value | 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 | PDBe_list = string.gsub(url_uniprot, ",", "%%20or%%20") --add or's inststead of commas | ||
Line 317: | Line 440: | ||
PDBe_list = url_uniprot | PDBe_list = url_uniprot | ||
end | 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 | 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 | --p.formatRow(title)---how to not close the tags is a mystery and I could condense code once I figure out | ||
Line 348: | Line 471: | ||
:attr('rowspan', '2') | :attr('rowspan', '2') | ||
:css('background-color', sideTitleBGcolor) | :css('background-color', sideTitleBGcolor) | ||
:css('width', | :css('width', CFG.PDB_bar_width) -- CHANGED | ||
:wikitext(pdb_link) | :wikitext(pdb_link) | ||
:done() --end th | :done() --end th | ||
Line 404: | Line 527: | ||
function p.renderIdentifiers(aliases, hgnc_id, gene_symbol, homologene_id, omim_id, mgi_id, ChEMBL_id, IUPHAR_id, ec_no, entrez_gene, ensembl) | 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 = | local title = RS.IdentifiersU | ||
local label_aliases = | local label_aliases = MkIntLnk (RS.aliases_lnk) | ||
local symbol_url | local symbol_url | ||
if gene_symbol == "" or gene_symbol == nil then | if gene_symbol == "" or gene_symbol == nil then | ||
symbol_url = "" | symbol_url = "" | ||
else | else | ||
if hgnc_id == "" or hgnc_id == nil then | if hgnc_id == "" or hgnc_id == nil then | ||
symbol_url = gene_symbol | symbol_url = gene_symbol | ||
else | else | ||
symbol_url = "[https://www.genenames.org/data/gene-symbol-report/#!/hgnc_id/"..hgnc_id.." "..gene_symbol.."]" | symbol_url = "[https://www.genenames.org/data/gene-symbol-report/#!/hgnc_id/"..hgnc_id.." "..gene_symbol.."]" | ||
.." ("..MkIntLnk(RS.HUGO_lnk)..")" -- CHANGED, New | |||
end | end | ||
end | |||
-- *lclz*: see getAliases. You can, say, use another punctuation for your language. | |||
if (gene_symbol ~= "") and (gene_symbol ~= nil) then -- CHANGED with checking gene_symbol | |||
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 | end | ||
aliases = string.gsub(aliases, ", ,", ",") --remove comma from middle | |||
local label_ext_id = | aliases = string.gsub(aliases, ", $", "") --remove comma from end | ||
local label_ext_id = RS.ext_id | |||
omim_id = string.gsub(omim_id, "%s", "") | omim_id = string.gsub(omim_id, "%s", "") | ||
local omim_list = mw.text.split(omim_id, | local omim_list = mw.text.split(omim_id, CFG.SeparatorStr) | ||
local omim = "" | local omim = "" | ||
if (omim_id ~= nil and omim_id ~= "") then | if (omim_id ~= nil and omim_id ~= "") then | ||
omim = | omim = MkIntLnk (RS.OMIM_lnk)..": " | ||
end | end | ||
for i, v in ipairs(omim_list) do | for i, v in ipairs(omim_list) do | ||
Line 436: | Line 561: | ||
end | end | ||
end | end | ||
omim = | omim = string.gsub(omim, ", $"," ") --remove comma from end | ||
homologene_id = string.gsub(homologene_id, "%s", "") | homologene_id = string.gsub(homologene_id, "%s", "") | ||
local homolo_list = mw.text.split(homologene_id, | local homolo_list = mw.text.split(homologene_id, CFG.SeparatorStr) | ||
local homolo ="" | local homolo ="" | ||
if (homologene_id ~= nil and homologene_id ~= "") then | if (homologene_id ~= nil and homologene_id ~= "") then | ||
homolo = | homolo = MkIntLnk (RS.Homolo_lnk)..": " | ||
end | end | ||
for i, v in ipairs(homolo_list) do | for i, v in ipairs(homolo_list) do | ||
Line 448: | Line 573: | ||
end | end | ||
end | end | ||
homolo = | homolo = string.gsub(homolo, ", $"," ") --remove comma from end | ||
local genecards = | local genecards = MkIntLnk (RS.GeneCards_lnk)..": " | ||
genecards = genecards.."[https://www.genecards.org/cgi-bin/carddisp.pl?gene="..gene_symbol.." "..gene_symbol.."]" | genecards = genecards.."[https://www.genecards.org/cgi-bin/carddisp.pl?gene="..gene_symbol.." "..gene_symbol.."] " | ||
mgi_id = string.gsub(mgi_id, "%s", "") | mgi_id = string.gsub(mgi_id, "%s", "") | ||
local mgi_list = mw.text.split(mgi_id, | local mgi_list = mw.text.split(mgi_id, CFG.SeparatorStr) | ||
local mgi = "" | local mgi = "" | ||
if (mgi_id ~= nil and mgi_id ~= "") then | if (mgi_id ~= nil and mgi_id ~= "") then | ||
mgi = | mgi = MkIntLnk (RS.MGI_lnk)..": " | ||
end | end | ||
for i, v in ipairs(mgi_list) do | for i, v in ipairs(mgi_list) do | ||
Line 463: | Line 588: | ||
end | end | ||
end | end | ||
mgi = | mgi = string.gsub(mgi, ", $"," ")--remove comma from end | ||
local ChEMBL = "" | local ChEMBL = "" | ||
if string.match(ChEMBL_id, '%w+') then | if string.match(ChEMBL_id, '%w+') then | ||
ChEMBL = | ChEMBL = MkIntLnk (RS.ChEMBL_lnk)..": ".."[https://www.ebi.ac.uk/chembldb/index.php/target/inspect/CHEMBL"..ChEMBL_id.." "..ChEMBL_id.."] " | ||
end | end | ||
local IUPHAR = "" | local IUPHAR = "" | ||
if string.match(IUPHAR_id, '%w+') then | if string.match(IUPHAR_id, '%w+') then | ||
IUPHAR = | IUPHAR = MkIntLnk (RS.IUPHAR_lnk)..": ".."[http://www.guidetopharmacology.org/GRAC/ObjectDisplayForward?objectId="..IUPHAR_id.." "..IUPHAR_id.."] " | ||
end -- *lclz* | end -- *lclz* | ||
local label_EC = | local label_EC = MkIntLnk (RS.EC_lnk) | ||
ec_no = string.gsub(ec_no, "%d%.%d+%.%d+%.%-,", "")--remove those with"-" in list | ec_no = string.gsub(ec_no, "%d%.%d+%.%d+%.%-,", "")--remove those with"-" in list | ||
ec_no = string.gsub(ec_no, "%d%.%d+%.%d+%.%-", "")--remove those with"-" not in list | 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 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 EC = "[https://www.genome.jp/dbget-bin/www_bget?enzyme+" .. link_ec_no .. " " .. ec_no .. "]" | ||
local oma = " | local oma = MkIntLnk (RS.OMA_lnk)..": " | ||
oma = oma.."[https://omabrowser.org/oma/vps/"..mw.text.split(ensembl,",")[1].." "..gene_symbol.." - orthologs]" | 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_table = {omim, mgi, homolo, ChEMBL, IUPHAR, genecards, oma} | ||
Line 486: | Line 611: | ||
end | end | ||
end | end | ||
external_ids = tostring(table.concat(external_id_processed_table, "; ")) | external_ids = tostring(table.concat(external_id_processed_table, " ")) | ||
root | root | ||
:tag('tr') | :tag('tr') | ||
:tag('th') | :tag('th') | ||
:attr('colspan', | :attr('colspan', 4) | ||
:css('text-align', 'center') | :css('text-align', 'center') | ||
:css('background-color', titleBGcolor) | :css('background-color', titleBGcolor) | ||
Line 502: | Line 627: | ||
:tag('span') | :tag('span') | ||
:attr('class', 'plainlinks') | :attr('class', 'plainlinks') | ||
:css('width', CFG.id_bar_width) --CHANGED. New | |||
:wikitext(label_aliases) | :wikitext(label_aliases) | ||
:done() --end span | :done() --end span | ||
Line 522: | Line 648: | ||
:attr('scope', 'row') | :attr('scope', 'row') | ||
:css('background-color', sideTitleBGcolor) | :css('background-color', sideTitleBGcolor) | ||
:css('width', CFG.id_bar_width) --CHANGED, New | |||
:wikitext(label_ext_id) | :wikitext(label_ext_id) | ||
:done() --end th | :done() --end th | ||
Line 555: | Line 682: | ||
function p.renderDiseases(frame, disease, dis_ref, name, qid) | function p.renderDiseases(frame, disease, dis_ref, name, qid) | ||
local title = | local title = RS.RelDiseases | ||
--check first to see if any of the diseases have references | --check first to see if any of the diseases have references | ||
local ref_flag_all = false --check if any disease have references if not then don't render the headers | local ref_flag_all = false --check if any disease have references if not then don't render the headers | ||
Line 565: | Line 691: | ||
disease_name = value | disease_name = value | ||
else | else | ||
disease_name = disease_name.." | disease_name = disease_name..CFG.SeparatorStr.." "..value -- CHANGED | ||
end | end | ||
ref_flag_all = true | ref_flag_all = true | ||
end | end | ||
end | end | ||
if ref_flag_all then | |||
root | root | ||
:tag('tr') | :tag('tr') | ||
Line 587: | Line 713: | ||
:done() --end td | :done() --end td | ||
:done() --end tr | :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 = | local title = RS.AssocDiseases..name..RS.SeeEditWDRef | ||
local ref_link = disease_name..frame:extensionTag("ref",frame | local ref_link = disease_name..' '..frame:extensionTag("ref", MkExtLnk (frame, title, ref_url)) -- CHANGED | ||
root | root | ||
Line 608: | Line 734: | ||
function p.renderDrug(frame,drug, drug_ref, drug_pqid, drug_pname) | function p.renderDrug(frame,drug, drug_ref, drug_pqid, drug_pname) | ||
local title = | local title = RS.TargDrug | ||
--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 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 | 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 | --for i,v in ipairs(drug_pqid) do -- set all lists keys to empty so can append without key errors | ||
--end | --end | ||
for index,value in ipairs(drug) do | for index,value in ipairs(drug) do | ||
Line 622: | Line 748: | ||
drug_list_per_protein[protein_qid] = value | drug_list_per_protein[protein_qid] = value | ||
else | else | ||
drug_list_per_protein[protein_qid] = drug_list_per_protein[protein_qid]..CFG.SeparatorStr.." "..value -- CHANGED, each list of drugs keyed on protein qid | |||
end | end | ||
ref_flag_all = true | ref_flag_all = true | ||
end | end | ||
end | end | ||
if ref_flag_all then | |||
root | root | ||
:tag('tr') | :tag('tr') | ||
Line 648: | Line 773: | ||
--loop to create reference links from drug lists | --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 = RS.InterDrug..drug_pname[k]..RS.SeeEditWDRef | |||
local ref_link = drug_name..' '..frame:extensionTag("ref", MkExtLnk (frame, title, ref_url)) -- CHANGED | |||
root | root | ||
:tag('tr') | :tag('tr') | ||
Line 666: | Line 791: | ||
:done() --end td | :done() --end td | ||
:done() --end tr | :done() --end tr | ||
end | |||
end | |||
end | end | ||
function p.renderGeneLocation(frame, chr, gstart, gend, db, cytoband, ensembl, chr_mm, gstart_mm, gend_mm, db_mm, cytoband_mm, ensembl_mm, name) | function p.renderGeneLocation(frame, chr, gstart, gend, db, cytoband, ensembl, chr_mm, gstart_mm, gend_mm, db_mm, cytoband_mm, ensembl_mm, name) | ||
function rootItems (specie_lnk, ideogramChromo, LabelLnkChromo, wikitext_for_ideogram, cytob, | |||
pair_start, link_start, pair_end, link_end) | |||
root | |||
:tag('tr') | |||
:tag('td') | |||
:attr('colspan', 4) | |||
:css('text-align', 'center') | |||
:css('background-color', rowBGcolor) | |||
: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') | |||
:attr('colspan', '4') | |||
:css('text-align', 'center') | |||
:css('background-color', titleBGcolor) | |||
:wikitext(RS.GL_GeneLoc..' ('..MkIntLnk(specie_lnk)..')') | |||
:done() --end th | |||
:done() --end tr | |||
:tag('tr') | |||
:tag('td') | |||
:attr('colspan', '4') | |||
:css('text-align', 'center') | |||
:css('background-color', rowBGcolor) | |||
:wikitext(ideogramChromo) | |||
:done() --end td | |||
:done() --end tr | |||
:tag('tr') | |||
:tag('td') | |||
:attr('colspan', '4') | |||
:css('background-color', titleBGcolor) | |||
:done() --end td | |||
:done() --end tr | |||
:tag('tr') | |||
:tag('td') --CHANGED, BEGIN | |||
:attr('colspan', '4') | |||
:css('text-align', 'center') | |||
:wikitext(LabelLnkChromo) | |||
:done() --end td --CHANGED, END | |||
:done() --end tr | |||
:tag('tr') | |||
:tag('td') | |||
:attr('colspan', '4') | |||
:css('text-align', 'center') | |||
:css('background-color', rowBGcolor) | |||
:wikitext(wikitext_for_ideogram) | |||
:done() --end td | |||
:done() --end tr | |||
:tag('tr') | |||
:tag('th') | |||
:attr('scope', 'row') | |||
:attr('rowspan', '2') | |||
:attr('width', CFG.label_locus_width) -- CHANGED | |||
:css('background-color', sideTitleBGcolor) | |||
:wikitext(MkIntLnk (RS.GL_locus_lnk)) | |||
:done() --end th | |||
:tag('td') | |||
:attr('rowspan', '2') | |||
:attr('width', CFG.cytoband_width) -- CHANGED | |||
:css('background-color', rowBGcolor) | |||
:tag('span') | |||
:attr('class', 'plainlinks') | |||
:wikitext(cytob) | |||
:done() --end span | |||
:done() --end td | |||
:tag('th') | |||
:attr('scope', 'row') | |||
:css('background-color', sideTitleBGcolor) | |||
:wikitext(RS.GL_gstart) | |||
:done() --end th | |||
:tag('td') | |||
:css('background-color', rowBGcolor) | |||
:tag('span') | |||
:attr('class', 'plainlinks') | |||
:wikitext(p.FormatNaturalNumber(pair_start).." "..MkIntLnk(RS.BasePair_lnk)..link_start) | |||
:done() --end span | |||
:done() --end td | |||
:done() --end tr | |||
:tag('tr') | |||
:tag('th') | |||
:attr('scope', 'row') | |||
:css('background-color', sideTitleBGcolor) | |||
:wikitext(RS.GL_gend) | |||
:done() --end th | |||
:tag('td') | |||
:css('background-color', rowBGcolor) | |||
:tag('span') | |||
:attr('class', 'plainlinks') | |||
:wikitext(p.FormatNaturalNumber(pair_end).." "..MkIntLnk(RS.BasePair_lnk)..link_end) | |||
:done() --end span | |||
:done() --end td | |||
:done() --end tr | |||
:done() --end table | |||
:done() --end td | |||
:done() --end tr | |||
end | |||
local label_chr = MkIntLnk (RS.GL_chr_lnk) | |||
local tooltip_arrowSign = RS.GL_tooltip..name | |||
local arrowSign_width = 14 | |||
if chr ~= "" and chr ~= nil and gstart ~= "" and gend ~= "" then | |||
: | --Chromosome lengths are from GRCh38.p10 https://www.ncbi.nlm.nih.gov/grc/human/data?asm=GRCh38.p10 | ||
--This table is used only for calculating "Where should red-rectangle put?" | |||
--Curretly, Aug 2017, it seems all gene data, which are stored in Wikidata, have start/end positions based on GRCh38. | |||
local chrLengthTable = {} | |||
chrLengthTable["1"] = 248956422 | |||
chrLengthTable["2"] = 242193529 | |||
chrLengthTable["3"] = 198295559 | |||
chrLengthTable["4"] = 190214555 | |||
chrLengthTable["5"] = 181538259 | |||
chrLengthTable["6"] = 170805979 | |||
chrLengthTable["7"] = 159345973 | |||
chrLengthTable["8"] = 145138636 | |||
chrLengthTable["9"] = 138394717 | |||
chrLengthTable["10"] = 133797422 | |||
chrLengthTable["11"] = 135086622 | |||
chrLengthTable["12"] = 133275309 | |||
chrLengthTable["13"] = 114364328 | |||
chrLengthTable["14"] = 107043718 | |||
chrLengthTable["15"] = 101991189 | |||
chrLengthTable["16"] = 90338345 | |||
chrLengthTable["17"] = 83257441 | |||
chrLengthTable["18"] = 80373285 | |||
chrLengthTable["19"] = 58617616 | |||
chrLengthTable["20"] = 64444167 | |||
chrLengthTable["21"] = 46709983 | |||
chrLengthTable["22"] = 50818468 | |||
chrLengthTable["X"] = 156040895 | |||
chrLengthTable["Y"] = 57227415 | |||
chrLengthTable["MT"] = 16569 | |||
local chrLength = chrLengthTable[chr] | |||
--Different languages have different word order. | |||
local chrTextTable = MkChrTextTable (22, RS.HumanL, true) -- CHANGED, NEW | |||
local chrText = chrTextTable[chr] | |||
--about the calculation below, see https://en.wikipedia.org/wiki/User:Was_a_bee/Gene#3._Calculation_detail | |||
local markerWidth = ((gend - gstart) * 294.133 )/ chrLength | |||
if markerWidth < 2 then | |||
markerWidth = 2 | |||
else | |||
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 | |||
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.."] - "..MkIntLnk(RS.Ensembl_lnk)..", May 2017", {name = "refGRCh38Ensembl"}) | |||
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.."] - "..MkIntLnk(RS.Ensembl_lnk)..", May 2017", {name = "refGRCh37Ensembl"}) | |||
source_link_gstart = frame:extensionTag("ref", "", {name = "refGRCh37Ensembl"}) | |||
source_link_gend = frame:extensionTag("ref", "", {name = "refGRCh37Ensembl"}) | |||
else | |||
source_link_chr = "" | |||
source_link_gstart = "" | |||
source_link_gend = "" | |||
end | |||
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>" | |||
end | |||
rootItems ( | |||
RS.GL_Human_lnk, | |||
"[[File:Ideogram human chromosome "..chr..".svg|300px|"..chrText.."]]", | |||
"'''"..label_chr.."''' [["..chrText.."]]"..source_link_chr, | |||
wikitext_for_ideogram_image, | |||
cytoband, | |||
gstart, source_link_gstart, | |||
gend, source_link_gend) | |||
end | end | ||
Line 918: | Line 1,022: | ||
--Different languages have different word order. | --Different languages have different word order. | ||
local chrTextTable_mm = | local chrTextTable_mm = MkChrTextTable (19, RS.MouseL, false) -- CHANGED, NEW | ||
local chrText_mm = chrTextTable_mm[chr_mm] | local chrText_mm = chrTextTable_mm[chr_mm] | ||
Line 960: | Line 1,042: | ||
--But as of now, Aug. 2017, it seems that all data which is stored in Wikidata are based on GRCm38/mm10. | --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. | --So treating mouse genomic data as GRCm38/mm10 if not specified. | ||
source_link_chr_mm = frame:extensionTag("ref", "[http://May2017.archive.ensembl.org/Mus_musculus/Gene/Summary?db=core;g="..ensembl_mm.." GRCm38: Ensembl release 89: "..ensembl_mm.."] – | source_link_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.."] – "..MkIntLnk(RS.Ensembl_lnk)..", May 2017", {name = "refGRCm38Ensembl"}) | ||
source_link_gstart_mm = frame:extensionTag("ref", "", {name = "refGRCm38Ensembl"}) | source_link_gstart_mm = frame:extensionTag("ref", "", {name = "refGRCm38Ensembl"}) | ||
source_link_gend_mm = frame:extensionTag("ref", "", {name = "refGRCm38Ensembl"}) | source_link_gend_mm = frame:extensionTag("ref", "", {name = "refGRCm38Ensembl"}) | ||
Line 971: | Line 1,053: | ||
if chr_mm == "MT" then -- wikitext for mitochondrial DNA | 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 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.."<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.."[[File:Map of the human mitochondrial genome.svg|300px|"..chrText_mm.."]]" | ||
--wikitext_for_ideogram_image_mm = wikitext_for_ideogram_image_mm.."</div>" | --wikitext_for_ideogram_image_mm = wikitext_for_ideogram_image_mm.."</div>" | ||
Line 986: | Line 1,068: | ||
wikitext_for_ideogram_image_mm = wikitext_for_ideogram_image_mm.."</div>" | wikitext_for_ideogram_image_mm = wikitext_for_ideogram_image_mm.."</div>" | ||
end | end | ||
rootItems ( | |||
RS.GL_Mouse_lnk, | |||
"[[File:Ideogram house mouse chromosome "..chr_mm..".svg|260px|"..chrText_mm.."]]", | |||
"'''"..label_chr.."''' "..chrText_mm..source_link_chr_mm, | |||
wikitext_for_ideogram_image_mm, | |||
cytoband_mm, | |||
gstart_mm, source_link_gstart_mm, | |||
gend_mm, source_link_gend_mm) | |||
end | |||
end | |||
--Get the render elements collapse option, collapsed anatomic entities (defaut text), | |||
--and anatomic entity list for the gene expression list rendering. | |||
function p.renderExpressionList(expressed_in_tissues, default_text) | |||
--create list of expressed in anatomic entities | |||
if default_text == nil then default_text = "" end | |||
local anatomic_entity_labels = CFG.NotApplicableStr | |||
local collapse = "none" | |||
local split_values = mw.text.split(expressed_in_tissues, CFG.SeparatorStr) | |||
local anatomic_entity_list = {} | |||
local anatomic_entities = {} | |||
local results | |||
for k,v in ipairs(split_values) do | |||
if string.match(v, '%w+') and v ~= CFG.NotApplicableStr then | |||
anatomic_entity_list[#anatomic_entity_list+1] = "<li style='line-height: 137%;'>"..v.."</li>" | |||
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 = CFG.NotApplicableStr | |||
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 | |||
function p.renderRNAexpression(expression_images, entrez_gene, | |||
ensembl, bgee_expression, ensembl_mouse, bgee_expression_mouse) | |||
local bgee_gene_page = "https://bgee.org/gene/" | |||
local title = RS.RNAexpres --*lclz* | |||
local biogps_link = "" | |||
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.."/ "..RS.RNAexpres_more_exprdata.."]" | |||
else | |||
expression_images = CFG.NotApplicableStr | |||
: | end | ||
local ensembl_id = string.match(ensembl,"%a+%d+") or "" | |||
local ensembl_id_mouse = string.match(ensembl_mouse,"%a+%d+") or "" | |||
local bgee_title = "Bgee" | |||
bgee_title = "[https://bgee.org/ " .. bgee_title .. "]" | |||
local bgee_default = "["..bgee_gene_page..ensembl_id.." "..RS.RNAexpres_more_expl.."]" | |||
bgee_expression = p.renderExpressionList(bgee_expression, bgee_default) | |||
local bgee_collapse = bgee_expression[1] | |||
:tag('tr') | bgee_default = bgee_expression[2] | ||
:tag('th') | local bgee_tissues = bgee_expression[3] | ||
:attr(' | local bgee_default_mm = "["..bgee_gene_page..ensembl_id_mouse.." "..RS.RNAexpres_more_expl.."]" | ||
: | bgee_expression_mouse = p.renderExpressionList(bgee_expression_mouse, bgee_default_mm) | ||
local bgee_collapse_mm = bgee_expression_mouse[1] | |||
:css('background-color', | bgee_default_mm = bgee_expression_mouse[2] | ||
:wikitext( | local bgee_tissues_mm = bgee_expression_mouse[3] | ||
local bgee_more_link = "" | |||
if bgee_tissues ~= CFG.NotApplicableStr then | |||
bgee_more_link = "["..bgee_gene_page..ensembl_id.." "..RS.RNAexpres_more_exprdata.."]" | |||
end | |||
root | |||
:tag('tr') | |||
:tag('td') | |||
:attr('colspan', 4) | |||
:css('text-align', 'center') | |||
:css('background-color', rowBGcolor) | |||
: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') | |||
:attr('colspan', '4') | |||
:css('text-align', 'center') | |||
:css('background-color', titleBGcolor) | |||
:wikitext(title) | |||
:done() --end th | :done() --end th | ||
: | :done() --end tr | ||
:tag('tr') | |||
:tag('th') | :tag('th') | ||
:attr('scope', 'row') | :attr('scope', 'row') | ||
:css('background-color', sideTitleBGcolor) | :css('background-color', sideTitleBGcolor) | ||
:wikitext( | :wikitext(bgee_title) | ||
:done() --end th | :done() --end th | ||
:tag('td') | :tag('td') | ||
:css(' | :tag('table') | ||
:attr('class', 'none') | |||
: | :css('padding', '0') | ||
:wikitext( | :css('border', 'none') | ||
:css('margin', '0') | |||
:css('width', '100%') | |||
:css('text-align', 'left') | |||
:tag('tr') | |||
:tag('th') | |||
:wikitext("'''"..MkIntLnk(RS.GL_Human_lnk).."'''") | |||
:done() --end th | |||
:tag('th') | |||
:wikitext("'''"..MkIntLnk(RS.GL_Mouse_lnk).."''' "..RS.GL_ortholog) | |||
:done() --end th | |||
:done() --end tr | |||
:tag('tr') | |||
:tag('td') | |||
:tag('table') | |||
:attr('class', bgee_collapse) | |||
: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) | |||
: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) | |||
: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 | |||
:done() --end tr | :done() --end tr | ||
:tag('tr') | :tag('tr') | ||
Line 1,182: | Line 1,277: | ||
:attr('scope', 'row') | :attr('scope', 'row') | ||
:css('background-color', sideTitleBGcolor) | :css('background-color', sideTitleBGcolor) | ||
:wikitext( | :wikitext(biogps_title) | ||
:done() --end th | :done() --end th | ||
:tag('td') | :tag('td') | ||
:tag('table') | :tag('table') | ||
:attr('class', | :attr('class', bgee_collapse) | ||
:css('padding', '0') | :css('padding', '0') | ||
:css('border', 'none') | :css('border', 'none') | ||
Line 1,193: | Line 1,288: | ||
:css('text-align', 'left') | :css('text-align', 'left') | ||
:tag('tr') | :tag('tr') | ||
:tag(' | :tag('td') | ||
: | :attr('colspan', '4') | ||
: | :css('text-align', 'center') | ||
:css('background-color', rowBGcolor) | |||
:wikitext( | :wikitext(expression_images) | ||
:done() --end | :done() --end td | ||
:done() --end tr | :done() --end tr | ||
:tag('tr') | :tag('tr') | ||
:tag('td') | :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 | |||
:done() --end table | |||
:done() --end td | |||
:done() --end tr | |||
end | |||
function p.renderGeneOntology(mol_funct, cell_comp, bio_process, uniprotID) | |||
local title = MkIntLnk (RS.GO_title_lnk) | |||
local mol_funct_title = RS.GO_mol_funct | |||
local cell_comp_title = RS.GO_cell_comp | |||
local bio_process_title = RS.GO_bio_process | |||
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) | |||
: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) | |||
:wikitext(title) | |||
:done() --end th | |||
:done() --end tr | |||
:tag('tr') | |||
:tag('td') | |||
:css('width', CFG.GO_bar_width) --CHANGED. New | |||
:css('background-color', sideTitleBGcolor) | |||
:css('font-weight', 'bold') | |||
:wikitext(mol_funct_title) | |||
:done() --end td | |||
:tag('td') | |||
:css('background-color', rowBGcolor) | |||
: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('width', CFG.GO_bar_width) --CHANGED. New | |||
:css('background-color', sideTitleBGcolor) | |||
:css('font-weight', 'bold') | |||
:wikitext(cell_comp_title) | |||
:done() --end td | |||
:tag('td') | |||
:css('background-color', rowBGcolor) | |||
: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 | |||
:done() --end td | :done() --end td | ||
:done() --end tr | :done() --end tr | ||
:tag('tr') | :tag('tr') | ||
:tag(' | :tag('td') | ||
: | :css('width', GO_bar_width) --CHANGED. New | ||
:css('background-color', sideTitleBGcolor) | :css('background-color', sideTitleBGcolor) | ||
:wikitext( | :css('font-weight', 'bold') | ||
:done() --end | :wikitext(bio_process_title) | ||
:done() --end td | |||
:tag('td') | :tag('td') | ||
: | :css('background-color', rowBGcolor) | ||
: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-align', 'center') | |||
:attr('colspan', '4') | |||
:wikitext(RS.SourcesTP) | |||
:wikitext(amigo_link) | |||
:wikitext(" / ") | |||
:wikitext(quickGO_link) | |||
:done() --end td | :done() --end td | ||
:done() --end tr | :done() --end tr | ||
Line 1,325: | Line 1,408: | ||
end | end | ||
function p.renderOrthologs(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 = RS.Orth_Orthologs --*lclz* | |||
--to do make the list creation a function | |||
--create list for entrez ids | |||
local category_chromosome = MkIntLnk (RS.Orth_Categ..string.format (RS.Orth_C_ChNXY, chr)) -- *lclz*: Category name | |||
if chr == "MT" then | |||
category_chromosome = MkIntLnk (RS.Orth_Categ..RS.Orth_C_Mit) -- *lclz*: Category name for mtDNA genes | |||
end | |||
if chr == "" then | |||
local | category_chromosome = MkIntLnk (RS.Orth_Categ..RS.Orth_HumanGens) -- Per [[Wikipedia:Categories for discussion/Log/2023 August 15]] | ||
local | end | ||
if mw.title.getCurrentTitle().namespace ~= 0 then | |||
category_chromosome = "" | |||
end | |||
local entrezTitle = MkIntLnk (RS.Orth_Entrez_lnk) | |||
entrez_gene = string.gsub(entrez_gene, "%s", "") | |||
local entrez_link = CFG.NotApplicableStr | |||
local entrez_collapse | |||
local entrez_default = "" | |||
local split_entrez = mw.text.split(entrez_gene, CFG.SeparatorStr) | |||
local entrez_link_list = {} | |||
for k,v in ipairs(split_entrez) do | |||
if string.match(v, '%w+') and v ~= CFG.NotApplicableStr then | |||
entrez_link_list[#entrez_link_list+1] = "[https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&cmd=retrieve&dopt=default&list_uids="..entrez_gene.."&rn=1 "..entrez_gene.."]" | |||
end | |||
end | |||
--if less than 5 don't create collapsible list | |||
if CFG.OrthologsCollapsed or (table.getn(entrez_link_list) < 5) then -- CHANGED, added OrthologsCollapsed | |||
entrez_collapse = "none" | |||
if entrez_default == nil and table.getn(entrez_link_list) == 0 then entrez_link = CFG.NotApplicableStr end | |||
else | |||
entrez_collapse = "collapsible collapsed" | |||
entrez_default = table.remove(entrez_link_list, 1) .. '<br>' .. table.remove(entrez_link_list, 1) .. '<br>' ..table.remove(entrez_link_list, 1) .. '<br>' .. table.remove(entrez_link_list, 1) .. '<br>' .. table.remove(entrez_link_list, 1) .. '<br>'--get first 5 elements in table and use for display | |||
end | |||
if entrez_link_list[#entrez_link_list] then | |||
entrez_link = table.concat(entrez_link_list, "<br>") | |||
end | |||
--create list for mouse Entrez id | |||
entrez_gene_mm = string.gsub(entrez_gene_mm, "%s", "") | |||
local entrez_mm_link = CFG.NotApplicableStr | |||
local entrez_mm_collapse | |||
local entrez_mm_default = "" | |||
local split_entrez_mm = mw.text.split(entrez_gene_mm, CFG.SeparatorStr) | |||
local entrez_mm_link_list = {} | |||
for k,v in ipairs(split_entrez_mm) do | |||
if string.match(v, '%w+') and v ~= CFG.NotApplicableStr then | |||
entrez_mm_link_list[#entrez_mm_link_list+1] = "[https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&cmd=retrieve&dopt=default&list_uids="..v.."&rn=1 "..v.."]" | |||
end | |||
end | |||
--if less than 5 don't create collapsible list | |||
if CFG.OrthologsCollapsed or (table.getn(entrez_mm_link_list) < 5) then -- CHANGED, added OrthologsCollapsed | |||
entrez_mm_collapse = "none" | |||
if entrez_mm_default == nil and table.getn(entrez_mm_link_list) == 0 then entrez_mm_link = CFG.NotApplicableStr end | |||
else | |||
entrez_mm_collapse = "collapsible collapsed" | |||
entrez_mm_default = table.remove(entrez_mm_link_list, 1) .. '<br>' .. table.remove(entrez_mm_link_list, 1) .. '<br>' ..table.remove(entrez_mm_link_list, 1) .. '<br>' .. table.remove(entrez_mm_link_list, 1) .. '<br>' .. table.remove(entrez_mm_link_list, 1) .. '<br>'--get first 5 elements in table and use for display | |||
end | |||
if entrez_mm_link_list[#entrez_mm_link_list] then | |||
entrez_mm_link = table.concat(entrez_mm_link_list, "<br>") | |||
end | |||
--create list of ensembl id | |||
local ensemblTitle = MkIntLnk (RS.Orth_Ensembl_lnk) | |||
ensembl = string.gsub(ensembl, "%s", "") | |||
local ensembl_link = CFG.NotApplicableStr | |||
local ensembl_collapse | |||
local ensembl_default = "" | |||
local split_ensembl = mw.text.split(ensembl, CFG.SeparatorStr) | |||
local ensembl_link_list = {} | |||
for k,v in ipairs(split_ensembl) do | |||
if string.match(v, '%w+') and v ~= CFG.NotApplicableStr then | |||
ensembl_link_list[#ensembl_link_list+1] = "[http://www.ensembl.org/Homo_sapiens/geneview?gene="..v..";db=core".." "..v.."]" | |||
end | |||
end | |||
--if less than 5 don't create collapsible list | |||
if CFG.OrthologsCollapsed or (table.getn(ensembl_link_list) < 5) then -- CHANGED, added OrthologsCollapsed | |||
ensembl_collapse = "none" | |||
if ensembl_default == nil and table.getn(ensembl_link_list) == 0 then ensembl_link = CFG.NotApplicableStr end | |||
else | |||
ensembl_collapse = "collapsible collapsed" | |||
ensembl_default = table.remove(ensembl_link_list, 1) .. '<br>' .. table.remove(ensembl_link_list, 1) .. '<br>' ..table.remove(ensembl_link_list, 1) .. '<br>' .. table.remove(ensembl_link_list, 1) .. '<br>' .. table.remove(ensembl_link_list, 1) .. '<br>'--get first 5 elements in table and use for display | |||
end | |||
if ensembl_link_list[#ensembl_link_list] then | |||
ensembl_link = table.concat(ensembl_link_list, "<br>") | |||
end | |||
--create list of mouse ensembl id | |||
ensembl_mm = string.gsub(ensembl_mm, "%s", "") | |||
local ensembl_mm_link = CFG.NotApplicableStr | |||
local ensembl_mm_collapse | |||
local ensembl_mm_default = "" | |||
local split_ensembl_mm = mw.text.split(ensembl_mm, CFG.SeparatorStr) | |||
local ensembl_mm_link_list = {} | |||
for k,v in ipairs(split_ensembl_mm) do | |||
if string.match(v, '%w+') and v ~= CFG.NotApplicableStr then | |||
ensembl_mm_link_list[#ensembl_mm_link_list+1] = "[http://www.ensembl.org/Mus_musculus/geneview?gene="..v..";db=core".." "..v.."]" | |||
end | |||
end | |||
--if less than 5 don't create collapsible list | |||
if CFG.OrthologsCollapsed or (table.getn(ensembl_mm_link_list) < 5) then -- CHANGED, added OrthologsCollapsed | |||
ensembl_mm_collapse = "none" | |||
if ensembl_mm_default == nil and table.getn(ensembl_mm_link_list) == 0 then ensembl_mm_link = CFG.NotApplicableStr end | |||
else | |||
ensembl_mm_collapse = "collapsible collapsed" | |||
ensembl_mm_default = table.remove(ensembl_mm_link_list, 1) .. '<br>' .. table.remove(ensembl_mm_link_list, 1) .. '<br>' ..table.remove(ensembl_mm_link_list, 1) .. '<br>' .. table.remove(ensembl_mm_link_list, 1) .. '<br>' .. table.remove(ensembl_mm_link_list, 1) .. '<br>'--get first 5 elements in table and use for display | |||
end | |||
if ensembl_mm_link_list[#ensembl_mm_link_list] then | |||
ensembl_mm_link = table.concat(ensembl_mm_link_list, "<br>") | |||
end | |||
--create lists of uniprot ID | |||
local uniprotTitle = MkIntLnk (RS.Orth_UniProt_lnk) | |||
local uniprot_url = "https://www.uniprot.org/uniprot/" | |||
local uniprot_link = CFG.NotApplicableStr | |||
local uniprot_collapse | |||
local uniprot_default = "" | |||
--split string and loop through concatenate by <br> | |||
local split_uniprot = mw.text.split(uniprot, '%p') -- the separator may be different sometimes, see note on zhwiki. This is unlikely to have punctuation, prayer. | |||
local uniprot_link_list = {} | |||
local uniprot_first = {} --preferred values only display [O,P,Q] prefixed entries if they exist | |||
local uniprot_alternate = {} --[A-N,R-Z] entries | |||
local hash = {} --storage to look for duplicated values | |||
for k,v in ipairs(split_uniprot) 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 | |||
local | if string.match(v, '%w+') and v ~= CFG.NotApplicableStr then | ||
--to do | 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 .. "]" | |||
end | |||
end | |||
hash[v] = true | |||
end | |||
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 | end | ||
if | |||
--if less than 5 don't create collapsible list | |||
if CFG.OrthologsCollapsed or (table.getn(uniprot_link_list) < 5) then -- CHANGED, added OrthologsCollapsed | |||
uniprot_collapse = "none" | |||
if uniprot_default == nil and table.getn(uniprot_link_list) == 0 then uniprot_link = CFG.NotApplicableStr end | |||
else | |||
uniprot_collapse = "collapsible collapsed" | |||
uniprot_default = table.remove(uniprot_link_list, 1) .. '<br>' .. table.remove(uniprot_link_list, 1) .. '<br>' ..table.remove(uniprot_link_list, 1) .. '<br>' .. table.remove(uniprot_link_list, 1) .. '<br>' .. table.remove(uniprot_link_list, 1) .. '<br>'--get first 5 elements in table and use for display | |||
end | |||
if uniprot_link_list[#uniprot_link_list] then | |||
uniprot_link = table.concat(uniprot_link_list, "<br>") | |||
end | end | ||
--mouse uniprot lists | |||
local | local uniprot_mm_link = CFG.NotApplicableStr | ||
local | local uniprot_mm_collapse | ||
local | local uniprot_mm_default = "" | ||
local | --split string and loop through concatenate by <br> | ||
local split_uniprot_mm = mw.text.split(uniprot_mm, CFG.SeparatorStr) | |||
for k,v in ipairs( | 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 ~= CFG.NotApplicableStr 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 | ||
end | end | ||
if table.getn(uniprot_mm_first)>0 then --if there is something in the preferred values display else display anything else | |||
if table.getn( | uniprot_mm_link_list = uniprot_mm_first | ||
else | else | ||
uniprot_mm_link_list = uniprot_mm_alternate | |||
end | end | ||
--create list for | --if less than 5 don't create collapsible list | ||
if CFG.OrthologsCollapsed or (table.getn(uniprot_mm_link_list) < 5) then -- CHANGED, added OrthologsCollapsed | |||
local | uniprot_mm_collapse = "none" | ||
local | if uniprot_mm_default == nil and table.getn(uniprot_mm_link_list) == 0 then uniprot_mm_link = CFG.NotApplicableStr end | ||
local | else | ||
local | uniprot_mm_collapse = "collapsible collapsed" | ||
local | uniprot_mm_default = table.remove(uniprot_mm_link_list, 1) .. '<br>' .. table.remove(uniprot_mm_link_list, 1) .. '<br>' ..table.remove(uniprot_mm_link_list, 1) .. '<br>' .. table.remove(uniprot_mm_link_list, 1) .. '<br>' .. table.remove(uniprot_mm_link_list, 1) .. '<br>'--get first 5 elements in table and use for display | ||
for k,v in ipairs( | end | ||
if string.match(v, '%w+') and v ~= | |||
if uniprot_mm_link_list[#uniprot_mm_link_list] then | |||
uniprot_mm_link = table.concat(uniprot_mm_link_list, "<br>") | |||
end | |||
local ncbi_link = "https://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?val=" | |||
local refseq_mRNATitle = MkIntLnk (RS.Orth_RefSeq_lnk).." "..RS.refseq_RNAm | |||
--create list of links for refSeq mRNA | |||
local refseq_mRNA_link = CFG.NotApplicableStr | |||
local refseq_mRNA_collapse | |||
local refseq_mRNA_default = "" | |||
--split string and loop through concatenate by <br> | |||
local split_refseq_mRNA = mw.text.split(refseq_mRNA, CFG.SeparatorStr) | |||
local link_list_first = {} --hold those the have NM or NP values | |||
local link_list_alternate = {} --hold those that are XM or XP values | |||
local link_list = {} --if NM,NP display if not display XM, XP values | |||
for k,v in ipairs(split_refseq_mRNA) do | |||
local label = mw.text.trim(v) | |||
local concat_ncbi_link = ncbi_link .. label | |||
if string.match(v, '%w+') and v ~= CFG.NotApplicableStr 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 | ||
end | |||
if table.getn(link_list_first)>0 then | |||
link_list = link_list_first | |||
else | |||
link_list = link_list_alternate | |||
end | end | ||
--if less than 5 don't create collapsible list | --if less than 5 don't create collapsible list | ||
if table.getn( | if CFG.OrthologsCollapsed or (table.getn(link_list) < 6) then -- CHANGED, added OrthologsCollapsed | ||
refseq_mRNA_collapse = "none" | |||
if | if refseq_mRNA_default == nil and table.getn(link_list) == 0 then refseq_mRNA_link = CFG.NotApplicableStr end | ||
else | 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 | end | ||
if | |||
if link_list[#link_list] then | |||
refseq_mRNA_link = table.concat(link_list, "<br>") | |||
end | end | ||
--create list of | --create list of links for refSeq mRNA for mouse | ||
local | local refseq_mRNA_mm_link = CFG.NotApplicableStr | ||
local refseq_mRNA_mm_collapse | |||
local refseq_mRNA_mm_default = "" | |||
local | local split_refseq_mRNA_mm = mw.text.split(refseq_mRNA_mm, CFG.SeparatorStr) | ||
local | local link_list_mm = {} --if NM,NP display if not display XM, XP values | ||
local | local link_list_first = {} --hold those the have NM or NP values | ||
local | local link_list_alternate = {} --hold those that are XM or XP values | ||
for k,v in ipairs( | |||
if string.match(v, '%w+') and v ~= | for k,v in ipairs(split_refseq_mRNA_mm) do | ||
local label = mw.text.trim(v) | |||
local concat_ncbi_link = ncbi_link .. label | |||
if string.match(v, '%w+') and v ~= CFG.NotApplicableStr 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 | ||
end | |||
if table.getn(link_list_first)>0 then | |||
link_list_mm = link_list_first | |||
else | |||
link_list_mm = link_list_alternate | |||
end | end | ||
--if less than 5 don't create collapsible list | --if less than 5 don't create collapsible list | ||
if table.getn( | if CFG.OrthologsCollapsed or (table.getn(link_list_mm) < 6) then -- CHANGED, added OrthologsCollapsed | ||
refseq_mRNA_mm_collapse = "none" | |||
if | if refseq_mRNA_mm_default == nil and table.getn(link_list_mm) == 0 then refseq_mRNA_mm_link = CFG.NotApplicableStr end | ||
else | else | ||
refseq_mRNA_mm_collapse = "collapsible collapsed" | |||
refseq_mRNA_mm_default = table.remove(link_list_mm, 1) .. '<br>' .. table.remove(link_list_mm, 1) .. '<br>' ..table.remove(link_list_mm, 1) .. '<br>' .. table.remove(link_list_mm, 1) .. '<br>' .. table.remove(link_list_mm, 1) .. '<br>'--get first 5 elements in table and use for display | |||
end | end | ||
if | |||
if link_list_mm[#link_list_mm] then | |||
refseq_mRNA_mm_link = table.concat(link_list_mm, "<br>") | |||
end | end | ||
-- | -- *lclz*: sometimes | ||
local refseq_protTitle = "RefSeq "..RS.refseq_protein | |||
local | --create list of links for human refseq protein | ||
local | local refseq_prot_link = CFG.NotApplicableStr | ||
local | local refseq_prot_collapse | ||
local | local refseq_prot_default = "" | ||
local | local split_refseq_prot = mw.text.split(refseq_prot, CFG.SeparatorStr) | ||
for k,v in ipairs( | local link_list_prot = {} | ||
if string.match(v, '%w+') and v ~= | 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 | |||
local label = mw.text.trim(v) | |||
local concat_ncbi_link = ncbi_link .. label | |||
if string.match(v, '%w+') and v ~= CFG.NotApplicableStr 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 | ||
end | end | ||
if table.getn(link_list_first)>0 then | |||
if table.getn( | link_list_prot = link_list_first | ||
else | else | ||
link_list_prot = link_list_alternate | |||
end | end | ||
if | --if less than 5 don't create collapsible list | ||
if CFG.OrthologsCollapsed or (table.getn(link_list_prot) < 6) then -- CHANGED, added OrthologsCollapsed | |||
refseq_prot_collapse = "none" | |||
if refseq_prot_default == nil and table.getn(link_list_prot) == 0 then refseq_prot_link = CFG.NotApplicableStr end | |||
else | |||
refseq_prot_collapse = "collapsible collapsed" | |||
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 | end | ||
if link_list_prot[#link_list_prot] then | |||
refseq_prot_link = table.concat(link_list_prot, "<br>") | |||
end | end | ||
--create list of links for mouse refseq protein | |||
local refseq_prot_mm_link = CFG.NotApplicableStr | |||
local refseq_prot_mm_collapse | |||
local refseq_prot_mm_default = "" | |||
local split_refseq_prot_mm = mw.text.split(refseq_prot_mm, CFG.SeparatorStr) | |||
-- | local link_list_prot_mm = {} | ||
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_mm) do | |||
local label = mw.text.trim(v) | |||
local concat_ncbi_link = ncbi_link .. label | |||
if string.match(v, '%w+') and v ~= CFG.NotApplicableStr 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 .. "]" | |||
local | |||
local | |||
local | |||
local | |||
local | |||
local | |||
local | |||
for k,v in ipairs( | |||
end | end | ||
end | end | ||
end | end | ||
if table.getn( | if table.getn(link_list_first)>0 then | ||
link_list_prot_mm = link_list_first | |||
else | else | ||
link_list_prot_mm = link_list_alternate | |||
end | end | ||
--if less than 5 don't create collapsible list | --if less than 5 don't create collapsible list | ||
if table.getn( | if CFG.OrthologsCollapsed or (table.getn(link_list_prot_mm) < 6) then -- CHANGED, added OrthologsCollapsed | ||
refseq_prot_mm_collapse = "none" | |||
if | if refseq_prot_mm_default == nil and table.getn(link_list_prot_mm) == 0 then refseq_prot_mm_link = CFG.NotApplicableStr end | ||
else | else | ||
refseq_prot_mm_collapse = "collapsible collapsed" | |||
refseq_prot_mm_default = table.remove(link_list_prot_mm, 1) .. '<br>' .. table.remove(link_list_prot_mm, 1) .. '<br>' ..table.remove(link_list_prot_mm, 1) .. '<br>' .. table.remove(link_list_prot_mm, 1) .. '<br>' .. table.remove(link_list_prot_mm, 1) .. '<br>'--get first 5 elements in table and use for display | |||
end | end | ||
if link_list_prot_mm[#link_list_prot_mm] then | |||
if | refseq_prot_mm_link = table.concat(link_list_prot_mm, "<br>") | ||
end | end | ||
local | local locTitle = string.format (RS.Orth_UCSC, MkIntLnk(RS.Orth_UCSC_lnk)) -- *lclz* | ||
local gstart_mb = p.locToMb(gstart, 2) | |||
local gend_mb = p.locToMb(gend, 2) | |||
local chr_loc_link = "" | |||
local | if (string.match(db, '%w+') and string.match(chr, '%w+') and string.match(gstart, '%w+') and string.match(gend, '%w+') )then | ||
local chr_ucsc | |||
local | if chr == "MT" then | ||
chr_ucsc = "M" --UCSC uses "M" (not "MT") in URL for mitochondrial DNA | |||
else | |||
local | chr_ucsc = chr | ||
end | end | ||
chr_loc_link = "[https://genome.ucsc.edu/cgi-bin/hgTracks?org=Human&db="..db.."&position=chr"..chr_ucsc..":"..gstart.."-"..gend.." ".."Chr "..chr_ucsc..": "..gstart_mb.." – "..gend_mb.." Mb]" | |||
else | |||
chr_loc_link = CFG.NotApplicableStr | |||
end | end | ||
if | local gstart_mm_mb = p.locToMb(gstart_mm, 2) | ||
local gend_mm_mb = p.locToMb(gend_mm, 2) | |||
local chr_loc_mm_link = "" | |||
if (string.match(db_mm, '%w+') and string.match(chr_mm, '%w+') and string.match(gstart_mm, '%w+') and string.match(gend_mm, '%w+') )then | |||
local chr_mm_ucsc | |||
if chr_mm == "MT" then | |||
chr_mm_ucsc = "M" --UCSC uses "M" (not "MT") in URL for mitochondrial DNA | |||
else | |||
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 | else | ||
chr_loc_mm_link = CFG.NotApplicableStr | |||
end | end | ||
local pubmedTitle = string.format (RS.PubMed_Search, MkIntLnk(RS.PubMed_lnk)) -- *lclz* | |||
-- | local pubmed_link = entrez_gene | ||
if | if string.match(entrez_gene, '%w+') and entrez_gene ~= CFG.NotApplicableStr then | ||
pubmed_link = frame:extensionTag("ref", MkExtLnk (frame, "Human PubMed Reference:" , -- CHANGED | |||
"https://www.ncbi.nlm.nih.gov/sites/entrez?db=gene&cmd=Link&LinkName=gene_pubmed&from_uid="..entrez_gene, | |||
"National Center for Biotechnology Information, U.S. National Library of Medicine") )--expandTemplate creates cite web template {{cite web|title=value|url=ref_link..ect}} | |||
end | end | ||
local pubmed_mm_link = entrez_gene_mm | |||
if | if string.match(entrez_gene_mm, '%w+') and entrez_gene_mm ~= CFG.NotApplicableStr then | ||
pubmed_mm_link = frame:extensionTag("ref", MkExtLnk (frame, "Mouse PubMed Reference:" , -- CHANGED | |||
"https://www.ncbi.nlm.nih.gov/sites/entrez?db=gene&cmd=Link&LinkName=gene_pubmed&from_uid="..entrez_gene_mm, | |||
"National Center for Biotechnology Information, U.S. National Library of Medicine" ) )--expandTemplate creates cite web template {{cite web|title=value|url=ref_link..ect}} | |||
end | end | ||
local OrthologsClass = 'collapsible' | |||
local | if CFG.OrthologsCollapsed then -- CHANGED, NEW | ||
OrthologsClass = 'collapsible collapsed' | |||
end | |||
root | |||
:tag('tr') | |||
:tag('td') | |||
:attr('colspan', 4) | |||
:css('text-align', 'center') | |||
:css('background-color', rowBGcolor) | |||
:tag('table') | |||
:attr('class', OrthologsClass) -- CHANGED, NEW | |||
:css('padding', '0') | |||
:css('border', 'none') | |||
:css('margin', '0') | |||
:css('width', '100%') | |||
:css('text-align', 'left') | |||
: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(RS.SpeciesU) | |||
:done() --end th | |||
:tag('td') | |||
:wikitext("'''"..RS.HumanU.."'''") | |||
:done() --end td | |||
:tag('td') | |||
:wikitext("'''"..RS.MouseU.."'''") | |||
: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') | |||
:tag('table') | |||
:attr('class', entrez_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') | |||
:tag('span') | |||
:attr('class', 'plainlinks') | |||
:wikitext(entrez_mm_default) | |||
:done() --end span | |||
:done() --end th | |||
:done() --end tr | |||
:tag('tr') | |||
:tag('td') | |||
:attr('colspan', '1') | |||
:tag('p') | |||
:attr('class', 'plainlinks') | |||
:wikitext(entrez_mm_link) | |||
:done() --end p | |||
:done() --end td | |||
:done() --end tr | |||
:done() --end table | |||
:done() --end td | |||
:done() --end tr | |||
:tag('tr') | |||
:tag('th') | |||
:attr('scope', 'row') | |||
:css('background-color', sideTitleBGcolor) | |||
:wikitext(ensemblTitle) | |||
:done() --end th | |||
:tag('td') | |||
:tag('table') | |||
:attr('class', ensembl_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(ensembl_default) | |||
:done() --end span | |||
:done() --end th | |||
:done() --end tr | |||
:tag('tr') | |||
:tag('td') | |||
:attr('colspan', '1') | |||
:tag('p') | |||
:attr('class', 'plainlinks') | |||
:wikitext(ensembl_link) | |||
:done() --end p | |||
:done() --end td | |||
:done() --end tr | |||
:done() --end table | |||
:done() --end td | |||
:tag('td') | |||
:tag('table') | |||
:attr('class', ensembl_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') | |||
:tag('span') | |||
:attr('class', 'plainlinks') | |||
:wikitext(ensembl_mm_default) | |||
:done() --end span | |||
:done() --end th | |||
:done() --end tr | |||
:tag('tr') | |||
:tag('td') | |||
:attr('colspan', '1') | |||
:tag('p') | |||
:attr('class', 'plainlinks') | |||
:wikitext(ensembl_mm_link) | |||
:done() --end p | |||
:done() --end td | |||
:done() --end tr | |||
:done() --end table | |||
:done() --end td | :done() --end td | ||
:done() --end tr | :done() --end tr | ||
Line 1,852: | Line 1,977: | ||
:attr('scope', 'row') | :attr('scope', 'row') | ||
:css('background-color', sideTitleBGcolor) | :css('background-color', sideTitleBGcolor) | ||
:wikitext( | :wikitext(uniprotTitle) | ||
:done() --end th | :done() --end th | ||
:tag('td') | :tag('td') | ||
:tag('table') | :tag('table') | ||
:attr('class', | :attr('class', uniprot_collapse) | ||
:css('padding', '0') | :css('padding', '0') | ||
:css('border', 'none') | :css('border', 'none') | ||
Line 1,867: | Line 1,992: | ||
:tag('span') | :tag('span') | ||
:attr('class', 'plainlinks') | :attr('class', 'plainlinks') | ||
:wikitext( | :wikitext(uniprot_default) | ||
:done() --end span | :done() --end span | ||
:done() --end th | :done() --end th | ||
Line 1,876: | Line 2,001: | ||
:tag('p') | :tag('p') | ||
:attr('class', 'plainlinks') | :attr('class', 'plainlinks') | ||
:wikitext( | :wikitext(uniprot_link) | ||
:done() --end p | :done() --end p | ||
:done() --end td | :done() --end td | ||
Line 1,884: | Line 2,009: | ||
:tag('td') | :tag('td') | ||
:tag('table') | :tag('table') | ||
:attr('class', | :attr('class', uniprot_mm_collapse) | ||
:css('padding', '0') | :css('padding', '0') | ||
:css('border', 'none') | :css('border', 'none') | ||
Line 1,895: | Line 2,020: | ||
:tag('span') | :tag('span') | ||
:attr('class', 'plainlinks') | :attr('class', 'plainlinks') | ||
:wikitext( | :wikitext(uniprot_mm_default) | ||
:done() --end span | :done() --end span | ||
:done() --end th | :done() --end th | ||
:done() --end | :done() --end th | ||
:tag('tr') | :tag('tr') | ||
:tag('td') | :tag('td') | ||
Line 1,904: | Line 2,029: | ||
:tag('p') | :tag('p') | ||
:attr('class', 'plainlinks') | :attr('class', 'plainlinks') | ||
:wikitext( | :wikitext(uniprot_mm_link) | ||
:done() --end p | :done() --end p | ||
:done() --end td | :done() --end td | ||
Line 1,915: | Line 2,040: | ||
:attr('scope', 'row') | :attr('scope', 'row') | ||
:css('background-color', sideTitleBGcolor) | :css('background-color', sideTitleBGcolor) | ||
:wikitext( | :wikitext(refseq_mRNATitle) | ||
:done() --end th | :done() --end th | ||
:tag('td') | :tag('td') --RNASeq mRNA collapsible table | ||
:tag('table') | :tag('table') | ||
:attr('class', | :attr('class', refseq_mRNA_collapse) | ||
:css('padding', '0') | :css('padding', '0') | ||
:css('border', 'none') | :css('border', 'none') | ||
Line 1,928: | Line 2,053: | ||
:tag('th') | :tag('th') | ||
:attr('colspan', '1') | :attr('colspan', '1') | ||
:attr('class', 'plainlinks') | |||
:wikitext(refseq_mRNA_default) | |||
:done() --end th | :done() --end th | ||
:done() --end tr | :done() --end tr | ||
Line 1,938: | Line 2,061: | ||
:attr('colspan', '1') | :attr('colspan', '1') | ||
:tag('p') | :tag('p') | ||
:attr('class', 'plainlinks') | :tag('span') | ||
:attr('class', 'plainlinks') | |||
:wikitext(refseq_mRNA_link) | |||
:done() --end span | |||
:done() --end p | :done() --end p | ||
:done() --end td | :done() --end td | ||
Line 1,945: | Line 2,070: | ||
:done() --end table | :done() --end table | ||
:done() --end td | :done() --end td | ||
:tag('td') | :tag('td') --RNASeq mRNA collapsible table for mouse | ||
:tag('table') | :tag('table') | ||
:attr('class', | :attr('class', refseq_mRNA_mm_collapse) | ||
:css('padding', '0') | :css('padding', '0') | ||
:css('border', 'none') | :css('border', 'none') | ||
Line 1,956: | Line 2,081: | ||
:tag('th') | :tag('th') | ||
:attr('colspan', '1') | :attr('colspan', '1') | ||
:attr('class', 'plainlinks') | |||
:wikitext(refseq_mRNA_mm_default) | |||
:done() --end th | :done() --end th | ||
:done() --end tr | :done() --end tr | ||
Line 1,966: | Line 2,089: | ||
:attr('colspan', '1') | :attr('colspan', '1') | ||
:tag('p') | :tag('p') | ||
:attr('class', 'plainlinks') | :tag('span') | ||
:attr('class', 'plainlinks') | |||
:wikitext(refseq_mRNA_mm_link) | |||
:done() --end span | |||
:done() --end p | :done() --end p | ||
:done() --end td | :done() --end td | ||
Line 1,978: | Line 2,103: | ||
:attr('scope', 'row') | :attr('scope', 'row') | ||
:css('background-color', sideTitleBGcolor) | :css('background-color', sideTitleBGcolor) | ||
:wikitext( | :wikitext(refseq_protTitle) | ||
:done() --end th | :done() --end th | ||
:tag('td') | :tag('td') --RNASeq protein collapsible table | ||
:tag('table') | :tag('table') | ||
:attr('class', | :attr('class', refseq_prot_collapse) | ||
:css('padding', '0') | :css('padding', '0') | ||
:css('border', 'none') | :css('border', 'none') | ||
Line 1,991: | Line 2,116: | ||
:tag('th') | :tag('th') | ||
:attr('colspan', '1') | :attr('colspan', '1') | ||
:attr('class', 'plainlinks') | |||
:wikitext(refseq_prot_default) | |||
:done() --end th | :done() --end th | ||
:done() --end tr | :done() --end tr | ||
Line 2,001: | Line 2,124: | ||
:attr('colspan', '1') | :attr('colspan', '1') | ||
:tag('p') | :tag('p') | ||
:attr('class', 'plainlinks') | :tag('span') | ||
:attr('class', 'plainlinks') | |||
:wikitext(refseq_prot_link) | |||
:done() --end span | |||
:done() --end p | :done() --end p | ||
:done() --end td | :done() --end td | ||
Line 2,008: | Line 2,133: | ||
:done() --end table | :done() --end table | ||
:done() --end td | :done() --end td | ||
:tag('td') | :tag('td') --RNASeq protein collapsible table for mouse | ||
:tag('table') | :tag('table') | ||
:attr('class', | :attr('class', refseq_prot_mm_collapse) | ||
:css('padding', '0') | :css('padding', '0') | ||
:css('border', 'none') | :css('border', 'none') | ||
Line 2,019: | Line 2,144: | ||
:tag('th') | :tag('th') | ||
:attr('colspan', '1') | :attr('colspan', '1') | ||
:attr('class', 'plainlinks') | |||
:wikitext(refseq_prot_mm_default) | |||
:done() --end th | :done() --end th | ||
:done() --end | :done() --end tr | ||
:tag('tr') | :tag('tr') | ||
:tag('td') | :tag('td') | ||
:attr('colspan', '1') | :attr('colspan', '1') | ||
:tag('p') | :tag('p') | ||
:attr('class', 'plainlinks') | :tag('span') | ||
:attr('class', 'plainlinks') | |||
:wikitext(refseq_prot_mm_link) | |||
:done() --end span | |||
:done() --end p | :done() --end p | ||
:done() --end td | :done() --end td | ||
Line 2,041: | Line 2,166: | ||
:attr('scope', 'row') | :attr('scope', 'row') | ||
:css('background-color', sideTitleBGcolor) | :css('background-color', sideTitleBGcolor) | ||
:wikitext( | :wikitext(locTitle) | ||
:done() --end th | :done() --end th | ||
:tag('td') | :tag('td') | ||
:tag(' | :tag('span') | ||
:attr('class', | :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 td | ||
:done() --end tr | |||
:tag('tr') | |||
:tag('th') | |||
:attr('scope', 'row') | |||
:done() --end tr | |||
:tag('tr') | |||
:tag('th') | |||
:attr('scope', 'row') | |||
:css('background-color', sideTitleBGcolor) | :css('background-color', sideTitleBGcolor) | ||
:wikitext( | :wikitext(pubmedTitle) | ||
:done() --end th | :done() --end th | ||
:tag('td') | :tag('td') | ||
:tag(' | :tag('span') | ||
:attr('class', | :attr('class', 'plainlinks') | ||
:wikitext(pubmed_link) | |||
:done() --end span | |||
:done() --end td | :done() --end td | ||
:tag('td') | :tag('td') | ||
:tag(' | :tag('span') | ||
:attr('class | :attr('class', 'plainlinks') | ||
:wikitext(pubmed_mm_link) | |||
: | :done() --end span | ||
:wikitext(category_chromosome) | |||
:done() --end td | :done() --end td | ||
:done() --end tr | :done() --end tr | ||
:tag('tr') | :done() --end table | ||
:done() --end td | |||
:done() --end tr | |||
end | |||
:wikitext( | |||
function p.formatRow(title) | |||
root | |||
:tag('tr') | |||
:tag('td') | |||
:attr('colspan', '4') | |||
:css('text-align', 'center') | |||
:css('background-color', rowBGcolor) | |||
:tag('table') | |||
:css('padding', '0') | |||
:css('border', 'none') | |||
:css('margin', '0') | |||
:css('width', '100%') | |||
:css('text-align', 'left') | |||
:tag('tr') --create title header | |||
:css('background-color', titleBGcolor) | |||
:css('text-align', 'center') | |||
:tag('th') | |||
:attr('colspan',"2") | |||
:wikitext(title) | |||
:done() --end th | :done() --end th | ||
:done() --end tr | |||
:done() --end table | |||
:done() --end td | |||
:done() --end tr | |||
:done() --end tr | |||
:done() --end table | |||
:done() --end td | |||
:done() --end tr | |||
end | end | ||
function p.renderFooter(Qid, Qid_mm) | |||
local text = MkIntLnk (RS.Wikidata_lnk) --*lclz* | |||
local hs_link = MkIntLnk ("d:"..Qid.."|"..RS.SeeEditHuman) --*lclz* | |||
function p.renderFooter(Qid, Qid_mm) | |||
local text = | |||
local hs_link = " | |||
local mm_link = "" | local mm_link = "" | ||
local link_no_hs | local link_no_hs | ||
local link_no_mm | local link_no_mm | ||
if Qid_mm == "" then | if Qid_mm == "" then | ||
link_no_mm = 0 | |||
link_no_hs = 4 | |||
else | else | ||
link_no_mm = 2 | |||
link_no_hs = 2 | |||
mm_link = MkIntLnk ("d:"..Qid_mm.."|"..RS.SeeEditMouse) --*lclz* | |||
end | end | ||
root | |||
:tag('tr') | :tag('tr') | ||
:tag('td') | :tag('td') | ||
Line 2,291: | Line 2,290: | ||
end | end | ||
-- look into entity object | |||
-- look into entity object | |||
function p.getLabel(entity) | function p.getLabel(entity) | ||
local data = entity | local data = entity | ||
local f = {'labels', | local f = {'labels', local_lang, 'value'} --*lclz* -CHANGED: use of local_lang | ||
local i = 1 | local i = 1 | ||
Line 2,319: | Line 2,306: | ||
end | end | ||
end | end | ||
data = data[index] or data[tonumber(index)] | data = data[index] or data[tonumber(index)] | ||
if not data then | if not data then | ||
return | return | ||
end | end | ||
i = i + 1 | i = i + 1 | ||
end | end | ||
Line 2,335: | Line 2,322: | ||
-- 'sep' parameter is the separation caracter used to separate returned values (e.g. ','), default is a space caracter, e.g. ' '. | -- '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. | -- 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) -- CHANGED, Add CFG.ArticleLnkH | |||
local claims | local claims | ||
if return_val == nil then return_val = "" end | if return_val == nil then return_val = "" end | ||
Line 2,348: | Line 2,335: | ||
local out = {} | local out = {} | ||
for k, v in pairs(claims) do | for k, v in pairs(claims) do | ||
local datav = mw.wikibase.label(v.mainsnak.datavalue.value["id"]) | --local datav = mw.wikibase.label(v.mainsnak.datavalue.value["id"]) -- CHANGED, OLD | ||
if datav == nil then datav = " " end | local datav, addEnd, Article = getInYourLang (v.mainsnak.datavalue.value["id"]) -- CHANGED, BEGIN | ||
if datav == nil then | |||
datav = " " | |||
else -- CHANGED, BEGIN | |||
if Article ~= nil then | |||
datav = MkIntLnk (Article..'|'..datav) | |||
end | |||
if addEnd ~= '' then | |||
datav = datav..addEnd | |||
end | |||
end -- CHANGED, END | |||
--Filter statements with the specified stated_in reference value, if none (stated_in = nil) all statements are considered. | --Filter statements with the specified stated_in reference value, if none (stated_in = nil) all statements are considered. | ||
local is_from_given_source = true | local is_from_given_source = true | ||
Line 2,385: | Line 2,382: | ||
if return_val == nil then return_val = "" end | if return_val == nil then return_val = "" end | ||
local sep = "," | 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 | 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 | local claims | ||
Line 2,399: | Line 2,396: | ||
for k, v in pairs(claims) do | for k, v in pairs(claims) do | ||
local datav = mw.wikibase.getLabel("Q" .. v.mainsnak.datavalue.value["numeric-id"]) | local datav = mw.wikibase.getLabel("Q" .. v.mainsnak.datavalue.value["numeric-id"]) | ||
if datav == nil then datav = " " end | if datav == nil then datav = " " end | ||
out[#out + 1] = datav | out[#out + 1] = datav | ||
end | end | ||
results = table.concat(out, sep) | results = table.concat(out, sep) | ||
Line 2,406: | Line 2,403: | ||
results = entity:formatPropertyValues(propertyID).value | results = entity:formatPropertyValues(propertyID).value | ||
end | end | ||
overall_results[#overall_results+1] = results --individual propertyID value stored in this index | overall_results[#overall_results+1] = results --individual propertyID value stored in this index | ||
end | end | ||
end | end | ||
Line 2,412: | Line 2,409: | ||
local str_overall_results = table.concat(overall_results, sep) --weirdness happens when add a sep = " " otherwise each value represented one time | local str_overall_results = table.concat(overall_results, sep) --weirdness happens when add a sep = " " otherwise each value represented one time | ||
if string.match(str_overall_results, '%w+') then | if string.match(str_overall_results, '%w+') then | ||
return str_overall_results | return str_overall_results | ||
else | else | ||
return return_val | return return_val | ||
Line 2,434: | Line 2,431: | ||
function p.getRefseq_mRNA(entity, propertyID, return_val) | function p.getRefseq_mRNA(entity, propertyID, return_val) | ||
if return_val == nil then return_val = "" end | 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 | local input_rank = "RANK_PREFERRED" ---this is mostly like won't do anything because ranking isn't maintained in wikidata | ||
local claims | local claims | ||
if entity.claims then | if entity.claims then | ||
claims = entity.claims[propertyID] | claims = entity.claims[propertyID] | ||
Line 2,448: | Line 2,445: | ||
local label = mw.wikibase.getLabel("Q" .. v.mainsnak.datavalue.value["numeric-id"]) | 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 | if label == nil then label = "Q" .. v.mainsnak.datavalue.value["numeric-id"] end | ||
if sitelink then | if sitelink then | ||
out[#out + 1] = "[[" .. sitelink .. "|" .. label .. "]]" | out[#out + 1] = "[[" .. sitelink .. "|" .. label .. "]]" | ||
Line 2,457: | Line 2,454: | ||
return table.concat(out, ", ") | return table.concat(out, ", ") | ||
else | else | ||
local results = entity:formatPropertyValues(propertyID, mw.wikibase.entity.claimRanks).value | local results = entity:formatPropertyValues(propertyID, mw.wikibase.entity.claimRanks).value | ||
--loop through results until get a NP or NM or just return whatever is in first element | --loop through results until get a NP or NM or just return whatever is in first element | ||
--[[local results_split = mw.text.split(results, | --[[local results_split = mw.text.split(results, CFG.SeparatorStr) | ||
local preffered_results = " " | local preffered_results = " " | ||
if results_split[1] then | if results_split[1] then | ||
Line 2,469: | Line 2,466: | ||
for i, id in ipairs(results_split) do | for i, id in ipairs(results_split) do | ||
local trim_id = mw.text.trim(id) | 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 | end | ||
if preferred_result then | if preferred_result then | ||
Line 2,488: | Line 2,485: | ||
-- *lclz*: same as getRefseq_mRNA | -- *lclz*: same as getRefseq_mRNA | ||
function p.getRefseq_protein(protein_entities, propertyID, return_val) | function p.getRefseq_protein(protein_entities, propertyID, return_val) | ||
local sep = | local sep = CFG.SeparatorStr | ||
local overall_results = {} --should return empty if nothing assigned | 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 | 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 | local claims | ||
local entity = val --each protein in encodes | local entity = val --each protein in encodes | ||
Line 2,505: | Line 2,502: | ||
for k, v in pairs(claims) do | for k, v in pairs(claims) do | ||
local datav = mw.wikibase.getLabel("Q" .. v.mainsnak.datavalue.value["numeric-id"]) | local datav = mw.wikibase.getLabel("Q" .. v.mainsnak.datavalue.value["numeric-id"]) | ||
if datav == nil then datav = " " end | if datav == nil then datav = " " end | ||
out[#out + 1] = datav | out[#out + 1] = datav | ||
end | end | ||
results = table.concat(out, sep) | results = table.concat(out, sep) | ||
Line 2,512: | Line 2,509: | ||
results = entity:formatPropertyValues(propertyID, mw.wikibase.entity.claimRanks).value | results = entity:formatPropertyValues(propertyID, mw.wikibase.entity.claimRanks).value | ||
end | end | ||
overall_results[#overall_results+1] = results --a list is in each index | overall_results[#overall_results+1] = results --a list is in each index | ||
end | end | ||
end | end | ||
--why are there duplicate results here | --why are there duplicate results here | ||
Line 2,544: | Line 2,541: | ||
--gets an image | --gets an image | ||
function p.getImage(entity, propertyID, sep, imgsize) | --function p.getImage(entity, propertyID, sep, imgsize) | ||
function p.getImage(entity, propertyID, sep, imgsize, searchCaption) -- CHANGED | |||
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 | |||
if searchCaption and (claims[1].qualifiers ~= nil) then | |||
local caption = nil | |||
local vals = claims[1].qualifiers["P2096"][1].datavalue | |||
if vals ~= nil then | |||
for k, v in pairs(vals) do | |||
if v.language == local_lang then | |||
caption = v.text | |||
break | |||
end | |||
end | |||
end | |||
return table.concat(out, sep), caption | |||
else | |||
return table.concat(out, sep) | |||
end | |||
else | |||
return "" | |||
end | |||
else | |||
return "" | |||
end | |||
end | |||
function p.getPDB(protein_entities) | |||
local pdb_propertyID = "P638" | |||
local overall_results = {} | |||
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 | |||
local entity = val | |||
if entity and entity.claims then | |||
claims = entity.claims[pdb_propertyID] | |||
function p.getPDB(protein_entities) | |||
local pdb_propertyID = "P638" | |||
local overall_results = {} | |||
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 | |||
local entity = val | |||
if entity and entity.claims then | |||
claims = entity.claims[pdb_propertyID] | |||
end | end | ||
local sitelink = "https://www.rcsb.org/structure/" | local sitelink = "https://www.rcsb.org/structure/" | ||
Line 2,581: | Line 2,593: | ||
local results | local results | ||
if (claims[1] and claims[1].mainsnak.snaktype == "value") then | if (claims[1] and claims[1].mainsnak.snaktype == "value") then | ||
local out = {} | local out = {} | ||
for k, v in pairs(claims) do | for k, v in pairs(claims) do | ||
local label = mw.wikibase.getLabel(v.mainsnak.datavalue.value) | local label = mw.wikibase.getLabel(v.mainsnak.datavalue.value) | ||
if label == nil then label = v.mainsnak.datavalue.value end | if label == nil then label = v.mainsnak.datavalue.value end | ||
if sitelink then | if sitelink then | ||
out[#out + 1] = "[" .. sitelink .. label .. " " ..label .. "]" | out[#out + 1] = "[" .. sitelink .. label .. " " ..label .. "]" | ||
Line 2,634: | Line 2,646: | ||
-- can only be P644 (genomic start) or P645 (genomic end) for this to work | -- can only be P644 (genomic start) or P645 (genomic end) for this to work | ||
-- should probably try to catch that. Might also increase legibility to use specific variable names when possible | -- should probably try to catch that. Might also increase legibility to use specific variable names when possible | ||
-- local propertyID = mw.text.trim(frame.args[1] or "") | -- local propertyID = mw.text.trim(frame.args[1] or "") | ||
-- this can really only be P659 right now. I'm not sure of the value of including it as a parameter as other values will likely break this function | -- this can really only be P659 right now. I'm not sure of the value of including it as a parameter as other values will likely break this function | ||
local qualifierID = "P659" --mw.text.trim(frame.args[2] or "") | local qualifierID = "P659" --mw.text.trim(frame.args[2] or "") | ||
-- Why do we include this here? What should happen if FETCH_WIKIDATA is not included? | -- Why do we include this here? What should happen if FETCH_WIKIDATA is not included? | ||
--local input_parm = mw.text.trim(frame.args[3] or "") | --local input_parm = mw.text.trim(frame.args[3] or "") | ||
-- this can needs to be fed to the function either by a call to {{#invoke:Wikidata|pageId}} or by setting it directly (e.g. if the function was applied on a page other than the targeted gene) | -- this can needs to be fed to the function either by a call to {{#invoke:Wikidata|pageId}} or by setting it directly (e.g. if the function was applied on a page other than the targeted gene) | ||
Line 2,662: | Line 2,674: | ||
local location = v.mainsnak.datavalue.value | local location = v.mainsnak.datavalue.value | ||
--debugging | --debugging | ||
--out[#out + 1] = k.." location:" .. location.. " || " | --out[#out + 1] = k.." location:" .. location.. " || " | ||
--gets the qualifiers linked to the current claim | --gets the qualifiers linked to the current claim | ||
local quals | local quals | ||
if v.qualifiers then | if v.qualifiers then | ||
quals = v.qualifiers.P659 | quals = v.qualifiers.P659 | ||
Line 2,694: | Line 2,706: | ||
end | end | ||
--in case there are no qualifiers, but there is a location, might as well return it | --in case there are no qualifiers, but there is a location, might as well return it | ||
else | else | ||
output = location | output = location | ||
end | end | ||
end | end | ||
Line 2,713: | Line 2,725: | ||
local output = "" | local output = "" | ||
local sep = " " | local sep = " " | ||
local propertyID = "P644" --genomic start used | local propertyID = "P644" --genomic start used | ||
local qualifierID = "P659" --genomic assembly | local qualifierID = "P659" --genomic assembly | ||
Line 2,719: | Line 2,731: | ||
local claims | local claims | ||
if entity.claims then | if entity.claims then | ||
claims = entity.claims[propertyID] | |||
end | end | ||
--will return nothing if no claims are found | --will return nothing if no claims are found | ||
Line 2,778: | Line 2,790: | ||
-- *lclz*: Your language's wikidata may have different nouns for chromosome and | -- *lclz*: Your language's wikidata may have different nouns for chromosome and | ||
-- mitochodria. | -- mitochodria. | ||
function p.trimChromosome(entity) | function p.trimChromosome(entity) -- CHANGED, FULL CHANGED | ||
local string_to_trim = p.getValue(entity, "P1057") | local string_to_trim = p.getValue(entity, "P1057") | ||
local function GetParam (NameValues) | |||
local value = nil | |||
for k, v in pairs(NameValues) do | |||
if string.find(string_to_trim, v) then | |||
return true | |||
end | |||
end | |||
return false | |||
end | |||
local out = '' | local out = '' | ||
--See [[d:Special:WhatLinksHere/Q18694495]] | --See [[d:Special:WhatLinksHere/Q18694495]] | ||
if | if GetParam (RS.WD_chromosomeMT) then | ||
out = "MT" | out = "MT" | ||
elseif | elseif GetParam (RS.WD_chromosome) then | ||
out = string.match(string_to_trim, " | out = string.match(string_to_trim, "X") or string.match(string_to_trim, "Y") | ||
if out == nil then | if out == nil then | ||
out = string.match(string_to_trim, " | out = string.match(string_to_trim, "%d+")--extract number from string | ||
end | end | ||
end | end | ||
Line 2,796: | Line 2,816: | ||
function p.locToMb(num, idp) | function p.locToMb(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 | end | ||
function p.isempty(s) | function p.isempty(s) | ||
return s == nil or s == '' | |||
end | end | ||
function p.getGO(protein_entities, propertyID) | function p.getGO(protein_entities, propertyID) | ||
--propertyID ie molecular, cellular, function | --propertyID ie molecular, cellular, function | ||
local overall_results = {} | local overall_results = {} | ||
local results = "" --string to return | local results = "" --string to return | ||
for key, val in pairs(protein_entities) do | for key, val in pairs(protein_entities) do | ||
local claims | local claims | ||
local entity = val | local entity = val | ||
Line 2,824: | Line 2,844: | ||
end | end | ||
local propertyID_child = "P686" -- Gene Ontology ID | local propertyID_child = "P686" -- Gene Ontology ID | ||
if claims then | if claims then | ||
if (claims[1] and claims[1].mainsnak.snaktype == "value" and claims[1].mainsnak.datavalue.type == "wikibase-entityid") then | if (claims[1] and claims[1].mainsnak.snaktype == "value" and claims[1].mainsnak.datavalue.type == "wikibase-entityid") then | ||
--local out = {} | --local out = {} | ||
Line 2,841: | Line 2,861: | ||
end | end | ||
local sitelink = "http://amigo.geneontology.org/amigo/term/" | local sitelink = "http://amigo.geneontology.org/amigo/term/" | ||
local | local identH = "Q" .. v.mainsnak.datavalue.value["numeric-id"] | ||
if label == nil then label = | --local label = mw.wikibase.getLabel(identH) -- CHANGED | ||
local label, addEnd, Article = getInYourLang (identH) -- CHANGED | |||
if label == nil then label = identH end | |||
local wiki_link = "" | local wiki_link = "" | ||
if sitelink and result_GOID ~= nil then | if sitelink and result_GOID ~= nil then | ||
Line 2,849: | Line 2,871: | ||
wiki_link = "\n* [[:d:Q" .. v.mainsnak.datavalue.value["numeric-id"] .. "|" .. label .. "]]" | wiki_link = "\n* [[:d:Q" .. v.mainsnak.datavalue.value["numeric-id"] .. "|" .. label .. "]]" | ||
end | end | ||
-- CHANGED, BEGIN | |||
local AtEnd = '' | |||
if Article ~= nil then | |||
Article = string.gsub (Article, ' ', '_') | |||
AtEnd = ' [[File:Wiki article small light.svg|text-bottom|' | |||
.. "|link=https://ca.wikipedia.org/wiki/"..Article.."]]" | |||
elseif addEnd ~= '' then | |||
AtEnd = addEnd | |||
end | |||
-- CHANGED, END | |||
if AtEnd ~= '' then | |||
wiki_link = wiki_link..AtEnd | |||
end | |||
overall_results[#overall_results+1] = wiki_link | overall_results[#overall_results+1] = wiki_link | ||
end | end | ||
else | else | ||
results = entity:formatPropertyValues(propertyID, mw.wikibase.entity.claimRanks).value | results = entity:formatPropertyValues(propertyID, mw.wikibase.entity.claimRanks).value | ||
end | end | ||
end | end | ||
--overall_results[#overall_results+1] = results --each protein GO terms stored in this index, so table contains all the GO terms with duplicates | --overall_results[#overall_results+1] = results --each protein GO terms stored in this index, so table contains all the GO terms with duplicates | ||
end | end | ||
Line 2,864: | Line 2,899: | ||
for _,v in ipairs(overall_results) do | for _,v in ipairs(overall_results) do | ||
if (not hash[v]) then | |||
res[#res+1] = v | |||
hash[v] = true | |||
end | |||
end | end | ||
return table.concat(res, "") | return table.concat(res, "") | ||
Line 2,873: | Line 2,908: | ||
local function getReference(qID, entity, property_id, ref_index) | local function getReference(qID, entity, property_id, ref_index) | ||
local f = {"claims",property_id, ref_index, "references"} | local f = {"claims",property_id, ref_index, "references"} | ||
local id = qID | local id = qID | ||
--if id and (#id == 0) then | --if id and (#id == 0) then | ||
Line 2,882: | Line 2,917: | ||
return nil | return nil | ||
end | end | ||
local i = 1 | local i = 1 | ||
while true do | while true do | ||
Line 2,893: | Line 2,928: | ||
end | end | ||
end | end | ||
data = data[index] or data[tonumber(index)] | data = data[index] or data[tonumber(index)] | ||
if not data then | if not data then | ||
Line 2,900: | Line 2,935: | ||
i = i + 1 | i = i + 1 | ||
end | end | ||
end | end | ||
function p.getDisease(entity, propertyID) | function getRefLink (id, entity, prop, k) -- CHANGED, NEW. Used for p.getDisease and p.getDrug | ||
local claims | local refLink = "" | ||
local return_val = "" -- define variable; this line was 'if return_val == nil then return_val = "" end' which looks like a copy/paste | local ref = "" | ||
if entity and entity.claims then | ref = getReference (id, entity, prop, k) | ||
claims = entity.claims[propertyID] | if (ref ~= nil and ref ~= '') then | ||
end | refLink = ref | ||
if claims then | end | ||
-- if wiki-linked value output as link if possible | return refLink | ||
end | |||
if (claims[1] and claims[1].mainsnak.snaktype == "value" and claims[1].mainsnak.datavalue.type == "wikibase-entityid") then | |||
function p.getDisease(entity, propertyID) | |||
local out = {} | local claims | ||
local datasource = {} | local return_val = "" -- define variable; this line was 'if return_val == nil then return_val = "" end' which looks like a copy/paste | ||
--{{#invoke:Wikidata |ViewSomething |id=Q18023174 |claims|P2293|1|references|1|snaks|P854|1|datavalue|value}} | if entity and entity.claims then | ||
--maybe there is a more direct way to find this than looping through the json object | claims = entity.claims[propertyID] | ||
end | |||
for k, v in pairs(claims) do | if claims then | ||
local datav = mw.wikibase.getLabel("Q" .. v.mainsnak.datavalue.value["numeric-id"]) | -- if wiki-linked value output as link if possible | ||
if datav == nil then datav = " " end | if (claims[1] and claims[1].mainsnak.snaktype == "value" and claims[1].mainsnak.datavalue.type == "wikibase-entityid") then | ||
local id = "Q" .. v.mainsnak.datavalue.value["numeric-id"] | local out = {} | ||
local linkTarget = mw.wikibase.getSitelink(id) | local datasource = {} | ||
local refLink = "" | --{{#invoke:Wikidata |ViewSomething |id=Q18023174 |claims|P2293|1|references|1|snaks|P854|1|datavalue|value}} | ||
local ref = "" | --maybe there is a more direct way to find this than looping through the json object | ||
ref = getReference("", entity, "P2293", k) | for k, v in pairs(claims) do -- CHANGED | ||
if (ref ~= nil and ref ~= '') then | --local datav = mw.wikibase.getLabel("Q" .. v.mainsnak.datavalue.value["numeric-id"]) | ||
--refLink = refLink..","..ref | --if datav == nil then datav = " " end | ||
refLink = ref | --local id = "Q" .. v.mainsnak.datavalue.value["numeric-id"] | ||
end | --local linkTarget = mw.wikibase.getSitelink(id) | ||
--local refLink = "" | |||
--local ref = "" | |||
--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 refLink = "" then --skip if there isn't a reference found | ||
--if linkTarget then | |||
if linkTarget then | -- out[#out + 1] = "[["..linkTarget.."|"..datav.."]]" | ||
--else | |||
else | -- out[#out + 1] = "[[:d:" .. id .. "|" .. datav .. "]]" | ||
--end | --end | ||
out[#out + 1] = getInYourLang1 ("Q" .. v.mainsnak.datavalue.value["numeric-id"]) -- CHANGED, NEW | |||
--datasource[#out] = refLink | |||
datasource[#out] = getRefLink ("", entity, "P2293", k) -- CHANGED, NEW | |||
end | end | ||
return out, datasource | return out, datasource | ||
Line 2,951: | Line 2,992: | ||
else | else | ||
return return_val | return return_val | ||
end | end | ||
return return_val | |||
end | end | ||
function p.getDrug(protein_entities, propertyID) | function p.getDrug(protein_entities, propertyID) | ||
local out = {} | |||
local datasource = {} | local datasource = {} | ||
local pname = {} | local pname = {} | ||
Line 2,972: | Line 3,013: | ||
if claims then | if claims then | ||
if (claims[1] and claims[1].mainsnak.snaktype == "value" and claims[1].mainsnak.datavalue.type == "wikibase-entityid") 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 | for k, v in pairs(claims) do -- CHANGED | ||
local datav = mw.wikibase.getLabel("Q" .. v.mainsnak.datavalue.value["numeric-id"]) | --local datav = mw.wikibase.getLabel("Q" .. v.mainsnak.datavalue.value["numeric-id"]) | ||
--if datav == nil then datav = "" end | |||
if datav == nil then datav = "" end | --local id = "Q" .. v.mainsnak.datavalue.value["numeric-id"] | ||
local id = "Q" .. v.mainsnak.datavalue.value["numeric-id"] | --local linkTarget = mw.wikibase.getSitelink(id) | ||
local linkTarget = mw.wikibase.getSitelink(id) | --local refLink = "" | ||
local refLink = "" | --local ref = getReference(protein_id, entity, "P129",k) --just check if anything returned | ||
local ref = getReference(protein_id, entity, "P129",k) --just check if anything returned | --if (ref ~= nil and ref ~= '') then | ||
if (ref ~= nil and ref ~= '') then | --refLink = ref | ||
--end | |||
--if linkTarget then | |||
if linkTarget then | --out[#out + 1] = "[["..linkTarget.."|"..datav.."]]" | ||
--else | |||
--out[#out + 1] = "[[:d:" .. id .. "|" .. datav .. "]]" | |||
--end | |||
out[#out + 1] = getInYourLang1 ("Q" .. v.mainsnak.datavalue.value["numeric-id"]) -- CHANGED, NEW | |||
datasource[#out] = getRefLink (protein_id, entity, "P129",k) -- CHANGED, NEW | |||
pname[protein_id] = name | pname[protein_id] = name | ||
pqid[#out] = protein_id | |||
end --end k,v claims loop | end --end k,v claims loop | ||
end --end claims[1] | end --end claims[1] | ||
end --if claims | end --if claims | ||
end -- end protein_entities loop | |||
return out, datasource, pqid, pname | return out, datasource, pqid, pname | ||
end | end | ||
function p. | function p.FormatNaturalNumber(bp) -- CHANGED function name | ||
--Separate number with comma. For example when this function gets "12345678", returns "12 | --Separate number with comma. For example when this function gets "12345678", returns "12.345.678" | ||
local | local FormatedNumber = bp | ||
while true do | while true do | ||
local k | local k | ||
FormatedNumber, k = string.gsub(FormatedNumber, "^(-?%d+)(%d%d%d)", '%1'..CFG.ThousandSeparator..'%2') -- CHANGED, using CFG.ThousandSeparator | |||
if k == 0 then | if k == 0 then | ||
break | break | ||
end | end | ||
end | end | ||
return | return FormatedNumber | ||
end | end | ||
return p | return p |