1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47
|
// PatMaN DNA pattern matcher
// (C) 2007 Kay Pruefer, Udo Stenzel
//
// This program is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or (at
// your option) any later version. See the LICENSE file for details.
#include "fasta.h"
using namespace std ;
fasta* fasta_fac::get( )
{
string headline ;
fasta* ret = new fasta ;
ret->null = 0 ;
// headline
getline( in, ret->headerline ) ;
line++ ;
if ( ret->headerline[0] != '>' ) {
if ( !in.eof() ) cerr << "No headerline in fasta file at line " << line << endl ;
ret->null = 1 ;
return ret ;
} else {
// cut the '>' in headerline
ret->headerline = ret->headerline.substr( 1, ret->headerline.size()-1 ) ;
// read the sequence
// handles eof, \n and '>', everything else is
// considered part of the sequence.
int i ;
while ( (i = in.get()) && in.good() ) {
if ( i == '>' ) {
in.putback( i ) ;
return ret ;
} else {
// add to seq ;
if ( i != '\n' )
ret->seq += static_cast<char>(i) ;
else
line++ ;
}
}
return ret ;
}
}
|