This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How To Extracting Fastq Sequence For Given Fastq Ids And Fastq File

I have a text file which contain fastq ids and another file is my original fastq file which is approx 14GB. Is there any efficient program which could help me to extract fastq seq according to my IDs are like:

@lcl|SRR681003.3 SN603:5:1101:47.10:122.20 length=100

@lcl|SRR681003.14 SN603:5:1101:57.10:114.60 length=100

@lcl|SRR681003.16 SN603:5:1101:72.70:115.10 length=100

@lcl|SRR681003.19 SN603:5:1101:54.80:117.50 length=100

@lcl|SRR681003.22 SN603:5:1101:50.60:119.00 length=100

it is very easy to extract fasta seq for given id by using fastacmd but no idea how to extract fastq files of desire ids

fastq

do you need a system to extract those ids often (like fasttacmd , and you need an index) or do you just need to grep the file ?

Dear Sir, I want to grep it. by using awk or grep shell command

Sir, for single read it dooing perfectly well grep -e "@SRR681003.7 SN603:5:1101:70.90:105.60 length=100" -A 3 che.fastq > output.fastq but when I am giving it as whole id.txt like grep -f id.txt -A 3 che.fastq > out.fastq it dumped entire file as it is, I am missing matching part i think please help me out sir thnQ

Please post this comment to the original answer. I am sure, you will get some coe in response, if not send me a PM over the site.

Dear raghvendra, this question has been asked and answered already on this site: How to efficiently parse a huge fastq file?, How to extract a subset of reads in fastq using an ID list?, How to extract set of reads from fastq (or eventually fasta and qual) based on list of ids?, or extracting a subset of sequences from a FASTQ file (BioPython speed). You should be able to find the information you are looking for by searching for "fastq extract" easily.

As an experienced user, you are recommended to study the site search. I will close this question in order to avoid further duplication and confusion. I hope you understand my motivation for this descision. Please feel free to post a comment if you do not agree with it or want to refine your question.

Dear Sir, I understand and realized, I must avoid such type of duplicate questions which definitely create confusion for new users, thank sir I will keep it in mind further,

Don't worry, this happened to almost everyone I believe.

1 answer

lh3's seqtk can do this. See here: https://github.com/lh3/seqtk

with the example:

Extract sequences with names in file name.lst, one sequence name per line:

seqtk subseq in.fq name.lst > out.fq

Dear Sir, it is good tool :) thnQ

great information, thank you. Although this works is simple, but with great tools will simplify further! It is worth to look around here.

Log in to answer this question.