@@ -13,7 +13,6 @@ def show_help (){
13
13
--bams [directory] input folder with BAM files and indexes
14
14
References
15
15
--fasta [file] Path to fasta reference to encode the CRAM file
16
- --fai [file] Path to fasta reference index [samtools faidx]
17
16
Input alternatives:
18
17
--bam_csv file with tabular data for each sample to process [label bam index ]
19
18
-profile [str] Configuration profile to use.
@@ -36,28 +35,41 @@ log.info IARC_Header()
36
35
log. info tool_header()
37
36
38
37
// 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
+
40
40
// we check the reference
41
41
ch_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!"
43
46
44
47
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
+
46
55
if (params. bam_csv) {
47
56
Channel . fromPath(file(params. bam_csv)). splitCsv(header : true , sep : ' \t ' , strip : true )
48
57
.map{row -> [ row. label, file(row. bam), file(row. index)]}
49
58
.ifEmpty{exit 1 , " params.bams_csv was empty - no input files supplied" }
50
59
.into { inputbams; bamstats; sizebams }
51
60
52
61
}else {
53
-
62
+ if (file(params . bams) . listFiles() . findAll { it . name ==~ / .*bam / } . size() > 0 ){
54
63
bams = Channel . fromPath( params. bams+ ' /*.bam' )
55
64
.map {path -> [ path. name. replace(" .bam" ," " ),path]}
56
65
bams_index = Channel . fromPath( params. bams+ ' /*.bam.bai' )
57
66
.map { path -> [ path. name. replace(" .bam.bai" ," " ), path ] }
58
67
// we create the chanel
59
68
files = bams. join(bams_index)
60
69
files. into {inputbams; bamstats; sizebams}
70
+ }else {
71
+ println " ERROR: input folder ${ params.bams} contains no BAM files" ; System . exit(1 )
72
+ }
61
73
}
62
74
63
75
0 commit comments