import random import string import os def generate_dna_file(n_rows, m_columns, output_dir='script_results/dna_files'): # Create output directory if it doesn't exist os.makedirs(output_dir, exist_ok=True) # Generate the random DNA sequence dna_sequence = [''.join(random.choices('ATCG', k=m_columns)) for _ in range(n_rows)] # Create the filename based on the number of rows and columns filename = f'random_ATCG_{m_columns}x{n_rows}.txt' filepath = os.path.join(output_dir, filename) # Write the DNA sequence to the file with open(filepath, 'w') as f: for line in dna_sequence: f.write(line + '\n') print(f'File saved to: {filepath}') # Example usage if __name__ == "__main__": n_rows = 2000000 # Number of rows m_columns = 50 # Number of columns per row generate_dna_file(n_rows, m_columns)