Commit 222f4622 authored by Holger Brandl's avatar Holger Brandl

migrated fasta utils

parent 627dc71f
#library(BiocGenerics, quietly=T, warn.conflicts=F )
#library(Biostrings, quietly=T)
#require.auto(BiocGenerics )x
require.auto(Biostrings)
read.fasta <- function(fileName){
## read a fasta file as data.fram
fastaData <- readBStringSet(fileName, "fasta")
# fastaDataDF <- as.data.frame(as.character(fastaData), stringsAsFactors=FALSE)
fastaDataDF <- data.frame(Sequence=as.character(fastaData), GeneDesc=names(fastaData), stringsAsFactors=FALSE)
rownames(fastaDataDF) <- NULL
# names(fastaDataDF)[1] <- "Sequence"
return(fastaDataDF)
}
getSeqLengthFromFasta <- function(fileName){
assembly <- mutate(read.fasta(fileName), seq_len=nchar(Sequence))
assembly$Sequence = NULL
return(assembly)
}
write.fasta <- function(seq_names, sequences, file){
fastaData <- AAStringSet(sequences)
names(fastaData) <- seq_names;
writeXStringSet(fastaData, file=file, format="fasta", width=80)
}
......@@ -191,17 +191,8 @@ trimEnd <-function(fileNames, exts=c()){
fileNames
}
chopFileExt <-function(fileNames, exts=c()){
warning("this method is deprecated. use trimEnd instead")
for(fileExt in exts){
fileNames <- str_replace(fileNames, paste(".", fileExt, "$",sep=""), "")
}
fileNames
}
write.delim <- function(df, header=TRUE,...){
write.table(df, row.names=FALSE, col.names=header, sep="\t", ...)
write.delim <- function(df, file, header=TRUE,...){
write.table(df, file, row.names=FALSE, col.names=header, sep="\t", ...)
}
## writes a table in bed format expecting columns being ordered according to bed spec already
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment