Content deleted Content added
Julialturner (talk | contribs) updated ncbi links to use https |
Julialturner (talk | contribs) Changed how disease and drugs are displayed and referenced to eliminate bare urls and enable editing to reference in wikidata |
||
Line 157:
local disease, dis_ref = ''
if p.getDisease(entity, "P2293") then disease, dis_ref = p.getDisease(entity, "P2293") else disease, dis_ref = {"'''VALUE_ERROR'''","'''VALUE_ERROR'''" } end
if p.getDrug(entity_protein, "P129") then drug, drug_ref, drug_pqid, drug_pname = p.getDrug(entity_protein, "P129") else drug, drug_ref, drug_pqid, drug_pname = {"'''VALUE_ERROR'''","'''VALUE_ERROR'''" } end
--local drug = check_values(p.getDrug, {entity_protein, "P129"})
--define Global Color Scheme
Line 171 ⟶ 172:
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, name, root_qid)
end
if (drug ~= "" ) then --removes section from those items without drug info
p.renderDrug(frame,drug, drug_ref, drug_pqid, drug_pname)
if (mol_funct ~= "" and cell_comp ~= "" and bio_process ~= "") then
Line 188 ⟶ 189:
return tostring(root)
--return table.concat(drug_pqid)
else return "An Error has occurred retrieving Wikidata item for infobox"
end
Line 532 ⟶ 533:
end
p.renderDiseases = function(frame, disease, dis_ref, name, qid)
local title = "Genetically Related Diseases"
--check first to see if any of the diseases have references
local
local disease_name = ''
for index,value in ipairs(disease) do
if (dis_ref[index] ~= nil and dis_ref[index] ~= '') then
disease_name = value
else
disease_name = disease_name..","..value
end
ref_flag_all = true
end
Line 564 ⟶ 566:
:done()
:newline()
--local disease_name = table.concat(disease, ", ")
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"
local ref_link = disease_name..frame:extensionTag("ref",frame:expandTemplate{ title = 'cite_web', args = { title = title, url = ref_url} })
root
:tag('tr')
Line 617 ⟶ 584:
:css('background-color', rowBGcolor)
:attr('scope', 'row')
:attr('colspan', '
:wikitext(
:done()
:newline()
:done()
:done()
:newline()
end
end
p.renderDrug = function(frame,drug, drug_ref, drug_pqid, drug_pname)
local title = "Targeted by Drug"
--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
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
--end
for index,value in ipairs(drug) do
if (drug_ref[index] ~= nil and drug_ref[index] ~= '') then
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
else
drug_list_per_protein[protein_qid] = drug_list_per_protein[protein_qid]..','..value --each list of drugs keyed on protein qid
end
ref_flag_all = true
end
end
if ref_flag_all then
root
Line 680 ⟶ 634:
:done()
:newline()
--loop to create reference links from drug lists
for k,v in pairs(drug_list_per_protein) do
local drug_name = v
local ref_url = "https://www.wikidata.org/wiki/"..k.."#P129" --direct page to property genetically associated disease
local title = "Drugs that physically interact with "..drug_pname[k].." view/edit references on wikidata"
local ref_link = drug_name..frame:extensionTag("ref",frame:expandTemplate{ title = 'cite_web', args = { title = title, url = ref_url} })
root
Line 738 ⟶ 655:
:css('background-color', rowBGcolor)
:attr('scope', 'row')
:attr('colspan', '
:done()
:newline()
:done()
:newline()
end
end
Line 2,324 ⟶ 2,219:
end
local function getReference(qID
local f = {"claims",property_id,
local id = qID
--if id and (#id == 0) then
Line 2,379 ⟶ 2,274:
local linkTarget = mw.wikibase.sitelink(id)
local refLink = ""
local
ref = getReference("", entity, "P2293", k)
if (ref
--refLink = refLink..","..ref
end
--if refLink = "" then --skip if there isn't a reference found
if linkTarget then
out[#out + 1] = "[["..datav.."|"..datav.."]]"
Line 2,394 ⟶ 2,288:
out[#out + 1] = "[[:d:" .. id .. "|" .. datav .. "]]"
end
datasource[#out] = refLink
--end
end
Line 2,411 ⟶ 2,306:
local out = {}
local datasource = {}
local pname = {}
local pqid = {}
for key, val in pairs(protein_entities) do
local claims
local entity = val
local name = check_values(p.getLabel,{entity})
if entity.claims then
claims = entity.claims[propertyID] -- ie physically interacts with
Line 2,429 ⟶ 2,328:
local linkTarget = mw.wikibase.sitelink(id)
local refLink = ""
local ref = getReference(protein_id, entity, "P129",k) --just check if anything returned
end
out[#out + 1] = "[[:d:" .. id .. "|" .. datav .. "]]"
pname[protein_id] = name
pqid[#out] = protein_id
end --end k,v claims loop
end --end claims[1]
end --if claims
end -- end protein_entities loop
return out, datasource, pqid, pname
end
|