@@ -13,7 +13,6 @@ def show_help (){
1313 --bams [directory] input folder with BAM files and indexes
1414 References
1515 --fasta [file] Path to fasta reference to encode the CRAM file
16- --fai [file] Path to fasta reference index [samtools faidx]
1716 Input alternatives:
1817 --bam_csv file with tabular data for each sample to process [label bam index ]
1918 -profile [str] Configuration profile to use.
@@ -36,28 +35,41 @@ log.info IARC_Header()
3635log. info tool_header()
3736
3837// check fasta and fasta index
39- if (! params. fasta && ! params. fai) exit 1 , " The reference fasta file need to be provided!"
38+ if (! params. fasta) exit 1 , " The reference fasta file need to be provided!"
39+
4040// we check the reference
4141ch_fasta = Channel . value(file(params. fasta)). ifEmpty{exit 1 , " Fasta file not found: ${ params.fasta} " }
42- ch_fai = Channel . value(file(params. fai)). ifEmpty{exit 1 , " fai index file not found: ${ params.fai} " }
42+ ch_fai = Channel . value(file(params. fasta+ " .fai" )). ifEmpty{exit 1 , " fai index file not found: ${ params.fasta} .fai" }
43+
44+ // check that BAM input is provided!
45+ if (! params. bam_csv && ! params. bams) exit 1 , " No --bam_csv nor --bams options provided!"
4346
4447
45- // see file ./test_dataset/sample_fwrev.txt
48+ // we print the parameters
49+ log. info " \n "
50+ log. info " -\0 33[2m------------------Calling PARAMETERS--------------------\0 33[0m-"
51+ log. info params. collect{ k,v -> " ${ k.padRight(18)} : $v " }. join(" \n " )
52+ log. info " -\0 33[2m--------------------------------------------------------\0 33[0m-"
53+ log. info " \n "
54+
4655if (params. bam_csv) {
4756 Channel . fromPath(file(params. bam_csv)). splitCsv(header : true , sep : ' \t ' , strip : true )
4857 .map{row -> [ row. label, file(row. bam), file(row. index)]}
4958 .ifEmpty{exit 1 , " params.bams_csv was empty - no input files supplied" }
5059 .into { inputbams; bamstats; sizebams }
5160
5261}else {
53-
62+ if (file(params . bams) . listFiles() . findAll { it . name ==~ / .*bam / } . size() > 0 ){
5463 bams = Channel . fromPath( params. bams+ ' /*.bam' )
5564 .map {path -> [ path. name. replace(" .bam" ," " ),path]}
5665 bams_index = Channel . fromPath( params. bams+ ' /*.bam.bai' )
5766 .map { path -> [ path. name. replace(" .bam.bai" ," " ), path ] }
5867 // we create the chanel
5968 files = bams. join(bams_index)
6069 files. into {inputbams; bamstats; sizebams}
70+ }else {
71+ println " ERROR: input folder ${ params.bams} contains no BAM files" ; System . exit(1 )
72+ }
6173}
6274
6375
0 commit comments