- 
                Notifications
    You must be signed in to change notification settings 
- Fork 45
Added hisat2 component #213
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
      
      
            PhilPalmer
  wants to merge
  3
  commits into
  master
  
    
      
        
          
  
    
      Choose a base branch
      
     
    
      
        
      
      
        
          
          
        
        
          
            
              
              
              
  
           
        
        
          
            
              
              
           
        
       
     
  
        
          
            
          
            
          
        
       
    
      
from
jackson-labs
  
      
      
   
  
    
  
  
  
 
  
      
    base: master
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
          
          
            3 commits
          
        
        Select commit
          Hold shift + click to select a range
      
      
    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
    
  
  
    
              
  
    
      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
    
  
  
    
              | Original file line number | Diff line number | Diff line change | 
|---|---|---|
| @@ -0,0 +1,84 @@ | ||
| if (params.reference{{ param_id }}) { | ||
| Channel | ||
| .fromPath("${params.reference{{ param_id }}}.fasta") | ||
| .ifEmpty { exit 1, "FASTA annotation file not found: ${params.reference{{ param_id }}}" } | ||
| .set { hisat2Fasta_{{pid}} } | ||
| } else if (params.hisat2_index{{ param_id }}) { | ||
| Channel | ||
| .fromPath(params.hisat2_index{{ param_id }}) | ||
| .ifEmpty { exit 1, "Folder containing Hisat2 indexes for reference genome not found: ${params.hisat2_index{{ param_id }}}" } | ||
| .set { hisat2Index_{{pid}} } | ||
| hisat2IndexName_{{pid}} = Channel.value( "${params.hisat2_index_name{{ param_id }}}" ) | ||
| } else { | ||
| exit 1, "Please specify either `--reference /path/to/file_basename` OR `--hisat2_index /path/to/hisat2_index_folder` AND `--hisat2_index_name hisat2_index_folder/basename`" | ||
| } | ||
|  | ||
| if (!params.hisat2_index{{ param_id }}) { | ||
| process make_hisat2_index_{{ pid }} { | ||
|  | ||
| {% include "post.txt" ignore missing %} | ||
| tag "$fasta" | ||
|  | ||
| input: | ||
| each file(fasta) from hisat2Fasta_{{pid}} | ||
|  | ||
| output: | ||
| val "hisat2_index/${fasta.baseName}.hisat2_index" into hisat2IndexName_{{pid}} | ||
| file "hisat2_index" into hisat2Index_{{pid}} | ||
|  | ||
| """ | ||
| mkdir hisat2_index | ||
| hisat2-build -p ${task.cpus} $fasta hisat2_index/${fasta.baseName}.hisat2_index | ||
| """ | ||
| } | ||
| } | ||
|  | ||
| process hisat2_{{ pid }} { | ||
|  | ||
| {% include "post.txt" ignore missing %} | ||
| tag "$sample_id" | ||
|  | ||
| input: | ||
| set sample_id, file(fastq_pair) from {{ input_channel }} | ||
| each index_name from hisat2IndexName_{{pid}} | ||
| each file(index) from hisat2Index_{{pid}} | ||
|  | ||
| output: | ||
| set sample_id, file("${sample_id}.sam") into hisat2Sam_{{pid}} | ||
| {% with task_name="hisat2" %} | ||
| {%- include "compiler_channels.txt" ignore missing -%} | ||
| {% endwith %} | ||
|  | ||
| """ | ||
| hisat2 \ | ||
| -p ${task.cpus} \ | ||
| -x $index_name \ | ||
| -1 ${fastq_pair[0]} \ | ||
| -2 ${fastq_pair[1]} \ | ||
| -S ${sample_id}.sam | ||
| """ | ||
| } | ||
|  | ||
| process samtools_sort_{{ pid }} { | ||
|  | ||
| {% include "post.txt" ignore missing %} | ||
| publishDir "results/mapping/hisat2_{{ pid }}" | ||
| tag "$sample_id" | ||
|  | ||
| input: | ||
| set sample_id, file(sam) from hisat2Sam_{{pid}} | ||
|  | ||
| output: | ||
| set sample_id, file("${sample_id}.sorted.bam"), file("${sample_id}.sorted.bam.bai") into {{ output_channel }} | ||
| {% with task_name="samtools_sort" %} | ||
| {%- include "compiler_channels.txt" ignore missing -%} | ||
| {% endwith %} | ||
|  | ||
| """ | ||
| samtools view -Sb $sam > ${sample_id}.bam | ||
| samtools sort -T ${sample_id}.bam.tmp ${sample_id}.bam -o ${sample_id}.sorted.bam | ||
| samtools index ${sample_id}.sorted.bam | ||
| """ | ||
| } | ||
|  | ||
| {{ forks }} | ||
  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.
  
    
  
    
Uh oh!
There was an error while loading. Please reload this page.
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.
You can improve I/O here by piping some of these commands: https://github.com/assemblerflow/flowcraft/blob/master/flowcraft/generator/templates/mapping_patlas.nf#L40 (example).
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.
Additionally, in your class you have defined the output as bam, not as bam, bai. This makes this component theoretically compatible with modules that receive bam files (retrieve_mapped, for example) but in fact they're not being compatible. Why don't you pass the .bai file as a side channel?