@@ -0,0 +1,2429 @@
+# This script will test the issue where the file name order when you form the training database%0A# does not match the file name order when you read the training database back in%0Aimport khmer%0Aimport marisa_trie as mt%0Aimport numpy as np%0Aimport os%0Aimport sys%0A# The following is for ease of development (so I don't need to keep re-installing the tool)%0Atry:%0A%09from CMash import MinHash as MH%0Aexcept ImportError:%0A%09try:%0A%09%09import MinHash as MH%0A%09except ImportError:%0A%09%09sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__))))%0A%09%09from CMash import MinHash as MH%0Aimport multiprocessing%0Aimport pandas as pd%0Aimport argparse%0Afrom argparse import ArgumentTypeError%0Aimport re%0Aimport matplotlib.pyplot as plt%0Afrom hydra import WritingBloomFilter, ReadingBloomFilter%0Afrom scipy.sparse import csr_matrix, csc_matrix%0Afrom scipy.sparse import save_npz%0Afrom scipy.io import savemat%0Aimport timeit%0Afrom itertools import islice%0A%0Anum_train = 10%0A%0A# Read in all the file names%0Aall_file_names = %5B%5D%0Awith open(%22/nfs1/Koslicki_Lab/koslickd/MiCOPCMash/TrainingData/NathanRefSeq/absolute_file_names.txt%22, %22r%22) as fid:%0A%09for line in fid.readlines():%0A%09%09all_file_names.append(line.strip())%0A%0A# form the training database on a few of them%0Asubset_file_names_file = %22/nfs1/Koslicki_Lab/koslickd/MiCOPCMash/TrainingData/NathanRefSeq/TestFileNameOrder/FileNames.txt%22%0Awith open(subset_file_names_file, %22w%22) as fid:%0A%09for i in range(num_train):%0A%09%09fid.write(%22%25s%5Cn%22 %25 all_file_names%5Bi%5D)%0A%0Aout_hdf5_file = %22/nfs1/Koslicki_Lab/koslickd/MiCOPCMash/TrainingData/NathanRefSeq/TestFileNameOrder/TrainingData.h5%22%0Apython = %22/nfs1/Koslicki_Lab/koslickd/MiCOPCMash/CMashVE/bin/python %22%0Ascript = %22/nfs1/Koslicki_Lab/koslickd/MiCOPCMash/CMash/scripts/MakeStreamingDNADatabase.py %22%0Ascript_args = subset_file_names_file + %22 %22 + out_hdf5_file + %22 -n 1000 -k 60%22%0Aos.system(python + script + script_args)%0A%0A# Import the HDF5 file%0Asketches = MH.import_multiple_from_single_hdf5(out_hdf5_file)%0Atree = mt.Trie()%0Atree.load(out_hdf5_file.split('.')%5B0%5D + %22.tst%22)%0A%0Afor sketch_index in range(num_train):%0A%09for kmer in sketches%5Bsketch_index%5D._kmers:%0A%09%09is_correct = False%0A%09%09for hit in tree.keys(kmer):%0A%09%09%09hit_split = hit.split('x')%0A%09%09%09tree_sketch_index = int(hit_split%5B1%5D)%0A%09%09%09if tree_sketch_index == sketch_index:%0A%09%09%09%09is_correct = True%0A%09%09%09%09break%0A%09%09if not is_correct:%0A%09%09%09raise Exception(%22Mismatch: sketch index was %25d while in the tree it's %25d: %25s%22 %25 (sketch_index, tree_sketch_index, hit))

add test for file name order