File: fasta_to_fastq.py

package info (click to toggle)
hinge 0.5.0-8
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 2,972 kB
  • sloc: cpp: 9,480; ansic: 8,826; python: 5,023; sh: 340; makefile: 10
file content (20 lines) | stat: -rwxr-xr-x 454 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/python3
"""
Convert FASTA to FASTQ file with a static

Usage:
$ ./fasta_to_fastq NAME.fasta NAME.fastq
"""

import sys, os
from Bio import SeqIO

# Get inputs
fa_path = sys.argv[1]
fq_path = sys.argv[2]

# make fastq
with open(fa_path, "r") as fasta, open(fq_path, "w") as fastq:
    for record in SeqIO.parse(fasta, "fasta"):
        record.letter_annotations["phred_quality"] = [40] * len(record)
        SeqIO.write(record, fastq, "fastq")