Skip to content

Commit

Permalink
Editorconfig
Browse files Browse the repository at this point in the history
  • Loading branch information
nictru committed Apr 26, 2024
1 parent f20ea3b commit f8e7911
Show file tree
Hide file tree
Showing 7 changed files with 29 additions and 29 deletions.
6 changes: 3 additions & 3 deletions modules/local/motifs/convert_motifs/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ process CONVERT_MOTIFS {
input:
tuple val(meta), path(in_file), val(in_type)
val(out_type)

output:
tuple val(meta), path("${out_file}"), emit: converted
path "versions.yml" , emit: versions

script:
out_file = "${meta.id}.converted.${out_type}"
template "convert.R"
}
}
28 changes: 14 additions & 14 deletions modules/local/motifs/convert_motifs/templates/convert.R
Original file line number Diff line number Diff line change
Expand Up @@ -8,32 +8,32 @@ in_type <- "$in_type"
allowed_in_types <- c("cisbp", "homer", "jaspar", "meme", "transfac", "uniprobe", "universal")

if (!(in_type %in% allowed_in_types)) {
stop("Input type '", in_type, "' not supported. Supported types are: ", paste(allowed_in_types, collapse=", "))
stop("Input type '", in_type, "' not supported. Supported types are: ", paste(allowed_in_types, collapse=", "))
}

out_type <- "$out_type"
allowed_out_types <- c("homer", "jaspar", "meme", "transfac", "universal")

if (!(out_type %in% allowed_out_types)) {
stop("Output type '", out_type, "' not supported. Supported types are: ", paste(allowed_out_types, collapse=", "))
stop("Output type '", out_type, "' not supported. Supported types are: ", paste(allowed_out_types, collapse=", "))
}

u.motif <- switch(in_type,
cisbp = read_cisbp,
homer = read_homer,
jaspar = read_jaspar,
meme = read_meme,
transfac = read_transfac,
uniprobe = read_uniprobe,
universal = readRDS
cisbp = read_cisbp,
homer = read_homer,
jaspar = read_jaspar,
meme = read_meme,
transfac = read_transfac,
uniprobe = read_uniprobe,
universal = readRDS
)(in_file)

switch(out_type,
homer = write_homer,
jaspar = write_jaspar,
meme = write_meme,
transfac = write_transfac,
universal = saveRDS
homer = write_homer,
jaspar = write_jaspar,
meme = write_meme,
transfac = write_transfac,
universal = saveRDS
)(u.motif, "$out_file")

writeLines(
Expand Down
2 changes: 1 addition & 1 deletion modules/local/motifs/fetch_jaspar/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,4 @@ process FETCH_JASPAR {

script:
template "fetch_jaspar.py"
}
}
6 changes: 3 additions & 3 deletions modules/local/motifs/filter_motifs/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -10,12 +10,12 @@ process FILTER_MOTIFS {
input:
tuple val(meta), path(in_file)
tuple val(meta2), path(tfs)

output:
tuple val(meta), path("${out_file}"), emit: filtered
path "versions.yml" , emit: versions

script:
out_file = "${meta.id}.filtered.RDS"
template "filter_motifs.R"
}
}
6 changes: 3 additions & 3 deletions modules/local/motifs/transfac_to_psem/main.nf
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@ process TRANSFAC_TO_PSEM {

input:
tuple val(meta), path(transfac)

output:
tuple val(meta), path("*.psem"), emit: psem
path "versions.yml" , emit: versions

script:
template "convert.py"
}
}
6 changes: 3 additions & 3 deletions modules/local/motifs/transfac_to_psem/templates/convert.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ def write_pwm(f, matrix, name, ma_id):

pwm = np.zeros_like(matrix)

for i, active, active_content, other, other_content in zip([A, C, G, T],
[maxAT, maxGC, maxGC, maxAT],
for i, active, active_content, other, other_content in zip([A, C, G, T],
[maxAT, maxGC, maxGC, maxAT],
[at_content, gc_content, gc_content, at_content],
[maxGC, maxAT, maxAT, maxGC],
[maxGC, maxAT, maxAT, maxGC],
[gc_content, at_content, at_content, gc_content]):
pwm[:, i] = np.where(active<other,
np.log((other / other_content) * (active_content / matrix[:, i])) / lamda,
Expand Down
4 changes: 2 additions & 2 deletions subworkflows/local/motifs.nf
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ workflow MOTIFS {
ch_input_motifs
ch_tfs
ch_taxon_id

main:
ch_versions = Channel.empty()

Expand Down Expand Up @@ -43,4 +43,4 @@ workflow MOTIFS {
psem = TRANSFAC_TO_PSEM.out.psem

versions = ch_versions
}
}

0 comments on commit f8e7911

Please sign in to comment.