INNER CODE UNIT · Python
index_for_dot
MariaNattestad/assemblytics · assemblytics/dot_prep.py:23
def index_for_dot(reference_lengths, fields_by_query, output_prefix, max_overview_alignments):
# Find the order of the reference chromosomes
reference_lengths.sort(key=lambda x: natural_key(x[0]))
# Find the cumulative sums
cumulative_sum = 0
ref_chrom_offsets = {}
queries_by_reference = {}
for ref,ref_length in reference_lengths:
ref_chrom_offsets[ref] = cumulative_sum
cumulative_sum += ref_length
queries_by_reference[ref] = set()
# Calculate relative positions of each alignment in this cumulative length, and take the median of these for each query, then sort the queries by those scores
flip_by_query = {}
unique_references_by_query = {} # for index, only unique alignments
all_references_by_query = {} # for index, including repetitive alignments