local p =
local navbar = require('Module:Navbar')._navbarlocal infobox = require('Module:Infobox3cols').infoboxlocal infoboxImage = require('Module:InfoboxImage').InfoboxImage
--on a page --in debug window --frame = mw.getCurrentFrame--frame.args = Q18031325--print(p.getTemplateData(frame))p.getTemplateData = function(frame)
--make some guesses about whether the provided QID is a good one --could expand here if we had some kind of error handling framework --did we get it from the page local root_qid = mw.text.trim(frame.args['QID'] or "") --try to get it from the args local mm_qid = "" --pull all the entity objects that we will need local entity = local entity_protein = local entity_mouse = local entity_mouse_protein = local checkOrtholog = "" --flag used to see if mouse data avaliable local mouse_propertyID = "P684" local protein_propertyID = "P688"
--get root gene entity if root_qid
"value" and claims[1].mainsnak.datavalue.type
"value" and claims[1].mainsnak.datavalue.type
"value" and claims[1].mainsnak.datavalue.type
"value" and claims[1].mainsnak.datavalue.type
--define Global Color Scheme rowBGcolor = '#eee' titleBGcolor = '#ddd' sideTitleBGcolor = '#c3fdb8'
p.createTable p.renderUpperTitle(name) if (disease ~= "" and dis_ref ~= "") then --removes section from those items without disease info p.renderDiseases(disease, dis_ref, root_qid) end p.renderFooter return tostring(root)
else return "An Error has occurred retrieving Wikidata item for infobox" end end
p.createTable = function(subbox)
if subbox
end
-- look into entity objectp.getLabel = function(entity) local data = entity
local f =
local i = 1 while true do local index = f[i] if not index then if type(data)
--Title above imagep.renderUpperTitle = function(name) local title = name if not title then return "error: failed to get label"; end root :tag('tr') :tag('th') :attr('colspan', 4) :css('text-align', 'center') :css('font-size', '125%') :css('font-weight', 'bold') :wikitext(title) :newlineend
p.renderDiseases = function(disease, dis_ref, Qid) local title = "Genetically Related Diseases" local disease_title = "Disease Name" local source_title = "References"
local ref_flag = --check each disease for a reference local ref_flag_all = "true" --not used in this code
if ref_flag_all
nil or dis_ref[index]
--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 ..'
' 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) :css('text-align', 'center') :css('background-color', rowBGcolor) :newline :tag('th') :css('background-color', rowBGcolor) :attr('scope', 'row') :attr('colspan', '2') :wikitext(value) :done :newline :tag('td') :tag('span') :attr('colspan', '2') :tag('table') :attr('class', ref_collapse) :css('padding', '0') :css('border', 'none') :css('margin', '0') :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') :attr('colspan', '1') :newline :tag('p') :attr('class', 'plainlinks') :wikitext(ref_link) :newline :done :done :done :done :newline end end
local function getReference(qID, index, entity, property_id, ref_index) local f = local id = qID --if id and (#id
"table" then return mw.text.jsonEncode(data, mw.text.JSON_PRESERVE_KEYS + mw.text.JSON_PRETTY) else return tostring(data) end end data = data[index] or data[tonumber(index)] if not data then return "" end i = i + 1 endend
--general function to get value given an entity and propertyp.getValue = function(entity, propertyID, return_val)
local claims if return_val
"value" and claims[1].mainsnak.datavalue.type
nil then datav = " " end out[#out + 1] = datav end return table.concat(out, sep) else -- just return best values return entity:formatPropertyValues(propertyID).value end else return return_val endend
p.getDisease= function(entity, propertyID) local claims if return_val
"value" and claims[1].mainsnak.datavalue.type
nil then datav = " " end local id = "Q" .. v.mainsnak.datavalue.value["numeric-id"] local linkTarget = mw.wikibase.sitelink(id) local refLink = "" local i for i=1,100 do --limits to 100 references displayed local ref = "" ref = getReference("", k, entity, "P2293", i) if (ref ~= nil and ref ~= ) then refLink = refLink..",["..ref.."]" --else -- refLink = "click to add reference" --link to disease association section to add reference end end --if refLink = "" then --skip if there isn't a reference found datasource[#out + 1] = refLink if linkTarget then out[#out + 1] = ""..datav.."" else out[#out + 1] = "" .. datav .. "" end --end end return out, datasource else -- just return best values --return entity:formatPropertyValues(propertyID).value return return_val, return_val end else return return_val end return return_valend
p.renderFooter = function local text = "Module:Sandbox/genewiki/generefbox"
root :tag('tr') :tag('td') :attr('colspan', '4') :css('text-align', 'center') :css('font-size','small') :css('background-color', rowBGcolor) :wikitext('The alternate rendering for the references can be found at line 252 in this source module ') :wikitext(text) :done :newline :done
end
return p