<div dir="ltr"><div><div><div>Hello Daniel,<br><br></div>The whole point of the FASTQ APIs in biojava is to support conversions as you are trying to do, so you shouldn&#39;t have to do it yourself.<br><br></div>I would also be interested in seeing (some of) your input data.  If you&#39;ve found a historical edge case, or something that otherwise bends the rules, we could add it to the repo as another test case.<br><br></div>   michael<br><div><div><br><br><div><div><div class="gmail_extra"><div class="gmail_quote">On Wed, Sep 16, 2015 at 2:22 AM, Peter Cock <span dir="ltr">&lt;<a href="mailto:p.j.a.cock@googlemail.com" target="_blank">p.j.a.cock@googlemail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">Hi Daniel,<br>
<br>
I can&#39;t help you on the BioJava specifics, but do your input files really<br>
have Illumina&#39;s old FASTQ quality encoding? Can you show use the<br>
first couple of records which is usually enough to guess.<br>
<br>
<a href="http://dx.doi.org/10.1093/nar/gkp1137" rel="noreferrer" target="_blank">http://dx.doi.org/10.1093/nar/gkp1137</a><br>
<br>
Peter<br>
<div><div class="h5"><br>
On Wed, Sep 16, 2015 at 4:28 AM, Daniel Katzel &lt;<a href="mailto:dkatzel@gmail.com">dkatzel@gmail.com</a>&gt; wrote:<br>
&gt; Sorry if this has been asked many times, but I couldn&#39;t find it when<br>
&gt; searching the mailing list or popular forums. When I follow the BioJava<br>
&gt; cookbook to convert a Sanger fastq file into an illumina fastq I get<br>
&gt; validation errors.<br>
&gt;<br>
&gt; The cookbook<br>
&gt;<br>
&gt; <a href="http://biojava.org/wiki/BioJava:CookBook3:FASTQ#Convert_between_FASTQ_variants_using_streaming_API" rel="noreferrer" target="_blank">http://biojava.org/wiki/BioJava:CookBook3:FASTQ#Convert_between_FASTQ_variants_using_streaming_API</a><br>
&gt;<br>
&gt; says this will work:<br>
&gt;<br>
&gt; FastqReader fastqReader = new IlluminaFastqReader();<br>
&gt; final FastqWriter fastqWriter = new SangerFastqWriter();<br>
&gt; final FileWriter fileWriter = new FileWriter(new File(&quot;sanger.fastq&quot;))));<br>
&gt; InputStream in = ...<br>
&gt;<br>
&gt; fastqReader.stream(in, new StreamListener()<br>
&gt;   {<br>
&gt;     @Override<br>
&gt;     public void fastq(final Fastq fastq)<br>
&gt;     {<br>
&gt;       fastqWriter.append(fileWriter, fastq);<br>
&gt;     }<br>
&gt;   });<br>
&gt;<br>
&gt;<br>
&gt; But instead it throws this error:<br>
&gt;<br>
&gt; Caused by: java.io.IOException: sequence SRR062634.1<br>
&gt; HWI-EAS110_103327062:6:1:1092:8469/1 not fastq-illumina format, was<br>
&gt; fastq-sanger<br>
&gt;         at<br>
&gt; org.biojava.nbio.sequencing.io.fastq.IlluminaFastqWriter.validate(IlluminaFastqWriter.java:43)<br>
&gt;         at<br>
&gt; org.biojava.nbio.sequencing.io.fastq.AbstractFastqWriter.append(AbstractFastqWriter.java:62)<br>
&gt;         at<br>
&gt; org.biojava.nbio.sequencing.io.fastq.AbstractFastqWriter.append(AbstractFastqWriter.java:46)<br>
&gt;<br>
&gt;<br>
&gt; My workaround was to create a new Fastq instance inside the<br>
&gt; StreamListener#fastq() method to manually convert the quality chars<br>
&gt;<br>
&gt;<br>
&gt;  char[] oldQual = fastq.getQuality().toCharArray();<br>
&gt;                     char[] newQual = new char[oldQual.length];<br>
&gt;                     for(int i=0; i&lt; oldQual.length; i++){<br>
&gt;                         newQual[i] =<br>
&gt; FastqVariant.FASTQ_ILLUMINA.quality(FastqVariant.FASTQ_SANGER.qualityScore(oldQual[i]));<br>
&gt;                     }<br>
&gt;<br>
&gt;                     Fastq newFastq = new<br>
&gt; FastqBuilder().withDescription(fastq.getDescription())<br>
&gt;                                     .withSequence(fastq.getSequence())<br>
&gt;                                     .withQuality(new String(newQual))<br>
&gt;<br>
&gt; .withVariant(FastqVariant.FASTQ_ILLUMINA)<br>
&gt;                                     .build();<br>
&gt;                     try {<br>
&gt;                         fastqWriter.append(writer, newFastq);<br>
&gt;                     } catch (IOException e) {<br>
&gt;                        throw new UncheckedIOException(e);<br>
&gt;                     }<br>
&gt;<br>
&gt;<br>
&gt; Is that the correct way to do it? Is there a better way?<br>
&gt;<br>
&gt; Thanks<br>
&gt;<br>
</div></div>&gt; _______________________________________________<br>
&gt; Biojava-l mailing list  -  <a href="mailto:Biojava-l@mailman.open-bio.org">Biojava-l@mailman.open-bio.org</a><br>
&gt; <a href="http://mailman.open-bio.org/mailman/listinfo/biojava-l" rel="noreferrer" target="_blank">http://mailman.open-bio.org/mailman/listinfo/biojava-l</a><br>
_______________________________________________<br>
Biojava-l mailing list  -  <a href="mailto:Biojava-l@mailman.open-bio.org">Biojava-l@mailman.open-bio.org</a><br>
<a href="http://mailman.open-bio.org/mailman/listinfo/biojava-l" rel="noreferrer" target="_blank">http://mailman.open-bio.org/mailman/listinfo/biojava-l</a><br>
</blockquote></div><br></div></div></div></div></div></div>