Module:Infobox gene: Difference between revisions

Content deleted Content added
Fixed suppression of Drug section title when not present
Changed disease section and drug to link references to the reference section on the wikipedia page
Line 171:
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(frame, disease, dis_ref)
end
if (drug ~= "" ) then --removes section from those items without drug info
p.renderDrug(frame,drug)
end
Line 184:
p.renderRNAexpression(expression_images, entrez_gene)
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)
 
Line 532:
end
 
p.renderDiseases = function(frame, disease, dis_ref)
local title = "Genetically Related Diseases"
local disease_title = "Disease Name"
Line 581:
for index,value in ipairs(disease) do
local i = 0
--local ref_collapse = ""
local ref_default = ""
local ref_link = ""
Line 589:
ref_link_list = mw.text.split(dis_ref[index], ",")
end
 
local br_count = 0
--if less than 4 don't create collapsible list
iffor i =1, table.getn(ref_link_list) < 5do then
ref_linkref_url = ref_link..table.remove(ref_link_list, 1) .. ' '
ref_collapse = "none"
abbr_url = string.gsub(ref_url, "http://", '')
else
if i > 1 then --not sure why indexing off, but renders empty value if don't do this
ref_collapse = "collapsible collapsed"
ref_link = ref_link..frame:extensionTag("ref",frame:expandTemplate{ title = 'cite_web', args = { title = abbr_url, url = ref_url} })
for i =1, 5 do --get at most 4 elements to display
else
ref_default = ref_default..table.remove(ref_link_list, 1) .. ' '
br_count = br_count + -1
end
local br_count = 0
if br_count < 53 then
for i =1, table.getn(ref_link_list) do --get at most 4 elements to display
ref_linkbr_count = ref_link..table.remove(ref_link_list,br_count + 1) .. ' '
else
if br_count < 5= then0
br_countref_link = br_countref_link + 1..'<br>'
elseend
br_count = 0
ref_link = ref_link ..'<br>'
end
end
end
if ref_link_list[#ref_link_list] then
ref_link = table.concat(ref_link_list, " ")
end
root
:tag('tr')
Line 634 ⟶ 626:
:tag('table')
:attr('class', ref_collapse)
:css('padding', '0')
:css('border', 'none')
Line 640 ⟶ 631:
:css('width', '100%')
:css('text-align', 'right')
:tag('tr')
:newline()
:tag('th')
:attr('colspan', '1')
:tag('span')
:attr('class', 'plainlinks')
:wikitext(ref_default)
:done()
:done()
:newline()
:done()
:tag('tr')
:tag('td')
Line 670 ⟶ 650:
 
--p.renderDrug = function(drug, drug_ref)
p.renderDrug = function(frame,drug)
local title = "Targeted by Drug"
local drug_title = "Drug Name"
Line 717 ⟶ 697:
for key,value in pairs(drug) do
local i = 0
--local ref_collapse = ""
local ref_default = ""
local ref_link = ""
Line 730 ⟶ 710:
end
end
local br_count = 0
for i =1, table.getn(ref_link_list) do --get at most 4 elements to display
ref_defaultref_url = ref_default..table.remove(ref_link_list, 1) .. ' '
abbr_url = string.gsub(ref_url, "http://", '')
if i > 1 then --not sure why indexing off, but renders empty value if don't do this
ref_link = ref_link..frame:extensionTag("ref",frame:expandTemplate{ title = 'cite_web', args = { title = abbr_url, url = ref_url} })
else
br_count = br_count -1
end
if br_count < 3 then
br_count = br_count + 1
endelse
br_count = 0
ref_link = ref_link ..'<br>'
end
end
root
 
--if less than 4 don't create collapsible list
if table.getn(ref_link_list) < 5 then
ref_collapse = "none"
else
ref_collapse = "collapsible collapsed"
for i =1, 5 do --get at most 4 elements to display
ref_default = ref_default..table.remove(ref_link_list, 1) .. ' '
end
local br_count = 0
for i =1, table.getn(ref_link_list) do --get at most 4 elements to display
ref_link = ref_link..table.remove(ref_link_list, 1) .. ' '
if br_count < 5 then
br_count = br_count + 1
else
br_count = 0
ref_link = ref_link ..'<br>'
end
end
end
if ref_link_list[#ref_link_list] then
ref_link = table.concat(ref_link_list, " ")
end
root
:tag('tr')
:attr('colspan', 4)
Line 783 ⟶ 754:
:css('width', '100%')
:css('text-align', 'right')
:tag('tr')
:newline()
:tag('th')
:attr('colspan', '1')
:tag('span')
:attr('class', 'plainlinks')
:wikitext(ref_default)
:done()
:done()
:newline()
:done()
:tag('tr')
:tag('td')
Line 933 ⟶ 893:
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 = "Orthologs"
--to do make the list creation a function
Line 1,313 ⟶ 1,273:
local pubmed_link = entrez_gene
if string.match(entrez_gene, '%w+') and entrez_gene ~= "n/a" then
pubmed_link = frame:extensionTag("ref",frame:expandTemplate{ title = 'cite_web', args = { title ="Human PubMed Reference:" , url = "[http://www.ncbi.nlm.nih.gov/sites/entrez?db=gene&cmd=Link&LinkName=gene_pubmed&from_uid="..entrez_gene } } )--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" then
pubmed_mm_link = frame:extensionTag("ref",frame:expandTemplate{ title = 'cite_web', args = { title ="Mouse PubMed Reference:" , url ="[http://www.ncbi.nlm.nih.gov/sites/entrez?db=gene&cmd=Link&LinkName=gene_pubmed&from_uid="..entrez_gene_mm } } )--expandTemplate creates cite web template {{cite web|title=value|url=ref_link.."]"ect}}
end
Line 2,424 ⟶ 2,384:
ref = getReference("", k, entity, "P2293", i)
if (ref ~= nil and ref ~= '') then
refLink = refLink..",["..ref.."]"
end
end
Line 2,474 ⟶ 2,434:
ref = getReference(protein_id, k, entity, "P129", i)
if (ref ~= nil and ref ~= '') then
refLink = refLink..",["..ref.."]"
end
end