Answers.Body: <p>A simple Biopython solution:</p>
  <pre><code>from Bio import SeqIO
  
  for r in SeqIO.parse(&quot;myfile.fa&quot;, &quot;fasta&quot;):
      r.letter_annotations[&quot;solexa_quality&quot;] = [40] * len(r)
      print(r.format(&quot;fastq&quot;), end='')
  </code></pre>
  <p>Example:</p>
  <pre><code><span class="math-container">$ cat &lt;&lt; EOF &gt; myfile.fa 
  &gt;1
  ATG
  &gt;2
  ATGTAGA
  EOF
  $</span> python3 myscript.py 
  @1
  ATG
  +
  III
  @2
  ATGTAGA
  +
  IIIIIII
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-20T20:59:28.290Z
Answers.LastActivityDate: 2021-04-30T12:26:16.180Z
Answers.LastEditDate: 2021-04-30T12:26:16.180Z
Answers.UserDisplayName: Chris_Rands
Answers.Body: <p>Here's a quick one-liner with no dependencies other than the UNIX core utils and Perl.</p>
  
  <pre><code>cat seqs.fasta | paste - - | perl -ne 'chomp; s/^&gt;/@/; @v = split /\t/; printf("%s\n%s\n+\n%s\n", $v[0], $v[1], "B"x length($v[1]))' &gt; seqs.fastq
  </code></pre>
  
  <p>Caveat: assumes your Fasta sequences are not wrapped, i.e. two lines per record.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-22T14:42:30.503Z
Answers.LastActivityDate: 2020-01-22T14:42:30.503Z
Answers.UserDisplayName: Daniel Standage
Answers.Body: <p>I think the python package <a href="https://bioconvert.readthedocs.io/en/master/user_guide.html#explicit-conversion" rel="nofollow noreferrer">bioconvert</a> does what you want if you don't provide qualities: <a href="https://github.com/bioconvert/bioconvert/blob/master/bioconvert/fasta2fastq.py" rel="nofollow noreferrer">https://github.com/bioconvert/bioconvert/blob/master/bioconvert/fasta2fastq.py</a></p>
  
  <p>The following outputs lots of warnings for me, but does generate a fastq file <code>test.fq</code> from an existing fasta file <code>test.fa</code> (using dummy quality "I", and adding "None" to sequence headers that do not have a comment part in the original fasta):</p>
  
  <pre><code>bioconvert fasta2fastq test.fa test.fq
  </code></pre>
  
  <p>(This requires installing bioconvert using <code>pip</code> beforehand: <code>pip install bioconvert</code>.)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-21T10:39:06.400Z
Answers.LastActivityDate: 2020-01-22T11:45:44.253Z
Answers.LastEditDate: 2020-01-22T11:45:44.253Z
Answers.UserDisplayName: bli
Answers.Body: <p>I have just uploaded a Python tool to convert fasta to fastq: <a href="https://github.com/Mostafa-MR/A_tool_to_convert_fasta_to_fastq" rel="nofollow noreferrer">https://github.com/Mostafa-MR/A_tool_to_convert_fasta_to_fastq</a></p>
  <p>Please note this is presented directly from a Jupyter notebook, i.e. it is a ipynb.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2022-03-17T01:00:41.417Z
Answers.LastActivityDate: 2022-03-17T01:06:24.740Z
Answers.LastEditDate: 2022-03-17T01:06:24.740Z
Answers.UserDisplayName: Mostafa M. Rezaee
Answers.Body: <p>One way of doing this is with two subcommands from the <a href="https://github.com/sanger-pathogens/Fastaq" rel="nofollow noreferrer"><code>pyfastaq</code></a> suite.</p>
  
  <pre class="lang-sh prettyprint-override"><code>fastaq to_fake_qual in.fasta - | fastaq fasta_to_fastq in.fasta - out.fastq
  </code></pre>
  
  <p>The first tool, <code>to_fake_qual</code>, creates fake quality scores (default 40) for each base and the <code>-</code> sends that file (<code>.qual</code>) to stdout. The second tool, <code>fasta_to_fastq</code>, consumes both the original fasta and the quality scores coming from stdin and turns these into a fastq file.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2020-01-20T14:15:13.417Z
Answers.LastActivityDate: 2020-01-20T14:15:13.417Z
Answers.UserDisplayName: Michael Hall
Body: <p>I have a FASTA file which I would like to convert into FASTQ format as the tool I want to use my data in requires it in FASTQ format. So dummy quality scores are fine.</p>
  
  <p>Note: I am not using any functionality of the tool that will require the quality score.</p>
  
Tags: <fasta><fastq>
Title: Convert FASTA to FASTQ with dummy quality scores
ThreadText: # Convert FASTA to FASTQ with dummy quality scores
  
  (Asked by: username_0 on 2020-01-20)
  
  I have a FASTA file which I would like to convert into FASTQ format as the tool I want to use my data in requires it in FASTQ format. So dummy quality scores are fine.
  
  Note: I am not using any functionality of the tool that will require the quality score.
  
  **Tags:** fasta, fastq
  
  
  ---
  
  ## 5 answers
  
  ### Answer by username_0 on 2020-01-20. Score: 4 | Accepted answer
  
  One way of doing this is with two subcommands from the [`pyfastaq`](https://github.com/sanger-pathogens/Fastaq) suite.
  
  ```sh
  fastaq to_fake_qual in.fasta - | fastaq fasta_to_fastq in.fasta - out.fastq
  
  ```
  
  The first tool, `to_fake_qual`, creates fake quality scores (default 40) for each base and the `-` sends that file (`.qual`) to stdout. The second tool, `fasta_to_fastq`, consumes both the original fasta and the quality scores coming from stdin and turns these into a fastq file.
  
  
  ---
  
  ### Answer by username_1 on 2020-01-20. Score: 6
  
  A simple Biopython solution:
  
  ```
  from Bio import SeqIO
  
  for r in SeqIO.parse("myfile.fa", "fasta"):
      r.letter_annotations["solexa_quality"] = [40] * len(r)
      print(r.format("fastq"), end='')
  
  ```
  
  Example:
  
  ```
  $ cat << EOF > myfile.fa 
  >1
  ATG
  >2
  ATGTAGA
  EOF
  $ python3 myscript.py 
  @1
  ATG
  +
  III
  @2
  ATGTAGA
  +
  IIIIIII
  
  ```
  
  
  ---
  
  ### Answer by username_2 on 2020-01-22. Score: 2
  
  Here's a quick one-liner with no dependencies other than the UNIX core utils and Perl.
  
  ```
  cat seqs.fasta | paste - - | perl -ne 'chomp; s/^>/@/; @v = split /\t/; printf("%s\n%s\n+\n%s\n", $v[0], $v[1], "B"x length($v[1]))' > seqs.fastq
  
  ```
  
  Caveat: assumes your Fasta sequences are not wrapped, i.e. two lines per record.
  
  
  ---
  
  ### Answer by username_3 on 2020-01-21. Score: 2
  
  I think the python package [bioconvert](https://bioconvert.readthedocs.io/en/master/user_guide.html#explicit-conversion) does what you want if you don't provide qualities: <https://github.com/bioconvert/bioconvert/blob/master/bioconvert/fasta2fastq.py>
  
  The following outputs lots of warnings for me, but does generate a fastq file `test.fq` from an existing fasta file `test.fa` (using dummy quality "I", and adding "None" to sequence headers that do not have a comment part in the original fasta):
  
  ```
  bioconvert fasta2fastq test.fa test.fq
  
  ```
  
  (This requires installing bioconvert using `pip` beforehand: `pip install bioconvert`.)
  
  
  ---
  
  ### Answer by username_4 on 2022-03-17. Score: 0
  
  I have just uploaded a Python tool to convert fasta to fastq: <https://github.com/username_4-MR/A_tool_to_convert_fasta_to_fastq>
  
  Please note this is presented directly from a Jupyter notebook, i.e. it is a ipynb.
  
  
  ---
  
  