Module:Infobox gene and Module:Infobox gene/sandbox: Difference between pages

(Difference between pages)
Page 1
Page 2
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 localSeparatorStr = "," -- **lclz** Correct it if your wiki has different setting, like zhwiki uses "、" for now
local localNotApplicableStr = "n/a" -- **lclz**
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 --**lclz** and/or *lclz*
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(frame.args['QID'] or "") --try to get it from the args
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
  --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, 'protein') then --if protein switch entity to gene **lclz**
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 by
claims = entity.claims["P702"] --encoded bychrLength_mm
end
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
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
--get protein entity object
if entity.claims then
if entity.claims then
claims = entity.claims[protein_propertyID]
claims = entity.claims[protein_propertyID]
end
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
--get mouse entity object
if entity.claims then
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", localNotApplicableStr, localSeparatorStr, bgee_wikidata_id}) --P5572: expressed in
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", localNotApplicableStr, localSeparatorStr, bgee_wikidata_id}) --P5572: expressed in
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", localNotApplicableStr} )
local entrez_gene = check_values(p.getValue, {entity, "P351", CFG.NotApplicableStr} )
local entrez_gene_mm = check_values(p.getValue, {entity_mouse, "P351", localNotApplicableStr})
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", localNotApplicableStr})
local caption = nil -- CHANGED, NEW
local uniprotID_mm = check_values(p.getValueProtein, {entity_mouse_protein, "P352", localNotApplicableStr})
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", localNotApplicableStr})
local ensembl = check_values(p.getValue, {entity, "P594", CFG.NotApplicableStr})
local ensembl_mm = check_values(p.getValue, {entity_mouse, "P594", localNotApplicableStr})
local ensembl_mm = check_values(p.getValue, {entity_mouse, "P594", CFG.NotApplicableStr})
local refseq_mRNA = check_values(p.getRefseq_mRNA, {entity, "P639", localNotApplicableStr})
local refseq_mRNA = check_values(p.getRefseq_mRNA, {entity, "P639", CFG.NotApplicableStr})
local refseq_mRNA_mm = check_values(p.getRefseq_mRNA, {entity_mouse, "P639", localNotApplicableStr})
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", localNotApplicableStr})
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", localNotApplicableStr})
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 = check_values(p.trimChromosome, {entity})
local chr = p.trimChromosome (entity)
local cytoband = check_values(p.getValue, {entity, "P4196", localNotApplicableStr})
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 = check_values( p.trimChromosome, {entity_mouse})
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", localNotApplicableStr})
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.renderUpperTitle(name)
--p.renderCaption()
    --p.renderCaption()
p.renderImage(image)
    p.renderImage(image, caption) -- CHANGED, Added caption
p.renderAvailableStructures(uniprotID_hs, uniprotID_mm, checkOrtholog, pdbIDs) --PDB info
    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 (disease ~= "" and dis_ref ~= "") then --removes section from those items without disease info
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)
p.renderDiseases(frame, disease, dis_ref, name, root_qid)
--end
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 (drug ~= "" ) then --removes section from those items without drug info
if (CFG.ShowDrugs and drug ~= "" ) then --removes section from those items without drug info
-- p.renderDrug(frame,drug, drug_ref, drug_pqid, drug_pname)
p.renderDrug(frame,drug, drug_ref, drug_pqid, drug_pname)
--end
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 ~= localNotApplicableStr then
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)
        --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
    if subbox == 'sub' then --doesn't work  
root
    root
:tag('table')
        :tag('table')  
:css('padding', '0')
            :css('padding', '0')
:css('border', 'none')
            :css('border', 'none')
:css('margin', '0')
            :css('margin', '0')
:css('width', 'auto')
            :css('width', 'auto')
:css('min-width', '100%')
            :css('min-width', '100%')
:css('font-size', '100%')
            :css('font-size', '100%')
:css('clear', 'none')
            :css('clear', 'none')
:css('float', 'none')
            :css('float', 'none')
:css('background-color', 'transparent')
            :css('background-color', 'transparent')
 
         
else
    else
root = mw.html.create('table')
    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('width', '26.4em')
            :css('font-size', '90%') --NEW
end
            :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 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 = 'Available structures' --**lclz**
    local title = RS.AvailableStructures
local pdb_link = "[[Protein_Data_Bank|PDB]]" --**lclz**
    local pdb_link = MkIntLnk (RS.PDB_lnk)
local searchTitle = ""
    local searchTitle = ""  
local listTitle = "List of PDB id codes" --**lclz**
    local listTitle = RS.PDBListTitle
local PDBe_base = 'https://www.ebi.ac.uk/pdbe/searchResults.html?display=both&amp;term='
local PDBe_base = 'https://www.ebi.ac.uk/pdbe/searchResults.html?display=both&amp;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 = " "
    local url_uniprot = " "  
 
   
if checkOrtholog == 1 and uniprotID_mm ~= 'n/a' then
    if checkOrtholog == 1 and uniprotID_mm ~= 'n/a' then
searchTitle = 'Ortholog search: ' --**lclz**
    searchTitle = RS.checkOrtholog
url_uniprot = uniprotID_mm..','..uniprotID_hs
    url_uniprot = uniprotID_mm..','..uniprotID_hs
else
    else
searchTitle = 'Human UniProt search: ' --**lclz**
    searchTitle = RS.checkOrthologH
url_uniprot = uniprotID_hs
    url_uniprot = uniprotID_hs
end
    end
local PDBe_list = " " --create a list with " or " if there is more than one uniprot
    local PDBe_list = " " --create a list with " or " if there is more than one uniprot
--get first uniprot in a list
    --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 PDBe = "["..PDBe_base..PDBe_list.." PDBe] "
local RCSB = "["..RCSB_base..url_uniprot.." RCSB] "
    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', '43px')
: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 = "Identifiers" --**lclz**
local title = RS.IdentifiersU
local label_aliases = "[[Gene nomenclature|Aliases]]" --**lclz**
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
    end
 
-- *lclz*: see getAliases. You can, say, use another punctuation for your language.
-- *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 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 first in aliases list
aliases = string.gsub(aliases, ', '..gene_symbol..',', ',') --get rid of gene name if 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 end
    aliases = string.gsub(aliases, ", ,", ",") --remove comma from middle
local label_ext_id = "External IDs" --**lclz**
    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, localSeparatorStr)
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 = "[[Mendelian_Inheritance_in_Man|OMIM]]"..": " --**lclz**
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 = trim(string.gsub(omim, ", $","")--remove comma from end
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, localSeparatorStr)
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 = "[[HomoloGene]]"..": "
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 = trim(string.gsub(homolo, ", $",""))  --remove comma from end
homolo = string.gsub(homolo, ", $"," ")  --remove comma from end
local genecards = "[[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, localSeparatorStr)
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 = "[[Mouse_Genome_Informatics|MGI]]"..": " --**lclz**
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 = trim(string.gsub(mgi, ", $","")) --remove comma from end
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]]"..": ".."[https://www.ebi.ac.uk/chembldb/index.php/target/inspect/CHEMBL"..ChEMBL_id.." "..ChEMBL_id.."] "
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 = "[[International_Union_of_Basic_and_Clinical_Pharmacology|IUPHAR]]"..": ".."[http://www.guidetopharmacology.org/GRAC/ObjectDisplayForward?objectId="..IUPHAR_id.." "..IUPHAR_id.."]" --**lclz**
IUPHAR = MkIntLnk (RS.IUPHAR_lnk)..": ".."[http://www.guidetopharmacology.org/GRAC/ObjectDisplayForward?objectId="..IUPHAR_id.." "..IUPHAR_id.."] "
end -- *lclz*
end -- *lclz*
local label_EC = "[[Enzyme_Commission_number|EC number]]" --**lclz**
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 = "[[Orthologous_MAtrix|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, "&nbsp; "))
root
root
:tag('tr')
:tag('tr')
:tag('th')
:tag('th')
:attr('colspan', '4')
: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 = "Genetically Related Diseases" --**lclz**
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..", "..value -- *lclz*: punctuation
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
    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 = "Diseases that are genetically associated with "..name.." view/edit references on wikidata" --**lclz**
local title = RS.AssocDiseases..name..RS.SeeEditWDRef
local ref_link = disease_name..frame:extensionTag("ref",frame:expandTemplate{ title = 'cite_web', args = { title = title, url = ref_url} })
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 = "Targeted by Drug" --**lclz**
local title = RS.TargDrug


--check first to see if any of the drugs have references
    --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
-- *lclz*: comma
    drug_list_per_protein[protein_qid] = drug_list_per_protein[protein_qid]..CFG.SeparatorStr.." "..value -- CHANGED, each list of drugs keyed on protein qid  
drug_list_per_protein[protein_qid] = drug_list_per_protein[protein_qid]..', '..value --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
    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
    for k,v in pairs(drug_list_per_protein) do
local drug_name = v
        local drug_name = v
local ref_url = "https://www.wikidata.org/wiki/"..k.."#P129" --direct page to property genetically associated disease
    local ref_url =   "https://www.wikidata.org/wiki/"..k.."#P129" --direct page to property genetically associated disease
local title = "Drugs that physically interact with "..drug_pname[k].." view/edit references on wikidata" --**lclz**
        local title = RS.InterDrug..drug_pname[k]..RS.SeeEditWDRef
local ref_link = drug_name..frame:extensionTag("ref",frame:expandTemplate{ title = 'cite_web', args = { title = title, url = ref_url} })
    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
 
   
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)
local titleHuman = "Gene location ([[Human genome|Human]])" --**lclz**
local titleMouse = "Gene location ([[Laboratory mouse|Mouse]])" --**lclz**
local label_chr = "[[Chromosome|Chr.]]" --**lclz**
local label_locus = "[[Locus (genetics)|Band]]" --**lclz**
local label_gstart = "Start" --**lclz**
local label_gend = "End" --**lclz**
local tooltip_arrowSign = "Genomic location for "..name --**lclz**
local arrowSign_width = 14


if chr ~= "" and gstart ~= "" and gend ~= "" then
function rootItems (specie_lnk, ideogramChromo, LabelLnkChromo, wikitext_for_ideogram, cytob,  
--Chromosome lengths are from GRCh38.p10 https://www.ncbi.nlm.nih.gov/grc/human/data?asm=GRCh38.p10
  pair_start, link_start, pair_end, link_end)
--This table is used only for calculating "Where should red-rectangle put?"
root
--Curretly, Aug 2017, it seems all gene data, which are stored in Wikidata, have start/end positions based on GRCh38.
:tag('tr')
local chrLengthTable = {}
:tag('td')
chrLengthTable["1"] = 248956422
:attr('colspan', 4)
chrLengthTable["2"] = 242193529
:css('text-align', 'center')
chrLengthTable["3"] = 198295559
:css('background-color', rowBGcolor)
chrLengthTable["4"] = 190214555
:tag('table')
chrLengthTable["5"] = 181538259
:attr('class', 'collapsible collapsed')
chrLengthTable["6"] = 170805979
:css('padding', '0')
chrLengthTable["7"] = 159345973
:css('border', 'none')
chrLengthTable["8"] = 145138636
:css('margin', '0')
chrLengthTable["9"] = 138394717
:css('width', '100%')
chrLengthTable["10"] = 133797422
:css('text-align', 'left')
chrLengthTable["11"] = 135086622
:tag('tr')
chrLengthTable["12"] = 133275309
:tag('th')
chrLengthTable["13"] = 114364328
:attr('colspan', '4')
chrLengthTable["14"] = 107043718
:css('text-align', 'center')
chrLengthTable["15"] = 101991189
:css('background-color', titleBGcolor)
chrLengthTable["16"] = 90338345
:wikitext(RS.GL_GeneLoc..' ('..MkIntLnk(specie_lnk)..')')
chrLengthTable["17"] = 83257441
:done() --end th
chrLengthTable["18"] = 80373285
:done() --end tr
chrLengthTable["19"] = 58617616
:tag('tr')
chrLengthTable["20"] = 64444167
:tag('td')
chrLengthTable["21"] = 46709983
:attr('colspan', '4')
chrLengthTable["22"] = 50818468
:css('text-align', 'center')
chrLengthTable["X"] = 156040895
:css('background-color', rowBGcolor)
chrLengthTable["Y"] = 57227415
:wikitext(ideogramChromo)
chrLengthTable["MT"] = 16569
:done() --end td
local chrLength = chrLengthTable[chr]
:done() --end tr
 
:tag('tr')
--Different languages have different word order.
:tag('td')
local chrTextTable = {} --**lclz** linked articles
:attr('colspan', '4')
chrTextTable["1"] = "Chromosome 1 (human)"
:css('background-color', titleBGcolor)
chrTextTable["2"] = "Chromosome 2 (human)"
:done() --end td
chrTextTable["3"] = "Chromosome 3 (human)"
:done() --end tr
chrTextTable["4"] = "Chromosome 4 (human)"
:tag('tr')
chrTextTable["5"] = "Chromosome 5 (human)"
:tag('td') --CHANGED, BEGIN
chrTextTable["6"] = "Chromosome 6 (human)"
:attr('colspan', '4')
chrTextTable["7"] = "Chromosome 7 (human)"
:css('text-align', 'center')
chrTextTable["8"] = "Chromosome 8 (human)"
:wikitext(LabelLnkChromo)
chrTextTable["9"] = "Chromosome 9 (human)"
:done() --end td --CHANGED, END
chrTextTable["10"] = "Chromosome 10 (human)"
:done() --end tr
chrTextTable["11"] = "Chromosome 11 (human)"
:tag('tr')
chrTextTable["12"] = "Chromosome 12 (human)"
:tag('td')
chrTextTable["13"] = "Chromosome 13 (human)"
:attr('colspan', '4')
chrTextTable["14"] = "Chromosome 14 (human)"
:css('text-align', 'center')
chrTextTable["15"] = "Chromosome 15 (human)"
:css('background-color', rowBGcolor)
chrTextTable["16"] = "Chromosome 16 (human)"
:wikitext(wikitext_for_ideogram)
chrTextTable["17"] = "Chromosome 17 (human)"
:done() --end td
chrTextTable["18"] = "Chromosome 18 (human)"
:done() --end tr
chrTextTable["19"] = "Chromosome 19 (human)"
:tag('tr')
chrTextTable["20"] = "Chromosome 20 (human)"
:tag('th')
chrTextTable["21"] = "Chromosome 21 (human)"
:attr('scope', 'row')
chrTextTable["22"] = "Chromosome 22 (human)"
:attr('rowspan', '2')
chrTextTable["X"] = "X chromosome (human)"
:attr('width', CFG.label_locus_width) -- CHANGED
chrTextTable["Y"] = "Y chromosome (human)"
:css('background-color', sideTitleBGcolor)
chrTextTable["MT"] = "Mitochondrial DNA (human)"
:wikitext(MkIntLnk (RS.GL_locus_lnk))
local chrText = chrTextTable[chr]
:done() --end th
 
:tag('td')
--about the calculation below, see https://en.wikipedia.org/wiki/User:Was_a_bee/Gene#3._Calculation_detail
:attr('rowspan', '2')
local markerWidth = ((gend - gstart) * 294.133 )/ chrLength
:attr('width', CFG.cytoband_width) -- CHANGED
if markerWidth < 2 then
:css('background-color', rowBGcolor)
markerWidth = 2
:tag('span')
else
:attr('class', 'plainlinks')
markerWidth = math.ceil(markerWidth)
:wikitext(cytob)
end
:done() --end span
local markerLocation = (147.0666 * (gstart + gend) / chrLength ) + 1.6 - (markerWidth / 2)
:done() --end td
local arrowSignLocation = markerLocation + (markerWidth / 2) - (arrowSign_width / 2)
:tag('th')
markerLocation = math.floor( markerLocation * 10 + 0.5 ) / 10
:attr('scope', 'row')
 
:css('background-color', sideTitleBGcolor)
local source_link_chr, source_link_gstart, source_link_gend
:wikitext(RS.GL_gstart)
if( db == "hg38" ) then
:done() --end th
source_link_chr = frame:extensionTag("ref", "[http://May2017.archive.ensembl.org/Homo_sapiens/Gene/Summary?db=core;g="..ensembl.." GRCh38: Ensembl release 89: "..ensembl.."] &ndash; [[Ensembl genome database project|Ensembl]], May 2017", {name = "refGRCh38Ensembl"}) --**lclz**
:tag('td')
source_link_gstart = frame:extensionTag("ref", "", {name = "refGRCh38Ensembl"})
:css('background-color', rowBGcolor)
source_link_gend = frame:extensionTag("ref", "", {name = "refGRCh38Ensembl"})
:tag('span')
elseif( db == "hg37") then
:attr('class', 'plainlinks')
source_link_chr = frame:extensionTag("ref", "[http://grch37.ensembl.org/Homo_sapiens/Gene/Summary?db=core;&g="..ensembl.." GRCh37: Ensembl release 89: "..ensembl.."] &ndash; [[Ensembl genome database project|Ensembl]], May 2017", {name = "refGRCh37Ensembl"}) --**lclz**
:wikitext(p.FormatNaturalNumber(pair_start).." "..MkIntLnk(RS.BasePair_lnk)..link_start)
source_link_gstart = frame:extensionTag("ref", "", {name = "refGRCh37Ensembl"})
:done() --end span
source_link_gend = frame:extensionTag("ref", "", {name = "refGRCh37Ensembl"})
:done() --end td
else
:done() --end tr
source_link_chr = ""
:tag('tr')
source_link_gstart = ""
:tag('th')
source_link_gend = ""
:attr('scope', 'row')
end
:css('background-color', sideTitleBGcolor)
 
:wikitext(RS.GL_gend)
local wikitext_for_ideogram_image = "" --wikitext used for showing gene location
:done() --end th
if chr == "MT" then -- wikitext for mitochondrial DNA
:tag('td')
--wikitext_for_ideogram_image = wikitext_for_ideogram_image.."<div align=\"center\">"
:css('background-color', rowBGcolor)
--wikitext_for_ideogram_image = wikitext_for_ideogram_image.."<div style=\"position: relative; width: 300px;\">"
:tag('span')
--wikitext_for_ideogram_image = wikitext_for_ideogram_image.."[[File:Map of the human mitochondrial genome.svg|300px|"..chrText.."]]"
:attr('class', 'plainlinks')
--wikitext_for_ideogram_image = wikitext_for_ideogram_image.."</div>"
:wikitext(p.FormatNaturalNumber(pair_end).." "..MkIntLnk(RS.BasePair_lnk)..link_end)
--wikitext_for_ideogram_image = wikitext_for_ideogram_image.."</div>"
:done() --end span
:done() --end td
:done() --end tr
:done() --end table
:done() --end td
:done() --end tr
end


else -- wikitext for autosome and sex chromosome
local label_chr = MkIntLnk (RS.GL_chr_lnk)
wikitext_for_ideogram_image = wikitext_for_ideogram_image.."<div align=\"center\">"
local tooltip_arrowSign = RS.GL_tooltip..name
wikitext_for_ideogram_image = wikitext_for_ideogram_image.."<div style=\"position: relative; width: 300px;\">"
local arrowSign_width = 14
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


root
if chr ~= "" and chr ~= nil and gstart ~= "" and gend ~= "" then
:tag('tr')
--Chromosome lengths are from GRCh38.p10 https://www.ncbi.nlm.nih.gov/grc/human/data?asm=GRCh38.p10
:tag('td')
--This table is used only for calculating "Where should red-rectangle put?"
:attr('colspan', 4)
--Curretly, Aug 2017, it seems all gene data, which are stored in Wikidata, have start/end positions based on GRCh38.
:css('text-align', 'center')
local chrLengthTable = {}
:css('background-color', rowBGcolor)
chrLengthTable["1"] = 248956422
:tag('table')
chrLengthTable["2"] = 242193529
:attr('class', 'collapsible collapsed')
chrLengthTable["3"] = 198295559
:css('padding', '0')
chrLengthTable["4"] = 190214555
:css('border', 'none')
chrLengthTable["5"] = 181538259
:css('margin', '0')
chrLengthTable["6"] = 170805979
:css('width', '100%')
chrLengthTable["7"] = 159345973
:css('text-align', 'left')
chrLengthTable["8"] = 145138636
:tag('tr')
chrLengthTable["9"] = 138394717
:tag('th')
chrLengthTable["10"] = 133797422
:attr('colspan', '4')
chrLengthTable["11"] = 135086622
:css('text-align', 'center')
chrLengthTable["12"] = 133275309
:css('background-color', titleBGcolor)
chrLengthTable["13"] = 114364328
:wikitext(titleHuman)
chrLengthTable["14"] = 107043718
:done() --end th
chrLengthTable["15"] = 101991189
:done() --end tr
chrLengthTable["16"] = 90338345
:tag('tr')
chrLengthTable["17"] = 83257441
:tag('td')
chrLengthTable["18"] = 80373285
:attr('colspan', '4')
chrLengthTable["19"] = 58617616
:css('text-align', 'center')
chrLengthTable["20"] = 64444167
:css('background-color', rowBGcolor)
chrLengthTable["21"] = 46709983
:wikitext("[[File:Ideogram human chromosome "..chr..".svg|300px|"..chrText.."]]")
chrLengthTable["22"] = 50818468
:done() --end td
chrLengthTable["X"] = 156040895
:done() --end tr
chrLengthTable["Y"] = 57227415
:tag('tr')
chrLengthTable["MT"] = 16569
:tag('th')
local chrLength = chrLengthTable[chr]
:attr('scope', 'row')
 
:attr('width', '15%')
--Different languages have different word order.
:css('background-color', sideTitleBGcolor)
local chrTextTable = MkChrTextTable (22, RS.HumanL, true) -- CHANGED, NEW
:wikitext(label_chr)
local chrText = chrTextTable[chr]
:done() --end th
 
:tag('td')
--about the calculation below, see https://en.wikipedia.org/wiki/User:Was_a_bee/Gene#3._Calculation_detail
:attr('colspan', '3')
local markerWidth = ((gend - gstart) * 294.133 )/ chrLength
:attr('width', '85%')
if markerWidth < 2 then
:css('background-color', rowBGcolor)
markerWidth = 2
:tag('span')
else
:attr('class', 'plainlinks')
markerWidth = math.ceil(markerWidth)
:wikitext("[["..chrText.."]]"..source_link_chr)
end
:done() --end span
local markerLocation = (147.0666 * (gstart + gend) / chrLength ) + 1.6 - (markerWidth / 2)
:done() --end td
local arrowSignLocation = markerLocation + (markerWidth / 2) - (arrowSign_width / 2)
:done() --end tr
markerLocation = math.floor( markerLocation * 10 + 0.5 ) / 10
:tag('tr')
 
:tag('td')
local source_link_chr, source_link_gstart, source_link_gend
:attr('colspan', '4')
if( db == "hg38" ) then
:css('text-align', 'center')
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"})
:css('background-color', rowBGcolor)
source_link_gstart = frame:extensionTag("ref", "", {name = "refGRCh38Ensembl"})
:wikitext(wikitext_for_ideogram_image)
source_link_gend = frame:extensionTag("ref", "", {name = "refGRCh38Ensembl"})
:done() --end td
elseif( db == "hg37") then
:done() --end tr
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"})
:tag('tr')
source_link_gstart = frame:extensionTag("ref", "", {name = "refGRCh37Ensembl"})
:tag('th')
source_link_gend = frame:extensionTag("ref", "", {name = "refGRCh37Ensembl"})
:attr('scope', 'row')
else
:attr('rowspan', '2')
source_link_chr = ""
:attr('width', '15%')
source_link_gstart = ""
:css('background-color', sideTitleBGcolor)
source_link_gend = ""
:wikitext(label_locus)
end
:done() --end th
 
:tag('td')
local wikitext_for_ideogram_image = "" --wikitext used for showing gene location
:attr('rowspan', '2')
if chr == "MT" then -- wikitext for mitochondrial DNA
:attr('width', '35%')
--wikitext_for_ideogram_image = wikitext_for_ideogram_image.."<div align=\"center\">"
:css('background-color', rowBGcolor)
--wikitext_for_ideogram_image = wikitext_for_ideogram_image.."<div style=\"position: relative; width: 300px;\">"
:tag('span')
--wikitext_for_ideogram_image = wikitext_for_ideogram_image.."[[File:Map of the human mitochondrial genome.svg|300px|"..chrText.."]]"
:attr('class', 'plainlinks')
--wikitext_for_ideogram_image = wikitext_for_ideogram_image.."</div>"
:wikitext(cytoband)
--wikitext_for_ideogram_image = wikitext_for_ideogram_image.."</div>"
:done() --end span
 
:done() --end td
else -- wikitext for autosome and sex chromosome
:tag('th')
wikitext_for_ideogram_image = wikitext_for_ideogram_image.."<div align=\"center\">"
:attr('scope', 'row')
wikitext_for_ideogram_image = wikitext_for_ideogram_image.."<div style=\"position: relative; width: 300px;\">"
:css('background-color', sideTitleBGcolor)
wikitext_for_ideogram_image = wikitext_for_ideogram_image.."[[File:Human chromosome "..chr.." ideogram.svg|300px|"..chrText.."]]"
:wikitext(label_gstart)
wikitext_for_ideogram_image = wikitext_for_ideogram_image.."<div style=\"position: absolute; left: "..arrowSignLocation.."px; top: 2px; padding: 0;\">"
:done() --end th
wikitext_for_ideogram_image = wikitext_for_ideogram_image.."[[File:HSR 1996 II 3.5e.svg|"..arrowSign_width.."px|"..tooltip_arrowSign.."]]</div>"
:tag('td')
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>"
:css('background-color', rowBGcolor)
wikitext_for_ideogram_image = wikitext_for_ideogram_image.."</div>"
:tag('span')
wikitext_for_ideogram_image = wikitext_for_ideogram_image.."</div>"
:attr('class', 'plainlinks')
end
:wikitext(p.separateWithComma(gstart).." [[Base pair|bp]]"..source_link_gstart) -- **lclz** Change it if it is inappropriate
 
:done() --end span
rootItems (
:done() --end td
RS.GL_Human_lnk,
:done() --end tr
"[[File:Ideogram human chromosome "..chr..".svg|300px|"..chrText.."]]",
:tag('tr')
"'''"..label_chr.."''' [["..chrText.."]]"..source_link_chr,
:tag('th')
wikitext_for_ideogram_image,
:attr('scope', 'row')
cytoband,
:css('background-color', sideTitleBGcolor)
gstart, source_link_gstart,
:wikitext(label_gend)
gend, source_link_gend)
:done() --end th
:tag('td')
:css('background-color', rowBGcolor)
:tag('span')
:attr('class', 'plainlinks')
:wikitext(p.separateWithComma(gend).." [[Base pair|bp]]"..source_link_gend) -- **lclz** Change it if it is inappropriate
:done() --end span
:done() --end td
:done() --end tr
:done() --end table
:done() --end td
:done() --end tr
end
end


Line 918: Line 1,022:


--Different languages have different word order.
--Different languages have different word order.
local chrTextTable_mm = {}--**lclz** Articles not yet created
local chrTextTable_mm = MkChrTextTable (19, RS.MouseL, false) -- CHANGED, NEW
chrTextTable_mm["1"] = "Chromosome 1 (mouse)"
chrTextTable_mm["2"] = "Chromosome 2 (mouse)"
chrTextTable_mm["3"] = "Chromosome 3 (mouse)"
chrTextTable_mm["4"] = "Chromosome 4 (mouse)"
chrTextTable_mm["5"] = "Chromosome 5 (mouse)"
chrTextTable_mm["6"] = "Chromosome 6 (mouse)"
chrTextTable_mm["7"] = "Chromosome 7 (mouse)"
chrTextTable_mm["8"] = "Chromosome 8 (mouse)"
chrTextTable_mm["9"] = "Chromosome 9 (mouse)"
chrTextTable_mm["10"] = "Chromosome 10 (mouse)"
chrTextTable_mm["11"] = "Chromosome 11 (mouse)"
chrTextTable_mm["12"] = "Chromosome 12 (mouse)"
chrTextTable_mm["13"] = "Chromosome 13 (mouse)"
chrTextTable_mm["14"] = "Chromosome 14 (mouse)"
chrTextTable_mm["15"] = "Chromosome 15 (mouse)"
chrTextTable_mm["16"] = "Chromosome 16 (mouse)"
chrTextTable_mm["17"] = "Chromosome 17 (mouse)"
chrTextTable_mm["18"] = "Chromosome 18 (mouse)"
chrTextTable_mm["19"] = "Chromosome 19 (mouse)"
chrTextTable_mm["X"] = "X chromosome (mouse)"
chrTextTable_mm["Y"] = "Y chromosome (mouse)"
chrTextTable_mm["MT"] = "Mitochondrial DNA (mouse)"
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.."] &ndash; [[Ensembl genome database project|Ensembl]], May 2017", {name = "refGRCm38Ensembl"}) --**lclz**
source_link_chr_mm = frame:extensionTag("ref", "[http://May2017.archive.ensembl.org/Mus_musculus/Gene/Summary?db=core;g="..ensembl_mm.." GRCm38: Ensembl release 89: "..ensembl_mm.."] &ndash; "..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


root
--Get the render elements collapse option, collapsed anatomic entities (defaut text),
:tag('tr')
--and anatomic entity list for the gene expression list rendering.
:tag('td')
function p.renderExpressionList(expressed_in_tissues, default_text)
:attr('colspan', 4)
--create list of expressed in anatomic entities
:css('text-align', 'center')
if default_text == nil then default_text = "" end
:css('background-color', rowBGcolor)
local anatomic_entity_labels = CFG.NotApplicableStr
:tag('table')
local collapse = "none"
:attr('class', 'collapsible collapsed')
local split_values = mw.text.split(expressed_in_tissues, CFG.SeparatorStr)
:css('padding', '0')
local anatomic_entity_list = {}
:css('border', 'none')
local anatomic_entities = {}
:css('margin', '0')
local results
:css('width', '100%')
for k,v in ipairs(split_values) do
:css('text-align', 'left')
if string.match(v, '%w+') and v ~= CFG.NotApplicableStr then
:tag('tr')
anatomic_entity_list[#anatomic_entity_list+1] = "<li style='line-height: 137%;'>"..v.."</li>"
:tag('th')
anatomic_entities[#anatomic_entities+1] = v
:attr('colspan', '4')
end
:css('text-align', 'center')
end
:css('background-color', titleBGcolor)
--if less than 11 don't create collapsible list
:wikitext(titleMouse)
if table.getn(anatomic_entity_list) < 11 then
:done() --end th
if table.getn(anatomic_entity_list) == 0 then
:done() --end tr
anatomic_entity_labels = CFG.NotApplicableStr
:tag('tr')
default_text = ""
:tag('td')
end
:attr('colspan', '4')
else
:css('text-align', 'center')
collapse = "collapsible collapsed"
:css('background-color', rowBGcolor)
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
:wikitext("[[File:Ideogram house mouse chromosome "..chr_mm..".svg|260px|"..chrText_mm.."]]")
end
:done() --end td
if anatomic_entity_list[#anatomic_entity_list] then
:done() --end tr
anatomic_entity_labels = table.concat(anatomic_entity_list, "<br>")
:tag('tr')
end
:tag('th')
results = {collapse, default_text, anatomic_entity_labels}
:attr('scope', 'row')
return results
:attr('width', '15%')
end
:css('background-color', sideTitleBGcolor)
 
:wikitext(label_chr)
function p.renderRNAexpression(expression_images, entrez_gene,
:done() --end th
ensembl, bgee_expression, ensembl_mouse, bgee_expression_mouse)
:tag('td')
local bgee_gene_page = "https://bgee.org/gene/"
:attr('colspan', '3')
local title = RS.RNAexpres --*lclz*
:attr('width', '85%')
local biogps_link = ""
:css('background-color', rowBGcolor)
local biogps_title = "BioGPS"
:tag('span')
biogps_title = "[http://biogps.org/ " .. biogps_title .. "]"
:attr('class', 'plainlinks')
-- If no expression image exist in BioGPS, the N/A is displayed
:wikitext(chrText_mm..source_link_chr_mm)
if expression_images ~= "" then
:done() --end span
biogps_link = "[http://biogps.org/gene/"..entrez_gene.."/ "..RS.RNAexpres_more_exprdata.."]"
:done() --end td
else
:done() --end tr
expression_images = CFG.NotApplicableStr
:tag('tr')
end
:tag('td')
local ensembl_id = string.match(ensembl,"%a+%d+") or ""
:attr('colspan', '4')
local ensembl_id_mouse = string.match(ensembl_mouse,"%a+%d+") or ""
:css('text-align', 'center')
local bgee_title = "Bgee"
:css('background-color', rowBGcolor)
bgee_title = "[https://bgee.org/ " .. bgee_title .. "]"
:wikitext(wikitext_for_ideogram_image_mm)
local bgee_default = "["..bgee_gene_page..ensembl_id.." "..RS.RNAexpres_more_expl.."]"
:done() --end td
bgee_expression = p.renderExpressionList(bgee_expression, bgee_default)
:done() --end tr
local bgee_collapse = bgee_expression[1]
:tag('tr')
bgee_default = bgee_expression[2]
:tag('th')
local bgee_tissues = bgee_expression[3]
:attr('scope', 'row')
local bgee_default_mm = "["..bgee_gene_page..ensembl_id_mouse.." "..RS.RNAexpres_more_expl.."]"
:attr('rowspan', '2')
bgee_expression_mouse = p.renderExpressionList(bgee_expression_mouse, bgee_default_mm)
:attr('width', '15%')
local bgee_collapse_mm = bgee_expression_mouse[1]
:css('background-color', sideTitleBGcolor)
bgee_default_mm = bgee_expression_mouse[2]
:wikitext(label_locus)
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
:tag('td')
:done() --end tr
:attr('rowspan', '2')
:tag('tr')
:attr('width', '35%')
:css('background-color', rowBGcolor)
:tag('span')
:attr('class', 'plainlinks')
:wikitext(cytoband_mm)
:done() --end span
:done() --end td
:tag('th')
:tag('th')
:attr('scope', 'row')
:attr('scope', 'row')
:css('background-color', sideTitleBGcolor)
:css('background-color', sideTitleBGcolor)
:wikitext(label_gstart)
:wikitext(bgee_title)
:done() --end th
:done() --end th
:tag('td')
:tag('td')
:css('background-color', rowBGcolor)
:tag('table')
:tag('span')
:attr('class', 'none')
:attr('class', 'plainlinks')
:css('padding', '0')
:wikitext(p.separateWithComma(gstart_mm).." [[Base pair|bp]]"..source_link_gstart_mm) -- **lclz** Change it if it is inappropriate
:css('border', 'none')
:done() --end span
:css('margin', '0')
:done() --end td
:css('width', '100%')
:done() --end tr
:css('text-align', 'left')
:tag('tr')
:tag('tr')
:tag('th')
:tag('th')
:attr('scope', 'row')
:wikitext("'''"..MkIntLnk(RS.GL_Human_lnk).."'''")
:css('background-color', sideTitleBGcolor)
:done() --end th
:wikitext(label_gend)
:tag('th')
:done() --end th
:wikitext("'''"..MkIntLnk(RS.GL_Mouse_lnk).."''' "..RS.GL_ortholog)
:tag('td')
:done() --end th
:css('background-color', rowBGcolor)
:done() --end tr
:tag('span')
:tag('tr')
:attr('class', 'plainlinks')
:tag('td')
:wikitext(p.separateWithComma(gend_mm).." [[Base pair|bp]]"..source_link_gend_mm) -- **lclz** Change it if it is inappropriate
:tag('table')
:done() --end span
:attr('class', bgee_collapse)
:done() --end td
:css('padding', '0')
:done() --end tr
:css('border', 'none')
:done() --end table
:css('margin', '0')
:done() --end td
:css('width', '100%')
:done() --end tr
:css('text-align', 'center')
end
:tag('tr')
end
:tag('td')
 
:attr('colspan', '1')
--Get the render elements collapse option, collapsed anatomic entities (defaut text),
:tag('span')
--and anatomic entity list for the gene expression list rendering.
:attr('class', 'plainlinks')
function p.renderExpressionList(expressed_in_tissues, default_text)
:css('margin', '-3px')
--create list of expressed in anatomic entities
:wikitext(bgee_default)
if default_text == nil then default_text = "" end
:done() --end span
local anatomic_entity_labels = localNotApplicableStr
:done() --end td
local collapse = "none"
:done() --end tr
local split_values = mw.text.split(expressed_in_tissues, localSeparatorStr)
:tag('tr')
local anatomic_entity_list = {}
:tag('td')
local anatomic_entities = {}
:attr('colspan', '1')
local results
:tag('div')
for k,v in ipairs(split_values) do
:css('margin', '-12px 0px -10px 0px')
if string.match(v, '%w+') and v ~= localNotApplicableStr then
:attr('class', 'plainlinks')
anatomic_entity_list[#anatomic_entity_list+1] = "<li style='line-height: 137%;'>"..v.."</li>"
:tag('ul')
anatomic_entities[#anatomic_entities+1] = v
:css('line-height', '15%')
end
:css('margin', '9px')
end
:wikitext(bgee_tissues)
--if less than 11 don't create collapsible list
:done() --end ul
if table.getn(anatomic_entity_list) < 11 then
:done() --end div
if table.getn(anatomic_entity_list) == 0 then
:done() --end td
anatomic_entity_labels = localNotApplicableStr
:done() --end tr
default_text = ""
:done() --end table
end
:done() --end td
else
:tag('td')
collapse = "collapsible collapsed"
:tag('table')
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
:attr('class', bgee_collapse_mm)
end
:css('padding', '0')
if anatomic_entity_list[#anatomic_entity_list] then
:css('border', 'none')
anatomic_entity_labels = table.concat(anatomic_entity_list, "<br>")
:css('margin', '0')
end
:css('width', '100%')
results = {collapse, default_text, anatomic_entity_labels}
:css('text-align', 'center')
return results
:tag('tr')
end
:tag('td')
 
:attr('colspan', '1')
function p.renderRNAexpression(expression_images, entrez_gene,
:tag('span')
ensembl, bgee_expression, ensembl_mouse, bgee_expression_mouse)
:attr('class', 'plainlinks')
local bgee_gene_page = "https://www.bgee.org/gene/"
:css('margin', '-3px')
local title = "[[Gene expression|RNA expression]] pattern" --**lclz**
:wikitext(bgee_default_mm)
local biogps_link = ""
:done() --end span
local biogps_title = "BioGPS"
:done() --end td
biogps_title = "[http://biogps.org/ " .. biogps_title .. "]"
:done() --end tr
-- If no expression image exist in BioGPS, the N/A is displayed
:tag('tr')
if expression_images ~= "" then
:tag('td')
biogps_link = "[http://biogps.org/gene/"..entrez_gene.."/ More reference expression data]" --**lclz**
:attr('colspan', '1')
else
:tag('div')
expression_images = localNotApplicableStr
:css('margin', '-12px 0px -10px 0px')
end
:attr('class', 'plainlinks')
local ensembl_id = string.match(ensembl,"%a+%d+") or ""
:tag('ul')
local ensembl_id_mouse = string.match(ensembl_mouse,"%a+%d+") or ""
:css('line-height', '15%')
local bgee_title = "Bgee"
:css('margin', '9px')
bgee_title = "[https://www.bgee.org/ " .. bgee_title .. "]"
:wikitext(bgee_tissues_mm)
local bgee_default = "["..bgee_gene_page..ensembl_id.." Top expressed in]"
:done() --end ul
bgee_expression = p.renderExpressionList(bgee_expression, bgee_default)
:done() --end div
local bgee_collapse = bgee_expression[1]
:done() --end td
bgee_default = bgee_expression[2]
:done() --end tr
local bgee_tissues = bgee_expression[3]
:done() --end table
local bgee_default_mm = "["..bgee_gene_page..ensembl_id_mouse.." Top expressed in]"
:done() --end td
bgee_expression_mouse = p.renderExpressionList(bgee_expression_mouse, bgee_default_mm)
:done() --end tr
local bgee_collapse_mm = bgee_expression_mouse[1]
:tag('tr')
bgee_default_mm = bgee_expression_mouse[2]
:tag('td')
local bgee_tissues_mm = bgee_expression_mouse[3]
:attr('colspan', '4')
local bgee_more_link = ""
:css('text-align', 'center')
if bgee_tissues ~= localNotApplicableStr then
:css('background-color', rowBGcolor)
bgee_more_link = "["..bgee_gene_page..ensembl_id.." More reference expression data]"
:tag('span')
end
:attr('class', 'plainlinks')
 
:wikitext(bgee_more_link)
root
:done() --end span
:tag('tr')
:done() --end td
:tag('td')
:done() --end tr
:attr('colspan', 4)
:done() --end table
:css('text-align', 'center')
:done() --end td
: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 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(bgee_title)
:wikitext(biogps_title)
:done() --end th
:done() --end th
:tag('td')
:tag('td')
:tag('table')
:tag('table')
:attr('class', 'none')
: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('th')
:tag('td')
:wikitext("'''[[Human genome|Human]]'''")
:attr('colspan', '4')
:done() --end th
:css('text-align', 'center')
:tag('th')
:css('background-color', rowBGcolor)
:wikitext("'''[[Laboratory mouse|Mouse]] (ortholog)'''")  
:wikitext(expression_images)
:done() --end th
:done() --end td
:done() --end tr
:done() --end tr
:tag('tr')
:tag('tr')
:tag('td')
:tag('td')
:tag('table')
:attr('colspan', '4')
:attr('class', bgee_collapse)
:css('text-align', 'center')
:css('padding', '0')
:css('background-color', rowBGcolor)
:css('border', 'none')
:tag('span')
:css('margin', '0')
:attr('class', 'plainlinks')
:css('width', '100%')
:wikitext(biogps_link)
:css('text-align', 'center')
:done() --end span
:tag('tr')
:done() --end td
:tag('td')
:done() --end tr
:attr('colspan', '1')
:done() --end table
:tag('span')
:done() --end td
:attr('class', 'plainlinks')
:done() --end tr
:css('margin', '-3px')
:done() --end table
:wikitext(bgee_default)
:done() --end td
:done() --end span
:done() --end tr
:done() --end td
end
:done() --end tr
 
:tag('tr')
 
:tag('td')
function p.renderGeneOntology(mol_funct, cell_comp, bio_process, uniprotID)
:attr('colspan', '1')
local title = MkIntLnk (RS.GO_title_lnk)
:tag('div')
local mol_funct_title = RS.GO_mol_funct
:css('margin', '-12px 0px -10px 0px')
local cell_comp_title = RS.GO_cell_comp
:attr('class', 'plainlinks')
local bio_process_title = RS.GO_bio_process
:tag('ul')
local amigo_link = "[http://amigo.geneontology.org/" .. " Amigo]"
:css('line-height', '15%')
local quickGO_link = "[https://www.ebi.ac.uk/QuickGO/" .. " QuickGO]"
:css('margin', '9px')
root
:wikitext(bgee_tissues)
:tag('tr')
:done() --end ul
:tag('td')
:done() --end div
:attr('colspan', 4)
:done() --end td
:css('text-align', 'center')
:done() --end tr
:css('background-color', rowBGcolor)
:done() --end table
:tag('table')
:done() --end td
:attr('class', 'collapsible collapsed')
:tag('td')
:css('padding', '0')
:tag('table')
:css('border', 'none')
:attr('class', bgee_collapse_mm)
:css('margin', '0')
:css('padding', '0')
:css('width', '100%')
:css('border', 'none')
:css('text-align', 'left')
:css('margin', '0')
:tag('tr') --create title bar
:css('width', '100%')
:tag('th')
:css('text-align', 'center')
:attr('colspan', '4')
:tag('tr')
:css('text-align', 'center')
:tag('td')
:css('background-color', titleBGcolor)
:attr('colspan', '1')
:wikitext(title)
:tag('span')
:done() --end th
:attr('class', 'plainlinks')
:done() --end tr
:css('margin', '-3px')
:tag('tr')
:wikitext(bgee_default_mm)
:tag('td')
:done() --end span
:css('width', CFG.GO_bar_width) --CHANGED. New
:done() --end td
:css('background-color', sideTitleBGcolor)
:done() --end tr
:css('font-weight', 'bold')
:tag('tr')
:wikitext(mol_funct_title)
:tag('td')
:done() --end td
:attr('colspan', '1')
:tag('td')
:tag('div')
:css('background-color', rowBGcolor)
:css('margin', '-12px 0px -10px 0px')
:tag('div')
:attr('class', 'plainlinks')
:attr('class', 'plainlinks')
:tag('ul')
:wikitext(mol_funct)
:css('line-height', '15%')
:wikitext( '\n' ) -- newline before ending div tag, to ensure next section formats properly
:css('margin', '9px')
:done() --end div
:wikitext(bgee_tissues_mm)
:done() --end td
:done() --end ul
:done() --end tr
:done() --end div
:tag('tr')
:done() --end td
:tag('td')
:done() --end tr
:css('width', CFG.GO_bar_width) --CHANGED. New
:done() --end table
:css('background-color', sideTitleBGcolor)
:done() --end td
:css('font-weight', 'bold')
:done() --end tr
:wikitext(cell_comp_title)
:tag('tr')
:done() --end td
:tag('td')
:tag('td')
:attr('colspan', '4')
:css('background-color', rowBGcolor)
:css('text-align', 'center')
:tag('div')
:css('background-color', rowBGcolor)
:attr('class', 'plainlinks')
:tag('span')
:wikitext(cell_comp)
:attr('class', 'plainlinks')
:wikitext( '\n' ) -- newline before ending div tag, to ensure next section formats properly
:wikitext(bgee_more_link)
:done() --end div
:done() --end span
:done() --end td
:done() --end tr
:done() --end table
:done() --end td
:done() --end td
:done() --end tr
:done() --end tr
:tag('tr')
:tag('tr')
:tag('th')
:tag('td')
:attr('scope', 'row')
:css('width', GO_bar_width) --CHANGED. New
:css('background-color', sideTitleBGcolor)
:css('background-color', sideTitleBGcolor)
:wikitext(biogps_title)
:css('font-weight', 'bold')
:done() --end th
:wikitext(bio_process_title)
:done() --end td
:tag('td')
:tag('td')
:tag('table')
:css('background-color', rowBGcolor)
:attr('class', bgee_collapse)
:tag('div')
:css('padding', '0')
:attr('class', 'plainlinks')
:css('border', 'none')
:wikitext(bio_process)
:css('margin', '0')
:wikitext( '\n' ) -- newline before ending div tag, to ensure next section formats properly
:css('width', '100%')
:done() --end div
:css('text-align', 'left')
:done() --end td
:tag('tr')
:done() --end tr
:tag('td')
 
:attr('colspan', '4')
:tag('tr')
:css('text-align', 'center')
:tag('td')
:css('background-color', rowBGcolor)
:css('background-color', rowBGcolor)
:wikitext(expression_images)
:css('text-align', 'center')
:done() --end td
:attr('colspan', '4')
:done() --end tr
:wikitext(RS.SourcesTP)
:tag('tr')
:wikitext(amigo_link)
:tag('td')
:wikitext(" / ")
:attr('colspan', '4')
:wikitext(quickGO_link)
: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 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


function p.renderGeneOntology(mol_funct, cell_comp, bio_process, uniprotID)
local category_chromosome = MkIntLnk (RS.Orth_Categ..string.format (RS.Orth_C_ChNXY, chr)) -- *lclz*: Category name
local title = "[[Gene ontology]]" --**lclz**
if chr == "MT" then
local mol_funct_title = "Molecular function" --**lclz**
category_chromosome = MkIntLnk (RS.Orth_Categ..RS.Orth_C_Mit) -- *lclz*: Category name for mtDNA genes
local cell_comp_title = "Cellular component" --**lclz**
end
local bio_process_title = "Biological process" --**lclz**
if chr == "" then
local amigo_link = "[http://amigo.geneontology.org/" .. " Amigo]"
category_chromosome = MkIntLnk (RS.Orth_Categ..RS.Orth_HumanGens)  -- Per [[Wikipedia:Categories for discussion/Log/2023 August 15]]
local quickGO_link = "[https://www.ebi.ac.uk/QuickGO/" .. " QuickGO]"
end
 
if mw.title.getCurrentTitle().namespace ~= 0 then
root
category_chromosome = ""
:tag('tr')
end
:tag('td')
local entrezTitle = MkIntLnk (RS.Orth_Entrez_lnk)
:attr('colspan', 4)
entrez_gene = string.gsub(entrez_gene, "%s", "")
:css('text-align', 'center')
local entrez_link = CFG.NotApplicableStr
:css('background-color', rowBGcolor)
local entrez_collapse
:tag('table')
local entrez_default = ""
:attr('class', 'collapsible collapsed')
local split_entrez = mw.text.split(entrez_gene, CFG.SeparatorStr)
:css('padding', '0')
local entrez_link_list = {}
:css('border', 'none')
for k,v in ipairs(split_entrez) do
:css('margin', '0')
if string.match(v, '%w+') and v ~= CFG.NotApplicableStr then
:css('width', '100%')
entrez_link_list[#entrez_link_list+1] = "[https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&amp;cmd=retrieve&amp;dopt=default&amp;list_uids="..entrez_gene.."&amp;rn=1 "..entrez_gene.."]"
:css('text-align', 'left')
end
:tag('tr') --create title bar
end
:tag('th')
:attr('colspan', '4')
--if less than 5 don't create collapsible list
:css('text-align', 'center')
if CFG.OrthologsCollapsed or (table.getn(entrez_link_list) < 5) then -- CHANGED, added OrthologsCollapsed
:css('background-color', titleBGcolor)
entrez_collapse = "none"
:wikitext(title)
if entrez_default == nil and table.getn(entrez_link_list) == 0 then entrez_link = CFG.NotApplicableStr end
:done() --end th
else
:done() --end tr
entrez_collapse = "collapsible collapsed"
:tag('tr')
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
:tag('td')
end
:css('background-color', sideTitleBGcolor)
if entrez_link_list[#entrez_link_list] then
:css('font-weight', 'bold')
entrez_link = table.concat(entrez_link_list, "<br>")
:wikitext(mol_funct_title)
end
:done() --end td
:tag('td')
--create list for mouse Entrez id
:css('background-color', rowBGcolor)
entrez_gene_mm = string.gsub(entrez_gene_mm, "%s", "")
:tag('div')
local entrez_mm_link = CFG.NotApplicableStr
:attr('class', 'plainlinks')
local entrez_mm_collapse
:wikitext(mol_funct)
local entrez_mm_default = ""
:wikitext( '\n' ) -- newline before ending div tag, to ensure next section formats properly
local split_entrez_mm = mw.text.split(entrez_gene_mm, CFG.SeparatorStr)
:done() --end div
local entrez_mm_link_list = {}
:done() --end td
for k,v in ipairs(split_entrez_mm) do
:done() --end tr
if string.match(v, '%w+') and v ~= CFG.NotApplicableStr then
:tag('tr')
entrez_mm_link_list[#entrez_mm_link_list+1] = "[https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&amp;cmd=retrieve&amp;dopt=default&amp;list_uids="..v.."&amp;rn=1 "..v.."]"
:tag('td')
end
:css('background-color', sideTitleBGcolor)
end
:css('font-weight', 'bold')
--if less than 5 don't create collapsible list
:wikitext(cell_comp_title)
if CFG.OrthologsCollapsed or (table.getn(entrez_mm_link_list) < 5) then -- CHANGED, added OrthologsCollapsed
:done() --end td
entrez_mm_collapse = "none"
:tag('td')
if entrez_mm_default == nil and table.getn(entrez_mm_link_list) == 0 then entrez_mm_link = CFG.NotApplicableStr end
:css('background-color', rowBGcolor)
else
:tag('div')
entrez_mm_collapse = "collapsible collapsed"
:attr('class', 'plainlinks')
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
:wikitext(cell_comp)
end
:wikitext( '\n' ) -- newline before ending div tag, to ensure next section formats properly
if entrez_mm_link_list[#entrez_mm_link_list] then
:done() --end div
entrez_mm_link = table.concat(entrez_mm_link_list, "<br>")
:done() --end td
end
:done() --end tr
:tag('tr')
--create list of ensembl id
:tag('td')
local ensemblTitle = MkIntLnk (RS.Orth_Ensembl_lnk)
:css('background-color', sideTitleBGcolor)
ensembl = string.gsub(ensembl, "%s", "")
:css('font-weight', 'bold')
local ensembl_link = CFG.NotApplicableStr
:wikitext(bio_process_title)
local ensembl_collapse
:done() --end td
local ensembl_default = ""
:tag('td')
local split_ensembl = mw.text.split(ensembl, CFG.SeparatorStr)
:css('background-color', rowBGcolor)
local ensembl_link_list = {}
:tag('div')
for k,v in ipairs(split_ensembl) do
:attr('class', 'plainlinks')
if string.match(v, '%w+') and v ~= CFG.NotApplicableStr then
:wikitext(bio_process)
ensembl_link_list[#ensembl_link_list+1] = "[http://www.ensembl.org/Homo_sapiens/geneview?gene="..v..";db=core".." "..v.."]"
:wikitext( '\n' ) -- newline before ending div tag, to ensure next section formats properly
end
:done() --end div
end
:done() --end td
--if less than 5 don't create collapsible list
:done() --end tr
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


:tag('tr')
--create lists of uniprot ID
:tag('td')
local uniprotTitle = MkIntLnk (RS.Orth_UniProt_lnk)
:css('background-color', rowBGcolor)
local uniprot_url = "https://www.uniprot.org/uniprot/"
:css('text-align', 'center')
:attr('colspan', '4')
local uniprot_link = CFG.NotApplicableStr
:wikitext("Sources:") -- **lclz**
local uniprot_collapse
:wikitext(amigo_link)
local uniprot_default = ""
:wikitext(" / ")
--split string and loop through concatenate by <br>
:wikitext(quickGO_link)
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.
:done() --end td
local uniprot_link_list = {}
:done() --end tr
local uniprot_first = {} --preferred values only display [O,P,Q] prefixed entries if they exist
:done() --end table
local uniprot_alternate = {} --[A-N,R-Z] entries
:done() --end td
local hash = {} --storage to look for duplicated values
:done() --end tr
for k,v in ipairs(split_uniprot) do  
end
if not hash[v] then --only add if not found previously..some encodes uniprotID dup in different encodes
 
local label = mw.text.trim(v)
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 concat_uniprot_link = uniprot_url .. label
local title = "[[Orthologs]]" --**lclz**
if string.match(v, '%w+') and v ~= CFG.NotApplicableStr then
--to do make the list creation a function
if string.match(v, '^O') or string.match(v,'^P') or string.match(v, '^Q') then
--create list for entrez ids
    uniprot_first[#uniprot_first+1] = "[" .. concat_uniprot_link .. " " ..label .. "]"
 
else
local category_chromosome = '[[Category:Genes on human chromosome '..chr..']]'-- *lclz*: Category name
uniprot_alternate[#uniprot_alternate+1] = "[" .. concat_uniprot_link .. " " ..label .. "]"
if chr == "MT" then
end
category_chromosome = '[[Category:Human mitochondrial genes]]'-- *lclz*: Category name for mtDNA genes
end
hash[v] = true
end
end
end
if chr == "" then
    if table.getn(uniprot_first)>0 then --if there is something in the preferred values display else display anything else
category_chromosome = '[[Category:Human genes]]' -- Per [[Wikipedia:Categories for discussion/Log/2023 August 15]]
uniprot_link_list  = uniprot_first
else
uniprot_link_list  = uniprot_alternate
end
end
if mw.title.getCurrentTitle().namespace ~= 0 then
category_chromosome = ""
--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
local entrezTitle = "[[Entrez]]"
entrez_gene = string.gsub(entrez_gene, "%s", "")
    --mouse uniprot lists
local entrez_link = localNotApplicableStr
local uniprot_mm_link = CFG.NotApplicableStr
local entrez_collapse
local uniprot_mm_collapse
local entrez_default = ""
local uniprot_mm_default = ""
local split_entrez = mw.text.split(entrez_gene, localSeparatorStr)
--split string and loop through concatenate by <br>
local entrez_link_list = {}
local split_uniprot_mm = mw.text.split(uniprot_mm, CFG.SeparatorStr)
for k,v in ipairs(split_entrez) do
    local uniprot_mm_link_list = {}
if string.match(v, '%w+') and v ~= localNotApplicableStr then
    local uniprot_mm_first = {} --preferred values only display [O,P,Q] prefixed entries if they exist
entrez_link_list[#entrez_link_list+1] = "[https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&amp;cmd=retrieve&amp;dopt=default&amp;list_uids="..entrez_gene.."&amp;rn=1 "..entrez_gene.."]"
    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 less than 5 don't create collapsible list
if table.getn(uniprot_mm_first)>0 then --if there is something in the preferred values display else display anything else
if table.getn(entrez_link_list) < 5 then
uniprot_mm_link_list  = uniprot_mm_first
entrez_collapse = "none"
if entrez_default == nil and table.getn(entrez_link_list) == 0 then entrez_link = localNotApplicableStr end
else
else
entrez_collapse = "collapsible collapsed"
uniprot_mm_link_list  = uniprot_mm_alternate
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
end


--create list for mouse Entrez id
--if less than 5 don't create collapsible list
entrez_gene_mm = string.gsub(entrez_gene_mm, "%s", "")
if CFG.OrthologsCollapsed or (table.getn(uniprot_mm_link_list) < 5) then -- CHANGED, added OrthologsCollapsed
local entrez_mm_link = localNotApplicableStr
uniprot_mm_collapse = "none"
local entrez_mm_collapse
if uniprot_mm_default == nil and table.getn(uniprot_mm_link_list) == 0 then uniprot_mm_link = CFG.NotApplicableStr end
local entrez_mm_default = ""
else
local split_entrez_mm = mw.text.split(entrez_gene_mm, localSeparatorStr)
uniprot_mm_collapse = "collapsible collapsed"
local entrez_mm_link_list = {}
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(split_entrez_mm) do
end
if string.match(v, '%w+') and v ~= localNotApplicableStr then
entrez_mm_link_list[#entrez_mm_link_list+1] = "[https://www.ncbi.nlm.nih.gov/entrez/query.fcgi?db=gene&amp;cmd=retrieve&amp;dopt=default&amp;list_uids="..v.."&amp;rn=1 "..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(entrez_mm_link_list) < 5 then
if CFG.OrthologsCollapsed or (table.getn(link_list) < 6) then -- CHANGED, added OrthologsCollapsed
entrez_mm_collapse = "none"
refseq_mRNA_collapse = "none"
if entrez_mm_default == nil and table.getn(entrez_mm_link_list) == 0 then entrez_mm_link = localNotApplicableStr end
if refseq_mRNA_default == nil and table.getn(link_list) == 0 then refseq_mRNA_link = CFG.NotApplicableStr end
else
else
entrez_mm_collapse = "collapsible collapsed"
refseq_mRNA_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
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 entrez_mm_link_list[#entrez_mm_link_list] then
entrez_mm_link = table.concat(entrez_mm_link_list, "<br>")
if link_list[#link_list] then
refseq_mRNA_link = table.concat(link_list, "<br>")
end
end
 
--create list of ensembl id
--create list of links for refSeq mRNA for mouse
local ensemblTitle = "[[Ensembl]]"
local refseq_mRNA_mm_link = CFG.NotApplicableStr
ensembl = string.gsub(ensembl, "%s", "")
local refseq_mRNA_mm_collapse
local ensembl_link = localNotApplicableStr
local refseq_mRNA_mm_default = ""
local ensembl_collapse
local split_refseq_mRNA_mm = mw.text.split(refseq_mRNA_mm, CFG.SeparatorStr)
local ensembl_default = ""
local link_list_mm = {} --if NM,NP display if not display XM, XP values
local split_ensembl = mw.text.split(ensembl, localSeparatorStr)
local link_list_first = {} --hold those the have NM or NP values
local ensembl_link_list = {}
local link_list_alternate = {} --hold those that are XM or XP values
for k,v in ipairs(split_ensembl) do
 
if string.match(v, '%w+') and v ~= localNotApplicableStr then
for k,v in ipairs(split_refseq_mRNA_mm) do
ensembl_link_list[#ensembl_link_list+1] = "[http://www.ensembl.org/Homo_sapiens/geneview?gene="..v..";db=core".." "..v.."]"
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(ensembl_link_list) < 5 then
if CFG.OrthologsCollapsed or (table.getn(link_list_mm) < 6) then -- CHANGED, added OrthologsCollapsed
ensembl_collapse = "none"
refseq_mRNA_mm_collapse = "none"
if ensembl_default == nil and table.getn(ensembl_link_list) == 0 then ensembl_link = localNotApplicableStr end
if refseq_mRNA_mm_default == nil and table.getn(link_list_mm) == 0 then refseq_mRNA_mm_link = CFG.NotApplicableStr end
else
else
ensembl_collapse = "collapsible collapsed"
refseq_mRNA_mm_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
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 ensembl_link_list[#ensembl_link_list] then
 
ensembl_link = table.concat(ensembl_link_list, "<br>")
if link_list_mm[#link_list_mm] then
refseq_mRNA_mm_link = table.concat(link_list_mm, "<br>")
end
end
 
--create list of mouse ensembl id
-- *lclz*: sometimes
ensembl_mm = string.gsub(ensembl_mm, "%s", "")
local refseq_protTitle = "RefSeq "..RS.refseq_protein
local ensembl_mm_link = localNotApplicableStr
--create list of links for human refseq protein
local ensembl_mm_collapse
local refseq_prot_link = CFG.NotApplicableStr
local ensembl_mm_default = ""
local refseq_prot_collapse
local split_ensembl_mm = mw.text.split(ensembl_mm, localSeparatorStr)
local refseq_prot_default = ""
local ensembl_mm_link_list = {}
local split_refseq_prot = mw.text.split(refseq_prot, CFG.SeparatorStr)
for k,v in ipairs(split_ensembl_mm) do
local link_list_prot = {}
if string.match(v, '%w+') and v ~= localNotApplicableStr then
    local link_list_first = {} --hold those the have NM or NP values
ensembl_mm_link_list[#ensembl_mm_link_list+1] = "[http://www.ensembl.org/Mus_musculus/geneview?gene="..v..";db=core".." "..v.."]"
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 less than 5 don't create collapsible list
if table.getn(link_list_first)>0 then
if table.getn(ensembl_mm_link_list) < 5 then
link_list_prot  = link_list_first
ensembl_mm_collapse = "none"
if ensembl_mm_default == nil and table.getn(ensembl_mm_link_list) == 0 then ensembl_mm_link = localNotApplicableStr end
else
else
ensembl_mm_collapse = "collapsible collapsed"
link_list_prot  = link_list_alternate
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
end
if ensembl_mm_link_list[#ensembl_mm_link_list] then
--if less than 5 don't create collapsible list
ensembl_mm_link = table.concat(ensembl_mm_link_list, "<br>")
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
 
 
--create lists of uniprot ID
if link_list_prot[#link_list_prot] then
local uniprotTitle = "[[UniProt]]"
refseq_prot_link = table.concat(link_list_prot, "<br>")
local uniprot_url = "https://www.uniprot.org/uniprot/"
 
local uniprot_link = localNotApplicableStr
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
if string.match(v, '%w+') and v ~= localNotApplicableStr then
if string.match(v, '^O') or string.match(v,'^P') or string.match(v, '^Q') then
uniprot_first[#uniprot_first+1] = "[" .. concat_uniprot_link .. " " ..label .. "]"
else
uniprot_alternate[#uniprot_alternate+1] = "[" .. concat_uniprot_link .. " " ..label .. "]"
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
--create list of links for mouse refseq protein
else
local refseq_prot_mm_link = CFG.NotApplicableStr
uniprot_link_list = uniprot_alternate
local refseq_prot_mm_collapse
end
local refseq_prot_mm_default = ""
 
local split_refseq_prot_mm = mw.text.split(refseq_prot_mm, CFG.SeparatorStr)
--if less than 5 don't create collapsible list
local link_list_prot_mm = {}
if table.getn(uniprot_link_list) < 5 then
local link_list_first = {} --hold those the have NM or NP values
uniprot_collapse = "none"
local link_list_alternate = {} --hold those that are XM or XP values
if uniprot_default == nil and table.getn(uniprot_link_list) == 0 then uniprot_link = localNotApplicableStr end
 
else
for k,v in ipairs(split_refseq_prot_mm) do
uniprot_collapse = "collapsible collapsed"
local label = mw.text.trim(v)
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
local concat_ncbi_link = ncbi_link .. label
end
if string.match(v, '%w+') and v ~= CFG.NotApplicableStr then
 
if string.match(v, 'NM') or string.match(v, 'NP') then
if uniprot_link_list[#uniprot_link_list] then
    link_list_first[#link_list_first+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
uniprot_link = table.concat(uniprot_link_list, "<br>")
elseif string.match(v, 'XM') or string.match(v, 'XP') then
end
link_list_alternate[#link_list_alternate+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
 
--mouse uniprot lists
local uniprot_mm_link = localNotApplicableStr
local uniprot_mm_collapse
local uniprot_mm_default = ""
--split string and loop through concatenate by <br>
local split_uniprot_mm = mw.text.split(uniprot_mm, localSeparatorStr)
local uniprot_mm_link_list = {}
local uniprot_mm_first = {} --preferred values only display [O,P,Q] prefixed entries if they exist
local uniprot_mm_alternate = {} --[A-N,R-Z] entries
local hash = {} --storage to look for duplicated values
for k,v in ipairs(split_uniprot_mm) do
if not hash[v] then --only add if not found previously..some encodes uniprotID dup in different encodes
local label = mw.text.trim(v)
local concat_uniprot_link = uniprot_url .. label
if string.match(v, '%w+') and v ~= localNotApplicableStr then
if string.match(v, '^O') or string.match(v,'^P') or string.match(v, '^Q') then
uniprot_mm_first[#uniprot_mm_first+1] = "[" .. concat_uniprot_link .. " " ..label .. "]"
else
uniprot_mm_alternate[#uniprot_mm_alternate+1] = "[" .. concat_uniprot_link .. " " ..label .. "]"
end
end
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(link_list_first)>0 then
uniprot_mm_link_list = uniprot_mm_first
link_list_prot_mm  = link_list_first
else
else
uniprot_mm_link_list = uniprot_mm_alternate
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(uniprot_mm_link_list) < 5 then
if CFG.OrthologsCollapsed or (table.getn(link_list_prot_mm) < 6) then -- CHANGED, added OrthologsCollapsed
uniprot_mm_collapse = "none"
refseq_prot_mm_collapse  = "none"
if uniprot_mm_default == nil and table.getn(uniprot_mm_link_list) == 0 then uniprot_mm_link = localNotApplicableStr end
if refseq_prot_mm_default == nil and table.getn(link_list_prot_mm) == 0 then refseq_prot_mm_link = CFG.NotApplicableStr end
else
else
uniprot_mm_collapse = "collapsible collapsed"
refseq_prot_mm_collapse = "collapsible collapsed"
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
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 uniprot_mm_link_list[#uniprot_mm_link_list] then
refseq_prot_mm_link = table.concat(link_list_prot_mm, "<br>")
uniprot_mm_link = table.concat(uniprot_mm_link_list, "<br>")
end
end


local ncbi_link = "https://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?val="
local locTitle = string.format (RS.Orth_UCSC, MkIntLnk(RS.Orth_UCSC_lnk)) -- *lclz*
local refseq_mRNATitle = "RefSeq (mRNA)" -- *lclz*: sometimes
local gstart_mb = p.locToMb(gstart, 2)
 
local gend_mb = p.locToMb(gend, 2)
--create list of links for refSeq mRNA
local chr_loc_link = ""
local refseq_mRNA_link = localNotApplicableStr
if (string.match(db, '%w+') and string.match(chr, '%w+') and string.match(gstart, '%w+') and string.match(gend, '%w+') )then
local refseq_mRNA_collapse
local chr_ucsc
local refseq_mRNA_default = ""
if chr == "MT" then
--split string and loop through concatenate by <br>
chr_ucsc = "M" --UCSC uses "M" (not "MT") in URL for mitochondrial DNA
local split_refseq_mRNA = mw.text.split(refseq_mRNA, localSeparatorStr)
else
local link_list_first = {} --hold those the have NM or NP values
chr_ucsc = chr
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 ~= localNotApplicableStr then
if string.match(v, 'NM') or string.match(v, 'NP') then
link_list_first[#link_list_first+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
elseif string.match(v, 'XM') or string.match(v, 'XP') then
link_list_alternate[#link_list_alternate+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
end
end
end
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 table.getn(link_list_first)>0 then
local gstart_mm_mb = p.locToMb(gstart_mm, 2)
link_list = link_list_first
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
link_list = link_list_alternate
chr_loc_mm_link = CFG.NotApplicableStr
end
end
 
local pubmedTitle = string.format (RS.PubMed_Search, MkIntLnk(RS.PubMed_lnk)) -- *lclz*
--if less than 5 don't create collapsible list
local pubmed_link = entrez_gene
if table.getn(link_list) < 6 then
if string.match(entrez_gene, '%w+') and entrez_gene ~= CFG.NotApplicableStr then
refseq_mRNA_collapse = "none"
pubmed_link = frame:extensionTag("ref", MkExtLnk (frame, "Human PubMed Reference:" , -- CHANGED
if refseq_mRNA_default == nil and table.getn(link_list) == 0 then refseq_mRNA_link = localNotApplicableStr end
"https://www.ncbi.nlm.nih.gov/sites/entrez?db=gene&cmd=Link&LinkName=gene_pubmed&from_uid="..entrez_gene,  
else
"National Center for Biotechnology Information, U.S. National Library of Medicine") )--expandTemplate creates cite web template {{cite web|title=value|url=ref_link..ect}}
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
 
local pubmed_mm_link = entrez_gene_mm
if link_list[#link_list] then
if string.match(entrez_gene_mm, '%w+') and entrez_gene_mm ~= CFG.NotApplicableStr then
refseq_mRNA_link = table.concat(link_list, "<br>")
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
 
--create list of links for refSeq mRNA for mouse
local OrthologsClass = 'collapsible'
local refseq_mRNA_mm_link = localNotApplicableStr
if CFG.OrthologsCollapsed then  -- CHANGED, NEW
local refseq_mRNA_mm_collapse
OrthologsClass = 'collapsible collapsed' 
local refseq_mRNA_mm_default = ""
end
local split_refseq_mRNA_mm = mw.text.split(refseq_mRNA_mm, localSeparatorStr)
root
local link_list_mm = {} --if NM,NP display if not display XM, XP values
:tag('tr')
local link_list_first = {} --hold those the have NM or NP values
:tag('td')
local link_list_alternate = {} --hold those that are XM or XP values
:attr('colspan', 4)
 
:css('text-align', 'center')
for k,v in ipairs(split_refseq_mRNA_mm) do
:css('background-color', rowBGcolor)
local label = mw.text.trim(v)
:tag('table')
local concat_ncbi_link = ncbi_link .. label
:attr('class', OrthologsClass) -- CHANGED, NEW
if string.match(v, '%w+') and v ~= localNotApplicableStr then
:css('padding', '0')
if string.match(v, 'NM') or string.match(v, 'NP') then
:css('border', 'none')
link_list_first[#link_list_first+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
:css('margin', '0')
elseif string.match(v, 'XM') or string.match(v, 'XP') then
:css('width', '100%')
link_list_alternate[#link_list_alternate+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
:css('text-align', 'left')
end
:tag('tr')
end
:tag('th')
end
:attr('colspan', '4')
if table.getn(link_list_first)>0 then
:css('text-align', 'center')
link_list_mm = link_list_first
:css('background-color', titleBGcolor)
else
:wikitext(title)
link_list_mm = link_list_alternate
:done() --end th
end
:done() --end tr
--if less than 5 don't create collapsible list
:tag('tr')
if table.getn(link_list_mm) < 6 then
:tag('th')
refseq_mRNA_mm_collapse = "none"
:attr('scope', 'row')
if refseq_mRNA_mm_default == nil and table.getn(link_list_mm) == 0 then refseq_mRNA_mm_link = localNotApplicableStr end
:css('background-color', sideTitleBGcolor)
else
:wikitext(RS.SpeciesU)
refseq_mRNA_mm_collapse = "collapsible collapsed"
:done() --end th
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
:tag('td')
end
:wikitext("'''"..RS.HumanU.."'''")
 
:done() --end td
if link_list_mm[#link_list_mm] then
:tag('td')
refseq_mRNA_mm_link = table.concat(link_list_mm, "<br>")
:wikitext("'''"..RS.MouseU.."'''")
end
:done() --end td
 
:done() --end tr
-- *lclz*: sometimes
:tag('tr')
local refseq_protTitle = "RefSeq (protein)"
:tag('th')
--create list of links for human refseq protein
:attr('scope', 'row')
local refseq_prot_link = localNotApplicableStr
:css('background-color', sideTitleBGcolor)
local refseq_prot_collapse
:wikitext(entrezTitle)
local refseq_prot_default = ""
:done() --end th
local split_refseq_prot = mw.text.split(refseq_prot, localSeparatorStr)
:tag('td')
local link_list_prot = {}
:tag('table')
local link_list_first = {} --hold those the have NM or NP values
:attr('class', entrez_collapse)
local link_list_alternate = {} --hold those that are XM or XP values
:css('padding', '0')
for k,v in ipairs(split_refseq_prot) do
:css('border', 'none')
local label = mw.text.trim(v)
:css('margin', '0')
local concat_ncbi_link = ncbi_link .. label
:css('width', '100%')
if string.match(v, '%w+') and v ~= localNotApplicableStr then
:css('text-align', 'right')
if string.match(v, 'NM') or string.match(v, 'NP') then
:tag('tr')
link_list_first[#link_list_first+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
:tag('th')
elseif string.match(v, 'XM') or string.match(v, 'XP') then
:attr('colspan', '1')
link_list_alternate[#link_list_alternate+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
:tag('span')
end
:attr('class', 'plainlinks')
end
:wikitext(entrez_default)
end
:done() --end span
if table.getn(link_list_first)>0 then
:done() --end th
link_list_prot = link_list_first
:done() --end tr
else
:tag('tr')
link_list_prot = link_list_alternate
:tag('td')
end
:attr('colspan', '1')
--if less than 5 don't create collapsible list
:tag('p')
if table.getn(link_list_prot) < 6 then
:attr('class', 'plainlinks')
refseq_prot_collapse = "none"
:wikitext(entrez_link)
if refseq_prot_default == nil and table.getn(link_list_prot) == 0 then refseq_prot_link = localNotApplicableStr end
:done() --end p
else
:done() --end td
refseq_prot_collapse = "collapsible collapsed"
:done() --end tr
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
:done() --end table
end
:done() --end td
 
:tag('td')
if link_list_prot[#link_list_prot] then
:tag('table')
refseq_prot_link = table.concat(link_list_prot, "<br>")
:attr('class', entrez_mm_collapse)
end
:css('padding', '0')
 
:css('border', 'none')
--create list of links for mouse refseq protein
:css('margin', '0')
local refseq_prot_mm_link = localNotApplicableStr
:css('width', '100%')
local refseq_prot_mm_collapse
:css('text-align', 'right')
local refseq_prot_mm_default = ""
:tag('tr')
local split_refseq_prot_mm = mw.text.split(refseq_prot_mm, localSeparatorStr)
:tag('th')
local link_list_prot_mm = {}
:attr('colspan', '1')
local link_list_first = {} --hold those the have NM or NP values
:tag('span')
local link_list_alternate = {} --hold those that are XM or XP values
:attr('class', 'plainlinks')
 
:wikitext(entrez_mm_default)
for k,v in ipairs(split_refseq_prot_mm) do
:done() --end span
local label = mw.text.trim(v)
:done() --end th
local concat_ncbi_link = ncbi_link .. label
:done() --end tr
if string.match(v, '%w+') and v ~= localNotApplicableStr then
:tag('tr')
if string.match(v, 'NM') or string.match(v, 'NP') then
:tag('td')
link_list_first[#link_list_first+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
:attr('colspan', '1')
elseif string.match(v, 'XM') or string.match(v, 'XP') then
:tag('p')
link_list_alternate[#link_list_alternate+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
:attr('class', 'plainlinks')
end
:wikitext(entrez_mm_link)
end
:done() --end p
end
:done() --end td
if table.getn(link_list_first)>0 then
:done() --end tr
link_list_prot_mm = link_list_first
:done() --end table
else
:done() --end td
link_list_prot_mm = link_list_alternate
:done() --end tr
end
:tag('tr')
--if less than 5 don't create collapsible list
:tag('th')
if table.getn(link_list_prot_mm) < 6 then
:attr('scope', 'row')
refseq_prot_mm_collapse = "none"
:css('background-color', sideTitleBGcolor)
if refseq_prot_mm_default == nil and table.getn(link_list_prot_mm) == 0 then refseq_prot_mm_link = localNotApplicableStr end
:wikitext(ensemblTitle)
else
:done() --end th
refseq_prot_mm_collapse = "collapsible collapsed"
:tag('td')
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
:tag('table')
end
:attr('class', ensembl_collapse)
if link_list_prot_mm[#link_list_prot_mm] then
:css('padding', '0')
refseq_prot_mm_link = table.concat(link_list_prot_mm, "<br>")
:css('border', 'none')
end
:css('margin', '0')
 
:css('width', '100%')
local locTitle = "Location (UCSC)" -- *lclz*
:css('text-align', 'right')
local gstart_mb = p.locToMb(gstart, 2)
:tag('tr')
local gend_mb = p.locToMb(gend, 2)
:tag('th')
local chr_loc_link = ""
:attr('colspan', '1')
if (string.match(db, '%w+') and string.match(chr, '%w+') and string.match(gstart, '%w+') and string.match(gend, '%w+') )then
:tag('span')
local chr_ucsc
:attr('class', 'plainlinks')
if chr == "MT" then
:wikitext(ensembl_default)
chr_ucsc = "M" --UCSC uses "M" (not "MT") in URL for mitochondrial DNA
:done() --end span
else
:done() --end th
chr_ucsc = chr
:done() --end tr
end
:tag('tr')
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]"
:tag('td')
else
:attr('colspan', '1')
chr_loc_link = localNotApplicableStr
:tag('p')
end
:attr('class', 'plainlinks')
local gstart_mm_mb = p.locToMb(gstart_mm, 2)
:wikitext(ensembl_link)
local gend_mm_mb = p.locToMb(gend_mm, 2)
:done() --end p
local chr_loc_mm_link = ""
:done() --end td
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
:done() --end tr
local chr_mm_ucsc
:done() --end table
if chr_mm == "MT" then
:done() --end td
chr_mm_ucsc = "M" --UCSC uses "M" (not "MT") in URL for mitochondrial DNA
:tag('td')
else
:tag('table')
chr_mm_ucsc = chr_mm
:attr('class', ensembl_mm_collapse)
end
:css('padding', '0')
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]"
:css('border', 'none')
else
:css('margin', '0')
chr_loc_mm_link = localNotApplicableStr
:css('width', '100%')
end
:css('text-align', 'right')
 
:tag('tr')
local pubmedTitle = "[[PubMed]] search" -- *lclz*
:tag('th')
local pubmed_link = entrez_gene
:attr('colspan', '1')
if string.match(entrez_gene, '%w+') and entrez_gene ~= localNotApplicableStr then
:tag('span')
pubmed_link = frame:extensionTag("ref",frame:expandTemplate{ title = 'cite_web', args = { title ="Human PubMed Reference:" , url = "https://www.ncbi.nlm.nih.gov/sites/entrez?db=gene&cmd=Link&LinkName=gene_pubmed&from_uid="..entrez_gene, website = "National Center for Biotechnology Information, U.S. National Library of Medicine" } } )--expandTemplate creates cite web template {{cite web|title=value|url=ref_link..ect}}
:attr('class', 'plainlinks')
end
:wikitext(ensembl_mm_default)
local pubmed_mm_link = entrez_gene_mm
:done() --end span
if string.match(entrez_gene_mm, '%w+') and entrez_gene_mm ~= localNotApplicableStr then
:done() --end th
pubmed_mm_link = frame:extensionTag("ref",frame:expandTemplate{ title = 'cite_web', args = { title ="Mouse PubMed Reference:" , url ="https://www.ncbi.nlm.nih.gov/sites/entrez?db=gene&cmd=Link&LinkName=gene_pubmed&from_uid="..entrez_gene_mm, website = "National Center for Biotechnology Information, U.S. National Library of Medicine" } } )--expandTemplate creates cite web template {{cite web|title=value|url=ref_link..ect}}
:done() --end tr
end
:tag('tr')
 
:tag('td')
root
:attr('colspan', '1')
:tag('tr')
:tag('p')
:tag('td')
:attr('class', 'plainlinks')
:attr('colspan', 4)
:wikitext(ensembl_mm_link)
:css('text-align', 'center')
:done() --end p
:css('background-color', rowBGcolor)
:done() --end td
:tag('table')
:done() --end tr
:attr('class', 'collapsible')
:done() --end table
: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("Species") --**lclz**
:done() --end th
:tag('td')
:wikitext("'''Human'''") --**lclz**
:done() --end td
:tag('td')
:wikitext("'''Mouse'''") --**lclz**
: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(entrezTitle)
:wikitext(uniprotTitle)
:done() --end th
:done() --end th
:tag('td')
:tag('td')
:tag('table')
:tag('table')
:attr('class', entrez_collapse)
: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(entrez_default)
: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(entrez_link)
: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', entrez_mm_collapse)
: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(entrez_mm_default)
:wikitext(uniprot_mm_default)
:done() --end span
:done() --end span
:done() --end th
:done() --end th
:done() --end tr
: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(entrez_mm_link)
: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(ensemblTitle)
:wikitext(refseq_mRNATitle)
:done() --end th
:done() --end th
:tag('td')
:tag('td') --RNASeq mRNA collapsible table
:tag('table')
:tag('table')
:attr('class', ensembl_collapse)
: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')
:tag('span')
:attr('class', 'plainlinks')
:attr('class', 'plainlinks')
:wikitext(refseq_mRNA_default)
:wikitext(ensembl_default)
:done() --end span
: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')
:wikitext(ensembl_link)
: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', ensembl_mm_collapse)
: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')
:tag('span')
:attr('class', 'plainlinks')
:attr('class', 'plainlinks')
:wikitext(refseq_mRNA_mm_default)
:wikitext(ensembl_mm_default)
:done() --end span
: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')
:wikitext(ensembl_mm_link)
: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(uniprotTitle)
:wikitext(refseq_protTitle)
:done() --end th
:done() --end th
:tag('td')
:tag('td') --RNASeq protein collapsible table
:tag('table')
:tag('table')
:attr('class', uniprot_collapse)
: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')
:tag('span')
:attr('class', 'plainlinks')
:attr('class', 'plainlinks')
:wikitext(refseq_prot_default)
:wikitext(uniprot_default)
:done() --end span
: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')
:wikitext(uniprot_link)
: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', uniprot_mm_collapse)
: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')
:tag('span')
:attr('class', 'plainlinks')
:attr('class', 'plainlinks')
:wikitext(refseq_prot_mm_default)
:wikitext(uniprot_mm_default)
:done() --end span
:done() --end th
:done() --end th
:done() --end th
: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')
:wikitext(uniprot_mm_link)
: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(refseq_mRNATitle)
:wikitext(locTitle)
:done() --end th
:done() --end th
:tag('td') --RNASeq mRNA collapsible table
:tag('td')
:tag('table')
:tag('span')
:attr('class', refseq_mRNA_collapse)
:attr('class', 'plainlinks')
:css('padding', '0')
:wikitext(chr_loc_link)
:css('border', 'none')
:done() --end span
:css('margin', '0')
:done() --end td
:css('width', '100%')
:tag('td')
:css('text-align', 'right')
:tag('span')
:tag('tr')
:attr('class', 'plainlinks')
:tag('th')
:wikitext(chr_loc_mm_link)
:attr('colspan', '1')
:done() --end span
:attr('class', 'plainlinks')
:wikitext(refseq_mRNA_default)
:done() --end th
:done() --end tr
:tag('tr')
:tag('td')
:attr('colspan', '1')
:tag('p')
:tag('span')
:attr('class', 'plainlinks')
:wikitext(refseq_mRNA_link)
:done() --end span
:done() --end p
:done() --end td
:done() --end tr
:done() --end table
:done() --end td
:done() --end td
:tag('td') --RNASeq mRNA collapsible table for mouse
:done() --end tr
:tag('table')
:tag('tr')
:attr('class', refseq_mRNA_mm_collapse)
:tag('th')
:css('padding', '0')
:attr('scope', 'row')
:css('border', 'none')
:css('margin', '0')
:css('width', '100%')
:css('text-align', 'right')
:tag('tr')
:tag('th')
:attr('colspan', '1')
:attr('class', 'plainlinks')
:wikitext(refseq_mRNA_mm_default)
:done() --end th
:done() --end tr
:tag('tr')
:tag('td')
:attr('colspan', '1')
:tag('p')
:tag('span')
:attr('class', 'plainlinks')
:wikitext(refseq_mRNA_mm_link)
:done() --end span
:done() --end p
:done() --end td
:done() --end tr
:done() --end table
:done() --end td
:done() --end tr
:tag('tr')
:tag('th')
:attr('scope', 'row')
:css('background-color', sideTitleBGcolor)
:css('background-color', sideTitleBGcolor)
:wikitext(refseq_protTitle)
:wikitext(pubmedTitle)
:done() --end th
:done() --end th
:tag('td') --RNASeq protein collapsible table
:tag('td')
:tag('table')
:tag('span')
:attr('class', refseq_prot_collapse)
:attr('class', 'plainlinks')
:css('padding', '0')
:wikitext(pubmed_link)
:css('border', 'none')
:done() --end span
:css('margin', '0')
:css('width', '100%')
:css('text-align', 'right')
:tag('tr')
:tag('th')
:attr('colspan', '1')
:attr('class', 'plainlinks')
:wikitext(refseq_prot_default)
:done() --end th
:done() --end tr
:tag('tr')
:tag('td')
:attr('colspan', '1')
:tag('p')
:tag('span')
:attr('class', 'plainlinks')
:wikitext(refseq_prot_link)
:done() --end span
:done() --end p
:done() --end td
:done() --end tr
:done() --end table
:done() --end td
:done() --end td
:tag('td') --RNASeq protein collapsible table for mouse
:tag('td')
:tag('table')
:tag('span')
:attr('class', refseq_prot_mm_collapse)
:attr('class', 'plainlinks')
:css('padding', '0')
:wikitext(pubmed_mm_link)
:css('border', 'none')
:done() --end span
:css('margin', '0')
:wikitext(category_chromosome)
:css('width', '100%')
:css('text-align', 'right')
:tag('tr')
:tag('th')
:attr('colspan', '1')
:attr('class', 'plainlinks')
:wikitext(refseq_prot_mm_default)
:done() --end th
:done() --end tr
:tag('tr')
:tag('td')
:attr('colspan', '1')
:tag('p')
:tag('span')
:attr('class', 'plainlinks')
:wikitext(refseq_prot_mm_link)
:done() --end span
:done() --end p
:done() --end td
:done() --end tr
:done() --end table
:done() --end td
:done() --end td
:done() --end tr
:done() --end tr
:tag('tr')
:done() --end table
:tag('th')
:done() --end td
:attr('scope', 'row')
:done() --end tr
:css('background-color', sideTitleBGcolor)
end
:wikitext(locTitle)
 
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
:tag('td')
:done() --end tr
:tag('span')
:done() --end table
:attr('class', 'plainlinks')
:done() --end td
:wikitext(chr_loc_link)
:done() --end tr
:done() --end span
:done() --end td
:tag('td')
:tag('span')
:attr('class', 'plainlinks')
:wikitext(chr_loc_mm_link)
:done() --end span
:done() --end td
:done() --end tr
:tag('tr')
:tag('th')
:attr('scope', 'row')
:css('background-color', sideTitleBGcolor)
:wikitext(pubmedTitle)
:done() --end th
:tag('td')
:tag('span')
:attr('class', 'plainlinks')
:wikitext(pubmed_link)
:done() --end span
:done() --end td
:tag('td')
:tag('span')
:attr('class', 'plainlinks')
:wikitext(pubmed_mm_link)
:done() --end span
:wikitext(category_chromosome)
:done() --end td
:done() --end tr
:done() --end table
:done() --end td
:done() --end tr
end
end


function p.formatRow(title)
function p.renderFooter(Qid, Qid_mm)
root
local text = MkIntLnk (RS.Wikidata_lnk)  --*lclz*
:tag('tr')
local hs_link = MkIntLnk ("d:"..Qid.."|"..RS.SeeEditHuman) --*lclz*
: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 tr
:done() --end table
:done() --end td
:done() --end tr
end
 
function p.renderFooter(Qid, Qid_mm)
local text = "[[Wikidata]]" --**lclz**
local hs_link = "[[d:"..Qid.."|View/Edit Human]]" --**lclz**
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_mm = 0
link_no_hs = 4
link_no_hs = 4
else
else  
link_no_mm = 2
link_no_mm = 2
link_no_hs = 2
link_no_hs = 2
mm_link = "[[d:"..Qid_mm.."|View/Edit Mouse]]" --**lclz**
mm_link = MkIntLnk ("d:"..Qid_mm.."|"..RS.SeeEditMouse) --*lclz*
end
end
 
root
root
:tag('tr')
:tag('tr')
:tag('td')
:tag('td')
Line 2,291: Line 2,290:
end
end


--this code isn't used was hoping could do some generalization of rows
-- look into entity object
function p.rowLabel(label)
root
:tag('tr')
:tag('th')
:attr('rowspan', '2')
:css('background-color', sideTitleBGcolor)
:css('width', '43px')
:wikitext(label)
--:done()
end
 
-- look into entity object
function p.getLabel(entity)
function p.getLabel(entity)
local data = entity
local data = entity


local f = {'labels','en','value'} --**lclz**
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)


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
    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, localSeparatorStr)
--[[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
  if string.match( trim_id, '^NM_%d+') then  
preferred_result = trim_id --overwrite each time found only need one to display
  preferred_result = trim_id --overwrite each time found only need one to display
end
  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 = localSeparatorStr
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


local claims
function p.getPDB(protein_entities)
 
local pdb_propertyID = "P638"
if entity and entity.claims then
local overall_results = {}
claims = entity.claims[propertyID]
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
end
local claims
 
local entity = val
if claims then
if entity and entity.claims then
if (claims[1] and claims[1].mainsnak.datatype == "commonsMedia") then
claims = entity.claims[pdb_propertyID]
local out = {}
for k, v in pairs(claims) do
local filename = v.mainsnak.datavalue.value
out[#out + 1] = "[[File:" .. filename .. "|" .. imgsize .. "]]"
end
return table.concat(out, sep)
else
return ""
end
else
return ""
end
end
 
function p.getPDB(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]
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 = ''
--"mitochondrion" and "chromosome MT" is used for mitochondrial DNA.
--See [[d:Special:WhatLinksHere/Q18694495]]
--See [[d:Special:WhatLinksHere/Q18694495]]
if string.find(string_to_trim, 'chromosome MT') or string.find(string_to_trim, 'mitochondri') then --match both 'mitochondrio'/'mitochondrial'
if GetParam (RS.WD_chromosomeMT) then
out = "MT"
out = "MT"
elseif string.find(string_to_trim, 'chromosome') then --**lclz** Add your local label, otherwise it may break
elseif GetParam (RS.WD_chromosome) then  
out = string.match(string_to_trim, "%d+")--extract number from string
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, "X") or string.match(string_to_trim, "Y")
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)
  num = tonumber(num)
if num == nil then
  if num == nil then  
return ""
  return ""
else
  else
local mb = num/1000000
  local mb = num/1000000
local mult = 10^(idp or 0)
  local mult = 10^(idp or 0)
return math.floor(mb * mult + 0.5) / mult
  return math.floor(mb * mult + 0.5) / mult
end
  end
end
end


function p.isempty(s)
function p.isempty(s)
return s == nil or 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 label = mw.wikibase.getLabel("Q" .. v.mainsnak.datavalue.value["numeric-id"])
local identH = "Q" .. v.mainsnak.datavalue.value["numeric-id"]
if label == nil then label = "Q" .. v.mainsnak.datavalue.value["numeric-id"] end
--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 = '&thinsp;[[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
  if (not hash[v]) then
res[#res+1] = v
      res[#res+1] = v  
hash[v] = true
      hash[v] = true
end
  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.."]]"
out[#out + 1] = "[["..linkTarget.."|"..datav.."]]"
--else
else
-- out[#out + 1] = "[[:d:" .. id .. "|" .. datav .. "]]"
out[#out + 1] = "[[:d:" .. id .. "|" .. datav .. "]]"
end
datasource[#out] = refLink
--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
  return return_val
end
end


function p.getDrug(protein_entities, propertyID)
function p.getDrug(protein_entities, propertyID)
local out = {}
    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
refLink = ref
    --end
end
--if linkTarget then
if linkTarget then
    --out[#out + 1] = "[["..linkTarget.."|"..datav.."]]"
out[#out + 1] = "[["..linkTarget.."|"..datav.."]]"
    --else
else
    --out[#out + 1] = "[[:d:" .. id .. "|" .. datav .. "]]"
out[#out + 1] = "[[:d:" .. id .. "|" .. datav .. "]]"
    --end
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
    pqid[#out] = protein_id
datasource[#out] = refLink
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
    end -- end protein_entities loop
return out, datasource, pqid, pname
return out, datasource, pqid, pname
end
end


function p.separateWithComma(bp)
function p.FormatNaturalNumber(bp) -- CHANGED function name
--Separate number with comma. For example when this function gets "12345678", returns "12,345,678"
--Separate number with comma. For example when this function gets "12345678", returns "12.345.678"
local commaSeparated = bp
local FormatedNumber = bp
while true do
while true do
local k
local k
commaSeparated, k = string.gsub(commaSeparated, "^(-?%d+)(%d%d%d)", '%1,%2')
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 commaSeparated
return FormatedNumber
end
end


return p
return p