for loop in a bash script

for loop in a bash script

0

Hi!
I have this bash script which is just for one file and I want to use for a multiple files in a folder. I have been trying with the for loop, but my script does not work. THanks in advance!

#!/bin/bash

# USAGE
# sh getSNPs_and_clean.sh vcf output_path
## Note this only works when we use chromosomes with sites to be exchanged
## Note this only works on one chromosome VCF

FILE=$1; # A VCF file multisample or mono sample

OUTPUT_PATH=$2;

file_name=${FILE%.vcf*};
file_name=${file_name##*/};

# SNPs
bcftools view --threads 40 -m2 -M2 -v snps -Oz -o ${OUTPUT_PATH}/${file_name}.snps.vcf.gz ${FILE}
bcftools index --threads 40 ${OUTPUT_PATH}/${file_name}.snps.vcf.gz
bcftools view --threads 40 -e 'POS=80294998' -Oz -o ${OUTPUT_PATH}/${file_name}.snpsTMP.vcf.gz ${OUTPUT_PATH}/${file_name}.snps.vcf.gz # without duplicates
mv -f ${OUTPUT_PATH}/${file_name}.snpsTMP.vcf.gz ${OUTPUT_PATH}/${file_name}.snps.vcf.gz
bcftools index --threads 40 ${OUTPUT_PATH}/${file_name}.snps.vcf.gz

echo "${FILE} completed!"


bash


for


script


loop

• 53 views


updated 1 hour ago by

107k

written 2 hours ago by

0

Read more here: Source link