#BiocManager::install("Biostrings",force = TRUE)
library(Biostrings)
library(plyr)
fastaFile <- readBStringSet("D:/DATA/Homo_sapiens/Homo_sapiens.fasta",
? ? ? ? ? ? ? ? ? ? ? ? ? ? format="fasta")
? ? ? ? ? ? ? ? ? ? ? ? ? ? #nrec=-1L,
? ? ? ? ? ? ? ? ? ? ? ? ? ? #skip=0L,
? ? ? ? ? ? ? ? ? ? ? ? ? ? #seek.first.rec=FALSE,
? ? ? ? ? ? ? ? ? ? ? ? ? ? #use.names=FALSE)
test<-name[1,1]
#獲取名字id
name <- names(fastaFile) %>% as.data.frame()
#######################按"|"分割----
#############自定義函數(shù)
filler <- function(x){
? a <- strsplit(x,split = "|",fixed = T) %>% as.data.frame()##按"|"分割
? y <- a[5,]
? return(y)
}
#####應(yīng)用函數(shù)
results.list <- lapply(name$.,filler)
results.list <- unlist(results.list) %>% as.data.frame()
#######################按";"分割----
#############自定義函數(shù)
#results.list$.[1]
filler <- function(x){
? #x <- results.list$.[3]
? a <- strsplit(x,split = ";",fixed = T) %>% as.data.frame()##按";"分割
? y <- a[1,]
? return(y)
}
#####應(yīng)用函數(shù)
results <- lapply(results.list$.,filler)
results <- unlist(results) %>% as.data.frame()
results <- unique(results$.)
write.csv(results,"iuuCD.human.list.RDS")