Skip to content

Commit 1b5b48b

Browse files
authored
Merge pull request #142 from marbl/deterministic-output
Order results before shuffling
2 parents f80a15a + 46495cf commit 1b5b48b

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

parsnp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -22,15 +22,14 @@ from multiprocessing import Pool
2222
from Bio import SeqIO
2323
from glob import glob
2424
from pathlib import Path
25-
from random import shuffle
2625

2726

2827
import extend as ext
2928
from tqdm import tqdm
3029

31-
__version__ = "2.0.0"
30+
__version__ = "2.0.1"
3231
reroot_tree = True #use --midpoint-reroot
33-
random.seed(42)
32+
random_seeded = random.Random(42)
3433

3534
try:
3635
import dendropy
@@ -1223,7 +1222,7 @@ SETTINGS:
12231222
reflen = 0
12241223

12251224
if ref == "!":
1226-
ref = random.choice(input_files)
1225+
ref = random_seeded.choice(input_files)
12271226

12281227
# Check if reference genome is aligned
12291228
reflen = check_ref_genome_aligned(ref)
@@ -1444,6 +1443,7 @@ SETTINGS:
14441443
ffo.close()
14451444
ref = auto_ref
14461445

1446+
finalfiles = sorted(finalfiles)
14471447
totseqs = len(finalfiles)
14481448

14491449
#initiate parallelPhiPack tasks
@@ -1614,7 +1614,7 @@ SETTINGS:
16141614

16151615
full_query_list_path = f"{outputDir}/config/input-list.txt"
16161616
with open(full_query_list_path, 'w') as input_list_handle:
1617-
shuffle(finalfiles)
1617+
random_seeded.shuffle(finalfiles)
16181618
for qf in finalfiles:
16191619
input_list_handle.write(qf + "\n")
16201620

@@ -1651,7 +1651,7 @@ SETTINGS:
16511651
logger.error(f"Partition {cl} failed...")
16521652
good_chunks.remove(cl)
16531653

1654-
chunk_labels = list(good_chunks)
1654+
chunk_labels = sorted(list(good_chunks))
16551655

16561656
logger.info("Computing intersection of all partition LCBs...")
16571657
chunk_to_intvervaldict = partition.get_chunked_intervals(partition_output_dir, chunk_labels)

0 commit comments

Comments
 (0)