我真的很感激一些帮助 -
我必须创建一个通用规则,显示所有小中性氨基酸的长名称?
这甚至可能吗?您需要更多信息吗?
答案 0 :(得分:2)
SWI-Prolog提供了一些工具:这个片段从Wikipedia中捕获一个片段,并将数据转储为准备好使用Prolog事实:
:- use_module(library(xpath)).
:- use_module(library(sgml)).
:- dynamic protein_table_page/1.
wiki_protein_table_capture :-
( protein_table_page(P)
-> true
; load_xml('https://en.wikipedia.org/wiki/Proteinogenic_amino_acid', [P], []),
assertz(protein_table_page(P))
),
xpath(P, //table(@class='wikitable sortable'), Table),
forall(xpath(Table, //tr, Tr), (
xpath_chk(Tr, th(text), LongName),
xpath_chk(Tr, td(1,text), Short),
xpath_chk(Tr, td(2,text), Code),
format('~q.~n', protein(LongName,Short,Code))
; true
)).
之后,请参阅片段:
:- [user].
protein('Alanine','A','Ala').
protein('Cysteine','C','Cys').
protein('Aspartic acid','D','Asp').
protein('Glutamic acid','E','Glu').
protein('Phenylalanine','F','Phe').
protein('Glycine','G','Gly').
protein('Histidine','H','His').
protein('Isoleucine','I','Ile').
protein('Lysine','K','Lys').
protein('Leucine','L','Leu').
protein('Methionine','M','Met').
protein('Asparagine','N','Asn').
protein('Pyrrolysine','O','Pyl').
protein('Proline','P','Pro').
protein('Glutamine','Q','Gln').
protein('Arginine','R','Arg').
protein('Serine','S','Ser').
protein('Threonine','T','Thr').
protein('Selenocysteine','U','Sec').
protein('Valine','V','Val').
protein('Tryptophan','W','Trp').
protein('Tyrosine','Y','Tyr').
现在:
?- protein(LongName, _, 'Val').
LongName = 'Valine'.
答案 1 :(得分:0)
要开始使用Prolog,请参阅:http://www.learnprolognow.org/