write.fasta() fails when writing sequence with only one amino acid
The Rscript:
write.fasta(ids = fasta1$id,seqs=fasta1_alcol1,file=opt$out_fasta1)
works fine with multiple amino acid per sequence, but when there is only one amino acid per sequence, it gives an error:
Error in seqs[i, ] : incorrect number of dimensions Calls: write.fasta -> cat Execution halted
Is this a bug.
Comments (7)
-
-
Should work if you keep seqs as a matrix as Xinqiu suggests. drop=FALSE might be of help:
aln <- read.fasta(system.file("examples/hivp_xray.fa",package="bio3d")) write.fasta(ids=aln$id, seqs=aln$ali[,1, drop=FALSE], file="test.fasta")
I've noticed earlier that reading the same one-column fasta file causes an error though:
read.fasta("test.fasta") Error in `rownames<-`(`*tmp*`, value = c("d1hhp__", "d1nh0a_", "d1nh0b_", : length of 'dimnames' [1] not equal to array extent
-
The drop option is cool! Thanks Lars. read.fasta() really doesn't work with one-column fasta file. So let me fix it.
-
-
assigned issue to
-
assigned issue to
-
- changed status to resolved
fixed with latest commit
-
I have setup an Rscript so i dont always know if the fasta1_alcol1 will always have 1 column. So, i cant specify ncol=1. However, i did try with just
seqs=matrix(fasta1_alcol1)
but now its only writing one column even when there are multiples.
Thanks
-
Hi,
Try seqs=matrix(fasta1_alcol1, nrow=length(fasta1$id))
- Log in to comment
Hi,
Make sure your alignment is still a "matrix" even if there is only one residue in each sequence. Try
Let us know if it is still problem.