Skip to main content
added 5 characters in body
Source Link
terdon
  • 252.3k
  • 69
  • 480
  • 718

I believe you are looking for something like this:

#!/bin/bash

## Set the scriptHeader variable to hold the SBATCH commands you need
read -r -d '' scriptHeader <<EoF
#!/bin/bash

#SBATCH line 1
#SBATCH line 2
#SBATCH line 3
EoF

stuffPath=/Where/My/Stuff/Is
samplePath=/Where/My/Samples/Are
outputPath=/Where/I/Want/NewFile/To/Go


while read sampleName; do
  for ((chr=1; chr<=22; chr++)); do 
    command="$stuffPath/bcftools viewview"
 $thisSamplePath   inVCF="$thisSamplePath/$chr.vcf"
    thisSamplePath="$samplePath/${sampleName}_Samples.txt"
    thisOutputPath="$outputPath/${sampleName}_Chrom${chr}.vcf"

    printf '%s\n%s "%s" -S "%s" -o "%s"\n' "$scriptHeader" \
           "$command" \"$inVCF"\
           "$thisSamplePath/$chr.vcf" \
           "$thisOutputPath" > "$stuffPath/$sampleName.$chr.sh"
  done
done < "$samplePath"/FullSampleList.txt 

This will produce 22 files for each line in "$samplePath"/FullSampleList.txt. Each file will look like this:

#!/bin/bash
SBATCH line 1
SBATCH line 2
SBATCH line 3
/Where/My/Stuff/Is/bcftools view "/Where/My/Samples/Are/ACB_YRI_Samples.txt/6.vcfvcf" -S "/Where/My/Samples/Are/ACB_YRI_Samples.txt/6.vcf" -o "/Where/I/Want/NewFile/To/Go/ACB_YRI_Chrom6.vcf"

I believe you are looking for something like this:

#!/bin/bash

## Set the scriptHeader variable to hold the SBATCH commands you need
read -r -d '' scriptHeader <<EoF
#!/bin/bash

#SBATCH line 1
#SBATCH line 2
#SBATCH line 3
EoF

stuffPath=/Where/My/Stuff/Is
samplePath=/Where/My/Samples/Are
outputPath=/Where/I/Want/NewFile/To/Go


while read sampleName; do
  for ((chr=1; chr<=22; chr++)); do 
    command="$stuffPath/bcftools view $thisSamplePath/$chr.vcf"
    thisSamplePath="$samplePath/${sampleName}_Samples.txt"
    thisOutputPath="$outputPath/${sampleName}_Chrom${chr}.vcf"

    printf '%s\n%s -S "%s" -o "%s"\n' "$scriptHeader" \
           "$command" \
           "$thisSamplePath/$chr.vcf" \
           "$thisOutputPath" > "$stuffPath/$sampleName.$chr.sh"
  done
done < "$samplePath"/FullSampleList.txt 

This will produce 22 files for each line in "$samplePath"/FullSampleList.txt. Each file will look like this:

#!/bin/bash
SBATCH line 1
SBATCH line 2
SBATCH line 3
/Where/My/Stuff/Is/bcftools view /Where/My/Samples/Are/ACB_YRI_Samples.txt/6.vcf -S "/Where/My/Samples/Are/ACB_YRI_Samples.txt/6.vcf" -o "/Where/I/Want/NewFile/To/Go/ACB_YRI_Chrom6.vcf"

I believe you are looking for something like this:

#!/bin/bash

## Set the scriptHeader variable to hold the SBATCH commands you need
read -r -d '' scriptHeader <<EoF
#!/bin/bash

#SBATCH line 1
#SBATCH line 2
#SBATCH line 3
EoF

stuffPath=/Where/My/Stuff/Is
samplePath=/Where/My/Samples/Are
outputPath=/Where/I/Want/NewFile/To/Go


while read sampleName; do
  for ((chr=1; chr<=22; chr++)); do 
    command="$stuffPath/bcftools view"
    inVCF="$thisSamplePath/$chr.vcf"
    thisSamplePath="$samplePath/${sampleName}_Samples.txt"
    thisOutputPath="$outputPath/${sampleName}_Chrom${chr}.vcf"

    printf '%s\n%s "%s" -S "%s" -o "%s"\n' "$scriptHeader" \
           "$command" "$inVCF"\
           "$thisSamplePath/$chr.vcf" \
           "$thisOutputPath" > "$stuffPath/$sampleName.$chr.sh"
  done
done < "$samplePath"/FullSampleList.txt 

This will produce 22 files for each line in "$samplePath"/FullSampleList.txt. Each file will look like this:

#!/bin/bash
SBATCH line 1
SBATCH line 2
SBATCH line 3
/Where/My/Stuff/Is/bcftools view "/Where/My/Samples/Are/ACB_YRI_Samples.txt/6.vcf" -S "/Where/My/Samples/Are/ACB_YRI_Samples.txt/6.vcf" -o "/Where/I/Want/NewFile/To/Go/ACB_YRI_Chrom6.vcf"
added 5 characters in body
Source Link
terdon
  • 252.3k
  • 69
  • 480
  • 718

I believe you are looking for something like this:

#!/bin/bash

## Set the sbatchscriptHeader variable to hold the SBATCH commands you need
read -r -d '' scriptHeader <<EoF
#!/bin/bash
SBATCH
#SBATCH line 1
SBATCH#SBATCH line 2
SBATCH#SBATCH line 3
EoF

stuffPath=/Where/My/Stuff/Is
samplePath=/Where/My/Samples/Are
outputPath=/Where/I/Want/NewFile/To/Go


while read sampleName; do
  for ((chr=1; chr<=22; chr++)); do 
    command="$stuffPath/bcftools view $thisSamplePath/$chr.vcf"
    thisSamplePath="$samplePath/${sampleName}_Samples.txt"
    thisOutputPath="$outputPath/${sampleName}_Chrom${chr}.vcf"

    printf '%s\n%s -S "%s" -o "%s"\n' "$scriptHeader" \
           "$command" \
           "$thisSamplePath/$chr.vcf" \
           "$thisOutputPath" > "$stuffPath/$sampleName.$chr.sh"
  done
done < "$samplePath"/FullSampleList.txt 

This will produce 22 files for each line in "$samplePath"/FullSampleList.txt. Each file will look like this:

#!/bin/bash
SBATCH line 1
SBATCH line 2
SBATCH line 3
/Where/My/Stuff/Is/bcftools view /Where/My/Samples/Are/ACB_YRI_Samples.txt/6.vcf -S "/Where/My/Samples/Are/ACB_YRI_Samples.txt/6.vcf" -o "/Where/I/Want/NewFile/To/Go/ACB_YRI_Chrom6.vcf"

I believe you are looking for something like this:

#!/bin/bash

## Set the sbatch variable to hold the SBATCH commands you need
read -r -d '' scriptHeader <<EoF
#!/bin/bash
SBATCH line 1
SBATCH line 2
SBATCH line 3
EoF

stuffPath=/Where/My/Stuff/Is
samplePath=/Where/My/Samples/Are
outputPath=/Where/I/Want/NewFile/To/Go


while read sampleName; do
  for ((chr=1; chr<=22; chr++)); do 
    command="$stuffPath/bcftools view $thisSamplePath/$chr.vcf"
    thisSamplePath="$samplePath/${sampleName}_Samples.txt"
    thisOutputPath="$outputPath/${sampleName}_Chrom${chr}.vcf"

    printf '%s\n%s -S "%s" -o "%s"\n' "$scriptHeader" \
           "$command" \
           "$thisSamplePath/$chr.vcf" \
           "$thisOutputPath" > "$stuffPath/$sampleName.$chr.sh"
  done
done < "$samplePath"/FullSampleList.txt 

I believe you are looking for something like this:

#!/bin/bash

## Set the scriptHeader variable to hold the SBATCH commands you need
read -r -d '' scriptHeader <<EoF
#!/bin/bash

#SBATCH line 1
#SBATCH line 2
#SBATCH line 3
EoF

stuffPath=/Where/My/Stuff/Is
samplePath=/Where/My/Samples/Are
outputPath=/Where/I/Want/NewFile/To/Go


while read sampleName; do
  for ((chr=1; chr<=22; chr++)); do 
    command="$stuffPath/bcftools view $thisSamplePath/$chr.vcf"
    thisSamplePath="$samplePath/${sampleName}_Samples.txt"
    thisOutputPath="$outputPath/${sampleName}_Chrom${chr}.vcf"

    printf '%s\n%s -S "%s" -o "%s"\n' "$scriptHeader" \
           "$command" \
           "$thisSamplePath/$chr.vcf" \
           "$thisOutputPath" > "$stuffPath/$sampleName.$chr.sh"
  done
done < "$samplePath"/FullSampleList.txt 

This will produce 22 files for each line in "$samplePath"/FullSampleList.txt. Each file will look like this:

#!/bin/bash
SBATCH line 1
SBATCH line 2
SBATCH line 3
/Where/My/Stuff/Is/bcftools view /Where/My/Samples/Are/ACB_YRI_Samples.txt/6.vcf -S "/Where/My/Samples/Are/ACB_YRI_Samples.txt/6.vcf" -o "/Where/I/Want/NewFile/To/Go/ACB_YRI_Chrom6.vcf"
Source Link
terdon
  • 252.3k
  • 69
  • 480
  • 718

I believe you are looking for something like this:

#!/bin/bash

## Set the sbatch variable to hold the SBATCH commands you need
read -r -d '' scriptHeader <<EoF
#!/bin/bash
SBATCH line 1
SBATCH line 2
SBATCH line 3
EoF

stuffPath=/Where/My/Stuff/Is
samplePath=/Where/My/Samples/Are
outputPath=/Where/I/Want/NewFile/To/Go


while read sampleName; do
  for ((chr=1; chr<=22; chr++)); do 
    command="$stuffPath/bcftools view $thisSamplePath/$chr.vcf"
    thisSamplePath="$samplePath/${sampleName}_Samples.txt"
    thisOutputPath="$outputPath/${sampleName}_Chrom${chr}.vcf"

    printf '%s\n%s -S "%s" -o "%s"\n' "$scriptHeader" \
           "$command" \
           "$thisSamplePath/$chr.vcf" \
           "$thisOutputPath" > "$stuffPath/$sampleName.$chr.sh"
  done
done < "$samplePath"/FullSampleList.txt