Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: parse file format from extension (ignore compression) #41

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 19 additions & 5 deletions snakemake_wrapper_utils/snakemake.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
def get_mem(snakemake, out_unit="MiB"):
"""
Obtain requested memory (from resources) and return in given units.
If no memory resources found, return a value equivalent to 205 .
If no memory resources found, return a value equivalent to 205.
"""

# Store memory in MiB
Expand All @@ -22,8 +22,22 @@ def get_mem(snakemake, out_unit="MiB"):


def is_arg(arg, cmd):
"""Check command for the presence of argument"""
if arg in cmd.replace("=", " ").split(" "):
return True
"""Check command for the presence of argument."""
return arg in cmd.replace("=", " ").split(" "):
fgvieira marked this conversation as resolved.
Show resolved Hide resolved

return False

def get_format(path):
"""Get file format from extension, ignoring common compressions."""
from pathlib import Path
exts = Path(path).suffixes
if exts[-1] in (".gz", ".bgz", ".bz2"):
ext = exts[-2]
else:
ext = exts[-1]

if ext in (".fq", ".fastq"):
return "fastq"
elif ext in (".fa", ".fas", ".fna", ".fasta"):
return "fasta"
else:
return ext.lower()
fgvieira marked this conversation as resolved.
Show resolved Hide resolved
Loading