Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix #91 #92

Merged
merged 3 commits into from
Jan 21, 2021
Merged

Fix #91 #92

merged 3 commits into from
Jan 21, 2021

Conversation

bricoletc
Copy link
Collaborator

#91 spotted a problem with nested if/else conditionals for including config files. This showed the regexp
we had for spotting these conditionals was incomplete, which I fixed, with added unit test.

This part of the code, where python syntax is 'glued' with snakemake syntax, is tricky to get right- I anticipate more edge cases exist, but I think we should wait to see them in real files rather than try and anticipate them all.

Support consecutive, nested conditional statements
@codecov
Copy link

codecov bot commented Jan 19, 2021

Codecov Report

Merging #92 (2bf6f60) into master (50cb371) will decrease coverage by 0.10%.
The diff coverage is 75.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master      #92      +/-   ##
==========================================
- Coverage   98.18%   98.07%   -0.11%     
==========================================
  Files          11       11              
  Lines         882      884       +2     
  Branches      161      162       +1     
==========================================
+ Hits          866      867       +1     
- Misses          8        9       +1     
  Partials        8        8              
Flag Coverage Δ
unittests 98.07% <75.00%> (-0.11%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
snakefmt/formatter.py 99.00% <75.00%> (-0.50%) ⬇️

@bricoletc
Copy link
Collaborator Author

Update; #93 raises concerned related to this, which should be addressed in this PR too, will update it as explore fixes.

* Bugfix: properly deal with indentation of python code nested in
snakemake syntax
* Space out keywords when they come out of a nested python code context
* Nested, consecutive, identical keywords now not spaced out
Copy link
Member

@mbhall88 mbhall88 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Awesome work @bricoletc!

I agree, there are likely all sorts of weird edge cases, but worry about them when/if they arise.

@Smeds
Copy link

Smeds commented Jan 20, 2021

The latest commit gives me some strange results. Example

if config["programs"]["Trimming"] == "Cutadapt":

    include: "../rules/Fastq/Cutadapt_trimming.smk"


elif config["programs"]["Trimming"] == "Fastp":

    include: "../rules/Fastq/Fastp_trimming.smk"


else:

    include: "../rules/Fastq/move_fastq.smk"


# include: "../rules/CNV/ONCOCNV.smk"
# include: "../rules/CNV/cnvkit.smk"
# include: "../rules/QC/check_coverage.smk"
# include: "../rules/VCF_fix/Collect_results_DNA.smk" #Change folder!
# include: "../rules/Mutect2/Mutect2.smk"


if config["programs"]["Duplicates"] == "fgbio":

    include: "../rules/Alignment/fgbio.smk"


else:
    if config["programs"]["markduplicate"] == "GPU":

        include: "../rules/Alignment/GPU_alignment.smk"


    else:

        include: "../rules/Alignment/bwa-mem.smk"
        include: "../rules/Alignment/MarkDuplicates.smk"

Snakefmt wants to make the following modifications

  if config["programs"]["Trimming"] == "Cutadapt":
  
      include: "../rules/Fastq/Cutadapt_trimming.smk"
  
  
  elif config["programs"]["Trimming"] == "Fastp":
  
      include: "../rules/Fastq/Fastp_trimming.smk"
  
  
  else:
  
      include: "../rules/Fastq/move_fastq.smk"
  
  
- # include: "../rules/CNV/ONCOCNV.smk"
+     # include: "../rules/CNV/ONCOCNV.smk"
? ++++
- # include: "../rules/CNV/cnvkit.smk"
+     # include: "../rules/CNV/cnvkit.smk"
? ++++
- # include: "../rules/QC/check_coverage.smk"
+     # include: "../rules/QC/check_coverage.smk"
? ++++
- # include: "../rules/VCF_fix/Collect_results_DNA.smk" #Change folder!
+     # include: "../rules/VCF_fix/Collect_results_DNA.smk" #Change folder!
? ++++
- # include: "../rules/Mutect2/Mutect2.smk"
+     # include: "../rules/Mutect2/Mutect2.smk"
? ++++
  
  
- if config["programs"]["Duplicates"] == "fgbio":
+     if config["programs"]["Duplicates"] == "fgbio":
? ++++
  
      include: "../rules/Alignment/fgbio.smk"
  
  
  else:
      if config["programs"]["markduplicate"] == "GPU":
  
          include: "../rules/Alignment/GPU_alignment.smk"
  
  
      else:
  
          include: "../rules/Alignment/bwa-mem.smk"
          include: "../rules/Alignment/MarkDuplicates.smk"

Treat special edge case where comments follow snakemake directives
nested in python code.
@bricoletc
Copy link
Collaborator Author

bricoletc commented Jan 20, 2021

Nice edge case spotted @Smeds , here's commit 01c1f87 to fix that.

@Smeds
Copy link

Smeds commented Jan 21, 2021

Nice=)

@bricoletc bricoletc merged commit 01c1f87 into master Jan 21, 2021
@bricoletc bricoletc deleted the fix_91 branch January 21, 2021 15:14
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants