Skip to content

Commit 7287f31

Browse files
authored
Cn bugfix (#95)
bug fix when parsing clonal string
1 parent c3a6894 commit 7287f31

4 files changed

Lines changed: 11 additions & 8 deletions

File tree

setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -76,7 +76,7 @@ def build_extension(self, ext):
7676

7777
setup(
7878
name='hatchet',
79-
version='0.4.5',
79+
version='0.4.6',
8080
packages=['hatchet', 'hatchet.utils', 'hatchet.utils.solve', 'hatchet.bin', 'hatchet.data'],
8181
package_dir={'': 'src'},
8282
package_data={'hatchet': ['hatchet.ini'], 'hatchet.data': ['*']},

src/hatchet/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
__version__ = '0.4.5'
1+
__version__ = '0.4.6'
22

33
import os.path
44
from importlib.resources import path

src/hatchet/utils/ArgParsing.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ def parse_count_reads_arguments(args=None):
228228
if not os.path.isfile(normalbaf): raise ValueError(sp.error("The specified normal BAM file does not exist"))
229229
tumors = args.tumors
230230
for tumor in tumors:
231-
if(not os.path.isfile(tumor)): raise ValueError(sp.error("The specified normal BAM file does not exist"))
231+
if(not os.path.isfile(tumor)): raise ValueError(sp.error(f"The specified tumor BAM file {tumor} does not exist"))
232232
names = args.samples
233233
if names != None and (len(tumors)+1) != len(names):
234234
raise ValueError(sp.error("A sample name must be provided for each corresponding BAM: both for each normal sample and each tumor sample"))

src/hatchet/utils/solve/utils.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -33,16 +33,19 @@ def parse_clonal(clonal):
3333
copy_numbers = OrderedDict() # dict from cluster_id => (cn_a, cn_b) 2-tuple
3434
clonal_parts = clonal.split(',')
3535
n_clonal_parts = len(clonal_parts)
36-
cn_totals = set()
3736

38-
for c in clonal_parts:
37+
for i, c in enumerate(clonal_parts):
3938
cluster_id, cn_a, cn_b = [int(_c) for _c in c.split(':')]
39+
40+
# The first two clonal clusters (used for scaling) MUST have different total copy numbers
41+
if i==1:
42+
_first_cn_a, _first_cn_b = list(copy_numbers.values())[0]
43+
if _first_cn_a + _first_cn_b == cn_a + cn_b:
44+
raise ValueError('When >= 2 clonal copy numbers are given, the first two must be different in the two segmental clusters')
45+
4046
cn_total = cn_a + cn_b
4147
if (cn_total == 2) and (n_clonal_parts > 1):
4248
warnings.warn('Please specify a single cluster when CN_A+CN_B=2')
43-
if cn_total in cn_totals:
44-
raise ValueError('Cannot specify two clusters with same CN_A+CN_B')
45-
cn_totals.add(cn_total)
4649
if cluster_id in copy_numbers:
4750
raise ValueError('Already encountered cluster_id =', str(cluster_id))
4851
copy_numbers[cluster_id] = cn_a, cn_b

0 commit comments

Comments
 (0)