Module:Infobox gene: Difference between revisions

Content deleted Content added
Undid revision 726603242 by Julialturner (talk)
added checks for values to catch lua error messages
Line 5:
local infoboxImage = require('Module:InfoboxImage').InfoboxImage
 
local function check_values(f,args)
 
--local u= table.upack(args)
local exist, val = pcall(f, unpack(args))
if exist and val ~= nil then
return(val)
else
return("'''VALUE_ERROR'''")
end
end
 
--on a page {{#invoke:Sandbox/genewiki/alllua|getTemplateData|QID=Q14865053}}
Line 112 ⟶ 121:
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"} )
local entrez_gene_mm = check_values(p.getValue(, {entity_mouse, "P351", "n/a"})
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"})
local uniprotID_mm = check_values(p.getValueProtein(, {entity_mouse_protein, "P352", "n/a"})
local pdbIDs = check_values(p.getPDB(, {entity_protein}) --makes a list with links to RCSB
local aliases = check_values(p.getAliases(, {entity})
local gene_symbol = check_values(p.getValue(, {entity, "P353"})
local hgnc_id = check_values(p.getValue(, {entity, "P354"})
local homologene_id = check_values(p.getValue(, {entity, "P593"})
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"})
local ensembl_mm = check_values(p.getValue(, {entity_mouse, "P594", "n/a"})
local refseq_mRNA = check_values(p.getRefseq_mRNA(, {entity, "P639", "n/a"})
local refseq_mRNA_mm = check_values(p.getRefseq_mRNA(, {entity_mouse, "P639", "n/a"})
local refseq_prot = check_values(p.getRefseq_protein(, {entity_protein, "P637", "n/a"})
local refseq_prot_mm = check_values(p.getRefseq_protein(, {entity_mouse_protein, "P637", "n/a"})
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 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 db_mm = check_values(p.getAliasFromGenomeAssembly(, {entity_mouse,"mm"})
local chr_mm = check_values( p.trimChromosome(, {entity_mouse})
local disease, dis_ref = p.getDisease(entity, "P2293")''
if p.getDisease(entity, "P2293") then disease, dis_ref = p.getDisease(entity, "P2293") else disease, dis_ref = {"'''VALUE_ERROR'''","'''VALUE_ERROR'''" } end
local drug = check_values(p.getDrug(, {entity_protein, "P129"})
--define Global Color Scheme