Esempio n. 1
0
def run(indices):

    starting_barcode_map = datadir + '/populations/barcode_map_pyndexact_0_ATCAGT.pkl'
    library = homedir + '/allele_dic_with_WT.pkl'

    fastqs = []
    for i in range(0, len(indices)):
        fastqs.append(homedir + '/pynd_indices/pynd_' + str(i) + '_' +
                      indices[i] + '.fastq')

    processes = []
    for i in range(0, len(indices)):
        print("Running map_barcodes " + str(i))
        process = mp.Process(target=map_barcodes.update_read_map,
                             args=(fastqs[i], library, max_hamming_dist))
        processes.append(process)
        process.start()

    for process in processes:
        process.join()

    freqs_outputs = []
    for i in range(0, len(indices)):
        freqs_outputs.append(datadir + '/freqs_' + str(i) + '_' + indices[i] +
                             '.pkl')

    for i in range(0, len(indices)):
        print("Running freqs " + str(i))
        result = counts.calc_mutant_freqs(fastqs[i], library, freqs_outputs[i])
        with open(freqs_outputs[i], 'wb') as f:
            pickle.dump(result, f)
Esempio n. 2
0
def run(indices):

	starting_barcode_map = datadir + '/populations/barcode_map_pyndexact_0_ATCAGT.pkl'
	library = homedir + '/allele_dic_with_WT.pkl'

	fastqs = []
	for i in range(0, len(indices)):
		fastqs.append(homedir + '/pynd_indices/pynd_' + str(i) + '_' + indices[i] + '.fastq')

	processes = []
	for i in range(0, len(indices)):
		print("Running map_barcodes " + str(i))
		process = mp.Process(target=map_barcodes.update_read_map, args=(fastqs[i], library, max_hamming_dist))
		processes.append(process)
		process.start()

	for process in processes:
		process.join()

	freqs_outputs = []
	for i in range(0, len(indices)):
		freqs_outputs.append(datadir + '/freqs_' + str(i) + '_' + indices[i] + '.pkl')

	for i in range(0, len(indices)):
		print("Running freqs " + str(i))
		result = counts.calc_mutant_freqs(fastqs[i], library, freqs_outputs[i]) 
		with open(freqs_outputs[i], 'wb') as f: pickle.dump(result, f)
	def test(self, rev_comp):
		print("Running")
		#rev_comp.side_effect = lambda s: s
		#records = list(parse.load_fastq('../test_resources/test_allele_shortrevcomp.fastq'))
		records = []
		records.extend([FastQRecord('a', 'a', ''), FastQRecord('a', 'a', ''), FastQRecord('a', 'a', ''), FastQRecord('b', 'b', ''), FastQRecord('b', 'b', ''), FastQRecord('c', 'c', '')])
		library = ['A', 'B', 'C']
		red = Red()
		red.data = {'a': 'A', 'aa': 'A', 'aaa': 'A', 'b': 'B', 'bb': 'B', 'c': 'C'}
		red.data = {lambda key, val: key: prefix + val for key, val in red.data.items()}

		#read_count = 0
		def side_effect(self):
			log.debug(self.sequence)
			return self.sequence
			#read_count += 1
			#return records[read_count - 1].sequence

		#rev_comp.side_effect = lambda self: self.sequence
		#rev_comp.side_effect = side_effect
		freqs = count.calc_mutant_freqs(records, red, library)
		print(freqs)