My sed command won't execute a rename of fastq.gz files using a .txt file as a reference, but will show me a desirable output

I am looking to write some code using dummy samples that will look at a confusing fastq.gz filename and rename it based on it's corresponding simple sample ID from a .txt file that contains both. I will eventually do this in one pass for hundreds of files so I want to dial it in on something small and lowrisk. I have written some empty txt files to pose as my fastq.gz filenames. The reference .txt file contains both sequence and sample IDs. I want to read the sequence ID's find a match and edit the file name in my dummy file to match the corresponding Sample ID

An example of a line from my .txt file:

52704.3.422276.TTGCGAAG-TTGCGAAG.fastq.gz S19_BESC 156_B1_d1

I have written code that shows a rename, but when I add the 'e' flag to it, it does nothing or it tells me sed: -e expression #1, char 1: unknown command:m'`

I have written: sed 's/\(\w+\.fastq\.gz\)/${SeqID%.fastq.gz} ${SampleID}/' BESC-156_Swaps.txt

To give me a desirable output of:

52704.3.422276.TTGCGAAG-TTGCGAAG.fastq.gz       S19_BESC 156_B1_d1
52704.3.422276.ACATAGGC-ACATAGGC.fastq.gz       S19_BESC 156_B1_d3
52704.3.422276.GTTGTAGC-GTTGTAGC.fastq.gz       S19_BESC 156_B1_d6
52704.3.422276.ACCACGAT-ACCACGAT.fastq.gz       S19_BESC 156_B1_d9
52704.3.422276.CTGAAGCT-CTGAAGCT.fastq.gz       S19_BESC 156_B1_d12
52704.3.422276.TCCTTAGC-TCCTTAGC.fastq.gz       S19_BESC 156_B1_d15
52704.3.422276.ACGACTTG-ACGACTTG.fastq.gz       S19_BESC 156_B2_d1
52704.3.422276.TGCTTCCA-TGCTTCCA.fastq.gz       S19_BESC 156_B2_d3
52704.3.422276.GCATACAG-GCATACAG.fastq.gz       S19_BESC 156_B2_d6
52704.3.422276.CTTCGTTC-CTTCGTTC.fastq.gz       S19_BESC 156_B2_d9
52704.3.422276.TGCGAACT-TGCGAACT.fastq.gz       S19_BESC 156_B2_d12
52704.3.422276.CATCGTGA-CATCGTGA.fastq.gz       S19_BESC 156_B2_d15
52704.3.422276.TCTCCGAT-TCTCCGAT.fastq.gz       S19_BESC 156_B3_d1
52704.3.422276.AGAGTAGC-AGAGTAGC.fastq.gz       S19_BESC 156_B3_d3
52704.3.422276.CAACACCT-CAACACCT.fastq.gz       S19_BESC 156_B3_d6
52704.3.422276.TTGTGTGC-TTGTGTGC.fastq.gz       S19_BESC 156_B3_d9
52709.1.423639.ACTGCTAG-ACTGCTAG.fastq.gz       S19_BESC 156_B3_d12
52709.1.423639.GTCATCGA-GTCATCGA.fastq.gz       S19_BESC 156_B3_d15

But when I add the 'e' flag:

sed -e 's/\(\w+\.fastq\.gz\)/${SeqID%.fastq.gz} ${SampleID}/' BESC-156_Swaps.txt

I get nothing. Or if I do this:

sed 's/\(\w+\.fastq\.gz\)/${SeqID%.fastq.gz} ${SampleID}/' -e 'mv $1 $2' BESC-156_Swaps.txt

I get:

sed: -e expression #1, char 1: unknown command: m'`

Thank you in advance this type of code really gets me hung up.



Comments

Popular posts from this blog

Today Walkin 14th-Sept

Spring Elasticsearch Operations

Hibernate Search - Elasticsearch with JSON manipulation