def main(): logging.basicConfig(filename='GeniToools.log', level=logging.INFO) logging.info('Starting GeniTools\n' + "=" * 20 + "\n") #Firstly the Input File is Read data = reader_input.reader_input("INPUT") base_call = geni_calls(data.genikey) if (data.continue_execution and base_call.check_valid_genikey()): #We only continue if inputs are correct! test_profile = profile.profile(data.profile, data.genikey) if (data.climbancestors or data.climbcousins): climber = climb(test_profile) if (data.climbcousins): ancestors, matrix_count, included_profiles = climber.get_cousins( data.generations) print(matrix_count) if (data.climbancestors): ancestors, affected_profiles = climber.get_ancestors( data.generations) else: logging.error(ERROR_MISSING_DATA) logging.info('Finishing GeniTools' + "=" * 20 + "\n")
def testCousinsExecution(self): ''' We will test the cousins execution in different way. Will be tested by number, not by person ''' philip = profile(COUSIN_PROFILE) generations = 2 climber = climb(philip) ancestors, anc_count, profiles = climber.get_cousins(generations) total_center = 0 total_outside = 0 for i in range(0, generations+1): total_center = total_center + anc_count[i][i] for j in range(i+1, generations + 1): total_outside = total_outside + anc_count[i][j] assert(total_center == 7) assert(total_outside == 0) total_final = 0 for i in range(0, generations+1): for j in range(0, generations + 1): total_final = total_final + anc_count[i][j] assert(total_final == 36) assert(len(profiles) == 36)
def testCousinsExecution(self): ''' We will test the cousins execution in different way. Will be tested by number, not by person ''' #Database creation geni_db = geni_database_interface() philip = profile(COUSIN_PROFILE) generations = 2 climber = climb(geni_db) ancestors, anc_count, profiles = climber.get_cousins(philip, generations) total_center = 0 total_outside = 0 for i in range(0, generations+1): total_center = total_center + anc_count[i][i] for j in range(i+1, generations + 1): total_outside = total_outside + anc_count[i][j] assert(total_center == 7) assert(total_outside == 0) total_final = 0 #We are counting here the number of cousing of the generation selected. #However, I noticed that this number varies... I selected an historical person #Philip IV of Spain, but apparently hundreds of years after... still new cousins appear. #TODO: fix this with a more stable profile, potentially from sandbox. for i in range(0, generations+1): for j in range(0, generations + 1): total_final = total_final + anc_count[i][j] assert(total_final == 32) assert(len(profiles) == 32)
def test_using_roots_magic(self): ''' Test using climber with RootsMagic database ''' file_rm = os.path.join(self.filelocation, "Rootstest.rmgc") rm_db = database_rm(file_rm) #We create the climber with the RM database climber = climb(rm_db) prof = rm_db.get_profile_by_ID(1)
def testStopWithNoAncestors(self): ''' If there are no longer ancestors, the ancestor climb should stop. Checking if that works! This profile has only one generation available ''' flavia = profile(FLAVIAg) climber = climb(flavia) ancestors = climber.get_ancestors(6) assert(len(ancestors) == 2)
def testStopWithNoAncestors(self): ''' If there are no longer ancestors, the ancestor climb should stop. Checking if that works! This profile has only one generation available ''' #Database creation geni_db = geni_database_interface() flavia = profile(FLAVIAg) climber = climb(geni_db) ancestors = climber.get_ancestors(flavia, 6) assert(len(ancestors) == 2)
def testCountingOfAncestors(self): ''' Testing the right calculation of ancestors. We know Philip IV was having duplicated ancestors, so the number will be lower than the generation count. ''' #Database creation geni_db = geni_database_interface() philip = profile(PHILIPIVg) climber = climb(geni_db) ancest = climber.get_ancestors(philip, 4) assert (len(ancest[1].keys()) == 23)
def testCountingOfAncestors(self): ''' Testing the right calculation of ancestors. We know Philip IV was having duplicated ancestors, so the number will be lower than the generation count. ''' philip = profile(PHILIPIVg) climber = climb(philip) ancestors, profiles = climber.get_ancestors(4) i = 0 for generation in ancestors: i = i + len(generation.values()) assert(i == 23) assert(len(profiles) == 23)
def test_using_roots_magic(self): ''' Test using climber with RootsMagic database ''' file_rm = os.path.join(self.filelocation, "Rootstest.rmgc") rm_db = database_rm(file_rm) #We create the climber with the RM database climber = climb(rm_db) prof = rm_db.get_profile_by_ID(1) #We execute the ancestors ancestors, data_gen = climber.get_ancestors(prof, 4) i = 0 for generation in ancestors: i = i + len(generation) assert (i == 7) total = 0 for id_value in data_gen.values(): total += id_value assert (total == 3.0) cousins, cousins_count, profiles_score = climber.get_cousins(prof, 2) assert (cousins[2][2] == [4, 5, 8]) assert (cousins_count[2][1] == 1) assert (sum(list(profiles_score.values())) == 3.5)