-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnf_bigRandomTree.nf
90 lines (71 loc) · 2.23 KB
/
nf_bigRandomTree.nf
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
#!/usr/bin/env nextflow
/*
* Copyright (c) 2017-2018, Centre for Genomic Regulation (CRG) and the authors.
*
* This file is part of 'XXXXXX'.
*
* XXXXXX is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* XXXXXX is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with XXXXXX. If not, see <http://www.gnu.org/licenses/>.
*/
/*
* Main XXX pipeline script
*
* @authors
* Edgar Garriga
*/
/*
* defaults parameter definitions
*/
// input sequences to align in fasta format
params.seqs = "$baseDir/test/*"
// output directory
params.output = "$baseDir/results"
log.info """\
PIPELINE ~ version 0.1"
======================================="
Input sequences (FASTA) : ${params.seqs}
Output directory (DIRECTORY) : ${params.output}
"""
.stripIndent()
// Channels containing sequences
if ( params.seqs ) {
Channel
.fromPath(params.seqs)
.map { item -> [ item.baseName, item] }
.view()
.into { seqsCh; seqs2 }
}
process generateTree {
conda './my-env.yaml'
tag "${id}"
publishDir "${params.output}/trees", mode: 'copy', overwrite: true
input:
set val(id), file(seqs) from seqsCh
output:
set val(id), file("${id}.rndTree.dnd") into reformatSeqsOut
script:
"""
#!/usr/bin/env Rscript
fastaFile <- seqinr::read.fasta(file = "$seqs")
#how many fasta sequences
length(fastaFile)
#get the seqs IDs
seqNames<-seqinr::getName(fastaFile)
#define numbers of leave
n <- length(fastaFile)
#produce the tree
rt<-ape::rmtree(1, n, rooted = TRUE, tip.label = seqNames, br = runif)
#convert & save to newick
ape::write.tree(rt, file = "${id}.rndTree.dnd", append = FALSE,digits = 2, tree.names = FALSE)
"""
}