Discussion line court and change context of huge data

I got a file named as data_file
Contents of data_file got about IGB reads.
The contents look like below:
+ABC_01
AABBCCDDEEFFPPOOLLKK
-ABC_01
hhhhhhhhhhhhhhhhhhhhh
+ACB_100
APPPPPPPPPPIIIPPOOLLKK
-ACB_100
hhhhhhhhhhHHHHHHHIhhh
+AEF_55
CCCCPPPCQQFFPPOOLLKK
-AEF_55
WEEGFVShhhhhhhhhhhhPP
.
.
.
.

By using the same contents of data_file, I would like to court line of "+A" in the file and change all of the "+A" to "@A" and print the line below the "+A".
This is the way I do for court line of data_file :

grep '^+A' data_file | wc -l

This is the way I do for change context of all the "+A" to "@A" and print the line below the "+A":

cat data_file | awk '/^+A/{getline;print}' | sed 's/^+A/^@A/g' > data_file.extract

My desired data_file.extract look like this:
@ABC_01
AABBCCDDEEFFPPOOLLKK
@ACB_100
APPPPPPPPPPIIIPPOOLLKK
@AEF_55
CCCCPPPCQQFFPPOOLLKK
.
.
.

Actually all of the code that I used are work perfectly for small data.
Unfortunately, when facing to huge data such as 1GB reads.
It takes a very long time for my code to line court and change context of the huge data.
Thus hopefully can discuss with all of the experts see whether got any fastest way to improve my code and to get my desired output.
Thanks again for all of your sharing.

Try :

awk '/^+A/{sub(/^+/, "@"); print;getline;print} ' data_file

Jean-Pierre.

Another approach:

awk 'NF{print "@" $1 "\n" $2}' RS="+" file

Hi aigles,
I just try your code.
Sad to said that it can't work :frowning:
Seem like the code got a bit problem :frowning:
Still thanks for your suggestion.

awk '/^+A/{sub(/^+/, "@"/); print;getline;print} ' data_file

---------- Post updated at 07:57 PM ---------- Previous update was at 07:54 PM ----------

Thanks a lot, Franklin52.
Your code work very fast and efficiently compare to my previous code.

awk 'NF{print "@" $1 "\n" $2}' RS="+" file

It just take few seconds to finish 1GB reads.
Really thanks for your help.
In between, do you have any better idea to faster the speed of specific line court of a huge data.
The code I used is :

grep '^+A' data_file | wc -l

aigles solution derivate

awk '/^\+A/{sub(/^\+/,"@");c++;print;getline;print}END{printf "Records Count: %d\n",c} ' file

Franklin52 solution derivate

awk 'NF{c++;printf "@%s\n%s\n",$1,$2}END{printf "Records Count: %d\n",c}' RS="+" file

Please fix the code tags in your last post.

There was an extra / in the sub statement :

awk '/^+A/{sub(/^+/, "@"); print;getline;print} ' data_file

Jean-Pierre.

You can try this:

awk '/^+A/{c++}END{print c}' data_file

Thanks a lot for your code, Franklin52

awk '/^+A/{c++}END{print c}' data_file

This code work faster than the grep function.
Hopefully still got few more ways to improve the line court speed :slight_smile: