Exemplo n.º 1
0
 def test_nearest_neighbor_in_sorted_arrays(self):
     a = np.sort(np.unique(np.random.randint(1000, size=120)))
     b = np.sort(np.unique(np.random.randint(1000, size=150)))
     actual = list(util.nearest_neighbor_in_sorted_arrays(a, b))
     expected = [np.abs(a - x).argmin() for x in b]
     assert_equal(actual, expected,
                  'Wrong nearest neighbor location in sorted arrays')
Exemplo n.º 2
0
def calculate_genetic_positions(map_file, snps):
    '''Calculate the closest genetic positions to a list of SNP bp''s on a chromosome in the
    chromosomal genetic map file map_file, and update the SNP database with those positions.'''
    positions = np.loadtxt(map_file, skiprows=1, usecols=[1, 3], dtype=np.float)
    bp, genetic = positions[:, 0], positions[:, 1]
    closest_bp = list(util.nearest_neighbor_in_sorted_arrays(bp, [x.bp for x in snps]))
    for i, x in enumerate(snps): x.genetic_pos = genetic[closest_bp[i]]
    snp_dao.save(snps)
Exemplo n.º 3
0
def calculate_genetic_positions(map_file, snps):
    '''Calculate the closest genetic positions to a list of SNP bp''s on a chromosome in the
    chromosomal genetic map file map_file, and update the SNP database with those positions.'''
    positions = np.loadtxt(map_file,
                           skiprows=1,
                           usecols=[1, 3],
                           dtype=np.float)
    bp, genetic = positions[:, 0], positions[:, 1]
    closest_bp = list(
        util.nearest_neighbor_in_sorted_arrays(bp, [x.bp for x in snps]))
    for i, x in enumerate(snps):
        x.genetic_pos = genetic[closest_bp[i]]
    snp_dao.save(snps)
Exemplo n.º 4
0
 def test_nearest_neighbor_in_sorted_arrays(self):
     a = np.sort(np.unique(np.random.randint(1000, size=120)))
     b = np.sort(np.unique(np.random.randint(1000, size=150)))
     actual = list(util.nearest_neighbor_in_sorted_arrays(a, b))
     expected = [np.abs(a - x).argmin() for x in b]
     assert_equal(actual, expected, 'Wrong nearest neighbor location in sorted arrays')