Skip to main content
added 8 characters in body
Source Link

I'm trying to set up a for loop to run a process on pairs of files. The names of the files look like this

 36_002_CGATGT_L001_R1_005.fastq.gz 36_002_CGATGT_L001_R2_005.fastq.gz 36_002_CGATGT_L001_R1_002.fastq.gz 36_002_CGATGT_L001_R2_002.fastq.gz 62_013_AGTCAA_L001_R1_003.fastq.gz 62_013_AGTCAA_L001_R2_003.fastq.gz 

I need to use each pair in the following command

sickle pe -f 36_002_CGATGT_L001_R1_005.fastq.gz \ -r 36_002_CGATGT_L001_R2_005.fastq.gz\ -o trimmed_36_002_CGATGT_L001_R1_005.fastq.gz\ -p 36_002_CGATGT_L001_R2_005trimmed_36_002_CGATGT_L001_R2_005.fastq.gz\ -s 36_002_CGATGT_L001_singles_005.fastq.gz 

To begin with I'm trying:

for n in *R1*; do m='basename $n R2' ; echo $m; done 

but clearly this approach isn't working because the both the front and back of the file name are important. Do I need to rename files so the R1 and R2 are the last part of the name? Which would be awkward but not impossible

I'm trying to set up a for loop to run a process on pairs of files. The names of the files look like this

 36_002_CGATGT_L001_R1_005.fastq.gz 36_002_CGATGT_L001_R2_005.fastq.gz 36_002_CGATGT_L001_R1_002.fastq.gz 36_002_CGATGT_L001_R2_002.fastq.gz 62_013_AGTCAA_L001_R1_003.fastq.gz 62_013_AGTCAA_L001_R2_003.fastq.gz 

I need to use each pair in the following command

sickle pe -f 36_002_CGATGT_L001_R1_005.fastq.gz \ -r 36_002_CGATGT_L001_R2_005.fastq.gz\ -o trimmed_36_002_CGATGT_L001_R1_005.fastq.gz\ -p 36_002_CGATGT_L001_R2_005.fastq.gz\ -s 36_002_CGATGT_L001_singles_005.fastq.gz 

To begin with I'm trying:

for n in *R1*; do m='basename $n R2' ; echo $m; done 

but clearly this approach isn't working because the both the front and back of the file name are important. Do I need to rename files so the R1 and R2 are the last part of the name? Which would be awkward but not impossible

I'm trying to set up a for loop to run a process on pairs of files. The names of the files look like this

 36_002_CGATGT_L001_R1_005.fastq.gz 36_002_CGATGT_L001_R2_005.fastq.gz 36_002_CGATGT_L001_R1_002.fastq.gz 36_002_CGATGT_L001_R2_002.fastq.gz 62_013_AGTCAA_L001_R1_003.fastq.gz 62_013_AGTCAA_L001_R2_003.fastq.gz 

I need to use each pair in the following command

sickle pe -f 36_002_CGATGT_L001_R1_005.fastq.gz \ -r 36_002_CGATGT_L001_R2_005.fastq.gz\ -o trimmed_36_002_CGATGT_L001_R1_005.fastq.gz\ -p trimmed_36_002_CGATGT_L001_R2_005.fastq.gz\ -s 36_002_CGATGT_L001_singles_005.fastq.gz 

To begin with I'm trying:

for n in *R1*; do m='basename $n R2' ; echo $m; done 

but clearly this approach isn't working because the both the front and back of the file name are important. Do I need to rename files so the R1 and R2 are the last part of the name? Which would be awkward but not impossible

edited tags
Link
added 51 characters in body
Source Link
Stéphane Chazelas
  • 586.3k
  • 96
  • 1.1k
  • 1.7k

I'm trying to set up a for loop to run a process on pairs of files. The names of the files look like this

36_002_CGATGT_L001_R1_005.fastq.gz

36_002_CGATGT_L001_R2_005.fastq.gz

36_002_CGATGT_L001_R1_002.fastq.gz

36_002_CGATGT_L001_R2_002.fastq.gz

62_013_AGTCAA_L001_R1_003.fastq.gz

62_013_AGTCAA_L001_R2_003.fastq.gz

 36_002_CGATGT_L001_R1_005.fastq.gz 36_002_CGATGT_L001_R2_005.fastq.gz 36_002_CGATGT_L001_R1_002.fastq.gz 36_002_CGATGT_L001_R2_002.fastq.gz 62_013_AGTCAA_L001_R1_003.fastq.gz 62_013_AGTCAA_L001_R2_003.fastq.gz 

I need to use each pair in the following command

sickle pe -f 36_002_CGATGT_L001_R1_005.fastq.gz \ -r 36_002_CGATGT_L001_R2_005.fastq.gz\ -o trimmed_36_002_CGATGT_L001_R1_005.fastq.gz\ -p 36_002_CGATGT_L001_R2_005.fastq.gz\ -s 36_002_CGATGT_L001_singles_005.fastq.gz 

To begin with I'm trying:

for n in *R1*; do m='basename $n R2' ; echo $m; done 

but clearly this approach isn't working because the both the front and back of the file name are important. Do I need to rename files so the R1 and R2 are the last part of the name? Which would be awkward but not impossible

I'm trying to set up a for loop to run a process on pairs of files. The names of the files look like this

36_002_CGATGT_L001_R1_005.fastq.gz

36_002_CGATGT_L001_R2_005.fastq.gz

36_002_CGATGT_L001_R1_002.fastq.gz

36_002_CGATGT_L001_R2_002.fastq.gz

62_013_AGTCAA_L001_R1_003.fastq.gz

62_013_AGTCAA_L001_R2_003.fastq.gz

I need to use each pair in the following command

sickle pe -f 36_002_CGATGT_L001_R1_005.fastq.gz \ -r 36_002_CGATGT_L001_R2_005.fastq.gz\ -o trimmed_36_002_CGATGT_L001_R1_005.fastq.gz\ -p 36_002_CGATGT_L001_R2_005.fastq.gz\ -s 36_002_CGATGT_L001_singles_005.fastq.gz 

To begin with I'm trying:

for n in *R1*; do m='basename $n R2' ; echo $m; done 

but clearly this approach isn't working because the both the front and back of the file name are important. Do I need to rename files so the R1 and R2 are the last part of the name? Which would be awkward but not impossible

I'm trying to set up a for loop to run a process on pairs of files. The names of the files look like this

 36_002_CGATGT_L001_R1_005.fastq.gz 36_002_CGATGT_L001_R2_005.fastq.gz 36_002_CGATGT_L001_R1_002.fastq.gz 36_002_CGATGT_L001_R2_002.fastq.gz 62_013_AGTCAA_L001_R1_003.fastq.gz 62_013_AGTCAA_L001_R2_003.fastq.gz 

I need to use each pair in the following command

sickle pe -f 36_002_CGATGT_L001_R1_005.fastq.gz \ -r 36_002_CGATGT_L001_R2_005.fastq.gz\ -o trimmed_36_002_CGATGT_L001_R1_005.fastq.gz\ -p 36_002_CGATGT_L001_R2_005.fastq.gz\ -s 36_002_CGATGT_L001_singles_005.fastq.gz 

To begin with I'm trying:

for n in *R1*; do m='basename $n R2' ; echo $m; done 

but clearly this approach isn't working because the both the front and back of the file name are important. Do I need to rename files so the R1 and R2 are the last part of the name? Which would be awkward but not impossible

added 8 characters in body
Source Link
Loading
Source Link
Loading