Answers.Body: <p>Assuming the read name lines only contain things like <code>@JQ714243-920-1</code> and nothing else, then <code>sed -i '1~4 s/-[12]$//' file.fastq</code> (N.B., example updated a bit for safety, thanks to @terdon) will remove the <code>-1</code> and <code>-2</code> suffixes.</p>
  
  <p>However, you should try to figure out <strong>why</strong> the read names were munged into that form to begin with (at least Illumina machines won't produce that, I don't know about others).</p>
  
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-30T10:57:27.827Z
Answers.Text: You could also replace the the second - with a space. Most mapping tools only regard the part of the id before the first space as the read name.
Answers.UserDisplayName: Ian Sudbery
Answers.ContentLicense: CC BY-SA 3.0
Answers.CreationDate: 2017-11-29T11:15:07.257Z
Answers.LastActivityDate: 2017-11-29T12:22:52.360Z
Answers.LastEditDate: 2017-11-29T12:22:52.360Z
Answers.UserDisplayName: Devon Ryan
Body: <p>I'm currently trying to run bwa-mem on Influenza substrains using the following command: </p>
  
  <pre><code>~/bwa mem h5n1_1_cons.fa h5n1_1_read1.fq h5n1_1_read2.fq
  </code></pre>
  
  <p>h5n1_1_cons.fa is the consensus sequence for substrain h5n1_1, and the fq files are paired end reads 1 and 2. Running the program gives me this error: </p>
  
  <pre><code>[mem_sam_pe] paired reads have different names: "JQ714243-920-1", "JQ714243-920-2"
  </code></pre>
  
  <p>Visual inspection shows that the read names are identical until the last character. I have found a package (bbmap) with a utility, bbrename.sh, that renames the sequences, producing:</p>
  
  <pre><code>./bbrename.sh in=h5n1_1_read1.fq out=fixed prefix=h5n1_1
  </code></pre>
  
  <p>which yields the following output</p>
  
  <pre><code>-bash-4.2$ head fixh5n1_1_read1.fq
  @h5n1_0
  gaaaatgtctcaggagttgatgcatggtgtttaatctttggtttgcgctg
  +
  @4&gt;C5?7FA?9@@@;1,-4B+E??4E9,DA&gt;6CB)*2.)?7/.'65+75/
  @h5n1_1
  catcagttggattttgcctaaggatgtccaccatccttatcccaccaatt
  +
  7(9?)=C3AEF+@@F=C-E&gt;EE57CD:;'?.*?7;&gt;:3&gt;2.;29..)=2'
  @h5n1_2
  catgcatttgttggaataatgttctcacaaatcaactgtattgaccgctg
  </code></pre>
  
  <p>This fixes the problem and allows BWA-MEM to work. However, header information is discarded. Is there another way to ensure the header names are the same while retaining all header information?</p>
  
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-11-29T11:08:55.740Z
Comments.Text: Please [edit] your question and show us a few examples of the read names in your original input files. The output of `awk 'NR % 4 == 1{print $1}' h5n1_1_read1.fq | head` and `awk 'NR % 4 == 1{print $1}' h5n1_1_read2.fq | head` for example.
Comments.UserDisplayName: terdon
Comments.ContentLicense: CC BY-SA 3.0
Comments.CreationDate: 2017-11-30T07:47:52.840Z
Comments.Text: Since you mention bbmap already, why not use that for mapping your reads altogether? It is after all called bb*map*
Comments.UserDisplayName: holmrenser
Tags: <bwa><errors>
Title: Is there a more elegant solution to the bwa-mem: paired reads have different names error?
ThreadText: # Is there a more elegant solution to the bwa-mem: paired reads have different names error?
  
  (Asked by: username_0 on 2017-11-28)
  
  I'm currently trying to run bwa-mem on Influenza substrains using the following command:
  
  ```
  ~/bwa mem h5n1_1_cons.fa h5n1_1_read1.fq h5n1_1_read2.fq
  
  ```
  
  h5n1\_1\_cons.fa is the consensus sequence for substrain h5n1\_1, and the fq files are paired end reads 1 and 2. Running the program gives me this error:
  
  ```
  [mem_sam_pe] paired reads have different names: "JQ714243-920-1", "JQ714243-920-2"
  
  ```
  
  Visual inspection shows that the read names are identical until the last character. I have found a package (bbmap) with a utility, bbrename.sh, that renames the sequences, producing:
  
  ```
  ./bbrename.sh in=h5n1_1_read1.fq out=fixed prefix=h5n1_1
  
  ```
  
  which yields the following output
  
  ```
  -bash-4.2$ head fixh5n1_1_read1.fq
  @h5n1_0
  gaaaatgtctcaggagttgatgcatggtgtttaatctttggtttgcgctg
  +
  @4>C5?7FA?9@@@;1,-4B+E??4E9,DA>6CB)*2.)?7/.'65+75/
  @h5n1_1
  catcagttggattttgcctaaggatgtccaccatccttatcccaccaatt
  +
  7(9?)=C3AEF+@@F=C-E>EE57CD:;'?.*?7;>:3>2.;29..)=2'
  @h5n1_2
  catgcatttgttggaataatgttctcacaaatcaactgtattgaccgctg
  
  ```
  
  This fixes the problem and allows BWA-MEM to work. However, header information is discarded. Is there another way to ensure the header names are the same while retaining all header information?
  
  **Tags:** bwa, errors
  
  > **Comments:**
  > **username_1**: Please [edit] your question and show us a few examples of the read names in your original input files. The output of `awk 'NR % 4 == 1{print $1}' h5n1_1_read1.fq | head` and `awk 'NR % 4 == 1{print $1}' h5n1_1_read2.fq | head` for example.  
  > **username_2**: Since you mention bbmap already, why not use that for mapping your reads altogether? It is after all called bb*map*  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_3 on 2017-11-29. Score: 7 | Accepted answer
  
  Assuming the read name lines only contain things like `@JQ714243-920-1` and nothing else, then `sed -i '1~4 s/-[12]$//' file.fastq` (N.B., example updated a bit for safety, thanks to @username_1) will remove the `-1` and `-2` suffixes.
  
  However, you should try to figure out **why** the read names were munged into that form to begin with (at least Illumina machines won't produce that, I don't know about others).
  
  > **Comments:**
  > **username_4**: You could also replace the the second - with a space. Most mapping tools only regard the part of the id before the first space as the read name.  
  
  ---
  
  