forked from droeatumn/kpi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfq2KHits.nf
executable file
·76 lines (65 loc) · 2.11 KB
/
fq2KHits.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
#!/usr/bin/env nextflow
/*
* kpi
*
* KIR structural interpretation for raw reads.
*
* Predict a (possibly-amiguous) pair of haplotypes given the
* presence/absence (PA) genotype from one individual and a collection
* of PA reference haplotypes.
*
* The input is a directory of 2-column tab-separated unix-formatted text
* files. Each file maps IDs to one or more files. The first column of each
* file is the ID of a set of reads (e.g., representing
* an individual). The second column is non-space-containing path to a
* optionally-gzipped fastq or fasta file.
*
* The output contains genotype and haplotype-pair predictions.
*
* One individual with 60G of gzippped fastq takes about todo minutes
* on an 8 CPU computer with 20G memory.
*
* @author Dave Roe
*/
nfForks = 1 // run this many input text files in parallel
mapSuffix = "txt"
params.input = '/opt/kpi/raw/'
params.output = '/opt/kpi/output'
geneProbes = '/opt/kpi/input/geneHapSigMarkers_v1-wRc'
mapDir = params.input
resultDir = params.output
mapPath = mapDir + '*' + mapSuffix
fqsIn = Channel.fromPath(mapPath).ifEmpty { error "cannot find any ${mapSuffix} files in ${mapDir}" }.map { path -> tuple(sample(path), path) }
process probeFastqs {
//publishDir resultDir, mode: 'copy', overwrite: true
maxForks nfForks
input: set s, file(f) from fqsIn
output:
set s, file('*.kmc_*') into kmcdb
script:
"""
probeFastqsKMC.groovy -m ${f} -o . -w .
"""
} // probeFastqs
process probeDB {
publishDir resultDir, mode: 'copy', overwrite: true
input: set s, file(fList) from kmcdb
output:
set s, file{ "*_hits.txt"} into filterdb
script:
"""
echo ${fList}
filterMarkersKMC2.groovy -d . -p ${geneProbes} -o . -w .
"""
} // probeFastqs
// get the per-sample name
def sample(Path path) {
def name = path.getFileName().toString()
int start = Math.max(0, name.lastIndexOf('/'))
int end = name.indexOf(mapSuffix)
if ( end <= 0 ) {
throw new Exception( "Expected file " + name + " to end in '" + mapSuffix + "'" );
}
end = end -1 // Remove the trailing '.'
return name.substring(start, end)
} // sample