模組討論:Infobox gene
外观
Jimmy-bot在话题“Module:Infobox gene”中的最新留言:8年前
![]() | 本頁是以往討論的存檔。請勿編輯本頁。若您想發起新討論或重啟現有討論,請在當前討論頁進行。 |
有個功能是自動幫條目加上[[分類:位於XX號人類染色體的基因]],但把模組移來zhwiki以後就抓不到號碼了。
例子請參考d:Q14865372、en:Dopamine_transporter、多巴胺轉運體
用來抓染色體號的code:
p.trimChromosome = function(entity)
local string_to_trim = p.getValue(entity, "P1057")
local out = ''
if string.find(string_to_trim, 'chromosome') then
out = string.match(string_to_trim, "%d+")--extract number from string
if out == nil then
out = string.match(string_to_trim, "X") or string.match(string_to_trim, "Y")
end
end
if string.find(string_to_trim, 'mitochondrial') then
out = "M"
end
return out
end
—以上未簽名的留言由Panintelize(對話|貢獻)於2017-01-26T04:29Z加入。
- 用RELN(Q414043)的例子的话,其染色体(P1057)值为Q657319(#7),getValue 好像是会给个链接。在本来的英语代码中是:
- 如果存在“chromosome”,则寻找数字或X、Y;否则尝试寻找“mitochondrial”。
- 我们在中文维基百科测试一下吧:
{{#invoke:Wikidata|getValueFromID|Q414043|P1057|FETCH_WIKIDATA}}
[[7號染色體|7號染色體]]
- 也许改成找“染色體”或“染色体”就好了?——Artoria2e5编 保持讨论完整,直接ping我回复。 2017年1月26日 (四) 06:04 (UTC)
完成 Special:Diff/42962820 ——Artoria2e5编 保持讨论完整,直接ping我回复。 2017年1月26日 (四) 06:09 (UTC)