def lkh_assemble(reads: List[Tuple[str, str]], scores: np.ndarray) -> Tuple[ List[str], float, int]: """ starting lkh run (i.e. calling make_new_lkh_run) parses the output tour and creates a List[Node] which is used for the assemble_tour method to assemble the contigs :param reads: :param scores: :return: """ filtered_reads_lengths = [len(x[1]) for i, x in enumerate(reads)] read_strings = [x[1] for i, x in enumerate(reads)] manipulated_scores = manipulate_scores2atsp(scores, filtered_reads_lengths) create_full_atsp_via_scores('/home/andreas/GDrive/workspace/atspsa/footest', manipulated_scores) start_time_tsp = time.time() run_lkh('/home/andreas/GDrive/workspace/atspsa/footest.par') end_time_tsp = time.time() tour = parser.parse_tour('/home/andreas/GDrive/workspace/atspsa/footest.tour') with open('/home/andreas/GDrive/workspace/atspsa/footest.tour', 'r') as f: tsp_value = int( [x.split('COMMENT : Length = ')[1] for x in f.readlines() if x.startswith('COMMENT : Length = ')][0]) - sum( filtered_reads_lengths) tsp_contigs = assemble_tour(scores, read_strings, tour) print(tsp_contigs) # compare_tours(tour, scores) print(end_time_tsp - start_time_tsp) return tsp_contigs, end_time_tsp - start_time_tsp, tsp_value
def make_new_lkh_run(filename: str, scores: np.ndarray, circular=False) -> None: #TODO delete? """ creates files for and runs LKH :param filename: :param scores: :param circular: :return: """ create_full_atsp_via_scores_with_big_M(filename, scores, circular) run_lkh(filename + '.par') return