Skip to content

Commit

Permalink
Merge pull request #142 from marbl/deterministic-output
Browse files Browse the repository at this point in the history
Order results before shuffling
  • Loading branch information
bkille authored Jan 16, 2024
2 parents f80a15a + 46495cf commit 1b5b48b
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions parsnp
Original file line number Diff line number Diff line change
Expand Up @@ -22,15 +22,14 @@ from multiprocessing import Pool
from Bio import SeqIO
from glob import glob
from pathlib import Path
from random import shuffle


import extend as ext
from tqdm import tqdm

__version__ = "2.0.0"
__version__ = "2.0.1"
reroot_tree = True #use --midpoint-reroot
random.seed(42)
random_seeded = random.Random(42)

try:
import dendropy
Expand Down Expand Up @@ -1223,7 +1222,7 @@ SETTINGS:
reflen = 0

if ref == "!":
ref = random.choice(input_files)
ref = random_seeded.choice(input_files)

# Check if reference genome is aligned
reflen = check_ref_genome_aligned(ref)
Expand Down Expand Up @@ -1444,6 +1443,7 @@ SETTINGS:
ffo.close()
ref = auto_ref

finalfiles = sorted(finalfiles)
totseqs = len(finalfiles)

#initiate parallelPhiPack tasks
Expand Down Expand Up @@ -1614,7 +1614,7 @@ SETTINGS:

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

Expand Down Expand Up @@ -1651,7 +1651,7 @@ SETTINGS:
logger.error(f"Partition {cl} failed...")
good_chunks.remove(cl)

chunk_labels = list(good_chunks)
chunk_labels = sorted(list(good_chunks))

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

0 comments on commit 1b5b48b

Please sign in to comment.