Skip to content

Issue with rewind when passing input through a non-seekable stream - #10

Open
WildBunnie wants to merge 1 commit into
cobilab:masterfrom
WildBunnie:rewind-issue
Open

Issue with rewind when passing input through a non-seekable stream#10
WildBunnie wants to merge 1 commit into
cobilab:masterfrom
WildBunnie:rewind-issue

Conversation

@WildBunnie

@WildBunnie WildBunnie commented Jul 13, 2026

Copy link
Copy Markdown

The parser currently uses the rewind function to go back to the start of a stream, for example in the FileType function. This works correctly when passing the input through stdin using a file stream:

bin $ ./gto_fasta_complement < input
>seq
AACGTGACTGGACTTCAGAACCTCATACTGGCGCCGAGCCGAGATAGCTTGCGAGCTAGATCGCGATATCCACCACGGCTTCCGCCAGACAGCAGCAT

The problem is that when we pass it through a pipe or any other non-seekable stream it is unable to go back to the start causing, in the case of FileType, the first character to disappear:

bin $ cat input | ./gto_fasta_complement
seq
AACGTGACTGGACTTCAGAACCTCATACTGGCGCCGAGCCGAGATAGCTTGCGAGCTAGATCGCGATATCCACCACGGCTTCCGCCAGACAGCAGCAT

I'm currently using GTO inside the browser through WebAssembly as part of the BioChef project, and the stdin is also passed in an non-seekable way, which causes the problem mentioned above. This pull request aims to fix this by using ungetc to put the character back in the buffer instead of using rewind. This fix solved this specific problem for me but I only tested it for this specific use case, so I'm guessing the other places that use rewind will also have the same problem.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant