Answers.Body: <p>You can exclude the 1D² reads by generate a list of the ids from the 1D² reads, then filtering those reads out from the 1D fastq files. Here's one way to do that using some <a href="https://github.com/gringer/bioinfscripts" rel="nofollow noreferrer">accessory scripts</a> that I have written:</p>
  
  <pre><code>$ cat 1d2_reads.fq | ~/scripts/fastx-length.pl | awk '{print $2}' &gt; readNames.txt
  $ cat 1d_reads.fq | ~/scripts/fastx-fetch.pl -v -i readNames.txt &gt; filtered_1d_reads.fq
  </code></pre>
  
  <p>In order to deal with the concatenated read IDs, it's necessary to switch to a language like Perl that supports the use of backreferences for the splitting. The following perl command (replacing the first line in the above procedure) inserts a line break after the 36th character in the 2nd value, then prints that value:</p>
  
  <pre><code>$ cat 1d2_reads.fq | ~/scripts/fastx-length.pl | perl -lane '$F[1] =~ s/(.{36})/$1\n/; print $F[1];' &gt; readNames.txt
  </code></pre>
  
  <p>So a full sequence of operations would look something like this:</p>
  
  <pre><code>$ cat 1d2_reads.fq | ~/scripts/fastx-length.pl | perl -lane '$F[1] =~ s/(.{36})/$1\n/; print $F[1];' &gt; readNames.txt
  $ cat 1d_reads.fq | ~/scripts/fastx-fetch.pl -v -i readNames.txt &gt; filtered_1d_reads.fq
  $ cat 1d2_reads.fq filtered_1d_reads.fq &gt; unique_reads.fq
  </code></pre>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2018-01-17T23:06:36.483Z
Answers.LastActivityDate: 2018-01-17T23:23:54.350Z
Answers.LastEditDate: 2018-01-17T23:23:54.350Z
Answers.UserDisplayName: gringer
Body: <p><em>This is summary of discussions and a question that was posted by <a href="https://twitter.com/devonorourke" rel="nofollow noreferrer">Devon O'Rourke</a> on <a href="https://twitter.com/devonorourke/status/951825589048168448" rel="nofollow noreferrer">Twitter</a></em></p>
  
  <p>Following Albacore basecalls on a 1D² library I get two sets of .fq files, summary stats, etc.: one for the 1D basecalling script, and one for the 1D² script. I'd like to use the reads generated from these scripts in a genome assembly.</p>
  
  <p>After a little bit of <code>grep</code> searching, it seems like there are overlapping reads among the 1D and 1D² directories - namely, those 1D reads that generated 1D² reads!</p>
  
  <p>How do people approach the choice of selecting which directory to pull the unique read from if you're planning on assembling a genome? I'd think that the 1D² reads are of higher quality and be preferred, but perhaps there are 1D² reads which are lower in quality than one of the two 1D pairs? </p>
  
  <p>Just looking for advice on how folks approach 1D² libraries, fastq outputs, and subsequent mapping. For what it's worth I'm hoping to use Minimap2 to proceed with alignments but am happy to hear others thoughts on alternatives.</p>
  
  <h2>Update</h2>
  
  <p>I tried the first solution proposed by @gringer, but my filtered_1d_reads.fq file contains same number of reads as raw_1d_reads.fq file.</p>
  
  <p>I'm pretty sure the problem is the naming convention difference between the linear and paired reads. linear reads always follow a read_id of alphanumeric (8)-(4)-(4)-(4)-(12), while paired reads are (8)-(4)-(4)-(4)-(20)-(4)-(4)-(4)-(12). When I looked at it in more detail, the paired read "read_id" naming is just a concatenation of the two linear "read_id"'s that are partnered. So that (20) value is really the last (12) of the first linear read, and the first (8) of the second linear pair.</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-01-18T08:06:26.477Z
Comments.Text: Bit silly, but here it goes. > I'd think that the 1D² reads are of higher quality and be preferred,
  > but perhaps there are 1D² reads which are lower in quality than one of
  > the two 1D pairs? Based on this it would make the most sense to have a script preferentially select 1D2 reads unless they have a lower quality than the 1D 'parents', and keep all 1D reads that did not contribute to a 1D2 read. I don't have a dataset to play with, but this shouldn't be too hard to write I believe.
Comments.UserDisplayName: Wouter De Coster
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-01-18T09:52:15.503Z
Comments.Text: An additional QC step (as suggested by @Wouter_De_Coster) would be a good idea. It could probably be done by using the run statistics file in the workspace directory to generate the read ids for filtering.
Comments.UserDisplayName: gringer
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2018-01-18T11:22:49.020Z
Comments.Text: Parsing the sequencing_summary.txt is convenient and fast. I have an old 2D example here in my test data folder, showing that it contains qscores of template, complement, and 2d. If that would be the same for 1D then filtering out 1D2 reads which we don't want to keep because they have lower quality than parents would be a breeze.
Comments.UserDisplayName: Wouter De Coster
Tags: <nanopore><1d2-reads>
Title: Removing repeated reads from nanopore 1D² reads
ThreadText: # Removing repeated reads from nanopore 1D² reads
  
  (Asked by: username_0 on 2018-01-17)
  
  *This is summary of discussions and a question that was posted by [Devon O'Rourke](https://twitter.com/devonorourke) on [Twitter](https://twitter.com/devonorourke/status/951825589048168448)*
  
  Following Albacore basecalls on a 1D² library I get two sets of .fq files, summary stats, etc.: one for the 1D basecalling script, and one for the 1D² script. I'd like to use the reads generated from these scripts in a genome assembly.
  
  After a little bit of `grep` searching, it seems like there are overlapping reads among the 1D and 1D² directories - namely, those 1D reads that generated 1D² reads!
  
  How do people approach the choice of selecting which directory to pull the unique read from if you're planning on assembling a genome? I'd think that the 1D² reads are of higher quality and be preferred, but perhaps there are 1D² reads which are lower in quality than one of the two 1D pairs?
  
  Just looking for advice on how folks approach 1D² libraries, fastq outputs, and subsequent mapping. For what it's worth I'm hoping to use Minimap2 to proceed with alignments but am happy to hear others thoughts on alternatives.
  
  ## Update
  
  I tried the first solution proposed by @username_0, but my filtered\_1d\_reads.fq file contains same number of reads as raw\_1d\_reads.fq file.
  
  I'm pretty sure the problem is the naming convention difference between the linear and paired reads. linear reads always follow a read\_id of alphanumeric (8)-(4)-(4)-(4)-(12), while paired reads are (8)-(4)-(4)-(4)-(20)-(4)-(4)-(4)-(12). When I looked at it in more detail, the paired read "read\_id" naming is just a concatenation of the two linear "read\_id"'s that are partnered. So that (20) value is really the last (12) of the first linear read, and the first (8) of the second linear pair.
  
  **Tags:** nanopore, 1d2-reads
  
  > **Comments:**
  > **username_1**: Bit silly, but here it goes. > I'd think that the 1D² reads are of higher quality and be preferred, > but perhaps there are 1D² reads which are lower in quality than one of > the two 1D pairs? Based on this it would make the most sense to have a script preferentially select 1D2 reads unless they have a lower quality than the 1D 'parents', and keep all 1D reads that did not contribute to a 1D2 read. I don't have a dataset to play with, but this shouldn't be too hard to write I believe.  
  > **username_0**: An additional QC step (as suggested by @username_1) would be a good idea. It could probably be done by using the run statistics file in the workspace directory to generate the read ids for filtering.  
  > **username_1**: Parsing the sequencing_summary.txt is convenient and fast. I have an old 2D example here in my test data folder, showing that it contains qscores of template, complement, and 2d. If that would be the same for 1D then filtering out 1D2 reads which we don't want to keep because they have lower quality than parents would be a breeze.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_0 on 2018-01-17. Score: 1 | Accepted answer
  
  You can exclude the 1D² reads by generate a list of the ids from the 1D² reads, then filtering those reads out from the 1D fastq files. Here's one way to do that using some [accessory scripts](https://github.com/username_0/bioinfscripts) that I have written:
  
  ```
  $ cat 1d2_reads.fq | ~/scripts/fastx-length.pl | awk '{print $2}' > readNames.txt
  $ cat 1d_reads.fq | ~/scripts/fastx-fetch.pl -v -i readNames.txt > filtered_1d_reads.fq
  
  ```
  
  In order to deal with the concatenated read IDs, it's necessary to switch to a language like Perl that supports the use of backreferences for the splitting. The following perl command (replacing the first line in the above procedure) inserts a line break after the 36th character in the 2nd value, then prints that value:
  
  ```
  $ cat 1d2_reads.fq | ~/scripts/fastx-length.pl | perl -lane '$F[1] =~ s/(.{36})/$1\n/; print $F[1];' > readNames.txt
  
  ```
  
  So a full sequence of operations would look something like this:
  
  ```
  $ cat 1d2_reads.fq | ~/scripts/fastx-length.pl | perl -lane '$F[1] =~ s/(.{36})/$1\n/; print $F[1];' > readNames.txt
  $ cat 1d_reads.fq | ~/scripts/fastx-fetch.pl -v -i readNames.txt > filtered_1d_reads.fq
  $ cat 1d2_reads.fq filtered_1d_reads.fq > unique_reads.fq
  
  ```
  
  
  ---
  
  