def write_read_list(readset, bipartition, sample_components,
    numeric_sample_ids, output_file):
    """
	Write a list of reads that has been used for phasing to given file object.
	readset -- core.ReadSet object with reads to be written
	bipartition -- bipartition of reads, i.e. iterable with one entry from {0,1} for each read in readset
	sample_components -- a dictionary that maps each sample to its connected components

			Each component in turn is a dict that maps each variant position to a
			component, where a component is identified by the position of its
			left-most variant

	numeric_sample_ids -- core.NumericSampleIds object mapping sample names to numeric ids as stored in each read
	output_file -- file object to write to
	"""
    assert len(readset) == len(bipartition)
    numeric_id_to_name = numeric_sample_ids.inverse_mapping()
    for read, haplotype in zip(readset, bipartition):
        sample = numeric_id_to_name[read.sample_id]
        components = sample_components[sample]
        phaseset = components[read[0].position] + 1
        print(read.name, read.source_id, sample, phaseset, haplotype, len(
            read), read[0].position + 1, read[-1].position + 1, file=
            output_file)
