def fastq_to_fasta(fastq_file, fasta_file):
with open(fastq_file, 'r') as fq:
with open(fasta_file, 'w') as fa:
while True:
# Read four lines from the FASTQ file
header = fq.readline().strip()
sequence = fq.readline().strip()
fq.readline() # Skip the '+' line
quality = fq.readline().strip()
# Check for EOF
if not header:
break
# Write to the FASTA file
fa.write('>' + header[1:] + '\n')
fa.write(sequence + '\n')
# Usage example
fastq_to_fasta('input.fastq', 'output.fasta')