macros.xml0:
## Something like CMC_20E1_R1.fastq.gz
#set sample_name = $sample_name.split('_R1')[0]
#else if $sample_name.find(".") > 0:
#if $read1.is_of_type('fastqsanger.gz'):
## Something like my_sample.fastq.gz
#set sample_name = '.'.join($sample_name.split('.')[0:-2])
#else:
## Something like my_sample.fastq
#set sample_name = $os.path.splitext($sample_name)[0]
#end if
#else if $sample_name.find("_") > 0:
#if $read1.is_of_type('fastqsanger.gz'):
## Something like my_sample_fastq_gz
#set sample_name = '_'.join($sample_name.split('_')[0:-2])
#else:
## Something like my_sample_fastq
#set sample_name = "_".join($sample_name.split("_")[0:-1])
#end if
#end if
echo '$sample_name' > '$output'
]]>
**What it does**
Accepts fastqsanger sample files, extracts a unique portion of the file name as the sample name, and writes it to
the output. The output text file can be consumed by the **Parse parameter value** expression tool to provide workflow
parameter values to the **Read group identifier (ID)** and the **Sample name identifier (SM)** parameters in the
**Map with BWA-MEM** tool.