Content deleted Content added
edits to resolve "ensembl_id is nil" error + cleanup |
per talk, update from Module:Infobox gene/sandbox; this cleans code, fixes a couple of issues, and removes globals, see sandbox history |
||
Line 1:
local p = {
local localSeparatorStr = "," -- **lclz** Correct it if your wiki has different setting, like zhwiki uses "、" for now
local localNotApplicableStr = "n/a" -- **lclz**
local root
-- wrapped "protected call", return "value error" with error info on error
Line 15 ⟶ 21:
end
end
--texts relevant to localization are tagged with --**lclz** and/or *lclz*
--on a page {{#invoke:Sandbox/genewiki/alllua|getTemplateData|QID=Q14865053}}
Line 21 ⟶ 28:
--frame.args = {QID="Q14865053"} Q18031325
--print(p.getTemplateData(frame))
function p.getTemplateData
--make some guesses about whether the provided QID is a good one
--could expand here if we had some kind of error handling framework
--did we get it from the page
local root_qid = mw.text.trim(frame.args['QID']
local mm_qid = ""
--pull all the entity objects that we will need
Line 51 ⟶ 58:
local subclass = p.getValue(entity, "P31") or ""
if string.find(subclass, 'protein') then --if protein switch entity to gene **lclz**
local claims
if entity.claims then
claims = entity.claims["P702"] --encoded by
Line 68 ⟶ 76:
entity = mw.wikibase.getEntity(root_qid)
end
--get the other related entities
if entity then
local claims
--get protein entity object
if entity.claims then
Line 138 ⟶ 145:
end
if entity then --only require the main gene entity
Line 177 ⟶ 183:
local db = check_values(p.getAliasFromGenomeAssembly, {entity,"hg"})
local gstart_mm = check_values(p.getChromosomeLoc, {entity_mouse, "P644", "mm"})
local gend_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", localNotApplicableStr})
local disease, dis_ref =
local drug, drug_ref, drug_pqid, drug_pname = p.getDrug(entity_protein, "P129")
--local drug = check_values(p.getDrug, {entity_protein, "P129"})
▲ --define Global Color Scheme
▲ rowBGcolor = '#eee'
▲ titleBGcolor = '#ddd'
▲ sideTitleBGcolor = '#c3fdb8'
p.createTable()
Line 222:
--return table.concat(drug_pqid)
else
end
end
function p.createTable
if subbox == 'sub' then --doesn't work
Line 253 ⟶ 254:
--Title above image
function p.renderUpperTitle
local title = name
if not title then return "error: failed to get label"; end
Line 270 ⟶ 271:
--This is a place holder for the image caption, which is stored in wikicommons comments unsure how to access
function p.renderCaption
--caption
end
--gets default image
function p.renderImage
root
end
▲p.renderAvailableStructures = function(uniprotID_hs, uniprotID_mm, checkOrtholog, pdbIDs)
local title = 'Available structures' --**lclz**
Line 301 ⟶ 298:
..'rcsb_polymer_entity_container_identifiers.reference_sequence_identifiers.database_accession:'
local url_uniprot = " "
if checkOrtholog == 1 and uniprotID_mm ~= 'n/a' then
Line 339 ⟶ 335:
:attr('colspan', '4')
:css('text-align', 'center')
:css('background-color', titleBGcolor)
:wikitext(title)
:done() --end th
Line 373 ⟶ 369:
:css('text-align', 'left')
:tag('tr')
:css('background-color', titleBGcolor)
:css('text-align', 'center')
:tag('th')
Line 401 ⟶ 397:
return ""
end
end
function p.renderIdentifiers
local title = "Identifiers" --**lclz**
local label_aliases = "[[Gene nomenclature|Aliases]]" --**lclz**
local symbol_url
if gene_symbol == "" or gene_symbol == nil
symbol_url = ""
else
if hgnc_id == "" or hgnc_id == nil
symbol_url = gene_symbol
Line 452 ⟶ 447:
end
homolo = string.gsub(homolo, ", $"," ") --remove comma from end
local genecards = "[[GeneCards]]"..": "
Line 538 ⟶ 532:
:done() --end tr
if ec_no ~= ""
:tag('tr')
:tag('th')
:attr('scope', 'row')
:css('background-color', sideTitleBGcolor)
:wikitext(label_EC)
:done() --end th
:tag('td')
:attr('colspan', '3')
:css('background-color', rowBGcolor)
:tag('span')
:attr('class', 'plainlinks')
:wikitext(EC)
:done() --end span
:done() --end td
:done() --end tr
end
end
function p.renderDiseases
local title = "Genetically Related Diseases" --**lclz**
Line 592 ⟶ 586:
:done() --end tr
local ref_url =
▲ 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 611 ⟶ 603:
: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
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
Line 626 ⟶ 616:
for index,value in ipairs(drug) do
if (drug_ref[index] ~= nil and drug_ref[index] ~= '') then
local protein_qid = drug_pqid[index]
if drug_list_per_protein[protein_qid] == '' or drug_list_per_protein[protein_qid] == nil then
drug_list_per_protein[protein_qid] = value
Line 658 ⟶ 648:
for k,v in pairs(drug_list_per_protein) do
local drug_name = v
local ref_url =
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} })
Line 679 ⟶ 669:
end
function p.renderGeneLocation
local titleHuman = "Gene ___location ([[Human genome|Human]])" --**lclz**
local titleMouse = "Gene ___location ([[Laboratory mouse|Mouse]])" --**lclz**
Line 757 ⟶ 747:
markerWidth = math.ceil(markerWidth)
end
local markerLocation =
local arrowSignLocation =
markerLocation = math.floor( markerLocation * 10 + 0.5 ) / 10
▲ local source_link_gstart = ""
if( db == "hg38" ) then
source_link_chr = frame:extensionTag("ref", "[http://May2017.archive.ensembl.org/Homo_sapiens/Gene/Summary?db=core;g="..ensembl.." GRCh38: Ensembl release 89: "..ensembl.."] - [[Ensembl genome database project|Ensembl]], May 2017", {name = "refGRCh38Ensembl"}) --**lclz**
source_link_gstart = frame:extensionTag("ref", "", {name = "refGRCh38Ensembl"})
source_link_gend = frame:extensionTag("ref", "", {name = "refGRCh38Ensembl"})
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"})
source_link_gstart = ""
source_link_gend = ""
Line 781 ⟶ 768:
local wikitext_for_ideogram_image = "" --wikitext used for showing gene ___location
if chr == "MT" then -- wikitext for mitochondrial DNA
--wikitext_for_ideogram_image
--wikitext_for_ideogram_image
--wikitext_for_ideogram_image
--wikitext_for_ideogram_image
--wikitext_for_ideogram_image
else -- wikitext for autosome and sex chromosome
Line 842 ⟶ 829:
:wikitext("[["..chrText.."]]"..source_link_chr)
:done() --end span
:done() --end tr
:tag('tr')
Line 868 ⟶ 855:
:wikitext(cytoband)
:done() --end span
:tag('th')
:attr('scope', 'row')
Line 880 ⟶ 867:
:wikitext(p.separateWithComma(gstart).." [[Base pair|bp]]"..source_link_gstart) -- **lclz** Change it if it is inappropriate
:done() --end span
:done() --end tr
:tag('tr')
Line 894 ⟶ 881:
:wikitext(p.separateWithComma(gend).." [[Base pair|bp]]"..source_link_gend) -- **lclz** Change it if it is inappropriate
:done() --end span
:done() --end tr
:done() --end table
:done() --end tr
end
Line 961 ⟶ 948:
markerWidth_mm = math.ceil(markerWidth_mm)
end
local markerLocation_mm =
local arrowSignLocation_mm =
markerLocation_mm = math.floor( markerLocation_mm * 10 + 0.5 ) / 10
local source_link_chr_mm = ""
Line 1,042 ⟶ 1,029:
:wikitext(chrText_mm..source_link_chr_mm)
:done() --end span
:done() --end tr
:tag('tr')
Line 1,080 ⟶ 1,067:
:wikitext(p.separateWithComma(gstart_mm).." [[Base pair|bp]]"..source_link_gstart_mm) -- **lclz** Change it if it is inappropriate
:done() --end span
:done() --end tr
:tag('tr')
Line 1,094 ⟶ 1,081:
:wikitext(p.separateWithComma(gend_mm).." [[Base pair|bp]]"..source_link_gend_mm) -- **lclz** Change it if it is inappropriate
:done() --end span
:done() --end tr
:done() --end table
:done() --end tr
end
end
--Get the render elements
--and anatomic entity list for the gene expression list rendering.
function p.renderExpressionList
--create list of expressed in anatomic entities
if default_text == nil then default_text = "" end
Line 1,120 ⟶ 1,107:
end
--if less than 11 don't create collapsible list
if
if table.getn(anatomic_entity_list) == 0 then
anatomic_entity_labels = localNotApplicableStr
Line 1,136 ⟶ 1,123:
end
function p.renderRNAexpression
local title = "[[Gene expression|RNA expression]] pattern" --**lclz**
local biogps_link = ""
Line 1,143 ⟶ 1,130:
biogps_title = "[http://biogps.org/ " .. biogps_title .. "]"
-- If no expression image exist in BioGPS, the N/A is displayed
if expression_images ~= ""
biogps_link = "[http://biogps.org/gene/"..entrez_gene.."/ More reference expression data]" --**lclz**
else
Line 1,157 ⟶ 1,144:
local bgee_tissues = bgee_expression[3]
local bgee_more_link = ""
if bgee_tissues ~= localNotApplicableStr
bgee_more_link = "[https://bgee.org/?page=gene&gene_id="..ensembl_id.." More reference expression data]"
end
Line 1,269 ⟶ 1,256:
end
function p.renderGeneOntology
local title = "[[Gene ontology]]" --**lclz**
local mol_funct_title = "Molecular function" --**lclz**
Line 1,276 ⟶ 1,263:
local amigo_link = "[http://amigo.geneontology.org/" .. " Amigo]"
local quickGO_link = "[https://www.ebi.ac.uk/QuickGO/" .. " QuickGO]"
root
Line 1,361 ⟶ 1,347:
end
function p.renderOrthologs
local title = "[[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
Line 1,387 ⟶ 1,372:
end
--if less than 5 don't create collapsible list
if
entrez_collapse = "none"
if entrez_default == nil and table.getn(entrez_link_list) == 0 then entrez_link = localNotApplicableStr end
Line 1,411 ⟶ 1,396:
end
--if less than 5 don't create collapsible list
if
entrez_mm_collapse = "none"
if entrez_mm_default == nil and table.getn(entrez_mm_link_list) == 0 then entrez_mm_link = localNotApplicableStr end
Line 1,436 ⟶ 1,421:
end
--if less than 5 don't create collapsible list
if
ensembl_collapse = "none"
if ensembl_default == nil and table.getn(ensembl_link_list) == 0 then ensembl_link = localNotApplicableStr end
Line 1,448 ⟶ 1,433:
--create list of mouse ensembl id
ensembl_mm = string.gsub(ensembl_mm, "%s", "")
local ensembl_mm_link = localNotApplicableStr
Line 1,461 ⟶ 1,445:
end
--if less than 5 don't create collapsible list
if
ensembl_mm_collapse = "none"
if ensembl_mm_default == nil and table.getn(ensembl_mm_link_list) == 0 then ensembl_mm_link = localNotApplicableStr end
Line 1,471 ⟶ 1,455:
ensembl_mm_link = table.concat(ensembl_mm_link_list, "<br>")
end
--create lists of uniprot ID
Line 1,492 ⟶ 1,475:
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
else
uniprot_alternate[#uniprot_alternate+1] = "[" .. concat_uniprot_link .. " " ..label .. "]"
Line 1,501 ⟶ 1,484:
end
if table.getn(uniprot_first)>0 then --if there is something in the preferred values display else display anything else
uniprot_link_list
else
uniprot_link_list
end
--if less than 5 don't create collapsible list
if
uniprot_collapse = "none"
if uniprot_default == nil and table.getn(uniprot_link_list) == 0 then uniprot_link = localNotApplicableStr end
Line 1,530 ⟶ 1,513:
local hash = {} --storage to look for duplicated values
for k,v in ipairs(split_uniprot_mm) do
uniprot_mm_first[#uniprot_mm_first+1] = "[" .. concat_uniprot_link .. " " ..label .. "]"
else
uniprot_mm_alternate[#uniprot_mm_alternate+1] = "[" .. concat_uniprot_link .. " " ..label .. "]"
end
hash[v] = true
end
end
if table.getn(uniprot_mm_first)>0 then --if there is something in the preferred values display else display anything else
uniprot_mm_link_list
else
uniprot_mm_link_list
end
--if less than 5 don't create collapsible list
if
if uniprot_mm_default == nil and table.getn(uniprot_mm_link_list) == 0 then uniprot_mm_link = localNotApplicableStr end
else
Line 1,561 ⟶ 1,544:
uniprot_mm_link = table.concat(uniprot_mm_link_list, "<br>")
end
local ncbi_link = "https://www.ncbi.nlm.nih.gov/entrez/viewer.fcgi?val="
Line 1,581 ⟶ 1,562:
if string.match(v, '%w+') and v ~= localNotApplicableStr then
if string.match(v, 'NM') or string.match(v, 'NP') then
elseif string.match(v, 'XM') or string.match(v, 'XP') then
link_list_alternate[#link_list_alternate+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
Line 1,594 ⟶ 1,575:
--if less than 5 don't create collapsible list
if
refseq_mRNA_collapse = "none"
if refseq_mRNA_default == nil and table.getn(link_list) == 0 then refseq_mRNA_link = localNotApplicableStr end
else
refseq_mRNA_collapse = "collapsible collapsed"
refseq_mRNA_default
end
Line 1,605 ⟶ 1,586:
refseq_mRNA_link = table.concat(link_list, "<br>")
end
--create list of links for refSeq mRNA for mouse
Line 1,621 ⟶ 1,601:
if string.match(v, '%w+') and v ~= localNotApplicableStr then
if string.match(v, 'NM') or string.match(v, 'NP') then
elseif string.match(v, 'XM') or string.match(v, 'XP') then
link_list_alternate[#link_list_alternate+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
Line 1,633 ⟶ 1,613:
end
--if less than 5 don't create collapsible list
if
refseq_mRNA_mm_collapse = "none"
if refseq_mRNA_mm_default == nil and table.getn(link_list_mm) == 0 then refseq_mRNA_mm_link = localNotApplicableStr end
Line 1,660 ⟶ 1,640:
if string.match(v, '%w+') and v ~= localNotApplicableStr then
if string.match(v, 'NM') or string.match(v, 'NP') then
elseif string.match(v, 'XM') or string.match(v, 'XP') then
link_list_alternate[#link_list_alternate+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
Line 1,667 ⟶ 1,647:
end
if table.getn(link_list_first)>0 then
link_list_prot
else
link_list_prot
end
--if less than 5 don't create collapsible list
if
refseq_prot_collapse
if refseq_prot_default == nil and table.getn(link_list_prot) == 0 then refseq_prot_link = localNotApplicableStr end
else
Line 1,679 ⟶ 1,659:
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
Line 1,700 ⟶ 1,678:
if string.match(v, '%w+') and v ~= localNotApplicableStr then
if string.match(v, 'NM') or string.match(v, 'NP') then
elseif string.match(v, 'XM') or string.match(v, 'XP') then
link_list_alternate[#link_list_alternate+1] = "[" .. concat_ncbi_link .. " " ..label .. "]"
Line 1,707 ⟶ 1,685:
end
if table.getn(link_list_first)>0 then
link_list_prot_mm
else
link_list_prot_mm
end
--if less than 5 don't create collapsible list
if
refseq_prot_mm_collapse
if refseq_prot_mm_default == nil and table.getn(link_list_prot_mm) == 0 then refseq_prot_mm_link = localNotApplicableStr end
else
Line 1,722 ⟶ 1,700:
refseq_prot_mm_link = table.concat(link_list_prot_mm, "<br>")
end
local locTitle = "Location (UCSC)" -- *lclz*
local gstart_mb = p.locToMb(gstart, 2)
local gend_mb = p.locToMb(gend, 2)
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
Line 1,749 ⟶ 1,726:
chr_mm_ucsc = chr_mm
end
chr_loc_mm_link =
else
chr_loc_mm_link = localNotApplicableStr
Line 2,142 ⟶ 2,119:
end
function p.formatRow
root
:tag('tr')
Line 2,156 ⟶ 2,133:
:css('text-align', 'left')
:tag('tr') --create title header
:css('background-color', titleBGcolor)
:css('text-align', 'center')
:tag('th')
Line 2,168 ⟶ 2,145:
end
function p.renderFooter
local text = "[[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
else
end
root
:css('font-size','x-small')
:wikitext(hs_link)
:done() --end td
:tag('td')
:css('font-size','x-small')
:wikitext(mm_link)
:done() --end td
:done() --end tr
:done() --end table
:done() --end tr
root:done() --end root table
end
--this code isn't used was hoping could do some generalization of rows
function p.rowLabel
root
:tag('tr')
Line 2,240 ⟶ 2,216:
-- look into entity object
function p.getLabel
local data = entity
Line 2,264 ⟶ 2,240:
end
end
-- Get property values formatted as a string of a given instance/entity.
Line 2,273 ⟶ 2,247:
-- '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.
function p.getValue
local claims
Line 2,320 ⟶ 2,294:
end
function p.getValueProtein
if return_val == nil then return_val = "" end
local sep = ","
Line 2,355 ⟶ 2,329:
end
end
--general function to get value given an entity and property
function p.getQid
local Qid
if entity and entity.id then
Line 2,371 ⟶ 2,344:
-- *lclz*: Sometimes Wikibase returns punctuations other than "," depending on
-- your site's language. Consider adding a gsub here.
function p.getRefseq_mRNA
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
Line 2,426 ⟶ 2,399:
-- *lclz*: same as getRefseq_mRNA
function p.getRefseq_protein
local sep = localSeparatorStr
local overall_results = {} --should return empty if nothing assigned
Line 2,435 ⟶ 2,408:
local entity = val --each protein in encodes
if entity.claims then
claims = entity.claims[
end
if claims then
Line 2,449 ⟶ 2,422:
results = table.concat(out, sep)
else
results = entity:formatPropertyValues(
end
overall_results[#overall_results+1] = results --a list is in each index
Line 2,463 ⟶ 2,436:
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,484 ⟶ 2,456:
--gets an image
function p.getImage
local claims
Line 2,508 ⟶ 2,480:
end
function p.getPDB
local pdb_propertyID = "P638"
local overall_results = {}
Line 2,521 ⟶ 2,493:
local results
if (claims[1] and claims[1].mainsnak.snaktype == "value") then
local out = {}
Line 2,536 ⟶ 2,507:
results = table.concat(out, ", ") -- *lclz*: punctuation (CJK comma, etc.)
else
results = entity:formatPropertyValues(
end
overall_results[#overall_results+1] = results --individual propertyID values stored in this index
Line 2,545 ⟶ 2,516:
function p.getAliases(entity)
if entity['aliases'] ~= nil then
-- *lclz*: You will need a different language here.
Line 2,555 ⟶ 2,525:
local test = entity['aliases']['en']
if test then
local a = ''
for key, value in ipairs(test) do
a = a .. ', ' ..
end
return a
Line 2,567 ⟶ 2,538:
end
--get a geneome start P644 or end P645
function p.getChromosomeLoc
-- will contain the numeric value for the requested coordinate
local output = ""
Line 2,636 ⟶ 2,606:
end
--in case there are no qualifiers, but there is a ___location, might as well return it
else
output = ___location end
end
else
return ""
Line 2,650 ⟶ 2,621:
end
function p.getAliasFromGenomeAssembly
-- will contain the numeric value for the requested coordinate
local output = ""
Line 2,660 ⟶ 2,631:
local claims
if entity.claims then
end
--will return nothing if no claims are found
Line 2,670 ⟶ 2,641:
--pulls the genome ___location from the claim
for k, v in pairs(claims) do
local ___location = '' -- TODO what should this be? defining ___location is required for 'output = ___location' below
local quals
if v.qualifiers then
Line 2,703 ⟶ 2,675:
end
--in case there are no qualifiers, but there is a ___location, might as well return it
else
output = ___location end
end
else
return ""
Line 2,717 ⟶ 2,690:
-- *lclz*: Your language's wikidata may have different nouns for chromosome and
-- mitochodria.
function p.trimChromosome
local string_to_trim = p.getValue(entity, "P1057")
local out = ''
Line 2,734 ⟶ 2,707:
end
function p.locToMb
num = tonumber(num)
if num == nil then
Line 2,745 ⟶ 2,718:
end
function p.isempty
return s == nil or s == ''
end
▲p.getGO = function(protein_entities, propertyID)
--propertyID ie molecular, cellular, function
Line 2,783 ⟶ 2,755:
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
local wiki_link
if sitelink and result_GOID ~= nil then
wiki_link = "\n* [" .. sitelink .. result_GOID .. " " .. label .."]"
Line 2,822 ⟶ 2,794:
return nil
end
local i = 1
Line 2,843 ⟶ 2,814:
end
function p.getDisease
local claims
local return_val = "" -- define variable; this line was 'if return_val == nil then return_val = "" end' which looks like a copy/paste
if entity and entity.claims then
claims = entity.claims[propertyID]
Line 2,896 ⟶ 2,867:
end
function p.getDrug
local out = {}
local datasource = {}
local pname = {}
local pqid = {}
for key, val in pairs(protein_entities) do
Line 2,940 ⟶ 2,910:
end
function p.separateWithComma
--Separate number with comma. For example when this function gets "12345678", returns "12,345,678"
local commaSeparated = bp
while true do
local k
commaSeparated, k = string.gsub(commaSeparated, "^(-?%d+)(%d%d%d)", '%1,%2')
if
break
end
|