Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
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
2 changes: 2 additions & 0 deletions .gitattributes
Original file line number Diff line number Diff line change
@@ -1 +1,3 @@
/src/ccbr_tools/templates/mkdocs-fnl/docs/custom-overrides/** linguist-vendored true
# SCM syntax highlighting & preventing 3-way merges
pixi.lock merge=binary linguist-language=YAML linguist-generated=true -diff
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -175,3 +175,6 @@ cython_debug/
# and can be added to the global gitignore or merged into this file. For a more nuclear
# option (not recommended) you can uncomment the following to ignore the entire idea folder.
#.idea/
# pixi environments
.pixi/*
!.pixi/config.toml
3 changes: 2 additions & 1 deletion .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@ exclude: |
^.*.svg|
^assets/|
^src/ccbr_tools/templates/mkdocs-fnl/docs/custom-overrides/|
^tests/data/
^tests/data/|
^pixi.lock
)
ci:
skip: [detect-absolute-paths]
Expand Down
2,611 changes: 2,611 additions & 0 deletions pixi.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion scripts/extract_value_from_json.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#!/usr/bin/env python
import json
import argparse
import json

parser = argparse.ArgumentParser(description="extract value for key from JSON")
parser.add_argument("-j", dest="json", required=True, help="input JSON file")
Expand Down
3 changes: 2 additions & 1 deletion scripts/extract_value_from_yaml.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env python
import yaml
import argparse

import yaml

parser = argparse.ArgumentParser(description="extract value for key from YAML")
parser.add_argument("-y", dest="yaml", required=True, help="input YAML file")
parser.add_argument(
Expand Down
3 changes: 2 additions & 1 deletion scripts/filter_bam_by_readids.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#!/usr/bin/env python
import pysam
import argparse

import pysam

parser = argparse.ArgumentParser(description="Filter BAM by readids")
parser.add_argument(
"--inputBAM", dest="inputBAM", type=str, required=True, help="input BAM file"
Expand Down
3 changes: 2 additions & 1 deletion scripts/filter_fastq_by_readids_highmem.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env python3
import HTSeq
import argparse
import os

import HTSeq


def get_sname(s):
"""Return the sample name from the input path."""
Expand Down
3 changes: 2 additions & 1 deletion scripts/filter_fastq_by_readids_highmem_pe.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
#!/usr/bin/env python
import HTSeq
import argparse
import os

import HTSeq


def get_sname(s):
"""Return the sample name from the input path."""
Expand Down
25 changes: 11 additions & 14 deletions src/ccbr_tools/GSEA/deg2gs.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,16 @@
__version__ = "1.1"
__copyright__ = "No copyright protection, can be used freely"

import sys
import argparse
import datetime
import os
import re
import datetime
import sys
from argparse import RawTextHelpFormatter

import pandas as pd

import argparse
from argparse import RawTextHelpFormatter
from .ncbr_huse import send_update, err_out
from .ncbr_huse import err_out, send_update


####################################
Expand Down Expand Up @@ -190,9 +191,7 @@ def main():
log.write(" ".join(sys.argv) + "\n")
log.write("deg2gs.py version " + __version__ + "\n")
log.write(
"Exporting genes to {}, n={}, p={}, q={}, ".format(
outfile.name, nhits, pvalue, qvalue
)
f"Exporting genes to {outfile.name}, n={nhits}, p={pvalue}, q={qvalue}, "
)
log.flush()

Expand All @@ -214,9 +213,7 @@ def main():
#
if df.shape[1] != len(in_cols):
errMsg = (
'\nYour input file does not match the expected format "{}".\n'.format(
fformat
)
f'\nYour input file does not match the expected format "{fformat}".\n'
+ "Please check the file or the selected format and try again\n."
)
if keepLog:
Expand All @@ -229,7 +226,7 @@ def main():

# split the ensemblID|Gene if necessary
if fformat == "topTable": # and method == 'gsea':
df["gene"] = [re.sub("^.*\|", "", i) for i in df.index.values.tolist()]
df["gene"] = [re.sub(r"^.*\|", "", i) for i in df.index.values.tolist()]

# Filter the df to the p-values, FDR, and number of hits specified
df = filter_by_p(df, nhits, pvalue, qvalue)
Expand All @@ -253,11 +250,11 @@ def main():
# Close out the log file
#
if keepLog:
send_update("deg2gs.py successfully completed. {} written.".format(fname), log)
send_update(f"deg2gs.py successfully completed. {fname} written.", log)
send_update(str(datetime.datetime.now()) + "\n", log)
log.close()
else:
print("deg2gs.py successfully completed. {} written.".format(fname))
print(f"deg2gs.py successfully completed. {fname} written.")


if __name__ == "__main__":
Expand Down
25 changes: 10 additions & 15 deletions src/ccbr_tools/GSEA/multitext2excel.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,23 +18,22 @@
__copyright__ = "No copyright protection, can be used freely"

# import csv
import sys
import os
import re
import datetime
import pandas as pd
import glob

# import scipy
# import numpy

import argparse
import datetime
import glob
import os
import re
import sys
from argparse import RawTextHelpFormatter

import pandas as pd

from .ncbr_huse import (
send_update,
)


####################################
#
# Functions
Expand Down Expand Up @@ -150,11 +149,7 @@ def main():
sheet_name = re.sub(indir + "/", "", filename).split(splitter)[0]
if firstsplitter != "":
sheet_name = sheet_name.split(firstsplitter)[1]
print(
"Writing data from input file: {} to output tab: {}".format(
filename, sheet_name
)
)
print(f"Writing data from input file: {filename} to output tab: {sheet_name}")

# Read in the data
df = pd.read_csv(filename, sep=delimiter, header=0, encoding="unicode_escape")
Expand All @@ -169,7 +164,7 @@ def main():
# Close out the log file
#
send_update(
"multitext2excel.py successfully completed. {} written.".format(outfile.name),
f"multitext2excel.py successfully completed. {outfile.name} written.",
log,
)
send_update(str(datetime.datetime.now()) + "\n", log)
Expand Down
16 changes: 4 additions & 12 deletions src/ccbr_tools/GSEA/ncbr_huse.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,10 @@
__version__ = "1.0.0"
__copyright__ = "none"

import sys
import os
import re
import subprocess
import sys

try:
import MySQLdb
Expand Down Expand Up @@ -139,27 +139,19 @@ def pause_for_input(txt, contkey="y", quitkey="q", log=None):
err_out("User elected to quit. Exiting...\n", log)

# if none, just return the input
if contkey is None:
result = answer

# if there is a contkey, then be sure it is correctly typed
elif answer == contkey:
if contkey is None or answer == contkey:
result = answer

else:
# give them additional help and increment the answer count
reminder = "Note: only {} to continue and {} to quit are valid options.\nPlease try again.\n".format(
contkey, quitkey
)
reminder = f"Note: only {contkey} to continue and {quitkey} to quit are valid options.\nPlease try again.\n"
if answer_cnt == 0:
txt = "\n" + txt + "\n" + reminder

# Otherwise 3 strikes and exit from the loop
if answer_cnt == 2:
err_out(
"User failed to continue ({}) or quit ({}) three times in a row. Exiting...".format(
contkey, quitkey
),
f"User failed to continue ({contkey}) or quit ({quitkey}) three times in a row. Exiting...",
log,
)

Expand Down
8 changes: 3 additions & 5 deletions src/ccbr_tools/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,19 @@
Entry point for CCBR Tools
"""

import click
import cffconvert.cli.cli
import click

from .pkg_util import (
CustomClickGroup,
get_project_scripts,
get_version,
print_citation,
repo_base,
CustomClickGroup,
)
from .send_email import send_email_msg
from .templates import use_quarto_ext, get_quarto_extensions
from .software import install as install_software

from .templates import get_quarto_extensions, use_quarto_ext

all_scripts = "All installed tools:\n" + "\n".join(
[f" {cmd}" for cmd in get_project_scripts()]
Expand All @@ -37,7 +36,6 @@ def cli():

https://ccbr.github.io/Tools/
"""
pass


@click.command()
Expand Down
3 changes: 2 additions & 1 deletion src/ccbr_tools/gb2gtf.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@
# Usage:python gb2gtf.py sequence.gb > sequence.gtf

import sys
from Bio import SeqIO

import Bio
from Bio import SeqIO


def main():
Expand Down
3 changes: 2 additions & 1 deletion src/ccbr_tools/github.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
"""

import warnings

from .pkg_util import get_url_json


Expand Down Expand Up @@ -64,7 +65,7 @@ def get_user_info(user_login):
try:
user_info = get_url_json(url)
except ConnectionError as e:
warnings.warn(f"Could not retrieve user info for {user_login}. {str(e)}")
warnings.warn(f"Could not retrieve user info for {user_login}. {e!s}")
return user_info


Expand Down
8 changes: 4 additions & 4 deletions src/ccbr_tools/homologfinder/hf.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,14 @@

import argparse
import importlib.resources
import pandas as pd
import sys

import pandas as pd


def exit_w_msg(message):
"""Gracefully exit with proper message"""
print("{} : EXITING!!".format(__file__))
print(f"{__file__} : EXITING!!")
print(message)
sys.exit()

Expand All @@ -42,7 +43,6 @@ def check_help(parser):
print(__doc__)
parser.print_help()
parser.exit()
return


def collect_args():
Expand All @@ -54,7 +54,7 @@ def collect_args():

# add version
parser.add_argument(
"-v", "--version", action="version", version="%(prog)s {}".format(__version__)
"-v", "--version", action="version", version=f"%(prog)s {__version__}"
)

# add joblist
Expand Down
4 changes: 2 additions & 2 deletions src/ccbr_tools/hooks/__main__.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,10 @@
"""

import click

from ..pkg_util import (
get_version,
CustomClickGroup,
get_version,
)
from .detect_absolute_paths import detect_absolute_paths
from .sync_nextflow_version import sync_nextflow_version
Expand All @@ -25,7 +26,6 @@ def cli():

https://ccbr.github.io/Tools/hooks
"""
pass


cli.add_command(detect_absolute_paths)
Expand Down
1 change: 0 additions & 1 deletion src/ccbr_tools/intersect.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
intersect file1 file2
"""

from __future__ import print_function
import sys


Expand Down
Loading
Loading