Our Sponsors



Download BioinformaticsOnline(BOL) Apps in your chrome browser.




  • BioScripts
  • Abhi
  • Python script to create fastq file with random sequences

Python script to create fastq file with random sequences

  • Public
By Abhi 164 days ago
import random def generate_random_sequence(length): bases = ['A', 'C', 'G', 'T'] return ''.join(random.choice(bases) for _ in range(length)) def generate_random_quality(length): return ''.join(chr(random.randint(33, 73)) for _ in range(length)) def generate_fastq_entry(sequence_length): sequence = generate_random_sequence(sequence_length) quality = generate_random_quality(sequence_length) return f"@SEQ_ID\n{sequence}\n+\n{quality}\n" def generate_fastq_file(num_entries, sequence_length, file_path): with open(file_path, 'w') as f: for _ in range(num_entries): entry = generate_fastq_entry(sequence_length) f.write(entry) # Generate a FASTQ file with 5 entries, each with a sequence length of 50 bases generate_fastq_file(100, 50, 'random.fastq')