def fragment_sequences(sequence, qualities, splitchar):
 if (len(sequence) != len(qualities)):
  print(sequence, qualities)
  raise RuntimeError("Internal error: length of sequence and qualities don't match???")
 retlist = []
 if (len(sequence) == 0):
  return retlist
 actseq = []
 actqual = []
 if (sequence[0] != splitchar):
  inseq = True
 else:
  inseq = False
 for (char, qual) in zip(sequence, qualities):
  if inseq:
   if (char != splitchar):
    actseq.append(char)
    actqual.append(qual)
   else:
    retlist.append((''.join(actseq), actqual))
    actseq = []
    actqual = []
    inseq = False
  elif (char != splitchar):
   inseq = True
   actseq.append(char)
   actqual.append(qual)
 if (inseq and len(actseq)):
  retlist.append((''.join(actseq), actqual))
 return retlist

def fragment_sequences ( sequence , qualities , splitchar ) : if ( len ( sequence ) != len ( qualities ) ) : print ( sequence , qualities ) raise RuntimeError ( "Internal error: length of sequence and qualities don't match???" ) retlist = [ ] if ( len ( sequence ) == 0 ) : return retlist actseq = [ ] actqual = [ ] if ( sequence [ 0 ] != splitchar ) : inseq = True else : inseq = False for ( char , qual ) in zip ( sequence , qualities ) : if inseq : if ( char != splitchar ) : actseq . append ( char ) actqual . append ( qual ) else : retlist . append ( ( '' . join ( actseq ) , actqual ) ) actseq = [ ] actqual = [ ] inseq = False elif ( char != splitchar ) : inseq = True actseq . append ( char ) actqual . append ( qual ) if ( inseq and len ( actseq ) ) : retlist . append ( ( '' . join ( actseq ) , actqual ) ) return retlist
works like split() on strings .