-
Notifications
You must be signed in to change notification settings - Fork 25
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #86 from zifornd/71-suppa-cluster-events-error
suppa fix attempt 1
- Loading branch information
Showing
5 changed files
with
104 additions
and
29 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
#!/usr/bin/env python3 | ||
# Author: Zifo Bioinformatics | ||
# Email: [email protected] | ||
# License: MIT | ||
|
||
import argparse | ||
import itertools | ||
|
||
|
||
def main(args): | ||
# Open file | ||
handle = open(args.file, "r") | ||
|
||
# Read header only | ||
header = handle.readline() | ||
|
||
# Split header by delimiter (e.g., transcript_GBR_1) | ||
samples = header.split("\t") | ||
|
||
# Trim replicate number (e.g., transcript_GBR_1 -> transcript_GBR) | ||
conditions = [sample.rsplit("_", 1)[0] for sample in samples] | ||
|
||
# Close file | ||
handle.close() | ||
|
||
# Create list of consecutive condition indices (e.g., [[1,2], [3,4]]) | ||
last_index = 0 | ||
out = [] | ||
for v, g in itertools.groupby(enumerate(conditions), lambda k: k[1]): | ||
l = [*g] | ||
out.append([last_index + 1, l[-1][0] + 1]) | ||
last_index += len(l) | ||
|
||
# Assert that condition indices are consecutive | ||
assert len(out) == 2, "Column numbers have to be continuous, with no overlapping or missing columns between them." | ||
|
||
# Format ranges for printing | ||
groups = ",".join([f"{start}-{end}" for start, end in out]) | ||
|
||
# Print to stdout without newline | ||
print(groups, end="") | ||
|
||
|
||
if __name__ == "__main__": | ||
parser = argparse.ArgumentParser() | ||
parser.add_argument("file") | ||
args = parser.parse_args() | ||
main(args) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
process CLUSTERGROUPS { | ||
tag "${cond1}-${cond2}" | ||
label 'process_single' | ||
|
||
conda "conda-forge::python=3.9.5" | ||
container "${ workflow.containerEngine == 'singularity' && !task.ext.singularity_pull_docker_container ? | ||
'https://depot.galaxyproject.org/singularity/python:3.9--1' : | ||
'biocontainers/python:3.9--1' }" | ||
|
||
input: | ||
tuple val(cond1), val(cond2), path(psivec) | ||
|
||
output: | ||
stdout | ||
|
||
when: | ||
task.ext.when == null || task.ext.when | ||
|
||
script: | ||
""" | ||
suppa_groups.py $psivec | ||
""" | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters