split_line = line.strip().split() if found_name_line: if len(split_line) != num_ind + 1: raise Exception locus = split_line[0] genotypes = split_line[1:num_ind + 1] genotypes_of_locus[locus] = genotypes else: if len(line.strip().split()) == num_ind + 1: individuals = line.strip().split()[1:num_ind + 1] found_name_line = True return(genotypes_of_locus) ini_map, num_loci_on_lg = parse_map_file("Y:\WORK\WAPLES\Stacks_mapping\Chum_data\mst\chum_08_iter0_mstmap.map", 'mst') genotypes_of_locus = parse_mst_map_infile("Y:\WORK\WAPLES\Stacks_mapping\Chum_data\mst\chum_08_iter0_mstmap.txt", 140) int_arr = convert_genotypes_to_int_array(genotypes_of_locus, ini_map) to_be_removed = 0 start_index = 0 end_index = 0 # What do we do if missing genotypes sit next to potential double crossovers? with open ('Y:\WORK\WAPLES\Stacks_mapping\pest_out.tsv', 'w') as OUTFILE: start_index = 0 end_index = 0 OUTFILE.write(("{}\t"*13+"\n").format("LG", "length", "end_index", "start_index", "current_LG.shape", "ind_count", "ind_genotypes", "nonzero_genotypes", "count_non_zero", "crossovers", "dbl_crossovers", "flag", "corrected_crossovers")) for LG, length in num_loci_on_lg.items(): end_index += length
chum_fams.write_Rqtl('CMUW10X_0008', 'Z:/HOME/Waples/Stacks_mapping/Chum_data/psv/chum_08_switched_3_Rqtl.txt', switched_mappable_3[0], switched_mappable_3[1]) chum_fams.write_mstmap('CMUW10X_0008', 'Z:/HOME/Waples/Stacks_mapping/Chum_data/psv/chum_08_switched_3_mstmap.txt', switched_mappable_3[0], switched_mappable_3[1]) # Go to Rqtl, rebuild linkage groups #Parameters genotypes_of_locus = switchAlleles.combine_mappable_loci(mappable) ini_map, loci_on_lg = switchAlleles.parse_map_file(linkage_map_file) int_arr = switchAlleles.convert_genotypes_to_int_array(genotypes_of_locus, ini_map) num_loci = int_arr.shape[0] num_pairs = int((num_loci * (num_loci-1))/2) pairs = itertools.combinations(int_arr, 2) #import timeit #timeit.timeit('next(switchAlleles.getR(pairs))', setup = "import switch_allele_functions as switchAlleles; from __main__ import int_arr; from __main__ import pairs", number = 100000) R = numpy.fromiter(switchAlleles.getR(pairs), dtype = numpy.float64, count = num_pairs) pairs = itertools.combinations(int_arr, 2) NR = numpy.fromiter(switchAlleles.getNR(pairs), dtype = numpy.float64, count = num_pairs)