[Seqinr-forum] write.fasta() example

Leonor Palmeira mlpalmeira at ulg.ac.be
Thu Dec 16 14:36:29 CET 2010


In write.fasta(), the input must indeed be a list, but a list of 
sequences as a vector of single characters and not as strings. You 
therefore only have to do a small conversion of your data in order to 
achieve this:

newdata=lapply(seq(length(data$seq)), function(i) {s2c(data$seq[[i]])})

and then your write.fasta should work like a charm on your 'newdata' object.
Let us know if this doesn't solve your problem on both Linux and Windows.

Best,
Leonor.

On 16/12/10 14:22, Darren Obbard wrote:
> Hi!
>
> data<-read.alignment("file.fas",format="fasta")
> write.fasta(as.list(data$seq), data$nam, file.out="out_file.fas", open =
> "a", nbchar = 100)
> test<-scan("out_file.fas",what="character")
> nchar(test[3])==100
>
> The problem may be that the file already contains the \r's, and that
> this casues write.fasta to fail in its wrapping?
>
> linux is Ubuntu (lucid lynx)
>
> R version 2.12.0 (2010-10-15)
> Platform: x86_64-pc-linux-gnu (64-bit)
>
> locale:
> [1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C
> [3] LC_TIME=en_GB.UTF-8 LC_COLLATE=en_GB.UTF-8
> [5] LC_MONETARY=C LC_MESSAGES=en_GB.UTF-8
> [7] LC_PAPER=en_GB.UTF-8 LC_NAME=C
> [9] LC_ADDRESS=C LC_TELEPHONE=C
> [11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C
>
> attached base packages:
> [1] stats graphics grDevices utils datasets methods base
>
> other attached packages:
> [1] seqinr_2.0-9 ape_2.5-3 multicore_0.1-3
>
> loaded via a namespace (and not attached):
> [1] gee_4.13-14 grid_2.12.0 lattice_0.19-13 nlme_3.1-97
>
>
>

-- 
Leonor Palmeira, PhD

Phone: +32 4 366 42 69
Email: mlpalmeira AT ulg DOT ac DOT be
http://sites.google.com/site/leonorpalmeira

Immunology-Vaccinology, Bat. B43b
Faculty of Veterinary Medicine
Boulevard de Colonster, 20
University of Liege, B-4000 Liege (Sart-Tilman)
Belgium


More information about the Seqinr-forum mailing list