Module:Infobox gene: Difference between revisions

Content deleted Content added
replace symbol_url per TPER
implement changes from sandbox per edit request - feel free to revert if problems arise
Line 4:
local infobox = require('Module:Infobox3cols').infobox
local infoboxImage = require('Module:InfoboxImage').InfoboxImage
local localSeparatorStr = "," -- **lclz** Correct it if your wiki has different setting, like zhwiki uses "、" for now
local localNotApplicableStr = "n/a" -- **lclz**
 
-- wrapped "protected call", return "value error" with error info on error
Line 18 ⟶ 20:
--texts relevant to localization are tagged with --**lclz** and/or *lclz*
--on a page {{#invoke:Sandbox/genewiki/alllua|getTemplateData|QID=Q14865053}}
--in debug window
--frame = mw.getCurrentFrame()
--frame.args = {QID="Q14865053"} Q18031325
Line 30 ⟶ 32:
local mm_qid = ""
--pull all the entity objects that we will need
local entity = {}
local entity_protein = {}
local entity_mouse = {}
local entity_mouse_protein = {}
local checkOrtholog = "" --flag used to see if mouse data avaliable
 
local mouse_propertyID = "P684" --actually ortholog property additional orthologs can exist
local protein_propertyID = "P688"
 
--get root gene entity
Line 43 ⟶ 45:
entity = mw.wikibase.getEntityObject()
if entity then root_qid = entity.id else root_qid = "" end
 
else
--assuming we think its good make one call to retrieve and store its wikidata representation
entity = mw.wikibase.getEntity(root_qid)
end
 
--need to figure out if it is protein or gene here
local subclass = p.getValue(entity, "P31") or ""
if string.find(subclass, 'protein') then --if protein switch entity to gene **lclz**
if entity.claims then
claims = entity.claims["P702"] --encoded by
Line 64 ⟶ 66:
root_qid = itemID
end
 
end --will return nothing if no claims are found
end
entity = mw.wikibase.getEntity(root_qid)
end
 
 
--get the other related entities
if entity then
Line 85 ⟶ 87:
entity_protein[#entity_protein + 1] = mw.wikibase.getEntity(protein_itemID)
end
 
end --will return nothing if no claims are found
end
 
--get mouse entity object
if entity.claims then
Line 103 ⟶ 105:
 
local mouse_itemID = "Q" .. v.mainsnak.datavalue.value["numeric-id"]
local quals
if v.qualifiers then
quals = v.qualifiers.P703
Line 112 ⟶ 114:
local qual_obj_id = "Q"..qv.datavalue.value["numeric-id"]
if qual_obj_id == mouse_qual then --check if this is mouse or other
mm_qid = mouse_itemID
entity_mouse = mw.wikibase.getEntity(mouse_itemID)
checkOrtholog = 1
Line 124 ⟶ 126:
checkOrtholog = 0
end
 
--get mouse protein entity object
if entity_mouse and entity_mouse.claims then
Line 136 ⟶ 138:
end
end --will return nothing if no claims are found
end
 
end
 
 
if entity then --only require the main gene entity
--a list variables of all the data in the info box
local name = check_values(p.getLabel,{entity})
local entrez_gene = check_values(p.getValue, {entity, "P351", "n/a"localNotApplicableStr} )
local entrez_gene_mm = check_values(p.getValue, {entity_mouse, "P351", "n/a"localNotApplicableStr})
local image = check_values( p.getImage, {entity, "P18", " ", "250px"}) --need to set size
local uniprotID_hs = check_values(p.getValueProtein, {entity_protein, "P352", "n/a"localNotApplicableStr})
local uniprotID_mm = check_values(p.getValueProtein, {entity_mouse_protein, "P352", "n/a"localNotApplicableStr})
local pdbIDs = check_values(p.getPDB, {entity_protein}) --makes a list with links to RCSB
local aliases = check_values(p.getAliases, {entity})
Line 156 ⟶ 158:
local omim_id = check_values(p.getValue, {entity, "P492"})
local mgi_id = check_values(p.getValue, {entity_mouse, "P671"})
local ChEMBL_id = check_values(p.getValue, {entity_protein, "P592"})
local IUPHAR_id = check_values(p.getValue, {entity_protein, "P595"})
local ec_no = check_values(p.getValueProtein, {entity_protein, "P591"})
local mol_funct = check_values(p.getGO, {entity_protein, "P680"})
local cell_comp = check_values(p.getGO, {entity_protein, "P681"})
local bio_process = check_values(p.getGO, {entity_protein, "P682"})
local expression_images = check_values(p.getImage, {entity,"P692","<br><br>","250px"})
local ensembl = check_values(p.getValue, {entity, "P594", "n/a"localNotApplicableStr})
local ensembl_mm = check_values(p.getValue, {entity_mouse, "P594", "n/a"localNotApplicableStr})
local refseq_mRNA = check_values(p.getRefseq_mRNA, {entity, "P639", "n/a"localNotApplicableStr})
local refseq_mRNA_mm = check_values(p.getRefseq_mRNA, {entity_mouse, "P639", "n/a"localNotApplicableStr})
local refseq_prot = check_values(p.getRefseq_protein, {entity_protein, "P637", "n/a"localNotApplicableStr})
local refseq_prot_mm = check_values(p.getRefseq_protein, {entity_mouse_protein, "P637", "n/a"localNotApplicableStr})
local gstart = check_values(p.getChromosomeLoc, {entity, "P644", "hg"})
local gend = check_values(p.getChromosomeLoc, {entity, "P645", "hg"})
local chr = check_values(p.trimChromosome, {entity})
local cytoband = check_values(p.getValue, {entity, "P4196", "n/a"localNotApplicableStr})
local db = check_values(p.getAliasFromGenomeAssembly, {entity,"hg"})
local gstart_mm = check_values(p.getChromosomeLoc, {entity_mouse, "P644", "mm"})
local gend_mm = check_values(p.getChromosomeLoc, {entity_mouse, "P645", "mm"})
local chr_mm = check_values( p.trimChromosome, {entity_mouse})
local db_mm = check_values(p.getAliasFromGenomeAssembly, {entity_mouse,"mm"})
local cytoband_mm = check_values(p.getValue, {entity_mouse, "P4196", "n/a"localNotApplicableStr})
local disease, dis_ref = ''
if p.getDisease(entity, "P2293") then disease, dis_ref = p.getDisease(entity, "P2293") else disease, dis_ref = {"'''VALUE_ERROR'''","'''VALUE_ERROR'''" } end
if p.getDrug(entity_protein, "P129") then drug, drug_ref, drug_pqid, drug_pname = p.getDrug(entity_protein, "P129") else drug, drug_ref, drug_pqid, drug_pname = {"'''VALUE_ERROR'''","'''VALUE_ERROR'''" } end
--local drug = check_values(p.getDrug, {entity_protein, "P129"})
 
--define Global Color Scheme
rowBGcolor = '#eee'
Line 199 ⟶ 201:
-- p.renderDiseases(frame, disease, dis_ref, name, root_qid)
--end
 
--uncomment here to add a section of the infobox about drugs that target the protein product of this gene, with references
--if (drug ~= "" ) then --removes section from those items without drug info
-- p.renderDrug(frame,drug, drug_ref, drug_pqid, drug_pname)
--end
 
if (chr ~= "" and gstart ~= "" and gend ~= "") or (chr_mm ~= "" and gstart_mm ~= "" and gend_mm ~= "") then
p.renderGeneLocation(frame, chr, gstart, gend, db, cytoband, ensembl, chr_mm, gstart_mm, gend_mm, db_mm, cytoband_mm, ensembl_mm, name)
Line 215 ⟶ 217:
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.renderFooter(root_qid, mm_qid)
 
return tostring(root)
--return table.concat(drug_pqid)
 
else return "An Error has occurred retrieving Wikidata item for infobox"
end
end
 
p.createTable = function(subbox)
 
if subbox == 'sub' then --doesn't work
root
:tag('table')
:css('padding', '0')
:css('border', 'none')
Line 238 ⟶ 240:
:css('float', 'none')
:css('background-color', 'transparent')
 
else
root = mw.html.create('table')
root
-- *lclz*: Some projects, like zhwiki (again), use inline styles on
-- infobox modules in addition to the class. Be sure to check them out.
:addClass('infobox')
Line 254 ⟶ 256:
local title = name
if not title then return "error: failed to get label"; end
 
root
:tag('tr')
Line 267 ⟶ 269:
end
 
--This is a place holder for the image caption, which is stored in wikicommons comments unsure how to access
p.renderCaption = function(entity)
--caption
Line 283 ⟶ 285:
:done() --end td
:done() --end tr
 
end
 
Line 292 ⟶ 294:
local title = 'Available structures' --**lclz**
local pdb_link = "[[Protein_Data_Bank|PDB]]" --**lclz**
local searchTitle = ""
local listTitle = "List of PDB id codes" --**lclz**
local PDBe_base = 'https://www.ebi.ac.uk/pdbe/searchResults.html?display=both&amp;term='
local RCSB_base = 'http://www.rcsb.org/pdb/search/smartSubquery.do?smartSearchSubtype=UpAccessionIdQuery&amp;accessionIdList='
local url_uniprot = " "
 
 
if checkOrtholog == 1 and uniprotID_mm ~= 'n/a' then
searchTitle = 'Ortholog search: ' --**lclz**
url_uniprot = uniprotID_mm..','..uniprotID_hs
else
searchTitle = 'Human UniProt search: ' --**lclz**
url_uniprot = uniprotID_hs
end
Line 313 ⟶ 315:
PDBe_list = url_uniprot
end
 
local PDBe = "["..PDBe_base..PDBe_list.." PDBe] "
local RCSB = "["..RCSB_base..url_uniprot.." RCSB] "
 
if string.match(pdbIDs, '%w+') then --if there aren't any PDB_ID don't display this part of the infobox
--p.formatRow(title)---how to not close the tags is a mystery and I could condense code once I figure out
Line 325 ⟶ 327:
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:tag('table')
:css('padding', '0')
:css('border', 'none')
Line 339 ⟶ 341:
:done() --end th
:done() --end tr
 
:tag('tr')
:tag('th')
Line 358 ⟶ 360:
:done() --end td
:done() --end tr
 
:tag('tr') --new row for collapsible list of PDB codes
:tag('td')
Line 403 ⟶ 405:
local title = "Identifiers" --**lclz**
local label_aliases = "[[Gene nomenclature|Aliases]]" --**lclz**
local symbol_url
if gene_symbol == "" or gene_symbol == nil then
symbol_url = ""
Line 409 ⟶ 411:
if hgnc_id == "" or hgnc_id == nil then
symbol_url = gene_symbol
 
else
symbol_url = "[https://www.genenames.org/data/gene-symbol-report/#!/hgnc_id/"..hgnc_id.." "..gene_symbol.."]"
Line 422 ⟶ 424:
aliases = string.gsub(aliases, ", $", "") --remove comma from end
local label_ext_id = "External IDs" --**lclz**
 
omim_id = string.gsub(omim_id, "%s", "")
local omim_list = mw.text.split(omim_id, ","localSeparatorStr)
local omim = ""
if (omim_id ~= nil and omim_id ~= "") then
omim = "[[Mendelian_Inheritance_in_Man|OMIM:]]"..": " --**lclz**
end
for i, v in ipairs(omim_list) do
Line 435 ⟶ 437:
end
omim = string.gsub(omim, ", $"," ") --remove comma from end
 
homologene_id = string.gsub(homologene_id, "%s", "")
local homolo_list = mw.text.split(homologene_id, ","localSeparatorStr)
local homolo =""
if (homologene_id ~= nil and homologene_id ~= "") then
homolo = "[[HomoloGene|HomoloGene:]]"..": "
end
for i, v in ipairs(homolo_list) do
Line 449 ⟶ 451:
homolo = string.gsub(homolo, ", $"," ") --remove comma from end
 
 
local genecards = "[[GeneCards|GeneCards:]]"..": "
genecards = genecards.."[https://www.genecards.org/cgi-bin/carddisp.pl?gene="..gene_symbol.." "..gene_symbol.."] "
 
mgi_id = string.gsub(mgi_id, "%s", "")
local mgi_list = mw.text.split(mgi_id, ","localSeparatorStr)
local mgi = ""
if (mgi_id ~= nil and mgi_id ~= "") then
mgi = "[[Mouse_Genome_Informatics|MGI:]]"..": " --**lclz**
end
for i, v in ipairs(mgi_list) do
Line 469 ⟶ 471:
local ChEMBL = ""
if string.match(ChEMBL_id, '%w+') then
ChEMBL = "[[ChEMBL|ChEMBL:]]"..": ".."[https://www.ebi.ac.uk/chembldb/index.php/target/inspect/CHEMBL"..ChEMBL_id.." "..ChEMBL_id.."] "
end
local IUPHAR = ""
if string.match(IUPHAR_id, '%w+') then
IUPHAR = "[[International_Union_of_Basic_and_Clinical_Pharmacology|IUPHAR:]]"..": ".."[http://www.guidetopharmacology.org/GRAC/ObjectDisplayForward?objectId="..IUPHAR_id.." "..IUPHAR_id.."] " --**lclz**
end -- *lclz*
local label_EC = "[[Enzyme_Commission_number|EC number]]" --**lclz**
Line 481 ⟶ 483:
 
local EC = "[https://www.genome.jp/dbget-bin/www_bget?enzyme+" .. link_ec_no .. " " .. ec_no .. "]"
 
root
:tag('tr')
Line 500 ⟶ 502:
:done() --end span
:done() --end th
 
:tag('td')
:attr('colspan','3')
Line 510 ⟶ 512:
:wikitext(aliases)
:done() --end td
:done() --end tr
:done() --end tr
 
:tag('tr')
:tag('th')
Line 554 ⟶ 556:
end
 
p.renderDiseases = function(frame, disease, dis_ref, name, qid)
local title = "Genetically Related Diseases" --**lclz**
 
Line 568 ⟶ 570:
end
ref_flag_all = true
end
end
if ref_flag_all then
Line 588 ⟶ 590:
:done() --end tr
 
 
 
local ref_url = "https://www.wikidata.org/wiki/"..qid.."#P2293" --direct page to property genetically associated disease
local title = "Diseases that are genetically associated with "..name.." view/edit references on wikidata" --**lclz**
local ref_link = disease_name..frame:extensionTag("ref",frame:expandTemplate{ title = 'cite_web', args = { title = title, url = ref_url} })
 
Line 604 ⟶ 606:
:attr('colspan', '3')
:wikitext(ref_link)
:done() --end td
:done() --end tr
end
 
end
 
 
p.renderDrug = function(frame,drug, drug_ref, drug_pqid, drug_pname)
local title = "Targeted by Drug" --**lclz**
 
--check first to see if any of the drugs have references
local ref_flag_all = false --check if any drugs have references if not then don't render the headers
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
 
--end
for index,value in ipairs(drug) do
Line 627 ⟶ 629:
else
-- *lclz*: comma
drug_list_per_protein[protein_qid] = drug_list_per_protein[protein_qid]..', '..value --each list of drugs keyed on protein qid
end
ref_flag_all = true
end
end
 
Line 655 ⟶ 657:
local drug_name = v
local ref_url = "https://www.wikidata.org/wiki/"..k.."#P129" --direct page to property genetically associated disease
local title = "Drugs that physically interact with "..drug_pname[k].." view/edit references on wikidata" --**lclz**
local ref_link = drug_name..frame:extensionTag("ref",frame:expandTemplate{ title = 'cite_web', args = { title = title, url = ref_url} })
 
root
:tag('tr')
Line 672 ⟶ 674:
end
end
 
end
 
p.renderGeneLocation = function(frame, chr, gstart, gend, db, cytoband, ensembl, chr_mm, gstart_mm, gend_mm, db_mm, cytoband_mm, ensembl_mm, name)
local titleHuman = "Gene ___location ([[Human genome|Human]])" --**lclz**
local titleMouse = "Gene ___location ([[Laboratory mouse|Mouse]])" --**lclz**
local label_chr = "[[Chromosome|Chr.]]" --**lclz**
local label_locus = "[[Locus (genetics)|Band]]" --**lclz**
Line 684 ⟶ 686:
local tooltip_arrowSign = "Genomic ___location for "..name --**lclz**
local arrowSign_width = 14
 
if chr ~= "" and gstart ~= "" and gend ~= "" then
--Chromosome lengths are from GRCh38.p10 https://www.ncbi.nlm.nih.gov/grc/human/data?asm=GRCh38.p10
Line 691 ⟶ 693:
local chrLengthTable = {}
chrLengthTable["1"] = 248956422
chrLengthTable["2"] = 242193529
chrLengthTable["3"] = 198295559
chrLengthTable["4"] = 190214555
chrLengthTable["5"] = 181538259
chrLengthTable["6"] = 170805979
chrLengthTable["7"] = 159345973
chrLengthTable["8"] = 145138636
chrLengthTable["9"] = 138394717
chrLengthTable["10"] = 133797422
chrLengthTable["11"] = 135086622
chrLengthTable["12"] = 133275309
chrLengthTable["13"] = 114364328
chrLengthTable["14"] = 107043718
chrLengthTable["15"] = 101991189
chrLengthTable["16"] = 90338345
chrLengthTable["17"] = 83257441
chrLengthTable["18"] = 80373285
chrLengthTable["19"] = 58617616
chrLengthTable["20"] = 64444167
chrLengthTable["21"] = 46709983
chrLengthTable["22"] = 50818468
chrLengthTable["X"] = 156040895
chrLengthTable["Y"] = 57227415
chrLengthTable["MT"] = 16569
local chrLength = chrLengthTable[chr]
 
--Different languages have different word order.
local chrTextTable = {} --**lclz** linked articles
chrTextTable["1"] = "Chromosome 1 (human)"
chrTextTable["2"] = "Chromosome 2 (human)"
Line 737 ⟶ 739:
chrTextTable["17"] = "Chromosome 17 (human)"
chrTextTable["18"] = "Chromosome 18 (human)"
chrTextTable["19"] = "Chromosome 19 (human)"
chrTextTable["20"] = "Chromosome 20 (human)"
chrTextTable["21"] = "Chromosome 21 (human)"
Line 745 ⟶ 747:
chrTextTable["MT"] = "Mitochondrial DNA (human)"
local chrText = chrTextTable[chr]
 
--about the calculation below, see https://en.wikipedia.org/wiki/User:Was_a_bee/Gene#3._Calculation_detail
local markerWidth = ((gend - gstart) * 294.133 )/ chrLength
Line 756 ⟶ 758:
local arrowSignLocation = markerLocation + (markerWidth / 2) - (arrowSign_width / 2)
markerLocation = math.floor( markerLocation * 10 + 0.5 ) / 10
 
 
local source_link_chr = ""
local source_link_gstart = ""
Line 765 ⟶ 767:
source_link_gstart = frame:extensionTag("ref", "", {name = "refGRCh38Ensembl"})
source_link_gend = frame:extensionTag("ref", "", {name = "refGRCh38Ensembl"})
elseif( db == "hg37") then
source_link_chr = frame:extensionTag("ref", "[http://grch37.ensembl.org/Homo_sapiens/Gene/Summary?db=core;&g="..ensembl.." GRCh37: Ensembl release 89: "..ensembl.."] - [[Ensembl genome database project|Ensembl]], May 2017", {name = "refGRCh37Ensembl"}) --**lclz**
source_link_gstart = frame:extensionTag("ref", "", {name = "refGRCh37Ensembl"})
source_link_gend = frame:extensionTag("ref", "", {name = "refGRCh37Ensembl"})
Line 774 ⟶ 776:
source_link_gend = ""
end
 
local wikitext_for_ideogram_image = "" --wikitext used for showing gene ___location
if chr == "MT" then -- wikitext for mitochondrial DNA
Line 782 ⟶ 784:
--wikitext_for_ideogram_image = wikitext_for_ideogram_image.."</div>"
--wikitext_for_ideogram_image = wikitext_for_ideogram_image.."</div>"
 
else -- wikitext for autosome and sex chromosome
wikitext_for_ideogram_image = wikitext_for_ideogram_image.."<div align=\"center\">"
Line 793 ⟶ 795:
wikitext_for_ideogram_image = wikitext_for_ideogram_image.."</div>"
end
 
root
:tag('tr')
Line 874 ⟶ 876:
:tag('span')
:attr('class', 'plainlinks')
:wikitext(p.separateWithComma(gstart).." [[Base pair|bp]]"..source_link_gstart) -- **lclz** Change it if it is inappropriate
:done() --end span
:done() --end td
Line 888 ⟶ 890:
: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
Line 896 ⟶ 898:
:done() --end tr
end
 
if chr_mm ~= "" and gstart_mm ~= "" and gend_mm ~= "" then
--Chromosome lengths are from GRCm38.p5 https://www.ncbi.nlm.nih.gov/grc/mouse/data?asm=GRCm38.p5
Line 905 ⟶ 907:
chrLengthTable_mm["4"] = 156508116
chrLengthTable_mm["5"] = 151834684
chrLengthTable_mm["6"] = 149736546
chrLengthTable_mm["7"] = 145441459
chrLengthTable_mm["8"] = 129401213
chrLengthTable_mm["9"] = 124595110
chrLengthTable_mm["10"] = 130694993
chrLengthTable_mm["11"] = 122082543
chrLengthTable_mm["12"] = 120129022
chrLengthTable_mm["13"] = 120421639
chrLengthTable_mm["14"] = 124902244
chrLengthTable_mm["15"] = 104043685
chrLengthTable_mm["16"] = 98207768
chrLengthTable_mm["17"] = 94987271
chrLengthTable_mm["18"] = 90702639
chrLengthTable_mm["19"] = 61431566
chrLengthTable_mm["X"] = 171031299
chrLengthTable_mm["Y"] = 91744698
chrLengthTable_mm["MT"] = 16299
local chrLength_mm = chrLengthTable_mm[chr_mm]
 
--Different languages have different word order.
local chrTextTable_mm = {}--**lclz** Articles not yet created
chrTextTable_mm["1"] = "Chromosome 1 (mouse)"
chrTextTable_mm["2"] = "Chromosome 2 (mouse)"
Line 944 ⟶ 946:
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]
 
--about the calculation below, see https://en.wikipedia.org/wiki/User:Was_a_bee/Gene#3._Calculation_detail
local markerWidth_mm = ((gend_mm - gstart_mm) * 294.133 )/ chrLength_mm
Line 967 ⟶ 969:
--But as of now, Aug. 2017, it seems that all data which is stored in Wikidata are based on GRCm38/mm10.
--So treating mouse genomic data as GRCm38/mm10 if not specified.
source_link_chr_mm = frame:extensionTag("ref", "[http://May2017.archive.ensembl.org/Mus_musculus/Gene/Summary?db=core;g="..ensembl_mm.." GRCm38: Ensembl release 89: "..ensembl_mm.."] - [[Ensembl genome database project|Ensembl]], May 2017", {name = "refGRCm38Ensembl"}) --**lclz**
source_link_gstart_mm = frame:extensionTag("ref", "", {name = "refGRCm38Ensembl"})
source_link_gend_mm = frame:extensionTag("ref", "", {name = "refGRCm38Ensembl"})
else
source_link_chr_mm = ""
Line 982 ⟶ 984:
--wikitext_for_ideogram_image_mm = wikitext_for_ideogram_image_mm.."</div>"
--wikitext_for_ideogram_image_mm = wikitext_for_ideogram_image_mm.."</div>"
 
else -- wikitext for autosome and sex chromosome
wikitext_for_ideogram_image_mm = wikitext_for_ideogram_image_mm.."<div align=\"center\">"
Line 993 ⟶ 995:
wikitext_for_ideogram_image_mm = wikitext_for_ideogram_image_mm.."</div>"
end
 
root
:tag('tr')
:tag('td')
Line 1,074 ⟶ 1,076:
:tag('span')
:attr('class', 'plainlinks')
:wikitext(p.separateWithComma(gstart_mm).." [[Base pair|bp]]"..source_link_gstart_mm) -- **lclz** Change it if it is inappropriate
:done() --end span
:done() --end td
Line 1,088 ⟶ 1,090:
:tag('span')
:attr('class', 'plainlinks')
:wikitext(p.separateWithComma(gend_mm).." [[Base pair|bp]]"..source_link_gend_mm) -- **lclz** Change it if it is inappropriate
:done() --end span
:done() --end td
Line 1,147 ⟶ 1,149:
 
p.renderGeneOntology = function(mol_funct, cell_comp, bio_process, uniprotID)
local title = "[[Gene_ontology|Gene ontology]]" --**lclz**
local mol_funct_title = "Molecular function" --**lclz**
local cell_comp_title = "Cellular component" --**lclz**
Line 1,215 ⟶ 1,217:
:done() --end td
:done() --end tr
 
:tag('tr')
:tag('td')
Line 1,221 ⟶ 1,223:
:css('text-align', 'center')
:attr('colspan', '4')
:wikitext("Sources:") -- **lclz**
:wikitext(amigo_link)
:wikitext(" / ")
Line 1,230 ⟶ 1,232:
:done() --end td
:done() --end tr
end
 
p.renderOrthologs = function(frame, entrez_gene, entrez_gene_mm, ensembl, ensembl_mm, uniprot, uniprot_mm, refseq_mRNA, refseq_mRNA_mm, refseq_prot, refseq_prot_mm, db, chr, gstart, gend, db_mm, chr_mm,gstart_mm, gend_mm)
local title = "[[Ortholog|Orthologs]]" --**lclz**
--to do make the list creation a function
--create list for entrez ids
 
 
local category_chromosome = '[[Category:Genes on human chromosome '..chr..']]'-- *lclz*: Category name
if chr == "MT" then
Line 1,245 ⟶ 1,247:
category_chromosome = ""
end
local entrezTitle = "[[Entrez|Entrez]]"
entrez_gene = string.gsub(entrez_gene, "%s", "")
local entrez_link = "n/a"localNotApplicableStr
local entrez_collapse
local entrez_default = ""
local split_entrez = mw.text.split(entrez_gene, ","localSeparatorStr)
local entrez_link_list = {}
for k,v in ipairs(split_entrez) do
if string.match(v, '%w+') and v ~= "n/a"localNotApplicableStr then
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.."]"
end
Line 1,260 ⟶ 1,262:
if table.getn(entrez_link_list) < 5 then
entrez_collapse = "none"
if entrez_default == nil and table.getn(entrez_link_list) == 0 then entrez_link = "n/a"localNotApplicableStr end
else
entrez_collapse = "collapsible collapsed"
entrez_default = table.remove(entrez_link_list, 1) .. '<br>' .. table.remove(entrez_link_list, 1) .. '<br>' ..table.remove(entrez_link_list, 1) .. '<br>' .. table.remove(entrez_link_list, 1) .. '<br>' .. table.remove(entrez_link_list, 1) .. '<br>'--get first 5 elements in table and use for display
Line 1,268 ⟶ 1,270:
entrez_link = table.concat(entrez_link_list, "<br>")
end
 
--create list for mouse Entrez id
entrez_gene_mm = string.gsub(entrez_gene_mm, "%s", "")
local entrez_mm_link = "n/a"localNotApplicableStr
local entrez_mm_collapse
local entrez_mm_default = ""
local split_entrez_mm = mw.text.split(entrez_gene_mm, ","localSeparatorStr)
local entrez_mm_link_list = {}
for k,v in ipairs(split_entrez_mm) do
if string.match(v, '%w+') and v ~= "n/a"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.."]"
end
Line 1,284 ⟶ 1,286:
if table.getn(entrez_mm_link_list) < 5 then
entrez_mm_collapse = "none"
if entrez_mm_default == nil and table.getn(entrez_mm_link_list) == 0 then entrez_mm_link = "n/a"localNotApplicableStr end
else
entrez_mm_collapse = "collapsible collapsed"
entrez_mm_default = table.remove(entrez_mm_link_list, 1) .. '<br>' .. table.remove(entrez_mm_link_list, 1) .. '<br>' ..table.remove(entrez_mm_link_list, 1) .. '<br>' .. table.remove(entrez_mm_link_list, 1) .. '<br>' .. table.remove(entrez_mm_link_list, 1) .. '<br>'--get first 5 elements in table and use for display
Line 1,292 ⟶ 1,294:
entrez_mm_link = table.concat(entrez_mm_link_list, "<br>")
end
 
--create list of ensembl id
local ensemblTitle = "[[Ensembl|Ensembl]]"
ensembl = string.gsub(ensembl, "%s", "")
local ensembl_link = "n/a"localNotApplicableStr
local ensembl_collapse
local ensembl_default = ""
local split_ensembl = mw.text.split(ensembl, ","localSeparatorStr)
local ensembl_link_list = {}
for k,v in ipairs(split_ensembl) do
if string.match(v, '%w+') and v ~= "n/a"localNotApplicableStr then
ensembl_link_list[#ensembl_link_list+1] = "[http://www.ensembl.org/Homo_sapiens/geneview?gene="..v..";db=core".." "..v.."]"
end
Line 1,309 ⟶ 1,311:
if table.getn(ensembl_link_list) < 5 then
ensembl_collapse = "none"
if ensembl_default == nil and table.getn(ensembl_link_list) == 0 then ensembl_link = "n/a"localNotApplicableStr 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
Line 1,317 ⟶ 1,319:
ensembl_link = table.concat(ensembl_link_list, "<br>")
end
 
--create list of mouse ensembl id
local ensemblTitle = "[[Ensembl|Ensembl]]"
ensembl_mm = string.gsub(ensembl_mm, "%s", "")
local ensembl_mm_link = "n/a"localNotApplicableStr
local ensembl_mm_collapse
local ensembl_mm_default = ""
local split_ensembl_mm = mw.text.split(ensembl_mm, ","localSeparatorStr)
local ensembl_mm_link_list = {}
for k,v in ipairs(split_ensembl_mm) do
if string.match(v, '%w+') and v ~= "n/a"localNotApplicableStr then
ensembl_mm_link_list[#ensembl_mm_link_list+1] = "[http://www.ensembl.org/Mus_musculus/geneview?gene="..v..";db=core".." "..v.."]"
end
Line 1,334 ⟶ 1,336:
if table.getn(ensembl_mm_link_list) < 5 then
ensembl_mm_collapse = "none"
if ensembl_mm_default == nil and table.getn(ensembl_mm_link_list) == 0 then ensembl_mm_link = "n/a"localNotApplicableStr 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
Line 1,345 ⟶ 1,347:
 
--create lists of uniprot ID
local uniprotTitle = "[[UniProt|UniProt]]"
local uniprot_url = "https://www.uniprot.org/uniprot/"
 
local uniprot_link = "n/a"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 ~= "n/a"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 .. "]"
Line 1,376 ⟶ 1,378:
uniprot_link_list = uniprot_alternate
end
 
--if less than 5 don't create collapsible list
if table.getn(uniprot_link_list) < 5 then
uniprot_collapse = "none"
if uniprot_default == nil and table.getn(uniprot_link_list) == 0 then uniprot_link = "n/a"localNotApplicableStr 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
 
--mouse uniprot lists
local uniprot_mm_link = "n/a"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 ~= "n/a"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
Line 1,423 ⟶ 1,425:
if table.getn(uniprot_mm_link_list) < 5 then
uniprot__mm_collapse = "none"
if uniprot_mm_default == nil and table.getn(uniprot_mm_link_list) == 0 then uniprot_mm_link = "n/a"localNotApplicableStr end
else
uniprot_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
end
 
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 = "RefSeq (mRNA)" -- *lclz*: sometimes
 
--create list of links for refSeq mRNA
local refseq_mRNA_link = "n/a"localNotApplicableStr
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, ","localSeparatorStr)
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 ~= "n/a"localNotApplicableStr then
if string.match(v, 'NM') or string.match(v, 'NP') then
link_list_first[#link_list_first+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
Line 1,463 ⟶ 1,465:
link_list = link_list_alternate
end
 
--if less than 5 don't create collapsible list
if table.getn(link_list) < 6 then
refseq_mRNA_collapse = "none"
if refseq_mRNA_default == nil and table.getn(link_list) == 0 then refseq_mRNA_link = "n/a"localNotApplicableStr end
else
refseq_mRNA_collapse = "collapsible collapsed"
refseq_mRNA_default = table.remove(link_list, 1) .. '<br>' .. table.remove(link_list, 1) .. '<br>' ..table.remove(link_list, 1) .. '<br>' .. table.remove(link_list, 1) .. '<br>' .. table.remove(link_list, 1) .. '<br>'--get first 5 elements in table and use for display
end
 
if link_list[#link_list] then
refseq_mRNA_link = table.concat(link_list, "<br>")
end
 
 
--create list of links for refSeq mRNA for mouse
local refseq_mRNA_mm_link = "n/a"localNotApplicableStr
local refseq_mRNA_mm_collapse
local refseq_mRNA_mm_default = ""
local split_refseq_mRNA_mm = mw.text.split(refseq_mRNA_mm, ","localSeparatorStr)
local link_list_mm = {} --if NM,NP display if not display XM, XP values
local link_list_first = {} --hold those the have NM or NP values
local link_list_alternate = {} --hold those that are XM or XP values
 
for k,v in ipairs(split_refseq_mRNA_mm) do
local label = mw.text.trim(v)
local concat_ncbi_link = ncbi_link .. label
if string.match(v, '%w+') and v ~= "n/a"localNotApplicableStr then
if string.match(v, 'NM') or string.match(v, 'NP') then
link_list_first[#link_list_first+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
Line 1,506 ⟶ 1,508:
if table.getn(link_list_mm) < 6 then
refseq_mRNA_mm_collapse = "none"
if refseq_mRNA_mm_default == nil and table.getn(link_list_mm) == 0 then refseq_mRNA_mm_link = "n/a"localNotApplicableStr end
else
refseq_mRNA_mm_collapse = "collapsible collapsed"
refseq_mRNA_mm_default = table.remove(link_list_mm, 1) .. '<br>' .. table.remove(link_list_mm, 1) .. '<br>' ..table.remove(link_list_mm, 1) .. '<br>' .. table.remove(link_list_mm, 1) .. '<br>' .. table.remove(link_list_mm, 1) .. '<br>'--get first 5 elements in table and use for display
Line 1,515 ⟶ 1,517:
refseq_mRNA_mm_link = table.concat(link_list_mm, "<br>")
end
 
-- *lclz*: sometimes
local refseq_protTitle = "RefSeq (protein)"
--create list of links for human refseq protein
local refseq_prot_link = "n/a"localNotApplicableStr
local refseq_prot_collapse
local refseq_prot_default = ""
local split_refseq_prot = mw.text.split(refseq_prot, ","localSeparatorStr)
local link_list_prot = {}
local link_list_first = {} --hold those the have NM or NP values
Line 1,529 ⟶ 1,531:
local label = mw.text.trim(v)
local concat_ncbi_link = ncbi_link .. label
if string.match(v, '%w+') and v ~= "n/a"localNotApplicableStr then
if string.match(v, 'NM') or string.match(v, 'NP') then
link_list_first[#link_list_first+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
Line 1,545 ⟶ 1,547:
if table.getn(link_list_prot) < 6 then
refseq_prot_collapse = "none"
if refseq_prot_default == nil and table.getn(link_list_prot) == 0 then refseq_prot_link = "n/a"localNotApplicableStr 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
 
 
if link_list_prot[#link_list_prot] then
refseq_prot_link = table.concat(link_list_prot, "<br>")
end
 
 
--create list of links for mouse refseq protein
local refseq_prot_mm_link = "n/a"localNotApplicableStr
local refseq_prot_mm_collapse
local refseq_prot_mm_default = ""
local split_refseq_prot_mm = mw.text.split(refseq_prot_mm, ","localSeparatorStr)
local link_list_prot_mm = {}
local link_list_first = {} --hold those the have NM or NP values
local link_list_alternate = {} --hold those that are XM or XP values
 
for k,v in ipairs(split_refseq_prot_mm) do
local label = mw.text.trim(v)
local concat_ncbi_link = ncbi_link .. label
if string.match(v, '%w+') and v ~= "n/a"localNotApplicableStr then
if string.match(v, 'NM') or string.match(v, 'NP') then
link_list_first[#link_list_first+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
Line 1,585 ⟶ 1,587:
if table.getn(link_list_prot_mm) < 6 then
refseq_prot_mm_collapse = "none"
if refseq_prot_mm_default == nil and table.getn(link_list_prot_mm) == 0 then refseq_prot_mm_link = "n/a"localNotApplicableStr end
else
refseq_prot_mm_collapse = "collapsible collapsed"
refseq_prot_mm_default = table.remove(link_list_prot_mm, 1) .. '<br>' .. table.remove(link_list_prot_mm, 1) .. '<br>' ..table.remove(link_list_prot_mm, 1) .. '<br>' .. table.remove(link_list_prot_mm, 1) .. '<br>' .. table.remove(link_list_prot_mm, 1) .. '<br>'--get first 5 elements in table and use for display
Line 1,593 ⟶ 1,595:
refseq_prot_mm_link = table.concat(link_list_prot_mm, "<br>")
end
 
 
local locTitle = "Location (UCSC)" -- *lclz*
Line 1,600 ⟶ 1,602:
local chr_loc_link = ""
if (string.match(db, '%w+') and string.match(chr, '%w+') and string.match(gstart, '%w+') and string.match(gend, '%w+') )then
local chr_ucsc
if chr == "MT" then
chr_ucsc = "M" --UCSC uses "M" (not "MT") in URL for mitochondrial DNA
else
chr_ucsc = chr
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 = "n/a" localNotApplicableStr
end
local gstart_mm_mb = p.locToMb(gstart_mm, 2)
Line 1,614 ⟶ 1,616:
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
Line 1,622 ⟶ 1,624:
chr_loc_mm_link = "[https://genome.ucsc.edu/cgi-bin/hgTracks?org=Mouse&db="..db_mm.."&position=chr"..chr_mm_ucsc..":"..gstart_mm.."-"..gend_mm.." ".."Chr "..chr_mm_ucsc..": "..gstart_mm_mb.." – "..gend_mm_mb.." Mb]"
else
chr_loc_mm_link = "n/a" localNotApplicableStr
end
 
local pubmedTitle = "[[PubMed|PubMed]] search" -- *lclz*
local pubmed_link = entrez_gene
if string.match(entrez_gene, '%w+') and entrez_gene ~= "n/a"localNotApplicableStr then
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}}
end
local pubmed_mm_link = entrez_gene_mm
if string.match(entrez_gene_mm, '%w+') and entrez_gene_mm ~= "n/a"localNotApplicableStr then
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}}
end
 
root
:tag('tr')
Line 1,852 ⟶ 1,854:
:wikitext(refseq_mRNATitle)
:done() --end th
:tag('td') --RNASeq mRNA collapsible table
:tag('table')
:attr('class', refseq_mRNA_collapse)
Line 1,879 ⟶ 1,881:
:done() --end tr
:done() --end table
:done() --end td
:tag('td') --RNASeq mRNA collapsible table for mouse
:tag('table')
:attr('class', refseq_mRNA_mm_collapse)
Line 1,906 ⟶ 1,908:
:done() --end td
:done() --end tr
:done() --end table
:done() --end td
:done() --end tr
Line 1,915 ⟶ 1,917:
:wikitext(refseq_protTitle)
:done() --end th
:tag('td') --RNASeq protein collapsible table
:tag('table')
:attr('class', refseq_prot_collapse)
Line 1,942 ⟶ 1,944:
:done() --end tr
:done() --end table
:done() --end td
:tag('td') --RNASeq protein collapsible table for mouse
:tag('table')
Line 2,020 ⟶ 2,022:
:css('text-align', 'center')
:css('background-color', rowBGcolor)
:tag('table')
:css('padding', '0')
:css('border', 'none')
Line 2,040 ⟶ 2,042:
 
p.renderFooter = function(Qid, Qid_mm)
local text = "[[Wikidata|Wikidata]]" --**lclz**
local hs_link = "[[d:"..Qid.."|View/Edit Human]]" --**lclz**
local mm_link = ""
local link_no_hs
local link_no_mm
 
if Qid_mm == "" then
link_no_mm = 0
link_no_hs = 4
else
link_no_mm = 2
link_no_hs = 2
mm_link = "[[d:"..Qid_mm.."|View/Edit Mouse]]" --**lclz**
end
 
root
:tag('tr')
Line 2,114 ⟶ 2,116:
local data = entity
 
local f = {'labels','en','value'} --**lclz**
 
local i = 1
Line 2,126 ⟶ 2,128:
end
end
 
data = data[index] or data[tonumber(index)]
if not data then
return
end
 
i = i + 1
end
Line 2,153 ⟶ 2,155:
for k, v in pairs(claims) do
local datav = mw.wikibase.label("Q" .. v.mainsnak.datavalue.value["numeric-id"])
if datav == nil then datav = " " end
out[#out + 1] = datav
end
return table.concat(out, sep)
Line 2,183 ⟶ 2,185:
for k, v in pairs(claims) do
local datav = mw.wikibase.label("Q" .. v.mainsnak.datavalue.value["numeric-id"])
if datav == nil then datav = " " end
out[#out + 1] = datav
end
results = table.concat(out, sep)
Line 2,190 ⟶ 2,192:
results = entity:formatPropertyValues(propertyID).value
end
overall_results[#overall_results+1] = results --individual propertyID value stored in this index
end
end
Line 2,196 ⟶ 2,198:
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
return str_overall_results
else
return return_val
Line 2,214 ⟶ 2,216:
end
 
--get random value that is preferred ranked
-- *lclz*: Sometimes Wikibase returns punctuations other than "," depending on
-- your site's language. Consider adding a gsub here.
p.getRefseq_mRNA = function(entity, propertyID, return_val)
if return_val == nil then return_val = "" end
local input_rank = "RANK_PREFERRED" ---this is mostly like won't do anything because ranking isn't maintained in wikidata
local claims
 
if entity.claims then
claims = entity.claims[propertyID]
Line 2,233 ⟶ 2,235:
local label = mw.wikibase.label("Q" .. v.mainsnak.datavalue.value["numeric-id"])
if label == nil then label = "Q" .. v.mainsnak.datavalue.value["numeric-id"] end
 
if sitelink then
out[#out + 1] = "[[" .. sitelink .. "|" .. label .. "]]"
Line 2,242 ⟶ 2,244:
return table.concat(out, ", ")
else
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
--[[local results_split = mw.text.split(results, ","localSeparatorStr)
 
local preffered_results = " "
if results_split[1] then
Line 2,254 ⟶ 2,256:
for i, id in ipairs(results_split) do
local trim_id = mw.text.trim(id)
if string.match( trim_id, '^NM_%d+') then
preferred_result = trim_id --overwrite each time found only need one to display
end
Line 2,273 ⟶ 2,275:
-- *lclz*: same as getRefseq_mRNA
p.getRefseq_protein = function(protein_entities, propertyID, return_val)
local sep = ","localSeparatorStr
local overall_results = {} --should return empty if nothing assigned
 
for key, val in pairs(protein_entities) do --in cases where there are multiple encodes we loop through each and return concatenated data as a whole
 
local claims
local entity = val --each protein in encodes
Line 2,290 ⟶ 2,292:
for k, v in pairs(claims) do
local datav = mw.wikibase.label("Q" .. v.mainsnak.datavalue.value["numeric-id"])
if datav == nil then datav = " " end
out[#out + 1] = datav
end
results = table.concat(out, sep)
else
results = entity:formatPropertyValues("P637", mw.wikibase.entity.claimRanks).value
end
overall_results[#overall_results+1] = results --a list is in each index
end
 
end
--why are there duplicate results here
Line 2,309 ⟶ 2,311:
local results_split = mw.text.split(str_overall_results, sep) --split complete list so can loop through..probably a more direct way to do this
--loop through results until get a NP or NM or just return whatever is in first element
 
 
local preffered_result = results_split[1] or ""
Line 2,316 ⟶ 2,318:
local trim_id = mw.text.trim(id)
--check of id starts with NP or NM
if string.match( trim_id, '^NP_%d+') then
preferred_result = trim_id --overwrite each time found only need one to display
end
Line 2,331 ⟶ 2,333:
--gets an image
p.getImage = function(entity, propertyID, sep, imgsize)
 
local claims
 
if entity and entity.claims then
claims = entity.claims[propertyID]
end
 
if claims then
if (claims[1] and claims[1].mainsnak.datatype == "commonsMedia") then
local out = {}
for k, v in pairs(claims) do
local filename = v.mainsnak.datavalue.value
out[#out + 1] = "[[File:" .. filename .. "|" .. imgsize .. "]]"
end
return table.concat(out, sep)
else
return ""
end
else
return ""
end
end
 
Line 2,367 ⟶ 2,369:
local results
if (claims[1] and claims[1].mainsnak.snaktype == "value") then
 
 
local out = {}
for k, v in pairs(claims) do
local label = mw.wikibase.label(v.mainsnak.datavalue.value)
if label == nil then label = v.mainsnak.datavalue.value end
 
if sitelink then
out[#out + 1] = "[" .. sitelink .. label .. " " ..label .. "]"
Line 2,395 ⟶ 2,397:
-- *lclz*: You will need a different language here.
-- If you are aiming for an "en" fallback, consider a set data structure.
 
-- zhwp went a bit further here: they moved this call after "gene_symbol",
-- so that this function can perform the deduplication here instead of
Line 2,411 ⟶ 2,413:
return ""
end
 
end
 
Line 2,422 ⟶ 2,424:
-- 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
-- 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
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?
--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)
Line 2,450 ⟶ 2,452:
local ___location = v.mainsnak.datavalue.value
--debugging
--out[#out + 1] = k.." ___location:" .. ___location.. " || "
--gets the qualifiers linked to the current claim
local quals
if v.qualifiers then
quals = v.qualifiers.P659
Line 2,482 ⟶ 2,484:
end
--in case there are no qualifiers, but there is a ___location, might as well return it
else output = ___location
end
end
Line 2,500 ⟶ 2,502:
local output = ""
local sep = " "
local propertyID = "P644" --genomic start used
local qualifierID = "P659" --genomic assembly
 
Line 2,549 ⟶ 2,551:
end
--in case there are no qualifiers, but there is a ___location, might as well return it
else output = ___location
end
end
Line 2,566 ⟶ 2,568:
local string_to_trim = p.getValue(entity, "P1057")
local out = ''
 
--"mitochondrion" and "chromosome MT" is used for mitochondrial DNA.
--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'
out = "MT"
elseif string.find(string_to_trim, 'chromosome') then --**lclz** Add your local label, otherwise it may break
out = string.match(string_to_trim, "%d+")--extract number from string
if out == nil then
Line 2,577 ⟶ 2,579:
end
end
return out
end
 
p.locToMb = function(num, idp)
num = tonumber(num)
if num == nil then
return ""
else
Line 2,598 ⟶ 2,600:
p.getGO = function(protein_entities, propertyID)
--propertyID ie molecular, cellular, function
 
local overall_results = {}
local results = "" --string to return
 
for key, val in pairs(protein_entities) do
 
local claims
local entity = val
Line 2,610 ⟶ 2,612:
end
local propertyID_child = "P686" -- Gene Ontology ID
 
if claims then
 
if (claims[1] and claims[1].mainsnak.snaktype == "value" and claims[1].mainsnak.datavalue.type == "wikibase-entityid") then
--local out = {}
Line 2,637 ⟶ 2,639:
overall_results[#overall_results+1] = wiki_link
end
 
else
results = entity:formatPropertyValues(propertyID, mw.wikibase.entity.claimRanks).value
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
end
 
Line 2,651 ⟶ 2,653:
for _,v in ipairs(overall_results) do
if (not hash[v]) then
res[#res+1] = v
hash[v] = true
end
Line 2,659 ⟶ 2,661:
 
local function getReference(qID, entity, property_id, ref_index)
local f = {"claims",property_id, ref_index, "references"}
local id = qID
--if id and (#id == 0) then
Line 2,668 ⟶ 2,670:
return nil
end
 
 
local i = 1
while true do
Line 2,680 ⟶ 2,682:
end
end
 
data = data[index] or data[tonumber(index)]
if not data then
Line 2,697 ⟶ 2,699:
if claims then
-- if wiki-linked value output as link if possible
 
if (claims[1] and claims[1].mainsnak.snaktype == "value" and claims[1].mainsnak.datavalue.type == "wikibase-entityid") then
 
Line 2,704 ⟶ 2,706:
--{{#invoke:Wikidata |ViewSomething |id=Q18023174 |claims|P2293|1|references|1|snaks|P854|1|datavalue|value}}
--maybe there is a more direct way to find this than looping through the json object
 
for k, v in pairs(claims) do
local datav = mw.wikibase.label("Q" .. v.mainsnak.datavalue.value["numeric-id"])
 
if datav == nil then datav = " " end
 
local id = "Q" .. v.mainsnak.datavalue.value["numeric-id"]
local linkTarget = mw.wikibase.sitelink(id)
Line 2,719 ⟶ 2,721:
refLink = ref
end
 
--if refLink = "" then --skip if there isn't a reference found
 
if linkTarget then
out[#out + 1] = "[["..linkTarget.."|"..datav.."]]"
Line 2,728 ⟶ 2,730:
end
datasource[#out] = refLink
--end
end
return out, datasource
Line 2,738 ⟶ 2,740:
else
return return_val
end
return return_val
end
Line 2,762 ⟶ 2,764:
for k, v in pairs(claims) do
local datav = mw.wikibase.label("Q" .. v.mainsnak.datavalue.value["numeric-id"])
 
if datav == nil then datav = "" end
local id = "Q" .. v.mainsnak.datavalue.value["numeric-id"]
Line 2,789 ⟶ 2,791:
--Separate number with comma. For example when this function gets "12345678", returns "12,345,678"
local commaSeparated = bp
while true do
commaSeparated, k = string.gsub(commaSeparated, "^(-?%d+)(%d%d%d)", '%1,%2')
if (k==0) then