[Seqinr-forum] FASTA output splits into all headers then all sequences

Jean lobry lobry at biomserv.univ-lyon1.fr
Sat Feb 20 10:29:40 CET 2010


Hi Oliver and Lionel,

thanks for pointing and solving this bug.

>This is due to the fact that you have sequences that have only the
>same length. Thus, getSequence returns a matrix instead of a list,
>which confuses write.fasta.

Yes indeed !

>getSequence.list <- function (object, as.string = FALSE, ...) {
>     lapply(seq_len(length(object)), function(i) getSequence(object[[i]],
>       as.string = as.string, ...))
>}
>
>I don't have a patch to propose, but as a workaround, you can do the
>following:

Where did you get this version of getSequence.list() from? Because
this *** is *** the fix!!! The trouble comes from that in the
current version (2.0-7) sapply() is used instead of lapply():

>  getSequence.list
function (object, as.string = FALSE, ...)
sapply(seq_len(length(object)), function(i) getSequence(object[[i]],
     as.string = as.string, ...))

So that when all sequences have the same length sapply() returns
the result in a matrix form which confuses write.fasta().

A quick fix is then just to evaluate the lapply form:

###
getSequence.list <- function(object, as.string = FALSE, ...)
   lapply(seq_len(length(object)), function(i) getSequence(object[[i]],
   as.string = as.string, ...))
###

before calling getSequence().

I can't commit the fix right now because R-Forge is down, but the
problem will be corrected in seqinr release 2.0-8.

Best,

Z.


-- 
Jean R. Lobry            (lobry at biomserv.univ-lyon1.fr)
Laboratoire BBE-CNRS-UMR-5558, Univ. C. Bernard - LYON I,
43 Bd 11/11/1918, F-69622 VILLEURBANNE CEDEX, FRANCE
allo  : +33 472 43 27 56     fax    : +33 472 43 13 88
http://pbil.univ-lyon1.fr/members/lobry/




More information about the Seqinr-forum mailing list