如何创建一个具有FASTA格式参数的R函数

时间:2018-05-10 09:52:24

标签: r bioinformatics fasta

这是我写的代码。我试图用FASTA格式的参数运行这个函数,但它没有使用它。请帮我改变代码中的内容,通过FASTA格式的参数可以很容易地计算出来

I= 131.1736 
L= 131.1736 
K= 146.1882 
M= 149.2124 
F= 165.19
T= 119.1197 
W= 204.2262 
V= 117.1469 
R= 174.2017 
H= 155.1552 
A= 89.0935
N= 132.1184 
D= 133.1032 
C= 121.159 
E= 147.1299 
Q= 146.1451 
G= 75.0669
P= 115.131
S= 105.093
Y= 181.1894


ref=c(I= 131.1736, L= 131.1736, K= 146.1882, M= 149.2124, F= 165.19, T= 119.1197, W= 204.2262, V= 117.1469, R= 174.2017, H= 155.1552, A= 89.0935, N= 132.1184, D= 133.1032, C= 121.159, E= 147.1299, Q= 146.1451, G= 75.0669, P= 115.131, S= 105.093, Y= 181.1894)

#function to calculate molecular weights of amino acids, could be used by using ("",ref=ref)

mw=function(compound)
{
    molecules=unlist(strsplit(compound,""))
    ans=sum(ref[molecules])-((nchar(compound)-1)*18)
    return(c("Molecular Weight:"=ans))
}

0 个答案:

没有答案