分为3个字符长度 [英] Split into 3 character length
本文介绍了分为3个字符长度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个非常简单的问题:如何在单个代码中将以下文本分为3
I have very simple question: How can I divide the following text into 3 in a single code
mycodes <- c("ATTTGGGCTAATTTTGTTTCTTTCTGGGTCTCTC")
strsplit(mycodes, split = character(3), fixed = T, perl = FALSE, useBytes = FALSE)
[[1]]
[1] "A" "T" "T" "T" "G" "G" "G" "C" "T" "A" "A" "T" "T" "T" "T" "G" "T" "T" "T" "C"
[21] "T" "T" "T" "C" "T" "G" "G" "G" "T" "C" "T" "C" "T" "C"
这不是我想要的;我一次要三个字母:
This is not what I want; I want three letters at a time:
[1] "ATT" "TGG", "GCT"...............and so on the final may be of one, two or three letters depending upon the letter availability.
谢谢;
推荐答案
我假设您想使用密码子。如果是这种情况,您可能需要查看Bioconductor提供的Biostrings套件。它提供了用于处理生物序列数据的多种工具。
I assume you want to work with codons. If that's the case, you might want to look at the Biostrings package from Bioconductor. It provides a variety of tools for working with biological sequence data.
library(Biostrings)
?codons
只需一点笨拙的强制即可实现您想要的:
You can achieve what you want, with a little bit of clumsy coercion:
as.character(codons(DNAString(mycodes)))
这篇关于分为3个字符长度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文