Skip to content

Commit

Permalink
pipeline.nf: Added check for unknown parameters; update parameter nam…
Browse files Browse the repository at this point in the history
…es; if compareBed.sh is not executable chmod +x is called
  • Loading branch information
renewiegandt committed Jan 23, 2019
1 parent 0f0aa58 commit 7e90339
Showing 1 changed file with 22 additions and 4 deletions.
26 changes: 22 additions & 4 deletions pipeline.nf
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
params.identity=0.8
params.sequence_coverage=8
params.memory=800
params.throw_away_seq=9
params.throw_away_seq=9
params.strand=0

//motif_estimation
Expand All @@ -60,7 +60,7 @@

//creating_gtf
params.organism=""
params.tissue=""
params.tissues=""

if (params.bigwig == "" || params.bed == "" || params.organism == "" || params.genome_fasta == "" || params.motif_db == "" || params.config == "" || "${params.help}" != "0" ){
log.info """
Expand Down Expand Up @@ -144,20 +144,27 @@ int_params = ["window_length", "step", "min_size_fp", "max_size_fp", "kmer",
"aprox_motif_len", "motif_occurence", "min_seq_length", "global",
"sequence_coverage", "memory", "throw_away_seq", "strand",
"min_seq", "motif_min_key", "motif_max_key", "iteration",
"edge_weight", "best_motif", "min_gap", "gap_penalty", "edge_weight"]
"edge_weight", "best_motif", "min_gap", "gap_penalty", "edge_weight",
"threads", ]
req_params = ["bigwig", "bed", "genome_fasta", "motif_db", "config"]
all_params = int_params + req_params + ["organism" , "identity", "tfbsscan_method",
"percentage", "tomtom_treshold", "motif_similarity_thresh", "out",
"tissues", "gtf_path", "cluster_motif", "tfbs_path", "help"]

valid_organism = ["hg38", "hg19", "mm9", "mm10"]
valid_tfbsscan_methods = ["moods","fimo"]

params.each { key, value ->
if (!(all_params.contains(key))){
println("Warning: Parameter $key is unknown. Please check for typos or the parameter list!")
}
if(int_params.contains(key)) {
if (!("${value}" ==~ /\d+/ )){
println("ERROR: $key needs to be an Integer")
System.exit(2)
}
}
if(req_params.contains(key)) {
if(req_params.contains(key) || (key == "gtf_path" && value != "") ) {
if(!file(value).exists()) {
println("ERROR: $key not found. Please check the given path.")
System.exit(2)
Expand Down Expand Up @@ -243,12 +250,20 @@ process overlap_with_known_TFBS {
script:
if(params.tfbs_path == ""){
"""
if [[ ! -x "${path_bin}/1.2_filter_motifs/compareBed.sh" ]]
then
chmod +x ${path_bin}/1.2_filter_motifs/compareBed.sh
fi
python ${path_bin}/1.2_filter_motifs/tfbsscan.py --use ${params.tfbsscan_method} --core ${params.threads} -m ${db} -g ${fasta} -o ./known_tfbs -b ${bed_peaks}
${path_bin}/1.2_filter_motifs/compareBed.sh --data ${bed_footprints} --motifs ./known_tfbs --fasta ${fasta} -o ${name}_unknown.bed -min ${params.min_size_fp} -max ${params.max_size_fp}
cp -r ./known_tfbs/ ${params.out}/1.2_filter_motifs/
"""
} else {
"""
if [[ ! -x "${path_bin}/1.2_filter_motifs/compareBed.sh" ]]
then
chmod +x ${path_bin}/1.2_filter_motifs/compareBed.sh
fi
${path_bin}/1.2_filter_motifs/compareBed.sh --data ${bed_footprints} --motifs ${known_tfbs} --fasta ${fasta} -o ${name}_unknown.bed -min ${params.min_size_fp} -max ${params.max_size_fp}
"""
}
Expand All @@ -274,6 +289,9 @@ process reduce_sequence {
set name, file ('*.bed') into bed_for_clustering
file ('*.log')

when:
params.lalal == "1"

script:
"""
Rscript ${path_bin}/2.1_clustering/reduce_sequence.R -i ${bed} -k ${params.kmer} -m ${params.aprox_motif_len} -o ${name}_reduced.bed -t ${params.threads} -f ${params.motif_occurence} -s ${params.min_seq_length} --summary reduce_sequence.log
Expand Down

0 comments on commit 7e90339

Please sign in to comment.