# How to change fastq header?

**URL:** <https://help.galaxyproject.org/t/how-to-change-fastq-header/3826>\
**Category:** usegalaxy.eu support\
**Tags:** text-manipulation, quality-control\
**Created:** [June 2, 2020, 12:31am UTC](https://help.galaxyproject.org/t/how-to-change-fastq-header/3826 "2020-06-02T00:31:37Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![miaeyaho](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/miaeyaho/32/1535_2.png) [@miaeyaho](https://help.galaxyproject.org/u/miaeyaho)\
**Post date:** [June 2, 2020, 12:31am UTC](https://help.galaxyproject.org/t/how-to-change-fastq-header/3826/1 "2020-06-02T00:31:37Z")

</div>

Hello, I have a fastq file with this header.

@1/1  
NNNNNNNNNNNNNNNNNNNNNNNNNNN  
+  
#############################  
@2/1  
NNNNNNNNNNNNNNNNNNNNNNNNNNN  
+  
#############################  
@3/1  
NNNNNNNNNNNNNNNNNNNNNNNNNNN  
+  
#############################

But I need to replace the header from “/1” to “/2”  
so it looks like this.

@1/2  
NNNNNNNNNNNNNNNNNNNNNNNNNNN  
+  
#############################  
@2/2  
NNNNNNNNNNNNNNNNNNNNNNNNNNN  
+  
#############################  
@3/2  
NNNNNNNNNNNNNNNNNNNNNNNNNNN  
+  
#############################

How can I replace this to every line?  
If the Galaxy tool is “Manipulate FASTQ”, I wanna know the string syntax. Many thanks!

Miae

---

<div class="post-metadata">

**Author:** ![jennaj](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/jennaj/32/27_2.png) [@jennaj](https://help.galaxyproject.org/u/jennaj)\
**Post date:** [June 2, 2020, 1:26am UTC](https://help.galaxyproject.org/t/how-to-change-fastq-header/3826/2 "2020-06-02T01:26:45Z")

</div>

Hello @miaeyaho

**Update** – Upon further review, have determined that `Manipulate FASTQ` is NOT a good tool choice for this particular task (for technical reasons around how the tool is designed). The tool does not interpret the entire string as a “word”. Instead, the function performs a direct translation, per character. _This is useful in other situations, but not for this one_.

How it works: the first character in the “from” string is translated to the first character in the “to” string; the second translated to the second; etc.

How this poorly impacts the result: All `1` characters will be translated to a `2` characters. Not just those following a `/`. The `/` is replaced by another `/`.

Apologies, I should have tested this out first. Try `Sed` as described in the other followup post. There is still likely a Python-version issue with the `Manipulate FASTQ` tool at [usegalaxy.eu](http://usegalaxy.eu) … and it will be addressed … but even once that is done, don’t use this tool for `/1` \> `/2` manipulation.

There are many ways/tools to “find/replace” data content, across datatypes, and the `Sed` tool is one good choice. The “find” portion of the substitution function can be customized to fit any text characters, and the “replace” can also be fully customized. Other “find/replace” tools were created to make data substitution functions easier to perform – search the tool panel with the keyword “replace” to explore options if interested. Then test out your desired manipulation across the tools and see which produce the result you want – each act on data a little bit differently.

That said, `sed` is worth learning how to use for many, even if just the simpler functions (like substations, aka `s/find/replace/`. It is a common and stable command-line utility. The way it is used/interpreted in Galaxy is near exact to command-line usage. A web search will return many resources for `sed` usage, examples, tutorials, tips&tricks, Q&A. There are also many “regular expression” syntax resources (including web forms where expressions can be “tested” as interpreted across several common utilities/scripting languages). Tool forms generally note which “type” of regular expression syntax is supported by the tool, along with basic syntax descriptions, examples, and link-outs to resources.

* * *

~~Yes, that would be a good tool choice.~~ **Incorrect, apologies!** Everything below is WRONG for the original usage, but I’m leaving it posted since sometimes explaining what _doesn’t work_ helps everyone to learn, discover and understand what _will work_, and importantly, _why_.

String translate the name/identifier. All reads in the file will be processed with the default “Match Reads” settings.

- From: `\/1`
- To: `\/2`

Screenshot:

 ![manipulate-fasta-seq-name-string-translate](https://us1.discourse-cdn.com/flex020/uploads/galaxy/original/2X/7/720309ceb42a50afa64e8915239f103517847e4d.png)

Thanks!

---

<div class="post-metadata">

**Author:** ![miaeyaho](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/miaeyaho/32/1535_2.png) [@miaeyaho](https://help.galaxyproject.org/u/miaeyaho)\
**Post date:** [June 2, 2020, 1:53pm UTC](https://help.galaxyproject.org/t/how-to-change-fastq-header/3826/3 "2020-06-02T13:53:33Z")

</div>

Thank you Jennifer, but unfortunately things didn’t go well.  
I’ve got the error message of SyntaxError as below.

 ![image](https://us1.discourse-cdn.com/flex020/uploads/galaxy/original/2X/2/2175d26fafaa03086f5e66fe358897dfe493df5c.png)

What is the problem?  
Thanks,

Miae

---

<div class="post-metadata">

**Author:** ![jennaj](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/jennaj/32/27_2.png) [@jennaj](https://help.galaxyproject.org/u/jennaj)\
**Post date:** [June 2, 2020, 3:48pm UTC](https://help.galaxyproject.org/t/how-to-change-fastq-header/3826/4 "2020-06-02T15:48:10Z")

</div>

Hi @miaeyaho

The [usegalaxy.eu](http://usegalaxy.eu) server is pending some changes to adapt to Python 3. This error is related to that. Other tools may also fail for this same reason until addressed – possibly any written in Python. Ping @wm75 @bjoern.gruening @mvdbeek

For your purposes, try `Sed` instead. This is the “program” substitution expression to use. It is specific enough that quality scores will not be modified, just the format of your particular fastq sequence headers.

```
s/(^@[0-9]+)\/1$/\1\/2/ 

```

Screenshot:

 ![manipulate-fasta-seq-name-sed](https://us1.discourse-cdn.com/flex020/uploads/galaxy/original/2X/e/e1a816949f40a0288910cf825e6fae5285deec5a.png)

Please give that a try. Thanks!

---

<div class="post-metadata">

**Author:** ![miaeyaho](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/miaeyaho/32/1535_2.png) [@miaeyaho](https://help.galaxyproject.org/u/miaeyaho)\
**Post date:** [June 3, 2020, 2:05pm UTC](https://help.galaxyproject.org/t/how-to-change-fastq-header/3826/5 "2020-06-03T14:05:33Z")

</div>

Yes, it definitely worked!!!  
I’m really appreciated for your kind help. Thanks!

Miae

---

<div class="post-metadata">

**Author:** ![jennaj](https://sea2.discourse-cdn.com/flex020/user_avatar/help.galaxyproject.org/jennaj/32/27_2.png) [@jennaj](https://help.galaxyproject.org/u/jennaj)\
**Post date:** [October 13, 2022, 9:39pm UTC](https://help.galaxyproject.org/t/how-to-change-fastq-header/3826/6 "2022-10-13T21:39:45Z")

</div>


