我有一个如下所示的 AAString 设置,如何从 seq 列中提取区域子集。
df <- AAStringSet(c("MEKIVLLLA", "MEKIVLDIA"))
输入:
df:
AAStringSet object of length 2:
width seq names
9 MEKIVLLLA A1
9 MEKIVLDIA A2
输出:
AAStringSet object of length 2:
width seq names
6 MKLLLA A1
6 MKLDIA A2
我使用了下面的代码,但它不起作用:
positions <- c(1,3,6,7,8,9)
end_positions <- c(1,3,6,7,8,9)
subseq(df, start = positions, end = end_positions))
也许是一种
base
方法,
seq1 = 'MEKIVLLLA'
seq2 = 'MEKIVLDIA'
paste(unlist(strsplit(seq2, split = ''))[c(1,3,6:9)], collapse='')
[1] "MKLDIA"
paste(unlist(strsplit(seq1, split = ''))[c(1,3,6:9)], collapse='')
[1] "MKLLLA"