Content deleted Content added
Changed the mouse ensembl.org link to Mus_musculus |
Julialturner (talk | contribs) 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
if p.getLabel(entity) then name = p.getLabel(entity) else errorflag = 1 end
local entrez_gene = ''
if p.getValue(entity, "P351") then entrez_gene = p.getValue(entity, "P351") else errorflag = 1 end
local entrez_gene_mm = ''
if p.getValue(entity_mouse, "P351", "n/a") then entrez_gene_mm = p.getValue(entity_mouse, "P351", "n/a") else errorflag = 1 end
local image = '' --need to set size
if p.getImage(entity, "P18", " ", "250px") then image = p.getImage(entity, "P18", " ", "250px") else errorflag = 1 end
local uniprotID_hs = ''
if p.getValueProtein(entity_protein, "P352", "n/a") then uniprotID_hs = p.getValueProtein(entity_protein, "P352", "n/a") else errorflag = 1 end
local
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 pdbIDs = '' --makes a list with links to RCSB
local
if p.getAliases(entity) then aliases = p.getAliases(entity) else errorflag = 1 end
local
if p.getValue(entity, "P353") then gene_symbol = p.getValue(entity, "P353") else errorflag = 1 end
local hgnc_id = ''
local
if p.getValue(entity, "P593") then homologene_id = p.getValue(entity, "P593") else errorflag = 1 end
local omim_id = ''
if p.getValue(entity, "P492") then omim_id = p.getValue(entity, "P492") else errorflag = 1 end
local mgi_id = ''
if p.getValue(entity_mouse, "P671") then mgi_id = p.getValue(entity_mouse, "P671") else errorflag = 1 end
local ChEMBL_id = ''
if p.getValue(entity_protein, "P592") then ChEMBL_id = p.getValue(entity_protein, "P592") else errorflag = 1 end
local IUPHAR_id = ''
if p.getValue(entity_protein, "P595") then IUPHAR_id = p.getValue(entity_protein, "P595") else errorflag = 1 end
local ec_no = ''
if p.getValueProtein(entity_protein, "P591") then ec_no = p.getValueProtein(entity_protein, "P591") else errorflag = 1 end
local mol_funct = ''
if p.getGO(entity_protein, "P680") then mol_funct = p.getGO(entity_protein, "P680") else errorflag = 1 end
local cell_comp = ''
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'
if errorflag == 1 then
return("DISPLAY ERROR: Infobox Gene cannot be displayed as one of the values is generating an error")
else
p.createTable()
p.renderUpperTitle(name)
--p.renderCaption()
p.renderImage(image)
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)
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)
return tostring(root)
end
else return "An Error has occurred retrieving Wikidata item for infobox" end
end
Line 2,273 ⟶ 2,318:
out = "M"
end
return out
end
|