It's not clear to me what you are trying to do here with the chan, it
really isn't necessary (the Writers are non-blocking within reason).
However, the cause of the problem is that you are treating the
reference as a text object, and this is not consistent with how BAM
work. The sam.Record holds a pointer to the sam.Reference. You create a
bam.Writer that knows about the reference created in the main func, but
then create another sam.Reference in Align - these have the same
characteristics, but are not the same reference.
I suspect that if this were written more naturally, you would not have
made this mistake.
Dan