Skip to content

Commit e783728

Browse files
authored
Merge pull request #233 from AlexandrovLab/development
v1.3.5 Updates
2 parents db0cfba + d3f122c commit e783728

File tree

5 files changed

+50
-33
lines changed

5 files changed

+50
-33
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,12 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
66

77
## [Unreleased]
88

9+
## [1.3.5] - 2025-08-05
10+
11+
### Changed
12+
- Updated README to clarify usage and examples.
13+
- Added custom output directory option.
14+
915
## [1.3.4] - 2025-06-06
1016

1117
### Fixed

README.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -103,18 +103,18 @@ a DBS, SBS, ID, and TSB folder (there will also be a plots folder if this parame
103103

104104
***First six columns are required, and either the column "svclass" (deletion, translocation, tandem-duplication, or inversion) or the columns "strand1" & "strand2" (BRASS convention, see https://github.com/cancerit/BRASS/wiki/BEDPE) must also be present***
105105

106-
107106
### Example with SV class present (tsv or csv file):
108107

109-
| chrom1 | start1 | end1 | chrom2 | start2 | end2 | svclass |
110-
| :-----: | :-: | :-: | :-: | :-: | :-: | :-: |
111-
| 19 | 21268384 | 21268385 | 19 | 21327858 | 21327859 | deletion
108+
| sample | chrom1 | start1 | end1 | chrom2 | start2 | end2 | svclass |
109+
|:-------:|:------:|:--------:|:--------:|:------:|:--------:|:--------:|:--------:|
110+
| Sample1 | 19 | 21268384 | 21268385 | 19 | 21327858 | 21327859 | deletion |
112111

113112
### Example without SV class present (tsv or csv file):
114113

115-
| chrom1 | start1 | end1 | chrom2 | start2 | end2 | strand1 | strand2
116-
| :-----: | :-: | :-: | :-: | :-: | :-: | :-: | :-: |
117-
| 19 | 21268384 | 21268385 | 19 | 21327858 | 21327859 | + | +
114+
| sample | chrom1 | start1 | end1 | chrom2 | start2 | end2 | strand1 | strand2 |
115+
|:-------:|:------:|:--------:|:--------:|:------:|:--------:|:--------:|:-------:|:-------:|
116+
| Sample1 | 19 | 21268384 | 21268385 | 19 | 21327858 | 21327859 | + | + |
117+
118118

119119
### Quick Start Example: ###
120120

SigProfilerMatrixGenerator/controllers/cli_controller.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -143,6 +143,12 @@ def parse_arguments_matrix_generator(args: List[str]) -> argparse.Namespace:
143143
default=None,
144144
)
145145

146+
parser.add_argument(
147+
"--output_directory",
148+
help="Specify a custom output directory (default: None).",
149+
default=None,
150+
)
151+
146152
result = parser.parse_args(args)
147153
return result
148154

@@ -230,6 +236,7 @@ def dispatch_matrix_generator(self, user_args: List[str]) -> None:
230236
seqInfo=parsed_args.seqInfo,
231237
cushion=parsed_args.cushion,
232238
volume=parsed_args.volume,
239+
output_directory=parsed_args.output_directory,
233240
)
234241

235242
def dispatch_sv_matrix_generator(self, user_args: List[str]) -> None:

SigProfilerMatrixGenerator/scripts/SigProfilerMatrixGeneratorFunc.py

Lines changed: 28 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ def SigProfilerMatrixGeneratorFunc(
6464
cushion=100,
6565
gs=False,
6666
volume=None,
67+
output_directory=None,
6768
):
6869
"""
6970
Allows for the import of the sigProfilerMatrixGenerator.py function. Returns a dictionary
@@ -1188,37 +1189,40 @@ def SigProfilerMatrixGeneratorFunc(
11881189
+ " has not been installed\nPlease refer to the SigProfilerMatrixGenerator README for installation instructions:\n\thttps://github.com/AlexandrovLab/SigProfilerMatrixGenerator"
11891190
)
11901191

1191-
# Organizes all of the input and output directories:
1192-
if path_to_input_files[-1] != "/":
1193-
path_to_input_files += "/"
1194-
vcf_path = path_to_input_files + "input/"
1192+
# Set base directory (for input/ and output/) based on user-provided output_directory if given
1193+
base_path = output_directory if output_directory else path_to_input_files
1194+
if not base_path.endswith("/"):
1195+
base_path += "/"
11951196

1197+
# Ensure input path and create if needed
1198+
vcf_path = os.path.join(base_path, "input/")
11961199
vcf_path_original = vcf_path
1200+
1201+
# Copy all regular files from input source into vcf_path if vcf_path is missing or empty
11971202
if not os.path.exists(vcf_path) or len(os.listdir(vcf_path)) < 1:
11981203
os.makedirs(vcf_path, exist_ok=True)
1199-
input_files = os.listdir(path_to_input_files)
1200-
if os.path.exists(path_to_input_files + "input/"):
1201-
input_files.remove("input")
1202-
if os.path.exists(path_to_input_files + "logs/"):
1203-
input_files.remove("logs")
1204-
if ".DS_Store" in input_files:
1205-
input_files.remove(".DS_Store")
1206-
if "__init__.py" in input_files:
1207-
input_files.remove("__init__.py")
1208-
if "__pycache__" in input_files:
1209-
input_files.remove("__pycache__")
1210-
if os.path.exists(path_to_input_files + "output/"):
1211-
input_files.remove("output")
1212-
for files in input_files:
1213-
shutil.copy(path_to_input_files + files, vcf_path + files)
1214-
output_matrix = path_to_input_files + "output/"
1215-
1216-
if not os.path.exists(output_matrix):
1217-
os.makedirs(output_matrix)
1204+
if not path_to_input_files.endswith("/"):
1205+
path_to_input_files += "/"
1206+
for filename in os.listdir(path_to_input_files):
1207+
src = os.path.join(path_to_input_files, filename)
1208+
dst = os.path.join(vcf_path, filename)
1209+
if os.path.isfile(src):
1210+
shutil.copy(src, dst)
1211+
1212+
# Define the output matrix path, allowing override via `output_directory`
1213+
if output_directory:
1214+
if output_directory[-1] != "/":
1215+
output_directory += "/"
1216+
output_matrix = output_directory
1217+
else:
1218+
output_matrix = base_path + "output/"
1219+
1220+
os.makedirs(output_matrix, exist_ok=True)
1221+
12181222

12191223
# Organizes the error and log files
12201224
time_stamp = datetime.date.today()
1221-
output_log_path = path_to_input_files + "logs/"
1225+
output_log_path = output_matrix + "logs/"
12221226
if not os.path.exists(output_log_path):
12231227
os.makedirs(output_log_path)
12241228
error_file = (

setup.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33

44
from setuptools import setup
55

6-
VERSION = "1.3.4"
6+
VERSION = "1.3.5"
77

88
# remove the dist folder first if exists
99
if os.path.exists("dist"):
@@ -23,7 +23,7 @@ def write_version_py(filename="SigProfilerMatrixGenerator/version.py"):
2323
# THIS FILE IS GENERATED FROM SIGPROFILEMATRIXGENERATOR SETUP.PY
2424
short_version = '%(version)s'
2525
version = '%(version)s'
26-
Update = 'v1.3.4: Fix mm39 and rn7 context counts and update in save_context_distribution script.'
26+
Update = 'v1.3.5: Update README and add custom output directory option'
2727
2828
"""
2929
fh = open(filename, "w")

0 commit comments

Comments
 (0)