prolog:蛋白质到RNA反向翻译

时间:2015-05-23 02:46:58

标签: list prolog concatenation sequence

我想显示蛋白质序列中RNA序列的所有可能概率 annexin是蛋白质的名称。 事实:

protein(annexin,[phe,leu,gly]).
code('phe') -> codon('UUU','UUC')
code('leu') -> codon('UUA','UUG')
code('gly') -> codon('GGC','GGU')

rules:
rna(X):-
   protein(X,[A,B,C].
   (i dont know how to permute the triplet codon)

query:
rna(annexin)

result:
UUU,UUA,GGC
UUU,UUG,GGC
UUU,UUA,GGU
UUC,UUA,GGC
...
...

2 个答案:

答案 0 :(得分:1)

我认为代码/密码子的表示必须是明确的,然后

?- rna(annexin, C).
C = ['UUU', 'UUA', 'GGC'] ;
C = ['UUU', 'UUA', 'GGU'] ;
C = ['UUU', 'UUG', 'GGC'] ;
C = ['UUU', 'UUG', 'GGU'] ;
C = ['UUC', 'UUA', 'GGC'] ;
C = ['UUC', 'UUA', 'GGU'] ;
C = ['UUC', 'UUG', 'GGC'] ;
C = ['UUC', 'UUG', 'GGU'].

产量

char a_char =  result.getContents().charAt(0);

答案 1 :(得分:-1)

1)

code('phe') -> codon('UUU','UUC')

不是一般情况,我会说你的意思是:

code('phe',codon('UUU','UUC')).

2)

您不需要评估所有可能的答案,prolog由您做到:

rna(X) :-
  protein(X,[CA,CB,CC]),
  ( code(CA,codon(DA,_)); code(CA,codon(_,DA)) ),
  ( code(CB,codon(DB,_)); code(CB,codon(_,DB)) ),
  ( code(CC,codon(DC,_)); code(CC,codon(_,DC)) ),
  format('~w ~w ~w~n', [DA, DB, DC] ),
  fail.

(如果您需要对结果进行一些后处理,请删除格式& fail并使用setof / bagof将它们存储在列表中)。