This is a test version of Biostars. For the public version, visit https://www.biostars.org.
cat command to get multiple fq reads into single fastq file

Hi,

file names are like this:

Root_T1_S_R8_S48_unmapped.R1.fq
Root_T1_S_R9_S47_unmapped.R1.fq
Root_T2_F_R2_S25_unmapped.R2.fq
Root_T2_F_R3_S24_unmapped.R2.fq

I need to take Multiple R1.fq and R2.fq into two separate files to run trinity for de novo assembly.

I am little bit confused, which command is correct? should I use double arrow or single arrow?
cat *.R2.fq >>right.fq
cat *.R2.fq > right.fq

cat *.R1.fq >leftt.fq
cat *.R1.fq >>left.fq

thanks

rna-seq linux

The S* numbers are added by Illumina's post-processing software depending on the location of that sample (and its index) in SampleSheet.csv used for demultiplexing. If these are separate samples i.e. if R* has any meaning then you should not be concatenating these files.

If these are replicates of some conditions use as shown in trinity manual :

--samples_file <string>         tab-delimited text file indicating biological replicate relationships.
 #                                   ex.
 #                                        cond_A    cond_A_rep1    A_rep1_left.fq    A_rep1_right.fq
 #                                        cond_A    cond_A_rep2    A_rep2_left.fq    A_rep2_right.fq
 #                                        cond_B    cond_B_rep1    B_rep1_left.fq    B_rep1_right.fq
 #                                        cond_B    cond_B_rep2    B_rep2_left.fq    B_rep2_right.fq
 #

or you could specify multiple files on command line:

 Trinity --seqType fq --max_memory 50G  \
         --left condA_1.fq.gz,condB_1.fq.gz,condC_1.fq.gz \
         --right condA_2.fq.gz,condB_2.fq.gz,condC_2.fq.gz

1 answer

Both are fine in your example since you're using cat once for all read files. If you were to loop over the files

for f in $(ls *.R2.fq); do cat $f > right.fq; done

would overwrite right.fq in each iteration, whereas using >> would actually concatenate.

An alternative for the loop would be

for f in $(ls *.R2.fq); do cat $f; done > right.fq

in which case all files would be concatenated.

Log in to answer this question.