Module:Infobox gene: Difference between revisions

Content deleted Content added
Changed the mouse ensembl.org link to Mus_musculus
added error handling
Line 1:
local p = { }
local errorflag = 0
 
 
 
 
 
local navbar = require('Module:Navbar')._navbar
local infobox = require('Module:Infobox3cols').infobox
local infoboxImage = require('Module:InfoboxImage').InfoboxImage
 
 
 
Line 112 ⟶ 116:
if entity then --only require the main gene entity
--a list variables of all the data in the info box
--check every function call to avoid lua page errors better way to execute this??
local name = p.getLabel(entity)
local entrez_genename = p.getValue(entity, "P351")''
if p.getLabel(entity) then name = p.getLabel(entity) else errorflag = 1 end
local entrez_gene_mm = p.getValue(entity_mouse, "P351", "n/a")
local entrez_gene = ''
local image = p.getImage(entity, "P18", " ", "250px") --need to set size
if p.getValue(entity, "P351") then entrez_gene = p.getValue(entity, "P351") else errorflag = 1 end
local uniprotID_hs = p.getValueProtein(entity_protein, "P352", "n/a")
local entrez_gene_mm = ''
local uniprotID_mm = p.getValueProtein(entity_mouse_protein, "P352", "n/a")
if p.getValue(entity_mouse, "P351", "n/a") then entrez_gene_mm = p.getValue(entity_mouse, "P351", "n/a") else errorflag = 1 end
local pdbIDs = p.getPDB(entity_protein) --makes a list with links to RCSB
local image = '' --need to set size
local aliases = p.getAliases(entity)
if p.getImage(entity, "P18", " ", "250px") then image = p.getImage(entity, "P18", " ", "250px") else errorflag = 1 end
local gene_symbol = p.getValue(entity, "P353")
local uniprotID_hs = ''
local hgnc_id = p.getValue(entity, "P354")
if p.getValueProtein(entity_protein, "P352", "n/a") then uniprotID_hs = p.getValueProtein(entity_protein, "P352", "n/a") else errorflag = 1 end
local homologene_id = p.getValue(entity, "P593")
local omim_iduniprotID_mm = p.getValue(entity, "P492")''
if p.getValueProtein(entity_mouse_protein, "P352", "n/a") then uniprotID_mm = p.getValueProtein(entity_mouse_protein, "P352", "n/a") else errorflag = 1 end
local mgi_id = p.getValue(entity_mouse, "P671")
local pdbIDs = '' --makes a list with links to RCSB
local ChEMBL_id = p.getValue(entity_protein, "P592")
localif IUPHAR_id p.getPDB(entity_protein) then pdbIDs = p.getValuegetPDB(entity_protein, "P595") else errorflag = 1 end
local ec_noaliases = p.getValueProtein(entity_protein, "P591")''
if p.getAliases(entity) then aliases = p.getAliases(entity) else errorflag = 1 end
local mol_funct = p.getGO(entity_protein, "P680")
local cell_compgene_symbol = p.getGO(entity_protein, "P681")''
if p.getValue(entity, "P353") then gene_symbol = p.getValue(entity, "P353") else errorflag = 1 end
local bio_process = p.getGO(entity_protein, "P682")
local hgnc_id = ''
local expression_images = p.getImage(entity,"P692","<br><br>","250px")
localif ensembl = p.getValue(entity, "P594P354") then hgnc_id = p.getValue(entity, "n/aP354") else errorflag = 1 end
local ensembl_mmhomologene_id = p.getValue(entity_mouse, "P594", "n/a")''
if p.getValue(entity, "P593") then homologene_id = p.getValue(entity, "P593") else errorflag = 1 end
local refseq_mRNA = p.getRefseq_mRNA(entity, "P639", "n/a")
local omim_id = ''
local refseq_mRNA_mm = p.getRefseq_mRNA(entity_mouse, "P639", "n/a")
if p.getValue(entity, "P492") then omim_id = p.getValue(entity, "P492") else errorflag = 1 end
local refseq_prot = p.getRefseq_protein(entity_protein, "P637", "n/a")
local mgi_id = ''
local refseq_prot_mm = p.getRefseq_protein(entity_mouse_protein, "P637", "n/a")
if p.getValue(entity_mouse, "P671") then mgi_id = p.getValue(entity_mouse, "P671") else errorflag = 1 end
local gstart = p.getChromosomeLoc(entity, "P644", "hg")
local ChEMBL_id = ''
local gend = p.getChromosomeLoc(entity, "P645", "hg")
if p.getValue(entity_protein, "P592") then ChEMBL_id = p.getValue(entity_protein, "P592") else errorflag = 1 end
local chr = p.trimChromosome(entity)
local IUPHAR_id = ''
local db = p.getAliasFromGenomeAssembly(entity,"hg")
if p.getValue(entity_protein, "P595") then IUPHAR_id = p.getValue(entity_protein, "P595") else errorflag = 1 end
local gstart_mm = p.getChromosomeLoc(entity_mouse, "P644", "mm")
local ec_no = ''
local gend_mm = p.getChromosomeLoc(entity_mouse, "P645", "mm")
if p.getValueProtein(entity_protein, "P591") then ec_no = p.getValueProtein(entity_protein, "P591") else errorflag = 1 end
local db_mm = p.getAliasFromGenomeAssembly(entity_mouse,"mm")
local mol_funct = ''
local chr_mm = p.trimChromosome(entity_mouse)
if p.getGO(entity_protein, "P680") then mol_funct = p.getGO(entity_protein, "P680") else errorflag = 1 end
local disease, dis_ref = p.getDisease(entity, "P2293")
local cell_comp = ''
local drug = p.getDrug(entity_protein, "P129")
if p.getGO(entity_protein, "P681") then cell_comp = p.getGO(entity_protein, "P681") else errorflag = 1 end
local bio_process = ''
if p.getGO(entity_protein, "P682") then bio_process = p.getGO(entity_protein, "P682") else errorflag = 1 end
local expression_images = ''
if p.getImage(entity,"P692","<br><br>","250px") then expression_images = p.getImage(entity,"P692","<br><br>","250px") else errorflag = 1 end
local ensembl = ''
if p.getValue(entity, "P594", "n/a") then ensembl = p.getValue(entity, "P594", "n/a") else errorflag = 1 end
local ensembl_mm = ''
if p.getValue(entity_mouse, "P594", "n/a") then ensembl_mm = p.getValue(entity_mouse, "P594", "n/a") else errorflag = 1 end
local refseq_mRNA = ''
if p.getRefseq_mRNA(entity, "P639", "n/a") then refseq_mRNA = p.getRefseq_mRNA(entity, "P639", "n/a") else errorflag = 1 end
local refseq_mRNA_mm = ''
if p.getRefseq_mRNA(entity_mouse, "P639", "n/a") then refseq_mRNA_mm = p.getRefseq_mRNA(entity_mouse, "P639", "n/a") else errorflag = 1 end
local refseq_prot = ''
if p.getRefseq_protein(entity_protein, "P637", "n/a") then refseq_prot = p.getRefseq_protein(entity_protein, "P637", "n/a") else errorflag = 1 end
local refseq_prot_mm = ''
if p.getRefseq_protein(entity_mouse_protein, "P637", "n/a") then refseq_prot_mm = p.getRefseq_protein(entity_mouse_protein, "P637", "n/a") else errorflag = 1 end
local gstart = ''
if p.getChromosomeLoc(entity, "P644", "hg") then gstart = p.getChromosomeLoc(entity, "P644", "hg") else errorflag = 1 end
local gend = ''
if p.getChromosomeLoc(entity, "P645", "hg") then gend = p.getChromosomeLoc(entity, "P645", "hg") else errorflag = 1 end
local chr = ''
if p.trimChromosome(entity) then chr = p.trimChromosome(entity) else errorflag = 1 end
local db = ''
if p.getAliasFromGenomeAssembly(entity,"hg") then db = p.getAliasFromGenomeAssembly(entity,"hg") else errorflag = 1 end
local gstart_mm = ''
if p.getChromosomeLoc(entity_mouse, "P644", "mm") then gstart_mm = p.getChromosomeLoc(entity_mouse, "P644", "mm") else errorflag = 1 end
local gend_mm = ''
if p.getChromosomeLoc(entity_mouse, "P645", "mm") then gend_mm = p.getChromosomeLoc(entity_mouse, "P645", "mm") else errorflag = 1 end
local db_mm = ''
if p.getAliasFromGenomeAssembly(entity_mouse,"mm") then db_mm = p.getAliasFromGenomeAssembly(entity_mouse,"mm") else errorflag = 1 end
local chr_mm = ''
if p.trimChromosome(entity_mouse) then chr_mm= p.trimChromosome(entity_mouse) else errorflag = 1 end
local disease, dis_ref = ''
if p.getDisease(entity, "P2293") then disease, dis_ref = p.getDisease(entity, "P2293") else errorflag = 1 end
local drug = ''
if p.getDrug(entity_protein, "P129") then drug = p.getDrug(entity_protein, "P129") else errorflag = 1 end
 
--define Global Color Scheme
rowBGcolor = '#eee'
Line 154 ⟶ 196:
sideTitleBGcolor = '#c3fdb8'
 
 
p.createTable()
if errorflag == 1 then
p.renderUpperTitle(name)
return("DISPLAY ERROR: Infobox Gene cannot be displayed as one of the values is generating an error")
--p.renderCaption()
else
p.renderImage(image)
p.createTable()
p.renderAvailableStructures(uniprotID_hs, uniprotID_mm, checkOrtholog, pdbIDs) --PDB info
p.renderUpperTitle(name)
p.renderIdentifiers(aliases, hgnc_id, gene_symbol, homologene_id, omim_id, mgi_id, ChEMBL_id, IUPHAR_id, ec_no, entrez_gene)
--p.renderCaption()
if (disease ~= "" and dis_ref ~= "") then --removes section from those items without disease info
p.renderImage(image)
p.renderDiseases(disease, dis_ref)
p.renderAvailableStructures(uniprotID_hs, uniprotID_mm, checkOrtholog, pdbIDs) --PDB info
end
p.renderIdentifiers(aliases, hgnc_id, gene_symbol, homologene_id, omim_id, mgi_id, ChEMBL_id, IUPHAR_id, ec_no, entrez_gene)
if (disease ~= "" and dis_ref ~= "") then --removes section from those items without disease info
p.renderDiseases(disease, dis_ref)
end
if (drug ~= "" ) then --removes section from those items without drug info
p.renderDrug(drug)
end
if (mol_funct ~= "" and cell_comp ~= "" and bio_process ~= "") then
p.renderGeneOntology(mol_funct, cell_comp, bio_process, uniprotID_hs)
end
if expression_images ~= "" then
p.renderRNAexpression(expression_images, entrez_gene)
end
p.renderOrthologs(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)
 
end
else return "An Error has occurred retrieving Wikidata item for infobox"
else return "An Error has occurred retrieving Wikidata item for infobox" end
end
end
 
Line 2,273 ⟶ 2,318:
out = "M"
end
return out
end