needle -filter

David Mathog mathog at mendel.bio.caltech.edu
Tue Jun 10 16:20:09 UTC 2003



> David Mathog wrote:
> 
> > Only the first character of that line, which is what I was
> > referring to in my earlier post.  If the input uses getc()
> > it can do an ungetc() at the second '>' and then exit.
> > The next "firstfasta" should pick up the same '>'
> > as its first character.  At least on Unix.  ungetc() isn't
> > the most portable of functions - but all the OS's I know
> > of allow it to be called at least once.  Just don't
> > expect to be able to call it a thousand times sequentially.
> 
> ... of course, I was carefully avoiding mention of GCG format which 
> ruins any plans to use ungetc :-)
> 
> ... and you can't seek back to the position in a pipe

Not directly.  But one can maintain inside getnextline()
a rollback buffer that stores the last N lines from fgets().
Reread lines from the rollback buffer instead of the
actual stream.  That will typically do the job so long
as the need to rollback is something reasonable, say, no
more than a couple of hundreds of lines.  Such a rollback
buffer will have a lot of advantages over unget() sorts
of functions.  For instance, one could drop in bookmarks
and start reading again from those positions.  More
importantly, it's completely portable.

Regards,

David Mathog
mathog at caltech.edu
Manager, Sequence Analysis Facility, Biology Division, Caltech



More information about the EMBOSS mailing list