- Timestamp:
- 04/17/23 02:30:51 (21 months ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
framspy/FramsticksLib.py
r1218 r1220 41 41 42 42 def __init__(self, frams_path, frams_lib_name, sim_settings_files): 43 self.dissim_measure_density_distribution = None # will be initialized only when necessary (for rare dissimilarity methods) 44 43 45 if frams_lib_name is None: 44 46 frams.init(frams_path) # could add support for setting alternative directories using -D and -d … … 148 150 def dissimilarity(self, genotype_list: List[str], method: int) -> np.ndarray: 149 151 """ 150 :param method: -1 = genetic Levenshtein distance; 0, 1, 2 = phenetic dissimilarity (SimilMeasureGreedy, SimilMeasureHungarian, SimilMeasureDistribution) 152 :param method: -1 = genetic Levenshtein distance; 0, 1, 2 = phenetic dissimilarity (SimilMeasureGreedy, SimilMeasureHungarian, SimilMeasureDistribution); -2, -3 = phenetic density distribution (count, frequency). 153 See also prepareDissimilarityCalculation(). 151 154 :return: A square array with dissimilarities of each pair of genotypes. 152 155 """ … … 174 177 for j in range(n): # maybe calculate only one triangle if you really need a 2x speedup 175 178 square_matrix[i][j] = Levenshtein.distance(genotype_list[i], genotype_list[j]) 179 elif method in (-2, -3): 180 if self.dissim_measure_density_distribution is None: 181 from dissimilarity.densityDistribution import DensityDistribution 182 self.dissim_measure_density_distribution = DensityDistribution(frams) 183 self.dissim_measure_density_distribution.frequency = (method == -3) 184 square_matrix = self.dissim_measure_density_distribution.getDissimilarityMatrix(genotype_list) 176 185 else: 177 raise Exception("Don't know what to do with dissimilarity method = %d" % method)186 raise ValueError("Don't know what to do with dissimilarity method = %d" % method) 178 187 179 188 for i in range(n):
Note: See TracChangeset
for help on using the changeset viewer.