0

I have FASTQ formatted Illumina sequence file like this:

@ERR009148.2485 IL26_1382:7:1:224:616 length=36
ATCACATGCTCCTTGTTCTGCAGCTTGGTGCGGATG
+ERR009148.2485 IL26_1382:7:1:224:616 length=36
>>>>>>>>>>>>>>>>>>><>><>>>5>>->><->*
@ERR009148.2486 IL26_1382:7:1:914:59 length=36
AAAGAAGTAAAATAAGAAGGCAATGCTTGTGGAAGG
+ERR009148.2486 IL26_1382:7:1:914:59 length=36
.>>74::1>174151/7152313,3&003,00&2%2
@ERR009148.2487 IL26_1382:7:1:251:589 length=36
GCCATAAACACCCCAGCACCACATTCATCAGAAGGG
+ERR009148.2487 IL26_1382:7:1:251:589 length=36
>>>>>>>>>>>>>>>>>>>>>>8>>>>>>><;<>>7
@ERR009148.2488 IL26_1382:7:1:911:194 length=36
ATTGAGGTGGAGTAGATTAGGCGTAGGTAGAAGTAG
+ERR009148.2488 IL26_1382:7:1:911:194 length=36
<>>>=>>>>>>>=;<:>>7>==<<7;=67=/57/57

I need to extract only the raw sequences from each record. What sed command can be used for that?

Expected output:

ATCACATGCTCCTTGTTCTGCAGCTTGGTGCGGATG
AAAGAAGTAAAATAAGAAGGCAATGCTTGTGGAAGG
GCCATAAACACCCCAGCACCACATTCATCAGAAGGG
ATTGAGGTGGAGTAGATTAGGCGTAGGTAGAAGTAG
  • add expected output for clarity... – Sundeep Oct 13 '17 at 5:55
2

Using sed.

sed -n '/^[ATGC]/p' infile

Using grep:

grep '^[ATGC]' infile

Using awk:

awk '/^[ATGC]/' infile

All will return those lines that starts with one of A, C, T, G letters.

2

You want to extract the raw sequence line from a FASTQ formatted file:

Assuming no blank lines in the file, using GNU sed:

$ sed -n '2~4p' file.fastq
ATCACATGCTCCTTGTTCTGCAGCTTGGTGCGGATG
AAAGAAGTAAAATAAGAAGGCAATGCTTGTGGAAGG
GCCATAAACACCCCAGCACCACATTCATCAGAAGGG
ATTGAGGTGGAGTAGATTAGGCGTAGGTAGAAGTAG

The expression 2~4p will print (p) every 4th line (~4) starting at line 2 in the input data.

If you want to be a bit more specific and get the line after each line starting with @:

$ sed -n '/^@/{n;p;}' file.fastq

This will locate the lines starting with the @ character, and when one such line is found, the next line is read (n) and printed.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.