- 
                Notifications
    
You must be signed in to change notification settings  - Fork 4
 
Changes to report logic: STRY0017737 #188
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
          
     Open
      
      
            mattheww95
  wants to merge
  8
  commits into
  dev
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
QCMessageUpdate
  
      
      
   
  
    
  
  
  
 
  
      
    base: dev
Could not load branches
            
              
  
    Branch not found: {{ refName }}
  
            
                
      Loading
              
            Could not load tags
            
            
              Nothing to show
            
              
  
            
                
      Loading
              
            Are you sure you want to change the base?
            Some commits from the old base branch may be removed from the timeline,
            and old review comments may become outdated.
          
          
  
     Open
                    Changes from all commits
      Commits
    
    
            Show all changes
          
          
            8 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      5b19d46
              
                initial commit
              
              
                 c763092
              
                updated enum values
              
              
                 b550cdc
              
                added lib files
              
              
                 98935f8
              
                Merge branch 'dev' of github.com:phac-nml/mikrokondo into QCMessageUp…
              
              
                 a96c2d1
              
                upaded tests
              
              
                 5adcc7b
              
                renamed lib functions
              
              
                 13c26fa
              
                renamed class name in groovy module
              
              
                 e67cbdd
              
                made changes to reflect PR review comments
              
              
                 File filter
Filter by extension
Conversations
          Failed to load comments.   
        
        
          
      Loading
        
  Jump to
        
          Jump to file
        
      
      
          Failed to load files.   
        
        
          
      Loading
        
  Diff view
Diff view
There are no files selected for viewing
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,140 @@ | ||
| 
     | 
||
| class ReportFunctions { | ||
| 
     | 
||
| enum FuncType { | ||
| 
     | 
||
| GENERIC, | ||
| CONTIG, | ||
| READQUALITY, | ||
| AUTOFAIL, | ||
| COVERAGE | ||
| 
     | 
||
| } | ||
| 
     | 
||
| static def select_qc_func(java.util.LinkedHashMap qual_data, java.lang.String metric, java.util.ArrayList qc_message, java.util.LinkedHashMap meta_info, java.lang.String func) { | ||
| def check_failed = 0 | ||
| def reisolate = 0 | ||
| def resequence = 0 | ||
| def check_ignored = 0 | ||
| def failed_p = false | ||
| def checks = 0 | ||
| def function = func as FuncType | ||
| 
     | 
||
| switch (function) { | ||
| case FuncType.GENERIC: | ||
| (checks, | ||
| reisolate, | ||
| resequence, | ||
| failed_p, | ||
| check_failed, | ||
| check_ignored) = ReportFunctions.generic_qc_func(qual_data, metric, qc_message) | ||
| break | ||
| case FuncType.AUTOFAIL: | ||
| (checks, | ||
| reisolate, | ||
| resequence, | ||
| failed_p, | ||
| check_failed, | ||
| check_ignored) = ReportFunctions.autofail_reisolate(qual_data, metric, qc_message) | ||
| break | ||
| case FuncType.READQUALITY: | ||
| if (!meta_info.assembly) { | ||
| (checks, | ||
| reisolate, | ||
| resequence, | ||
| failed_p, | ||
| check_failed, | ||
| check_ignored) = ReportFunctions.generic_qc_func(qual_data, metric, qc_message) | ||
| } | ||
| break | ||
| case FuncType.COVERAGE: | ||
| if (!meta_info.assembly) { | ||
| (checks, | ||
| reisolate, | ||
| resequence, | ||
| failed_p, | ||
| check_failed, | ||
| check_ignored) = ReportFunctions.generic_qc_func(qual_data, metric, qc_message) | ||
| if (!failed_p && meta_info.downsampled) { | ||
| qc_message.add('The sample may have been downsampled too aggressively, if this is the cause please re-run sample with a different target depth.') | ||
| } | ||
| } | ||
| break | ||
| case FuncType.CONTIG: | ||
| (checks, | ||
| reisolate, | ||
| resequence, | ||
| failed_p, | ||
| check_failed, | ||
| check_ignored) = ReportFunctions.contig_qc_func(qual_data, metric, qc_message) | ||
| break | ||
| default: | ||
| throw NoSuchMethodExeption("No function for $func exists.") | ||
| } | ||
| 
     | 
||
| return [checks, reisolate, resequence, failed_p, check_failed, check_ignored] | ||
| } | ||
| 
     | 
||
| static def contig_qc_func(java.util.LinkedHashMap qual_data, java.lang.String metric, java.util.ArrayList qc_message) { | ||
| def checks_failed = 0 | ||
| def reisolate = 0 | ||
| def resequence = 0 | ||
| def checks_ignored = 0 | ||
| def failed_p = false | ||
| def checks = 0 | ||
| 
     | 
||
| if (qual_data && qual_data.containsKey(metric) && !qual_data[metric].status) { | ||
| checks_failed = 1 | ||
| failed_p = true | ||
| }else if (qual_data && (!qual_data.containsKey(metric) || !qual_data[metric].status)) { | ||
| checks_ignored = 1 | ||
| }else if (qual_data == null) { | ||
| checks_ignored = 1 | ||
| } | ||
| checks += 1 | ||
| return [checks, reisolate, resequence, failed_p, checks_failed, checks_ignored] | ||
| } | ||
| 
     | 
||
| static def generic_qc_func(java.util.LinkedHashMap qual_data, java.lang.String metric, java.util.ArrayList qc_message) { | ||
| def reisolate = 0 | ||
| def resequence = 0 | ||
| def failed_p = false | ||
| def checks_failed = 0 | ||
| def checks_ignored = 0 | ||
| def checks = 0 | ||
| if (qual_data && qual_data.containsKey(metric) && !qual_data[metric].status) { | ||
| reisolate = 1 | ||
| resequence = 1 | ||
| failed_p = true | ||
| checks_failed = 1 | ||
| }else if (qual_data && (!qual_data.containsKey(metric) || !qual_data[metric].status)) { | ||
| checks_ignored = 1 | ||
| }else if (qual_data == null) { | ||
| checks_ignored = 1 | ||
| } | ||
| checks += 1 | ||
| return [checks, reisolate, resequence, failed_p, checks_failed, checks_ignored] | ||
| } | ||
| 
     | 
||
| static def autofail_reisolate(java.util.LinkedHashMap qual_data, java.lang.String metric, java.util.ArrayList qc_message) { | ||
| def reisolate = 0 | ||
| def resequence = 0 | ||
| def failed_p = false | ||
| def checks_failed = 0 | ||
| def checks_ignored = 0 | ||
| def checks = 0 | ||
| if (qual_data && qual_data.containsKey(metric) && !qual_data[metric].status) { | ||
| reisolate = 1 | ||
| resequence = 1 | ||
| failed_p = true | ||
| checks_failed = 1 | ||
| }else if (qual_data && (!qual_data.containsKey(metric) || !qual_data[metric].status)) { | ||
| checks_ignored = 1 | ||
| }else if (qual_data == null) { | ||
| checks_ignored = 1 | ||
| } | ||
| checks += 1 | ||
| return [checks, reisolate, resequence, failed_p, checks_failed, checks_ignored] | ||
| } | ||
| 
     | 
||
| } | ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| 
          
            
          
           | 
    @@ -6,7 +6,6 @@ import groovy.json.JsonSlurper | |
| import groovy.json.JsonBuilder | ||
| import java.nio.file.Paths | ||
| 
     | 
||
| 
     | 
||
| process REPORT{ | ||
| tag "Report Generation" | ||
| label "process_single" | ||
| 
          
            
          
           | 
    @@ -152,7 +151,7 @@ def n50_nrcontigs_decision(qual_data, nr_cont_p, n50_p, qual_message, reisolate, | |
| */ | ||
| 
     | 
||
| if(nr_cont_p && n50_p){ | ||
| // both fialed :( | ||
| // both failed :( | ||
| if(qual_data && qual_data.containsKey("nr_contigs") && qual_data.nr_contigs.low){ | ||
| if(qual_data.n50_value.low){ | ||
| 
     | 
||
| 
          
            
          
           | 
    @@ -267,94 +266,33 @@ def create_action_call(sample_data, species_tag){ | |
| } | ||
| 
     | 
||
| def qual_message = [] | ||
| def failed_p = false | ||
| //def failed_p = false | ||
| 
         There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. If this is now unused could you remove it.  | 
||
| def checks_failed = 0 | ||
| def checks = 0 | ||
| def checks_ignored = 0 | ||
| def n50_failed = false | ||
| def nr_contigs_failed = false | ||
| 
     | 
||
| 
     | 
||
| for(qc_report_field in params.QCReportFields){ | ||
| 
     | 
||
| // ! TODO Summing of ignored checks is messy and the logic can likely be cleaned up | ||
| if(qual_data && qual_data.containsKey("checkm_contamination") && !qual_data.checkm_contamination.status){ | ||
| reisolate = reisolate + contamination_fail | ||
| resequence += 1 | ||
| failed_p = true | ||
| checks_failed += 1 | ||
| }else if (qual_data && (!qual_data.containsKey("checkm_contamination") || !qual_data.checkm_contamination.status)){ | ||
| checks_ignored += 1 | ||
| }else if(qual_data == null){ | ||
| checks_ignored += 1 | ||
| } | ||
| checks += 1 | ||
| 
     | 
||
| if(!meta_data.assembly){ | ||
| // We should have reads as we assembled it | ||
| if(qual_data && qual_data.containsKey("raw_average_quality") && !qual_data.raw_average_quality.status){ | ||
| resequence += 1 | ||
| checks_failed += 1 | ||
| }else if (qual_data && (!qual_data.containsKey("raw_average_quality") || !qual_data.raw_average_quality.status)){ | ||
| checks_ignored += 1 | ||
| }else if(qual_data == null){ | ||
| checks_ignored += 1 | ||
| } | ||
| checks += 1 | ||
| 
     | 
||
| if(qual_data && qual_data.containsKey("average_coverage") && !qual_data.average_coverage.status){ | ||
| 
     | 
||
| if(meta_data.downsampled){ | ||
| qual_message.add("The sample may have been downsampled too aggressively, if this is the cause please re-run sample with a different target depth.") | ||
| if(qc_report_field.value.on){ | ||
| // Need to figure out how to handle the requirement of a category requiring reads... | ||
| // number is too hight as not excluding read checks | ||
| def (checked, rei, res, fail_p, chck_f, chck_i) = ReportFunctions.select_qc_func(qual_data, qc_report_field.key, qual_message, meta_data, qc_report_field.value.qc_func) | ||
| //reisolate = rei + contamination_fail | ||
| checks_failed += chck_f | ||
| resequence += res | ||
| failed_p = fail_p | ||
| if(failed_p && qc_report_field.value.qc_func as ReportFunctions.FuncType == ReportFunctions.FuncType.AUTOFAIL){ | ||
| reisolate = rei + contamination_fail | ||
| } | ||
| checks_failed += 1 | ||
| resequence += 1 | ||
| }else if(qual_data && (!qual_data.containsKey("average_coverage") || !qual_data.average_coverage.status)){ | ||
| checks_ignored += 1 | ||
| }else if(qual_data == null){ | ||
| checks_ignored += 1 | ||
| checks_ignored += chck_i | ||
| checks += checked | ||
| } | ||
| checks += 1 | ||
| } | ||
| 
     | 
||
| if(qual_data && qual_data.containsKey("length") && !qual_data.length.status){ | ||
| if(qual_data.length.low){ | ||
| resequence += 1 | ||
| checks_failed += 1 | ||
| }else{ | ||
| resequence += 1 | ||
| reisolate = reisolate + contamination_fail | ||
| checks_failed += 1 | ||
| } | ||
| }else if (qual_data && (!qual_data.containsKey("length") || !qual_data.length.status)){ | ||
| checks_ignored += 1 | ||
| }else if(qual_data == null){ | ||
| checks_ignored += 1 | ||
| } | ||
| checks += 1 | ||
| 
     | 
||
| if(qual_data && qual_data.containsKey("nr_contigs") && !qual_data.nr_contigs.status){ | ||
| checks_failed += 1 | ||
| nr_contigs_failed = true | ||
| }else if (qual_data && (!qual_data.containsKey("nr_contigs") || !qual_data.nr_contigs.status)){ | ||
| checks_ignored += 1 | ||
| }else if(qual_data == null){ | ||
| checks_ignored += 1 | ||
| } | ||
| checks += 1 | ||
| 
     | 
||
| if(qual_data && qual_data.containsKey("n50_value") && !qual_data.n50_value.status){ | ||
| checks_failed += 1 | ||
| n50_failed = true | ||
| }else if (qual_data && (!qual_data.containsKey("n50_value") || !qual_data.n50_value.status)){ | ||
| checks_ignored += 1 | ||
| }else if(qual_data == null){ | ||
| checks_ignored += 1 | ||
| } | ||
| checks += 1 | ||
| 
     | 
||
| 
     | 
||
| (reisolate, resequence) = n50_nrcontigs_decision(qual_data, nr_contigs_failed, n50_failed, qual_message, reisolate, resequence) | ||
| //qual_message.add("Quality Conclusion") | ||
| 
     | 
||
| add_secondary_message(params.assembly_status.report_tag, | ||
| "Assembly failed, this may be an issue with your data or the pipeline. Please check the log or the outputs in the samples work directory.", | ||
| 
          
            
          
           | 
    ||
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  
    
      This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
      Learn more about bidirectional Unicode characters
    
  
  
    
              
  Add this suggestion to a batch that can be applied as a single commit.
  This suggestion is invalid because no changes were made to the code.
  Suggestions cannot be applied while the pull request is closed.
  Suggestions cannot be applied while viewing a subset of changes.
  Only one suggestion per line can be applied in a batch.
  Add this suggestion to a batch that can be applied as a single commit.
  Applying suggestions on deleted lines is not supported.
  You must change the existing code in this line in order to create a valid suggestion.
  Outdated suggestions cannot be applied.
  This suggestion has been applied or marked resolved.
  Suggestions cannot be applied from pending reviews.
  Suggestions cannot be applied on multi-line comments.
  Suggestions cannot be applied while the pull request is queued to merge.
  Suggestion cannot be applied right now. Please check back later.
  
    
  
    
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could you add a
defaultcase here that raises an exception about an invalid FuncType (though I suspect you would likely also get an exception raised when casting the string to the enum FuncType anyways).There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
fixed in: e67cbdd