- Timestamp:
- 07/28/20 16:00:06 (4 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
framspy/FramsticksCLI.py
r1019 r1021 38 38 DISSIMIL_CMD = "dissimil" 39 39 DISSIMIL_FILE = "dissimilarity_matrix.tsv" # tab-separated values 40 ISVALID_CMD = " isvalid"40 ISVALID_CMD = "arevalid" 41 41 ISVALID_FILE = "validity.txt" 42 42 MUTATE_CMD = "mutate" … … 90 90 91 91 self.__readFromFramsCLIUntil("UserScripts.autoload") 92 print('Performing a basic test 1/ 3... ', end='')92 print('Performing a basic test 1/2... ', end='') 93 93 assert self.getSimplest("1") == "X" 94 94 print('OK.') 95 print('Performing a basic test 2/3... ', end='') 96 assert self.isValid("X[0:0]") is True 97 print('OK.') 98 print('Performing a basic test 3/3... ', end='') 99 assert self.isValid("X[0:0],") is False 95 print('Performing a basic test 2/2... ', end='') 96 assert self.isValid(["X[0:0],", "X[0:0]", "X[1:0]"]) == [False, True, False] 100 97 print('OK.') 101 98 if not self.DETERMINISTIC: … … 249 246 A square array with dissimilarities of each pair of genotypes. 250 247 """ 248 assert isinstance(genotype_list, list) # because in python str has similar capabilities as list and here it would pretend to work too, so to avoid any ambiguity 251 249 files = self.__runCommand(self.DISSIMIL_CMD, genotype_list, self.DISSIMIL_FILE, self.GENO_SAVE_FILE_FORMAT["NATIVEFRAMS"]) 252 250 with open(files[-1]) as f: … … 265 263 266 264 267 def isValid(self, genotype: str) -> bool: 268 files = self.__runCommand(self.ISVALID_CMD, [genotype], self.ISVALID_FILE, self.GENO_SAVE_FILE_FORMAT["RAWGENO"]) 269 with open(files[-1]) as f: 270 valid = f.readline() == "1" 271 self.__cleanUpCommandResults(files) 265 def isValid(self, genotype_list: List[str]) -> List[bool]: 266 assert isinstance(genotype_list, list) # because in python str has similar capabilities as list and here it would pretend to work too, so to avoid any ambiguity 267 files = self.__runCommand(self.ISVALID_CMD, genotype_list, self.ISVALID_FILE, self.GENO_SAVE_FILE_FORMAT["NATIVEFRAMS"]) 268 valid = [] 269 with open(files[-1]) as f: 270 for line in f: 271 valid.append(line.strip() == "1") 272 self.__cleanUpCommandResults(files) 273 assert len(genotype_list) == len(valid), "Submitted %d genotypes, received %d validity values" % (len(genotype_list), len(valid)) 272 274 return valid 273 275 … … 319 321 print('\tDissimilarity of Parent1 and Offspring:', framsCLI.dissimilarity([parent1, offspring])[0, 1]) 320 322 print('\tPerformance of Offspring:', framsCLI.evaluate(offspring)) 321 print('\tValidity of Offspring:', framsCLI.isValid(offspring))323 print('\tValidity of Parent1, Parent 2, and Offspring:', framsCLI.isValid([parent1, parent2, offspring])) 322 324 323 325 framsCLI.closeFramsticksCLI()
Note: See TracChangeset
for help on using the changeset viewer.