How to change fastq header?

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

1 Like

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 … 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:

Thanks!

1 Like

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

What is the problem?
Thanks,

Miae

1 Like

Hi @miaeyaho

The 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:

Please give that a try. Thanks!

2 Likes

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

Miae

2 Likes