[Seqan-dev] file reader with standard input


Hi all,
   I am trying to use the SeqAn Fasta reading API to do a basic conversion of a Fasta file.  My listing compiles fine and works when run on a proper file.  However, when the Fasta file is passed via stdin (cin), I doesn't work.  My question is whether or not the reader API in file.h can work with standard in?  It seems like it should as cin can be treated as just an istream pointer...

I would be grateful for help, as I am sure there is a trivial solution.

$ cat faToTab.cpp

#include <iostream>
#include <fstream>
#include <cstdio>
#include <seqan/sequence.h>
#include <seqan/file.h>

using namespace std;
using namespace seqan;

int main(int argc, char* argv[])
{
    
    if (argc > 1) {
        ifstream faStream;
        faStream.open(argv[1], ios::in);
        if ( !faStream.is_open() ) {
    		cerr << "Error: The requested file (" << argv[1] << ") could not be opened. Exiting!" << endl;
    		exit (1);
    	}
    	else {
    	    String<char> name;
        	String<Dna5>  seq;
    	    while (!faStream.eof())
            {
                readMeta(faStream, name, Fasta());
                read(faStream, seq, Fasta());        
                cout << name << "\t" << seq << endl;
            }
    	}
    }
    else {
    	String<char> name;
    	String<Dna5>  seq;
	    while (cin)
        {
            readMeta(cin, name, Fasta());
            read(cin, seq, Fasta());        
            cout << name << "\t" << seq << endl;
        }
    }
}

$ faToTab test.fa 
1	GAGAGAG
2	AGGGAGGAGAGGACCC
	
$ cat test.fa | faToTab
?	

Best,
Aaron

Aaron Quinlan, Ph.D.
University of Virginia
Box 800717 
Charlottesville, VA  22908
(T) 434.243.1669  (F) 434.924.1312 
cphg.virginia.edu/quinlan
arq5x@virginia.edu