This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Extract the DNA sequence header!

I have question about our DNA sequence data. If the format of sequence data is

@HWI-ST1234:136:C5F6VACXX:6:1101:4121:2231 1:N:0:ACTTGA
TATGGGTTTCCACGGAGCACAGTGCCTAGTGCTCACTCCCCAGTTGTATCTTATTTTTCAGGTCAGCAGGTCGGGCCGGGAGTGTGACATGACGGAGCAGA
+
CCCFFFDDHHHHHJJGIJJJJJHIJJIJJHIJIJIJJJJJJIIIIJGIIBFHHFHJJJG>FHIJIGIIEHAHBBAB@BDBDD<?ACA>CDDDDDD5<BBD?.

I can extract the sequence identifier as @HWI-ST1234:136:C5F6VACXX:6:1101:4121:2231 1:N:0:ACTTGA using the code.

If the format of sequence data is

@HWI-ST1234:136:C5F6VACXX:6:1101:4295:2242 1:N:0:ACTTGA
AATACTTGTACGAGGGTGTTTTGCCACACCATATCTCATAAGGTGTGTTGGGTACATCTTTACTTGTCATTCTATTCAAAATATGTGTTGTTGTTTC
+
@@@ADD?DH8FH1CGG2A<F@FH?@?FC1DFGEDB9?BFHHIF?8?DBC=FB5@CDA;@)=.))..).;;B@B?@>>BDCCCCCD>B;?=5??<?CC

I can not extract the sequence identifier.

So I think the problem is the sequence data. The first symbol of second one is @. The first symbol of identifier also is @. So the code can not extract the correct sequencing identifier from our sequence data.

I want to extract the sequence identifier from my sequence data. The identifier format is @HWI-ST1234:136:C5F6VACXX:6:1101:4295:2242 1:N:0:ACTTGA. Could you help me do it?

Thanks,
Fuyou

genome fastq

Goutham and Ashutosh,

Thanks,

It is working.

2 answers

You just need to print the read name which is the first line of every 4 lines in fastq format. Something like:

awk '{if (NR%4==1) print}'​
cat Input.fastq | paste - - - - | cut -f1 > ReadIDs.txt

Goutham's solution that purely uses awk should be much faster.

Log in to answer this question.