def build_scaffolds(adjacencies, perm_container, debug_output, correct_distances): """ Assembles scaffolds wrt to inferred adjacencies """ if debug_output: logger.debug("Building scaffolds") contigs, contig_index = _make_contigs(perm_container) scaffolds = _extend_scaffolds(adjacencies, contigs, contig_index, correct_distances) num_contigs = sum([len(s.contigs) for s in scaffolds]) logger.debug("%d contigs were joined into %d scaffolds", num_contigs, len(scaffolds)) if debugger.debugging and debug_output: links_out = os.path.join(debugger.debug_dir, "scaffolder.links") output_links(scaffolds, links_out) contigs_out = os.path.join(debugger.debug_dir, "scaffolder_contigs.txt") output_permutations(perm_container.target_perms, contigs_out) perms_out = os.path.join(debugger.debug_dir, "scaffolder_scaffolds.txt") output_scaffolds_premutations(scaffolds, perms_out) return scaffolds
def merge_scaffolds(big_scaffolds, small_scaffolds, perm_container, rearrange): """ Merges scaffold sets from different iterations. If rearrangements are allowed, tries to keep some small-scale rearrangements from the weaker scaffold set. """ logger.info("Merging two iterations") #synchronizing scaffolds to the same permutations big_updated = _update_scaffolds(big_scaffolds, perm_container) small_updated = _update_scaffolds(small_scaffolds, perm_container) if rearrange: projector = RearrangementProjector(big_updated, small_updated, True) new_adj = projector.project() big_rearranged = build_scaffolds(new_adj, perm_container, False, False) else: big_rearranged = big_updated merged_scf = _merge_scaffolds(big_rearranged, small_updated) merged_scf = _merge_consecutive_contigs(merged_scf) if debugger.debugging: links_out = os.path.join(debugger.debug_dir, "merged.links") output_links(merged_scf, links_out) perms_out = os.path.join(debugger.debug_dir, "merged_scaffolds.txt") output_scaffolds_premutations(merged_scf, perms_out) return merged_scf
def merge_scaffolds(big_scaffolds, small_scaffolds, perm_container, rearrange, ancestral = False): """ Merges scaffold sets from different iterations. If rearrangements are allowed, tries to keep some small-scale rearrangements from the weaker scaffold set. """ logger.info("Merging two iterations") #synchronizing scaffolds to the same permutations big_updated = _update_scaffolds(big_scaffolds, perm_container, ancestral=ancestral) small_updated = _update_scaffolds(small_scaffolds, perm_container, ancestral=ancestral) if rearrange: projector = RearrangementProjector(big_updated, small_updated, True) new_adj = projector.project() big_rearranged = build_scaffolds(new_adj, perm_container, False, False, ancestral=ancestral) else: big_rearranged = big_updated merged_scf = _merge_scaffolds(big_rearranged, small_updated) merged_scf = _merge_consecutive_contigs(merged_scf) if debugger.debugging: links_out = os.path.join(debugger.debug_dir, "merged.links") output_links(merged_scf, links_out) perms_out = os.path.join(debugger.debug_dir, "merged_scaffolds.txt") output_scaffolds_premutations(merged_scf, perms_out) return merged_scf
def build_scaffolds(adjacencies, perm_container, debug_output=True, correct_distances=True, ancestral=False): """ Assembles scaffolds wrt to inferred adjacencies """ if debug_output: logger.info("Building scaffolds") if not ancestral: contigs, contig_index = _make_contigs(perm_container) else: contigs, contig_index = _make_contigs(perm_container, ancestral=ancestral) scaffolds = _extend_scaffolds(adjacencies, contigs, contig_index, correct_distances) num_contigs = sum(map(lambda s: len(s.contigs), scaffolds)) logger.debug("{0} contigs were joined into {1} scaffolds" .format(num_contigs, len(scaffolds))) if debugger.debugging and debug_output: links_out = os.path.join(debugger.debug_dir, "scaffolder.links") output_links(scaffolds, links_out) contigs_out = os.path.join(debugger.debug_dir, "scaffolder_contigs.txt") output_permutations(perm_container.target_perms, contigs_out) perms_out = os.path.join(debugger.debug_dir, "scaffolder_scaffolds.txt") output_scaffolds_premutations(scaffolds, perms_out) return scaffolds
def build_scaffolds(adjacencies, perm_container, debug_output=True, correct_distances=True, ancestral=False): """ Assembles scaffolds wrt to inferred adjacencies """ if debug_output: logger.info("Building scaffolds") if not ancestral: contigs, contig_index = _make_contigs(perm_container) else: contigs, contig_index = _make_contigs(perm_container, ancestral=ancestral) scaffolds = _extend_scaffolds(adjacencies, contigs, contig_index, correct_distances) num_contigs = sum(map(lambda s: len(s.contigs), scaffolds)) logger.debug("{0} contigs were joined into {1} scaffolds".format( num_contigs, len(scaffolds))) if debugger.debugging and debug_output: links_out = os.path.join(debugger.debug_dir, "scaffolder.links") output_links(scaffolds, links_out) contigs_out = os.path.join(debugger.debug_dir, "scaffolder_contigs.txt") output_permutations(perm_container.target_perms, contigs_out) perms_out = os.path.join(debugger.debug_dir, "scaffolder_scaffolds.txt") output_scaffolds_premutations(scaffolds, perms_out) return scaffolds