def SimpleFastaParser(handle):
 while True:
  line = handle.readline()
  if (line == ''):
   return
  if (line[0] == '>'):
   break
 while True:
  if (line[0] != '>'):
   raise ValueError("Records in Fasta files should start with '>' character")
  title = line[1:].rstrip()
  lines = []
  line = handle.readline()
  while True:
   if (not line):
    break
   if (line[0] == '>'):
    break
   lines.append(line.rstrip())
   line = handle.readline()
  (yield (title, ''.join(lines).replace(' ', '').replace('\r', '')))
  if (not line):
   return
 assert False, 'Should not reach this line'

def SimpleFastaParser ( handle ) : while True : line = handle . readline ( ) if ( line == '' ) : return if ( line [ 0 ] == '>' ) : break while True : if ( line [ 0 ] != '>' ) : raise ValueError ( "Records in Fasta files should start with '>' character" ) title = line [ 1 : ] . rstrip ( ) lines = [ ] line = handle . readline ( ) while True : if ( not line ) : break if ( line [ 0 ] == '>' ) : break lines . append ( line . rstrip ( ) ) line = handle . readline ( ) ( yield ( title , '' . join ( lines ) . replace ( ' ' , '' ) . replace ( '\r' , '' ) ) ) if ( not line ) : return assert False , 'Should not reach this line'
generator function to iterate over fasta records .