public static void stream_align(FlaggableCharacterString input_stream,
    Vector<AlignmentTuple> alignments,
    Vector<AlignmentTriplet> triplets) {


for (AlignmentTuple alignment : alignments) {
    // copy strings
    FlaggableCharacterString presented = alignment.getPresented();
    FlaggableCharacterString trans = alignment.getTranscript();

    FlaggableCharacterString new_presented = new FlaggableCharacterString(presented);
    FlaggableCharacterString new_transcribed = new FlaggableCharacterString(trans);
    FlaggableCharacterString new_input_stream = new FlaggableCharacterString(input_stream);
    
    // align action of stream for aligned presented and transcribed
    for (int i = 0; i < Math.max(new_transcribed.size(),
	       new_input_stream.size()); i++) {
	
	// i < new_transcribed.size() and i < new_input_stream.size() not in pseudo code
	if (i < new_transcribed.size() && new_transcribed.charAt(i).getSymbol() == '-') {
	    Util.insertInto(new_input_stream, i, new FlaggableCharacter('_'));
	} else if ( i < new_input_stream.size() && !new_input_stream.get(i).isFlagged()) {
	    Util.insertInto(new_presented, i, new FlaggableCharacter('_'));
	    Util.insertInto(new_transcribed, i, new FlaggableCharacter('_'));
	}
	
    }
    triplets.add(new AlignmentTriplet(new_presented, new_transcribed, new_input_stream));
}
}