FU Logo
  • Startseite
  • Kontakt
  • Impressum
  • Home
  • Listenauswahl
  • Anleitungen

[Seqan-dev] file reader with standard input

<-- thread -->
<-- date -->
  • From: Aaron Quinlan <aaronquinlan@gmail.com>
  • To: seqan-dev@lists.fu-berlin.de
  • Date: Wed, 9 Mar 2011 20:59:48 -0500
  • Domainkey-signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=from:content-type:content-transfer-encoding:subject:date:message-id :to:mime-version:x-mailer; b=yFhi/7Jpe/0d4o5AStYlubwE55ZbLZ7DLII1RSiiz3BxJx3pgBPrGRSMUJLs/YAQ6R iuUn4XrQhQo0PKjBZYL1q5LVjr7linuKAOLpzFog9S1xxzP6A6uutzstirz0yJfo0bGv cg8HFSpEKT8bIi3kIG1nP/mg1FXKNnUXKLMjg=
  • Reply-to: SeqAn Development <seqan-dev@lists.fu-berlin.de>
  • Subject: [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





<-- thread -->
<-- date -->
  • Follow-Ups:
    • Re: [Seqan-dev] file reader with standard input
      • From: "Holtgrewe, Manuel" <manuel.holtgrewe@fu-berlin.de>
  • seqan-dev - March 2011 - Archives indexes sorted by:
    [ thread ] [ subject ] [ author ] [ date ]
  • Complete archive of the seqan-dev mailing list
  • More info on this list...

Hilfe

  • FAQ
  • Dienstbeschreibung
  • ZEDAT Beratung
  • postmaster@lists.fu-berlin.de

Service-Navigation

  • Startseite
  • Listenauswahl

Einrichtung Mailingliste

  • ZEDAT-Portal
  • Mailinglisten Portal