def run(tfea_csv, experiment, outdir, N=500, seed=True): logfile = ''.join([outdir, '/', experiment, '_LOG.txt']) sys.stdout = open(logfile, "w") print( "Log file for sequences generated based on some back ground distribution. \n" ) if seed == 0: np.random.seed() print("--------------------------------------------------------------") print("-----------Setting seed for the sequence generator.-----------") print("Using random seed..............................") print( "WARNING: Sequences generated using a random seed can not be reproduced." ) elif seed is True: np.random.seed(global_seed()) else: np.random.seed(seed) print("--------------------------------------------------------------") print("-----------Setting seed for the sequence generator.-----------") print("User defined seed..............................:", seed, "\n") print("--------------------------------------------------------------") print("-----------Reading per-base sequence frequency----------------", "\n") ##get the sequences from teh frequency calculator position_prob = sequence_input(tfea_csv) print("--------------------------------------------------------------") print("-----------Generating sequences-------------------------------", "\n") ##generate sequences #sequences_generating = sequence_generator(sequences, experiment, seq_len=seq_len, N = N) generating_sequences = sequence_generator(bases=['A', 'T', 'G', 'C'], N=N, position_feq=position_prob) generating_headers = fasta_header(experiment, N=N) print("--------------------------------------------------------------") print("-----------Writing sequences to fasta file--------------------", "\n") ##write sequences to fasta file #write_fasta(sequences_generating, experiment, outdir) write_fasta(generating_sequences, generating_headers, experiment, outdir) print("--------------------------------------------------------------") print("----------------------------DONE------------------------------") stop_time = int(time.time()) print("Run time :", stop_time - start_time, " seconds")
def gen(): """Return a fresh new generator object for each test""" return sequence_generator()