I have the following tab vcf file example:
Chrom Pos
chr1 82689
chr1 82709
chr1 93583
chr1 94111
I would like it to look like this:
Chrom ID Pos
chr1 sample1_82689 82689
chr1 sample1_82709 82709
chr1 sample1_93583 93583
I have a sample names stored in a text file (136 of them), and have been using this code, when the job is ran in slurm array on the HPC, to extract the line of the ID associated with the array job number:
#!/bin/bash --login
#SBATCH --array=1-136
EXOME_IDs_FILE=/home/IDs.txt
sed -n "${SLURM_ARRAY_TASK_ID}p" $EXOME_IDs_FILE
This means that anytime {} occurs in my script, the ID from that file is extracted and can be used. Therefore, I can use that to insert the ID into the column but am struggling to figure out how to get the Pos value also into that ID column.
awk 'BEGIN{ FS=OFS="\t" } {$1 = $1 FS (NR==1? "sample_variantpos_ID" : "{}") }1' file.vcf > tmp && mv tmp file.vcf
However I do not know how to get the value of the Pos column to be attached to the ID file.