Entering edit mode
4.5 years ago
mukil.biotek
▴
10
Hi all, I have fastq.gz files and I need to rename it
The read names in my files are
389817_001_E01_S49_R1_001.fastq.gz
389817_001_E01_S49_R2_001.fastq.gz
389818_001_A01_S1_R1_001.fastq.gz
389818_001_A01_S1_R2_001.fastq.gz
And i want to transform them in the format:
389817_S49_L001_R1_001.fastq.gz
389817_S49_L001_R2_001.fastq.gz
389818_S1_L001_R1_001.fastq.gz
389818_S1_L001_R2_001.fastq.gz
I tried using python but not working..see below for codes
import os
for i in os.listdir():
file_name, file_ext = os.path.splitext(i)
print(os.path.splitext(i))
file_name, file_ext = os.path.splitext(i)
print(file_name)
file_name1, file_ext1 = os.path.splitext(file_name)
file_name1
file_ext1
print(file_name1.split('_'))
f_0, f_1, f_2, f_3, f_4, f_5 = file_name1.split('_')
new_name = print(os.path.join(f_0+'_'+f_3+'_'+'L001'+'_'+f_4+'_'+f_5+file_ext1+file_ext))
path = '/Users/mukilkavi/Desktop/NAMING'
os.rename('/Users/mukilkavi/Desktop/NAMING/', new_name)
Any advice will be appreciated...Thanks in advance
I don't know python, but shouldn't that last line concatenate the path and the 'i' file name, and that's the input into os.rename?
How many of these files need renaming? If it is only what you listed, a simple
mv
command may be good enough.mv 389817_001_E01_S49_R1_001.fastq.gz 389817_S49_L001_R1_001.fastq.gz