Skip to content

Commit

Permalink
updating readme and setting tags for process
Browse files Browse the repository at this point in the history
  • Loading branch information
adigenova committed Nov 25, 2020
1 parent 55cb63b commit 956ecca
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 9 deletions.
10 changes: 8 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ A repository to convert BAM->CRAM files

```
#using a tsv file, with custom working directory
nextflow run main.nf --bam_csv test/bams.txt --fasta test/ref.fa --output_folder csv2 -w tmp
nextflow run main.nf --bam_csv test/bams.txt --fasta test/ref.fa --fai test/ref.fa.fai --output_folder csv2 -w tmp
#using a directory with bams
nextflow run main.nf --bams test --fasta test/ref.fa --output_folder dirs_bam
nextflow run main.nf --bams test --fasta test/ref.fa --fai test/ref.fa.fai --output_folder dirs_bam
```
### tsv file
A tabular file with the following colums:
Expand All @@ -17,3 +17,9 @@ label bam index
S4 /path/S4.bam /path/S4.bam.bai
S3 /path/S3.bam /path/S3.bam.bai
```

# Samtools

This tool has been tested with samtools 1.11.


17 changes: 10 additions & 7 deletions main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ def show_help (){
--bams [directory] input folder with BAM files and indexes
References
--fasta [file] Path to fasta reference to encode the CRAM file
--fai [file] Path to fasta reference index.
Input alternatives:
--bam_csv file with tabular data for each sample to process [label bam index ]
-profile [str] Configuration profile to use.
Expand All @@ -26,6 +27,8 @@ def show_help (){
params.help = null
params.bams = null
params.bam_csv = null
params.fasta= null
params.fai = null

// Show help message
if (params.help) exit 0, show_help()
Expand All @@ -35,16 +38,14 @@ log.info IARC_Header()
log.info tool_header()

//check fasta and fasta index
if (!params.fasta) exit 1, "The reference fasta file need to be provided!"
if (!params.fasta || !params.fai) exit 1, "The reference fasta file with its index need to be provided!"

//we check the reference
ch_fasta = Channel.value(file(params.fasta)).ifEmpty{exit 1, "Fasta file not found: ${params.fasta}"}
ch_fai = Channel.value(file(params.fasta+".fai")).ifEmpty{exit 1, "fai index file not found: ${params.fasta}.fai"}

ch_fai = Channel.value(file(params.fai)).ifEmpty{exit 1, "fai index file not found: ${params.fai}"}
//check that BAM input is provided!
if(!params.bam_csv && !params.bams) exit 1, "No --bam_csv nor --bams options provided!"


//we print the parameters
log.info "\n"
log.info "-\033[2m------------------Calling PARAMETERS--------------------\033[0m-"
Expand Down Expand Up @@ -76,8 +77,7 @@ if(params.bam_csv) {

//map the rna-seq reads to the genome
process bam2cram{
tag "${sample}"
label 'load_low2'
tag "${sample}-2cram"
//we can remove this to don't keep the bam files
publishDir "${params.output_folder}/CRAM", mode: 'copy'

Expand All @@ -98,7 +98,7 @@ process bam2cram{

//we compute some stat for original bam files
process stats_bams{

tag "${sample}-bam_stats"
publishDir "${params.output_folder}/qc/bam", mode: 'copy'
input:
set val(sample), file(bam), file(bam_index) from bamstats
Expand All @@ -113,6 +113,8 @@ process stats_bams{

//we compute some stat for original bam files
process stats_crams{
tag "${sample}-cram_stats"

publishDir "${params.output_folder}/qc/cram", mode: 'copy'
input:
set val(sample), file(cram), file(cram_index) from cramstats
Expand All @@ -131,6 +133,7 @@ cram_bam_qc=cram_qc.join(bam_qc)

//we merge both cram_qc and bam_qc to check if they are identical
process check_conversion{
tag "${sample}-check"
publishDir "${params.output_folder}/qc/check", mode: 'copy'

input:
Expand Down

0 comments on commit 956ecca

Please sign in to comment.