rotary-genomics / rotary

Assembly/annotation workflow for Nanopore-based microbial genome data containing circular DNA elements
BSD 3-Clause "New" or "Revised" License
2 stars 1 forks source link

Refactor aggregate_contigs function in rotary.smk for readability. #72

Closed LeeBergstrand closed 4 months ago

LeeBergstrand commented 10 months ago

I already refactored this code a bit by pulling out the path below.

def aggregate_contigs(wildcards):
    # TODO - I do not further use this variable, but checkpoints needs to be called to trigger the checkpoint.
    # Am I doing something wrong?
    checkpoint_output = checkpoints.split_circular_and_linear_contigs.get(**wildcards).output[0]
    circularize_lists_path = f"{wildcards.sample}/circularize/filter/lists"

    return expand("{{sample}}/circularize/combine/{circular_or_linear}.fasta",
                  circular_or_linear=glob_wildcards(os.path.join(circularize_lists_path, "{i}.list")).i)

However, the glob wildcards bit should be pulled into its own variable and comments should be added to describe what is going on.

LeeBergstrand commented 10 months ago

@jmtsuji When you get a chance, can you refactor this so most of the code isn't being passed directly into the return value? When the paths to the lists were inside the os.path.join, I had much difficulty finding them when debugging.

jmtsuji commented 10 months ago

@LeeBergstrand OK, will take a look.

LeeBergstrand commented 4 months ago

Addressed in https://github.com/rotary-genomics/rotary/pull/149